Skip to content

Commit

Permalink
GET external_subscription by external_id
Browse files Browse the repository at this point in the history
Added new method to get external_subscription by external_id.
  • Loading branch information
paulorbpinho-fullstacklabs committed Jun 12, 2024
1 parent 351dc00 commit 3f43daa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Library/ExternalSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public List<ExternalInvoice> ExternalInvoices
public int Quantity { get; set; }
public ExternalProductReference ExternalProductReference { get; private set; }
public DateTime? LastPurchased { get; private set; }
public bool? Import { get; set; }
public DateTime? ActivatedAt { get; private set; }
public DateTime? CanceledAt { get; private set; }
public DateTime? ExpiresAt { get; private set; }
Expand Down Expand Up @@ -93,6 +94,12 @@ internal override void ReadXml(XmlTextReader reader)
if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
LastPurchased = dateVal;
break;

case "import":
bool import;
if (bool.TryParse(reader.ReadElementContentAsString(), out import))
Import = import;
break;

case "state":
State = reader.ReadElementContentAsString();
Expand Down Expand Up @@ -202,6 +209,20 @@ public static ExternalSubscription Get(string uuid)

return statusCode == HttpStatusCode.NotFound ? null : externalSubscription;
}

public static ExternalSubscription GetByExternalId(string externalId)
{
if (string.IsNullOrWhiteSpace(externalId))
{
return null;
}
var externalSubscription = new ExternalSubscription();
var statusCode = Client.Instance.PerformRequest(Client.HttpRequestMethod.Get,
ExternalSubscription.UrlPrefix + Uri.EscapeDataString("external-id-"+externalId),
externalSubscription.ReadXml);

return statusCode == HttpStatusCode.NotFound ? null : externalSubscription;
}
/// <summary>
/// Returns a list of external_invoices for this external subscription
/// </summary>
Expand Down

0 comments on commit 3f43daa

Please sign in to comment.