Skip to content

Commit

Permalink
Get external sub by uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
amandamfielding committed Aug 27, 2024
1 parent e528914 commit 147a55a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Library/ExternalSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public List<ExternalInvoice> 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; }
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

/// <summary>
/// Returns a list of external_invoices for this external subscription
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion Test/ExternalSubscriptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}

0 comments on commit 147a55a

Please sign in to comment.