(files)
- create - Create File
- delete - Delete File
- list - List Files
- update - Update File
- uploaded - Complete File Upload
Create a file.
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\OrganizationAvatarFileCreate(
name: '<value>',
mimeType: '<value>',
size: 638424,
upload: new Components\S3FileCreateMultipart(
parts: [
new Components\S3FileCreatePart(
number: 417458,
chunkStart: 134365,
chunkEnd: 69025,
),
],
),
);
$response = $sdk->files->create(
request: $request
);
if ($response->fileUpload !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Components\DownloadableFileCreate|Components\ProductMediaFileCreate|Components\OrganizationAvatarFileCreate | ✔️ | The request object to use for the request. |
?Operations\FilesCreateResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Delete a file.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$response = $sdk->files->delete(
id: '<value>'
);
if ($response->statusCode === 200) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | N/A |
?Operations\FilesDeleteResponse
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 | */* |
List files.
declare(strict_types=1);
require 'vendor/autoload.php';
use Polar;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Polar\Polar::builder()->setSecurity($security)->build();
$responses = $sdk->files->list(
page: 1,
limit: 10,
organizationId: '<value>',
ids: [
'<value>',
]
);
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 | ➖ | N/A |
ids |
array<string> | ➖ | List of file IDs to get. |
Error Type | Status Code | Content Type |
---|---|---|
Errors\HTTPValidationError | 422 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Update a file.
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();
$filePatch = new Components\FilePatch();
$response = $sdk->files->update(
id: '<value>',
filePatch: $filePatch
);
if ($response->responseFilesUpdate !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The file ID. |
filePatch |
Components\FilePatch | ✔️ | N/A |
?Operations\FilesUpdateResponse
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 | */* |
Complete a file upload.
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();
$fileUploadCompleted = new Components\FileUploadCompleted(
id: '<id>',
path: '/sys',
parts: [
new Components\S3FileUploadCompletedPart(
number: 848922,
checksumEtag: '<value>',
checksumSha256Base64: '<value>',
),
],
);
$response = $sdk->files->uploaded(
id: '<value>',
fileUploadCompleted: $fileUploadCompleted
);
if ($response->responseFilesUploaded !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
id |
string | ✔️ | The file ID. |
fileUploadCompleted |
Components\FileUploadCompleted | ✔️ | N/A |
?Operations\FilesUploadedResponse
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 | */* |