Skip to content

Latest commit

 

History

History
253 lines (160 loc) · 8.6 KB

README.md

File metadata and controls

253 lines (160 loc) · 8.6 KB

Customers

(customers)

Overview

Available Operations

create

Create a customer.

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\CustomerCreate(
    email: '[email protected]',
);

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

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

Parameters

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

Response

?Operations\CustomersCreateResponse

Errors

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

delete

Delete a customer.

Immediately cancels any active subscriptions and revokes any active benefits.

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->customers->delete(
    id: '<value>'
);

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

Parameters

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

Response

?Operations\CustomersDeleteResponse

Errors

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

get

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

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

Parameters

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

Response

?Operations\CustomersGetResponse

Errors

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

list

List customers.

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

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


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

Parameters

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

Response

?Operations\CustomersListResponse

Errors

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

update

Update a customer.

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

$customerUpdate = new Components\CustomerUpdate();

$response = $sdk->customers->update(
    id: '<value>',
    customerUpdate: $customerUpdate

);

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

Parameters

Parameter Type Required Description
id string ✔️ The customer ID.
customerUpdate Components\CustomerUpdate ✔️ N/A

Response

?Operations\CustomersUpdateResponse

Errors

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