recurly v0.2.2 Recurly.Plan
Module for handling plans in Recurly. See the developer docs on plans for more details
Summary
Functions
Creates a plan from a changeset
Finds a plan given a plan code. Returns the plan or an error
Generates the path to a plan given the plan code
Creates a stream of plans given some options
Functions
Creates a plan from a changeset.
Parameters
changeset
Keyword list changeset
Examples
alias Recurly.ValidationError
changeset = [
plan_code: "gold",
name: "Gold",
plan_interval_length: 1,
plan_interval_unit: "month",
unit_amount_in_cents: [
USD: 200,
EUR: 300
]
]
case Recurly.Plan.create(changeset) do
{:ok, plan} ->
# created the plan
{:error, %ValidationError{errors: errors}} ->
# will give you a list of validation errors
end
Finds a plan given a plan code. Returns the plan or an error.
Parameters
plan_code
String plan code
Examples
alias Recurly.NotFoundError
case Recurly.Plan.find("myplancode") do
{:ok, plan} ->
# Found the plan
{:error, %NotFoundError{}} ->
# 404 plan was not found
end
Generates the path to a plan given the plan code
Parameters
plan_code
String plan code
Creates a stream of plans given some options.
Parameters
options
Keyword list of the request options. See options in the plan list section of the docs.
Examples
See Recurly.Resource.stream/3
for more detailed examples of
working with resource streams.
# stream of plans sorted from most recently
# updated to least recently updated
stream = Recurly.Plan.stream(sort: :updated_at)