Polarex.Mcp (Polarex v0.1.0)

View Source

Provides API endpoints related to mcp

Summary

Functions

List Customer Meters

Get Customer State by External ID

Get Metrics Limits

Get Order Invoice

Export Subscriptions

List Subscriptions

Functions

customer_meters_get(id, opts \\ [])

@spec customer_meters_get(
  String.t(),
  keyword()
) ::
  {:ok, Polarex.CustomerMeter.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Customer Meter

Get a customer meter by ID.

Scopes: customer_meters:read

customer_meters_list(opts \\ [])

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

List Customer Meters

List customer meters.

Scopes: customer_meters:read

Options

  • organization_id: Filter by organization ID.
  • customer_id: Filter by customer ID.
  • external_customer_id: Filter by external customer ID.
  • meter_id: Filter by meter 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.

customers_create(body, opts \\ [])

@spec customers_create(
  Polarex.CustomerCreate.t(),
  keyword()
) :: {:ok, Polarex.Customer.t()} | {:error, Polarex.HTTPValidationError.t()}

Create Customer

Create a customer.

Scopes: customers:write

customers_delete(id, opts \\ [])

@spec customers_delete(
  String.t(),
  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.

Scopes: customers:write

customers_delete_external(external_id, opts \\ [])

@spec customers_delete_external(
  String.t(),
  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.

Scopes: customers:write

customers_get(id, opts \\ [])

@spec customers_get(
  String.t(),
  keyword()
) ::
  {:ok, Polarex.Customer.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(
  String.t(),
  keyword()
) ::
  {:ok, Polarex.Customer.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(
  String.t(),
  keyword()
) ::
  {:ok, Polarex.CustomerState.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(
  String.t(),
  keyword()
) ::
  {:ok, Polarex.CustomerState.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(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 or email.
  • 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 \\ [])

Update Customer

Update a customer.

Scopes: customers:write

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

Update Customer by External ID

Update a customer by external ID.

Scopes: customers:write

metrics_get(opts \\ [])

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

Get Metrics

Get metrics about your orders and subscriptions.

Currency values are output in cents.

Scopes: metrics:read

Options

  • start_date: Start date.
  • end_date: End date.
  • interval: Interval between two timestamps.
  • organization_id: Filter by organization ID.
  • product_id: Filter by product ID.
  • billing_type: Filter by billing type. recurring will filter data corresponding to subscriptions creations or renewals. one_time will filter data corresponding to one-time purchases.
  • customer_id: Filter by customer ID.

metrics_limits(opts \\ [])

@spec metrics_limits(keyword()) :: {:ok, Polarex.MetricsLimits.t()} | :error

Get Metrics Limits

Get the interval limits for the metrics endpoint.

Scopes: metrics:read

orders_get(id, opts \\ [])

@spec orders_get(
  String.t(),
  keyword()
) ::
  {:ok, Polarex.Order.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Order

Get an order by ID.

Scopes: orders:read

orders_invoice(id, opts \\ [])

@spec orders_invoice(
  String.t(),
  keyword()
) ::
  {:ok, Polarex.OrderInvoice.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Order Invoice

Get an order's invoice data.

Scopes: orders:read

orders_list(opts \\ [])

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

List Orders

List orders.

Scopes: orders:read

Options

  • organization_id: Filter by organization ID.
  • product_id: Filter by product ID.
  • product_billing_type: Filter by product billing type. recurring will filter data corresponding to subscriptions creations or renewals. one_time will filter data corresponding to one-time purchases.
  • discount_id: Filter by discount ID.
  • customer_id: Filter by customer ID.
  • checkout_id: Filter by checkout 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.

payments_get(id, opts \\ [])

Get Payment

Get a payment by ID.

Scopes: payments:read

payments_list(opts \\ [])

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

List Payments

List payments.

Scopes: payments:read

Options

  • organization_id: Filter by organization ID.
  • checkout_id: Filter by checkout ID.
  • order_id: Filter by order ID.
  • status: Filter by payment status.
  • method: Filter by payment method.
  • customer_email: Filter by customer email.
  • 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.

products_create(body, opts \\ [])

@spec products_create(
  Polarex.ProductCreate.t(),
  keyword()
) :: {:ok, Polarex.Product.t()} | {:error, Polarex.HTTPValidationError.t()}

Create Product

Create a product.

Scopes: products:write

products_get(id, opts \\ [])

@spec products_get(
  String.t(),
  keyword()
) ::
  {:ok, Polarex.Product.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Product

Get a product by ID.

Scopes: products:read products:write

products_list(opts \\ [])

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

List Products

List products.

Scopes: products:read products:write

Options

  • id: Filter by product ID.
  • organization_id: Filter by organization ID.
  • query: Filter by product name.
  • is_archived: Filter on archived products.
  • is_recurring: Filter on recurring products. If true, only subscriptions tiers are returned. If false, only one-time purchase products are returned.
  • benefit_id: Filter products granting specific benefit.
  • 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.

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

Update Product

Update a product.

Scopes: products:write

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

Update Product Benefits

Update benefits granted by a product.

Scopes: products:write

subscriptions_export(opts \\ [])

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

Export Subscriptions

Export subscriptions as a CSV file.

Scopes: subscriptions:read subscriptions:write

Options

  • organization_id: Filter by organization ID.

subscriptions_get(id, opts \\ [])

@spec subscriptions_get(
  String.t(),
  keyword()
) ::
  {:ok, Polarex.Subscription.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}

Get Subscription

Get a subscription by ID.

Scopes: subscriptions:write

subscriptions_list(opts \\ [])

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

List Subscriptions

List subscriptions.

Scopes: subscriptions:read subscriptions:write

Options

  • organization_id: Filter by organization ID.
  • product_id: Filter by product ID.
  • customer_id: Filter by customer ID.
  • discount_id: Filter by discount ID.
  • active: Filter by active or inactive 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.

subscriptions_revoke(id, opts \\ [])

Revoke Subscription

Revoke a subscription, i.e cancel immediately.

Scopes: subscriptions:write

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

Update Subscription

Update a subscription.

Scopes: subscriptions:write