Polarex.Customers (Polarex v0.3.0)

View Source

Provides API endpoints related to customers

Summary

Functions

customer_portal_customers_add_payment_method(body, opts \\ [])

Add Customer Payment Method

Add a payment method to the authenticated customer.

Request Body

Content Types: application/json

customer_portal_customers_check_email_update(opts \\ [])

@spec customer_portal_customers_check_email_update(opts :: keyword()) ::
  :ok | {:error, Polarex.HTTPValidationError.t()}

Check Email Change Token

Check if an email change verification token is still valid.

Options

  • token

customer_portal_customers_confirm_payment_method(body, opts \\ [])

Confirm Customer Payment Method

Confirm a payment method for the authenticated customer.

Request Body

Content Types: application/json

customer_portal_customers_delete_payment_method(id, opts \\ [])

@spec customer_portal_customers_delete_payment_method(
  id :: String.t(),
  opts :: keyword()
) ::
  :ok
  | {:error,
     Polarex.HTTPValidationError.t()
     | Polarex.PaymentMethodInUseByActiveSubscription.t()
     | Polarex.ResourceNotFound.t()}

Delete Customer Payment Method

Delete a payment method from the authenticated customer.

customer_portal_customers_get(opts \\ [])

@spec customer_portal_customers_get(opts :: keyword()) ::
  {:ok, Polarex.CustomerPortalCustomer.t()} | :error

Get Customer

Get authenticated customer.

Scopes: customer_portal:read customer_portal:write

customer_portal_customers_list_payment_methods(opts \\ [])

@spec customer_portal_customers_list_payment_methods(opts :: keyword()) ::
  {:ok, Polarex.ListResourceCustomerPaymentMethod.t()}
  | {:error, Polarex.HTTPValidationError.t()}

List Customer Payment Methods

Get saved payment methods of the authenticated customer.

Options

  • page: Page number, defaults to 1.
  • limit: Size of a page, defaults to 10. Maximum is 100.

customer_portal_customers_request_email_update(body, opts \\ [])

@spec customer_portal_customers_request_email_update(
  body :: Polarex.CustomerEmailUpdateRequest.t(),
  opts :: keyword()
) :: {:ok, map()} | {:error, Polarex.HTTPValidationError.t()}

Request Email Change

Request an email change for the authenticated customer.

Request Body

Content Types: application/json

customer_portal_customers_update(body, opts \\ [])

@spec customer_portal_customers_update(
  body :: Polarex.CustomerPortalCustomerUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.CustomerPortalCustomer.t()}
  | {:error, Polarex.HTTPValidationError.t()}

Update Customer

Update authenticated customer.

Request Body

Content Types: application/json

customer_portal_customers_verify_email_update(body, opts \\ [])

@spec customer_portal_customers_verify_email_update(
  body :: Polarex.CustomerEmailUpdateVerifyRequest.t(),
  opts :: keyword()
) :: {:ok, Polarex.CustomerEmailUpdateVerifyResponse.t()} | :error

Verify Email Change

Verify an email change using the token from the verification email.

Request Body

Content Types: application/json

customers_create(body, opts \\ [])

Create Customer

Create a customer.

Scopes: customers:write

Request Body

Content Types: application/json

customers_delete(id, opts \\ [])

@spec customers_delete(id :: String.t(), opts :: keyword()) ::
  :ok | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.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

Options

  • anonymize: If true, also anonymize the customer's personal data for GDPR compliance. This replaces email with a hashed version, hashes name and billing name (name preserved for businesses with tax_id), clears billing address, and removes OAuth account data.

customers_delete_external(external_id, opts \\ [])

@spec customers_delete_external(external_id :: String.t(), opts :: keyword()) ::
  :ok | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.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

Options

  • anonymize: If true, also anonymize the customer's personal data for GDPR compliance.

customers_export(opts \\ [])

@spec customers_export(opts :: keyword()) ::
  {:ok, map() | String.t()} | {:error, Polarex.HTTPValidationError.t()}

Export Customers

Export customers as a CSV file.

Scopes: customers:read customers:write

Options

  • organization_id: Filter by organization ID.

customers_get(id, opts \\ [])

@spec customers_get(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerIndividual.t() | Polarex.CustomerTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Customer

Get a customer by ID.

Scopes: customers:read customers:write

customers_get_external(external_id, opts \\ [])

@spec customers_get_external(external_id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerIndividual.t() | Polarex.CustomerTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Customer by External ID

Get a customer by external ID.

Scopes: customers:read customers:write

customers_get_state(id, opts \\ [])

@spec customers_get_state(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerStateIndividual.t() | Polarex.CustomerStateTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.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

customers_get_state_external(external_id, opts \\ [])

@spec customers_get_state_external(external_id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerStateIndividual.t() | Polarex.CustomerStateTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.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

customers_list(opts \\ [])

@spec customers_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceCustomer.t()}
  | {:error, Polarex.HTTPValidationError.t()}

List Customers

List customers.

Scopes: customers:read customers:write

Options

  • organization_id: Filter by organization ID.
  • email: Filter by exact email.
  • query: Filter by name, email, or external ID.
  • page: Page number, defaults to 1.
  • limit: Size of a page, defaults to 10. Maximum is 100.
  • sorting: Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order.
  • metadata: Filter by metadata key-value pairs. It uses the deepObject style, e.g. ?metadata[key]=value.

customers_update(id, body, opts \\ [])

@spec customers_update(
  id :: String.t(),
  body :: Polarex.CustomerUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.CustomerIndividual.t() | Polarex.CustomerTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Update Customer

Update a customer.

Scopes: customers:write

Request Body

Content Types: application/json

customers_update_external(external_id, body, opts \\ [])

@spec customers_update_external(
  external_id :: String.t(),
  body :: Polarex.CustomerUpdateExternalID.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.CustomerIndividual.t() | Polarex.CustomerTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Update Customer by External ID

Update a customer by external ID.

Scopes: customers:write

Request Body

Content Types: application/json