Skip to content

Commit

Permalink
Add a change list function that takes any params
Browse files Browse the repository at this point in the history
This allows us to access other API parmeters, like getting charges
by customer or card.
  • Loading branch information
katzenbar committed May 24, 2016
1 parent 0e4d31b commit 594623f
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions lib/stripe/charges.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,22 @@ defmodule Stripe.Charges do
{:ok, charges} = Stripe.Charges.list(100)
```
"""
def list(limit \\ 10) do
def list(params \\ [])
def list(limit) when is_integer(limit) do
list Stripe.config_or_env_key, limit
end
@doc """
Lists charges from your account. Optionally pass parameters that are accepted through the Stripe
API.
## Examples
```
{:ok, charges} = Stripe.Charges.list(limit: 100)
```
"""
def list(params) do
list(Stripe.config_or_env_key, params)
end

@doc """
Lists out charges from your account with a default limit of 10. You can override this by passing in a limit.
Expand All @@ -83,10 +96,23 @@ defmodule Stripe.Charges do
{:ok, charges} = Stripe.Charges.list(key, 100)
```
"""
def list(key, limit) do
def list(key, limit) when is_integer(limit) do
Stripe.make_request_with_key(:get, "#{@endpoint}?limit=#{limit}", key)
|> Stripe.Util.handle_stripe_response
end
@doc """
Lists charges from your account. Optionally pass parameters that are accepted through the Stripe
API. Using a given stripe key to apply against the account associated.
## Examples
```
{:ok, charges} = Stripe.Charges.list(limit: 100)
```
"""
def list(key, params) do
Stripe.make_request_with_key(:get, "#{@endpoint}", key, %{}, %{}, [params: params])
|> Stripe.Util.handle_stripe_response
end


@doc """
Expand Down

0 comments on commit 594623f

Please sign in to comment.