Unit.API.Rewards (Unit v1.0.0)

Copy Markdown View Source

API module for Unit Rewards.

Rewards credit money to end-customers as cash-back, sign-up bonuses, referral bonuses, or any other promotional incentive. They are deducted from your configured funding (revenue) account.

Example

{:ok, reward} = Unit.API.Rewards.create(%{
  amount: 500,                  # $5.00 cash-back
  description: "Cash Back Reward",
  receiving_account_id: account.id,
  funding_account_id: revenue_account.id
})

Summary

Functions

Create a reward.

Get a reward by ID.

List rewards.

Functions

create(params, opts \\ [])

@spec create(
  map(),
  keyword()
) :: {:ok, Unit.Resource.Reward.t()} | {:error, term()}

Create a reward.

Required params

  • :amount — in cents
  • :description — appears on the transaction
  • :receiving_account_id — customer's deposit account to receive the reward
  • :funding_account_id — your revenue/funding account to debit

Optional

  • :tags
  • :idempotency_key

get(id, opts \\ [])

@spec get(
  String.t(),
  keyword()
) :: {:ok, Unit.Resource.Reward.t()} | {:error, term()}

Get a reward by ID.

list(opts \\ [])

@spec list(keyword()) :: {:ok, [Unit.Resource.Reward.t()], map()} | {:error, term()}

List rewards.

Filter options

  • :account_id — filter by receiving account
  • :customer_id
  • :status
  • :since, :until
  • :page_limit, :page_offset