Skip to content

Commit 7a7da19

Browse files
Merge pull request #491 from sgilrodriguez/support-tax_service_opt_out
Add support for tax_service_opt_out in giftcard
2 parents fb94a14 + 0b996c4 commit 7a7da19

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

src/main/java/com/ning/billing/recurly/model/GiftCard.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public class GiftCard extends RecurlyObject {
7171
@XmlElement(name = "performance_obligation_id")
7272
private String performanceObligationId;
7373

74+
@XmlElement(name = "tax_service_opt_out")
75+
private Boolean taxServiceOptOut;
76+
7477
@XmlElement(name = "created_at")
7578
private DateTime createdAt;
7679

@@ -188,6 +191,14 @@ public void setPerformanceObligationId(final Object performanceObligationId) {
188191
this.performanceObligationId = stringOrNull(performanceObligationId);
189192
}
190193

194+
public Boolean getTaxServiceOptOut() {
195+
return taxServiceOptOut;
196+
}
197+
198+
public void setTaxServiceOptOut(final Object taxServiceOptOut) {
199+
this.taxServiceOptOut = booleanOrNull(taxServiceOptOut);
200+
}
201+
191202
public DateTime getCreatedAt() {
192203
return createdAt;
193204
}
@@ -274,6 +285,7 @@ public String toString() {
274285
sb.append(", liabilityGlAccountId='").append(liabilityGlAccountId).append('\'');
275286
sb.append(", revenueGlAccountId='").append(revenueGlAccountId).append('\'');
276287
sb.append(", performanceObligationId='").append(performanceObligationId).append('\'');
288+
sb.append(", taxServiceOptOut='").append(taxServiceOptOut).append('\'');
277289
sb.append(", createdAt='").append(createdAt).append('\'');
278290
sb.append(", updatedAt='").append(updatedAt).append('\'');
279291
sb.append(", redeemedAt='").append(redeemedAt).append('\'');
@@ -331,6 +343,9 @@ public boolean equals(final Object o) {
331343
if (performanceObligationId != null ? !performanceObligationId.equals(that.performanceObligationId) : that.performanceObligationId != null) {
332344
return false;
333345
}
346+
if (taxServiceOptOut != null ? !taxServiceOptOut.equals(that.taxServiceOptOut) : that.taxServiceOptOut != null) {
347+
return false;
348+
}
334349
if (createdAt != null ? createdAt.compareTo(that.createdAt) != 0 : that.createdAt != null) {
335350
return false;
336351
}
@@ -364,6 +379,7 @@ public int hashCode() {
364379
liabilityGlAccountId,
365380
revenueGlAccountId,
366381
performanceObligationId,
382+
taxServiceOptOut,
367383
createdAt,
368384
updatedAt,
369385
redeemedAt,

src/test/java/com/ning/billing/recurly/model/TestGiftCards.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void testDeserialization() throws Exception {
6565
" <liability_gl_account_id>123</liability_gl_account_id>\n" +
6666
" <revenue_gl_account_id>456</revenue_gl_account_id>\n" +
6767
" <performance_obligation_id>789</performance_obligation_id>\n" +
68+
" <tax_service_opt_out type=\"boolean\">true</tax_service_opt_out>\n" +
6869
" </gift_card>" +
6970
"</gift_cards>";
7071

@@ -86,6 +87,7 @@ public void testDeserialization() throws Exception {
8687
Assert.assertEquals(giftCard.getLiabilityGlAccountId(), "123");
8788
Assert.assertEquals(giftCard.getRevenueGlAccountId(), "456");
8889
Assert.assertEquals(giftCard.getPerformanceObligationId(), "789");
90+
Assert.assertEquals(giftCard.getTaxServiceOptOut(), Boolean.TRUE);
8991
Assert.assertNull(giftCard.getCanceledAt());
9092

9193
final Delivery delivery = giftCard.getDelivery();
@@ -107,4 +109,55 @@ public void testDeserialization() throws Exception {
107109
Assert.assertEquals(address.getZip(), "94110");
108110
Assert.assertEquals(address.getPhone(), "555-555-5555");
109111
}
112+
113+
@Test(groups = "fast")
114+
public void testSerializationWithTaxServiceOptOut() throws Exception {
115+
final GiftCard giftCard = new GiftCard();
116+
giftCard.setProductCode("gift_card_100");
117+
giftCard.setCurrency("USD");
118+
giftCard.setUnitAmountInCents(10000);
119+
giftCard.setTaxServiceOptOut(true);
120+
121+
final String xml = xmlMapper.writeValueAsString(giftCard);
122+
123+
Assert.assertTrue(xml.contains("<product_code>gift_card_100</product_code>"));
124+
Assert.assertTrue(xml.contains("<currency>USD</currency>"));
125+
Assert.assertTrue(xml.contains("<unit_amount_in_cents>10000</unit_amount_in_cents>"));
126+
Assert.assertTrue(xml.contains("<tax_service_opt_out>true</tax_service_opt_out>"));
127+
}
128+
129+
@Test(groups = "fast")
130+
public void testDeserializationWithTaxServiceOptOutFalse() throws Exception {
131+
final String giftCardData =
132+
"<gift_card>" +
133+
" <product_code>gift_card</product_code>\n" +
134+
" <currency>USD</currency> \n" +
135+
" <unit_amount_in_cents type=\"integer\">2000</unit_amount_in_cents>\n" +
136+
" <tax_service_opt_out type=\"boolean\">false</tax_service_opt_out>\n" +
137+
"</gift_card>";
138+
139+
final GiftCard giftCard = xmlMapper.readValue(giftCardData, GiftCard.class);
140+
141+
Assert.assertEquals(giftCard.getProductCode(), "gift_card");
142+
Assert.assertEquals(giftCard.getCurrency(), "USD");
143+
Assert.assertEquals(giftCard.getUnitAmountInCents(), new Integer(2000));
144+
Assert.assertEquals(giftCard.getTaxServiceOptOut(), Boolean.FALSE);
145+
}
146+
147+
@Test(groups = "fast")
148+
public void testDeserializationWithoutTaxServiceOptOut() throws Exception {
149+
final String giftCardData =
150+
"<gift_card>" +
151+
" <product_code>gift_card</product_code>\n" +
152+
" <currency>USD</currency> \n" +
153+
" <unit_amount_in_cents type=\"integer\">2000</unit_amount_in_cents>\n" +
154+
"</gift_card>";
155+
156+
final GiftCard giftCard = xmlMapper.readValue(giftCardData, GiftCard.class);
157+
158+
Assert.assertEquals(giftCard.getProductCode(), "gift_card");
159+
Assert.assertEquals(giftCard.getCurrency(), "USD");
160+
Assert.assertEquals(giftCard.getUnitAmountInCents(), new Integer(2000));
161+
Assert.assertNull(giftCard.getTaxServiceOptOut());
162+
}
110163
}

0 commit comments

Comments
 (0)