class

Polar::Api::Products

Inherits Reference < Object

API client for products operations

Constants

Log = ::Log.for(self)

Constructors

new(client : Client)

Creates a new Products instance

@param client [Client] The Polar API client instance

Source

Instance methods

Create Product

Create a product.

Scopes: products:write

Endpoint: POST /v1/products/

Parameters:

  • body (required): Request body as Polar::Models::ProductCreate

Returns: Polar::Models::Product

Raises:

  • ResourceNotFoundError on 404
  • NotPermittedError on 403
  • HTTPValidationError on 422
  • PolarError on other errors
Source

Get Product

Get a product by ID.

Scopes: products:read products:write

Endpoint: GET /v1/products/{id}

Parameters:

  • id (required): Path parameter

Returns: Polar::Models::Product

Raises:

  • ResourceNotFoundError on 404
  • NotPermittedError on 403
  • HTTPValidationError on 422
  • PolarError on other errors
Source
list(id : String | Nil = nil, organization_id : String | Nil = nil, query : String | Nil = nil, is_archived : String | Nil = nil, is_recurring : String | Nil = nil, benefit_id : String | Nil = nil, page : Int32 | Nil = nil, limit : Int32 | Nil = nil, sorting : String | Nil = nil, metadata : String | Nil = nil) : Polar::Models::ListResource(Polar::Models::Product)

List Products

List products.

Scopes: products:read products:write

Endpoint: GET /v1/products/

Parameters:

  • id (optional): Filter by product ID.
  • organization_id (optional): Filter by organization ID.
  • query (optional): Filter by product name.
  • is_archived (optional): Filter on archived products.
  • is_recurring (optional): Filter on recurring products. If true, only subscriptions tiers are returned. If false, only one-time purchase products are returned.
  • benefit_id (optional): Filter products granting specific benefit.
  • page (optional): Page number, defaults to 1.
  • limit (optional): Size of a page, defaults to 10. Maximum is 100.
  • sorting (optional): 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 (optional): Filter by metadata key-value pairs. It uses the deepObject style, e.g. ?metadata[key]=value.

Returns: Polar::Models::ListResource(Polar::Models::Product)

Raises:

  • ResourceNotFoundError on 404
  • NotPermittedError on 403
  • HTTPValidationError on 422
  • PolarError on other errors
Source

Update Product

Update a product.

Scopes: products:write

Endpoint: PATCH /v1/products/{id}

Parameters:

  • id (required): Path parameter
  • body (required): Request body as Polar::Models::ProductUpdate

Returns: Polar::Models::Product

Raises:

  • ResourceNotFoundError on 404
  • NotPermittedError on 403
  • HTTPValidationError on 422
  • PolarError on other errors
Source

Update Product Benefits

Update benefits granted by a product.

Scopes: products:write

Endpoint: POST /v1/products/{id}/benefits

Parameters:

  • id (required): Path parameter
  • body (required): Request body as Polar::Models::ProductBenefitsUpdate

Returns: Polar::Models::Product

Raises:

  • ResourceNotFoundError on 404
  • NotPermittedError on 403
  • HTTPValidationError on 422
  • PolarError on other errors
Source