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.10.0"
".": "2.11.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 41
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-5dbe631ce516ca688273053ddcb58870561bd6dc76fa75df354c954d7af65a3c.yml
openapi_spec_hash: 53a74c4cccbdec8590db38183840a446
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-b0c72d2fe5911c9ce155275b954198bf2152e915a7e5b9f719aad50e222b9ef8.yml
openapi_spec_hash: 5cf943ea5718059b7975417b012cee28
config_hash: 0fb0ceca5946298c416cec0cca5260c7
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 2.11.0 (2026-08-18)

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

### Features

* **api:** api update ([6884bcc](https://github.com/context-dot-dev/context-php-sdk/commit/6884bccdb59931c30a1778e0ce6dfe8566eac781))
* **api:** api update ([12c8df5](https://github.com/context-dot-dev/context-php-sdk/commit/12c8df51b59e9fefe8ebf3dd17ee2ddbc8ef3af7))
* **api:** api update ([5f91017](https://github.com/context-dot-dev/context-php-sdk/commit/5f910173f3c49527bd7d5408a198885b11c4fd29))


### Chores

* **internal:** codegen related update ([dc83cc4](https://github.com/context-dot-dev/context-php-sdk/commit/dc83cc446beff270d9352e6962eec7541219a691))

## 2.10.0 (2026-08-17)

Full Changelog: [v2.9.0...v2.10.0](https://github.com/context-dot-dev/context-php-sdk/compare/v2.9.0...v2.10.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.10.0"
composer require "context-dev/context-dev-php 2.11.0"
```

<!-- x-release-please-end -->
Expand Down
36 changes: 33 additions & 3 deletions src/Brand/BrandGetResponse/Brand/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace ContextDev\Brand\BrandGetResponse\Brand;

use ContextDev\Brand\BrandGetResponse\Brand\Color\Source;
use ContextDev\Core\Attributes\Optional;
use ContextDev\Core\Concerns\SdkModel;
use ContextDev\Core\Contracts\BaseModel;

/**
* @phpstan-type ColorShape = array{hex?: string|null, name?: string|null}
* @phpstan-type ColorShape = array{
* hex?: string|null, name?: string|null, source?: null|Source|value-of<Source>
* }
*/
final class Color implements BaseModel
{
Expand All @@ -28,6 +31,14 @@ final class Color implements BaseModel
#[Optional]
public ?string $name;

/**
* Where the color was observed: 'site' colors come from the website's own theme signals (rendered page colors, manifest, theme-color meta), 'logo' colors from logo image pixels.
*
* @var value-of<Source>|null $source
*/
#[Optional(enum: Source::class)]
public ?string $source;

public function __construct()
{
$this->initialize();
Expand All @@ -37,13 +48,19 @@ public function __construct()
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param Source|value-of<Source>|null $source
*/
public static function with(?string $hex = null, ?string $name = null): self
{
public static function with(
?string $hex = null,
?string $name = null,
Source|string|null $source = null
): self {
$self = new self;

null !== $hex && $self['hex'] = $hex;
null !== $name && $self['name'] = $name;
null !== $source && $self['source'] = $source;

return $self;
}
Expand All @@ -69,4 +86,17 @@ public function withName(string $name): self

return $self;
}

/**
* Where the color was observed: 'site' colors come from the website's own theme signals (rendered page colors, manifest, theme-color meta), 'logo' colors from logo image pixels.
*
* @param Source|value-of<Source> $source
*/
public function withSource(Source|string $source): self
{
$self = clone $this;
$self['source'] = $source;

return $self;
}
}
15 changes: 15 additions & 0 deletions src/Brand/BrandGetResponse/Brand/Color/Source.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace ContextDev\Brand\BrandGetResponse\Brand\Color;

/**
* Where the color was observed: 'site' colors come from the website's own theme signals (rendered page colors, manifest, theme-color meta), 'logo' colors from logo image pixels.
*/
enum Source: string
{
case SITE = 'site';

case LOGO = 'logo';
}
36 changes: 33 additions & 3 deletions src/Brand/BrandGetSimplifiedResponse/Brand/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace ContextDev\Brand\BrandGetSimplifiedResponse\Brand;

use ContextDev\Brand\BrandGetSimplifiedResponse\Brand\Color\Source;
use ContextDev\Core\Attributes\Optional;
use ContextDev\Core\Concerns\SdkModel;
use ContextDev\Core\Contracts\BaseModel;

/**
* @phpstan-type ColorShape = array{hex?: string|null, name?: string|null}
* @phpstan-type ColorShape = array{
* hex?: string|null, name?: string|null, source?: null|Source|value-of<Source>
* }
*/
final class Color implements BaseModel
{
Expand All @@ -28,6 +31,14 @@ final class Color implements BaseModel
#[Optional]
public ?string $name;

/**
* Where the color was observed: 'site' colors come from the website's own theme signals (rendered page colors, manifest, theme-color meta), 'logo' colors from logo image pixels.
*
* @var value-of<Source>|null $source
*/
#[Optional(enum: Source::class)]
public ?string $source;

public function __construct()
{
$this->initialize();
Expand All @@ -37,13 +48,19 @@ public function __construct()
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param Source|value-of<Source>|null $source
*/
public static function with(?string $hex = null, ?string $name = null): self
{
public static function with(
?string $hex = null,
?string $name = null,
Source|string|null $source = null
): self {
$self = new self;

null !== $hex && $self['hex'] = $hex;
null !== $name && $self['name'] = $name;
null !== $source && $self['source'] = $source;

return $self;
}
Expand All @@ -69,4 +86,17 @@ public function withName(string $name): self

return $self;
}

/**
* Where the color was observed: 'site' colors come from the website's own theme signals (rendered page colors, manifest, theme-color meta), 'logo' colors from logo image pixels.
*
* @param Source|value-of<Source> $source
*/
public function withSource(Source|string $source): self
{
$self = clone $this;
$self['source'] = $source;

return $self;
}
}
15 changes: 15 additions & 0 deletions src/Brand/BrandGetSimplifiedResponse/Brand/Color/Source.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace ContextDev\Brand\BrandGetSimplifiedResponse\Brand\Color;

/**
* Where the color was observed: 'site' colors come from the website's own theme signals (rendered page colors, manifest, theme-color meta), 'logo' colors from logo image pixels.
*/
enum Source: string
{
case SITE = 'site';

case LOGO = 'logo';
}
5 changes: 1 addition & 4 deletions src/Core/BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ protected function buildRequest(
$parsedPath = Util::parsePath($path);

/** @var array<string,mixed> $mergedQuery */
$mergedQuery = array_merge_recursive(
$query,
$options->extraQueryParams ?? []
);
$mergedQuery = [...$query, ...($options->extraQueryParams ?? [])];
$uri = Util::joinUri($this->baseUrl, path: $parsedPath, query: $mergedQuery)->__toString();
$idempotencyHeaders = $this->idempotencyHeader && !array_key_exists($this->idempotencyHeader, array: $headers)
? [$this->idempotencyHeader => $this->generateIdempotencyKey()]
Expand Down
20 changes: 20 additions & 0 deletions src/Core/Concerns/SdkModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ public function __get(string $key): mixed
return null;
}

/**
* @internal
*
* Like {@link __unserialize()}, but for raw API payloads, whose keys are
* API property names rather than PHP property names
*
* @param array<string, mixed> $data
*/
public function unserializeFromApiPayload(array $data): void
{
foreach (self::$converter->properties as $name => $info) {
if ($name !== $info->apiName && array_key_exists($info->apiName, array: $data)) {
$data[$name] = $data[$info->apiName];
unset($data[$info->apiName]);
}
}

$this->__unserialize($data);
}

/**
* @internal
*
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static function joinUri(
parse_str($base->getQuery(), $q1);
parse_str($parsed['query'] ?? '', $q2);

$mergedQuery = array_merge_recursive($q1, $q2, $query);
$mergedQuery = [...$q1, ...$q2, ...$query];

/** @var array<string,mixed> */
$normalizedQuery = self::mapRecursive(
Expand Down
25 changes: 24 additions & 1 deletion src/News/NewsSearchResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,29 @@ final class NewsSearchResponse implements BaseModel
/** @use SdkModel<NewsSearchResponseShape> */
use SdkModel;

/** @var list<Data> $data */
/**
* Articles matching the search, in the requested order.
*
* @var list<Data> $data
*/
#[Required(list: Data::class)]
public array $data;

/**
* True when more results are available beyond this page.
*/
#[Required('has_more')]
public bool $hasMore;

/**
* Summary information about this response.
*/
#[Required]
public Meta $meta;

/**
* Pass as cursor in the next request to fetch the following page. Null when there are no more results.
*/
#[Required('next_cursor')]
public ?string $nextCursor;

Expand Down Expand Up @@ -101,6 +114,8 @@ public static function with(
}

/**
* Articles matching the search, in the requested order.
*
* @param list<Data|DataShape> $data
*/
public function withData(array $data): self
Expand All @@ -111,6 +126,9 @@ public function withData(array $data): self
return $self;
}

/**
* True when more results are available beyond this page.
*/
public function withHasMore(bool $hasMore): self
{
$self = clone $this;
Expand All @@ -120,6 +138,8 @@ public function withHasMore(bool $hasMore): self
}

/**
* Summary information about this response.
*
* @param Meta|MetaShape $meta
*/
public function withMeta(Meta|array $meta): self
Expand All @@ -130,6 +150,9 @@ public function withMeta(Meta|array $meta): self
return $self;
}

/**
* Pass as cursor in the next request to fetch the following page. Null when there are no more results.
*/
public function withNextCursor(?string $nextCursor): self
{
$self = clone $this;
Expand Down
Loading
Loading