Omise.Recipient (omise v0.10.0)

Provides Recipient API interfaces.

https://www.omise.co/recipients-api

Summary

Functions

Create a recipient.

Destroy a recipient.

List all recipients.

List all transfer schedules for a given recipient.

Retrieve a recipient.

Search all the recipients.

Update a recipient.

Types

@type t() :: %Omise.Recipient{
  active: boolean(),
  bank_account: Omise.BankAccount.t(),
  created: String.t(),
  default: boolean(),
  deleted: boolean(),
  description: String.t(),
  email: String.t(),
  failure_code: String.t(),
  id: String.t(),
  livemode: boolean(),
  location: String.t(),
  name: String.t(),
  object: String.t(),
  schedule: String.t(),
  tax_id: String.t(),
  type: String.t(),
  verified: boolean()
}

Functions

Link to this function

create(params, opts \\ [])

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

Create a recipient.

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

Request Parameters:

  • name - The recipient's name.
  • email - (optional) The recipient's email.
  • description - (optional) The recipient's description.
  • type - Either individual or corporation.
  • tax_id - (optional) The recipient's tax id.
  • bank_account - A valid bank account.

Examples

params = [
  name: "Nanna",
  email: "anna@omise.co",
  description: "Though the truth may vary, this ship will carry our bodies safe to shore",
  type: "individual",
  bank_account: [
    brand: "bbl",
    number: "1234567890",
    name: "Nanna"
  ]
]

Omise.Recipient.create(params)
Link to this function

destroy(id, opts \\ [])

@spec destroy(String.t(), Keyword.t()) :: {:ok, t()} | {:error, Omise.Error.t()}

Destroy a recipient.

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

Examples

Omise.Recipient.destroy("recp_test_4z6p7e0m4k40txecj5o")
Link to this function

list(params \\ [], opts \\ [])

@spec list(Keyword.t(), Keyword.t()) ::
  {:ok, Omise.List.t()} | {:error, Omise.Error.t()}

List all recipients.

Returns {:ok, recipients} 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

Omise.Recipient.list

Omise.Recipient.list(limit: 5)
Link to this function

list_schedules(id, params \\ [], opts \\ [])

@spec list_schedules(String.t(), Keyword.t(), Keyword.t()) ::
  {:ok, Omise.List.t()} | {:error, Omise.Error.t()}

List all transfer schedules for a given recipient.

Returns {:ok, schedules} 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

Omise.Recipient.list_schedules("recp_test_556jkf7u174ptxuytac")
Link to this function

retrieve(id, opts \\ [])

@spec retrieve(String.t(), Keyword.t()) :: {:ok, t()} | {:error, Omise.Error.t()}

Retrieve a recipient.

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

Examples

Omise.Recipient.retrieve("recp_test_4z6p7e0m4k40txecj5o")
Link to this function

search(params \\ [], opts \\ [])

@spec search(Keyword.t(), Keyword.t()) ::
  {:ok, Omise.Search.t()} | {:error, Omise.Error.t()}

Search all the recipients.

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

Query Parameters:

<https://www.omise.co/search-query-and-filters>

Examples

Omise.Recipient.search(filters: [kind: "individual"])

Omise.Recipient.search(query: "recp_235k46kl6ljl")
Link to this function

update(id, params, opts \\ [])

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

Update a recipient.

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

Request Parameters:

  • name - The recipient's name.
  • email - (optional) The recipient's email.
  • description - (optional) The recipient's description.
  • type - Either individual or corporation.
  • tax_id - (optional) The recipient's tax id.
  • bank_account - A valid bank account.

Examples

params = [
  name: "Emma Stone",
  email: "emma@omise.co",
  bank_account: [
    brand: "kbank",
    name: "Emma Stone"
  ]
]

Omise.Recipient.update("recp_test_4z6p7e0m4k40txecj5oparams", params)