Skip to content

Commit

Permalink
Add required params
Browse files Browse the repository at this point in the history
- add required params on Card.create, Cardholder.create, and Dispute.create functions
- add atom enums to typespecs and params
  • Loading branch information
Jason Cartwright authored and Jason Cartwright committed May 24, 2019
1 parent c9211bf commit 9e64940
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/stripe/issuing/card.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Stripe.Issuing.Card do
brand: String.t(),
cardholder: Stripe.Issuing.Cardholder.t(),
created: Stripe.timestamp(),
currency: String.t() | nil,
currency: String.t(),
exp_month: pos_integer,
exp_year: pos_integer,
last4: String.t(),
Expand All @@ -33,7 +33,7 @@ defmodule Stripe.Issuing.Card do
replacement_reason: String.t() | nil,
shipping: Stripe.Types.shipping() | nil,
status: String.t(),
type: String.t()
type: atom() | String.t()
}

defstruct [
Expand Down Expand Up @@ -65,6 +65,8 @@ defmodule Stripe.Issuing.Card do
@spec create(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params:
%{
:currency => String.t(),
:type => :physical | :virtual,
optional(:authorization_controls) =>
Stripe.Issuing.Types.authorization_controls(),
optional(:cardholder) => Stripe.Issuing.Cardholder.t(),
Expand Down
5 changes: 4 additions & 1 deletion lib/stripe/issuing/cardholder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Stripe.Issuing.Cardholder do
name: String.t(),
phone_number: String.t() | nil,
status: String.t() | nil,
type: String.t()
type: atom() | String.t()
}

defstruct [
Expand All @@ -54,6 +54,9 @@ defmodule Stripe.Issuing.Cardholder do
@spec create(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params:
%{
:billing => Stripe.Issuing.Types.billing(),
:name => String.t(),
:type => :individual | :business_entity,
optional(:authorization_controls) =>
Stripe.Issuing.Types.authorization_controls(),
optional(:email) => String.t(),
Expand Down
5 changes: 4 additions & 1 deletion lib/stripe/issuing/dispute.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Stripe.Issuing.Dispute do
evidence: evidence(),
livemode: boolean,
metadata: Stripe.Types.metadata(),
reason: String.t(),
reason: atom() | String.t(),
status: String.t()
}

Expand All @@ -61,6 +61,8 @@ defmodule Stripe.Issuing.Dispute do
@spec create(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params:
%{
:disputed_transaction => Stripe.id() | Stripe.Issuing.Transaction.t(),
:reason => :other | :fradulent,
optional(:amount) => non_neg_integer,
optional(:evidence) => evidence(),
optional(:metadata) => Stripe.Types.metadata()
Expand All @@ -71,6 +73,7 @@ defmodule Stripe.Issuing.Dispute do
|> put_endpoint(@plural_endpoint)
|> put_params(params)
|> put_method(:post)
|> cast_to_id([:disputed_transaction])
|> make_request()
end

Expand Down
2 changes: 1 addition & 1 deletion test/stripe/issuing/card_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Stripe.Issuing.CardTest do
test "is creatable" do
params = %{
currency: "usd",
type: "virtual"
type: :virtual
}

assert {:ok, %Stripe.Issuing.Card{}} = Stripe.Issuing.Card.create(params)
Expand Down

0 comments on commit 9e64940

Please sign in to comment.