Skip to content

Commit 4ccadfb

Browse files
SP-737 Type Review: Java
1 parent 34f4ac2 commit 4ccadfb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+832
-197
lines changed

src/main/java/com/bitpay/sdk/model/bill/Bill.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
import com.bitpay.sdk.exceptions.BitPayGenericException;
1010
import com.bitpay.sdk.model.Currency;
1111
import com.bitpay.sdk.model.ModelConfiguration;
12+
import com.bitpay.sdk.util.serializer.Iso8601ToZonedDateTimeDeserializer;
13+
import com.bitpay.sdk.util.serializer.ZonedDateTimeToIso8601Serializer;
1214
import com.fasterxml.jackson.annotation.JsonIgnore;
1315
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1416
import com.fasterxml.jackson.annotation.JsonInclude;
1517
import com.fasterxml.jackson.annotation.JsonProperty;
18+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
19+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
1620
import java.time.ZonedDateTime;
1721
import java.util.List;
1822

@@ -39,7 +43,7 @@ public class Bill {
3943
private String country = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
4044
private List<String> cc;
4145
private String phone = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
42-
private String dueDate = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
46+
private ZonedDateTime dueDate;
4347
private Boolean passProcessingFee;
4448
private String status = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
4549
private String url = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
@@ -395,7 +399,8 @@ public void setPhone(final String phone) {
395399
*/
396400
@JsonProperty("dueDate")
397401
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
398-
public String getDueDate() {
402+
@JsonSerialize(using = ZonedDateTimeToIso8601Serializer.class)
403+
public ZonedDateTime getDueDate() {
399404
return this.dueDate;
400405
}
401406

@@ -405,7 +410,8 @@ public String getDueDate() {
405410
* @param dueDate the due date
406411
*/
407412
@JsonProperty("dueDate")
408-
public void setDueDate(final String dueDate) {
413+
@JsonDeserialize(using = Iso8601ToZonedDateTimeDeserializer.class)
414+
public void setDueDate(final ZonedDateTime dueDate) {
409415
this.dueDate = dueDate;
410416
}
411417

@@ -480,6 +486,7 @@ public void setUrl(final String url) {
480486
*/
481487
@JsonIgnore
482488
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
489+
@JsonSerialize(using = ZonedDateTimeToIso8601Serializer.class)
483490
public ZonedDateTime getCreatedDate() {
484491
return this.createdDate;
485492
}
@@ -490,6 +497,7 @@ public ZonedDateTime getCreatedDate() {
490497
* @param createdDate the create date
491498
*/
492499
@JsonProperty("createdDate")
500+
@JsonDeserialize(using = Iso8601ToZonedDateTimeDeserializer.class)
493501
public void setCreatedDate(final ZonedDateTime createdDate) {
494502
this.createdDate = createdDate;
495503
}

src/main/java/com/bitpay/sdk/model/invoice/InvoiceTransaction.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
package com.bitpay.sdk.model.invoice;
77

88
import com.bitpay.sdk.model.ModelConfiguration;
9+
import com.bitpay.sdk.util.serializer.Iso8601ToZonedDateTimeDeserializer;
10+
import com.bitpay.sdk.util.serializer.ZonedDateTimeToIso8601Serializer;
911
import com.fasterxml.jackson.annotation.JsonIgnore;
1012
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1113
import com.fasterxml.jackson.annotation.JsonProperty;
14+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
15+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
1216
import java.math.BigDecimal;
13-
import java.util.Date;
17+
import java.time.ZonedDateTime;
1418
import java.util.Map;
1519

1620
/**
@@ -26,8 +30,8 @@ public class InvoiceTransaction {
2630

2731
private BigDecimal amount;
2832
private Integer confirmations;
29-
private Date time;
30-
private Date receivedTime;
33+
private ZonedDateTime time;
34+
private ZonedDateTime receivedTime;
3135
private String txid = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
3236
private Map<String, BigDecimal> exRates;
3337
private Integer outputIndex;
@@ -84,7 +88,8 @@ public void setConfirmations(final Integer confirmations) {
8488
* @return the received time
8589
*/
8690
@JsonIgnore
87-
public Date getReceivedTime() {
91+
@JsonSerialize(using = ZonedDateTimeToIso8601Serializer.class)
92+
public ZonedDateTime getReceivedTime() {
8893
return this.receivedTime;
8994
}
9095

@@ -94,7 +99,8 @@ public Date getReceivedTime() {
9499
* @param receivedTime the received time
95100
*/
96101
@JsonProperty("receivedTime")
97-
public void setReceivedTime(final Date receivedTime) {
102+
@JsonDeserialize(using = Iso8601ToZonedDateTimeDeserializer.class)
103+
public void setReceivedTime(final ZonedDateTime receivedTime) {
98104
this.receivedTime = receivedTime;
99105
}
100106

@@ -124,7 +130,8 @@ public void setTransactionId(final String txid) {
124130
* @return the time
125131
*/
126132
@JsonIgnore
127-
public Date getTime() {
133+
@JsonSerialize(using = ZonedDateTimeToIso8601Serializer.class)
134+
public ZonedDateTime getTime() {
128135
return this.time;
129136
}
130137

@@ -134,7 +141,8 @@ public Date getTime() {
134141
* @param time the time
135142
*/
136143
@JsonProperty("time")
137-
public void setTime(final Date time) {
144+
@JsonDeserialize(using = Iso8601ToZonedDateTimeDeserializer.class)
145+
public void setTime(final ZonedDateTime time) {
138146
this.time = time;
139147
}
140148

src/main/java/com/bitpay/sdk/model/invoice/MinerFeesItem.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.fasterxml.jackson.annotation.JsonIgnore;
99
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1010
import com.fasterxml.jackson.annotation.JsonProperty;
11-
import java.math.BigDecimal;
1211

1312
/**
1413
* The type Miner fees item.
@@ -18,8 +17,8 @@
1817
@JsonIgnoreProperties(ignoreUnknown = true)
1918
public class MinerFeesItem {
2019

21-
private BigDecimal satoshisPerByte;
22-
private BigDecimal totalFee;
20+
private Integer satoshisPerByte;
21+
private Integer totalFee;
2322
private Double fiatAmount;
2423

2524
/**
@@ -34,7 +33,7 @@ public MinerFeesItem() {
3433
* @return the satoshis per byte
3534
*/
3635
@JsonIgnore
37-
public BigDecimal getSatoshisPerByte() {
36+
public Integer getSatoshisPerByte() {
3837
return this.satoshisPerByte;
3938
}
4039

@@ -44,7 +43,7 @@ public BigDecimal getSatoshisPerByte() {
4443
* @param satoshisPerByte the satoshis per byte
4544
*/
4645
@JsonProperty("satoshisPerByte")
47-
public void setSatoshisPerByte(BigDecimal satoshisPerByte) {
46+
public void setSatoshisPerByte(Integer satoshisPerByte) {
4847
this.satoshisPerByte = satoshisPerByte;
4948
}
5049

@@ -54,7 +53,7 @@ public void setSatoshisPerByte(BigDecimal satoshisPerByte) {
5453
* @return the total fee
5554
*/
5655
@JsonIgnore
57-
public BigDecimal getTotalFee() {
56+
public Integer getTotalFee() {
5857
return this.totalFee;
5958
}
6059

@@ -64,7 +63,7 @@ public BigDecimal getTotalFee() {
6463
* @param totalFee the total fee
6564
*/
6665
@JsonProperty("totalFee")
67-
public void setTotalFee(BigDecimal totalFee) {
66+
public void setTotalFee(Integer totalFee) {
6867
this.totalFee = totalFee;
6968
}
7069

src/main/java/com/bitpay/sdk/model/invoice/Refund.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
package com.bitpay.sdk.model.invoice;
77

88
import com.bitpay.sdk.model.ModelConfiguration;
9+
import com.bitpay.sdk.util.serializer.Iso8601ToZonedDateTimeDeserializer;
10+
import com.bitpay.sdk.util.serializer.ZonedDateTimeToIso8601Serializer;
911
import com.fasterxml.jackson.annotation.JsonIgnore;
1012
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1113
import com.fasterxml.jackson.annotation.JsonInclude;
1214
import com.fasterxml.jackson.annotation.JsonProperty;
15+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
16+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
1317
import java.math.BigDecimal;
14-
import java.util.Date;
18+
import java.time.ZonedDateTime;
1519

1620
/**
1721
* Fully paid invoices can be refunded via the merchant's authorization to issue a refund,
@@ -32,31 +36,17 @@ public class Refund {
3236
private Boolean buyerPaysRefundFee;
3337
private String reference = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
3438
private Double refundFee;
35-
private Date lastRefundNotification;
39+
private ZonedDateTime requestDate;
40+
private ZonedDateTime lastRefundNotification;
3641
private String notificationUrl = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
3742
private String refundAddress = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
3843
private String supportRequest = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
3944
private String txid = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
4045
private String type = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
41-
42-
/**
43-
* Amount to be refunded in terms of the transaction currency.
44-
*/
4546
private BigDecimal transactionAmount;
46-
47-
/**
48-
* The refund fee expressed in terms of transaction currency.
49-
*/
5047
private BigDecimal transactionRefundFee;
51-
52-
/**
53-
* The currency used for the invoice transaction.
54-
*/
5548
private String transactionCurrency = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
56-
57-
5849
private String id;
59-
private Date requestDate;
6050
private String status = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
6151

6252

@@ -278,7 +268,8 @@ public void setId(final String id) {
278268
*/
279269
@JsonIgnore
280270
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
281-
public Date getRequestDate() {
271+
@JsonSerialize(using = ZonedDateTimeToIso8601Serializer.class)
272+
public ZonedDateTime getRequestDate() {
282273
return this.requestDate;
283274
}
284275

@@ -288,7 +279,8 @@ public Date getRequestDate() {
288279
* @param requestDate the request date
289280
*/
290281
@JsonProperty("requestDate")
291-
public void setRequestDate(final Date requestDate) {
282+
@JsonDeserialize(using = Iso8601ToZonedDateTimeDeserializer.class)
283+
public void setRequestDate(final ZonedDateTime requestDate) {
292284
this.requestDate = requestDate;
293285
}
294286

@@ -394,7 +386,8 @@ public void setTransactionCurrency(final String transactionCurrency) {
394386
*/
395387
@JsonIgnore
396388
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
397-
public Date getLastRefundNotification() {
389+
@JsonSerialize(using = ZonedDateTimeToIso8601Serializer.class)
390+
public ZonedDateTime getLastRefundNotification() {
398391
return this.lastRefundNotification;
399392
}
400393

@@ -404,7 +397,8 @@ public Date getLastRefundNotification() {
404397
* @param lastRefundNotification the last refund notification
405398
*/
406399
@JsonProperty("lastRefundNotification")
407-
public void setLastRefundNotification(final Date lastRefundNotification) {
400+
@JsonDeserialize(using = Iso8601ToZonedDateTimeDeserializer.class)
401+
public void setLastRefundNotification(final ZonedDateTime lastRefundNotification) {
408402
this.lastRefundNotification = lastRefundNotification;
409403
}
410404

src/main/java/com/bitpay/sdk/model/invoice/RefundStatus.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@ public class RefundStatus {
1616
* No funds deducted, refund will not proceed automatically -
1717
* the status must be changed via Update a Refund Request.
1818
*/
19-
public static final String Preview = "preview";
19+
public static final String PREVIEW = "preview";
2020
/**
2121
* Funds deducted/allocated if immediate,
2222
* will proceed when transactions are confirmed and the required data is collected.
2323
*/
24-
public static final String Created = "created";
24+
public static final String CREATED = "created";
2525
/**
2626
* Refund is in process of being fulfilled.
2727
*/
28-
public static final String Pending = "pending";
28+
public static final String PENDING = "pending";
2929
/**
3030
* Refund was canceled by merchant action. Immediate refunds cannot be canceled outside of preview state.
3131
*/
32-
public static final String Canceled = "canceled";
32+
public static final String CANCELED = "canceled";
3333
/**
3434
* Refund was successfully processed.
3535
*/
36-
public static final String Success = "success";
36+
public static final String SUCCESS = "success";
3737
/**
3838
* Refund failed during processing (this is really more of an internal state).
3939
*/
40-
public static final String Failure = "failure";
40+
public static final String FAILURE = "failure";
4141
}

src/main/java/com/bitpay/sdk/model/invoice/RefundWebhook.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
package com.bitpay.sdk.model.invoice;
77

88
import com.bitpay.sdk.model.ModelConfiguration;
9+
import com.bitpay.sdk.util.serializer.Iso8601ToZonedDateTimeDeserializer;
10+
import com.bitpay.sdk.util.serializer.ZonedDateTimeToIso8601Serializer;
911
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1012
import com.fasterxml.jackson.annotation.JsonInclude;
1113
import com.fasterxml.jackson.annotation.JsonProperty;
12-
import java.util.Date;
14+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
15+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
16+
import java.time.ZonedDateTime;
1317

1418
/**
1519
* The type Refund webhook.
@@ -25,11 +29,11 @@ public class RefundWebhook {
2529
private String status = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
2630
private Double amount;
2731
private String currency = ModelConfiguration.DEFAULT_NON_SENT_VALUE;
28-
private Date lastRefundNotification;
32+
private ZonedDateTime lastRefundNotification;
2933
private Double refundFee;
3034
private Boolean immediate;
3135
private Boolean buyerPaysRefundFee;
32-
private Date requestDate;
36+
private ZonedDateTime requestDate;
3337

3438
/**
3539
* Instantiates a new Refund webhook.
@@ -172,7 +176,8 @@ public void setCurrency(String currency) {
172176
*/
173177
@JsonProperty("lastRefundNotification")
174178
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
175-
public Date getLastRefundNotification() {
179+
@JsonSerialize(using = ZonedDateTimeToIso8601Serializer.class)
180+
public ZonedDateTime getLastRefundNotification() {
176181
return this.lastRefundNotification;
177182
}
178183

@@ -182,7 +187,8 @@ public Date getLastRefundNotification() {
182187
* @param lastRefundNotification the last refund notification
183188
*/
184189
@JsonProperty("lastRefundNotification")
185-
public void setLastRefundNotification(Date lastRefundNotification) {
190+
@JsonDeserialize(using = Iso8601ToZonedDateTimeDeserializer.class)
191+
public void setLastRefundNotification(ZonedDateTime lastRefundNotification) {
186192
this.lastRefundNotification = lastRefundNotification;
187193
}
188194

@@ -258,7 +264,8 @@ public void setBuyerPaysRefundFee(Boolean buyerPaysRefundFee) {
258264
*/
259265
@JsonProperty("requestDate")
260266
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
261-
public Date getRequestDate() {
267+
@JsonSerialize(using = ZonedDateTimeToIso8601Serializer.class)
268+
public ZonedDateTime getRequestDate() {
262269
return this.requestDate;
263270
}
264271

@@ -268,7 +275,8 @@ public Date getRequestDate() {
268275
* @param requestDate the request date
269276
*/
270277
@JsonProperty("requestDate")
271-
public void setRequestDate(Date requestDate) {
278+
@JsonDeserialize(using = Iso8601ToZonedDateTimeDeserializer.class)
279+
public void setRequestDate(ZonedDateTime requestDate) {
272280
this.requestDate = requestDate;
273281
}
274282

0 commit comments

Comments
 (0)