Skip to content

Latest commit

 

History

History
269 lines (180 loc) · 18.1 KB

README.md

File metadata and controls

269 lines (180 loc) · 18.1 KB

Benefits

(benefits)

Overview

Available Operations

list

List benefits.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.benefits.list()

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
organization_id OptionalNullable[models.BenefitsListQueryParamOrganizationIDFilter] Filter by organization ID.
type_filter OptionalNullable[models.BenefitTypeFilter] Filter by benefit type.
page Optional[int] Page number, defaults to 1.
limit Optional[int] Size of a page, defaults to 10. Maximum is 100.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.BenefitsListResponse

Errors

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

create

Create a benefit.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.benefits.create(request={
        "description": "delightfully fumigate convection though zowie up bulky electronics",
        "properties": {
            "guild_token": "<value>",
            "role_id": "<id>",
        },
        "type": "discord",
    })

    # Handle response
    print(res)

Parameters

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

Response

models.Benefit

Errors

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

get

Get a benefit by ID.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.benefits.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.Benefit

Errors

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

update

Update a benefit.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.benefits.update(id="<value>", request_body={
        "type": "license_keys",
    })

    # Handle response
    print(res)

Parameters

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

Response

models.Benefit

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

delete

Delete a benefit.

Warning

Every grants associated with the benefit will be revoked. Users will lose access to the benefit.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    polar.benefits.delete(id="<value>")

    # Use the SDK ...

Parameters

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

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

grants

List the individual grants for a benefit.

It's especially useful to check if a user has been granted a benefit.

Example Usage

from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.benefits.grants(id="<value>")

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
id str ✔️ N/A
is_granted OptionalNullable[bool] Filter by granted status. If true, only granted benefits will be returned. If false, only revoked benefits will be returned.
customer_id OptionalNullable[models.QueryParamCustomerIDFilter] Filter by customer.
page Optional[int] Page number, defaults to 1.
limit Optional[int] Size of a page, defaults to 10. Maximum is 100.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.BenefitsGrantsResponse

Errors

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