From 67772db1c183a275458480affe6af3672418f167 Mon Sep 17 00:00:00 2001 From: Paulo Pinho Date: Wed, 12 Jun 2024 18:03:18 -0300 Subject: [PATCH] GET external_subscription by external_id Added new method to get external_subscription by external_id. --- .../ning/billing/recurly/RecurlyClient.java | 11 ++++++++++ .../recurly/model/ExternalSubscription.java | 22 +++++++++++++++++++ .../model/TestExternalSubscription.java | 4 ++++ .../model/TestExternalSubscriptions.java | 4 ++++ 4 files changed, 41 insertions(+) diff --git a/src/main/java/com/ning/billing/recurly/RecurlyClient.java b/src/main/java/com/ning/billing/recurly/RecurlyClient.java index 6acdb1ee..59785456 100644 --- a/src/main/java/com/ning/billing/recurly/RecurlyClient.java +++ b/src/main/java/com/ning/billing/recurly/RecurlyClient.java @@ -1210,6 +1210,17 @@ public ExternalSubscription getExternalSubscription(final String externalSubscri return doGET(ExternalSubscriptions.EXTERNAL_SUBSCRIPTIONS_RESOURCE + "/" + urlEncode(externalSubscriptionUuid), ExternalSubscription.class); } + /** + * Get a specific External Subscription by external id + *

+ * Returns the requested external subscriptions + * + * @param externalSubscriptionExternalId external subscription external id + * @return The requested external subscription + */ + public ExternalSubscription getExternalSubscriptionByExternalId(final String externalSubscriptionExternalId) { + return doGET(ExternalSubscriptions.EXTERNAL_SUBSCRIPTIONS_RESOURCE + "/" + urlEncode("external-id-"+externalSubscriptionExternalId), ExternalSubscription.class); + } /** * Get External Accounts of an account *

diff --git a/src/main/java/com/ning/billing/recurly/model/ExternalSubscription.java b/src/main/java/com/ning/billing/recurly/model/ExternalSubscription.java index 02823a65..30f92296 100644 --- a/src/main/java/com/ning/billing/recurly/model/ExternalSubscription.java +++ b/src/main/java/com/ning/billing/recurly/model/ExternalSubscription.java @@ -43,6 +43,12 @@ public class ExternalSubscription extends RecurlyObject { @XmlElement(name = "last_purchased") private DateTime lastPurchased; + @XmlElement(name = "imported") + private Boolean imported; + + @XmlElement(name = "test") + private Boolean test; + @XmlElement(name = "auto_renew") private Boolean autoRenew; @@ -138,6 +144,22 @@ public void setInGracePeriod(final Object inGracePeriod) { this.inGracePeriod = booleanOrNull(inGracePeriod); } + public Boolean getImported() { + return imported; + } + + public void setImported(final Object imported) { + this.imported = booleanOrNull(imported); + } + + public Boolean getTest() { + return test; + } + + public void setTest(final Object test) { + this.test = booleanOrNull(test); + } + public String getAppIdentifier() { return this.appIdentifier; } diff --git a/src/test/java/com/ning/billing/recurly/model/TestExternalSubscription.java b/src/test/java/com/ning/billing/recurly/model/TestExternalSubscription.java index e27dd958..9a50f09b 100644 --- a/src/test/java/com/ning/billing/recurly/model/TestExternalSubscription.java +++ b/src/test/java/com/ning/billing/recurly/model/TestExternalSubscription.java @@ -38,6 +38,8 @@ public void testDeserialization() throws Exception { " 2022-09-12T18:40:51Z" + " " + " 2022-09-12T18:40:51Z" + + " false" + + " false" + " false" + " false" + " com.foo.id" + @@ -62,6 +64,8 @@ public void testDeserialization() throws Exception { Assert.assertEquals(externalSubscription.getExternalProductReference().getCreatedAt(), new DateTime("2022-09-12T18:40:51Z")); Assert.assertEquals(externalSubscription.getExternalProductReference().getUpdatedAt(), new DateTime("2022-09-12T18:40:51Z")); Assert.assertEquals(externalSubscription.getLastPurchased(), new DateTime("2022-09-12T18:40:51Z")); + Assert.assertEquals(externalSubscription.getImported(), Boolean.FALSE); + Assert.assertEquals(externalSubscription.getTest(), Boolean.FALSE); Assert.assertEquals(externalSubscription.getAutoRenew(), Boolean.FALSE); Assert.assertEquals(externalSubscription.getInGracePeriod(), Boolean.FALSE); Assert.assertEquals(externalSubscription.getAppIdentifier(), "com.foo.id"); diff --git a/src/test/java/com/ning/billing/recurly/model/TestExternalSubscriptions.java b/src/test/java/com/ning/billing/recurly/model/TestExternalSubscriptions.java index 255ab1b4..c64b6a35 100644 --- a/src/test/java/com/ning/billing/recurly/model/TestExternalSubscriptions.java +++ b/src/test/java/com/ning/billing/recurly/model/TestExternalSubscriptions.java @@ -39,6 +39,8 @@ public void testDeserialization() throws Exception { " 2022-09-12T18:40:51Z" + " " + " 2022-09-12T18:40:51Z" + + " false" + + " false" + " false" + " false" + " com.foo.id" + @@ -67,6 +69,8 @@ public void testDeserialization() throws Exception { Assert.assertEquals(externalSubscription.getExternalProductReference().getCreatedAt(), new DateTime("2022-09-12T18:40:51Z")); Assert.assertEquals(externalSubscription.getExternalProductReference().getUpdatedAt(), new DateTime("2022-09-12T18:40:51Z")); Assert.assertEquals(externalSubscription.getLastPurchased(), new DateTime("2022-09-12T18:40:51Z")); + Assert.assertEquals(externalSubscription.getImported(), Boolean.FALSE); + Assert.assertEquals(externalSubscription.getTest(), Boolean.FALSE); Assert.assertEquals(externalSubscription.getAutoRenew(), Boolean.FALSE); Assert.assertEquals(externalSubscription.getInGracePeriod(), Boolean.FALSE); Assert.assertEquals(externalSubscription.getAppIdentifier(), "com.foo.id");