From 767201753adca1da0c891f07575f81bd3cafac3e Mon Sep 17 00:00:00 2001 From: snewcomer Date: Thu, 12 Apr 2018 08:49:23 -0700 Subject: [PATCH 1/4] update params event payout --- lib/stripe/core_resources/event.ex | 10 +++++++++- lib/stripe/core_resources/payout.ex | 14 +++++++------- lib/stripe/core_resources/refund.ex | 24 +++++++++++++----------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/lib/stripe/core_resources/event.ex b/lib/stripe/core_resources/event.ex index 29aaa1cc..288b1ec5 100644 --- a/lib/stripe/core_resources/event.ex +++ b/lib/stripe/core_resources/event.ex @@ -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) diff --git a/lib/stripe/core_resources/payout.ex b/lib/stripe/core_resources/payout.ex index ab5f329e..5b6ec90e 100644 --- a/lib/stripe/core_resources/payout.ex +++ b/lib/stripe/core_resources/payout.ex @@ -134,13 +134,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) diff --git a/lib/stripe/core_resources/refund.ex b/lib/stripe/core_resources/refund.ex index 595516eb..0133d1e8 100644 --- a/lib/stripe/core_resources/refund.ex +++ b/lib/stripe/core_resources/refund.ex @@ -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 @@ -39,6 +40,7 @@ defmodule Stripe.Refund do :failure_balance_transaction, :failure_reason, :metadata, + :payment, :reason, :receipt_number, :status @@ -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) @@ -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) @@ -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) From 25f499f1b3931b654e5169866fcab4e1accfc6ef Mon Sep 17 00:00:00 2001 From: snewcomer Date: Thu, 12 Apr 2018 09:14:22 -0700 Subject: [PATCH 2/4] update remaining payout --- lib/stripe/core_resources/payout.ex | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/stripe/core_resources/payout.ex b/lib/stripe/core_resources/payout.ex index 5b6ec90e..1a514702 100644 --- a/lib/stripe/core_resources/payout.ex +++ b/lib/stripe/core_resources/payout.ex @@ -13,6 +13,7 @@ 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(), @@ -35,6 +36,7 @@ defmodule Stripe.Payout do :object, :amount, :arrival_date, + :automatic, :balance_transaction, :created, :currency, @@ -65,16 +67,17 @@ 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: %{ + :amount => pos_integer, + :currency => String.t(), + optional(:description) => String.t(), + optional(:destination) => %{ :account => Stripe.id() | Stripe.Account.t(), optional(:amount) => non_neg_integer }, - metadata: map, - source_type: String.t(), - statement_descriptor: 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) @@ -111,10 +114,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) From bd367333bef6318102e3a17fbefe62ae25276a27 Mon Sep 17 00:00:00 2001 From: snewcomer Date: Sun, 15 Apr 2018 17:47:53 -0700 Subject: [PATCH 3/4] convert a few payout lines to appropriate types --- lib/stripe/core_resources/payout.ex | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/stripe/core_resources/payout.ex b/lib/stripe/core_resources/payout.ex index 1a514702..c5287130 100644 --- a/lib/stripe/core_resources/payout.ex +++ b/lib/stripe/core_resources/payout.ex @@ -18,7 +18,7 @@ defmodule Stripe.Payout do 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, @@ -70,10 +70,7 @@ defmodule Stripe.Payout do :amount => pos_integer, :currency => String.t(), optional(:description) => String.t(), - optional(:destination) => %{ - :account => Stripe.id() | Stripe.Account.t(), - optional(:amount) => non_neg_integer - }, + 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(), From 4559ad087eb669c50fb07d914989bcfd3e955dc8 Mon Sep 17 00:00:00 2001 From: snewcomer Date: Mon, 23 Apr 2018 10:07:31 -0700 Subject: [PATCH 4/4] use nickname in plan test --- test/stripe/subscriptions/plan_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/stripe/subscriptions/plan_test.exs b/test/stripe/subscriptions/plan_test.exs index b57584c6..ca64dff5 100644 --- a/test/stripe/subscriptions/plan_test.exs +++ b/test/stripe/subscriptions/plan_test.exs @@ -8,7 +8,7 @@ defmodule Stripe.PlanTest do currency: "usd", id: "sapphire-elite", interval: "month", - name: "Sapphire elite", + nickname: "Sapphire elite", product: "abc_123" }