Skip to content

Latest commit

 

History

History
236 lines (167 loc) · 17.1 KB

README.md

File metadata and controls

236 lines (167 loc) · 17.1 KB

Products

(products)

Overview

Available Operations

list

List products.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.products.list(organization_id=[
        "<value>",
    ])

    if res is not None:
        while True:
            # handle items

            res = res.next()
            if res is None:
                break

Parameters

Parameter Type Required Description
organization_id OptionalNullable[models.ProductsListQueryParamOrganizationIDFilter] Filter by organization ID.
query OptionalNullable[str] Filter by product name.
is_archived OptionalNullable[bool] Filter on archived products.
is_recurring OptionalNullable[bool] Filter on recurring products. If true, only subscriptions tiers are returned. If false, only one-time purchase products are returned.
benefit_id OptionalNullable[models.QueryParamBenefitIDFilter] Filter products granting specific benefit.
page Optional[int] Page number, defaults to 1.
limit Optional[int] Size of a page, defaults to 10. Maximum is 100.
sorting List[models.ProductSortProperty] 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.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ProductsListResponse

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

create

Create a product.

Example Usage

import polar_sdk
from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.products.create(request={
        "name": "<value>",
        "prices": [
            {
                "recurring_interval": polar_sdk.SubscriptionRecurringInterval.MONTH,
                "type": polar_sdk.ProductPriceRecurringFreeCreateType.RECURRING,
                "amount_type": polar_sdk.ProductPriceRecurringFreeCreateAmountType.FREE,
            },
        ],
    })

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
request models.ProductCreate ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Product

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

get

Get a product by ID.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.products.get(id="<value>")

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Product

Errors

Error Type Status Code Content Type
models.ResourceNotFound 404 application/json
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

update

Update a product.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.products.update(id="<value>", product_update={})

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
id str ✔️ N/A
product_update models.ProductUpdate ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Product

Errors

Error Type Status Code Content Type
models.NotPermitted 403 application/json
models.ResourceNotFound 404 application/json
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

update_benefits

Update benefits granted by a product.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.products.update_benefits(id="<value>", product_benefits_update={
        "benefits": [
            "<value>",
        ],
    })

    if res is not None:
        # handle response
        pass

Parameters

Parameter Type Required Description
id str ✔️ N/A
product_benefits_update models.ProductBenefitsUpdate ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Product

Errors

Error Type Status Code Content Type
models.NotPermitted 403 application/json
models.ResourceNotFound 404 application/json
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*