Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a change list function that takes any params #49

Merged
merged 1 commit into from
May 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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