Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update params for Event, Payout, Refund #350

Merged
merged 4 commits into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/stripe/core_resources/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ defmodule Stripe.Event do
@doc """
List all events, going back up to 30 days.
"""
@spec list(map, Stripe.options()) :: {:ok, Stripe.List.t(t)} | {:error, Stripe.Error.t()}
@spec list(params, Stripe.options()) :: {:ok, Stripe.List.t(t)} | {:error, Stripe.Error.t()}
when params: %{
optional(:created) => Stripe.date_query(),
optional(:ending_before) => t | Stripe.id(),
optional(:limit) => 1..100,
optional(:starting_after) => t | Stripe.id(),
optional(:type) => String.t(),
optional(:types) => list
} | %{}
def list(params \\ %{}, opts \\ []) do
new_request(opts)
|> put_endpoint(@plural_endpoint)
Expand Down
41 changes: 19 additions & 22 deletions lib/stripe/core_resources/payout.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ defmodule Stripe.Payout do
object: String.t(),
amount: integer,
arrival_date: Stripe.timestamp(),
automatic: boolean,
balance_transaction: Stripe.id() | Stripe.BalanceTransaction.t() | nil,
created: Stripe.timestamp(),
currency: String.t(),
description: String.t() | nil,
destination: Stripe.id() | Stripe.Card.t() | Stripe.BankAccount.t() | nil,
destination: Stripe.id() | Stripe.Card.t() | Stripe.BankAccount.t() | String.t() | nil,
failure_balance_transaction: Stripe.id() | Stripe.BalanceTransaction.t() | nil,
failure_code: String.t() | nil,
failure_message: String.t() | nil,
Expand All @@ -35,6 +36,7 @@ defmodule Stripe.Payout do
:object,
:amount,
:arrival_date,
:automatic,
:balance_transaction,
:created,
:currency,
Expand Down Expand Up @@ -65,16 +67,14 @@ defmodule Stripe.Payout do
"""
@spec create(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
amount: pos_integer,
currency: String.t(),
description: String.t(),
destination: %{
:account => Stripe.id() | Stripe.Account.t(),
optional(:amount) => non_neg_integer
},
metadata: map,
source_type: String.t(),
statement_descriptor: String.t()
:amount => pos_integer,
:currency => String.t(),
optional(:description) => String.t(),
optional(:destination) => Stripe.id() | Stripe.Card.t() | Stripe.BankAccount.t() | String.t(),
optional(:metadata) => Stripe.Types.metadata(),
optional(:method) => String.t(),
optional(:source_type) => String.t(),
optional(:statement_descriptor) => String.t()
} | %{}
def create(params, opts \\ []) do
new_request(opts)
Expand Down Expand Up @@ -111,10 +111,7 @@ defmodule Stripe.Payout do
"""
@spec update(Stripe.id() | t, params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
metadata: %{
optional(String.t()) => String.t(),
optional(atom) => String.t()
}
optional(:metadata) => Stripe.Types.metadata()
} | %{}
def update(id, params, opts \\ []) do
new_request(opts)
Expand All @@ -134,13 +131,13 @@ defmodule Stripe.Payout do
"""
@spec list(params, Stripe.options()) :: {:ok, Stripe.List.t(t)} | {:error, Stripe.Error.t()}
when params: %{
arrival_date: Stripe.date_query(),
created: Stripe.date_query(),
destination: String.t(),
ending_before: t | Stripe.id(),
limit: 1..100,
starting_after: t | Stripe.id(),
status: String.t()
optional(:arrival_date) => Stripe.date_query(),
optional(:created) => Stripe.date_query(),
optional(:destination) => String.t(),
optional(:ending_before) => t | Stripe.id(),
optional(:limit) => 1..100,
optional(:starting_after) => t | Stripe.id(),
optional(:status) => String.t()
} | %{}
def list(params \\ %{}, opts \\ []) do
new_request(opts)
Expand Down
24 changes: 13 additions & 11 deletions lib/stripe/core_resources/refund.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ defmodule Stripe.Refund do
failure_balance_transaction: Stripe.id() | Stripe.BalanceTransaction.t() | nil,
failure_reason: String.t() | nil,
metadata: Stripe.Types.metadata(),
payment: Stripe.id() | Stripe.Charge.t() | nil,
reason: String.t() | nil,
receipt_number: String.t() | nil,
status: String.t() | nil
Expand All @@ -39,6 +40,7 @@ defmodule Stripe.Refund do
:failure_balance_transaction,
:failure_reason,
:metadata,
:payment,
:reason,
:receipt_number,
:status
Expand Down Expand Up @@ -66,12 +68,12 @@ defmodule Stripe.Refund do
"""
@spec create(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
charge: Stripe.Charge.t() | Stripe.id(),
amount: pos_integer,
metadata: Stripe.Types.metadata(),
reason: String.t(),
refund_application_fee: boolean,
reverse_transfer: boolean
:charge => Stripe.Charge.t() | Stripe.id(),
optional(:amount) => pos_integer,
optional(:metadata) => Stripe.Types.metadata(),
optional(:reason) => String.t(),
optional(:refund_application_fee) => boolean,
optional(:reverse_transfer) => boolean
} | %{}
def create(params, opts \\ []) do
new_request(opts)
Expand Down Expand Up @@ -109,7 +111,7 @@ defmodule Stripe.Refund do
"""
@spec update(Stripe.id() | t, params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
metadata: Stripe.Types.metadata()
optional(:metadata) => Stripe.Types.metadata()
} | %{}
def update(id, params, opts \\ []) do
new_request(opts)
Expand All @@ -131,10 +133,10 @@ defmodule Stripe.Refund do
"""
@spec list(params, Stripe.options()) :: {:ok, Stripe.List.t(t)} | {:error, Stripe.Error.t()}
when params: %{
charge: Stripe.id() | Stripe.Charge.t(),
ending_before: Stripe.id() | t,
limit: 1..100,
starting_after: Stripe.id() | t
optional(:charget) => Stripe.id() | Stripe.Charge.t(),
optional(:ending_before) => t | Stripe.id(),
optional(:limit) => 1..100,
optional(:starting_after) => t | Stripe.id()
} | %{}
def list(params \\ %{}, opts \\ []) do
new_request(opts)
Expand Down
2 changes: 1 addition & 1 deletion test/stripe/subscriptions/plan_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Stripe.PlanTest do
currency: "usd",
id: "sapphire-elite",
interval: "month",
name: "Sapphire elite",
nickname: "Sapphire elite",
product: "abc_123"
}

Expand Down