recurly v0.2.1 Recurly.XML.Schema

Module responsible for handling schemas of the resources. Schemas are used for building the resource structs as well as marshalling and unmarshalling the xml. The syntax for defining schemas is similar to Ecto:

defmodule MyResource do
  use Recurly.XML.Schema

  schema :my_resource do
    field :a_string, :string
    field :an_integer, :integer
    field :a_float, :float, read_only: true
  end
end

Calling use Recurly.XML.Schema adds two macros, schema and field. It also defines two functions on the module:

  • __resource_name__/0
  • __schema__/0

The first returns the name of the resource :my_schema. The second returns the fields and their options. It also calls defstruct passing in the names of the fields to definte the type.

Summary

Macros

Defines a field in the schema

Defines the schema for this resource

Functions

fields(schema, atom)
find_field(schema, name)
get(resource_type)

Macros

field(name, type, opts \\ [])

Defines a field in the schema

schema(resource_name, list)

Defines the schema for this resource