Skip to content

Latest commit

 

History

History
235 lines (159 loc) · 17.5 KB

README.md

File metadata and controls

235 lines (159 loc) · 17.5 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 polar:

    res = polar.products.list(organization_id=[

    ])

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
id OptionalNullable[models.QueryParamProductIDFilter] Filter by product ID.
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.BenefitIDFilter] 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 polar:

    res = polar.products.create(request={
        "name": "<value>",
        "prices": [
            {
                "recurring_interval": polar_sdk.SubscriptionRecurringInterval.MONTH,
                "type": "recurring",
                "amount_type": "free",
            },
        ],
    })

    # Handle response
    print(res)

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 polar:

    res = polar.products.get(id="<value>")

    # Handle response
    print(res)

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 polar:

    res = polar.products.update(id="<value>", product_update={})

    # Handle response
    print(res)

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 polar:

    res = polar.products.update_benefits(id="<value>", product_benefits_update={
        "benefits": [

        ],
    })

    # Handle response
    print(res)

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 */*