omise v0.1.4 Omise.Customers

Provides Customers API interfaces.

Summary

Functions

Create a customer

Destroy a customer

List all customers

Retrieve a customer

Update a customer

Functions

create(params)

Specs

create(Keyword.t) ::
  {:ok, Omise.Customer.t} |
  {:error, Omise.Error.t}

Create a customer.

Returns {:ok, customer} if the request is successful, {:error, error} otherwise.

Request Parameters:

  • email - (optional) Customer’s email.
  • description - (optional) A custom description for the customer.
  • card - (optional) A card token in case you want to add a card to the customer.

Examples

# Create a customer without attaching a card.
{:ok, customer} = Omise.Customers.create(
  email: "edward@omistry.com",
  description: "Shut up, thief."
)

# Create a customer and attach a card.
{:ok, customer} = Omise.Customers.create(
  email: "edward@omistry.com",
  description: "Shut up, thief.",
  card: "tokn_test_51yer81s9aqqyktdoeh"
)
destroy(id)

Specs

destroy(String.t) ::
  {:ok, Omise.Customer.t} |
  {:error, Omise.Error.t}

Destroy a customer.

Returns {:ok, customer} if the request is successful, {:error, error} otherwise.

Examples

{:ok, customer} = Omise.Customers.destroy("cust_test_4xtrb759599jsxlhkrb")
list(params \\ [])

Specs

list(Keyword.t) ::
  {:ok, [Omise.Customer.t]} |
  {:error, Omise.Error.t}

List all customers.

Returns {:ok, customers} if the request is successful, {:error, error} otherwise.

Query Parameters:

  • offset - (optional, default: 0) The offset of the first record returned.
  • limit - (optional, default: 20, maximum: 100) The maximum amount of records returned.
  • from - (optional, default: 1970-01-01T00:00:00Z, format: ISO 8601) The UTC date and time limiting the beginning of returned records.
  • to - (optional, default: current UTC Datetime, format: ISO 8601) The UTC date and time limiting the end of returned records.

Examples

{:ok, customers} = Omise.Customers.list
retrieve(id)

Specs

retrieve(String.t) ::
  {:ok, Omise.Customer.t} |
  {:error, Omise.Error.t}

Retrieve a customer.

Returns {:ok, customer} if the request is successful, {:error, error} otherwise.

Examples

{:ok, customer} = Omise.Customers.retrieve("cust_test_4xtrb759599jsxlhkrb")
update(id, params)

Specs

update(String.t, Keyword.t) ::
  {:ok, Omise.Customer.t} |
  {:error, Omise.Error.t}

Update a customer.

Returns {:ok, customer} if the request is successful, {:error, error} otherwise.

Request Parameters:

  • email - (optional) Customer’s email.
  • description - (optional) A custom description for the customer.
  • card - (optional) A card token in case you want to add a card to the customer.

Examples

# Update email and description.
{:ok, customer} = Omise.Customers.update("cust_test_51yerhn3ghztgv31n4p", email: "edward@omistry.com", description: "Hello, it's me.")

# Attach a card to a customer.
{:ok, customer} = Omise.Customers.update("cust_test_4xtrb759599jsxlhkrb", card: "tokn_test_4xs9408a642a1htto8z")