From 147a55aae730fd2bcfe7e429fd22a573e47c5b05 Mon Sep 17 00:00:00 2001 From: Amanda Date: Wed, 14 Aug 2024 11:38:37 -0700 Subject: [PATCH] Get external sub by uuid --- Library/ExternalSubscription.cs | 21 +++++++++++++++++++++ Test/ExternalSubscriptionTest.cs | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Library/ExternalSubscription.cs b/Library/ExternalSubscription.cs index d1314fcb..afa55e34 100644 --- a/Library/ExternalSubscription.cs +++ b/Library/ExternalSubscription.cs @@ -34,6 +34,7 @@ public List ExternalInvoices public bool? InGracePeriod { get; set; } public int Quantity { get; set; } public ExternalProductReference ExternalProductReference { get; private set; } + public string Uuid { get; private set; } public DateTime? LastPurchased { get; private set; } public bool? Imported { get; set; } public bool? Test { get; set; } @@ -128,6 +129,10 @@ internal override void ReadXml(XmlTextReader reader) AppIdentifier = reader.ReadElementContentAsString(); break; + case "uuid": + AppIdentifier = reader.ReadElementContentAsString(); + break; + case "quantity": Quantity = reader.ReadElementContentAsInt(); break; @@ -231,6 +236,22 @@ public static ExternalSubscription GetByExternalId(string externalId) ); return statusCode == HttpStatusCode.NotFound ? null : externalSubscription; } + + public static ExternalSubscription GetByUuid(string uuid) + { + if (string.IsNullOrWhiteSpace(uuid)) + { + return null; + } + var externalSubscription = new ExternalSubscription(); + var statusCode = Client.Instance.PerformRequest( + Client.HttpRequestMethod.Get, + ExternalSubscription.UrlPrefix + Uri.EscapeDataString("uuid-" + uuid), + externalSubscription.ReadXml + ); + return statusCode == HttpStatusCode.NotFound ? null : externalSubscription; + } + /// /// Returns a list of external_invoices for this external subscription /// diff --git a/Test/ExternalSubscriptionTest.cs b/Test/ExternalSubscriptionTest.cs index e101768c..3d68d661 100644 --- a/Test/ExternalSubscriptionTest.cs +++ b/Test/ExternalSubscriptionTest.cs @@ -21,6 +21,7 @@ public void LookupExternalSubscription() externalSubscription.TrialEndsAt.Should().Be(null); externalSubscription.Imported.Should().Be(false); externalSubscription.Test.Should().Be(false); + // externalSubscription.Uuid.Should().Be("fill this in after backfill"); id = 3799097350953132104 } } -} +} \ No newline at end of file