Skip to content

Commit 2bab53b

Browse files
authored
Merge pull request #222 from mwarzybok-sumoheavy/feature/javadoc
fix javadoc, improve naming convention
2 parents 8773528 + 149a932 commit 2bab53b

19 files changed

+148
-145
lines changed

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

Lines changed: 74 additions & 74 deletions
Large diffs are not rendered by default.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public BillClient(BitPayClient bitPayClient, TokenContainer accessTokens) {
5454
* @throws BitPayException BitPayException class
5555
* @throws BillCreationException BillCreationException class
5656
*/
57-
public Bill createBill(Bill bill, Facade facade, boolean signRequest)
57+
public Bill create(Bill bill, Facade facade, boolean signRequest)
5858
throws BitPayException, BillCreationException {
5959
if (Objects.isNull(bill) || Objects.isNull(facade)) {
6060
throw new BillCreationException(null, "missing required parameter");
@@ -91,7 +91,7 @@ public Bill createBill(Bill bill, Facade facade, boolean signRequest)
9191
* @throws BitPayException BitPayException class
9292
* @throws BillQueryException BillQueryException class
9393
*/
94-
public Bill getBill(String billId, Facade facade, boolean signRequest) throws BitPayException, BillQueryException {
94+
public Bill get(String billId, Facade facade, boolean signRequest) throws BitPayException, BillQueryException {
9595
if (Objects.isNull(billId) || Objects.isNull(facade)) {
9696
throw new BillQueryException(null, "missing required parameter");
9797
}
@@ -180,7 +180,7 @@ public List<Bill> getBills() throws BitPayException, BillQueryException {
180180
* @throws BitPayException BitPayException class
181181
* @throws BillUpdateException BillUpdateException class
182182
*/
183-
public Bill updateBill(Bill bill, String billId) throws BitPayException, BillUpdateException {
183+
public Bill update(Bill bill, String billId) throws BitPayException, BillUpdateException {
184184
if (Objects.isNull(billId) || Objects.isNull(bill)) {
185185
throw new BillUpdateException(null, "missing required parameter");
186186
}
@@ -212,7 +212,7 @@ public Bill updateBill(Bill bill, String billId) throws BitPayException, BillUpd
212212
* @return A response status returned from the API.
213213
* @throws BillDeliveryException BillDeliveryException class
214214
*/
215-
public String deliverBill(String billId, String billToken, boolean signRequest) throws BillDeliveryException {
215+
public String deliver(String billId, String billToken, boolean signRequest) throws BillDeliveryException {
216216
if (Objects.isNull(billId) || Objects.isNull(billToken)) {
217217
throw new BillDeliveryException(null, "missing required parameter");
218218
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public CurrencyClient(BitPayClient client) throws BitPayException {
4545
* @throws BitPayException the bit pay exception
4646
*/
4747
@SuppressWarnings (value="unchecked")
48-
public Map<String, Object> getCurrencyInfo(String currencyCode) throws BitPayException {
48+
public Map<String, Object> getInfo(String currencyCode) throws BitPayException {
4949
if (Objects.isNull(currencyCode)) {
5050
throw new BitPayException(null, "missing required parameter");
5151
}

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public InvoiceClient(
6464
* @throws BitPayException BitPayException class
6565
* @throws InvoiceCreationException InvoiceCreationException class
6666
*/
67-
public Invoice createInvoice(Invoice invoice, Facade facade, Boolean signRequest) throws BitPayException,
67+
public Invoice create(Invoice invoice, Facade facade, Boolean signRequest) throws BitPayException,
6868
InvoiceCreationException {
6969
if (Objects.isNull(invoice) || Objects.isNull(facade)) {
7070
throw new InvoiceCreationException(null, "missing required parameter");
@@ -106,7 +106,7 @@ public Invoice createInvoice(Invoice invoice, Facade facade, Boolean signRequest
106106
* @throws BitPayException BitPayException class
107107
* @throws InvoiceQueryException InvoiceQueryException class
108108
*/
109-
public Invoice getInvoice(String invoiceId, Facade facade, Boolean signRequest) throws BitPayException,
109+
public Invoice get(String invoiceId, Facade facade, Boolean signRequest) throws BitPayException,
110110
InvoiceQueryException {
111111
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
112112
ParameterAdder.execute(params, "token", this.accessTokens.getAccessToken(facade));
@@ -138,7 +138,7 @@ public Invoice getInvoice(String invoiceId, Facade facade, Boolean signRequest)
138138
* @return A BitPay Invoice object.
139139
* @throws InvoiceQueryException InvoiceQueryException class
140140
*/
141-
public Invoice getInvoiceByGuid(String guid, Facade facade, Boolean signRequest) throws InvoiceQueryException {
141+
public Invoice getByGuid(String guid, Facade facade, Boolean signRequest) throws InvoiceQueryException {
142142
if (Objects.isNull(guid) || Objects.isNull(facade)) {
143143
throw new InvoiceQueryException(null, "missing required parameters");
144144
}
@@ -252,7 +252,7 @@ public InvoiceEventToken getInvoiceEventToken(String invoiceId) throws BitPayExc
252252
* @throws BitPayException BitPayException class
253253
* @throws InvoiceUpdateException InvoiceUpdateException class
254254
*/
255-
public Invoice updateInvoice(
255+
public Invoice update(
256256
String invoiceId,
257257
String buyerSms,
258258
String smsCode,
@@ -304,27 +304,6 @@ public Invoice updateInvoice(
304304
return invoice;
305305
}
306306

307-
private void validateSmsCode(String buyerSms, String smsCode, Boolean autoVerify) throws InvoiceUpdateException {
308-
if (Objects.isNull(autoVerify)) {
309-
return;
310-
}
311-
312-
if (autoVerify) {
313-
return;
314-
}
315-
316-
if (Objects.nonNull(buyerSms) && Objects.nonNull(smsCode)) {
317-
return;
318-
}
319-
320-
if (Objects.isNull(buyerSms) && Objects.isNull(smsCode)) {
321-
return;
322-
}
323-
324-
throw new InvoiceUpdateException(null,
325-
"If provided alongside a valid SMS, will bypass the need to complete an SMS challenge");
326-
}
327-
328307
/**
329308
* Pay a BitPay invoice with a mock transaction.
330309
*
@@ -334,7 +313,7 @@ private void validateSmsCode(String buyerSms, String smsCode, Boolean autoVerify
334313
* @throws BitPayException BitPayException class
335314
* @throws InvoiceUpdateException InvoiceUpdateException class
336315
*/
337-
public Invoice payInvoice(String invoiceId, String status) throws BitPayException, InvoiceUpdateException {
316+
public Invoice pay(String invoiceId, String status) throws BitPayException, InvoiceUpdateException {
338317
final Map<String, Object> params = new HashMap<>();
339318
params.put("token", this.accessTokens.getAccessToken(Facade.MERCHANT));
340319
if (status != null) {
@@ -372,9 +351,9 @@ public Invoice payInvoice(String invoiceId, String status) throws BitPayExceptio
372351
* @throws InvoiceCancellationException InvoiceCancellationException class
373352
* @throws BitPayException BitPayException class
374353
*/
375-
public Invoice cancelInvoice(String invoiceId) throws InvoiceCancellationException, BitPayException {
354+
public Invoice cancel(String invoiceId) throws InvoiceCancellationException, BitPayException {
376355
try {
377-
return this.cancelInvoice(invoiceId, false);
356+
return this.cancel(invoiceId, false);
378357
} catch (BitPayException ex) {
379358
throw new InvoiceCancellationException(ex.getStatusCode(), ex.getReasonPhrase());
380359
} catch (Exception e) {
@@ -391,7 +370,7 @@ public Invoice cancelInvoice(String invoiceId) throws InvoiceCancellationExcepti
391370
* @throws InvoiceCancellationException InvoiceCancellationException class
392371
* @throws BitPayException BitPayException class
393372
*/
394-
public Invoice cancelInvoice(String invoiceId, Boolean forceCancel)
373+
public Invoice cancel(String invoiceId, Boolean forceCancel)
395374
throws InvoiceCancellationException, BitPayException {
396375
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
397376
ParameterAdder.execute(params, "token", this.accessTokens.getAccessToken(Facade.MERCHANT));
@@ -413,7 +392,7 @@ public Invoice cancelInvoice(String invoiceId, Boolean forceCancel)
413392
return invoice;
414393
}
415394

416-
public Invoice cancelInvoiceByGuid(String guid, Boolean forceCancel) throws BitPayException {
395+
public Invoice cancelByGuid(String guid, Boolean forceCancel) throws BitPayException {
417396
if (Objects.isNull(guid) || Objects.isNull(forceCancel)) {
418397
throw new InvoiceCancellationException(null, "missing required parameter");
419398
}
@@ -470,4 +449,25 @@ private void validateRequiredField(String buyerSms, String buyerEmail) throws In
470449
throw new InvoiceUpdateException(null, "Updating an invoice will require EITHER an SMS or E-mail)");
471450
}
472451
}
452+
453+
private void validateSmsCode(String buyerSms, String smsCode, Boolean autoVerify) throws InvoiceUpdateException {
454+
if (Objects.isNull(autoVerify)) {
455+
return;
456+
}
457+
458+
if (autoVerify) {
459+
return;
460+
}
461+
462+
if (Objects.nonNull(buyerSms) && Objects.nonNull(smsCode)) {
463+
return;
464+
}
465+
466+
if (Objects.isNull(buyerSms) && Objects.isNull(smsCode)) {
467+
return;
468+
}
469+
470+
throw new InvoiceUpdateException(null,
471+
"If provided alongside a valid SMS, will bypass the need to complete an SMS challenge");
472+
}
473473
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public LedgerClient(BitPayClient bitPayClient, TokenContainer accessTokens) {
4040
}
4141

4242
/**
43-
* Retrieve a list of ledgers entries by currency & date range using the merchant facade.
43+
* Retrieve a list of ledgers entries by currency and date range using the merchant facade.
4444
*
4545
* @param currency The three digit currency string for the ledger to retrieve.
4646
* @param dateStart The first date for the query filter.
@@ -49,7 +49,7 @@ public LedgerClient(BitPayClient bitPayClient, TokenContainer accessTokens) {
4949
* @throws BitPayException BitPayException class
5050
* @throws LedgerQueryException LedgerQueryException class
5151
*/
52-
public List<LedgerEntry> getLedgerEntries(String currency, String dateStart, String dateEnd) throws BitPayException,
52+
public List<LedgerEntry> getEntries(String currency, String dateStart, String dateEnd) throws BitPayException,
5353
LedgerQueryException {
5454
if (Objects.isNull(currency) || Objects.isNull(dateStart) || Objects.isNull(dateEnd)) {
5555
throw new BitPayException(null, "missing mandatory fields");

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public Boolean cancel(String payoutId) throws BitPayException, PayoutCancellatio
132132
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
133133
ParameterAdder.execute(params, "token", this.accessTokens.getAccessToken(Facade.PAYOUT));
134134

135-
Boolean result;
135+
boolean result;
136136
JsonMapper mapper = JsonMapperFactory.create();
137137

138138
try {
@@ -214,7 +214,7 @@ public List<Payout> getPayouts(
214214
* @throws BitPayException BitPayException class
215215
* @throws PayoutNotificationException PayoutNotificationException class
216216
*/
217-
public Boolean requestPayoutNotification(String payoutId)
217+
public Boolean requestNotification(String payoutId)
218218
throws BitPayException, PayoutNotificationException {
219219
if (Objects.isNull(payoutId)) {
220220
throw new PayoutNotificationException(null, "missing required parameter");
@@ -225,7 +225,7 @@ public Boolean requestPayoutNotification(String payoutId)
225225

226226
JsonMapper mapper = JsonMapperFactory.create();
227227

228-
Boolean result;
228+
boolean result;
229229
String json;
230230

231231
try {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public List<PayoutRecipient> submit(PayoutRecipients recipients)
111111
* @throws BitPayException BitPayException class
112112
* @throws PayoutRecipientQueryException PayoutRecipientQueryException class
113113
*/
114-
public List<PayoutRecipient> getByFilters(String status, Integer limit, Integer offset)
114+
public List<PayoutRecipient> getRecipientsByFilters(String status, Integer limit, Integer offset)
115115
throws BitPayException, PayoutRecipientQueryException {
116116

117117
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
@@ -193,7 +193,7 @@ public PayoutRecipient update(String recipientId, PayoutRecipient recipient)
193193
throw new PayoutRecipientUpdateException(null, "missing required parameter");
194194
}
195195
recipient.setToken(this.accessTokens.getAccessToken(Facade.PAYOUT));
196-
recipient.setGuid(this.guidGenerator.execute());
196+
recipient.setGuid(Objects.isNull(recipient.getGuid()) ? this.guidGenerator.execute() : recipient.getGuid());
197197
JsonMapper mapper = JsonMapperFactory.create();
198198
String json;
199199

@@ -265,7 +265,7 @@ public Boolean delete(String recipientId)
265265
* @throws PayoutRecipientNotificationException PayoutRecipientNotificationException class
266266
* @throws BitPayException BitPayException class
267267
*/
268-
public Boolean requestPayoutRecipientNotification(String recipientId)
268+
public Boolean requestNotification(String recipientId)
269269
throws PayoutRecipientNotificationException, BitPayException {
270270
if (Objects.isNull(recipientId)) {
271271
throw new PayoutRecipientNotificationException(null, "missing required parameter");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public RateClient(BitPayClient bitPayClient) {
3939
* @throws RateQueryException RateQueryException class
4040
* @since 8.8.0
4141
*/
42-
public Rate getRate(String baseCurrency, String currency) throws RateQueryException {
42+
public Rate get(String baseCurrency, String currency) throws RateQueryException {
4343
try {
4444
HttpResponse response = this.bitPayClient.get("rates/" + baseCurrency + "/" + currency);
4545
final String content = this.bitPayClient.responseToJsonString(response);

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ public Refund create(Refund refund) throws BitPayException {
9696
* @throws BitPayException BitPayException class
9797
*/
9898
public Refund getById(String refundId) throws RefundQueryException, BitPayException {
99-
if (Objects.isNull(refundId)) {
100-
throw new RefundQueryException(null, "missing required parameter");
101-
}
99+
validateRefundId(refundId);
102100

103101
Refund refund;
104102

@@ -129,9 +127,7 @@ public Refund getById(String refundId) throws RefundQueryException, BitPayExcept
129127
* @throws BitPayException BitPayException
130128
*/
131129
public Refund getByGuid(String guid) throws BitPayException {
132-
if (Objects.isNull(guid)) {
133-
throw new RefundQueryException(null, "missing required parameter");
134-
}
130+
validateRefundId(guid);
135131

136132
Refund refund;
137133

@@ -164,9 +160,7 @@ public Refund getByGuid(String guid) throws BitPayException {
164160
* @throws BitPayException BitPayException class
165161
*/
166162
public List<Refund> getRefundsByInvoiceId(String invoiceId) throws RefundQueryException, BitPayException {
167-
if (Objects.isNull(invoiceId)) {
168-
throw new RefundQueryException(null, "missing required parameter");
169-
}
163+
validateRefundId(invoiceId);
170164

171165
List<Refund> refunds;
172166
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
@@ -420,4 +414,10 @@ private Map<String, Object> createBasicParamsForCreate(Refund refund) throws Bit
420414

421415
return params;
422416
}
417+
418+
private void validateRefundId(String refundId) throws RefundQueryException {
419+
if (Objects.isNull(refundId)) {
420+
throw new RefundQueryException(null, "missing required parameter");
421+
}
422+
}
423423
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public List<Settlement> getSettlements(String currency, String dateStart, String
9999
* @throws BitPayException BitPayException class
100100
* @throws SettlementQueryException SettlementQueryException class
101101
*/
102-
public Settlement getSettlement(String settlementId) throws BitPayException, SettlementQueryException {
102+
public Settlement get(String settlementId) throws BitPayException, SettlementQueryException {
103103
if (Objects.isNull(settlementId)) {
104104
throw new SettlementQueryException(null, "missing required parameter");
105105
}

0 commit comments

Comments
 (0)