(benefits)
- create - Create Benefit
- delete - Delete Benefit
- get - Get Benefit
- grants - List Benefit Grants
- list - List Benefits
- update - Update Benefit
Create a benefit.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$request = new Components\BenefitDiscordCreate(
description: 'delightfully fumigate convection though zowie up bulky electronics',
properties: new Components\BenefitDiscordCreateProperties(
guildToken: '<value>',
roleId: '<id>',
),
);
$response = $sdk->benefits->create(
request: $request
);
if ($response->benefit !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Components\BenefitCustomCreate|Components\BenefitAdsCreate|Components\BenefitDiscordCreate|Components\BenefitGitHubRepositoryCreate|Components\BenefitDownloadablesCreate|Components\BenefitLicenseKeysCreate | ✔️ | The request object to use for the request. |
?Operations\BenefitsCreateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Delete a benefit.
Warning
Every grants associated with the benefit will be revoked. Users will lose access to the benefit.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$response = $sdk->benefits->delete(
id: '<value>'
);
if ($response->statusCode === 200) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | N/A |
?Operations\BenefitsDeleteResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\NotPermitted | 403 | application/json |
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Get a benefit by ID.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$response = $sdk->benefits->get(
id: '<value>'
);
if ($response->benefit !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | N/A |
?Operations\BenefitsGetResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
List the individual grants for a benefit.
It's especially useful to check if a user has been granted a benefit.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$request = new Operations\BenefitsGrantsRequest(
id: '<value>',
);
$responses = $sdk->benefits->grants(
request: $request
);
foreach ($responses as $response) {
if ($response->statusCode === 200) {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Operations\BenefitsGrantsRequest | ✔️ | The request object to use for the request. |
?Operations\BenefitsGrantsResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
List benefits.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$responses = $sdk->benefits->list(
page: 1,
limit: 10,
organizationId: [
'<value>',
],
typeFilter: [
Components\BenefitType::Downloadables,
]
);
foreach ($responses as $response) {
if ($response->statusCode === 200) {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
page |
?int | ➖ | Page number, defaults to 1. |
limit |
?int | ➖ | Size of a page, defaults to 10. Maximum is 100. |
organizationId |
string|array|null | ➖ | Filter by organization ID. |
typeFilter |
Components\BenefitType|array|null | ➖ | Filter by benefit type. |
?Operations\BenefitsListResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Update a benefit.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
use Polar\Models\Components;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$response = $sdk->benefits->update(
id: '<value>',
requestBody: new Components\BenefitLicenseKeysUpdate()
);
if ($response->benefit !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | N/A |
requestBody |
Components\BenefitAdsUpdate|Components\BenefitCustomUpdate|Components\BenefitDiscordUpdate|Components\BenefitGitHubRepositoryUpdate|Components\BenefitDownloadablesUpdate|Components\BenefitLicenseKeysUpdate | ✔️ | N/A |
?Operations\BenefitsUpdateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\NotPermitted | 403 | application/json |
Errors\ResourceNotFound | 404 | application/json |
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |