From ff4c50fce115824f7ae784cc9db3876d0ff5d0c3 Mon Sep 17 00:00:00 2001 From: Maarten van Vliet Date: Fri, 17 Feb 2023 19:14:07 +0100 Subject: [PATCH 1/6] Fix for getting account by id --- lib/openapi/phases/build_modules.ex | 31 +++++++++++++++++++++++++--- test/stripe/connect/account_test.exs | 9 ++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/lib/openapi/phases/build_modules.ex b/lib/openapi/phases/build_modules.ex index 5402761b..a091daad 100644 --- a/lib/openapi/phases/build_modules.ex +++ b/lib/openapi/phases/build_modules.ex @@ -1,4 +1,23 @@ defmodule Stripe.OpenApi.Phases.BuildModules do + @method_name_overrides %{ + ["Account"] => %{ + {"retrieve", "/v1/account"} => "retrieve", + {"retrieve", "/v1/accounts/{account}"} => "retrieve_by_id" + }, + ["BankAccount"] => %{ + {"delete", "/v1/customers/{customer}/sources/{id}"} => "delete_source", + {"delete", "/v1/accounts/{account}/external_accounts/{id}"} => "delete_external_account", + {"update", "/v1/customers/{customer}/sources/{id}"} => "update_source", + {"update", "/v1/accounts/{account}/external_accounts/{id}"} => "update_external_account" + }, + ["Card"] => %{ + {"delete", "/v1/customers/{customer}/sources/{id}"} => "delete_source", + {"delete", "/v1/accounts/{account}/external_accounts/{id}"} => "delete_external_account", + {"update", "/v1/customers/{customer}/sources/{id}"} => "update_source", + {"update", "/v1/accounts/{account}/external_accounts/{id}"} => "update_external_account" + } + } + @moduledoc false def run(blueprint, _options \\ []) do components = @@ -15,9 +34,8 @@ defmodule Stripe.OpenApi.Phases.BuildModules do description: map["description"], operations: (map["x-stripeOperations"] || []) - # see connect/account_test.exs - |> Enum.uniq_by(& &1["method_name"]) - |> Enum.map(&%{&1 | "method_name" => Macro.underscore(&1["method_name"])}), + |> Enum.reject(&(&1["method_on"] == "collection")) + |> Enum.map(&%{&1 | "method_name" => method_name(&1, resource)}), module: Module.concat(["Stripe" | resource]), properties: map["properties"] || %{}, expandable_fields: @@ -27,4 +45,11 @@ defmodule Stripe.OpenApi.Phases.BuildModules do {:ok, %{blueprint | components: components}} end + + defp method_name(op, resource) do + case @method_name_overrides[resource][{op["method_name"], op["path"]}] do + nil -> Macro.underscore(op["method_name"]) + value -> value + end + end end diff --git a/test/stripe/connect/account_test.exs b/test/stripe/connect/account_test.exs index 08f3c907..77f42711 100644 --- a/test/stripe/connect/account_test.exs +++ b/test/stripe/connect/account_test.exs @@ -6,11 +6,10 @@ defmodule Stripe.AccountTest do assert_stripe_requested(:get, "/v1/account") end - # ellided by build_modules.ex > Enum.uniq_by(& &1["method_name"]) - # test "is retrievable using plural endpoint" do - # assert {:ok, %Stripe.Account{}} = Stripe.Account.retrieve("acct_123") - # assert_stripe_requested(:get, "/v1/accounts/acct_123") - # end + test "is retrievable using plural endpoint" do + assert {:ok, %Stripe.Account{}} = Stripe.Account.retrieve_by_id("acct_123") + assert_stripe_requested(:get, "/v1/accounts/acct_123") + end test "is creatable" do assert {:ok, %Stripe.Account{}} = Stripe.Account.create(%{metadata: %{}, type: "standard"}) From 89b9221630301e8dffb24ce9c3aa46c4ea56dd2c Mon Sep 17 00:00:00 2001 From: Maarten van Vliet Date: Mon, 21 Aug 2023 21:42:43 +0200 Subject: [PATCH 2/6] Update naming --- lib/openapi/phases/build_modules.ex | 4 ++-- test/stripe/connect/account_test.exs | 4 ++-- test/stripe/payment_methods/bank_account_test.exs | 4 ++-- test/stripe/payment_methods/card_test.exs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/openapi/phases/build_modules.ex b/lib/openapi/phases/build_modules.ex index a091daad..07404857 100644 --- a/lib/openapi/phases/build_modules.ex +++ b/lib/openapi/phases/build_modules.ex @@ -1,8 +1,8 @@ defmodule Stripe.OpenApi.Phases.BuildModules do @method_name_overrides %{ ["Account"] => %{ - {"retrieve", "/v1/account"} => "retrieve", - {"retrieve", "/v1/accounts/{account}"} => "retrieve_by_id" + {"retrieve", "/v1/account"} => "show", + {"retrieve", "/v1/accounts/{account}"} => "retrieve" }, ["BankAccount"] => %{ {"delete", "/v1/customers/{customer}/sources/{id}"} => "delete_source", diff --git a/test/stripe/connect/account_test.exs b/test/stripe/connect/account_test.exs index 77f42711..be760857 100644 --- a/test/stripe/connect/account_test.exs +++ b/test/stripe/connect/account_test.exs @@ -2,12 +2,12 @@ defmodule Stripe.AccountTest do use Stripe.StripeCase, async: true test "is retrievable using singular endpoint" do - assert {:ok, %Stripe.Account{}} = Stripe.Account.retrieve() + assert {:ok, %Stripe.Account{}} = Stripe.Account.show() assert_stripe_requested(:get, "/v1/account") end test "is retrievable using plural endpoint" do - assert {:ok, %Stripe.Account{}} = Stripe.Account.retrieve_by_id("acct_123") + assert {:ok, %Stripe.Account{}} = Stripe.Account.retrieve("acct_123") assert_stripe_requested(:get, "/v1/accounts/acct_123") end diff --git a/test/stripe/payment_methods/bank_account_test.exs b/test/stripe/payment_methods/bank_account_test.exs index 9117f551..1b876bcc 100644 --- a/test/stripe/payment_methods/bank_account_test.exs +++ b/test/stripe/payment_methods/bank_account_test.exs @@ -3,14 +3,14 @@ defmodule Stripe.BankAccountTest do describe "update/2" do test "updates a bank account" do - assert {:ok, _} = Stripe.BankAccount.update("cus_123", "ba_123") + assert {:ok, _} = Stripe.BankAccount.update_source("cus_123", "ba_123") assert_stripe_requested(:post, "/v1/customers/cus_123/sources/ba_123") end end describe "delete/2" do test "deletes a bank account" do - assert {:ok, _} = Stripe.BankAccount.delete("cus_123", "ba_123") + assert {:ok, _} = Stripe.BankAccount.delete_source("cus_123", "ba_123") assert_stripe_requested(:delete, "/v1/customers/cus_123/sources/ba_123") end end diff --git a/test/stripe/payment_methods/card_test.exs b/test/stripe/payment_methods/card_test.exs index e3e28ccf..fa157543 100644 --- a/test/stripe/payment_methods/card_test.exs +++ b/test/stripe/payment_methods/card_test.exs @@ -17,14 +17,14 @@ defmodule Stripe.CardTest do describe "update/2" do test "updates a card" do - assert {:ok, _} = Stripe.Card.update("cus_123", "card_123", %{name: "sco"}) + assert {:ok, _} = Stripe.Card.update_source("cus_123", "card_123", %{name: "sco"}) assert_stripe_requested(:post, "/v1/customers/cus_123/sources/card_123") end end describe "delete/2" do test "deletes a card" do - assert {:ok, _} = Stripe.Card.delete("cus_123", "card_123") + assert {:ok, _} = Stripe.Card.delete_source("cus_123", "card_123") assert_stripe_requested(:delete, "/v1/customers/cus_123/sources/card_123") end end From 89af2cdf73a898bc5ed5d3f654c895d20fa5fbe2 Mon Sep 17 00:00:00 2001 From: Maarten van Vliet Date: Mon, 21 Aug 2023 21:51:28 +0200 Subject: [PATCH 3/6] Update generated --- lib/generated/account.ex | 62 +++++++++++--- lib/generated/bank_account.ex | 149 ++++++++++++++++++++++++++++++++-- lib/generated/card.ex | 149 ++++++++++++++++++++++++++++++++-- 3 files changed, 340 insertions(+), 20 deletions(-) diff --git a/lib/generated/account.ex b/lib/generated/account.ex index 5c0b56c8..b97b1e1e 100644 --- a/lib/generated/account.ex +++ b/lib/generated/account.ex @@ -91,7 +91,7 @@ defmodule Stripe.Account do ) ( - @typedoc "The Kanji variation of the the individual's primary address (Japan only)." + @typedoc "The Kanji variation of the company's primary address (Japan only)." @type address_kanji :: %{ optional(:city) => binary, optional(:country) => binary, @@ -216,8 +216,8 @@ defmodule Stripe.Account do ) ( - @typedoc "Settings specific to the account's use of the Card Issuing product." - @type card_issuing :: %{optional(:tos_acceptance) => tos_acceptance} + @typedoc "The card_issuing capability." + @type card_issuing :: %{optional(:requested) => boolean} ) ( @@ -570,11 +570,12 @@ defmodule Stripe.Account do ) ( - @typedoc "Details on the account's acceptance of the Stripe Treasury Services Agreement." + @typedoc "Details on the account's acceptance of the [Stripe Services Agreement](https://stripe.com/docs/connect/updating-accounts#tos-acceptance)." @type tos_acceptance :: %{ optional(:date) => integer, optional(:ip) => binary, - optional(:user_agent) => binary | binary + optional(:service_agreement) => binary, + optional(:user_agent) => binary } ) @@ -584,8 +585,8 @@ defmodule Stripe.Account do ) ( - @typedoc "The treasury capability." - @type treasury :: %{optional(:requested) => boolean} + @typedoc "Settings specific to the account's Treasury FinancialAccounts." + @type treasury :: %{optional(:tos_acceptance) => tos_acceptance} ) ( @@ -611,9 +612,9 @@ defmodule Stripe.Account do @doc "

