Unit.API.Customers (Unit v1.0.0)

Copy Markdown View Source

API module for Unit Customers.

Customers are created automatically when an application is approved. You cannot create customers directly — listen for the application.approved webhook to know when a customer is ready.

Summary

Functions

Add authorized users to a customer.

Archive a customer (ends the customer relationship).

Get a customer by ID.

List customers.

Remove an authorized user from a customer.

Update a customer's mutable attributes.

Functions

add_authorized_users(id, users, opts \\ [])

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

Add authorized users to a customer.

Each user map should include :full_name, :email, :phone, and optionally :jwt_subject.

archive(id, opts \\ [])

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

Archive a customer (ends the customer relationship).

get(id, opts \\ [])

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

Get a customer by ID.

list(opts \\ [])

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

List customers.

Filter options

  • :email, :tags, :status"Active" | "Archived"

remove_authorized_user(customer_id, user_id, opts \\ [])

@spec remove_authorized_user(String.t(), String.t(), keyword()) ::
  {:ok, nil} | {:error, term()}

Remove an authorized user from a customer.

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

@spec update(String.t(), map(), keyword()) ::
  {:ok, Unit.Resource.Customer.t()} | {:error, term()}

Update a customer's mutable attributes.

Pass :type to specify the customer type (default "individualCustomer").