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.7.0"
".": "2.8.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: 37
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-758c3a2fbd5b7be61c8e6e0ad2e6a5ec30695747bb675960d888c497647d13d7.yml
openapi_spec_hash: 00002d90bde02f67e174368ae470c597
config_hash: 2bea1743c84d63bd61f8501a6ea63065
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 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)

### Features

* **api:** manual updates ([5a35e94](https://github.com/context-dot-dev/context-php-sdk/commit/5a35e9456fbed83f7a6b96ee69c1443974246d2c))

## 2.7.0 (2026-08-01)

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

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

declare(strict_types=1);

namespace ContextDev\Brand;

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

/**
* Search brands by name or domain and get back up to 10 lightweight matches (domain, name, logo), most popular first: by Tranco rank, then market cap for brands outside the Tranco list, with text relevance breaking ties. Matching is prefix-based with no typo tolerance, so it is suited to autocomplete. Only brands already in the Context.dev index are returned — use /brand/retrieve to fetch (and index) a specific domain. Free on Pro and Scale plans; costs 1 credit per request on the Free and Starter plans.
*
* @see ContextDev\Services\BrandService::search()
*
* @phpstan-type BrandSearchParamsShape = array{
* query: string, tags?: list<string>|null
* }
*/
final class BrandSearchParams implements BaseModel
{
/** @use SdkModel<BrandSearchParamsShape> */
use SdkModel;
use SdkParams;

/**
* Search term, matched against brand names and domains by prefix (e.g. 'nike', 'nike.com', 'nik').
*/
#[Required]
public string $query;

/**
* Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.
*
* @var list<string>|null $tags
*/
#[Optional(list: 'string')]
public ?array $tags;

/**
* `new BrandSearchParams()` is missing required properties by the API.
*
* To enforce required parameters use
* ```
* BrandSearchParams::with(query: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new BrandSearchParams)->withQuery(...)
* ```
*/
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 list<string>|null $tags
*/
public static function with(string $query, ?array $tags = null): self
{
$self = new self;

$self['query'] = $query;

null !== $tags && $self['tags'] = $tags;

return $self;
}

/**
* Search term, matched against brand names and domains by prefix (e.g. 'nike', 'nike.com', 'nik').
*/
public function withQuery(string $query): self
{
$self = clone $this;
$self['query'] = $query;

return $self;
}

/**
* Optional comma-separated caller-defined tags for tracking this request. Tags are recorded on the request's usage log and can be used to filter usage on the dashboard usage page. Up to 20 tags, each 1-50 characters.
*
* @param list<string> $tags
*/
public function withTags(array $tags): self
{
$self = clone $this;
$self['tags'] = $tags;

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

declare(strict_types=1);

namespace ContextDev\Brand;

use ContextDev\Brand\BrandSearchResponse\KeyMetadata;
use ContextDev\Brand\BrandSearchResponse\Result;
use ContextDev\Core\Attributes\Optional;
use ContextDev\Core\Attributes\Required;
use ContextDev\Core\Concerns\SdkModel;
use ContextDev\Core\Contracts\BaseModel;

/**
* @phpstan-import-type ResultShape from \ContextDev\Brand\BrandSearchResponse\Result
* @phpstan-import-type KeyMetadataShape from \ContextDev\Brand\BrandSearchResponse\KeyMetadata
*
* @phpstan-type BrandSearchResponseShape = array{
* results: list<Result|ResultShape>,
* keyMetadata?: null|KeyMetadata|KeyMetadataShape,
* }
*/
final class BrandSearchResponse implements BaseModel
{
/** @use SdkModel<BrandSearchResponseShape> */
use SdkModel;

/**
* Up to 10 matching brands, most popular first. Empty when nothing matches.
*
* @var list<Result> $results
*/
#[Required(list: Result::class)]
public array $results;

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

/**
* `new BrandSearchResponse()` is missing required properties by the API.
*
* To enforce required parameters use
* ```
* BrandSearchResponse::with(results: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new BrandSearchResponse)->withResults(...)
* ```
*/
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 list<Result|ResultShape> $results
* @param KeyMetadata|KeyMetadataShape|null $keyMetadata
*/
public static function with(
array $results,
KeyMetadata|array|null $keyMetadata = null
): self {
$self = new self;

$self['results'] = $results;

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

return $self;
}

/**
* Up to 10 matching brands, most popular first. Empty when nothing matches.
*
* @param list<Result|ResultShape> $results
*/
public function withResults(array $results): self
{
$self = clone $this;
$self['results'] = $results;

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/Brand/BrandSearchResponse/KeyMetadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

declare(strict_types=1);

namespace ContextDev\Brand\BrandSearchResponse;

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