Skip to content

Commit 1877b1b

Browse files
committed
add user endpoints
1 parent 3debeab commit 1877b1b

19 files changed

+432
-65
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.wuhewuhe</groupId>
88
<artifactId>bybit-java-api</artifactId>
9-
<version>1.2.6</version>
9+
<version>1.2.7-SNAPSHOT</version>
1010
<name>bybit-java-api</name>
1111
<url>https://github.com/wuhewuhe/bybit-java-api</url>
1212

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
11
/**
2-
* Request Parameters
3-
* Parameter Required Type Comments
4-
* coin true string Coin
5-
* chain true string Chain
6-
* address true string Wallet address. Please note that the address is case sensitive, so use the exact same address added in address book
7-
* tag false string Tag
8-
* Required if tag exists in the wallet address list.
9-
* Note: please do not set a tag/memo in the address book if the chain does not support tag
10-
* amount true string Withdraw amount
11-
* timestamp true integer Current timestamp (ms). Used for preventing from withdraw replay
12-
* forceChain false integer Whether or not to force an on-chain withdrawal
13-
* 0(default): If the address is parsed out to be an internal address, then internal transfer
14-
* 1: Force the withdrawal to occur on-chain
15-
* accountType false string Select the wallet to be withdrawn from
16-
* SPOT:spot wallet (default)
17-
* FUND:Funding wallet
18-
* feeType false integer Handling fee option
19-
* 0(default): input amount is the actual amount received, so you have to calculate handling fee manually
20-
* 1: input amount is not the actual amount you received, the system will help to deduct the handling fee automatically
21-
* Response Parameters
22-
* Parameter Type Comments
23-
* id string Withdrawal ID
2+
Request Parameters
3+
Parameter Required Type Comments
4+
coin true string Coin, uppercase only
5+
chain false string Chain
6+
forceChain=0 or 1: this field is required
7+
forceChain=2: this field can be null
8+
address true string
9+
forceChain=0 or 1: fill wallet address, and make sure you add address in the address book first. Please note that the address is case sensitive, so use the exact same address added in address book
10+
forceChain=2: fill Bybit UID, and it can only be another Bybit main account UID. Make sure you add UID in the address book first
11+
tag false string Tag
12+
Required if tag exists in the wallet address list.
13+
Note: please do not set a tag/memo in the address book if the chain does not support tag
14+
amount true string Withdraw amount
15+
timestamp true integer Current timestamp (ms). Used for preventing from withdraw replay
16+
forceChain false integer Whether or not to force an on-chain withdrawal
17+
0(default): If the address is parsed out to be an internal address, then internal transfer
18+
1: Force the withdrawal to occur on-chain
19+
2: Use UID to withdraw
20+
accountType false string Select the wallet to be withdrawn from
21+
SPOT:spot wallet (default)
22+
FUND:Funding wallet
23+
feeType false integer Handling fee option
24+
0(default): input amount is the actual amount received, so you have to calculate handling fee manually
25+
1: input amount is not the actual amount you received, the system will help to deduct the handling fee automatically
26+
requestId false string Customised ID, globally unique, it is used for idempotent verification
27+
A combination of letters (case sensitive) and numbers, which can be pure letters or pure numbers and the length must be between 1 and 32 digits
28+
beneficiary false Object Travel rule info, only required for kyc=KOR (korean) users
29+
> vaspEntityId true string Receiver exchange entity Id. Please call this endpoint to get this ID
30+
> beneficiaryName false string Receiver exchange user KYC name, like John Wilson or Wilson John
31+
Please refer to target exchange kyc name
32+
When vaspEntityId="others", this field can be null
2433
*/
2534
package com.bybit.api.client.domain.asset.request;
2635

2736
import com.fasterxml.jackson.annotation.JsonInclude;
37+
import com.fasterxml.jackson.annotation.JsonProperty;
2838
import lombok.Builder;
2939
import lombok.Getter;
3040
import lombok.Setter;
3141
import lombok.ToString;
3242

43+
import java.util.List;
44+
import java.util.Map;
45+
3346
@Getter
3447
@Setter
3548
@ToString
@@ -45,5 +58,7 @@ public class AssetWithdrawRequest {
4558
private Integer forceChain;
4659
private String accountType;
4760
private Integer feeType;
48-
private Beneficiary beneficiary;
61+
private String requestId; // not required
62+
@JsonProperty("beneficiary")
63+
private Map<String, String> beneficiaryMap; // not required
4964
}

src/main/java/com/bybit/api/client/domain/user/UserDataRequest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.bybit.api.client.domain.user;
22

