Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"homepage": "https://www.cloudpdf.com"
}
},
"originGitCommit": "5f2d480665034420df58c19fd1328b0823104e0f",
"originGitCommit": "b7dddfba5011349a40db7878b5cbc8685b2d42cf",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0-alpha.13",
"requestedVersion": "3.0.0-alpha.14",
"ciProvider": "github",
"sdkVersion": "3.0.0-alpha.13"
"sdkVersion": "3.0.0-alpha.14"
}
8 changes: 4 additions & 4 deletions cloudpdf-generation.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"language": "php",
"canonicalVersion": "3.0.0-next.13",
"sdkVersion": "3.0.0-alpha.13",
"canonicalVersion": "3.0.0-next.14",
"sdkVersion": "3.0.0-alpha.14",
"source": {
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "a472da9c7aed5db7f2b6b1f67f1b6268a9407afe9e7cf879ac04b878b4fc9dc7",
"gitCommit": "5f2d480665034420df58c19fd1328b0823104e0f",
"openapiSha256": "188ea071e3534971638ee3d1fb1f19c77f36e04b2a783f5eefdbe67326527ea6",
"gitCommit": "b7dddfba5011349a40db7878b5cbc8685b2d42cf",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
146 changes: 146 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2946,6 +2946,152 @@ $client->doc->metadata->get(
</details>

## Doc Pages
<details><summary><code>$client-&gt;doc-&gt;pages-&gt;setScale($docId, $layerName, $pon, $request) -> ?DocPagesSetScale200Response</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```php
$client->doc->pages->setScale(
'docId',
'layerName',
1,
new DocPagesSetScaleRequest([]),
);
```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**$docId:** `string`

</dd>
</dl>

<dl>
<dd>

**$layerName:** `string`

</dd>
</dl>

<dl>
<dd>

**$pon:** `int`

</dd>
</dl>

<dl>
<dd>

**$documentPassword:** `?string` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.

</dd>
</dl>

<dl>
<dd>

**$measure:** `?DocPagesSetScaleRequestMeasure`

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>

<details><summary><code>$client-&gt;doc-&gt;pages-&gt;viewports($docId, $layerName, $pon, $request) -> ?array</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```php
$client->doc->pages->viewports(
'docId',
'layerName',
1,
new ViewportsPagesRequest([]),
);
```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**$docId:** `string`

</dd>
</dl>

<dl>
<dd>

**$layerName:** `string`

</dd>
</dl>

<dl>
<dd>

**$pon:** `int`

</dd>
</dl>

<dl>
<dd>

**$documentPassword:** `?string` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>

<details><summary><code>$client-&gt;doc-&gt;pages-&gt;delete($docId, $layerName, $request) -> ?DocPagesDelete200Response</code></summary>
<dl>
<dd>
Expand Down
4 changes: 2 additions & 2 deletions src/CloudPDFClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public function __construct(
$defaultHeaders = [
'X-Fern-Language' => 'PHP',
'X-Fern-SDK-Name' => 'CloudPDF',
'X-Fern-SDK-Version' => '3.0.0-alpha.13',
'User-Agent' => 'cloudpdf/sdk/3.0.0-alpha.13',
'X-Fern-SDK-Version' => '3.0.0-alpha.14',
'User-Agent' => 'cloudpdf/sdk/3.0.0-alpha.14',
];
if ($token != null) {
$defaultHeaders['Authorization'] = "Bearer $token";
Expand Down
138 changes: 136 additions & 2 deletions src/Doc/Pages/PagesClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@

use Psr\Http\Client\ClientInterface;
use CloudPDF\Core\Client\RawClient;
use CloudPDF\Doc\Pages\Requests\DeletePagesRequest;
use CloudPDF\Types\DocPagesDelete200Response;
use CloudPDF\Doc\Pages\Requests\DocPagesSetScaleRequest;
use CloudPDF\Types\DocPagesSetScale200Response;
use CloudPDF\Exceptions\CloudPDFException;
use CloudPDF\Exceptions\CloudPDFApiException;
use CloudPDF\Core\Json\JsonApiRequest;
use CloudPDF\Core\Client\HttpMethod;
use JsonException;
use Psr\Http\Client\ClientExceptionInterface;
use CloudPDF\Doc\Pages\Requests\ViewportsPagesRequest;
use CloudPDF\Types\DocPagesViewports200ResponseItem;
use CloudPDF\Core\Json\JsonDecoder;
use CloudPDF\Doc\Pages\Requests\DeletePagesRequest;
use CloudPDF\Types\DocPagesDelete200Response;
use CloudPDF\Doc\Pages\Requests\ExtractPagesRequest;
use CloudPDF\Doc\Pages\Requests\FlattenPagesRequest;
use CloudPDF\Types\DocPagesFlatten200Response;
Expand Down Expand Up @@ -66,6 +71,135 @@ public function __construct(
$this->options = $options ?? [];
}

/**
* Example:
* ```php
* $client->doc->pages->setScale(
* 'docId',
* 'layerName',
* 1,
* new DocPagesSetScaleRequest([]),
* );
* ```
*
* @param string $docId
* @param string $layerName
* @param int $pon
* @param DocPagesSetScaleRequest $request
* @param ?array{
* baseUrl?: string,
* maxRetries?: int,
* timeout?: float,
* headers?: array<string, string>,
* queryParameters?: array<string, mixed>,
* bodyProperties?: array<string, mixed>,
* } $options
* @return ?DocPagesSetScale200Response
* @throws CloudPDFException
* @throws CloudPDFApiException
*/
public function setScale(string $docId, string $layerName, int $pon, DocPagesSetScaleRequest $request, ?array $options = null): ?DocPagesSetScale200Response
{
$options = array_merge($this->options, $options ?? []);
$headers = [];
if ($request->documentPassword != null) {
$headers['X-Document-Password'] = $request->documentPassword;
}
try {
$response = $this->client->sendRequest(
new JsonApiRequest(
baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? '',
path: "v1/docs/{$docId}/layers/{$layerName}/pages/{$pon}/scale",
method: HttpMethod::PUT,
headers: $headers,
body: $request,
),
$options,
);
$statusCode = $response->getStatusCode();
if ($statusCode >= 200 && $statusCode < 400) {
$json = $response->getBody()->getContents();
if (empty($json)) {
return null;
}
return DocPagesSetScale200Response::fromJson($json);
}
} catch (JsonException $e) {
throw new CloudPDFException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e);
} catch (ClientExceptionInterface $e) {
throw new CloudPDFException(message: $e->getMessage(), previous: $e);
}
throw new CloudPDFApiException(
message: 'API request failed',
statusCode: $statusCode,
body: $response->getBody()->getContents(),
);
}

/**
* Example:
* ```php
* $client->doc->pages->viewports(
* 'docId',
* 'layerName',
* 1,
* new ViewportsPagesRequest([]),
* );
* ```
*
* @param string $docId
* @param string $layerName
* @param int $pon
* @param ViewportsPagesRequest $request
* @param ?array{
* baseUrl?: string,
* maxRetries?: int,
* timeout?: float,
* headers?: array<string, string>,
* queryParameters?: array<string, mixed>,
* bodyProperties?: array<string, mixed>,
* } $options
* @return ?array<DocPagesViewports200ResponseItem>
* @throws CloudPDFException
* @throws CloudPDFApiException
*/
public function viewports(string $docId, string $layerName, int $pon, ViewportsPagesRequest $request = new ViewportsPagesRequest(), ?array $options = null): ?array
{
$options = array_merge($this->options, $options ?? []);
$headers = [];
if ($request->documentPassword != null) {
$headers['X-Document-Password'] = $request->documentPassword;
}
try {
$response = $this->client->sendRequest(
new JsonApiRequest(
baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? '',
path: "v1/docs/{$docId}/layers/{$layerName}/pages/{$pon}/viewports",
method: HttpMethod::GET,
headers: $headers,
),
$options,
);
$statusCode = $response->getStatusCode();
if ($statusCode >= 200 && $statusCode < 400) {
$json = $response->getBody()->getContents();
if (empty($json)) {
return null;
}
return JsonDecoder::decodeArray($json, [DocPagesViewports200ResponseItem::class]); // @phpstan-ignore-line
}
} catch (JsonException $e) {
throw new CloudPDFException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e);
} catch (ClientExceptionInterface $e) {
throw new CloudPDFException(message: $e->getMessage(), previous: $e);
}
throw new CloudPDFApiException(
message: 'API request failed',
statusCode: $statusCode,
body: $response->getBody()->getContents(),
);
}

/**
* Example:
* ```php
Expand Down
34 changes: 34 additions & 0 deletions src/Doc/Pages/Requests/DocPagesSetScaleRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace CloudPDF\Doc\Pages\Requests;

use CloudPDF\Core\Json\JsonSerializableType;
use CloudPDF\Doc\Pages\Types\DocPagesSetScaleRequestMeasure;
use CloudPDF\Core\Json\JsonProperty;

class DocPagesSetScaleRequest extends JsonSerializableType
{
/**
* @var ?string $documentPassword Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead.
*/
public ?string $documentPassword;

/**
* @var ?DocPagesSetScaleRequestMeasure $measure
*/
#[JsonProperty('measure')]
public ?DocPagesSetScaleRequestMeasure $measure;

/**
* @param array{
* documentPassword?: ?string,
* measure?: ?DocPagesSetScaleRequestMeasure,
* } $values
*/
public function __construct(
array $values = [],
) {
$this->documentPassword = $values['documentPassword'] ?? null;
$this->measure = $values['measure'] ?? null;
}
}
Loading
Loading