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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.8.0"
".": "2.9.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 38
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-155e4761d62255841349c0f8a01b0a9c463ea1d1f2d6c4fd8d1a75c8bef6f226.yml
openapi_spec_hash: ab91f77e7c9d992400cbc7fc8a9e76c1
config_hash: bff282047fafdad771fb7ec685f56944
configured_endpoints: 40
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-a0dda03bbb600917cfb9add468cc4c8c84351a8dbbf61644dbc353263ca1748f.yml
openapi_spec_hash: c24264f32a46d9317aac5af9d6a396f7
config_hash: 920678668dd2da6f8966fbf1b8fde4e2
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 2.9.0 (2026-08-07)

Full Changelog: [v2.8.0...v2.9.0](https://github.com/context-dot-dev/context-php-sdk/compare/v2.8.0...v2.9.0)

### Features

* **api:** api update ([ff6e987](https://github.com/context-dot-dev/context-php-sdk/commit/ff6e9870b85a7e2c9b6f88928ae9fd3ab0af5d4b))
* **api:** api update ([1b83bad](https://github.com/context-dot-dev/context-php-sdk/commit/1b83bad5cc2fec1d3659f6109fc6b7ce30446add))
* **api:** api update ([5932741](https://github.com/context-dot-dev/context-php-sdk/commit/5932741da1376f8eba94cb6736f356efc8d9e455))
* **api:** api update ([985cbbd](https://github.com/context-dot-dev/context-php-sdk/commit/985cbbd5032c78418d6235faf14641dfe3782cb4))
* **api:** api update ([dd60dca](https://github.com/context-dot-dev/context-php-sdk/commit/dd60dca30260506e86c70a674f10e9892788109b))
* **api:** api update ([841bd43](https://github.com/context-dot-dev/context-php-sdk/commit/841bd435edb55d3539afb1162993ac28c427fcd0))
* **api:** api update ([3797497](https://github.com/context-dot-dev/context-php-sdk/commit/3797497dd171a1b3b6ca8260ea34c0e6bccda217))
* **api:** manual updates ([7de1574](https://github.com/context-dot-dev/context-php-sdk/commit/7de1574a2177b6842269fdd4f453f4e5829557fb))

## 2.8.0 (2026-08-05)

Full Changelog: [v2.7.0...v2.8.0](https://github.com/context-dot-dev/context-php-sdk/compare/v2.7.0...v2.8.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The REST API documentation can be found on [docs.context.dev](https://docs.conte
<!-- x-release-please-start-version -->

```
composer require "context-dev/context-dev-php 2.8.0"
composer require "context-dev/context-dev-php 2.9.0"
```

<!-- x-release-please-end -->
Expand Down
104 changes: 104 additions & 0 deletions src/Batch/BatchDeleteResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

declare(strict_types=1);

namespace ContextDev\Batch;

use ContextDev\Batch\BatchDeleteResponse\KeyMetadata;
use ContextDev\Core\Attributes\Optional;
use ContextDev\Core\Concerns\SdkModel;
use ContextDev\Core\Contracts\BaseModel;

/**
* @phpstan-import-type KeyMetadataShape from \ContextDev\Batch\BatchDeleteResponse\KeyMetadata
*
* @phpstan-type BatchDeleteResponseShape = array{
* id?: string|null,
* deleted?: bool|null,
* keyMetadata?: null|KeyMetadata|KeyMetadataShape,
* }
*/
final class BatchDeleteResponse implements BaseModel
{
/** @use SdkModel<BatchDeleteResponseShape> */
use SdkModel;

/**
* ID of the deleted batch.
*/
#[Optional]
public ?string $id;

/**
* Always true on success.
*/
#[Optional]
public ?bool $deleted;

/**
* Metadata about the API key used for the request. Included in every response whenever a valid API key is provided, even when the response status is not 200.
*/
#[Optional('key_metadata')]
public ?KeyMetadata $keyMetadata;

public function __construct()
{
$this->initialize();
}

/**
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param KeyMetadata|KeyMetadataShape|null $keyMetadata
*/
public static function with(
?string $id = null,
?bool $deleted = null,
KeyMetadata|array|null $keyMetadata = null,
): self {
$self = new self;

null !== $id && $self['id'] = $id;
null !== $deleted && $self['deleted'] = $deleted;
null !== $keyMetadata && $self['keyMetadata'] = $keyMetadata;

return $self;
}

/**
* ID of the deleted batch.
*/
public function withID(string $id): self
{
$self = clone $this;
$self['id'] = $id;

return $self;
}

/**
* Always true on success.
*/
public function withDeleted(bool $deleted): self
{
$self = clone $this;
$self['deleted'] = $deleted;

return $self;
}

/**
* Metadata about the API key used for the request. Included in every response whenever a valid API key is provided, even when the response status is not 200.
*
* @param KeyMetadata|KeyMetadataShape $keyMetadata
*/
public function withKeyMetadata(KeyMetadata|array $keyMetadata): self
{
$self = clone $this;
$self['keyMetadata'] = $keyMetadata;

return $self;
}
}
92 changes: 92 additions & 0 deletions src/Batch/BatchDeleteResponse/KeyMetadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

declare(strict_types=1);

namespace ContextDev\Batch\BatchDeleteResponse;

use ContextDev\Core\Attributes\Required;
use ContextDev\Core\Concerns\SdkModel;
use ContextDev\Core\Contracts\BaseModel;

/**
* Metadata about the API key used for the request. Included in every response whenever a valid API key is provided, even when the response status is not 200.
*
* @phpstan-type KeyMetadataShape = array{
* creditsConsumed: int, creditsRemaining: int
* }
*/
final class KeyMetadata implements BaseModel
{
/** @use SdkModel<KeyMetadataShape> */
use SdkModel;

/**
* The number of credits consumed by this request.
*/
#[Required('credits_consumed')]
public int $creditsConsumed;

/**
* The number of credits remaining for your organization after this request.
*/
#[Required('credits_remaining')]
public int $creditsRemaining;

/**
* `new KeyMetadata()` is missing required properties by the API.
*
* To enforce required parameters use
* ```
* KeyMetadata::with(creditsConsumed: ..., creditsRemaining: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new KeyMetadata)->withCreditsConsumed(...)->withCreditsRemaining(...)
* ```
*/
public function __construct()
{
$this->initialize();
}

/**
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*/
public static function with(
int $creditsConsumed,
int $creditsRemaining
): self {
$self = new self;

$self['creditsConsumed'] = $creditsConsumed;
$self['creditsRemaining'] = $creditsRemaining;

return $self;
}

/**
* The number of credits consumed by this request.
*/
public function withCreditsConsumed(int $creditsConsumed): self
{
$self = clone $this;
$self['creditsConsumed'] = $creditsConsumed;

return $self;
}

/**
* The number of credits remaining for your organization after this request.
*/
public function withCreditsRemaining(int $creditsRemaining): self
{
$self = clone $this;
$self['creditsRemaining'] = $creditsRemaining;

return $self;
}
}
42 changes: 35 additions & 7 deletions src/Batch/BatchGetResponse/Credits.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@
/**
* What this batch has done to your credit balance.
*
* @phpstan-type CreditsShape = array{net: int, refunded: int, reserved: int}
* @phpstan-type CreditsShape = array{
* net: int, ocrCharged: int, refunded: int, reserved: int
* }
*/
final class Credits implements BaseModel
{
/** @use SdkModel<CreditsShape> */
use SdkModel;

/**
* `reserved` minus `refunded` — what the batch has cost so far. Equal to `reserved` until the batch settles.
* `reserved` minus `refunded` plus `ocr_charged` — what the batch has cost so far. Equal to `reserved` until the batch settles.
*/
#[Required]
public int $net;

/**
* Credits charged for PDF pages recovered by OCR (pdf.ocr=true), 1 per recovered page, on top of `reserved`. Stays 0 until the batch settles.
*/
#[Required('ocr_charged')]
public int $ocrCharged;

/**
* Credits returned for pages that did not succeed. Stays 0 until the batch reaches a final status, then settles in one movement.
*/
Expand All @@ -41,13 +49,17 @@ final class Credits implements BaseModel
*
* To enforce required parameters use
* ```
* Credits::with(net: ..., refunded: ..., reserved: ...)
* Credits::with(net: ..., ocrCharged: ..., refunded: ..., reserved: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new Credits)->withNet(...)->withRefunded(...)->withReserved(...)
* (new Credits)
* ->withNet(...)
* ->withOcrCharged(...)
* ->withRefunded(...)
* ->withReserved(...)
* ```
*/
public function __construct()
Expand All @@ -60,19 +72,24 @@ public function __construct()
*
* You must use named parameters to construct any parameters with a default value.
*/
public static function with(int $net, int $refunded, int $reserved): self
{
public static function with(
int $net,
int $ocrCharged,
int $refunded,
int $reserved
): self {
$self = new self;

$self['net'] = $net;
$self['ocrCharged'] = $ocrCharged;
$self['refunded'] = $refunded;
$self['reserved'] = $reserved;

return $self;
}

/**
* `reserved` minus `refunded` — what the batch has cost so far. Equal to `reserved` until the batch settles.
* `reserved` minus `refunded` plus `ocr_charged` — what the batch has cost so far. Equal to `reserved` until the batch settles.
*/
public function withNet(int $net): self
{
Expand All @@ -82,6 +99,17 @@ public function withNet(int $net): self
return $self;
}

/**
* Credits charged for PDF pages recovered by OCR (pdf.ocr=true), 1 per recovered page, on top of `reserved`. Stays 0 until the batch settles.
*/
public function withOcrCharged(int $ocrCharged): self
{
$self = clone $this;
$self['ocrCharged'] = $ocrCharged;

return $self;
}

/**
* Credits returned for pages that did not succeed. Stays 0 until the batch reaches a final status, then settles in one movement.
*/
Expand Down
20 changes: 20 additions & 0 deletions src/Batch/BatchGetResultsResponse/Data/ScrapedPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* itemID?: string|null,
* markdown?: string|null,
* meta?: array<string,mixed>|null,
* ocrPages?: int|null,
* }
*/
final class ScrapedPage implements BaseModel
Expand Down Expand Up @@ -90,6 +91,12 @@ final class ScrapedPage implements BaseModel
#[Optional(map: 'mixed')]
public ?array $meta;

/**
* PDF pages of this document recovered by OCR (pdf.ocr=true). Each recovered page bills 1 credit on top of the page base credit; absent when no OCR ran.
*/
#[Optional('ocr_pages')]
public ?int $ocrPages;

/**
* `new ScrapedPage()` is missing required properties by the API.
*
Expand Down Expand Up @@ -130,6 +137,7 @@ public static function with(
?string $itemID = null,
?string $markdown = null,
?array $meta = null,
?int $ocrPages = null,
): self {
$self = new self;

Expand All @@ -142,6 +150,7 @@ public static function with(
null !== $itemID && $self['itemID'] = $itemID;
null !== $markdown && $self['markdown'] = $markdown;
null !== $meta && $self['meta'] = $meta;
null !== $ocrPages && $self['ocrPages'] = $ocrPages;

return $self;
}
Expand Down Expand Up @@ -250,4 +259,15 @@ public function withMeta(array $meta): self

return $self;
}

/**
* PDF pages of this document recovered by OCR (pdf.ocr=true). Each recovered page bills 1 credit on top of the page base credit; absent when no OCR ran.
*/
public function withOcrPages(int $ocrPages): self
{
$self = clone $this;
$self['ocrPages'] = $ocrPages;

return $self;
}
}
Loading
Loading