Skip to content

Commit 4812014

Browse files
committed
feat: change window method on rest method
1 parent 4a88891 commit 4812014

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

src/main/java/com/cryptomarket/sdk/HMAC.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public Integer getWindow() {
2929
return window;
3030
}
3131

32+
public String getApiSecret() {
33+
return apiSecret;
34+
}
35+
36+
public String getApiKey() {
37+
return apiKey;
38+
}
39+
3240
public String getCredential(String method, String body, String url) {
3341
String timestamp = String.format("%d", System.currentTimeMillis());
3442
String message = new StringBuffer()

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ public interface CloseableHttpClient extends Closeable {
1111

1212
/**
1313
* Changes the user credentials used for authentication in calls
14-
* @param apiKey the user public key used in new calls
14+
*
15+
* @param apiKey the user public key used in new calls
1516
* @param apiSecret the user secret key used in new calls
1617
*/
1718
public void changeCredentials(String apiKey, String apiSecret);
1819

20+
/**
21+
* Changes the window used in authenticated calls
22+
*
23+
* @param window acceptable time between request and server execution
24+
*/
25+
public void changeWindow(Integer window);
26+
1927
/**
2028
* Does an http get without authentication
2129
*

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ public interface CryptomarketRestClient extends Closeable {
6161
*/
6262
public void changeCredentials(String apiKey, String apiSecret);
6363

64+
/**
65+
* Changes the window used in authenticated calls
66+
*
67+
* @param window acceptable time between request and server execution
68+
*/
69+
public void changeWindow(Integer window);
70+
6471
/// PUBLIC CALLS///
6572

6673
/**

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ public void changeCredentials(String apiKey, String apiSecret) {
8282
httpClient.changeCredentials(apiKey, apiSecret);
8383
}
8484

85+
@Override
86+
public void changeWindow(Integer window) {
87+
httpClient.changeWindow(window);
88+
}
89+
8590
// PUBLIC
8691

8792
@Override

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ public void changeCredentials(String apiKey, String apiSecret) {
103103
this.hmac = new HMAC(apiKey, apiSecret, hmac.getWindow());
104104
}
105105

106+
@Override
107+
public void changeWindow(Integer window) {
108+
this.hmac = new HMAC(hmac.getApiKey(), hmac.getApiSecret(), window);
109+
}
110+
106111
public void close() throws IOException {
107112
client.close();
108113
}

0 commit comments

Comments
 (0)