class

Polar::Api::Discounts

Inherits Reference < Object

API client for discounts operations

Constants

Log = ::Log.for(self)

Constructors

new(client : Client)

Creates a new Discounts instance

@param client [Client] The Polar API client instance

Source

Instance methods

Create Discount

Create a discount.

Scopes: discounts:write

Endpoint: POST /v1/discounts/

Parameters:

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

Returns: Polar::Models::Discount

Raises:

  • ResourceNotFoundError on 404
  • NotPermittedError on 403
  • HTTPValidationError on 422
  • PolarError on other errors
Source
delete(id : String)

Delete Discount

Delete a discount.

Scopes: discounts:write

Endpoint: DELETE /v1/discounts/{id}

Parameters:

  • id (required): The discount ID.

Returns: JSON response string

Raises:

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

Get Discount

Get a discount by ID.

Scopes: discounts:read discounts:write

Endpoint: GET /v1/discounts/{id}

Parameters:

  • id (required): The discount ID.

Returns: Polar::Models::Discount

Raises:

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

List Discounts

List discounts.

Scopes: discounts:read discounts:write

Endpoint: GET /v1/discounts/

Parameters:

  • organization_id (optional): Filter by organization ID.
  • query (optional): Filter by name.
  • 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.

Returns: Polar::Models::ListResource(Polar::Models::Discount)

Raises:

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

Update Discount

Update a discount.

Scopes: discounts:write

Endpoint: PATCH /v1/discounts/{id}

Parameters:

  • id (required): The discount ID.
  • body (required): Request body as Polar::Models::DiscountUpdate

Returns: Polar::Models::Discount

Raises:

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