Skip to content

Commit

Permalink
Merge pull request #49 from ktornwall/add_charge_list_params
Browse files Browse the repository at this point in the history
Add a change list function that takes any params
  • Loading branch information
robconery committed May 24, 2016
2 parents 0e4d31b + 594623f commit 44d28db
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 44d28db

Please sign in to comment.