diff --git a/lib/stripe/account.ex b/lib/stripe/account.ex index da64f297..63b2cb99 100644 --- a/lib/stripe/account.ex +++ b/lib/stripe/account.ex @@ -186,4 +186,13 @@ defmodule Stripe.Account do endpoint = @plural_endpoint <> "/" <> id Stripe.Request.update(endpoint, changes, @schema, @nullable_keys, opts) end + + @doc """ + List all connected accounts. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(params, endpoint, opts) + end end diff --git a/lib/stripe/card.ex b/lib/stripe/card.ex index 95adce3f..7d241745 100644 --- a/lib/stripe/card.ex +++ b/lib/stripe/card.ex @@ -80,7 +80,8 @@ defmodule Stripe.Card do defp endpoint_for_owner(owner_type, owner_id) do case owner_type do :customer -> "customers/#{owner_id}/sources" - :recipient -> "recipients/#{owner_id}/cards" + :account -> "accounts/#{owner_id}/external_accounts" + :recipient -> "recipients/#{owner_id}/cards" # Deprecated end end @@ -138,4 +139,14 @@ defmodule Stripe.Card do endpoint = endpoint_for_owner(owner_type, owner_id) <> "/" <> card_id Stripe.Request.delete(endpoint, %{}, opts) end + + @doc """ + List all cards. + """ + @spec list(source, String.t, map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(owner_type, owner_id, params \\ %{}, opts \\ []) do + endpoint = endpoint_for_owner(owner_type, owner_id) + params = Map.merge(params, %{"object" => "card"}) + Stripe.Request.retrieve(params, endpoint, opts) + end end diff --git a/lib/stripe/charge.ex b/lib/stripe/charge.ex index 0d3dd70f..193e6670 100644 --- a/lib/stripe/charge.ex +++ b/lib/stripe/charge.ex @@ -103,4 +103,13 @@ defmodule Stripe.Charge do endpoint = @plural_endpoint <> "/" <> id Stripe.Request.retrieve(endpoint, opts) end + + @doc """ + List all charges. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(params, endpoint, opts) + end end diff --git a/lib/stripe/coupon.ex b/lib/stripe/coupon.ex index a73e6af4..6b907de3 100644 --- a/lib/stripe/coupon.ex +++ b/lib/stripe/coupon.ex @@ -79,4 +79,13 @@ defmodule Stripe.Coupon do endpoint = @plural_endpoint <> "/" <> id Stripe.Request.delete(endpoint, %{}, opts) end -end \ No newline at end of file + + @doc """ + List all coupons. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(params, endpoint, opts) + end +end diff --git a/lib/stripe/customer.ex b/lib/stripe/customer.ex index 8cfffbea..e4ae1f87 100644 --- a/lib/stripe/customer.ex +++ b/lib/stripe/customer.ex @@ -99,4 +99,13 @@ defmodule Stripe.Customer do endpoint = @plural_endpoint <> "/" <> id Stripe.Request.delete(endpoint, %{}, opts) end + + @doc """ + List all customers. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(params, endpoint, opts) + end end diff --git a/lib/stripe/event.ex b/lib/stripe/event.ex index 87c2eca9..39fe9994 100644 --- a/lib/stripe/event.ex +++ b/lib/stripe/event.ex @@ -29,4 +29,13 @@ defmodule Stripe.Event do endpoint = @plural_endpoint <> "/" <> id Stripe.Request.retrieve(endpoint, opts) end + + @doc """ + List all events. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(params, endpoint, opts) + end end diff --git a/lib/stripe/external_account.ex b/lib/stripe/external_account.ex index b6ea0f23..1f4119bd 100644 --- a/lib/stripe/external_account.ex +++ b/lib/stripe/external_account.ex @@ -88,4 +88,14 @@ defmodule Stripe.ExternalAccount do endpoint = endpoint(managed_account_id) <> "/" <> id Stripe.Request.delete(endpoint, %{}, opts) end + + @doc """ + List all external accounts. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts = [connect_account: managed_account_id]) do + endpoint = endpoint(managed_account_id) + params = Map.merge(params, %{"object" => "bank_account"}) + Stripe.Request.retrieve(params, endpoint, opts) + end end diff --git a/lib/stripe/file_upload.ex b/lib/stripe/file_upload.ex index c203d798..1e423a82 100644 --- a/lib/stripe/file_upload.ex +++ b/lib/stripe/file_upload.ex @@ -38,4 +38,12 @@ defmodule Stripe.FileUpload do Stripe.Request.retrieve_file_upload(endpoint, opts) end + @doc """ + List all file uploads. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(params, endpoint, opts) + end end diff --git a/lib/stripe/invoice.ex b/lib/stripe/invoice.ex index da33852e..18479468 100644 --- a/lib/stripe/invoice.ex +++ b/lib/stripe/invoice.ex @@ -101,4 +101,13 @@ defmodule Stripe.Invoice do endpoint = @plural_endpoint <> "/upcoming" Stripe.Request.retrieve(changes, endpoint, opts) end + + @doc """ + List all invoices. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(params, endpoint, opts) + end end diff --git a/lib/stripe/plan.ex b/lib/stripe/plan.ex index 1e210e7f..2029506d 100644 --- a/lib/stripe/plan.ex +++ b/lib/stripe/plan.ex @@ -79,4 +79,13 @@ defmodule Stripe.Plan do endpoint = @plural_endpoint <> "/" <> id Stripe.Request.delete(endpoint, %{}, opts) end + + @doc """ + List all plans. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(params, endpoint, opts) + end end diff --git a/lib/stripe/refund.ex b/lib/stripe/refund.ex index 67f22ee8..2c99a00b 100644 --- a/lib/stripe/refund.ex +++ b/lib/stripe/refund.ex @@ -58,5 +58,13 @@ defmodule Stripe.Refund do endpoint = @plural_endpoint <> "/" <> id Stripe.Request.update(endpoint, changes, @schema, @nullable_keys, opts) end -end + @doc """ + List all refunds. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(params, endpoint, opts) + end +end diff --git a/lib/stripe/subscription.ex b/lib/stripe/subscription.ex index 9b780319..6ea5f11f 100644 --- a/lib/stripe/subscription.ex +++ b/lib/stripe/subscription.ex @@ -95,4 +95,13 @@ defmodule Stripe.Subscription do endpoint = @plural_endpoint <> "/" <> id Stripe.Request.delete(endpoint, params, opts) end + + @doc """ + List all subscriptions. + """ + @spec list(map, Keyword.t) :: {:ok, Stripe.List.t} | {:error, Stripe.api_error_struct} + def list(params \\ %{}, opts \\ []) do + endpoint = @plural_endpoint + Stripe.Request.retrieve(endpoint, opts) + end end