Retrieves the details of an account.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/account`\n" ( - @spec retrieve(params :: %{optional(:expand) => list(binary)}, opts :: Keyword.t()) :: + @spec show(params :: %{optional(:expand) => list(binary)}, opts :: Keyword.t()) :: {:ok, Stripe.Account.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} - def retrieve(params \\ %{}, opts \\ []) do + def show(params \\ %{}, opts \\ []) do path = Stripe.OpenApi.Path.replace_path_params("/v1/account", [], []) Stripe.Request.new_request(opts) @@ -625,6 +626,47 @@ defmodule Stripe.Account do ) ) + ( + nil + + @doc "

Retrieves the details of an account.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts/{account}`\n" + ( + @spec retrieve( + account :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Account.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + ( nil @@ -922,4 +964,4 @@ defmodule Stripe.Account do end ) ) -end +end \ No newline at end of file diff --git a/lib/generated/bank_account.ex b/lib/generated/bank_account.ex index c21396d4..a0ae2114 100644 --- a/lib/generated/bank_account.ex +++ b/lib/generated/bank_account.ex @@ -61,6 +61,18 @@ defmodule Stripe.BankAccount do } ) + ( + @typedoc "One or more documents that support the [Bank account ownership verification](https://support.stripe.com/questions/bank-account-ownership-verification) requirement. Must be a document associated with the bank account that displays the last 4 digits of the account number, either a statement or a voided check." + @type bank_account_ownership_verification :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "Documents that may be submitted to satisfy various informational requests." + @type documents :: %{ + optional(:bank_account_ownership_verification) => bank_account_ownership_verification + } + ) + ( @typedoc nil @type owner :: %{ @@ -76,7 +88,7 @@ defmodule Stripe.BankAccount do @doc "

Update a specified source for a given customer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" ( - @spec update( + @spec update_source( customer :: binary(), id :: binary(), params :: %{ @@ -100,7 +112,7 @@ defmodule Stripe.BankAccount do {:ok, Stripe.Card.t() | Stripe.BankAccount.t() | Stripe.Source.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} - def update(customer, id, params \\ %{}, opts \\ []) do + def update_source(customer, id, params \\ %{}, opts \\ []) do path = Stripe.OpenApi.Path.replace_path_params( "/v1/customers/{customer}/sources/{id}", @@ -149,7 +161,7 @@ defmodule Stripe.BankAccount do @doc "

Delete a specified source for a given customer.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" ( - @spec delete( + @spec delete_source( customer :: binary(), id :: binary(), params :: %{optional(:expand) => list(binary)}, @@ -158,7 +170,7 @@ defmodule Stripe.BankAccount do {:ok, Stripe.PaymentSource.t() | Stripe.DeletedPaymentSource.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} - def delete(customer, id, params \\ %{}, opts \\ []) do + def delete_source(customer, id, params \\ %{}, opts \\ []) do path = Stripe.OpenApi.Path.replace_path_params( "/v1/customers/{customer}/sources/{id}", @@ -256,4 +268,131 @@ defmodule Stripe.BankAccount do end ) ) -end + + ( + nil + + @doc "

Updates the metadata, account holder name, account holder type of a bank account belonging to a Custom account, and optionally sets it as the default for its currency. Other bank account details are not editable by design.

\n\n

You can re-enable a disabled bank account by performing an update call without providing any arguments or changes.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}/external_accounts/{id}`\n" + ( + @spec update_external_account( + account :: binary(), + id :: binary(), + params :: %{ + optional(:account_holder_name) => binary, + optional(:account_holder_type) => :company | :individual, + optional(:account_type) => :checking | :futsu | :savings | :toza, + optional(:address_city) => binary, + optional(:address_country) => binary, + optional(:address_line1) => binary, + optional(:address_line2) => binary, + optional(:address_state) => binary, + optional(:address_zip) => binary, + optional(:default_for_currency) => boolean, + optional(:documents) => documents, + optional(:exp_month) => binary, + optional(:exp_year) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ExternalAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update_external_account(account, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/external_accounts/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Delete a specified external account for a given account.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/accounts/{account}/external_accounts/{id}`\n" + ( + @spec delete_external_account(account :: binary(), id :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedExternalAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete_external_account(account, id, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/external_accounts/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/card.ex b/lib/generated/card.ex index 48af0228..0d22154b 100644 --- a/lib/generated/card.ex +++ b/lib/generated/card.ex @@ -85,6 +85,18 @@ defmodule Stripe.Card do } ) + ( + @typedoc "One or more documents that support the [Bank account ownership verification](https://support.stripe.com/questions/bank-account-ownership-verification) requirement. Must be a document associated with the bank account that displays the last 4 digits of the account number, either a statement or a voided check." + @type bank_account_ownership_verification :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "Documents that may be submitted to satisfy various informational requests." + @type documents :: %{ + optional(:bank_account_ownership_verification) => bank_account_ownership_verification + } + ) + ( @typedoc nil @type owner :: %{ @@ -100,7 +112,7 @@ defmodule Stripe.Card do @doc "

Update a specified source for a given customer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" ( - @spec update( + @spec update_source( customer :: binary(), id :: binary(), params :: %{ @@ -124,7 +136,7 @@ defmodule Stripe.Card do {:ok, Stripe.Card.t() | Stripe.BankAccount.t() | Stripe.Source.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} - def update(customer, id, params \\ %{}, opts \\ []) do + def update_source(customer, id, params \\ %{}, opts \\ []) do path = Stripe.OpenApi.Path.replace_path_params( "/v1/customers/{customer}/sources/{id}", @@ -173,7 +185,7 @@ defmodule Stripe.Card do @doc "

Delete a specified source for a given customer.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" ( - @spec delete( + @spec delete_source( customer :: binary(), id :: binary(), params :: %{optional(:expand) => list(binary)}, @@ -182,7 +194,7 @@ defmodule Stripe.Card do {:ok, Stripe.PaymentSource.t() | Stripe.DeletedPaymentSource.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} - def delete(customer, id, params \\ %{}, opts \\ []) do + def delete_source(customer, id, params \\ %{}, opts \\ []) do path = Stripe.OpenApi.Path.replace_path_params( "/v1/customers/{customer}/sources/{id}", @@ -225,4 +237,131 @@ defmodule Stripe.Card do end ) ) -end + + ( + nil + + @doc "

Updates the metadata, account holder name, account holder type of a bank account belonging to a Custom account, and optionally sets it as the default for its currency. Other bank account details are not editable by design.

\n\n

You can re-enable a disabled bank account by performing an update call without providing any arguments or changes.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}/external_accounts/{id}`\n" + ( + @spec update_external_account( + account :: binary(), + id :: binary(), + params :: %{ + optional(:account_holder_name) => binary, + optional(:account_holder_type) => :company | :individual, + optional(:account_type) => :checking | :futsu | :savings | :toza, + optional(:address_city) => binary, + optional(:address_country) => binary, + optional(:address_line1) => binary, + optional(:address_line2) => binary, + optional(:address_state) => binary, + optional(:address_zip) => binary, + optional(:default_for_currency) => boolean, + optional(:documents) => documents, + optional(:exp_month) => binary, + optional(:exp_year) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ExternalAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update_external_account(account, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/external_accounts/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Delete a specified external account for a given account.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/accounts/{account}/external_accounts/{id}`\n" + ( + @spec delete_external_account(account :: binary(), id :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedExternalAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete_external_account(account, id, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/external_accounts/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file From ddebe454f10ee7dffefb24a1341039e6f861162c Mon Sep 17 00:00:00 2001 From: Maarten van Vliet Date: Fri, 26 Jan 2024 21:38:42 +0100 Subject: [PATCH 4/6] Fix CI failure --- lib/generated/account.ex | 2 +- lib/generated/bank_account.ex | 2 +- lib/generated/card.ex | 2 +- test/stripe/payment_methods/card_test.exs | 17 +++++++++++------ .../payment_methods/payment_method_test.exs | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/generated/account.ex b/lib/generated/account.ex index b97b1e1e..a16ec50f 100644 --- a/lib/generated/account.ex +++ b/lib/generated/account.ex @@ -964,4 +964,4 @@ defmodule Stripe.Account do end ) ) -end \ No newline at end of file +end diff --git a/lib/generated/bank_account.ex b/lib/generated/bank_account.ex index a0ae2114..80540764 100644 --- a/lib/generated/bank_account.ex +++ b/lib/generated/bank_account.ex @@ -395,4 +395,4 @@ defmodule Stripe.BankAccount do end ) ) -end \ No newline at end of file +end diff --git a/lib/generated/card.ex b/lib/generated/card.ex index 0d22154b..5c4229de 100644 --- a/lib/generated/card.ex +++ b/lib/generated/card.ex @@ -364,4 +364,4 @@ defmodule Stripe.Card do end ) ) -end \ No newline at end of file +end diff --git a/test/stripe/payment_methods/card_test.exs b/test/stripe/payment_methods/card_test.exs index fa157543..98ba7440 100644 --- a/test/stripe/payment_methods/card_test.exs +++ b/test/stripe/payment_methods/card_test.exs @@ -6,12 +6,17 @@ defmodule Stripe.CardTest do {:__from_json__, 1}, {:__struct__, 0}, {:__struct__, 1}, - delete: 2, - delete: 3, - delete: 4, - update: 2, - update: 3, - update: 4 + {:delete_external_account, 2}, + {:delete_external_account, 3}, + {:delete_source, 2}, + {:delete_source, 3}, + {:delete_source, 4}, + {:update_external_account, 2}, + {:update_external_account, 3}, + {:update_external_account, 4}, + {:update_source, 2}, + {:update_source, 3}, + {:update_source, 4} ] = Stripe.Card.__info__(:functions) end diff --git a/test/stripe/payment_methods/payment_method_test.exs b/test/stripe/payment_methods/payment_method_test.exs index ddabdd3a..fa84adf8 100644 --- a/test/stripe/payment_methods/payment_method_test.exs +++ b/test/stripe/payment_methods/payment_method_test.exs @@ -6,7 +6,7 @@ defmodule Stripe.PaymentMethodTest do assert {:ok, %Stripe.List{data: cards}} = Stripe.PaymentMethod.list(%{customer: "cus_123", type: "card"}) - assert_stripe_requested(:get, "/v1/payment_methods?customer=cus_123&type=card") + assert_stripe_requested(:get, "/v1/payment_methods?type=card&customer=cus_123") assert is_list(cards) end end From 169c6c4d82e0949f40ffd452ec161946235f81a8 Mon Sep 17 00:00:00 2001 From: Maarten van Vliet Date: Fri, 26 Jan 2024 21:50:15 +0100 Subject: [PATCH 5/6] Ensure query params assertions order independent --- test/support/stripe_case.ex | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/support/stripe_case.ex b/test/support/stripe_case.ex index 14d70c92..b0779026 100644 --- a/test/support/stripe_case.ex +++ b/test/support/stripe_case.ex @@ -13,8 +13,8 @@ defmodule Stripe.StripeCase do assert_received({method, url, headers, body, _}) assert expected_method == method - assert expected_url == url + assert_stripe_request_url(expected_url, url) assert_stripe_request_body(expected_body, body) assert_stripe_request_headers(expected_headers, headers) end @@ -29,6 +29,20 @@ defmodule Stripe.StripeCase do Application.get_env(:stripity_stripe, :api_base_url) end + defp assert_stripe_request_url(expected_url, url) do + expected_uri = URI.parse(expected_url) + uri = URI.parse(url) + assert expected_uri.path == uri.path + assert expected_uri.host == uri.host + + assert_stripe_request_url_query(expected_uri.query, uri.query) + end + + defp assert_stripe_request_url_query(nil, _), do: nil + defp assert_stripe_request_url_query(expected_query, query) do + URI.decode_query(expected_query) == URI.decode_query(query) + end + defp assert_stripe_request_headers(nil, _), do: nil defp assert_stripe_request_headers(expected_headers, headers) when is_list(expected_headers) do From f7be1e1603c5b45684af16f1725ddfb7cfbb10bc Mon Sep 17 00:00:00 2001 From: Maarten van Vliet Date: Fri, 26 Jan 2024 21:51:15 +0100 Subject: [PATCH 6/6] Fix formatting --- test/support/stripe_case.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/support/stripe_case.ex b/test/support/stripe_case.ex index b0779026..dc78dece 100644 --- a/test/support/stripe_case.ex +++ b/test/support/stripe_case.ex @@ -30,7 +30,7 @@ defmodule Stripe.StripeCase do end defp assert_stripe_request_url(expected_url, url) do - expected_uri = URI.parse(expected_url) + expected_uri = URI.parse(expected_url) uri = URI.parse(url) assert expected_uri.path == uri.path assert expected_uri.host == uri.host @@ -39,6 +39,7 @@ defmodule Stripe.StripeCase do end defp assert_stripe_request_url_query(nil, _), do: nil + defp assert_stripe_request_url_query(expected_query, query) do URI.decode_query(expected_query) == URI.decode_query(query) end