Skip to content

Latest commit

 

History

History
275 lines (192 loc) · 18.9 KB

README.md

File metadata and controls

275 lines (192 loc) · 18.9 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 s:
    res = s.benefits.list()

    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.BenefitsListQueryParamOrganizationIDFilter] Filter by organization ID.
type_filter OptionalNullable[models.QueryParamBenefitTypeFilter] 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

import polar_sdk
from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.benefits.create(request={
        "description": "delightfully fumigate convection though zowie up bulky electronics",
        "properties": {
            "guild_token": "<value>",
            "role_id": "<id>",
        },
        "type": polar_sdk.BenefitDiscordCreateType.DISCORD,
    })

    if res is not None:
        # handle response
        pass

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 s:
    res = s.benefits.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.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

import polar_sdk
from polar_sdk import Polar

with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as s:
    res = s.benefits.update(id="<value>", request_body={
        "type": polar_sdk.BenefitLicenseKeysUpdateType.LICENSE_KEYS,
    })

    if res is not None:
        # handle response
        pass

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 s:
    s.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 s:
    res = s.benefits.grants(id="<value>")

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

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

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.
user_id OptionalNullable[str] Filter by user ID.
github_user_id OptionalNullable[int] Filter by GitHub user ID. Only available for users who have linked their GitHub account on Polar.
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 */*