Skip to content

Commit

Permalink
Merge d1389c3 into 1493e42
Browse files Browse the repository at this point in the history
  • Loading branch information
kcraybould committed Jan 4, 2018
2 parents 1493e42 + d1389c3 commit f1c3bd0
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions lib/stripe/subscriptions/coupon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ defmodule Stripe.Coupon do
@type t :: %__MODULE__{
id: Stripe.id(),
object: String.t(),
amount_off: pos_integer,
amount_off: pos_integer | nil,
created: Stripe.timestamp(),
currency: String.t(),
currency: String.t() | nil,
duration: String.t(),
duration_in_months: pos_integer | nil,
livemode: boolean,
max_redemptions: pos_integer,
metadata: Stripe.Types.metadata(),
percent_off: pos_integer,
redeem_by: Stripe.timestamp(),
max_redemptions: pos_integer | nil,
metadata: %{
optional(String.t()) => String.t()
},
percent_off: pos_integer | nil,
redeem_by: Stripe.timestamp() | nil,
times_redeemed: non_neg_integer,
valid: boolean
}
Expand Down Expand Up @@ -57,16 +59,16 @@ defmodule Stripe.Coupon do
"""
@spec create(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
id: String.t(),
duration: String.t(),
amount_off: pos_integer,
currency: String.t(),
duration_in_months: pos_integer,
max_redemptions: pos_integer,
metadata: Stripe.Types.metadata(),
percent_off: pos_integer,
redeem_by: Stripe.timestamp()
} | %{}
optional(:id) => String.t(),
:duration => String.t(),
optional(:amount_off) => pos_integer,
optional(:duration_in_months) => pos_integer,
optional(:currency) => String.t(),
optional(:max_redemptions) => pos_integer,
optional(:metadata) => Stripe.Types.metadata(),
optional(:percent_off) => pos_integer,
optional(:redeem_by) => Stripe.timestamp()
}
def create(params, opts \\ []) do
new_request(opts)
|> put_endpoint(@plural_endpoint)
Expand All @@ -93,9 +95,11 @@ defmodule Stripe.Coupon do
Takes the `id` and a map of changes.
"""
@spec update(Stripe.id() | t, params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
metadata: Stripe.Types.metadata()
} | %{}
when params:
%{
metadata: Stripe.Types.metadata()
}
| %{}
def update(id, params, opts \\ []) do
new_request(opts)
|> put_endpoint(@plural_endpoint <> "/#{get_id!(id)}")
Expand All @@ -120,11 +124,11 @@ defmodule Stripe.Coupon do
"""
@spec list(params, Stripe.options()) :: {:ok, Stripe.List.t(t)} | {:error, Stripe.Error.t()}
when params: %{
created: Stripe.date_query(),
ending_before: t | Stripe.id(),
limit: 1..100,
starting_after: t | Stripe.id()
} | %{}
optional(:created) => Stripe.date_query(),
optional(:ending_before) => t | Stripe.id(),
optional(:limit) => 1..100,
optional(:starting_after) => t | Stripe.id()
}
def list(params \\ %{}, opts \\ []) do
new_request(opts)
|> put_endpoint(@plural_endpoint)
Expand Down

0 comments on commit f1c3bd0

Please sign in to comment.