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

Support JSON serialization with System.Text.Json #2971

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 22 additions & 1 deletion src/Stripe.net/Entities/AccountLinks/AccountLink.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using System;
#if USE_SYSTEM_TEXT_JSON
using System.Text.Json.Serialization;
#else
using Newtonsoft.Json;
#endif
using Stripe.Infrastructure;

/// <summary>
Expand All @@ -17,27 +20,45 @@ public class AccountLink : StripeEntity<AccountLink>, IHasObject
/// <summary>
/// String representing the object's type. Objects of the same type share the same value.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("object")]
#else
[JsonProperty("object")]
#endif
public string Object { get; set; }

/// <summary>
/// Time at which the object was created. Measured in seconds since the Unix epoch.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("created")]
[JsonConverter(typeof(UnixDateTimeConverter))]
#else
[JsonProperty("created")]
[JsonConverter(typeof(UnixDateTimeConverter))]
#endif
public DateTime Created { get; set; } = Stripe.Infrastructure.DateTimeUtils.UnixEpoch;

/// <summary>
/// The timestamp at which this account link will expire.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("expires_at")]
[JsonConverter(typeof(UnixDateTimeConverter))]
#else
[JsonProperty("expires_at")]
[JsonConverter(typeof(UnixDateTimeConverter))]
#endif
public DateTime ExpiresAt { get; set; } = Stripe.Infrastructure.DateTimeUtils.UnixEpoch;

/// <summary>
/// The URL for the account link.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("url")]
#else
[JsonProperty("url")]
#endif
public string Url { get; set; }
}
}
98 changes: 97 additions & 1 deletion src/Stripe.net/Entities/Accounts/Account.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// File generated from our OpenAPI spec
namespace Stripe
{
using System;
using System.Collections.Generic;
#if USE_SYSTEM_TEXT_JSON
using System.Text.Json.Serialization;
#else
using Newtonsoft.Json;
#endif
using Stripe.Infrastructure;

/// <summary>
Expand All @@ -29,19 +32,31 @@ public class Account : StripeEntity<Account>, IHasId, IHasMetadata, IHasObject,
/// <summary>
/// Unique identifier for the object.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("id")]
#else
[JsonProperty("id")]
#endif
public string Id { get; set; }

/// <summary>
/// String representing the object's type. Objects of the same type share the same value.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("object")]
#else
[JsonProperty("object")]
#endif
public string Object { get; set; }

/// <summary>
/// Business information about the account.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("business_profile")]
#else
[JsonProperty("business_profile")]
#endif
public AccountBusinessProfile BusinessProfile { get; set; }

/// <summary>
Expand All @@ -54,49 +69,86 @@ public class Account : StripeEntity<Account>, IHasId, IHasMetadata, IHasObject,
/// One of: <c>company</c>, <c>government_entity</c>, <c>individual</c>, or
/// <c>non_profit</c>.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("business_type")]
#else
[JsonProperty("business_type")]
#endif
public string BusinessType { get; set; }

#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("capabilities")]
#else
[JsonProperty("capabilities")]
#endif
public AccountCapabilities Capabilities { get; set; }

/// <summary>
/// Whether the account can create live charges.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("charges_enabled")]
#else
[JsonProperty("charges_enabled")]
#endif
public bool ChargesEnabled { get; set; }

#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("company")]
#else
[JsonProperty("company")]
#endif
public AccountCompany Company { get; set; }

#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("controller")]
#else
[JsonProperty("controller")]
#endif
public AccountController Controller { get; set; }

/// <summary>
/// The account's country.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("country")]
#else
[JsonProperty("country")]
#endif
public string Country { get; set; }

/// <summary>
/// Time at which the account was connected. Measured in seconds since the Unix epoch.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("created")]
[JsonConverter(typeof(UnixDateTimeConverter))]
#else
[JsonProperty("created")]
[JsonConverter(typeof(UnixDateTimeConverter))]
#endif
public DateTime Created { get; set; } = Stripe.Infrastructure.DateTimeUtils.UnixEpoch;

/// <summary>
/// Three-letter ISO currency code representing the default currency for the account. This
/// must be a currency that <a href="https://stripe.com/docs/payouts">Stripe supports in the
/// account's country</a>.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("default_currency")]
#else
[JsonProperty("default_currency")]
#endif
public string DefaultCurrency { get; set; }

/// <summary>
/// Whether this object is deleted or not.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("deleted")]
#else
[JsonProperty("deleted", NullValueHandling = NullValueHandling.Ignore)]
#endif
public bool? Deleted { get; set; }

/// <summary>
Expand All @@ -106,25 +158,41 @@ public class Account : StripeEntity<Account>, IHasId, IHasMetadata, IHasObject,
/// href="https://stripe.com/connect/onboarding">an onboarding flow</a> to finish submitting
/// account details.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("details_submitted")]
#else
[JsonProperty("details_submitted")]
#endif
public bool DetailsSubmitted { get; set; }

/// <summary>
/// An email address associated with the account. It's not used for authentication and
/// Stripe doesn't market to this field without explicit approval from the platform.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("email")]
#else
[JsonProperty("email")]
#endif
public string Email { get; set; }

/// <summary>
/// External accounts (bank accounts and debit cards) currently attached to this account.
/// External accounts are only returned for requests where <c>controller[is_controller]</c>
/// is true.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("external_accounts")]
#else
[JsonProperty("external_accounts")]
#endif
public StripeList<IExternalAccount> ExternalAccounts { get; set; }

#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("future_requirements")]
#else
[JsonProperty("future_requirements")]
#endif
public AccountFutureRequirements FutureRequirements { get; set; }

/// <summary>
Expand All @@ -142,41 +210,69 @@ public class Account : StripeEntity<Account>, IHasId, IHasMetadata, IHasObject,
/// href="https://stripe.com/connect/handling-api-verification#person-information">handling
/// identity verification with the API</a>.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("individual")]
#else
[JsonProperty("individual")]
#endif
public Person Individual { get; set; }

/// <summary>
/// Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can
/// attach to an object. This can be useful for storing additional information about the
/// object in a structured format.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("metadata")]
#else
[JsonProperty("metadata")]
#endif
public Dictionary<string, string> Metadata { get; set; }

/// <summary>
/// Whether Stripe can send payouts to this account.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("payouts_enabled")]
#else
[JsonProperty("payouts_enabled")]
#endif
public bool PayoutsEnabled { get; set; }

#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("requirements")]
#else
[JsonProperty("requirements")]
#endif
public AccountRequirements Requirements { get; set; }

/// <summary>
/// Options for customizing how the account functions within Stripe.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("settings")]
#else
[JsonProperty("settings")]
#endif
public AccountSettings Settings { get; set; }

#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("tos_acceptance")]
#else
[JsonProperty("tos_acceptance")]
#endif
public AccountTosAcceptance TosAcceptance { get; set; }

/// <summary>
/// The Stripe account type. Can be <c>standard</c>, <c>express</c>, <c>custom</c>, or
/// <c>none</c>.
/// One of: <c>custom</c>, <c>express</c>, <c>none</c>, or <c>standard</c>.
/// </summary>
#if USE_SYSTEM_TEXT_JSON
[JsonPropertyName("type")]
#else
[JsonProperty("type")]
#endif
public string Type { get; set; }
}
}
Loading