Skip to content

Latest commit

 

History

History
287 lines (193 loc) · 11.4 KB

README.md

File metadata and controls

287 lines (193 loc) · 11.4 KB

Files

(files)

Overview

Available Operations

create

Create a file.

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\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
}

Parameters

Parameter Type Required Description
$request Components\DownloadableFileCreate|Components\ProductMediaFileCreate|Components\OrganizationAvatarFileCreate ✔️ The request object to use for the request.

Response

?Operations\FilesCreateResponse

Errors

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

delete

Delete a file.

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

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

Parameters

Parameter Type Required Description
id string ✔️ N/A

Response

?Operations\FilesDeleteResponse

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

list

List files.

Example Usage

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
    }
}

Parameters

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.

Response

?Operations\FilesListResponse

Errors

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

update

Update a file.

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

$filePatch = new Components\FilePatch();

$response = $sdk->files->update(
    id: '<value>',
    filePatch: $filePatch

);

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

Parameters

Parameter Type Required Description
id string ✔️ The file ID.
filePatch Components\FilePatch ✔️ N/A

Response

?Operations\FilesUpdateResponse

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

uploaded

Complete a file upload.

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

$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
}

Parameters

Parameter Type Required Description
id string ✔️ The file ID.
fileUploadCompleted Components\FileUploadCompleted ✔️ N/A

Response

?Operations\FilesUploadedResponse

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