Skip to content

Commit

Permalink
Format Token
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsmith committed Nov 22, 2017
1 parent 1910672 commit 0a270a0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 52 deletions.
96 changes: 48 additions & 48 deletions lib/stripe/core_resources/token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,56 @@ defmodule Stripe.Token do
import Stripe.Request

@type token_bank_account :: %{
id: Stripe.id,
object: String.t,
account_holder_name: String.t | nil,
account_holder_type: Stripe.BankAccount.account_holder_type | nil,
bank_name: String.t | nil,
country: String.t,
currency: String.t,
fingerprint: String.t | nil,
last4: String.t,
routing_number: String.t | nil,
status: Stripe.BankAccount.status
}
id: Stripe.id(),
object: String.t(),
account_holder_name: String.t() | nil,
account_holder_type: Stripe.BankAccount.account_holder_type() | nil,
bank_name: String.t() | nil,
country: String.t(),
currency: String.t(),
fingerprint: String.t() | nil,
last4: String.t(),
routing_number: String.t() | nil,
status: Stripe.BankAccount.status()
}

@type token_card :: %{
id: Stripe.id,
object: String.t,
address_city: String.t | nil,
address_country: String.t | nil,
address_line1: String.t | nil,
address_line1_check: Stripe.Card.check_result | nil,
address_line2: String.t | nil,
address_state: String.t | nil,
address_zip: String.t | nil,
address_zip_check: Stripe.Card.check_result | nil,
brand: String.t,
country: String.t | nil,
currency: String.t,
cvc_check: Stripe.Card.check_result | nil,
dynamic_last4: String.t | nil,
exp_month: integer,
exp_year: integer,
fingerprint: String.t | nil,
funding: Stripe.Card.funding,
last4: String.t,
metadata: Stripe.Types.metadata,
name: String.t | nil,
tokenization_method: Stripe.Card.tokenization_method | nil
}
id: Stripe.id(),
object: String.t(),
address_city: String.t() | nil,
address_country: String.t() | nil,
address_line1: String.t() | nil,
address_line1_check: Stripe.Card.check_result() | nil,
address_line2: String.t() | nil,
address_state: String.t() | nil,
address_zip: String.t() | nil,
address_zip_check: Stripe.Card.check_result() | nil,
brand: String.t(),
country: String.t() | nil,
currency: String.t(),
cvc_check: Stripe.Card.check_result() | nil,
dynamic_last4: String.t() | nil,
exp_month: integer,
exp_year: integer,
fingerprint: String.t() | nil,
funding: Stripe.Card.funding(),
last4: String.t(),
metadata: Stripe.Types.metadata(),
name: String.t() | nil,
tokenization_method: Stripe.Card.tokenization_method() | nil
}

@type t :: %__MODULE__{
id: Stripe.id,
object: String.t,
bank_account: token_bank_account | nil,
card: token_card | nil,
client_ip: String.t | nil,
created: Stripe.timestamp,
livemode: boolean,
type: String.t,
used: boolean
}
id: Stripe.id(),
object: String.t(),
bank_account: token_bank_account | nil,
card: token_card | nil,
client_ip: String.t() | nil,
created: Stripe.timestamp(),
livemode: boolean,
type: String.t(),
used: boolean
}

defstruct [
:id,
Expand All @@ -90,7 +90,7 @@ defmodule Stripe.Token do
In most cases, you should create tokens client-side using Checkout, Elements,
or Stripe's mobile libraries, instead of using the API.
"""
@spec create(map, Stripe.options) :: {:ok, t} | {:error, Stripe.Error.t}
@spec create(map, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
def create(params, opts \\ []) do
new_request(opts)
|> put_endpoint(@plural_endpoint)
Expand All @@ -102,7 +102,7 @@ defmodule Stripe.Token do
@doc """
Retrieve a token.
"""
@spec retrieve(Stripe.id | t, Stripe.options) :: {:ok, t} | {:error, Stripe.Error.t}
@spec retrieve(Stripe.id() | t, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
def retrieve(id, opts \\ []) do
new_request(opts)
|> put_endpoint(@plural_endpoint <> "/#{get_id!(id)}")
Expand Down
8 changes: 4 additions & 4 deletions test/stripe/core_resources/token_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ defmodule Stripe.TokenTest do
describe "create/2" do
test "creates a card token" do
assert {:ok, %Stripe.Token{}} = Stripe.Token.create(%{card: @card})
assert_stripe_requested :post, "/v1/tokens"
assert_stripe_requested(:post, "/v1/tokens")
end

test "creates a bank account token" do
assert {:ok, %Stripe.Token{}} = Stripe.Token.create(%{bank_account: @bank_account})
assert_stripe_requested :post, "/v1/tokens"
assert_stripe_requested(:post, "/v1/tokens")
end

test "creates a PII token" do
assert {:ok, %Stripe.Token{}} = Stripe.Token.create(%{pii: @pii})
assert_stripe_requested :post, "/v1/tokens"
assert_stripe_requested(:post, "/v1/tokens")
end
end

describe "retrieve/2" do
test "retrieves a token" do
assert {:ok, %Stripe.Token{}} = Stripe.Token.retrieve("tok_123")
assert_stripe_requested :get, "/v1/tokens/tok_123"
assert_stripe_requested(:get, "/v1/tokens/tok_123")
end
end
end

0 comments on commit 0a270a0

Please sign in to comment.