Search documentation of polar_express

# PolarExpress.Services.CustomersService (polar_express v0.1.5)

Copy Markdown View Source

Customers

Customers API operations.

## Summary

### Functions

create_customer(client, params \\ %{}, opts \\ [])

Create Customer

delete_customer(client, id, params \\ %{}, opts \\ [])

Delete Customer

delete_customer_by_external_id(client, external_id, params \\ %{}, opts \\ [])

Delete Customer by External ID

export_customers(client, params \\ %{}, opts \\ [])

Export Customers

get_customer(client, id, params \\ %{}, opts \\ [])

Get Customer

get_customer_by_external_id(client, external_id, params \\ %{}, opts \\ [])

Get Customer by External ID

get_customer_state(client, id, params \\ %{}, opts \\ [])

Get Customer State

get_customer_state_by_external_id(client, external_id, params \\ %{}, opts \\ [])

Get Customer State by External ID

list_customers(client, params \\ %{}, opts \\ [])

List Customers

update_customer(client, id, params \\ %{}, opts \\ [])

Update Customer

update_customer_by_external_id(client, external_id, params \\ %{}, opts \\ [])

Update Customer by External ID

## Functions

# create_customer(client, params \\ %{}, opts \\ [])

    @spec create_customer(PolarExpress.Client.t(), map(), keyword()) ::
      {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
      | {:error, PolarExpress.Error.t()}

Create Customer

Create a customer.

Scopes: `customers:write`

See `PolarExpress.Params.CustomersCreateCustomerParams` for parameter details.

# delete_customer(client, id, params \\ %{}, opts \\ [])

    @spec delete_customer(PolarExpress.Client.t(), String.t(), map(), keyword()) ::
      {:ok, term()} | {:error, PolarExpress.Error.t()}

Delete Customer

Delete a customer.

This action cannot be undone and will immediately:

- Cancel any active subscriptions for the customer
- Revoke all their benefits
- Clear any `external_id`

Use it only in the context of deleting a user within your own service. Otherwise, use more granular API endpoints to cancel a specific subscription or revoke certain benefits.

Note: The customers information will nonetheless be retained for historic orders and subscriptions.

Set `anonymize=true` to also anonymize PII for GDPR compliance.

Scopes: `customers:write`

See `PolarExpress.Params.CustomersDeleteCustomerParams` for parameter details.

# delete_customer_by_external_id(client, external_id, params \\ %{}, opts \\ [])

    @spec delete_customer_by_external_id(
      PolarExpress.Client.t(),
      String.t(),
      map(),
      keyword()
    ) ::
      {:ok, term()} | {:error, PolarExpress.Error.t()}

Delete Customer by External ID

Delete a customer by external ID.

Immediately cancels any active subscriptions and revokes any active benefits.

Set `anonymize=true` to also anonymize PII for GDPR compliance.

Scopes: `customers:write`

See `PolarExpress.Params.CustomersDeleteCustomerByExternalIdParams` for parameter details.

# export_customers(client, params \\ %{}, opts \\ [])

    @spec export_customers(PolarExpress.Client.t(), map(), keyword()) ::
      {:ok, term()} | {:error, PolarExpress.Error.t()}

Export Customers

Export customers as a CSV file.

Scopes: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersExportCustomersParams` for parameter details.

# get_customer(client, id, params \\ %{}, opts \\ [])

    @spec get_customer(PolarExpress.Client.t(), String.t(), map(), keyword()) ::
      {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
      | {:error, PolarExpress.Error.t()}

Get Customer

Get a customer by ID.

Scopes: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersGetCustomerParams` for parameter details.

# get_customer_by_external_id(client, external_id, params \\ %{}, opts \\ [])

    @spec get_customer_by_external_id(
      PolarExpress.Client.t(),
      String.t(),
      map(),
      keyword()
    ) ::
      {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
      | {:error, PolarExpress.Error.t()}

Get Customer by External ID

Get a customer by external ID.

Scopes: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersGetCustomerByExternalIdParams` for parameter details.

# get_customer_state(client, id, params \\ %{}, opts \\ [])

    @spec get_customer_state(PolarExpress.Client.t(), String.t(), map(), keyword()) ::
      {:ok, PolarExpress.Schemas.CustomerState.t()}
      | {:error, PolarExpress.Error.t()}

Get Customer State

Get a customer state by ID.

The customer state includes information about the customer's active subscriptions and benefits.

It's the ideal endpoint to use when you need to get a full overview of a customer's status.

Scopes: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersGetCustomerStateParams` for parameter details.

# get_customer_state_by_external_id(client, external_id, params \\ %{}, opts \\ [])

    @spec get_customer_state_by_external_id(
      PolarExpress.Client.t(),
      String.t(),
      map(),
      keyword()
    ) ::
      {:ok, PolarExpress.Schemas.CustomerState.t()}
      | {:error, PolarExpress.Error.t()}

Get Customer State by External ID

Get a customer state by external ID.

The customer state includes information about the customer's active subscriptions and benefits.

It's the ideal endpoint to use when you need to get a full overview of a customer's status.

Scopes: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersGetCustomerStateByExternalIdParams` for parameter details.

# list_customers(client, params \\ %{}, opts \\ [])

    @spec list_customers(PolarExpress.Client.t(), map(), keyword()) ::
      {:ok, PolarExpress.ListObject.t()} | {:error, PolarExpress.Error.t()}

List Customers

List customers.

Scopes: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersListCustomersParams` for parameter details.

# update_customer(client, id, params \\ %{}, opts \\ [])

    @spec update_customer(PolarExpress.Client.t(), String.t(), map(), keyword()) ::
      {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
      | {:error, PolarExpress.Error.t()}

Update Customer

Update a customer.

Scopes: `customers:write`

See `PolarExpress.Params.CustomersUpdateCustomerParams` for parameter details.

# update_customer_by_external_id(client, external_id, params \\ %{}, opts \\ [])

    @spec update_customer_by_external_id(
      PolarExpress.Client.t(),
      String.t(),
      map(),
      keyword()
    ) ::
      {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
      | {:error, PolarExpress.Error.t()}

Update Customer by External ID

Update a customer by external ID.

Scopes: `customers:write`

See `PolarExpress.Params.CustomersUpdateCustomerByExternalIdParams` for parameter details.