Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get external sub by uuid #846

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
}
}
Loading