Skip to content

Commit addfb38

Browse files
update dependencies
1 parent 90a7f7f commit addfb38

File tree

10 files changed

+62
-53
lines changed

10 files changed

+62
-53
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>com.bitpay</groupId>
88
<artifactId>bitpay_sdk</artifactId>
9-
<version>BitPay_Java_Client_v9.0.0-beta1</version>
9+
<version>9.0.0-beta1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>BitPay</name>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@
5757
import com.bitpay.sdk.model.Rate.Rates;
5858
import com.bitpay.sdk.model.Settlement.Settlement;
5959
import com.bitpay.sdk.model.Wallet.Wallet;
60-
import com.bitpay.sdk.util.TokenContainer;
6160
import com.bitpay.sdk.util.GuidGenerator;
61+
import com.bitpay.sdk.util.JsonMapperFactory;
6262
import com.bitpay.sdk.util.KeyUtils;
63+
import com.bitpay.sdk.util.TokenContainer;
6364
import com.fasterxml.jackson.core.JsonProcessingException;
6465
import com.fasterxml.jackson.databind.JsonNode;
65-
import com.fasterxml.jackson.databind.ObjectMapper;
66+
import com.fasterxml.jackson.databind.json.JsonMapper;
6667
import java.io.File;
6768
import java.net.URISyntaxException;
6869
import java.nio.file.Files;
@@ -1246,12 +1247,11 @@ protected String getBaseUrl(Environment environment) {
12461247
protected Config buildConfigFromFile(ConfigFilePath configFilePath) throws BitPayException {
12471248
try {
12481249
byte[] jsonData = Files.readAllBytes(Paths.get(configFilePath.value()));
1249-
//create ObjectMapper instance
1250-
ObjectMapper mapper = new ObjectMapper();
1250+
JsonMapper mapper = JsonMapperFactory.create();
12511251
//read JSON like DOM Parser
12521252
JsonNode rootNode = mapper.readTree(jsonData);
12531253
JsonNode bitPayConfiguration = rootNode.path("BitPayConfiguration");
1254-
return new ObjectMapper().readValue(bitPayConfiguration.toString(), Config.class);
1254+
return mapper.readValue(bitPayConfiguration.toString(), Config.class);
12551255
} catch (JsonProcessingException e) {
12561256
throw new BitPayException(null, "failed to read configuration file : " + e.getMessage());
12571257
} catch (Exception e) {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/*
2+
* Copyright (c) 2019 BitPay
3+
*/
14
package com.bitpay.sdk;
25

36
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -118,7 +121,7 @@ public ObjectNode getApiTokens() {
118121
apiTokens = (ObjectNode) envConfig.get(API_TOKENS_KEY);
119122
if (Objects.isNull(apiTokens)) {
120123
apiTokens = (ObjectNode) JsonNodeFactory.instance.objectNode();
121-
envConfig.put(API_TOKENS_KEY, apiTokens);
124+
envConfig.putIfAbsent(API_TOKENS_KEY, apiTokens);
122125
}
123126

124127
return apiTokens;

src/main/java/com/bitpay/sdk/client/BillClient.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
import com.bitpay.sdk.exceptions.BitPayException;
1212
import com.bitpay.sdk.model.Bill.Bill;
1313
import com.bitpay.sdk.model.Facade;
14-
import com.bitpay.sdk.util.TokenContainer;
1514
import com.bitpay.sdk.util.JsonMapperFactory;
1615
import com.bitpay.sdk.util.ParameterAdder;
16+
import com.bitpay.sdk.util.TokenContainer;
1717
import com.fasterxml.jackson.core.JsonProcessingException;
18-
import com.fasterxml.jackson.databind.ObjectMapper;
1918
import com.fasterxml.jackson.databind.json.JsonMapper;
2019
import java.util.ArrayList;
2120
import java.util.Arrays;
@@ -104,7 +103,7 @@ public Bill getBill(String billId, Facade facade, boolean signRequest) throws Bi
104103

105104
try {
106105
HttpResponse response = this.bitPayClient.get("bills/" + billId, params, signRequest);
107-
bill = new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Bill.class);
106+
bill = JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Bill.class);
108107
} catch (JsonProcessingException e) {
109108
throw new BillQueryException(null,
110109
"failed to deserialize BitPay server response (Bill) : " + e.getMessage());
@@ -133,7 +132,7 @@ public Bill getBill(String billId, Facade facade, boolean signRequest) throws Bi
133132

134133
try {
135134
HttpResponse response = this.bitPayClient.get("bills", params);
136-
bills = Arrays.asList(new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Bill[].class));
135+
bills = Arrays.asList(JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Bill[].class));
137136
} catch (JsonProcessingException e) {
138137
throw new BillQueryException(null,
139138
"failed to deserialize BitPay server response (Bills) : " + e.getMessage());
@@ -160,7 +159,7 @@ public List<Bill> getBills() throws BitPayException, BillQueryException {
160159

161160
try {
162161
HttpResponse response = this.bitPayClient.get("bills", params);
163-
bills = Arrays.asList(new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Bill[].class));
162+
bills = Arrays.asList(JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Bill[].class));
164163
} catch (JsonProcessingException e) {
165164
throw new BillQueryException(null,
166165
"failed to deserialize BitPay server response (Bills) : " + e.getMessage());

src/main/java/com/bitpay/sdk/client/InvoiceClient.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
import com.bitpay.sdk.model.Facade;
1313
import com.bitpay.sdk.model.Invoice.Invoice;
1414
import com.bitpay.sdk.model.Invoice.InvoiceEventToken;
15-
import com.bitpay.sdk.util.TokenContainer;
1615
import com.bitpay.sdk.util.GuidGenerator;
1716
import com.bitpay.sdk.util.JsonMapperFactory;
1817
import com.bitpay.sdk.util.ParameterAdder;
18+
import com.bitpay.sdk.util.TokenContainer;
1919
import com.fasterxml.jackson.core.JsonProcessingException;
20-
import com.fasterxml.jackson.databind.ObjectMapper;
2120
import com.fasterxml.jackson.databind.json.JsonMapper;
2221
import java.util.ArrayList;
2322
import java.util.Arrays;
@@ -116,7 +115,7 @@ public Invoice getInvoice(String invoiceId, Facade facade, Boolean signRequest)
116115

117116
try {
118117
HttpResponse response = this.bitPayClient.get("invoices/" + invoiceId, params, signRequest);
119-
invoice = new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
118+
invoice = JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
120119
} catch (BitPayException ex) {
121120
throw new InvoiceQueryException(ex.getStatusCode(), ex.getReasonPhrase());
122121
} catch (JsonProcessingException e) {
@@ -150,7 +149,7 @@ public Invoice getInvoiceByGuid(String guid, Facade facade, Boolean signRequest)
150149
try {
151150
ParameterAdder.execute(params, "token", this.accessTokens.getAccessToken(facade));
152151
HttpResponse response = this.bitPayClient.get("invoices/guid/" + guid, params, signRequest);
153-
invoice = new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
152+
invoice = JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
154153
} catch (BitPayException ex) {
155154
throw new InvoiceQueryException(ex.getStatusCode(), ex.getReasonPhrase());
156155
} catch (JsonProcessingException e) {
@@ -201,7 +200,7 @@ public List<Invoice> getInvoices(String dateStart, String dateEnd, String status
201200
try {
202201
HttpResponse response = this.bitPayClient.get("invoices", params);
203202
invoices = Arrays.asList(
204-
new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Invoice[].class));
203+
JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Invoice[].class));
205204
} catch (BitPayException ex) {
206205
throw new InvoiceQueryException(ex.getStatusCode(), ex.getReasonPhrase());
207206
} catch (JsonProcessingException e) {
@@ -294,7 +293,7 @@ public Invoice updateInvoice(
294293

295294
try {
296295
HttpResponse response = this.bitPayClient.update("invoices/" + invoiceId, json);
297-
invoice = new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
296+
invoice = JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
298297
} catch (BitPayException ex) {
299298
throw new InvoiceUpdateException(ex.getStatusCode(), ex.getReasonPhrase());
300299
} catch (Exception e) {
@@ -403,7 +402,7 @@ public Invoice cancelInvoice(String invoiceId, Boolean forceCancel)
403402

404403
try {
405404
HttpResponse response = this.bitPayClient.delete("invoices/" + invoiceId, params);
406-
invoice = new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
405+
invoice = JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
407406
} catch (BitPayException ex) {
408407
throw new InvoiceCancellationException(ex.getStatusCode(), ex.getReasonPhrase());
409408
} catch (Exception e) {
@@ -428,7 +427,7 @@ public Invoice cancelInvoiceByGuid(String guid, Boolean forceCancel) throws BitP
428427

429428
try {
430429
HttpResponse response = this.bitPayClient.delete("invoices/guid/" + guid, params);
431-
invoice = new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
430+
invoice = JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Invoice.class);
432431
} catch (BitPayException ex) {
433432
throw new InvoiceCancellationException(ex.getStatusCode(), ex.getReasonPhrase());
434433
} catch (Exception e) {

src/main/java/com/bitpay/sdk/client/LedgerClient.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import com.bitpay.sdk.model.Facade;
1010
import com.bitpay.sdk.model.Ledger.Ledger;
1111
import com.bitpay.sdk.model.Ledger.LedgerEntry;
12-
import com.bitpay.sdk.util.TokenContainer;
12+
import com.bitpay.sdk.util.JsonMapperFactory;
1313
import com.bitpay.sdk.util.ParameterAdder;
14+
import com.bitpay.sdk.util.TokenContainer;
1415
import com.fasterxml.jackson.core.JsonProcessingException;
15-
import com.fasterxml.jackson.databind.ObjectMapper;
1616
import java.util.ArrayList;
1717
import java.util.Arrays;
1818
import java.util.List;
@@ -56,13 +56,13 @@ public List<LedgerEntry> getLedgerEntries(String currency, String dateStart, Str
5656
}
5757

5858
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
59-
ParameterAdder.execute(params,"token", this.accessTokens.getAccessToken(Facade.MERCHANT));
60-
ParameterAdder.execute(params,"startDate", dateStart);
61-
ParameterAdder.execute(params,"endDate", dateEnd);
59+
ParameterAdder.execute(params, "token", this.accessTokens.getAccessToken(Facade.MERCHANT));
60+
ParameterAdder.execute(params, "startDate", dateStart);
61+
ParameterAdder.execute(params, "endDate", dateEnd);
6262

6363
try {
6464
HttpResponse response = this.bitPayClient.get("ledgers/" + currency, params);
65-
return Arrays.asList(new ObjectMapper()
65+
return Arrays.asList(JsonMapperFactory.create()
6666
.readValue(this.bitPayClient.responseToJsonString(response), LedgerEntry[].class));
6767
} catch (JsonProcessingException e) {
6868
throw new LedgerQueryException(null,
@@ -83,14 +83,15 @@ public List<LedgerEntry> getLedgerEntries(String currency, String dateStart, Str
8383
*/
8484
public List<Ledger> getLedgers() throws BitPayException, LedgerQueryException {
8585
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
86-
ParameterAdder.execute(params,"token", this.accessTokens.getAccessToken(Facade.MERCHANT));
86+
ParameterAdder.execute(params, "token", this.accessTokens.getAccessToken(Facade.MERCHANT));
8787

8888
List<Ledger> ledgers;
8989

9090
try {
9191
HttpResponse response = this.bitPayClient.get("ledgers", params);
9292
ledgers = Arrays
93-
.asList(new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Ledger[].class));
93+
.asList(JsonMapperFactory.create()
94+
.readValue(this.bitPayClient.responseToJsonString(response), Ledger[].class));
9495
} catch (JsonProcessingException e) {
9596
throw new LedgerQueryException(null,
9697
"failed to deserialize BitPay server response (Ledger) : " + e.getMessage());

src/main/java/com/bitpay/sdk/client/PayoutClient.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
import com.bitpay.sdk.exceptions.PayoutQueryException;
1212
import com.bitpay.sdk.model.Facade;
1313
import com.bitpay.sdk.model.Payout.Payout;
14-
import com.bitpay.sdk.util.TokenContainer;
1514
import com.bitpay.sdk.util.JsonMapperFactory;
1615
import com.bitpay.sdk.util.ParameterAdder;
16+
import com.bitpay.sdk.util.TokenContainer;
1717
import com.fasterxml.jackson.core.JsonProcessingException;
1818
import com.fasterxml.jackson.databind.JsonNode;
19-
import com.fasterxml.jackson.databind.ObjectMapper;
2019
import com.fasterxml.jackson.databind.json.JsonMapper;
2120
import java.util.ArrayList;
2221
import java.util.Arrays;
@@ -72,7 +71,8 @@ public Payout submit(Payout payout) throws BitPayException, PayoutCreationExcept
7271
}
7372
try {
7473
HttpResponse response = this.bitPayClient.post("payouts", json, true);
75-
payout = new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Payout.class);
74+
payout = JsonMapperFactory.create()
75+
.readValue(this.bitPayClient.responseToJsonString(response), Payout.class);
7676
} catch (Exception e) {
7777
throw new PayoutCreationException(null,
7878
"failed to deserialize BitPay server response (Payout) : " + e.getMessage());
@@ -103,7 +103,8 @@ public Payout get(String payoutId) throws BitPayException, PayoutQueryException
103103

104104
try {
105105
HttpResponse response = this.bitPayClient.get("payouts/" + payoutId, params, true);
106-
payout = new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Payout.class);
106+
payout = JsonMapperFactory.create()
107+
.readValue(this.bitPayClient.responseToJsonString(response), Payout.class);
107108
} catch (JsonProcessingException e) {
108109
throw new PayoutQueryException(null,
109110
"failed to deserialize BitPay server response (Payout) : " + e.getMessage());
@@ -192,7 +193,8 @@ public List<Payout> getPayouts(
192193
try {
193194
HttpResponse response = this.bitPayClient.get("payouts", params, true);
194195
payouts = Arrays
195-
.asList(new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Payout[].class));
196+
.asList(JsonMapperFactory.create()
197+
.readValue(this.bitPayClient.responseToJsonString(response), Payout[].class));
196198
} catch (JsonProcessingException e) {
197199
throw new PayoutQueryException(null,
198200
"failed to deserialize BitPay server response (Payout) : " + e.getMessage());

src/main/java/com/bitpay/sdk/client/PayoutRecipientsClient.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
import com.bitpay.sdk.model.Facade;
1414
import com.bitpay.sdk.model.Payout.PayoutRecipient;
1515
import com.bitpay.sdk.model.Payout.PayoutRecipients;
16-
import com.bitpay.sdk.util.TokenContainer;
1716
import com.bitpay.sdk.util.GuidGenerator;
1817
import com.bitpay.sdk.util.JsonMapperFactory;
1918
import com.bitpay.sdk.util.ParameterAdder;
19+
import com.bitpay.sdk.util.TokenContainer;
2020
import com.fasterxml.jackson.core.JsonProcessingException;
2121
import com.fasterxml.jackson.databind.JsonNode;
22-
import com.fasterxml.jackson.databind.ObjectMapper;
2322
import com.fasterxml.jackson.databind.json.JsonMapper;
2423
import java.util.ArrayList;
2524
import java.util.Arrays;
@@ -130,7 +129,7 @@ public List<PayoutRecipient> getByFilters(String status, Integer limit, Integer
130129
try {
131130
HttpResponse response = this.bitPayClient.get("recipients", params, true);
132131
recipientsList = Arrays
133-
.asList(new ObjectMapper()
132+
.asList(JsonMapperFactory.create()
134133
.readValue(this.bitPayClient.responseToJsonString(response), PayoutRecipient[].class));
135134
} catch (JsonProcessingException e) {
136135
throw new PayoutRecipientQueryException(null,
@@ -165,8 +164,8 @@ public PayoutRecipient get(String recipientId)
165164

166165
try {
167166
HttpResponse response = this.bitPayClient.get("recipients/" + recipientId, params, true);
168-
recipient =
169-
new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), PayoutRecipient.class);
167+
recipient = JsonMapperFactory.create()
168+
.readValue(this.bitPayClient.responseToJsonString(response), PayoutRecipient.class);
170169
} catch (JsonProcessingException e) {
171170
throw new PayoutRecipientQueryException(null,
172171
"failed to deserialize BitPay server response (PayoutRecipient) : " + e.getMessage());
@@ -209,8 +208,8 @@ public PayoutRecipient update(String recipientId, PayoutRecipient recipient)
209208

210209
try {
211210
HttpResponse response = this.bitPayClient.update("recipients/" + recipientId, json);
212-
updateRecipient =
213-
new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), PayoutRecipient.class);
211+
updateRecipient = JsonMapperFactory.create()
212+
.readValue(this.bitPayClient.responseToJsonString(response), PayoutRecipient.class);
214213
} catch (JsonProcessingException e) {
215214
throw new PayoutRecipientUpdateException(null,
216215
"failed to deserialize BitPay server response (PayoutRecipients) : " + e.getMessage());

0 commit comments

Comments
 (0)