Skip to content

Commit

Permalink
Merge pull request #771 from recurly/external-resources-subscriptions…
Browse files Browse the repository at this point in the history
…-update

Added `ExternalSubscription.ExternalId`, removed `ExternalResource`
  • Loading branch information
amandamfielding authored Feb 22, 2023
2 parents 3e81240 + 68cb031 commit f27403c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 78 deletions.
18 changes: 0 additions & 18 deletions Library/ExternalProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,6 @@ internal ExternalProduct(XmlTextReader reader)

#region Read and Write XML documents

internal void ReadExternalResourceXml(XmlTextReader reader)
{
while (reader.Read())
{
if (reader.Name == "external_resource" && reader.NodeType == XmlNodeType.EndElement)
break;

if (reader.NodeType != XmlNodeType.Element) continue;

switch (reader.Name)
{
case "external_object_reference":
ExternalObjectReference = reader.ReadElementContentAsString();
break;
}
}
}

internal void ReadExternalProductReferenceXml(XmlTextReader reader)
{
ExternalProductReferenceList = new List<ExternalProductReference>();
Expand Down
49 changes: 0 additions & 49 deletions Library/ExternalResource.cs

This file was deleted.

20 changes: 10 additions & 10 deletions Library/ExternalSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ public Account Account
internal set { _account = value; }
}

public string ExternalId { get; set; }
public string AppIdentifier { get; private set; }
public string State { get; set; }
public bool? AutoRenew { get; set; }
public int Quantity { get; set; }
public ExternalProductReference ExternalProductReference { get; private set; }
public ExternalResource ExternalResource { get; private set; }
public DateTime? LastPurchased { get; private set; }
public DateTime? ActivatedAt { get; private set; }
public DateTime? ExpiresAt { get; private set; }
Expand All @@ -45,11 +46,6 @@ internal ExternalSubscription(XmlTextReader reader)

#region Read XML documents

internal void ReadExternalResourceXml(XmlTextReader reader)
{
ExternalResource = new ExternalResource(reader);
}

internal void ReadExternalProductReferenceXml(XmlTextReader reader)
{
ExternalProductReference = new ExternalProductReference(reader);
Expand All @@ -75,19 +71,23 @@ internal override void ReadXml(XmlTextReader reader)
_accountCode = Uri.UnescapeDataString(href.Substring(href.LastIndexOf("/") + 1));
break;

case "external_product_reference":
ReadExternalProductReferenceXml(reader);
case "external_id":
ExternalId = reader.ReadElementContentAsString();
break;

case "external_resource":
ReadExternalResourceXml(reader);
case "external_product_reference":
ReadExternalProductReferenceXml(reader);
break;

case "last_purchased":
if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
LastPurchased = dateVal;
break;

case "state":
State = reader.ReadElementContentAsString();
break;

case "auto_renew":
bool b;
if (bool.TryParse(reader.ReadElementContentAsString(), out b))
Expand Down
3 changes: 2 additions & 1 deletion Test/ExternalSubscriptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public void LookupExternalSubscription()
var uuid = "rv1loyqlf6si";
var externalSubscription = ExternalSubscriptions.Get(uuid);
externalSubscription.Quantity.Should().Be(14);
externalSubscription.ExternalResource.ExternalObjectReference.Should().Be("36d2313d-5663-49f6-80e1-0cd6ed69b792");
externalSubscription.State.Should().Be("");
externalSubscription.ExternalId.Should().Be("");
}
}
}

0 comments on commit f27403c

Please sign in to comment.