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

count(options \\ [])

Gives the count of invoices on the server given options

Parameters

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
find(invoice_number)

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
first(options \\ [])

Gives the first invoice returned given options

Parameters

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
path(invoice_number)

Generates the path to an invoice given the invoice number

Parameters

  • invoice_number String invoice number
stream(options \\ [])

Creates a stream of invoices given some options.

Parameters

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)