Skip to content

Latest commit

 

History

History
267 lines (175 loc) · 10.6 KB

README.md

File metadata and controls

267 lines (175 loc) · 10.6 KB

Products

(products)

Overview

Available Operations

create

Create a product.

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\ProductRecurringCreate(
    name: '<value>',
    prices: [
        new Components\ProductPriceRecurringFixedCreate(
            priceAmount: 638424,
            recurringInterval: Components\SubscriptionRecurringInterval::Month,
        ),
    ],
);

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

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

Parameters

Parameter Type Required Description
$request Components\ProductRecurringCreate|Components\ProductOneTimeCreate ✔️ The request object to use for the request.

Response

?Operations\ProductsCreateResponse

Errors

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

get

Get a product 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->products->get(
    id: '<value>'
);

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

Parameters

Parameter Type Required Description
id string ✔️ N/A

Response

?Operations\ProductsGetResponse

Errors

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

list

List products.

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

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


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

Parameters

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

Response

?Operations\ProductsListResponse

Errors

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

update

Update a product.

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

$productUpdate = new Components\ProductUpdate();

$response = $sdk->products->update(
    id: '<value>',
    productUpdate: $productUpdate

);

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

Parameters

Parameter Type Required Description
id string ✔️ N/A
productUpdate Components\ProductUpdate ✔️ N/A

Response

?Operations\ProductsUpdateResponse

Errors

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

updateBenefits

Update benefits granted by a product.

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

$productBenefitsUpdate = new Components\ProductBenefitsUpdate(
    benefits: [
        '<value>',
    ],
);

$response = $sdk->products->updateBenefits(
    id: '<value>',
    productBenefitsUpdate: $productBenefitsUpdate

);

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

Parameters

Parameter Type Required Description
id string ✔️ N/A
productBenefitsUpdate Components\ProductBenefitsUpdate ✔️ N/A

Response

?Operations\ProductsUpdateBenefitsResponse

Errors

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