From b376b1d8336566576a93cd16c54186ef22f62bb5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Jun 2026 08:24:48 +0000 Subject: [PATCH 1/2] feat(api): api update --- .stats.yml | 4 +- src/Content/ContentSubmitParams.php | 25 +++ .../ContentSubmitParams/ClientAction.php | 148 ++++++++++++++++++ .../ClientAction/Action.php | 17 ++ .../ClientAction/Behavior.php | 15 ++ .../Recommendation/ReasonCode.php | 2 + .../Data/Object_/Item.php | 28 ++++ .../Data/Object_/Item/ClientAction.php | 148 ++++++++++++++++++ .../Data/Object_/Item/ClientAction/Action.php | 17 ++ .../Object_/Item/ClientAction/Behavior.php | 15 ++ .../Data/Object_/Item.php | 28 ++++ .../Data/Object_/Item/ClientAction.php | 148 ++++++++++++++++++ .../Data/Object_/Item/ClientAction/Action.php | 17 ++ .../Object_/Item/ClientAction/Behavior.php | 15 ++ .../Data/Object_/Item.php | 28 ++++ .../Data/Object_/Item/ClientAction.php | 148 ++++++++++++++++++ .../Data/Object_/Item/ClientAction/Action.php | 17 ++ .../Object_/Item/ClientAction/Behavior.php | 15 ++ .../Data/Object_/Item.php | 28 ++++ .../Data/Object_/Item/ClientAction.php | 148 ++++++++++++++++++ .../Data/Object_/Item/ClientAction/Action.php | 17 ++ .../Object_/Item/ClientAction/Behavior.php | 15 ++ src/ServiceContracts/ContentContract.php | 4 + src/Services/ContentRawService.php | 3 + src/Services/ContentService.php | 5 + tests/Services/ContentTest.php | 6 + 26 files changed, 1059 insertions(+), 2 deletions(-) create mode 100644 src/Content/ContentSubmitParams/ClientAction.php create mode 100644 src/Content/ContentSubmitParams/ClientAction/Action.php create mode 100644 src/Content/ContentSubmitParams/ClientAction/Behavior.php create mode 100644 src/Queue/WebhookEvent/QueueItemActionEvent/Data/Object_/Item/ClientAction.php create mode 100644 src/Queue/WebhookEvent/QueueItemActionEvent/Data/Object_/Item/ClientAction/Action.php create mode 100644 src/Queue/WebhookEvent/QueueItemActionEvent/Data/Object_/Item/ClientAction/Behavior.php create mode 100644 src/Queue/WebhookEvent/QueueItemAllowedEvent/Data/Object_/Item/ClientAction.php create mode 100644 src/Queue/WebhookEvent/QueueItemAllowedEvent/Data/Object_/Item/ClientAction/Action.php create mode 100644 src/Queue/WebhookEvent/QueueItemAllowedEvent/Data/Object_/Item/ClientAction/Behavior.php create mode 100644 src/Queue/WebhookEvent/QueueItemCompletedEvent/Data/Object_/Item/ClientAction.php create mode 100644 src/Queue/WebhookEvent/QueueItemCompletedEvent/Data/Object_/Item/ClientAction/Action.php create mode 100644 src/Queue/WebhookEvent/QueueItemCompletedEvent/Data/Object_/Item/ClientAction/Behavior.php create mode 100644 src/Queue/WebhookEvent/QueueItemRejectedEvent/Data/Object_/Item/ClientAction.php create mode 100644 src/Queue/WebhookEvent/QueueItemRejectedEvent/Data/Object_/Item/ClientAction/Action.php create mode 100644 src/Queue/WebhookEvent/QueueItemRejectedEvent/Data/Object_/Item/ClientAction/Behavior.php diff --git a/.stats.yml b/.stats.yml index b80b97b..6265db3 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-cbf656f40e43acf60d9596f78204f031dc8c7205626df8f05ce8e88bcf49b597.yml -openapi_spec_hash: 23be5a56248a1a575b34833eb7e7fe49 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-9c5291067ec36cba0c9ef772c5c8eb10238fb332f1f25d0e31f3f2ad87c24e5e.yml +openapi_spec_hash: 790cc0a36d6ed693c06a285c441ab977 config_hash: 9d144cc6c49d3fd53e5b4472c1e22165 diff --git a/src/Content/ContentSubmitParams.php b/src/Content/ContentSubmitParams.php index 58dccb5..d2502bc 100644 --- a/src/Content/ContentSubmitParams.php +++ b/src/Content/ContentSubmitParams.php @@ -4,6 +4,7 @@ namespace ModerationAPI\Content; +use ModerationAPI\Content\ContentSubmitParams\ClientAction; use ModerationAPI\Content\ContentSubmitParams\Content\Audio; use ModerationAPI\Content\ContentSubmitParams\Content\Image; use ModerationAPI\Content\ContentSubmitParams\Content\Object_; @@ -23,12 +24,14 @@ * @phpstan-import-type ContentVariants from \ModerationAPI\Content\ContentSubmitParams\Content * @phpstan-import-type PolicyVariants from \ModerationAPI\Content\ContentSubmitParams\Policy * @phpstan-import-type ContentShape from \ModerationAPI\Content\ContentSubmitParams\Content + * @phpstan-import-type ClientActionShape from \ModerationAPI\Content\ContentSubmitParams\ClientAction * @phpstan-import-type PolicyShape from \ModerationAPI\Content\ContentSubmitParams\Policy * * @phpstan-type ContentSubmitParamsShape = array{ * content: ContentShape, * authorID?: string|null, * channel?: string|null, + * clientAction?: null|ClientAction|ClientActionShape, * contentID?: string|null, * conversationID?: string|null, * doNotStore?: bool|null, @@ -64,6 +67,12 @@ final class ContentSubmitParams implements BaseModel #[Optional] public ?string $channel; + /** + * A recommendation from your own client-side flagging (e.g. a banned-IP list or a third-party tool). Feeds the rules engine and can escalate or override the recommended action. Does not change whether our analysis flagged the content. + */ + #[Optional] + public ?ClientAction $clientAction; + /** * The unique ID of the content in your database. */ @@ -137,6 +146,7 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param ContentShape $content + * @param ClientAction|ClientActionShape|null $clientAction * @param array|null $metadata * @param MetaType|value-of|null $metaType * @param list|null $policies @@ -145,6 +155,7 @@ public static function with( Text|array|Image|Video|Audio|Object_ $content, ?string $authorID = null, ?string $channel = null, + ClientAction|array|null $clientAction = null, ?string $contentID = null, ?string $conversationID = null, ?bool $doNotStore = null, @@ -159,6 +170,7 @@ public static function with( null !== $authorID && $self['authorID'] = $authorID; null !== $channel && $self['channel'] = $channel; + null !== $clientAction && $self['clientAction'] = $clientAction; null !== $contentID && $self['contentID'] = $contentID; null !== $conversationID && $self['conversationID'] = $conversationID; null !== $doNotStore && $self['doNotStore'] = $doNotStore; @@ -206,6 +218,19 @@ public function withChannel(string $channel): self return $self; } + /** + * A recommendation from your own client-side flagging (e.g. a banned-IP list or a third-party tool). Feeds the rules engine and can escalate or override the recommended action. Does not change whether our analysis flagged the content. + * + * @param ClientAction|ClientActionShape $clientAction + */ + public function withClientAction(ClientAction|array $clientAction): self + { + $self = clone $this; + $self['clientAction'] = $clientAction; + + return $self; + } + /** * The unique ID of the content in your database. */ diff --git a/src/Content/ContentSubmitParams/ClientAction.php b/src/Content/ContentSubmitParams/ClientAction.php new file mode 100644 index 0000000..af16ddc --- /dev/null +++ b/src/Content/ContentSubmitParams/ClientAction.php @@ -0,0 +1,148 @@ +, + * behavior?: null|Behavior|value-of, + * reason?: string|null, + * source?: string|null, + * } + */ +final class ClientAction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @var value-of $action + */ + #[Required(enum: Action::class)] + public string $action; + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @var value-of|null $behavior + */ + #[Optional(enum: Behavior::class)] + public ?string $behavior; + + /** + * A human-readable explanation for your recommendation. + */ + #[Optional] + public ?string $reason; + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + #[Optional] + public ?string $source; + + /** + * `new ClientAction()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ClientAction::with(action: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ClientAction)->withAction(...) + * ``` + */ + 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 Action|value-of $action + * @param Behavior|value-of|null $behavior + */ + public static function with( + Action|string $action, + Behavior|string|null $behavior = null, + ?string $reason = null, + ?string $source = null, + ): self { + $self = new self; + + $self['action'] = $action; + + null !== $behavior && $self['behavior'] = $behavior; + null !== $reason && $self['reason'] = $reason; + null !== $source && $self['source'] = $source; + + return $self; + } + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @param Action|value-of $action + */ + public function withAction(Action|string $action): self + { + $self = clone $this; + $self['action'] = $action; + + return $self; + } + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @param Behavior|value-of $behavior + */ + public function withBehavior(Behavior|string $behavior): self + { + $self = clone $this; + $self['behavior'] = $behavior; + + return $self; + } + + /** + * A human-readable explanation for your recommendation. + */ + public function withReason(string $reason): self + { + $self = clone $this; + $self['reason'] = $reason; + + return $self; + } + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + public function withSource(string $source): self + { + $self = clone $this; + $self['source'] = $source; + + return $self; + } +} diff --git a/src/Content/ContentSubmitParams/ClientAction/Action.php b/src/Content/ContentSubmitParams/ClientAction/Action.php new file mode 100644 index 0000000..f850730 --- /dev/null +++ b/src/Content/ContentSubmitParams/ClientAction/Action.php @@ -0,0 +1,17 @@ +withID(...) * ->withAuthorID(...) * ->withChannelKey(...) + * ->withClientAction(...) * ->withContent(...) * ->withConversationID(...) * ->withFlagged(...) @@ -162,6 +173,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param ClientAction|ClientActionShape|null $clientAction * @param ContentShape $content * @param list|null $labels * @param MetaType|value-of|null $metaType @@ -171,6 +183,7 @@ public static function with( string $id, ?string $authorID, ?string $channelKey, + ClientAction|array|null $clientAction, Text|array|Image|Video|Audio|Object_ $content, ?string $conversationID, ?bool $flagged, @@ -185,6 +198,7 @@ public static function with( $self['id'] = $id; $self['authorID'] = $authorID; $self['channelKey'] = $channelKey; + $self['clientAction'] = $clientAction; $self['content'] = $content; $self['conversationID'] = $conversationID; $self['flagged'] = $flagged; @@ -230,6 +244,20 @@ public function withChannelKey(?string $channelKey): self return $self; } + /** + * A recommendation from your own client-side flagging. + * + * @param ClientAction|ClientActionShape|null $clientAction + */ + public function withClientAction( + ClientAction|array|null $clientAction + ): self { + $self = clone $this; + $self['clientAction'] = $clientAction; + + return $self; + } + /** * The original content payload. * diff --git a/src/Queue/WebhookEvent/QueueItemActionEvent/Data/Object_/Item/ClientAction.php b/src/Queue/WebhookEvent/QueueItemActionEvent/Data/Object_/Item/ClientAction.php new file mode 100644 index 0000000..fe2e671 --- /dev/null +++ b/src/Queue/WebhookEvent/QueueItemActionEvent/Data/Object_/Item/ClientAction.php @@ -0,0 +1,148 @@ +, + * behavior?: null|Behavior|value-of, + * reason?: string|null, + * source?: string|null, + * } + */ +final class ClientAction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @var value-of $action + */ + #[Required(enum: Action::class)] + public string $action; + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @var value-of|null $behavior + */ + #[Optional(enum: Behavior::class)] + public ?string $behavior; + + /** + * A human-readable explanation for your recommendation. + */ + #[Optional] + public ?string $reason; + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + #[Optional] + public ?string $source; + + /** + * `new ClientAction()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ClientAction::with(action: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ClientAction)->withAction(...) + * ``` + */ + 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 Action|value-of $action + * @param Behavior|value-of|null $behavior + */ + public static function with( + Action|string $action, + Behavior|string|null $behavior = null, + ?string $reason = null, + ?string $source = null, + ): self { + $self = new self; + + $self['action'] = $action; + + null !== $behavior && $self['behavior'] = $behavior; + null !== $reason && $self['reason'] = $reason; + null !== $source && $self['source'] = $source; + + return $self; + } + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @param Action|value-of $action + */ + public function withAction(Action|string $action): self + { + $self = clone $this; + $self['action'] = $action; + + return $self; + } + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @param Behavior|value-of $behavior + */ + public function withBehavior(Behavior|string $behavior): self + { + $self = clone $this; + $self['behavior'] = $behavior; + + return $self; + } + + /** + * A human-readable explanation for your recommendation. + */ + public function withReason(string $reason): self + { + $self = clone $this; + $self['reason'] = $reason; + + return $self; + } + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + public function withSource(string $source): self + { + $self = clone $this; + $self['source'] = $source; + + return $self; + } +} diff --git a/src/Queue/WebhookEvent/QueueItemActionEvent/Data/Object_/Item/ClientAction/Action.php b/src/Queue/WebhookEvent/QueueItemActionEvent/Data/Object_/Item/ClientAction/Action.php new file mode 100644 index 0000000..4298988 --- /dev/null +++ b/src/Queue/WebhookEvent/QueueItemActionEvent/Data/Object_/Item/ClientAction/Action.php @@ -0,0 +1,17 @@ +withID(...) * ->withAuthorID(...) * ->withChannelKey(...) + * ->withClientAction(...) * ->withContent(...) * ->withConversationID(...) * ->withFlagged(...) @@ -162,6 +173,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param ClientAction|ClientActionShape|null $clientAction * @param ContentShape $content * @param list|null $labels * @param MetaType|value-of|null $metaType @@ -171,6 +183,7 @@ public static function with( string $id, ?string $authorID, ?string $channelKey, + ClientAction|array|null $clientAction, Text|array|Image|Video|Audio|Object_ $content, ?string $conversationID, ?bool $flagged, @@ -185,6 +198,7 @@ public static function with( $self['id'] = $id; $self['authorID'] = $authorID; $self['channelKey'] = $channelKey; + $self['clientAction'] = $clientAction; $self['content'] = $content; $self['conversationID'] = $conversationID; $self['flagged'] = $flagged; @@ -230,6 +244,20 @@ public function withChannelKey(?string $channelKey): self return $self; } + /** + * A recommendation from your own client-side flagging. + * + * @param ClientAction|ClientActionShape|null $clientAction + */ + public function withClientAction( + ClientAction|array|null $clientAction + ): self { + $self = clone $this; + $self['clientAction'] = $clientAction; + + return $self; + } + /** * The original content payload. * diff --git a/src/Queue/WebhookEvent/QueueItemAllowedEvent/Data/Object_/Item/ClientAction.php b/src/Queue/WebhookEvent/QueueItemAllowedEvent/Data/Object_/Item/ClientAction.php new file mode 100644 index 0000000..316e9ab --- /dev/null +++ b/src/Queue/WebhookEvent/QueueItemAllowedEvent/Data/Object_/Item/ClientAction.php @@ -0,0 +1,148 @@ +, + * behavior?: null|Behavior|value-of, + * reason?: string|null, + * source?: string|null, + * } + */ +final class ClientAction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @var value-of $action + */ + #[Required(enum: Action::class)] + public string $action; + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @var value-of|null $behavior + */ + #[Optional(enum: Behavior::class)] + public ?string $behavior; + + /** + * A human-readable explanation for your recommendation. + */ + #[Optional] + public ?string $reason; + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + #[Optional] + public ?string $source; + + /** + * `new ClientAction()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ClientAction::with(action: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ClientAction)->withAction(...) + * ``` + */ + 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 Action|value-of $action + * @param Behavior|value-of|null $behavior + */ + public static function with( + Action|string $action, + Behavior|string|null $behavior = null, + ?string $reason = null, + ?string $source = null, + ): self { + $self = new self; + + $self['action'] = $action; + + null !== $behavior && $self['behavior'] = $behavior; + null !== $reason && $self['reason'] = $reason; + null !== $source && $self['source'] = $source; + + return $self; + } + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @param Action|value-of $action + */ + public function withAction(Action|string $action): self + { + $self = clone $this; + $self['action'] = $action; + + return $self; + } + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @param Behavior|value-of $behavior + */ + public function withBehavior(Behavior|string $behavior): self + { + $self = clone $this; + $self['behavior'] = $behavior; + + return $self; + } + + /** + * A human-readable explanation for your recommendation. + */ + public function withReason(string $reason): self + { + $self = clone $this; + $self['reason'] = $reason; + + return $self; + } + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + public function withSource(string $source): self + { + $self = clone $this; + $self['source'] = $source; + + return $self; + } +} diff --git a/src/Queue/WebhookEvent/QueueItemAllowedEvent/Data/Object_/Item/ClientAction/Action.php b/src/Queue/WebhookEvent/QueueItemAllowedEvent/Data/Object_/Item/ClientAction/Action.php new file mode 100644 index 0000000..0a7844e --- /dev/null +++ b/src/Queue/WebhookEvent/QueueItemAllowedEvent/Data/Object_/Item/ClientAction/Action.php @@ -0,0 +1,17 @@ +withID(...) * ->withAuthorID(...) * ->withChannelKey(...) + * ->withClientAction(...) * ->withContent(...) * ->withConversationID(...) * ->withFlagged(...) @@ -160,6 +171,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param ClientAction|ClientActionShape|null $clientAction * @param ContentShape $content * @param list|null $labels * @param MetaType|value-of|null $metaType @@ -169,6 +181,7 @@ public static function with( string $id, ?string $authorID, ?string $channelKey, + ClientAction|array|null $clientAction, Text|array|Image|Video|Audio|Object_ $content, ?string $conversationID, ?bool $flagged, @@ -183,6 +196,7 @@ public static function with( $self['id'] = $id; $self['authorID'] = $authorID; $self['channelKey'] = $channelKey; + $self['clientAction'] = $clientAction; $self['content'] = $content; $self['conversationID'] = $conversationID; $self['flagged'] = $flagged; @@ -228,6 +242,20 @@ public function withChannelKey(?string $channelKey): self return $self; } + /** + * A recommendation from your own client-side flagging. + * + * @param ClientAction|ClientActionShape|null $clientAction + */ + public function withClientAction( + ClientAction|array|null $clientAction + ): self { + $self = clone $this; + $self['clientAction'] = $clientAction; + + return $self; + } + /** * The original content payload. * diff --git a/src/Queue/WebhookEvent/QueueItemCompletedEvent/Data/Object_/Item/ClientAction.php b/src/Queue/WebhookEvent/QueueItemCompletedEvent/Data/Object_/Item/ClientAction.php new file mode 100644 index 0000000..db656de --- /dev/null +++ b/src/Queue/WebhookEvent/QueueItemCompletedEvent/Data/Object_/Item/ClientAction.php @@ -0,0 +1,148 @@ +, + * behavior?: null|Behavior|value-of, + * reason?: string|null, + * source?: string|null, + * } + */ +final class ClientAction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @var value-of $action + */ + #[Required(enum: Action::class)] + public string $action; + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @var value-of|null $behavior + */ + #[Optional(enum: Behavior::class)] + public ?string $behavior; + + /** + * A human-readable explanation for your recommendation. + */ + #[Optional] + public ?string $reason; + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + #[Optional] + public ?string $source; + + /** + * `new ClientAction()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ClientAction::with(action: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ClientAction)->withAction(...) + * ``` + */ + 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 Action|value-of $action + * @param Behavior|value-of|null $behavior + */ + public static function with( + Action|string $action, + Behavior|string|null $behavior = null, + ?string $reason = null, + ?string $source = null, + ): self { + $self = new self; + + $self['action'] = $action; + + null !== $behavior && $self['behavior'] = $behavior; + null !== $reason && $self['reason'] = $reason; + null !== $source && $self['source'] = $source; + + return $self; + } + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @param Action|value-of $action + */ + public function withAction(Action|string $action): self + { + $self = clone $this; + $self['action'] = $action; + + return $self; + } + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @param Behavior|value-of $behavior + */ + public function withBehavior(Behavior|string $behavior): self + { + $self = clone $this; + $self['behavior'] = $behavior; + + return $self; + } + + /** + * A human-readable explanation for your recommendation. + */ + public function withReason(string $reason): self + { + $self = clone $this; + $self['reason'] = $reason; + + return $self; + } + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + public function withSource(string $source): self + { + $self = clone $this; + $self['source'] = $source; + + return $self; + } +} diff --git a/src/Queue/WebhookEvent/QueueItemCompletedEvent/Data/Object_/Item/ClientAction/Action.php b/src/Queue/WebhookEvent/QueueItemCompletedEvent/Data/Object_/Item/ClientAction/Action.php new file mode 100644 index 0000000..2e64ef1 --- /dev/null +++ b/src/Queue/WebhookEvent/QueueItemCompletedEvent/Data/Object_/Item/ClientAction/Action.php @@ -0,0 +1,17 @@ +withID(...) * ->withAuthorID(...) * ->withChannelKey(...) + * ->withClientAction(...) * ->withContent(...) * ->withConversationID(...) * ->withFlagged(...) @@ -162,6 +173,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * + * @param ClientAction|ClientActionShape|null $clientAction * @param ContentShape $content * @param list|null $labels * @param MetaType|value-of|null $metaType @@ -171,6 +183,7 @@ public static function with( string $id, ?string $authorID, ?string $channelKey, + ClientAction|array|null $clientAction, Text|array|Image|Video|Audio|Object_ $content, ?string $conversationID, ?bool $flagged, @@ -185,6 +198,7 @@ public static function with( $self['id'] = $id; $self['authorID'] = $authorID; $self['channelKey'] = $channelKey; + $self['clientAction'] = $clientAction; $self['content'] = $content; $self['conversationID'] = $conversationID; $self['flagged'] = $flagged; @@ -230,6 +244,20 @@ public function withChannelKey(?string $channelKey): self return $self; } + /** + * A recommendation from your own client-side flagging. + * + * @param ClientAction|ClientActionShape|null $clientAction + */ + public function withClientAction( + ClientAction|array|null $clientAction + ): self { + $self = clone $this; + $self['clientAction'] = $clientAction; + + return $self; + } + /** * The original content payload. * diff --git a/src/Queue/WebhookEvent/QueueItemRejectedEvent/Data/Object_/Item/ClientAction.php b/src/Queue/WebhookEvent/QueueItemRejectedEvent/Data/Object_/Item/ClientAction.php new file mode 100644 index 0000000..87a1c7a --- /dev/null +++ b/src/Queue/WebhookEvent/QueueItemRejectedEvent/Data/Object_/Item/ClientAction.php @@ -0,0 +1,148 @@ +, + * behavior?: null|Behavior|value-of, + * reason?: string|null, + * source?: string|null, + * } + */ +final class ClientAction implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @var value-of $action + */ + #[Required(enum: Action::class)] + public string $action; + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @var value-of|null $behavior + */ + #[Optional(enum: Behavior::class)] + public ?string $behavior; + + /** + * A human-readable explanation for your recommendation. + */ + #[Optional] + public ?string $reason; + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + #[Optional] + public ?string $source; + + /** + * `new ClientAction()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ClientAction::with(action: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ClientAction)->withAction(...) + * ``` + */ + 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 Action|value-of $action + * @param Behavior|value-of|null $behavior + */ + public static function with( + Action|string $action, + Behavior|string|null $behavior = null, + ?string $reason = null, + ?string $source = null, + ): self { + $self = new self; + + $self['action'] = $action; + + null !== $behavior && $self['behavior'] = $behavior; + null !== $reason && $self['reason'] = $reason; + null !== $source && $self['source'] = $source; + + return $self; + } + + /** + * Your recommendation for the content: allow, review, or reject. + * + * @param Action|value-of $action + */ + public function withAction(Action|string $action): self + { + $self = clone $this; + $self['action'] = $action; + + return $self; + } + + /** + * How your recommendation combines with ours. Defaults to 'escalate', which only applies it when stricter than ours; 'override' replaces ours outright. + * + * @param Behavior|value-of $behavior + */ + public function withBehavior(Behavior|string $behavior): self + { + $self = clone $this; + $self['behavior'] = $behavior; + + return $self; + } + + /** + * A human-readable explanation for your recommendation. + */ + public function withReason(string $reason): self + { + $self = clone $this; + $self['reason'] = $reason; + + return $self; + } + + /** + * Where your recommendation came from, e.g. "banned-ip". + */ + public function withSource(string $source): self + { + $self = clone $this; + $self['source'] = $source; + + return $self; + } +} diff --git a/src/Queue/WebhookEvent/QueueItemRejectedEvent/Data/Object_/Item/ClientAction/Action.php b/src/Queue/WebhookEvent/QueueItemRejectedEvent/Data/Object_/Item/ClientAction/Action.php new file mode 100644 index 0000000..b8a316a --- /dev/null +++ b/src/Queue/WebhookEvent/QueueItemRejectedEvent/Data/Object_/Item/ClientAction/Action.php @@ -0,0 +1,17 @@ + $content, 'authorID' => $authorID, 'channel' => $channel, + 'clientAction' => $clientAction, 'contentID' => $contentID, 'conversationID' => $conversationID, 'doNotStore' => $doNotStore, diff --git a/tests/Services/ContentTest.php b/tests/Services/ContentTest.php index 542a67e..96386d8 100644 --- a/tests/Services/ContentTest.php +++ b/tests/Services/ContentTest.php @@ -54,6 +54,12 @@ public function testSubmitWithOptionalParams(): void content: ['text' => 'text', 'type' => 'text'], authorID: 'authorId', channel: 'channel', + clientAction: [ + 'action' => 'review', + 'behavior' => 'override', + 'reason' => 'reason', + 'source' => 'source', + ], contentID: 'contentId', conversationID: 'conversationId', doNotStore: true, From 1e5659df858e70b247c7780509851ed52a81b56a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Jun 2026 08:25:10 +0000 Subject: [PATCH 2/2] release: 0.21.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 0c2ecec..86b0e83 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.20.0" + ".": "0.21.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ac8d31..2c639db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.21.0 (2026-06-02) + +Full Changelog: [v0.20.0...v0.21.0](https://github.com/moderation-api/sdk-php/compare/v0.20.0...v0.21.0) + +### Features + +* **api:** api update ([b376b1d](https://github.com/moderation-api/sdk-php/commit/b376b1d8336566576a93cd16c54186ef22f62bb5)) + ## 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) diff --git a/README.md b/README.md index 026d373..2f42b62 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.20.0" +composer require "moderation-api/sdk-php 0.21.0" ``` diff --git a/src/Version.php b/src/Version.php index f7c8eea..e3755cc 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace ModerationAPI; // x-release-please-start-version -const VERSION = '0.20.0'; +const VERSION = '0.21.0'; // x-release-please-end