From 247b4cf8bace8c77249b90de09e3eccfa7692e2e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Jun 2026 14:13:26 +0000 Subject: [PATCH 1/2] feat(api): api update --- .stats.yml | 4 +- src/Content/ContentSubmitParams/Policy.php | 7 +- .../Policy/FaceDetection.php | 144 ++++++++++++++++++ .../Policy/FaceDetection/Comparator.php | 15 ++ .../Policy/ClassifierOutput.php | 25 +++ 5 files changed, 191 insertions(+), 4 deletions(-) create mode 100644 src/Content/ContentSubmitParams/Policy/FaceDetection.php create mode 100644 src/Content/ContentSubmitParams/Policy/FaceDetection/Comparator.php diff --git a/.stats.yml b/.stats.yml index e615fc9..b80b97b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 27 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-2a9024f55f158ede9f9d4811ab4035e470afc920d0f15513da6603d011b2bef7.yml -openapi_spec_hash: cc3275c46438bd043ac96e669e27276f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-cbf656f40e43acf60d9596f78204f031dc8c7205626df8f05ce8e88bcf49b597.yml +openapi_spec_hash: 23be5a56248a1a575b34833eb7e7fe49 config_hash: 9d144cc6c49d3fd53e5b4472c1e22165 diff --git a/src/Content/ContentSubmitParams/Policy.php b/src/Content/ContentSubmitParams/Policy.php index 50bebdb..103fc43 100644 --- a/src/Content/ContentSubmitParams/Policy.php +++ b/src/Content/ContentSubmitParams/Policy.php @@ -8,6 +8,7 @@ use ModerationAPI\Content\ContentSubmitParams\Policy\Cannabis; use ModerationAPI\Content\ContentSubmitParams\Policy\CodeAbuse; use ModerationAPI\Content\ContentSubmitParams\Policy\Crypto; +use ModerationAPI\Content\ContentSubmitParams\Policy\FaceDetection; use ModerationAPI\Content\ContentSubmitParams\Policy\Flirtation; use ModerationAPI\Content\ContentSubmitParams\Policy\Guideline; use ModerationAPI\Content\ContentSubmitParams\Policy\Hate; @@ -57,6 +58,7 @@ * @phpstan-import-type SelfHarmShape from \ModerationAPI\Content\ContentSubmitParams\Policy\SelfHarm * @phpstan-import-type SpamShape from \ModerationAPI\Content\ContentSubmitParams\Policy\Spam * @phpstan-import-type LowQualityContentShape from \ModerationAPI\Content\ContentSubmitParams\Policy\LowQualityContent + * @phpstan-import-type FaceDetectionShape from \ModerationAPI\Content\ContentSubmitParams\Policy\FaceDetection * @phpstan-import-type SelfPromotionShape from \ModerationAPI\Content\ContentSubmitParams\Policy\SelfPromotion * @phpstan-import-type PoliticalShape from \ModerationAPI\Content\ContentSubmitParams\Policy\Political * @phpstan-import-type ReligionShape from \ModerationAPI\Content\ContentSubmitParams\Policy\Religion @@ -66,8 +68,8 @@ * @phpstan-import-type URLRiskShape from \ModerationAPI\Content\ContentSubmitParams\Policy\URLRisk * @phpstan-import-type GuidelineShape from \ModerationAPI\Content\ContentSubmitParams\Policy\Guideline * - * @phpstan-type PolicyVariants = Toxicity|PersonalInformation|ToxicitySevere|Hate|Illicit|IllicitDrugs|IllicitAlcohol|IllicitFirearms|IllicitTobacco|IllicitGambling|Cannabis|Adult|Crypto|Sexual|Flirtation|Profanity|Violence|SelfHarm|Spam|LowQualityContent|SelfPromotion|Political|Religion|CodeAbuse|PiiMasking|URLMasking|URLRisk|Guideline - * @phpstan-type PolicyShape = PolicyVariants|ToxicityShape|PersonalInformationShape|ToxicitySevereShape|HateShape|IllicitShape|IllicitDrugsShape|IllicitAlcoholShape|IllicitFirearmsShape|IllicitTobaccoShape|IllicitGamblingShape|CannabisShape|AdultShape|CryptoShape|SexualShape|FlirtationShape|ProfanityShape|ViolenceShape|SelfHarmShape|SpamShape|LowQualityContentShape|SelfPromotionShape|PoliticalShape|ReligionShape|CodeAbuseShape|PiiMaskingShape|URLMaskingShape|URLRiskShape|GuidelineShape + * @phpstan-type PolicyVariants = Toxicity|PersonalInformation|ToxicitySevere|Hate|Illicit|IllicitDrugs|IllicitAlcohol|IllicitFirearms|IllicitTobacco|IllicitGambling|Cannabis|Adult|Crypto|Sexual|Flirtation|Profanity|Violence|SelfHarm|Spam|LowQualityContent|FaceDetection|SelfPromotion|Political|Religion|CodeAbuse|PiiMasking|URLMasking|URLRisk|Guideline + * @phpstan-type PolicyShape = PolicyVariants|ToxicityShape|PersonalInformationShape|ToxicitySevereShape|HateShape|IllicitShape|IllicitDrugsShape|IllicitAlcoholShape|IllicitFirearmsShape|IllicitTobaccoShape|IllicitGamblingShape|CannabisShape|AdultShape|CryptoShape|SexualShape|FlirtationShape|ProfanityShape|ViolenceShape|SelfHarmShape|SpamShape|LowQualityContentShape|FaceDetectionShape|SelfPromotionShape|PoliticalShape|ReligionShape|CodeAbuseShape|PiiMaskingShape|URLMaskingShape|URLRiskShape|GuidelineShape */ final class Policy implements ConverterSource { @@ -99,6 +101,7 @@ public static function variants(): array SelfHarm::class, Spam::class, LowQualityContent::class, + FaceDetection::class, SelfPromotion::class, Political::class, Religion::class, diff --git a/src/Content/ContentSubmitParams/Policy/FaceDetection.php b/src/Content/ContentSubmitParams/Policy/FaceDetection.php new file mode 100644 index 0000000..7392c27 --- /dev/null +++ b/src/Content/ContentSubmitParams/Policy/FaceDetection.php @@ -0,0 +1,144 @@ +, + * count?: int|null, + * threshold?: float|null, + * } + */ +final class FaceDetection implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var 'face_detection' $id */ + #[Required] + public string $id = 'face_detection'; + + #[Required] + public bool $flag; + + /** + * Flag images that contain "at least" or "fewer than" the configured number of faces. Defaults to at_least. + * + * @var value-of|null $comparator + */ + #[Optional(enum: Comparator::class)] + public ?string $comparator; + + /** + * Number of faces the comparator applies to. Defaults to 1, so the default rule flags any image containing a face. + */ + #[Optional] + public ?int $count; + + #[Optional] + public ?float $threshold; + + /** + * `new FaceDetection()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FaceDetection::with(flag: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FaceDetection)->withFlag(...) + * ``` + */ + 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 Comparator|value-of|null $comparator + */ + public static function with( + bool $flag, + Comparator|string|null $comparator = null, + ?int $count = null, + ?float $threshold = null, + ): self { + $self = new self; + + $self['flag'] = $flag; + + null !== $comparator && $self['comparator'] = $comparator; + null !== $count && $self['count'] = $count; + null !== $threshold && $self['threshold'] = $threshold; + + return $self; + } + + /** + * @param 'face_detection' $id + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + public function withFlag(bool $flag): self + { + $self = clone $this; + $self['flag'] = $flag; + + return $self; + } + + /** + * Flag images that contain "at least" or "fewer than" the configured number of faces. Defaults to at_least. + * + * @param Comparator|value-of $comparator + */ + public function withComparator(Comparator|string $comparator): self + { + $self = clone $this; + $self['comparator'] = $comparator; + + return $self; + } + + /** + * Number of faces the comparator applies to. Defaults to 1, so the default rule flags any image containing a face. + */ + public function withCount(int $count): self + { + $self = clone $this; + $self['count'] = $count; + + return $self; + } + + public function withThreshold(float $threshold): self + { + $self = clone $this; + $self['threshold'] = $threshold; + + return $self; + } +} diff --git a/src/Content/ContentSubmitParams/Policy/FaceDetection/Comparator.php b/src/Content/ContentSubmitParams/Policy/FaceDetection/Comparator.php new file mode 100644 index 0000000..a179c73 --- /dev/null +++ b/src/Content/ContentSubmitParams/Policy/FaceDetection/Comparator.php @@ -0,0 +1,15 @@ +|null, * flaggedFields?: list|null, * labels?: list|null, * } @@ -45,6 +46,14 @@ final class ClassifierOutput implements BaseModel #[Required] public float $probability; + /** + * Optional structured data produced by the policy. For face detection: { count, faces: [{ confidence, gender, age }] }. + * + * @var array|null $data + */ + #[Optional(map: 'mixed')] + public ?array $data; + /** * The keys of the flagged fields if submitting an object. * @@ -81,6 +90,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param array|null $data * @param list|null $flaggedFields * @param list|null $labels */ @@ -88,6 +98,7 @@ public static function with( string $id, bool $flagged, float $probability, + ?array $data = null, ?array $flaggedFields = null, ?array $labels = null, ): self { @@ -97,6 +108,7 @@ public static function with( $self['flagged'] = $flagged; $self['probability'] = $probability; + null !== $data && $self['data'] = $data; null !== $flaggedFields && $self['flaggedFields'] = $flaggedFields; null !== $labels && $self['labels'] = $labels; @@ -141,6 +153,19 @@ public function withType(string $type): self return $self; } + /** + * Optional structured data produced by the policy. For face detection: { count, faces: [{ confidence, gender, age }] }. + * + * @param array $data + */ + public function withData(array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } + /** * The keys of the flagged fields if submitting an object. * From b1d509ad89281c65b577e3418e5ba4738e72fc5b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Jun 2026 02:24:25 +0000 Subject: [PATCH 2/2] release: 0.20.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ README.md | 2 +- src/Version.php | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e756293..0c2ecec 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.19.0" + ".": "0.20.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 97e8a37..5ac8d31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.20.0 (2026-06-02) + +Full Changelog: [v0.19.0...v0.20.0](https://github.com/moderation-api/sdk-php/compare/v0.19.0...v0.20.0) + +### Features + +* **api:** api update ([247b4cf](https://github.com/moderation-api/sdk-php/commit/247b4cf8bace8c77249b90de09e3eccfa7692e2e)) + ## 0.19.0 (2026-06-01) Full Changelog: [v0.18.0...v0.19.0](https://github.com/moderation-api/sdk-php/compare/v0.18.0...v0.19.0) diff --git a/README.md b/README.md index b8da17e..026d373 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The REST API documentation can be found on [docs.moderationapi.com](https://docs ``` -composer require "moderation-api/sdk-php 0.19.0" +composer require "moderation-api/sdk-php 0.20.0" ``` diff --git a/src/Version.php b/src/Version.php index 6909427..f7c8eea 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace ModerationAPI; // x-release-please-start-version -const VERSION = '0.19.0'; +const VERSION = '0.20.0'; // x-release-please-end