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

Fix JSON serialization of Stripe objects #1433

Merged
merged 6 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 7 additions & 1 deletion src/Stripe.net/Entities/Accounts/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, IPaymentS
/// (ID of a <see cref="File"/>) A logo for this account (at least 128px x 128px).
/// <para>Expandable.</para>
/// </summary>
[JsonIgnore]
public string BusinessLogoId { get; set; }

/// <summary>
Expand All @@ -30,6 +31,11 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, IPaymentS
[JsonProperty("business_logo")]
internal object InternalBusinessLogo
{
get
{
return this.BusinessLogo ?? (object)this.BusinessLogoId;
}

set
{
StringOrObject<File>.Map(value, s => this.BusinessLogoId = s, o => this.BusinessLogo = o);
Expand Down Expand Up @@ -68,7 +74,7 @@ internal object InternalBusinessLogo
/// <summary>
/// Whether this object is deleted or not.
/// </summary>
[JsonProperty("deleted")]
[JsonProperty("deleted", NullValueHandling=NullValueHandling.Ignore)]
public bool? Deleted { get; set; }

[JsonProperty("details_submitted")]
Expand Down
12 changes: 12 additions & 0 deletions src/Stripe.net/Entities/Accounts/LegalEntityVerification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class LegalEntityVerification : StripeEntity
/// document, either a passport or local ID card.
/// <para>Expandable.</para>
/// </summary>
[JsonIgnore]
public string DocumentId { get; set; }

/// <summary>
Expand All @@ -30,6 +31,11 @@ public class LegalEntityVerification : StripeEntity
[JsonProperty("document")]
internal object InternalDocument
{
get
{
return this.Document ?? (object)this.DocumentId;
}

set
{
StringOrObject<File>.Map(value, s => this.DocumentId = s, o => this.Document = o);
Expand All @@ -44,6 +50,7 @@ internal object InternalDocument
/// document, either a passport or local ID card.
/// <para>Expandable.</para>
/// </summary>
[JsonIgnore]
public string DocumentBackId { get; set; }

/// <summary>
Expand All @@ -56,6 +63,11 @@ internal object InternalDocument
[JsonProperty("document_back")]
internal object InternalDocumentBack
{
get
{
return this.DocumentBack ?? (object)this.DocumentBackId;
}

set
{
StringOrObject<File>.Map(value, s => this.DocumentBackId = s, o => this.DocumentBack = o);
Expand Down
2 changes: 1 addition & 1 deletion src/Stripe.net/Entities/ApplePayDomains/ApplePayDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ApplePayDomain : StripeEntity, IHasId, IHasObject
/// <summary>
/// Whether this object is deleted or not.
/// </summary>
[JsonProperty("deleted")]
[JsonProperty("deleted", NullValueHandling=NullValueHandling.Ignore)]
public bool? Deleted { get; set; }

[JsonProperty("domain_name")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class ApplicationFeeRefund : StripeEntity, IHasId, IHasMetadata, IHasObje
public long Amount { get; set; }

#region Expandable Balance Transaction
[JsonIgnore]
public string BalanceTransactionId { get; set; }

[JsonIgnore]
Expand All @@ -25,6 +26,11 @@ public class ApplicationFeeRefund : StripeEntity, IHasId, IHasMetadata, IHasObje
[JsonProperty("balance_transaction")]
internal object InternalBalanceTransaction
{
get
{
return this.BalanceTransaction ?? (object)this.BalanceTransactionId;
}

set
{
StringOrObject<BalanceTransaction>.Map(value, s => this.BalanceTransactionId = s, o => this.BalanceTransaction = o);
Expand All @@ -40,6 +46,7 @@ internal object InternalBalanceTransaction
public string Currency { get; set; }

#region Expandable Fee
[JsonIgnore]
public string FeeId { get; set; }

[JsonIgnore]
Expand All @@ -48,6 +55,11 @@ internal object InternalBalanceTransaction
[JsonProperty("fee")]
internal object InternalFee
{
get
{
return this.Fee ?? (object)this.FeeId;
}

set
{
StringOrObject<ApplicationFee>.Map(value, s => this.FeeId = s, o => this.Fee = o);
Expand Down
30 changes: 30 additions & 0 deletions src/Stripe.net/Entities/ApplicationFees/ApplicationFee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ApplicationFee : StripeEntity, IHasId, IHasObject, IBalanceTransact
public string Object { get; set; }

#region Expandable Account
[JsonIgnore]
public string AccountId { get; set; }

[JsonIgnore]
Expand All @@ -21,6 +22,11 @@ public class ApplicationFee : StripeEntity, IHasId, IHasObject, IBalanceTransact
[JsonProperty("account")]
internal object InternalAccount
{
get
{
return this.Account ?? (object)this.AccountId;
}

set
{
StringOrObject<Account>.Map(value, s => this.AccountId = s, o => this.Account = o);
Expand All @@ -35,6 +41,7 @@ internal object InternalAccount
public long AmountRefunded { get; set; }

#region Expandable Application
[JsonIgnore]
public string ApplicationId { get; set; }

[JsonIgnore]
Expand All @@ -43,6 +50,11 @@ internal object InternalAccount
[JsonProperty("application")]
internal object InternalApplication
{
get
{
return this.Application ?? (object)this.ApplicationId;
}

set
{
StringOrObject<Application>.Map(value, s => this.ApplicationId = s, o => this.Application = o);
Expand All @@ -51,6 +63,7 @@ internal object InternalApplication
#endregion

#region Expandable Balance Transaction
[JsonIgnore]
public string BalanceTransactionId { get; set; }

[JsonIgnore]
Expand All @@ -59,6 +72,11 @@ internal object InternalApplication
[JsonProperty("balance_transaction")]
internal object InternalBalanceTransaction
{
get
{
return this.BalanceTransaction ?? (object)this.BalanceTransactionId;
}

set
{
StringOrObject<BalanceTransaction>.Map(value, s => this.BalanceTransactionId = s, o => this.BalanceTransaction = o);
Expand All @@ -67,6 +85,7 @@ internal object InternalBalanceTransaction
#endregion

#region Expandable Charge
[JsonIgnore]
public string ChargeId { get; set; }

[JsonIgnore]
Expand All @@ -75,6 +94,11 @@ internal object InternalBalanceTransaction
[JsonProperty("charge")]
internal object InternalCharge
{
get
{
return this.Charge ?? (object)this.ChargeId;
}

set
{
StringOrObject<Charge>.Map(value, s => this.ChargeId = s, o => this.Charge = o);
Expand All @@ -93,6 +117,7 @@ internal object InternalCharge
public bool Livemode { get; set; }

#region Expandable Originating Transaction
[JsonIgnore]
public string OriginatingTransactionId { get; set; }

[JsonIgnore]
Expand All @@ -101,6 +126,11 @@ internal object InternalCharge
[JsonProperty("originating_transaction")]
internal object InternalOriginatingTransaction
{
get
{
return this.OriginatingTransaction ?? (object)this.OriginatingTransactionId;
}

set
{
StringOrObject<Charge>.Map(value, s => this.OriginatingTransactionId = s, o => this.OriginatingTransaction = o);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class BalanceTransaction : StripeEntity, IHasId, IHasObject
public long Net { get; set; }

#region Expandable Source
[JsonIgnore]
public string SourceId { get; set; }

[JsonIgnore]
Expand All @@ -51,6 +52,11 @@ public class BalanceTransaction : StripeEntity, IHasId, IHasObject
[JsonProperty("source")]
internal object InternalSource
{
get
{
return this.Source ?? (object)this.SourceId;
}

set
{
StringOrObject<IBalanceTransactionSource>.Map(value, s => this.SourceId = s, o => this.Source = o);
Expand Down
14 changes: 13 additions & 1 deletion src/Stripe.net/Entities/BankAccounts/BankAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class BankAccount : StripeEntity, IHasId, IHasMetadata, IHasObject, IExte
public string Object { get; set; }

#region Expandable Account
[JsonIgnore]
public string AccountId { get; set; }

[JsonIgnore]
Expand All @@ -22,6 +23,11 @@ public class BankAccount : StripeEntity, IHasId, IHasMetadata, IHasObject, IExte
[JsonProperty("account")]
internal object InternalAccount
{
get
{
return this.Account ?? (object)this.AccountId;
}

set
{
StringOrObject<Account>.Map(value, s => this.AccountId = s, o => this.Account = o);
Expand All @@ -45,6 +51,7 @@ internal object InternalAccount
public string Currency { get; set; }

#region Expandable Customer
[JsonIgnore]
public string CustomerId { get; set; }

[JsonIgnore]
Expand All @@ -53,6 +60,11 @@ internal object InternalAccount
[JsonProperty("customer")]
internal object InternalCustomer
{
get
{
return this.Customer ?? (object)this.CustomerId;
}

set
{
StringOrObject<Customer>.Map(value, s => this.CustomerId = s, o => this.Customer = o);
Expand All @@ -66,7 +78,7 @@ internal object InternalCustomer
/// <summary>
/// Whether this object is deleted or not.
/// </summary>
[JsonProperty("deleted")]
[JsonProperty("deleted", NullValueHandling=NullValueHandling.Ignore)]
public bool? Deleted { get; set; }

[JsonProperty("fingerprint")]
Expand Down
20 changes: 19 additions & 1 deletion src/Stripe.net/Entities/Cards/Card.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Card : StripeEntity, IHasId, IHasMetadata, IHasObject, IExternalAcc
public string Object { get; set; }

#region Expandable Account
[JsonIgnore]
public string AccountId { get; set; }

[JsonIgnore]
Expand All @@ -21,6 +22,11 @@ public class Card : StripeEntity, IHasId, IHasMetadata, IHasObject, IExternalAcc
[JsonProperty("account")]
internal object InternalAccount
{
get
{
return this.Account ?? (object)this.AccountId;
}

set
{
StringOrObject<Account>.Map(value, s => this.AccountId = s, o => this.Account = o);
Expand Down Expand Up @@ -65,6 +71,7 @@ internal object InternalAccount
public string Currency { get; set; }

#region Expandable Customer
[JsonIgnore]
public string CustomerId { get; set; }

[JsonIgnore]
Expand All @@ -73,6 +80,11 @@ internal object InternalAccount
[JsonProperty("customer")]
internal object InternalCustomer
{
get
{
return this.Customer ?? (object)this.CustomerId;
}

set
{
StringOrObject<Customer>.Map(value, s => this.CustomerId = s, o => this.Customer = o);
Expand All @@ -89,7 +101,7 @@ internal object InternalCustomer
/// <summary>
/// Whether this object is deleted or not.
/// </summary>
[JsonProperty("deleted")]
[JsonProperty("deleted", NullValueHandling=NullValueHandling.Ignore)]
public bool? Deleted { get; set; }
ob-stripe marked this conversation as resolved.
Show resolved Hide resolved

[JsonProperty("dynamic_last4")]
Expand Down Expand Up @@ -117,6 +129,7 @@ internal object InternalCustomer
public string Name { get; set; }

#region Expandable Recipient
[JsonIgnore]
public string RecipientId { get; set; }

[JsonIgnore]
Expand All @@ -125,6 +138,11 @@ internal object InternalCustomer
[JsonProperty("recipient")]
internal object InternalRecipient
{
get
{
return this.Recipient ?? (object)this.RecipientId;
}

set
{
StringOrObject<Recipient>.Map(value, s => this.RecipientId = s, o => this.Recipient = o);
Expand Down
Loading