3+
import com.fasterxml.jackson.annotation.JsonInclude;
34
import lombok.Builder;
45
import lombok.Getter;
56
import lombok.Setter;
@@ -11,6 +12,7 @@
1112
@Setter
1213
@ToString
1314
@Builder
15+
@JsonInclude(JsonInclude.Include.NON_NULL)
1416
public class UserDataRequest {
1517
private String username;
1618
private String password;
@@ -28,4 +30,9 @@ public class UserDataRequest {
2830
private String apikey;
2931
private ReadOnlyStatus readOnlyStatus;
3032
private String uid;
33+
private String subMemberId;
34+
private Integer limit;
35+
private String pageSize;
36+
private String nextCursor;
37+
private String cursor;
3138
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
package com.bybit.api.client.domain.user.request;
2-
3-
import com.fasterxml.jackson.annotation.JsonInclude;
4-
import lombok.Builder;
5-
import lombok.Getter;
6-
import lombok.Setter;
7-
import lombok.ToString;
8-
9-
import java.util.List;
10-
import java.util.Map;
11-
12-
@Getter
13-
@Setter
14-
@ToString
15-
@Builder
16-
@JsonInclude(JsonInclude.Include.NON_NULL)
17-
public class CreateApiKeyRequest {
18-
19-
private Integer subuid; // required
20-
private String note;
21-
private Integer readOnly; // required
22-
private String ips;
23-
private Map<String, List<String>> permissions; // required
24-
}
25-
26-
1+
package com.bybit.api.client.domain.user.request;
2+
3+
import com.bybit.api.client.domain.user.SubUserPermissions;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import lombok.Builder;
7+
import lombok.Getter;
8+
import lombok.Setter;
9+
import lombok.ToString;
10+
11+
import java.util.List;
12+
import java.util.Map;
13+
14+
@Getter
15+
@Setter
16+
@ToString
17+
@Builder
18+
@JsonInclude(JsonInclude.Include.NON_NULL)
19+
public class CreateSubApiKeyRequest {
20+
private Integer subuid; // required
21+
private String note;
22+
private Integer readOnly; // required
23+
private String ips;
24+
@JsonProperty("permissions")
25+
private Map<String, List<String>> permissions; // required
26+
}
27+
28+

src/main/java/com/bybit/api/client/domain/user/request/ModifyApiKeyRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.bybit.api.client.domain.user.request;
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
45
import lombok.Builder;
56
import lombok.Getter;
67
import lombok.Setter;
@@ -17,5 +18,6 @@ public class ModifyApiKeyRequest {
1718
private Integer readOnly;
1819
private String ips;
1920
private String apikey;
21+
@JsonProperty("permissions")
2022
private Map<String, List<String>> permissionsMap;
2123
}

src/main/java/com/bybit/api/client/impl/BybitApiAsyncUserRestClientImpl.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,27 @@ public void deleteSubApiKey(UserDataRequest userDataRequest, BybitApiCallback<Ob
164164
public void getAffiliateUserInfo(UserDataRequest userDataRequest, BybitApiCallback<Object> callback) {
165165
bybitApiService.getAffiliateUserInfo(userDataRequest.getUid()).enqueue(new BybitApiCallbackAdapter<>(callback));
166166
}
167+
168+
@Override
169+
public void getSubUIDListUnlimited(UserDataRequest subUserRequest, BybitApiCallback<Object> callback) {
170+
bybitApiService.getSubUIDListUnlimited(
171+
subUserRequest.getPageSize(),
172+
subUserRequest.getNextCursor()
173+
).enqueue(new BybitApiCallbackAdapter<>(callback));
174+
}
175+
176+
@Override
177+
public void getSubUIDListUnlimited(BybitApiCallback<Object> callback) {
178+
bybitApiService.getSubUIDListUnlimited().enqueue(new BybitApiCallbackAdapter<>(callback));
179+
}
180+
181+
@Override
182+
public void getSubAccAllAPIKeyInfo(UserDataRequest subUserRequest, BybitApiCallback<Object> callback) {
183+
bybitApiService.getSubAccAllAPIKeyInfo(
184+
subUserRequest.getSubMemberId(),
185+
subUserRequest.getLimit(),
186+
subUserRequest.getCursor()
187+
).enqueue(new BybitApiCallbackAdapter<>(callback));
188+
189+
}
167190
}

src/main/java/com/bybit/api/client/impl/BybitApiUserRestClientImpl.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,28 @@ public Object getSubUIDList() {
3434
return executeSync(bybitApiService.getSubUIDList());
3535
}
3636

37+
@Override
38+
public Object getSubUIDListUnlimited(UserDataRequest subUserRequest) {
39+
return executeSync(bybitApiService.getSubUIDListUnlimited(
40+
subUserRequest.getPageSize(),
41+
subUserRequest.getNextCursor()
42+
));
43+
}
44+
45+
@Override
46+
public Object getSubUIDListUnlimited() {
47+
return executeSync(bybitApiService.getSubUIDListUnlimited());
48+
}
49+
50+
@Override
51+
public Object getSubAccAllAPIKeyInfo(UserDataRequest subUserRequest) {
52+
return executeSync(bybitApiService.getSubAccAllAPIKeyInfo(
53+
subUserRequest.getSubMemberId(),
54+
subUserRequest.getLimit(),
55+
subUserRequest.getCursor()
56+
));
57+
}
58+
3759
@Override
3860
public Object createSubMember(UserDataRequest request) {
3961
UserSubMemberRequest subUserRequest = converter.mapToCreateSubMemberRequest(request);

src/main/java/com/bybit/api/client/restApi/BybitApiAsyncUserRestClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ public interface BybitApiAsyncUserRestClient {
2727
void deleteMasterApiKey(BybitApiCallback<Object> callback);
2828
void deleteSubApiKey(UserDataRequest userDataRequest, BybitApiCallback<Object> callback);
2929
void getAffiliateUserInfo(UserDataRequest userDataRequest, BybitApiCallback<Object> callback);
30+
31+
void getSubUIDListUnlimited(UserDataRequest subUserRequest, BybitApiCallback<Object> callback);
32+
void getSubUIDListUnlimited(BybitApiCallback<Object> callback);
33+
void getSubAccAllAPIKeyInfo(UserDataRequest subUserRequest, BybitApiCallback<Object> callback);
3034
}

0 commit comments

Comments
 (0)