Skip to content

Commit

Permalink
Fixed some issues and updated the library's workflow to the last libr…
Browse files Browse the repository at this point in the history
…aries version
  • Loading branch information
N7ghtm4r3 committed Dec 7, 2022
1 parent 0dec597 commit bb491cd
Show file tree
Hide file tree
Showing 54 changed files with 1,171 additions and 973 deletions.
Binary file modified .gradle/7.4/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 54 additions & 9 deletions .idea/workspace.xml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CoinbaseManager
**v1.1.0**
**v1.1.1**

This is a Java Based library useful to work with Coinbase's API service.

Expand All @@ -23,7 +23,7 @@ allprojects {

```gradle
dependencies {
implementation 'com.github.N7ghtm4r3:CoinbaseManager:1.1.0'
implementation 'com.github.N7ghtm4r3:CoinbaseManager:1.1.1'
}
```

Expand All @@ -45,7 +45,7 @@ dependencies {
<dependency>
<groupId>com.github.N7ghtm4r3</groupId>
<artifactId>CoinbaseManager</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'tecknobit.com'
version '1.1.0'
version '1.1.1'

repositories {
mavenCentral()
Expand All @@ -16,7 +16,7 @@ dependencies {
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
implementation(group: 'commons-codec', name: 'commons-codec', version: '1.9')
implementation 'commons-validator:commons-validator:1.7'
implementation 'com.github.N7ghtm4r3:APIManager:2.0.1'
implementation 'com.github.N7ghtm4r3:APIManager:2.0.2'
implementation 'org.json:json:20220924'
}

Expand All @@ -25,7 +25,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.tecknobit.coinbasemanager'
artifactId = 'CoinbaseManager'
version = '1.1.0'
version = '1.1.1'
from components.java
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public class EndpointsList {
public static final String DEPOSIT_FROM_COINBASE_ENDPOINT = "/deposits" + COINBASE_ACCOUNT_ENDPOINT;

/**
* {@code DEPOSIT_FROM_PAYMENT_METHOD_ENDPOINT} is constant for DEPOSIT_FROM_PAYMENT_METHOD_ENDPOINT's endpoint
* **/
public static final String DEPOSIT_FROM_PAYMENT_METHOD_ENDPOINT = "/deposits/payment-method";
* {@code DEPOSIT_FROM_PAYMENT_ENDPOINT} is constant for DEPOSIT_FROM_PAYMENT_ENDPOINT's endpoint
**/
public static final String DEPOSIT_FROM_PAYMENT_ENDPOINT = "/deposits/payment-method";

/**
* {@code PAYMENTS_METHOD_ENDPOINT} is constant for PAYMENTS_METHOD_ENDPOINT's endpoint
* {@code PAYMENTS_ENDPOINT} is constant for PAYMENTS_ENDPOINT's endpoint
* **/
public static final String PAYMENTS_METHOD_ENDPOINT = "/payment-methods";
public static final String PAYMENTS_ENDPOINT = "/payment-methods";

/**
* {@code TRANSFERS_ENDPOINT} is constant for TRANSFERS_ENDPOINT's endpoint
Expand All @@ -66,9 +66,9 @@ public class EndpointsList {
public static final String FEE_WITHDRAW_TO_CRYPTO_ENDPOINT = "/withdrawals/fee-estimate";

/**
* {@code WITHDRAW_TO_PAYMENT_METHOD_ENDPOINT} is constant for WITHDRAW_TO_PAYMENT_METHOD_ENDPOINT's endpoint
* {@code WITHDRAW_TO_PAYMENT_ENDPOINT} is constant for WITHDRAW_TO_PAYMENT_ENDPOINT's endpoint
* **/
public static final String WITHDRAW_TO_PAYMENT_METHOD_ENDPOINT = "/withdrawals/payment-method";
public static final String WITHDRAW_TO_PAYMENT_ENDPOINT = "/withdrawals/payment-method";

/**
* {@code FEES_ENDPOINT} is constant for FEES_ENDPOINT's endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.Properties;

import static com.tecknobit.apimanager.apis.APIRequest.*;
import static com.tecknobit.apimanager.apis.APIRequest.RequestMethod.POST;
import static com.tecknobit.apimanager.apis.APIRequest.RequestMethod.PUT;
import static com.tecknobit.apimanager.trading.TradingTools.computeAssetPercent;
import static com.tecknobit.apimanager.trading.TradingTools.textualizeAssetPercent;

Expand Down Expand Up @@ -38,15 +40,18 @@ public class CoinbaseManager {
* {@code CB_ACCESS_SIGN} is constant for CB_ACCESS_SIGN's header
**/
protected static final String CB_ACCESS_SIGN = "cb-access-sign";

/**
* {@code CB_ACCESS_PASSPHRASE} is constant for CB_ACCESS_PASSPHRASE's header
**/
protected static final String CB_ACCESS_PASSPHRASE = "cb-access-passphrase";

/**
* {@code properties} is a local instance used to instantiate a new {@link CoinbaseManager}'s manager without
* re-insert credentials
**/
protected static final Properties properties = new Properties();

/**
* {@code headers} is instance that memorizes headers values
**/
Expand Down Expand Up @@ -176,7 +181,7 @@ else if (timeout != -1)
}

/**
* MethodId to store some properties
* Method to store some properties
*
* @param apiKey: {@code "Coinbase"} api key
* @param apiSecret: {@code "Coinbase"} api secret
Expand All @@ -197,27 +202,27 @@ private void storeProperties(String apiKey, String apiSecret, String passphrase,
}

/**
* MethodId to execute and get response of a request
* Method to execute and get response of a request
*
* @param endpoint: endpoint for the request and its query params es endpoint?param=paramValue
* @param method: method HTTP for the request
* @return response as {@link String}
**/
public String sendAPIRequest(String endpoint, String method) throws Exception {
public String sendAPIRequest(String endpoint, RequestMethod method) throws Exception {
setRequestHeaders(method, endpoint, null);
apiRequest.sendAPIRequest(BASE_ENDPOINT + endpoint, method, headers);
return apiRequest.getResponse();
}

/**
* MethodId to set {@code "Coinbase"} request headers
* Method to set {@code "Coinbase"} request headers
*
* @param endpoint: endpoint for the request and its query params es endpoint?param=paramValue
* @param method: method HTTP for the request
* @param body: only if request has a body params (generally POST request)
* any return
**/
private void setRequestHeaders(String method, String endpoint, String body) throws Exception {
private void setRequestHeaders(RequestMethod method, String endpoint, String body) throws Exception {
String timestamp = "" + System.currentTimeMillis() / 1000;
String stringToSign = timestamp + method + endpoint;
if (body != null)
Expand All @@ -232,50 +237,50 @@ private void setRequestHeaders(String method, String endpoint, String body) thro
}

/**
* MethodId to execute and get response of a POST http request
* Method to execute and get response of a POST http request
*
* @param endpoint: endpoint for the request and its query params es endpoint?param=paramValue
* @param payload: params to insert in the http body post request
* @return response as {@link String}
**/
public String sendPayloadedRequest(String endpoint, String method, Params payload) throws Exception {
public String sendPayloadedRequest(String endpoint, RequestMethod method, Params payload) throws Exception {
return sendPayloadedRequest(endpoint, method, payload, false);
}

/**
* MethodId to execute and get response of a POST http request
* Method to execute and get response of a POST http request
*
* @param endpoint: endpoint for the request and its query params es endpoint?param=paramValue
* @param payload: params to insert in the http body post request
* @return response as {@link String}
**/
public String sendJSONPayloadedRequest(String endpoint, String method, Params payload) throws Exception {
public String sendJSONPayloadedRequest(String endpoint, RequestMethod method, Params payload) throws Exception {
return sendPayloadedRequest(endpoint, method, payload, true);
}

/**
* MethodId to execute and get response of a POST http request
* Method to execute and get response of a POST http request
*
* @param endpoint: endpoint for the request and its query params es endpoint?param=paramValue
* @param payload: params to insert in the http body post request
* @param isJSONPayload: whether the payload is in {@code "JSON"}
* @return response as {@link String}
**/
private String sendPayloadedRequest(String endpoint, String method, Params payload,
private String sendPayloadedRequest(String endpoint, RequestMethod method, Params payload,
boolean isJSONPayload) throws Exception {
if (method.equals(POST_METHOD) || method.equals(PUT_METHOD)) {
if (method.equals(POST) || method.equals(PUT)) {
setRequestHeaders(method, endpoint, apiRequest.encodeBodyParams(payload));
if (isJSONPayload)
apiRequest.sendJSONPayloadedAPIRequest(BASE_ENDPOINT + endpoint, POST_METHOD, headers, payload);
apiRequest.sendJSONPayloadedAPIRequest(BASE_ENDPOINT + endpoint, POST, headers, payload);
else
apiRequest.sendPayloadedAPIRequest(BASE_ENDPOINT + endpoint, POST_METHOD, headers, payload);
apiRequest.sendPayloadedAPIRequest(BASE_ENDPOINT + endpoint, POST, headers, payload);
return apiRequest.getResponse();
} else
throw new IllegalArgumentException("Methods allowed for this request are POST and PUT method");
}

/**
* MethodId to assemble query params for a {@code "Coinbase"} request
* Method to assemble query params for a {@code "Coinbase"} request
*
* @param queryParams: value and key of query params to assemble
* @return query params as {@link String} es. ?param=paramValue&param2=param2Value
Expand All @@ -285,7 +290,7 @@ protected String assembleQueryParams(String defParams, Params queryParams) {
}

/**
* MethodId to get percent between two values and textualize it
* Method to get percent between two values and textualize it
*
* @param startValue: first value to make compare
* @param finalValue: last value to compare and get percent by first value
Expand All @@ -297,7 +302,7 @@ public String getTextTrendPercent(double startValue, double finalValue, int deci
}

/**
* MethodId to get error response of request <br>
* Method to get error response of request <br>
* Any params required
*
* @return error of the response as {@link String}
Expand All @@ -307,7 +312,7 @@ public String getErrorResponse() {
}

/**
* MethodId to get error response of request <br>
* Method to get error response of request <br>
* Any params required
*
* @return error response of the request formatted as {@code "JSON"} or as {@link String}
Expand All @@ -317,15 +322,15 @@ public <T> T getJSONErrorResponse() {
}

/**
* MethodId to print error response of request <br>
* Method to print error response of request <br>
* Any params required
**/
public void printErrorResponse() {
apiRequest.printErrorResponse();
}

/**
* MethodId to get status code of request response <br>
* Method to get status code of request response <br>
* Any params required
*
* @return status code of request response
Expand All @@ -335,7 +340,7 @@ public int getStatusResponse() {
}

/**
* MethodId to round a value
* Method to round a value
*
* @param value: value to round
* @param decimalDigits: number of digits to round final value
Expand All @@ -347,7 +352,7 @@ public double roundValue(double value, int decimalDigits) {
}

/**
* MethodId to get percent between two values
* Method to get percent between two values
*
* @param startValue: first value to make compare
* @param finalValue: last value to compare and get percent by first value
Expand All @@ -358,26 +363,28 @@ public double getTrendPercent(double startValue, double finalValue){
return computeAssetPercent(startValue, finalValue);
}

/** MethodId to get percent between two values and round it
* @param startValue: first value to make compare
* @param finalValue: last value to compare and get percent by first value
/**
* Method to get percent between two values and round it
*
* @param startValue: first value to make compare
* @param finalValue: last value to compare and get percent by first value
* @param decimalDigits: number of digits to round final percent value
* @return percent value as double es. 8 or -8
* @throws IllegalArgumentException if startValue or lastValue are negative
* **/
**/
public double getTrendPercent(double startValue, double finalValue, int decimalDigits){
return computeAssetPercent(startValue, finalValue, decimalDigits);
}

/** MethodId to format percent between two values and textualize it
/** Method to format percent between two values and textualize it
* @param percent: value to format
* @return percent value formatted es. +8% or -8% as {@link String}
* **/
public String getTextTrendPercent(double percent){
return textualizeAssetPercent(percent);
}

/** MethodId to get percent between two values and textualize it
/** Method to get percent between two values and textualize it
* @param startValue: first value to make compare
* @param finalValue: last value to compare and get percent by first value
* @return percent value es. +8% or -8% as {@link String}
Expand All @@ -386,15 +393,15 @@ public String getTextTrendPercent(double startValue, double finalValue){
return textualizeAssetPercent(startValue, finalValue);
}

/** MethodId to get {@code "Coinbase"} api key
/** Method to get {@code "Coinbase"} api key
* Any params required
* @return api key as {@link String}
* **/
public String getApiKey() {
return apiKey;
}

/** MethodId to get {@code "Coinbase"} api secret
/** Method to get {@code "Coinbase"} api secret
* Any params required
* @return api secret as {@link String}
* **/
Expand All @@ -403,7 +410,7 @@ public String getApiSecret() {
}

/**
* MethodId to get {@code "Coinbase"} api passphrase
* Method to get {@code "Coinbase"} api passphrase
* Any params required
*
* @return api passphrase as {@link String}
Expand Down
Loading

0 comments on commit bb491cd

Please sign in to comment.