recurly v0.1.3 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
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