Skip to content

Commit

Permalink
Merge pull request #197 from lukevs/master
Browse files Browse the repository at this point in the history
Add coupon_code to SubscriptionUpdate
  • Loading branch information
bhelx authored Jun 1, 2017
2 parents ae85e07 + 1247171 commit 85a3bc6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ public void setCollectionMethod(Object collectionMethod) {
this.collectionMethod = stringOrNull(collectionMethod);
}

@XmlElement(name = "coupon_code")
private String couponCode;

public String getCouponCode() {
return couponCode;
}

public void setCouponCode(String couponCode) {
this.couponCode = couponCode;
}

@Override
public boolean equals(final Object o) {
if (this == o) return true;
Expand All @@ -67,6 +78,9 @@ public boolean equals(final Object o) {
if (timeframe != that.timeframe) {
return false;
}
if (couponCode != null ? !couponCode.equals(that.couponCode) : that.couponCode != null) {
return false;
}

return true;
}
Expand All @@ -75,6 +89,7 @@ public boolean equals(final Object o) {
public int hashCode() {
return Objects.hashCode(
timeframe,
couponCode,
collectionMethod
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,23 @@ public void testSerializationWithAddOns() throws Exception {
"<plan_code>gold</plan_code>" +
"</subscription>");
}

@Test(groups = "fast")
public void testSerializationWithCoupons() throws Exception {
final SubscriptionUpdate subscription = new SubscriptionUpdate();
subscription.setPlanCode("gold");
subscription.setTimeframe(SubscriptionUpdate.Timeframe.now);
subscription.setUnitAmountInCents(800);
subscription.setQuantity(1);
subscription.setCouponCode("my_coupon");

final String xml = xmlMapper.writeValueAsString(subscription);
Assert.assertEquals(xml, "<subscription xmlns=\"\">" +
"<timeframe>now</timeframe>" +
"<unit_amount_in_cents>800</unit_amount_in_cents>" +
"<quantity>1</quantity>" +
"<plan_code>gold</plan_code>" +
"<coupon_code>my_coupon</coupon_code>" +
"</subscription>");
}
}

0 comments on commit 85a3bc6

Please sign in to comment.