Skip to content

Commit

Permalink
Add a wholesome test to ensure proper JSON converters are applied (#1761
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ob-stripe committed Oct 8, 2019
1 parent 6b5e4bd commit 501cf81
Show file tree
Hide file tree
Showing 26 changed files with 170 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ namespace Stripe
{
using System;
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class AccountTosAcceptanceOptions : INestedOptions
{
[JsonProperty("date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? Date { get; set; }

[JsonProperty("ip")]
Expand Down
1 change: 1 addition & 0 deletions src/Stripe.net/Services/Coupons/CouponCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class CouponCreateOptions : BaseOptions, IHasId, IHasMetadata
public string Name { get; set; }

[JsonProperty("redeem_by")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? RedeemBy { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Stripe.net/Services/Customers/CustomerCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public class CustomerCreateOptions : BaseOptions, IHasMetadata
public decimal? TaxPercent { get; set; }

[JsonProperty("trial_end")]
[JsonConverter(typeof(AnyOfConverter))]
public AnyOf<DateTime?, SubscriptionTrialEnd> TrialEnd { get; set; }

[JsonProperty("validate")]
Expand Down
1 change: 1 addition & 0 deletions src/Stripe.net/Services/FileLinks/FileLinkSharedOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class FileLinkSharedOptions : BaseOptions, IHasMetadata
/// A future timestamp after which the link will no longer be usable.
/// </summary>
[JsonProperty("expires_at")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? ExpiresAt { get; set; }

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Stripe.net/Services/Files/FileLinkDataOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Stripe
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class FileLinkDataOptions : BaseOptions, IHasMetadata
{
Expand All @@ -19,6 +20,7 @@ public class FileLinkDataOptions : BaseOptions, IHasMetadata
/// A future timestamp after which the link will no longer be usable.
/// </summary>
[JsonProperty("expires_at")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? ExpiresAt { get; set; }

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class InvoiceCreateOptions : BaseOptions, IHasMetadata
/// <c>billing=send_invoice</c>.
/// </summary>
[JsonProperty("due_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? DueDate { get; set; }

/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/Stripe.net/Services/Invoices/InvoiceItemPeriodOptions.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
namespace Stripe
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class InvoiceItemPeriodOptions : INestedOptions
{
/// <summary>
/// The end of the period, which must be greater than or equal to the start.
/// </summary>
[JsonProperty("end")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? End { get; set; }

/// <summary>
/// he start of the period.
/// </summary>
[JsonProperty("start")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? Start { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class InvoiceUpdateOptions : BaseOptions, IHasMetadata
/// <c>billing=send_invoice</c>.
/// </summary>
[JsonProperty("due_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? DueDate { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public class UpcomingInvoiceListLineItemsOptions : ListOptions
/// <see cref="Stripe.SubscriptionBillingCycleAnchor"/>.
/// </summary>
[JsonProperty("subscription_billing_cycle_anchor")]
[JsonConverter(typeof(AnyOfConverter))]
public AnyOf<DateTime?, SubscriptionBillingCycleAnchor> SubscriptionBillingCycleAnchor { get; set; }

/// <summary>
/// Time at which the subscription would cancel.
/// </summary>
[JsonProperty("subscription_cancel_at")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? SubscriptionCancelAt { get; set; }

/// <summary>
Expand Down Expand Up @@ -109,6 +111,7 @@ public class UpcomingInvoiceListLineItemsOptions : ListOptions
/// be set to false.
/// </summary>
[JsonProperty("subscription_proration_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? SubscriptionProrationDate { get; set; }

/// <summary>
Expand All @@ -126,6 +129,7 @@ public class UpcomingInvoiceListLineItemsOptions : ListOptions
/// required.
/// </summary>
[JsonProperty("subscription_trial_end")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? SubscriptionTrialEnd { get; set; }

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions src/Stripe.net/Services/Invoices/UpcomingInvoiceOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public class UpcomingInvoiceOptions : BaseOptions
/// <see cref="Stripe.SubscriptionBillingCycleAnchor"/>.
/// </summary>
[JsonProperty("subscription_billing_cycle_anchor")]
[JsonConverter(typeof(AnyOfConverter))]
public AnyOf<DateTime?, SubscriptionBillingCycleAnchor> SubscriptionBillingCycleAnchor { get; set; }

/// <summary>
/// Time at which the subscription would cancel.
/// </summary>
[JsonProperty("subscription_cancel_at")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? SubscriptionCancelAt { get; set; }

/// <summary>
Expand Down Expand Up @@ -109,6 +111,7 @@ public class UpcomingInvoiceOptions : BaseOptions
/// be set to false.
/// </summary>
[JsonProperty("subscription_proration_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? SubscriptionProrationDate { get; set; }

/// <summary>
Expand All @@ -126,6 +129,7 @@ public class UpcomingInvoiceOptions : BaseOptions
/// required.
/// </summary>
[JsonProperty("subscription_trial_end")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? SubscriptionTrialEnd { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Stripe
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class PaymentIntentConfirmOptions : BaseOptions
{
Expand All @@ -20,6 +21,7 @@ public class PaymentIntentConfirmOptions : BaseOptions
/// charge them later</a>.
/// </summary>
[JsonProperty("off_session")]
[JsonConverter(typeof(AnyOfConverter))]
public AnyOf<bool?, string> OffSession { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Stripe
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class PaymentIntentCreateOptions : BaseOptions, IHasMetadata
{
Expand Down Expand Up @@ -87,6 +88,7 @@ public class PaymentIntentCreateOptions : BaseOptions, IHasMetadata
/// charge them later</a>.
/// </summary>
[JsonProperty("off_session")]
[JsonConverter(typeof(AnyOfConverter))]
public AnyOf<bool?, string> OffSession { get; set; }

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Stripe.net/Services/Plans/PlanTierOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Stripe
{
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class PlanTierOptions : INestedOptions
{
Expand Down Expand Up @@ -37,6 +38,7 @@ public class PlanTierOptions : INestedOptions
/// tier.
/// </summary>
[JsonProperty("up_to")]
[JsonConverter(typeof(AnyOfConverter))]
public AnyOf<long?, PlanTierUpTo> UpTo { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class ParametersOptions : INestedOptions
public string Currency { get; set; }

[JsonProperty("interval_end")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? IntervalEnd { get; set; }

[JsonProperty("interval_start")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? IntervalStart { get; set; }

[JsonProperty("payout")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Stripe
public class SourceMandateAcceptanceOnlineOptions : INestedOptions
{
[JsonProperty("date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? Date { get; set; }

[JsonProperty("ip")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Stripe
public class SourceMandateAcceptanceOptions : INestedOptions
{
[JsonProperty("date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? Date { get; set; }

[JsonProperty("ip")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public abstract class SubscriptionItemSharedOptions : BaseOptions
/// upcoming invoice endpoint.
/// </summary>
[JsonProperty("proration_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? ProrationDate { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace Stripe
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;

Expand All @@ -26,6 +25,7 @@ public class SubscriptionScheduleCreateOptions : SubscriptionScheduleSharedOptio
/// The date at which the subscription schedule starts.
/// </summary>
[JsonProperty("start_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? StartDate { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Stripe
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class SubscriptionSchedulePhaseOptions : INestedOptions
{
Expand Down Expand Up @@ -56,6 +57,7 @@ public class SubscriptionSchedulePhaseOptions : INestedOptions
/// <c>iterations</c> must not be set.
/// </summary>
[JsonProperty("end_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? EndDate { get; set; }

/// <summary>
Expand Down Expand Up @@ -84,6 +86,7 @@ public class SubscriptionSchedulePhaseOptions : INestedOptions
/// The date at which this phase of the subscription schedule starts.
/// </summary>
[JsonProperty("start_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? StartDate { get; set; }

/// <summary>
Expand All @@ -108,6 +111,7 @@ public class SubscriptionSchedulePhaseOptions : INestedOptions
/// end date, can not be combined with <c>trial</c>.
/// </summary>
[JsonProperty("trial_end")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? TrialEnd { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class SubscriptionCreateOptions : SubscriptionSharedOptions
/// date and the current time. Can be combined with trials and the billing cycle anchor.
/// </summary>
[JsonProperty("backdate_start_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? BackdateStartDate { get; set; }

/// <summary>
Expand All @@ -21,6 +22,7 @@ public class SubscriptionCreateOptions : SubscriptionSharedOptions
/// <c>month</c> or <c>year</c> intervals, the day of the month for subsequent invoices.
/// </summary>
[JsonProperty("billing_cycle_anchor")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? BillingCycleAnchor { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public abstract class SubscriptionSharedOptions : BaseOptions, IHasMetadata
/// current period ends this will cause a proration if <c>prorate=true</c>.
/// </summary>
[JsonProperty("cancel_at")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? CancelAt { get; set; }

/// <summary>
Expand Down Expand Up @@ -125,6 +126,7 @@ public abstract class SubscriptionSharedOptions : BaseOptions, IHasMetadata
/// immediately.
/// </summary>
[JsonProperty("trial_end")]
[JsonConverter(typeof(AnyOfConverter))]
public AnyOf<DateTime?, SubscriptionTrialEnd> TrialEnd { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Stripe
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class SubscriptionUpdateOptions : SubscriptionSharedOptions
{
Expand All @@ -25,6 +26,7 @@ public class SubscriptionUpdateOptions : SubscriptionSharedOptions
/// If set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply exactly the same proration that was previewed with <see href="https://stripe.com/docs/api#upcoming_invoice">upcoming invoice</see> endpoint. It can also be used to implement custom proration logic, such as prorating by day instead of by second, by providing the time that you wish to use for proration calculations.
/// </summary>
[JsonProperty("proration_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? ProrationDate { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Stripe.net/Services/Tokens/TokenCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class TokenCreateOptions : BaseOptions
/// details.
/// </summary>
[JsonProperty("card")]
[JsonConverter(typeof(AnyOfConverter))]
public AnyOf<string, CreditCardOptions> Card { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace Stripe
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;

Expand All @@ -11,6 +10,7 @@ public class UsageRecordCreateOptions : BaseOptions
public string Action { get; set; }

[JsonProperty("timestamp")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? Timestamp { get; set; }

[JsonProperty("quantity")]
Expand Down
5 changes: 5 additions & 0 deletions src/Stripe.net/Services/_common/DateRangeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@ namespace Stripe
{
using System;
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class DateRangeOptions : INestedOptions
{
[JsonProperty("gt")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? GreaterThan { get; set; }

[JsonProperty("gte")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? GreaterThanOrEqual { get; set; }

[JsonProperty("lt")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? LessThan { get; set; }

[JsonProperty("lte")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? LessThanOrEqual { get; set; }
}
}
Loading

0 comments on commit 501cf81

Please sign in to comment.