Skip to content

Latest commit

 

History

History
253 lines (160 loc) · 12.9 KB

README.md

File metadata and controls

253 lines (160 loc) · 12.9 KB

CustomFields

(customFields)

Overview

Available Operations

  • create - Create Custom Field
  • delete - Delete Custom Field
  • get - Get Custom Field
  • list - List Custom Fields
  • update - Update Custom Field

create

Create a custom field.

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\CustomFieldCreateNumber(
    slug: '<value>',
    name: '<value>',
    properties: new Components\CustomFieldNumberProperties(),
);

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

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

Parameters

Parameter Type Required Description
$request Components\CustomFieldCreateText|Components\CustomFieldCreateNumber|Components\CustomFieldCreateDate|Components\CustomFieldCreateCheckbox|Components\CustomFieldCreateSelect ✔️ The request object to use for the request.

Response

?Operations\CustomFieldsCreateResponse

Errors

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

delete

Delete a custom field.

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

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

Parameters

Parameter Type Required Description
id string ✔️ The custom field ID.

Response

?Operations\CustomFieldsDeleteResponse

Errors

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

get

Get a custom field 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->customFields->get(
    id: '<value>'
);

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

Parameters

Parameter Type Required Description
id string ✔️ The custom field ID.

Response

?Operations\CustomFieldsGetResponse

Errors

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

list

List custom fields.

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

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


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

Parameters

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

Response

?Operations\CustomFieldsListResponse

Errors

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

update

Update a custom field.

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



$response = $sdk->customFields->update(
    id: '<value>',
    customFieldUpdate: new Components\CustomFieldUpdateText()

);

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

Parameters

Parameter Type Required Description
id string ✔️ The custom field ID.
customFieldUpdate Components\CustomFieldUpdateText|Components\CustomFieldUpdateNumber|Components\CustomFieldUpdateDate|Components\CustomFieldUpdateCheckbox|Components\CustomFieldUpdateSelect ✔️ N/A

Response

?Operations\CustomFieldsUpdateResponse

Errors

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