Skip to content

Commit 1ffe7ff

Browse files
author
T. Ismael Verdugo
committed
feat: adds get api keys endpoint
1 parent 264bcfe commit 1ffe7ff

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package com.cryptomarket.sdk.models;
2+
3+
import java.util.List;
4+
5+
import com.squareup.moshi.Json;
6+
7+
public class ApiKey {
8+
/** First 6 symbols of the public key */
9+
@Json(name = "api_key_first_six")
10+
private String firstSix;
11+
/** Name of the key */
12+
@Json(name = "key_name")
13+
private String name;
14+
/** "Orderbook, History, Trading balance" API key access right */
15+
@Json(name = "exchange_read")
16+
private Boolean exchangeRead;
17+
/** "Place/cancel orders" API key access right */
18+
@Json(name = "exchange_trade")
19+
private Boolean exchangeTrade;
20+
/** "Payment information" API key access right */
21+
@Json(name = "bank_read")
22+
private Boolean bankRead;
23+
/** "Withdraw cryptocurrencies" API key access right */
24+
@Json(name = "bank_withdraw")
25+
private Boolean bankWithdraw;
26+
/** A list of whitelisted IPs */
27+
@Json(name = "allowed_ips")
28+
private List<String> allowedIps;
29+
/** Flag indicating the API key is active */
30+
@Json(name = "is_active")
31+
private Boolean isActive;
32+
/** The date and time the key was created */
33+
@Json(name = "created_at")
34+
private String createdAt;
35+
/** The date and time the key was updated */
36+
@Json(name = "updated_at")
37+
private String updatedAt;
38+
39+
public String getFirstSix() {
40+
return firstSix;
41+
}
42+
43+
public void setFirstSix(String firstSix) {
44+
this.firstSix = firstSix;
45+
}
46+
47+
public String getName() {
48+
return name;
49+
}
50+
51+
public void setName(String name) {
52+
this.name = name;
53+
}
54+
55+
public Boolean getExchangeRead() {
56+
return exchangeRead;
57+
}
58+
59+
public void setExchangeRead(Boolean exchangeRead) {
60+
this.exchangeRead = exchangeRead;
61+
}
62+
63+
public Boolean getExchangeTrade() {
64+
return exchangeTrade;
65+
}
66+
67+
public void setExchangeTrade(Boolean exchangeTrade) {
68+
this.exchangeTrade = exchangeTrade;
69+
}
70+
71+
public Boolean getBankRead() {
72+
return bankRead;
73+
}
74+
75+
public void setBankRead(Boolean bankRead) {
76+
this.bankRead = bankRead;
77+
}
78+
79+
public Boolean getBankWithdraw() {
80+
return bankWithdraw;
81+
}
82+
83+
public void setBankWithdraw(Boolean bankWithdraw) {
84+
this.bankWithdraw = bankWithdraw;
85+
}
86+
87+
public List<String> getAllowedIps() {
88+
return allowedIps;
89+
}
90+
91+
public void setAllowedIps(List<String> allowedIps) {
92+
this.allowedIps = allowedIps;
93+
}
94+
95+
public Boolean getIsActive() {
96+
return isActive;
97+
}
98+
99+
public void setIsActive(Boolean isActive) {
100+
this.isActive = isActive;
101+
}
102+
103+
public String getCreatedAt() {
104+
return createdAt;
105+
}
106+
107+
public void setCreatedAt(String createdAt) {
108+
this.createdAt = createdAt;
109+
}
110+
111+
public String getUpdatedAt() {
112+
return updatedAt;
113+
}
114+
115+
public void setUpdatedAt(String updatedAt) {
116+
this.updatedAt = updatedAt;
117+
}
118+
119+
@Override
120+
public String toString() {
121+
return "ApiKey [firstSix=" + firstSix + ", name=" + name + ", exchangeRead=" + exchangeRead + ", exchangeTrade="
122+
+ exchangeTrade + ", bankRead=" + bankRead + ", bankWithdraw=" + bankWithdraw + ", allowedIps=" + allowedIps
123+
+ ", isActive=" + isActive + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + "]";
124+
}
125+
}

src/main/java/com/cryptomarket/sdk/rest/CryptomarketRestClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.cryptomarket.sdk.exceptions.CryptomarketSDKException;
2727
import com.cryptomarket.sdk.models.Address;
2828
import com.cryptomarket.sdk.models.AmountLock;
29+
import com.cryptomarket.sdk.models.ApiKey;
2930
import com.cryptomarket.sdk.models.Balance;
3031
import com.cryptomarket.sdk.models.Candle;
3132
import com.cryptomarket.sdk.models.Commission;
@@ -1125,6 +1126,10 @@ public List<Trade> getSpotTradesHistory(
11251126
public List<Trade> getSpotTradesHistory(ParamsBuilder paramsBuilder)
11261127
throws CryptomarketSDKException;
11271128

1129+
// USER MANAGEMENT
1130+
1131+
public List<ApiKey> getUserApiKeys() throws CryptomarketSDKException;
1132+
11281133
// WALLET MANAGEMENT
11291134

11301135
/**

src/main/java/com/cryptomarket/sdk/rest/CryptomarketRestClientImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.cryptomarket.sdk.exceptions.CryptomarketSDKException;
3131
import com.cryptomarket.sdk.models.Address;
3232
import com.cryptomarket.sdk.models.AmountLock;
33+
import com.cryptomarket.sdk.models.ApiKey;
3334
import com.cryptomarket.sdk.models.Balance;
3435
import com.cryptomarket.sdk.models.Candle;
3536
import com.cryptomarket.sdk.models.Commission;
@@ -742,6 +743,13 @@ public List<Trade> getSpotTradesHistory(ParamsBuilder paramsBuilder)
742743
paramsBuilder.build());
743744
return adapter.listFromJson(jsonResponse, Trade.class);
744745
}
746+
// USER MANAGEMENT
747+
748+
@Override
749+
public List<ApiKey> getUserApiKeys() throws CryptomarketSDKException {
750+
String jsonResponse = httpClient.get("user/api-keys",null);
751+
return adapter.listFromJson(jsonResponse, ApiKey.class);
752+
}
745753

746754
// WALLET MANAGEMENT
747755

0 commit comments

Comments
 (0)