Skip to content

Commit

Permalink
Merge pull request #233 from demainchezmoi/2.0
Browse files Browse the repository at this point in the history
Added Invoice.upcoming for retreiving upcoming invoices.
  • Loading branch information
begedin authored May 31, 2017
2 parents a032ae1 + 3483c55 commit eadba99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/stripe/invoice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,13 @@ defmodule Stripe.Invoice do
endpoint = @plural_endpoint <> "/" <> id
Stripe.Request.update(endpoint, changes, @schema, @nullable_keys, opts)
end

@doc """
Retrieve an upcoming invoice.
"""
@spec upcoming(map, Keyword.t) :: {:ok, t} | {:error, Stripe.api_error_struct}
def upcoming(changes = %{customer: _customer}, opts \\ []) do
endpoint = @plural_endpoint <> "/upcoming"
Stripe.Request.retrieve(changes, endpoint, opts)
end
end
7 changes: 5 additions & 2 deletions lib/stripe/request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ defmodule Stripe.Request do
end

@spec retrieve(String.t, Keyword.t) :: {:ok, struct} | {:error, Stripe.api_error_struct}
def retrieve(endpoint, opts) do
%{}
def retrieve(endpoint, opts), do: retrieve(%{}, endpoint, opts)

@spec retrieve(map, String.t, Keyword.t) :: {:ok, struct} | {:error, Stripe.api_error_struct}
def retrieve(changes, endpoint, opts) do
changes
|> Stripe.request(:get, endpoint, %{}, opts)
|> handle_result
end
Expand Down

0 comments on commit eadba99

Please sign in to comment.