recurly v0.2.2 Recurly.Invoice
Module for handling invoices in Recurly. See the developer docs on invoices for more details
Summary
Functions
Gives the count of invoices on the server given options
Finds an invoice given an invoice number. Returns the invoice or an error
Gives the first invoice returned given options
Generates the path to an invoice given the invoice number
Creates a stream of invoices given some options
Functions
Gives the count of invoices on the server given options
Parameters
options
Keyword list of the request options. See options in the invoices list section of the docs.
Examples
# suppose we want to count all accounts
case Recurly.Invoice.count() do
{:ok, count} ->
# count => 176 (or some integer)
{:error, err} ->
# error occurred
end
# or maybe we wan to count just past_due invoices
case Recurly.Invoice.count(state: :past_due) do
{:ok, count} ->
# count => 83 (or some integer)
{:error, err} ->
# error occurred
end
Finds an invoice given an invoice number. Returns the invoice or an error.
Parameters
invoice_number
String invoice number
Examples
alias Recurly.NotFoundError
case Recurly.Invoice.find("1001") do
{:ok, invoice} ->
# Found the invoice
{:error, %NotFoundError{}} ->
# 404 invoice was not found
end
Gives the first invoice returned given options
Parameters
options
Keyword list of the request options. See options in the invoice list section of the docs.
Examples
# suppose we want the latest, open invoice
case Recurly.Invoice.first(state: :open) do
{:ok, invoice} ->
# invoice => the newest open invoice
{:error, err} ->
# error occurred
end
# or maybe want the oldest, failed invoice
case Recurly.Invoice.first(state: :failed, order: :asc) do
{:ok, failed} ->
# invoice => the oldest failed invoice
{:error, err} ->
# error occurred
end
Generates the path to an invoice given the invoice number
Parameters
invoice_number
String invoice number
Creates a stream of invoices given some options.
Parameters
options
Keyword list of the request options. See options in the invoice list section of the docs.
Examples
See Recurly.Resource.stream/3
for more detailed examples of
working with resource streams.
# stream of open invoices sorted from most recently
# updated to least recently updated
stream = Recurly.Invoice.stream(state: :open, sort: :updated_at)