(benefits )
List benefits.
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
models.BenefitsListResponse
Error Type
Status Code
Content Type
models.HTTPValidationError
422
application/json
models.SDKError
4XX, 5XX
*/*
Create a benefit.
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
models.Benefit
Error Type
Status Code
Content Type
models.HTTPValidationError
422
application/json
models.SDKError
4XX, 5XX
*/*
Get a benefit by ID.
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
Parameter
Type
Required
Description
id
str
✔️
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
models.Benefit
Error Type
Status Code
Content Type
models.ResourceNotFound
404
application/json
models.HTTPValidationError
422
application/json
models.SDKError
4XX, 5XX
*/*
Update a benefit.
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
models.Benefit
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 a benefit.
Warning
Every grants associated with the benefit will be revoked.
Users will lose access to the benefit.
from polar_sdk import Polar
with Polar (
access_token = "<YOUR_BEARER_TOKEN_HERE>" ,
) as s :
s .benefits .delete (id = "<value>" )
# Use the SDK ...
Parameter
Type
Required
Description
id
str
✔️
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
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
*/*
List the individual grants for a benefit.
It's especially useful to check if a user has been granted a benefit.
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
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.
models.BenefitsGrantsResponse
Error Type
Status Code
Content Type
models.ResourceNotFound
404
application/json
models.HTTPValidationError
422
application/json
models.SDKError
4XX, 5XX
*/*