Polarex.Customers (Polarex v0.5.0)

Copy Markdown View Source

Provides API endpoints related to customers

Summary

Functions

Export Customers

Get Customer State by External ID

List Customer Payment Methods

List Customer Payment Methods by External ID

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, 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.
  • active: Filter by active customers, i.e. customers with at least one trialing, active or past_due subscription.
  • 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_list_payment_methods(id, opts \\ [])

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

List Customer Payment Methods

Get saved payment methods of a customer.

Scopes: customers:read customers:write

Options

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

customers_list_payment_methods_external(external_id, opts \\ [])

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

List Customer Payment Methods by External ID

Get saved payment methods of a customer by external ID.

Scopes: customers:read customers:write

Options

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

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

@spec customers_members_create(
  id :: String.t(),
  body :: Polarex.MemberCreateFromCustomer.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Member.t()}
  | {:error,
     Polarex.HTTPValidationError.t()
     | Polarex.NotPermitted.t()
     | Polarex.ResourceNotFound.t()}

Create Member

Create a new member for a customer.

Only B2B customers with the member management feature enabled can add members. The authenticated user or organization must have access to the customer's organization.

Scopes: members:write

Request Body

Content Types: application/json

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

@spec customers_members_create_external(
  external_id :: String.t(),
  body :: Polarex.MemberCreateFromCustomer.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Member.t()}
  | {:error,
     Polarex.AmbiguousExternalCustomerID.t()
     | Polarex.HTTPValidationError.t()
     | Polarex.NotPermitted.t()
     | Polarex.ResourceNotFound.t()}

Create Member by Customer External ID

Create a new member for a customer identified by its external ID.

Scopes: members:write

Request Body

Content Types: application/json

customers_members_delete(id, member_id, opts \\ [])

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

Delete Member

Delete a member of a customer.

Scopes: members:write

customers_members_delete_external(external_id, member_external_id, opts \\ [])

@spec customers_members_delete_external(
  external_id :: String.t(),
  member_external_id :: String.t(),
  opts :: keyword()
) ::
  :ok
  | {:error,
     Polarex.AmbiguousExternalCustomerID.t()
     | Polarex.HTTPValidationError.t()
     | Polarex.ResourceNotFound.t()}

Delete Member by External ID

Delete a member by external ID for a customer identified by its external ID.

Scopes: members:write

customers_members_get(id, member_id, opts \\ [])

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

Get Member

Get a member of a customer by its ID.

Scopes: members:read members:write

customers_members_get_external(external_id, member_external_id, opts \\ [])

@spec customers_members_get_external(
  external_id :: String.t(),
  member_external_id :: String.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Member.t()}
  | {:error,
     Polarex.AmbiguousExternalCustomerID.t()
     | Polarex.HTTPValidationError.t()
     | Polarex.ResourceNotFound.t()}

Get Member by External ID

Get a member by external ID for a customer identified by its external ID.

Scopes: members:read members:write

customers_members_update(id, member_id, body, opts \\ [])

@spec customers_members_update(
  id :: String.t(),
  member_id :: String.t(),
  body :: Polarex.MemberUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Member.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Update Member

Update a member of a customer.

Only name, email and role can be updated.

Scopes: members:write

Request Body

Content Types: application/json

customers_members_update_external(external_id, member_external_id, body, opts \\ [])

@spec customers_members_update_external(
  external_id :: String.t(),
  member_external_id :: String.t(),
  body :: Polarex.MemberUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Member.t()}
  | {:error,
     Polarex.AmbiguousExternalCustomerID.t()
     | Polarex.HTTPValidationError.t()
     | Polarex.ResourceNotFound.t()}

Update Member by External ID

Update a member by external ID for a customer identified by its external ID.

Scopes: members:write

Request Body

Content Types: application/json

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