Skip to content

Commit

Permalink
change subscription schedule plans to items
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Sep 4, 2022
1 parent 32fc8cf commit 92788c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
33 changes: 20 additions & 13 deletions lib/stripe/subscriptions/subscription_schedule.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ defmodule Stripe.SubscriptionSchedule do
use Stripe.Entity
import Stripe.Request

@type plans :: %{
plan: String.t(),
@type items :: %{
billing_thresholds: Stripe.Types.collection_method_thresholds(),
price: String.t(),
quantity: pos_integer
quantity: pos_integer,
tax_rates: [Stripe.TaxRate.t()],
}

@type phases :: %{
collection_method: string | nil,
collection_method: string | nil,
coupon: string | nil,
default_payment_method: string | nil,
default_tax_rates: float | nil,
application_fee_percent: float | nil,
end_date: Stripe.timestamp(),
start_date: Stripe.timestamp(),
tax_percent: float | nil,
trial_end: Stripe.timestamp(),
plans: list(plans)
items: list(items)
}

@type default_settings :: %{
Expand Down Expand Up @@ -49,6 +54,7 @@ defmodule Stripe.SubscriptionSchedule do
revision: String.t(),
status: String.t(),
subscription: Stripe.id() | Stripe.Subscription.t(),
test_clock: Stripe.id() | Stripe.Subscription.t(),
customer: Stripe.id() | Stripe.Customer.t(),
released_subscription: Stripe.id() | Stripe.Subscription.t() | nil,
phases: list(phases)
Expand All @@ -71,7 +77,8 @@ defmodule Stripe.SubscriptionSchedule do
:livemode,
:metadata,
:end_behavior,
:revision
:revision,
:test_clock,
]

@plural_endpoint "subscription_schedules"
Expand All @@ -98,19 +105,19 @@ defmodule Stripe.SubscriptionSchedule do
},
optional(:phases) => [
%{
:plans => [
:items => [
%{
optional(:plan) => Stripe.id() | Stripe.Plan.t(),
optional(:billing_thresholds): Stripe.Types.collection_method_thresholds()
optional(:price) => Stripe.id() | Stripe.Price.t(),
optional(:quantity) => non_neg_integer
optional(:quantity) => non_neg_integer,
optional(:tax_rates) => [Stripe.TaxRate.t()]
}
],
optional(:application_fee_percent) => non_neg_integer,
optional(:coupon) => String.t(),
optional(:end_date) => Stripe.timestamp(),
optional(:iterations) => non_neg_integer,
optional(:start_date) => Stripe.timestamp(),
optional(:tax_percent) => float,
optional(:trial) => boolean(),
optional(:trial_end) => Stripe.timestamp()
}
Expand Down Expand Up @@ -152,19 +159,19 @@ defmodule Stripe.SubscriptionSchedule do
},
optional(:phases) => [
%{
:plans => [
:items => [
%{
optional(:plan) => Stripe.id() | Stripe.Plan.t(),
optional(:billing_thresholds): Stripe.Types.collection_method_thresholds() | nil,
optional(:price) => Stripe.id() | Stripe.Price.t(),
optional(:quantity) => non_neg_integer
optional(:tax_rates) => [Stripe.TaxRate.t()]
}
],
optional(:application_fee_percent) => non_neg_integer,
optional(:coupon) => String.t(),
optional(:end_date) => Stripe.timestamp(),
optional(:iterations) => non_neg_integer,
optional(:start_date) => Stripe.timestamp(),
optional(:tax_percent) => float,
optional(:trial) => boolean(),
optional(:trial_end) => Stripe.timestamp()
}
Expand Down
5 changes: 0 additions & 5 deletions test/stripe/subscriptions/subscription_schedule_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ defmodule Stripe.SubscriptionScheduleTest do
default_tax_rates: [],
end_date: 1_557_566_037,
start_date: 1_554_974_037,
tax_percent: 0
}
]
}
Expand All @@ -35,13 +34,11 @@ defmodule Stripe.SubscriptionScheduleTest do
end_date: 1_557_566_037,
items: [
%{
plan: "some plan",
quantity: 2,
tax_rates: []
}
],
start_date: 1_554_974_037,
tax_percent: 0
}
]
}
Expand Down Expand Up @@ -70,13 +67,11 @@ defmodule Stripe.SubscriptionScheduleTest do
end_date: 1_557_566_037,
items: [
%{
plan: "some plan",
quantity: 2,
tax_rates: []
}
],
start_date: 1_554_974_037,
tax_percent: 0
}
]
}
Expand Down

0 comments on commit 92788c8

Please sign in to comment.