Skip to content

Latest commit

 

History

History
255 lines (163 loc) · 10.7 KB

README.md

File metadata and controls

255 lines (163 loc) · 10.7 KB

Discounts

(discounts)

Overview

Available Operations

create

Create a discount.

Example Usage

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\DiscountFixedRepeatDurationCreate(
    duration: Components\DiscountDuration::Forever,
    durationInMonths: 417458,
    type: Components\DiscountType::Fixed,
    amount: 69025,
    name: '<value>',
);

$response = $sdk->discounts->create(
    request: $request
);

if ($response->discount !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Components\DiscountFixedOnceForeverDurationCreate|Components\DiscountFixedRepeatDurationCreate|Components\DiscountPercentageOnceForeverDurationCreate|Components\DiscountPercentageRepeatDurationCreate ✔️ The request object to use for the request.

Response

?Operations\DiscountsCreateResponse

Errors

Error Type Status Code Content Type
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

delete

Delete a discount.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;

$security = '<YOUR_BEARER_TOKEN_HERE>';

$sdk = Polar\Polar::builder()->setSecurity($security)->build();



$response = $sdk->discounts->delete(
    id: '<value>'
);

if ($response->statusCode === 200) {
    // handle response
}

Parameters

Parameter Type Required Description
id string ✔️ The discount ID.

Response

?Operations\DiscountsDeleteResponse

Errors

Error Type Status Code Content Type
Errors\ResourceNotFound 404 application/json
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

get

Get a discount by ID.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Polar;

$security = '<YOUR_BEARER_TOKEN_HERE>';

$sdk = Polar\Polar::builder()->setSecurity($security)->build();



$response = $sdk->discounts->get(
    id: '<value>'
);

if ($response->discount !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
id string ✔️ The discount ID.

Response

?Operations\DiscountsGetResponse

Errors

Error Type Status Code Content Type
Errors\ResourceNotFound 404 application/json
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

list

List discounts.

Example Usage

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\DiscountsListRequest();

$responses = $sdk->discounts->list(
    request: $request
);


foreach ($responses as $response) {
    if ($response->statusCode === 200) {
        // handle response
    }
}

Parameters

Parameter Type Required Description
$request Operations\DiscountsListRequest ✔️ The request object to use for the request.

Response

?Operations\DiscountsListResponse

Errors

Error Type Status Code Content Type
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*

update

Update a discount.

Example Usage

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();

$discountUpdate = new Components\DiscountUpdate();

$response = $sdk->discounts->update(
    id: '<value>',
    discountUpdate: $discountUpdate

);

if ($response->discount !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
id string ✔️ The discount ID.
discountUpdate Components\DiscountUpdate ✔️ N/A

Response

?Operations\DiscountsUpdateResponse

Errors

Error Type Status Code Content Type
Errors\ResourceNotFound 404 application/json
Errors\HTTPValidationError 422 application/json
Errors\APIException 4XX, 5XX */*