Skip to content

Commit 06d030c

Browse files
SP-33
1 parent 742fe5b commit 06d030c

File tree

9 files changed

+916
-20
lines changed

9 files changed

+916
-20
lines changed

src/main/java/com/bitpay/sdk/Client.java

Lines changed: 81 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* Copyright (c) 2019 BitPay
3+
*/
4+
15
package com.bitpay.sdk;
26

37
import com.bitpay.sdk.exceptions.*;
@@ -51,10 +55,12 @@
5155
import java.util.*;
5256

5357
/**
58+
* The type Client. Class is responsible for API calls.
59+
*
5460
* @author Antonio Buedo
55-
* @version 8.5.2208
56-
* See bitpay.com/api for more information.
57-
* date 04.03.2022
61+
* @version 8.5.2208 date 04.03.2022
62+
* @see <a href="https://bitpay.com/api/#rest-api">REST API</a>
63+
*
5864
*/
5965

6066
public class Client {
@@ -329,7 +335,7 @@ public Invoice getInvoice(String invoiceId, String facade, Boolean signRequest)
329335

330336
return invoice;
331337
}
332-
338+
333339
/**
334340
* Retrieve a BitPay invoice by guid using the specified facade. The client must have been previously authorized for the specified facade.
335341
*
@@ -1169,7 +1175,7 @@ public PayoutRecipient getPayoutRecipient(String recipientId) throws BitPayExcep
11691175

11701176
return recipient;
11711177
}
1172-
1178+
11731179
/**
11741180
* Update a Payout Recipient.
11751181
*
@@ -1246,7 +1252,7 @@ public Boolean deletePayoutRecipient(String recipientId)
12461252

12471253
/**
12481254
* Request a payout recipient notification
1249-
*
1255+
*
12501256
* @param recipientId String A BitPay recipient ID.
12511257
* @return True if the notification was successfully sent, false otherwise.
12521258
* @throws BitPayException BitPayException class
@@ -1284,7 +1290,7 @@ public Boolean requestPayoutRecipientNotification(String recipientId)
12841290

12851291
return result;
12861292
}
1287-
1293+
12881294
/**
12891295
* Submit a BitPay Payout.
12901296
*
@@ -1319,7 +1325,7 @@ public Payout submitPayout(Payout payout) throws BitPayException, PayoutCreation
13191325
/**
13201326
* Retrieve a BitPay payout by payout id using. The client must have been
13211327
* previously authorized for the payout facade.
1322-
*
1328+
*
13231329
* @param payoutId String The id of the payout to retrieve.
13241330
* @return A BitPay Payout object.
13251331
* @throws BitPayException BitPayException class
@@ -1435,7 +1441,7 @@ public List<Payout> getPayouts(String startDate, String endDate, String status,
14351441

14361442
/**
14371443
* Request a payout notification
1438-
*
1444+
*
14391445
* @param payoutId String The id of the payout to notify..
14401446
* @return True if the notification was successfully sent, false otherwise.
14411447
* @throws BitPayException BitPayException class
@@ -1563,7 +1569,7 @@ public List<PayoutBatch> getPayoutBatches(String status) throws BitPayException,
15631569

15641570
return batches;
15651571
}
1566-
1572+
15671573
/**
15681574
* Retrieve a collection of BitPay payout batches.
15691575
*
@@ -1619,7 +1625,7 @@ public List<PayoutBatch> getPayoutBatches(String startDate, String endDate, Stri
16191625
/**
16201626
* Retrieve a BitPay payout batch by batch id using. The client must have been
16211627
* previously authorized for the payout facade.
1622-
*
1628+
*
16231629
* @param payoutBatchId String The id of the batch to retrieve.
16241630
* @return A BitPay PayoutBatch object.
16251631
* @throws BitPayException BitPayException class
@@ -1680,15 +1686,14 @@ public Boolean cancelPayoutBatch(String payoutBatchId) throws BitPayException, P
16801686

16811687
return result;
16821688
}
1683-
1689+
16841690
/**
16851691
* Request a payout batch notification
1686-
*
1692+
*
16871693
* @param payoutBatchId String The id of the payout batch to notify..
16881694
* @return True if the notification was successfully sent, false otherwise.
16891695
* @throws BitPayException BitPayException class
1690-
* @throws PayoutBatchNotificationException PayoutBatchNotificationException
1691-
* class
1696+
* @throws PayoutBatchNotificationException PayoutBatchNotificationException class
16921697
*/
16931698
public Boolean requestPayoutBatchNotification(String payoutBatchId)
16941699
throws BitPayException, PayoutBatchNotificationException {
@@ -1972,10 +1977,27 @@ public String getAccessToken(String key) throws BitPayException {
19721977
}
19731978

19741979

1980+
/**
1981+
* Send GET request.
1982+
*
1983+
* @param uri the uri
1984+
* @param parameters the parameters
1985+
* @return the http response
1986+
* @throws BitPayException the bit pay exception
1987+
*/
19751988
public HttpResponse get(String uri, List<BasicNameValuePair> parameters) throws BitPayException {
19761989
return get(uri, parameters, true);
19771990
}
19781991

1992+
/**
1993+
* Send GET request.
1994+
*
1995+
* @param uri the uri
1996+
* @param parameters the parameters
1997+
* @param signatureRequired the signature required
1998+
* @return the http response
1999+
* @throws BitPayException the bit pay exception
2000+
*/
19792001
public HttpResponse get(String uri, List<BasicNameValuePair> parameters, boolean signatureRequired) throws BitPayException {
19802002
try {
19812003

@@ -2009,6 +2031,13 @@ public HttpResponse get(String uri, List<BasicNameValuePair> parameters, boolean
20092031
}
20102032
}
20112033

2034+
/**
2035+
* Send GET request.
2036+
*
2037+
* @param uri the uri
2038+
* @return the http response
2039+
* @throws BitPayException the bit pay exception
2040+
*/
20122041
public HttpResponse get(String uri) throws BitPayException {
20132042
return this.get(uri, null, false);
20142043
}
@@ -2045,10 +2074,27 @@ private HttpResponse delete(String uri, List<BasicNameValuePair> parameters) thr
20452074
}
20462075
}
20472076

2077+
/**
2078+
* Send POST request.
2079+
*
2080+
* @param uri the uri
2081+
* @param json the json
2082+
* @return the http response
2083+
* @throws BitPayException the bit pay exception
2084+
*/
20482085
public HttpResponse post(String uri, String json) throws BitPayException {
20492086
return this.post(uri, json, false);
20502087
}
20512088

2089+
/**
2090+
* Send POST request.
2091+
*
2092+
* @param uri the uri
2093+
* @param json the json
2094+
* @param signatureRequired the signature required
2095+
* @return the http response
2096+
* @throws BitPayException the bit pay exception
2097+
*/
20522098
public HttpResponse post(String uri, String json, boolean signatureRequired) throws BitPayException {
20532099
try {
20542100
HttpPost post = new HttpPost(_baseUrl + uri);
@@ -2078,6 +2124,14 @@ public HttpResponse post(String uri, String json, boolean signatureRequired) thr
20782124
}
20792125
}
20802126

2127+
/**
2128+
* Send PUT request.
2129+
*
2130+
* @param uri the uri
2131+
* @param json the json
2132+
* @return the http response
2133+
* @throws BitPayException the bit pay exception
2134+
*/
20812135
public HttpResponse update(String uri, String json) throws BitPayException {
20822136
try {
20832137
HttpPut put = new HttpPut(_baseUrl + uri);
@@ -2104,6 +2158,13 @@ public HttpResponse update(String uri, String json) throws BitPayException {
21042158
}
21052159
}
21062160

2161+
/**
2162+
* Convert HttpResponse for Json string.
2163+
*
2164+
* @param response the response
2165+
* @return the string
2166+
* @throws BitPayException the bit pay exception
2167+
*/
21072168
public String responseToJsonString(HttpResponse response) throws BitPayException {
21082169
if (response == null) {
21092170
throw new BitPayException(null, "Error: HTTP response is null");
@@ -2187,7 +2248,7 @@ private String getGuid() {
21872248
}
21882249

21892250
/**
2190-
* Loads the configuration file (JSON)
2251+
* Loads the configuration file (JSON).
21912252
*
21922253
* @throws BitPayException BitPayException class
21932254
*/
@@ -2209,7 +2270,7 @@ public void GetConfig() throws BitPayException {
22092270
}
22102271

22112272
/**
2212-
* Builds the configuration object
2273+
* Builds the configuration object.
22132274
*
22142275
* @param privateKey The full path to the securely located private key.
22152276
* @param tokens Env.Tokens object containing the BitPay's API tokens.
@@ -2283,9 +2344,9 @@ private void loadCurrencies() throws BitPayException {
22832344
// No action required
22842345
}
22852346
}
2286-
2287-
2288-
2347+
2348+
2349+
22892350
/**
22902351
* Gets info for specific currency.
22912352
*

src/main/java/com/bitpay/sdk/Config.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,71 @@
44
import com.fasterxml.jackson.annotation.JsonProperty;
55
import com.fasterxml.jackson.databind.JsonNode;
66

7+
/**
8+
* The type Config.
9+
*/
710
public class Config {
811
String _environment;
912
JsonNode _envConfig;
1013

14+
/**
15+
* Instantiates a new Config.
16+
*/
1117
public Config() {
1218
}
1319

20+
/**
21+
* Gets environment.
22+
*
23+
* There are two environments available for merchants to use the following API.
24+
* To access these APIs, merchants need to combine the base URL + endpoint and make sure to have API credentials
25+
* for the corresponding environments.
26+
*
27+
* @return the environment
28+
*/
1429
@JsonIgnore
1530
public String getEnvironment() {
1631
return _environment;
1732
}
1833

34+
/**
35+
* Sets environment.
36+
*
37+
* There are two environments available for merchants to use the following API.
38+
* To access these APIs, merchants need to combine the base URL + endpoint and make sure to have API credentials
39+
* for the corresponding environments.
40+
*
41+
* @param environment the environment
42+
*/
1943
@JsonProperty("Environment")
2044
public void setEnvironment(String environment) {
2145
this._environment = environment;
2246
}
2347

48+
/**
49+
* Gets config for specific environment.
50+
*
51+
* @see <a href="https://github.com/bitpay/java-bitpay-client/blob/master/GUIDE.md#handling-your-client-private-key">
52+
* Example of env config as JSON
53+
* </a>
54+
*
55+
* @param env the env
56+
* @return the env config
57+
*/
2458
@JsonIgnore
2559
public JsonNode getEnvConfig(String env) {
2660
return _envConfig.path(env);
2761
}
2862

63+
/**
64+
* Sets config for specific environment.
65+
*
66+
* @see <a href="https://github.com/bitpay/java-bitpay-client/blob/master/GUIDE.md#handling-your-client-private-key">
67+
* Example of env config as JSON
68+
* </a>
69+
*
70+
* @param envConfig the env config
71+
*/
2972
@JsonProperty("EnvConfig")
3073
public void setEnvConfig(JsonNode envConfig) {
3174
this._envConfig = envConfig;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,53 @@
11
package com.bitpay.sdk;
22

3+
/**
4+
* The type Environment.
5+
*/
36
public class Env {
7+
/**
8+
* Test Environment.
9+
*/
410
public static final String Test = "Test";
11+
/**
12+
* Production Environment.
13+
*/
514
public static final String Prod = "Prod";
15+
/**
16+
* Test Url.
17+
*/
618
public static final String TestUrl = "https://test.bitpay.com/";
19+
/**
20+
* Production Url.
21+
*/
722
public static final String ProdUrl = "https://bitpay.com/";
23+
/**
24+
* BitPay Api Version.
25+
*/
826
public static final String BitpayApiVersion = "2.0.0";
27+
/**
28+
* BitPay Plugin Info Version.
29+
*/
930
public static final String BitpayPluginInfo = "BitPay_Java_Client_v8.5.2208";
31+
/**
32+
* BitPay Api Frame.
33+
*/
1034
public static final String BitpayApiFrame = "std";
35+
/**
36+
* BitPay Api Frame Version.
37+
*/
1138
public static final String BitpayApiFrameVersion = "1.0.0";
1239

40+
/**
41+
* The type Tokens.
42+
*/
1343
public static class Tokens {
44+
/**
45+
* The Merchant.
46+
*/
1447
public String merchant;
48+
/**
49+
* The Payout.
50+
*/
1551
public String payout;
1652
}
1753
}

0 commit comments

Comments
 (0)