diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 10f3091..6b7b74c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0" + ".": "0.3.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e8d960..633c83e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## 0.3.0 (2025-12-10) + +Full Changelog: [v0.2.0...v0.3.0](https://github.com/moderation-api/sdk-php/compare/v0.2.0...v0.3.0) + +### ⚠ BREAKING CHANGES + +* use camel casing for all class properties + +### Features + +* add `BaseResponse` class for accessing raw responses ([b70b4c9](https://github.com/moderation-api/sdk-php/commit/b70b4c941e71381dffd8332bbf3331e6e4482ee1)) +* split out services into normal & raw types ([a7e26e6](https://github.com/moderation-api/sdk-php/commit/a7e26e6953f26a9b72075bee096f32fc8ddc1ba5)) +* use camel casing for all class properties ([fc81f4b](https://github.com/moderation-api/sdk-php/commit/fc81f4b7f1afde496947d52394e3c2b50be9478f)) + + +### Chores + +* ensure constant values are marked as optional in array types ([50679be](https://github.com/moderation-api/sdk-php/commit/50679be728b3629ebc80582aa18deb111280927a)) +* switch from `#[Api(optional: true|false)]` to `#[Required]|#[Optional]` for annotations ([0b40eda](https://github.com/moderation-api/sdk-php/commit/0b40edaeadad1f12f6066b520829c057a05927f3)) +* use `$self = clone $this;` instead of `$obj = clone $this;` ([a8db5b6](https://github.com/moderation-api/sdk-php/commit/a8db5b63c804ddb837662907da5ed6efa0f921fd)) + ## 0.2.0 (2025-12-06) Full Changelog: [v0.1.1...v0.2.0](https://github.com/moderation-api/sdk-php/compare/v0.1.1...v0.2.0) diff --git a/README.md b/README.md index a37a2d9..a137286 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ The REST API documentation can be found on [docs.moderationapi.com](https://docs ``` -composer require "moderation-api/sdk-php 0.2.0" +composer require "moderation-api/sdk-php 0.3.0" ``` @@ -35,9 +35,9 @@ use ModerationAPI\Client; $client = new Client(secretKey: getenv('MODAPI_SECRET_KEY') ?: 'My Secret Key'); -$response = $client->content->submit([ - 'content' => ['text' => 'x', 'type' => 'text'] -]); +$response = $client->content->submit( + content: ['text' => 'x', 'type' => 'text'] +); var_dump($response->recommendation); ``` @@ -59,13 +59,13 @@ When the library is unable to connect to the API, or if the API returns a non-su use ModerationAPI\Core\Exceptions\APIConnectionException; try { - $response = $client->content->submit([ - 'content' => ['text' => 'x', 'type' => 'text'] - ]); + $response = $client->content->submit( + content: ['text' => 'x', 'type' => 'text'] + ); } catch (APIConnectionException $e) { echo "The server could not be reached", PHP_EOL; var_dump($e->getPrevious()); -} catch (RateLimitError $_) { +} catch (RateLimitError $e) { echo "A 429 status code was received; we should back off a bit.", PHP_EOL; } catch (APIStatusError $e) { echo "Another non-200-range status code was received", PHP_EOL; @@ -108,8 +108,8 @@ $client = new Client(maxRetries: 0); // Or, configure per-request: $result = $client->content->submit( - ['content' => ['text' => 'x', 'type' => 'text']], - RequestOptions::with(maxRetries: 5), + content: ['text' => 'x', 'type' => 'text'], + requestOptions: RequestOptions::with(maxRetries: 5), ); ``` @@ -129,8 +129,8 @@ Note: the `extra*` parameters of the same name overrides the documented paramete use ModerationAPI\RequestOptions; $response = $client->content->submit( - ['content' => ['text' => 'x', 'type' => 'text']], - RequestOptions::with( + content: ['text' => 'x', 'type' => 'text'], + requestOptions: RequestOptions::with( extraQueryParams: ['my_query_parameter' => 'value'], extraBodyParams: ['my_body_parameter' => 'value'], extraHeaders: ['my-header' => 'value'], diff --git a/src/Account/AccountListResponse.php b/src/Account/AccountListResponse.php index 3374b77..6c93889 100644 --- a/src/Account/AccountListResponse.php +++ b/src/Account/AccountListResponse.php @@ -5,54 +5,51 @@ namespace ModerationAPI\Account; use ModerationAPI\Account\AccountListResponse\CurrentProject; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type AccountListResponseShape = array{ * id: string, - * paid_plan_name: string, - * remaining_quota: float, - * text_api_quota: float, - * current_project?: CurrentProject|null, + * paidPlanName: string, + * remainingQuota: float, + * textAPIQuota: float, + * currentProject?: CurrentProject|null, * } */ -final class AccountListResponse implements BaseModel, ResponseConverter +final class AccountListResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * ID of the account. */ - #[Api] + #[Required] public string $id; /** * Name of the paid plan. */ - #[Api] - public string $paid_plan_name; + #[Required('paid_plan_name')] + public string $paidPlanName; /** * Remaining quota. */ - #[Api] - public float $remaining_quota; + #[Required('remaining_quota')] + public float $remainingQuota; /** * Text API quota. */ - #[Api] - public float $text_api_quota; + #[Required('text_api_quota')] + public float $textAPIQuota; - #[Api(optional: true)] - public ?CurrentProject $current_project; + #[Optional('current_project')] + public ?CurrentProject $currentProject; /** * `new AccountListResponse()` is missing required properties by the API. @@ -60,7 +57,7 @@ final class AccountListResponse implements BaseModel, ResponseConverter * To enforce required parameters use * ``` * AccountListResponse::with( - * id: ..., paid_plan_name: ..., remaining_quota: ..., text_api_quota: ... + * id: ..., paidPlanName: ..., remainingQuota: ..., textAPIQuota: ... * ) * ``` * @@ -84,25 +81,25 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param CurrentProject|array{id: string, name: string} $current_project + * @param CurrentProject|array{id: string, name: string} $currentProject */ public static function with( string $id, - string $paid_plan_name, - float $remaining_quota, - float $text_api_quota, - CurrentProject|array|null $current_project = null, + string $paidPlanName, + float $remainingQuota, + float $textAPIQuota, + CurrentProject|array|null $currentProject = null, ): self { - $obj = new self; + $self = new self; - $obj['id'] = $id; - $obj['paid_plan_name'] = $paid_plan_name; - $obj['remaining_quota'] = $remaining_quota; - $obj['text_api_quota'] = $text_api_quota; + $self['id'] = $id; + $self['paidPlanName'] = $paidPlanName; + $self['remainingQuota'] = $remainingQuota; + $self['textAPIQuota'] = $textAPIQuota; - null !== $current_project && $obj['current_project'] = $current_project; + null !== $currentProject && $self['currentProject'] = $currentProject; - return $obj; + return $self; } /** @@ -110,10 +107,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -121,10 +118,10 @@ public function withID(string $id): self */ public function withPaidPlanName(string $paidPlanName): self { - $obj = clone $this; - $obj['paid_plan_name'] = $paidPlanName; + $self = clone $this; + $self['paidPlanName'] = $paidPlanName; - return $obj; + return $self; } /** @@ -132,10 +129,10 @@ public function withPaidPlanName(string $paidPlanName): self */ public function withRemainingQuota(float $remainingQuota): self { - $obj = clone $this; - $obj['remaining_quota'] = $remainingQuota; + $self = clone $this; + $self['remainingQuota'] = $remainingQuota; - return $obj; + return $self; } /** @@ -143,10 +140,10 @@ public function withRemainingQuota(float $remainingQuota): self */ public function withTextAPIQuota(float $textAPIQuota): self { - $obj = clone $this; - $obj['text_api_quota'] = $textAPIQuota; + $self = clone $this; + $self['textAPIQuota'] = $textAPIQuota; - return $obj; + return $self; } /** @@ -155,9 +152,9 @@ public function withTextAPIQuota(float $textAPIQuota): self public function withCurrentProject( CurrentProject|array $currentProject ): self { - $obj = clone $this; - $obj['current_project'] = $currentProject; + $self = clone $this; + $self['currentProject'] = $currentProject; - return $obj; + return $self; } } diff --git a/src/Account/AccountListResponse/CurrentProject.php b/src/Account/AccountListResponse/CurrentProject.php index fe034aa..c423c2e 100644 --- a/src/Account/AccountListResponse/CurrentProject.php +++ b/src/Account/AccountListResponse/CurrentProject.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Account\AccountListResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class CurrentProject implements BaseModel /** * ID of the current project. */ - #[Api] + #[Required] public string $id; /** * Name of the current project. */ - #[Api] + #[Required] public string $name; /** @@ -54,12 +54,12 @@ public function __construct() */ public static function with(string $id, string $name): self { - $obj = new self; + $self = new self; - $obj['id'] = $id; - $obj['name'] = $name; + $self['id'] = $id; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -67,10 +67,10 @@ public static function with(string $id, string $name): self */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -78,9 +78,9 @@ public function withID(string $id): self */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } } diff --git a/src/Actions/ActionCreateParams.php b/src/Actions/ActionCreateParams.php index 7f9b449..ac0edf9 100644 --- a/src/Actions/ActionCreateParams.php +++ b/src/Actions/ActionCreateParams.php @@ -9,7 +9,8 @@ use ModerationAPI\Actions\ActionCreateParams\QueueBehaviour; use ModerationAPI\Actions\ActionCreateParams\Type; use ModerationAPI\Actions\ActionCreateParams\Webhook; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Concerns\SdkParams; use ModerationAPI\Core\Contracts\BaseModel; @@ -23,7 +24,7 @@ * name: string, * builtIn?: bool|null, * description?: string|null, - * filterInQueueIds?: list, + * filterInQueueIDs?: list, * freeText?: bool, * key?: string|null, * position?: Position|value-of, @@ -45,39 +46,39 @@ final class ActionCreateParams implements BaseModel /** * The name of the action. */ - #[Api] + #[Required] public string $name; /** * Whether the action is a built-in action or a custom one. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?bool $builtIn; /** * The description of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * The IDs of the queues the action is available in. * - * @var list|null $filterInQueueIds + * @var list|null $filterInQueueIDs */ - #[Api(list: 'string', optional: true)] - public ?array $filterInQueueIds; + #[Optional('filterInQueueIds', list: 'string')] + public ?array $filterInQueueIDs; /** * Whether the action allows any text to be entered as a value or if it must be one of the possible values. */ - #[Api(optional: true)] + #[Optional] public ?bool $freeText; /** * User defined key of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $key; /** @@ -85,7 +86,7 @@ final class ActionCreateParams implements BaseModel * * @var value-of|null $position */ - #[Api(enum: Position::class, optional: true)] + #[Optional(enum: Position::class)] public ?string $position; /** @@ -93,7 +94,7 @@ final class ActionCreateParams implements BaseModel * * @var list|null $possibleValues */ - #[Api(list: PossibleValue::class, optional: true)] + #[Optional(list: PossibleValue::class)] public ?array $possibleValues; /** @@ -101,7 +102,7 @@ final class ActionCreateParams implements BaseModel * * @var value-of|null $queueBehaviour */ - #[Api(enum: QueueBehaviour::class, optional: true)] + #[Optional(enum: QueueBehaviour::class)] public ?string $queueBehaviour; /** @@ -109,13 +110,13 @@ final class ActionCreateParams implements BaseModel * * @var value-of|null $type */ - #[Api(enum: Type::class, nullable: true, optional: true)] + #[Optional(enum: Type::class, nullable: true)] public ?string $type; /** * Whether the action requires a value to be executed. */ - #[Api(optional: true)] + #[Optional] public ?bool $valueRequired; /** @@ -123,7 +124,7 @@ final class ActionCreateParams implements BaseModel * * @var list|null $webhooks */ - #[Api(list: Webhook::class, optional: true)] + #[Optional(list: Webhook::class)] public ?array $webhooks; /** @@ -150,7 +151,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $filterInQueueIds + * @param list $filterInQueueIDs * @param Position|value-of $position * @param list $possibleValues * @param QueueBehaviour|value-of $queueBehaviour @@ -163,7 +164,7 @@ public static function with( string $name, ?bool $builtIn = null, ?string $description = null, - ?array $filterInQueueIds = null, + ?array $filterInQueueIDs = null, ?bool $freeText = null, ?string $key = null, Position|string|null $position = null, @@ -173,23 +174,23 @@ public static function with( ?bool $valueRequired = null, ?array $webhooks = null, ): self { - $obj = new self; - - $obj['name'] = $name; - - null !== $builtIn && $obj['builtIn'] = $builtIn; - null !== $description && $obj['description'] = $description; - null !== $filterInQueueIds && $obj['filterInQueueIds'] = $filterInQueueIds; - null !== $freeText && $obj['freeText'] = $freeText; - null !== $key && $obj['key'] = $key; - null !== $position && $obj['position'] = $position; - null !== $possibleValues && $obj['possibleValues'] = $possibleValues; - null !== $queueBehaviour && $obj['queueBehaviour'] = $queueBehaviour; - null !== $type && $obj['type'] = $type; - null !== $valueRequired && $obj['valueRequired'] = $valueRequired; - null !== $webhooks && $obj['webhooks'] = $webhooks; - - return $obj; + $self = new self; + + $self['name'] = $name; + + null !== $builtIn && $self['builtIn'] = $builtIn; + null !== $description && $self['description'] = $description; + null !== $filterInQueueIDs && $self['filterInQueueIDs'] = $filterInQueueIDs; + null !== $freeText && $self['freeText'] = $freeText; + null !== $key && $self['key'] = $key; + null !== $position && $self['position'] = $position; + null !== $possibleValues && $self['possibleValues'] = $possibleValues; + null !== $queueBehaviour && $self['queueBehaviour'] = $queueBehaviour; + null !== $type && $self['type'] = $type; + null !== $valueRequired && $self['valueRequired'] = $valueRequired; + null !== $webhooks && $self['webhooks'] = $webhooks; + + return $self; } /** @@ -197,10 +198,10 @@ public static function with( */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -208,10 +209,10 @@ public function withName(string $name): self */ public function withBuiltIn(?bool $builtIn): self { - $obj = clone $this; - $obj['builtIn'] = $builtIn; + $self = clone $this; + $self['builtIn'] = $builtIn; - return $obj; + return $self; } /** @@ -219,10 +220,10 @@ public function withBuiltIn(?bool $builtIn): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -232,10 +233,10 @@ public function withDescription(?string $description): self */ public function withFilterInQueueIDs(array $filterInQueueIDs): self { - $obj = clone $this; - $obj['filterInQueueIds'] = $filterInQueueIDs; + $self = clone $this; + $self['filterInQueueIDs'] = $filterInQueueIDs; - return $obj; + return $self; } /** @@ -243,10 +244,10 @@ public function withFilterInQueueIDs(array $filterInQueueIDs): self */ public function withFreeText(bool $freeText): self { - $obj = clone $this; - $obj['freeText'] = $freeText; + $self = clone $this; + $self['freeText'] = $freeText; - return $obj; + return $self; } /** @@ -254,10 +255,10 @@ public function withFreeText(bool $freeText): self */ public function withKey(?string $key): self { - $obj = clone $this; - $obj['key'] = $key; + $self = clone $this; + $self['key'] = $key; - return $obj; + return $self; } /** @@ -267,10 +268,10 @@ public function withKey(?string $key): self */ public function withPosition(Position|string $position): self { - $obj = clone $this; - $obj['position'] = $position; + $self = clone $this; + $self['position'] = $position; - return $obj; + return $self; } /** @@ -280,10 +281,10 @@ public function withPosition(Position|string $position): self */ public function withPossibleValues(array $possibleValues): self { - $obj = clone $this; - $obj['possibleValues'] = $possibleValues; + $self = clone $this; + $self['possibleValues'] = $possibleValues; - return $obj; + return $self; } /** @@ -294,10 +295,10 @@ public function withPossibleValues(array $possibleValues): self public function withQueueBehaviour( QueueBehaviour|string $queueBehaviour ): self { - $obj = clone $this; - $obj['queueBehaviour'] = $queueBehaviour; + $self = clone $this; + $self['queueBehaviour'] = $queueBehaviour; - return $obj; + return $self; } /** @@ -307,10 +308,10 @@ public function withQueueBehaviour( */ public function withType(Type|string|null $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } /** @@ -318,10 +319,10 @@ public function withType(Type|string|null $type): self */ public function withValueRequired(bool $valueRequired): self { - $obj = clone $this; - $obj['valueRequired'] = $valueRequired; + $self = clone $this; + $self['valueRequired'] = $valueRequired; - return $obj; + return $self; } /** @@ -333,9 +334,9 @@ public function withValueRequired(bool $valueRequired): self */ public function withWebhooks(array $webhooks): self { - $obj = clone $this; - $obj['webhooks'] = $webhooks; + $self = clone $this; + $self['webhooks'] = $webhooks; - return $obj; + return $self; } } diff --git a/src/Actions/ActionCreateParams/PossibleValue.php b/src/Actions/ActionCreateParams/PossibleValue.php index 94d8a1a..e96d584 100644 --- a/src/Actions/ActionCreateParams/PossibleValue.php +++ b/src/Actions/ActionCreateParams/PossibleValue.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Actions\ActionCreateParams; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,7 +19,7 @@ final class PossibleValue implements BaseModel /** * The value of the action. */ - #[Api] + #[Required] public string $value; /** @@ -48,11 +48,11 @@ public function __construct() */ public static function with(string $value): self { - $obj = new self; + $self = new self; - $obj['value'] = $value; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -60,9 +60,9 @@ public static function with(string $value): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj['value'] = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Actions/ActionCreateParams/Webhook.php b/src/Actions/ActionCreateParams/Webhook.php index 7e4f09a..84340c5 100644 --- a/src/Actions/ActionCreateParams/Webhook.php +++ b/src/Actions/ActionCreateParams/Webhook.php @@ -4,7 +4,8 @@ namespace ModerationAPI\Actions\ActionCreateParams; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -21,25 +22,25 @@ final class Webhook implements BaseModel /** * The webhook's name, used to identify it in the dashboard. */ - #[Api] + #[Required] public string $name; /** * The webhook's URL. We'll call this URL when the event occurs. */ - #[Api] + #[Required] public string $url; /** * ID of an existing webhook or undefined if this is a new webhook. */ - #[Api(optional: true)] + #[Optional] public ?string $id; /** * The webhook's description. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** @@ -72,15 +73,15 @@ public static function with( ?string $id = null, ?string $description = null ): self { - $obj = new self; + $self = new self; - $obj['name'] = $name; - $obj['url'] = $url; + $self['name'] = $name; + $self['url'] = $url; - null !== $id && $obj['id'] = $id; - null !== $description && $obj['description'] = $description; + null !== $id && $self['id'] = $id; + null !== $description && $self['description'] = $description; - return $obj; + return $self; } /** @@ -88,10 +89,10 @@ public static function with( */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -99,10 +100,10 @@ public function withName(string $name): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -110,10 +111,10 @@ public function withURL(string $url): self */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -121,9 +122,9 @@ public function withID(string $id): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } } diff --git a/src/Actions/ActionDeleteResponse.php b/src/Actions/ActionDeleteResponse.php index 208ae8d..f19dc13 100644 --- a/src/Actions/ActionDeleteResponse.php +++ b/src/Actions/ActionDeleteResponse.php @@ -4,32 +4,28 @@ namespace ModerationAPI\Actions; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type ActionDeleteResponseShape = array{id: string, deleted: bool} */ -final class ActionDeleteResponse implements BaseModel, ResponseConverter +final class ActionDeleteResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * The ID of the action. */ - #[Api] + #[Required] public string $id; /** * Whether the action was deleted. */ - #[Api] + #[Required] public bool $deleted; /** @@ -58,12 +54,12 @@ public function __construct() */ public static function with(string $id, bool $deleted): self { - $obj = new self; + $self = new self; - $obj['id'] = $id; - $obj['deleted'] = $deleted; + $self['id'] = $id; + $self['deleted'] = $deleted; - return $obj; + return $self; } /** @@ -71,10 +67,10 @@ public static function with(string $id, bool $deleted): self */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -82,9 +78,9 @@ public function withID(string $id): self */ public function withDeleted(bool $deleted): self { - $obj = clone $this; - $obj['deleted'] = $deleted; + $self = clone $this; + $self['deleted'] = $deleted; - return $obj; + return $self; } } diff --git a/src/Actions/ActionGetResponse.php b/src/Actions/ActionGetResponse.php index ed95145..0d86db0 100644 --- a/src/Actions/ActionGetResponse.php +++ b/src/Actions/ActionGetResponse.php @@ -9,18 +9,17 @@ use ModerationAPI\Actions\ActionGetResponse\QueueBehaviour; use ModerationAPI\Actions\ActionGetResponse\Type; use ModerationAPI\Actions\ActionGetResponse\Webhook; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type ActionGetResponseShape = array{ * id: string, * builtIn: bool|null, * createdAt: string, - * filterInQueueIds: list, + * filterInQueueIDs: list, * freeText: bool, * name: string, * position: value-of, @@ -33,49 +32,47 @@ * type?: value-of|null, * } */ -final class ActionGetResponse implements BaseModel, ResponseConverter +final class ActionGetResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * The ID of the action. */ - #[Api] + #[Required] public string $id; /** * Whether the action is a built-in action or a custom one. */ - #[Api] + #[Required] public ?bool $builtIn; /** * The date the action was created. */ - #[Api] + #[Required] public string $createdAt; /** * The IDs of the queues the action is available in. * - * @var list $filterInQueueIds + * @var list $filterInQueueIDs */ - #[Api(list: 'string')] - public array $filterInQueueIds; + #[Required('filterInQueueIds', list: 'string')] + public array $filterInQueueIDs; /** * Whether the action allows any text to be entered as a value or if it must be one of the possible values. */ - #[Api] + #[Required] public bool $freeText; /** * The name of the action. */ - #[Api] + #[Required] public string $name; /** @@ -83,7 +80,7 @@ final class ActionGetResponse implements BaseModel, ResponseConverter * * @var value-of $position */ - #[Api(enum: Position::class)] + #[Required(enum: Position::class)] public string $position; /** @@ -91,7 +88,7 @@ final class ActionGetResponse implements BaseModel, ResponseConverter * * @var list $possibleValues */ - #[Api(list: PossibleValue::class)] + #[Required(list: PossibleValue::class)] public array $possibleValues; /** @@ -99,13 +96,13 @@ final class ActionGetResponse implements BaseModel, ResponseConverter * * @var value-of $queueBehaviour */ - #[Api(enum: QueueBehaviour::class)] + #[Required(enum: QueueBehaviour::class)] public string $queueBehaviour; /** * Whether the action requires a value to be executed. */ - #[Api] + #[Required] public bool $valueRequired; /** @@ -113,19 +110,19 @@ final class ActionGetResponse implements BaseModel, ResponseConverter * * @var list $webhooks */ - #[Api(list: Webhook::class)] + #[Required(list: Webhook::class)] public array $webhooks; /** * The description of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * User defined key of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $key; /** @@ -133,7 +130,7 @@ final class ActionGetResponse implements BaseModel, ResponseConverter * * @var value-of|null $type */ - #[Api(enum: Type::class, nullable: true, optional: true)] + #[Optional(enum: Type::class, nullable: true)] public ?string $type; /** @@ -145,7 +142,7 @@ final class ActionGetResponse implements BaseModel, ResponseConverter * id: ..., * builtIn: ..., * createdAt: ..., - * filterInQueueIds: ..., + * filterInQueueIDs: ..., * freeText: ..., * name: ..., * position: ..., @@ -183,7 +180,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $filterInQueueIds + * @param list $filterInQueueIDs * @param Position|value-of $position * @param list $possibleValues * @param QueueBehaviour|value-of $queueBehaviour @@ -192,7 +189,7 @@ public function __construct() * name: string, * url: string, * description?: string|null, - * moderationActionId?: string|null, + * moderationActionID?: string|null, * }> $webhooks * @param Type|value-of|null $type */ @@ -201,7 +198,7 @@ public static function with( string $createdAt, string $name, ?bool $builtIn = false, - array $filterInQueueIds = [], + array $filterInQueueIDs = [], bool $freeText = false, Position|string $position = 'ALL_QUEUES', array $possibleValues = [], @@ -212,25 +209,25 @@ public static function with( ?string $key = null, Type|string|null $type = null, ): self { - $obj = new self; - - $obj['id'] = $id; - $obj['builtIn'] = $builtIn; - $obj['createdAt'] = $createdAt; - $obj['filterInQueueIds'] = $filterInQueueIds; - $obj['freeText'] = $freeText; - $obj['name'] = $name; - $obj['position'] = $position; - $obj['possibleValues'] = $possibleValues; - $obj['queueBehaviour'] = $queueBehaviour; - $obj['valueRequired'] = $valueRequired; - $obj['webhooks'] = $webhooks; - - null !== $description && $obj['description'] = $description; - null !== $key && $obj['key'] = $key; - null !== $type && $obj['type'] = $type; - - return $obj; + $self = new self; + + $self['id'] = $id; + $self['builtIn'] = $builtIn; + $self['createdAt'] = $createdAt; + $self['filterInQueueIDs'] = $filterInQueueIDs; + $self['freeText'] = $freeText; + $self['name'] = $name; + $self['position'] = $position; + $self['possibleValues'] = $possibleValues; + $self['queueBehaviour'] = $queueBehaviour; + $self['valueRequired'] = $valueRequired; + $self['webhooks'] = $webhooks; + + null !== $description && $self['description'] = $description; + null !== $key && $self['key'] = $key; + null !== $type && $self['type'] = $type; + + return $self; } /** @@ -238,10 +235,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -249,10 +246,10 @@ public function withID(string $id): self */ public function withBuiltIn(?bool $builtIn): self { - $obj = clone $this; - $obj['builtIn'] = $builtIn; + $self = clone $this; + $self['builtIn'] = $builtIn; - return $obj; + return $self; } /** @@ -260,10 +257,10 @@ public function withBuiltIn(?bool $builtIn): self */ public function withCreatedAt(string $createdAt): self { - $obj = clone $this; - $obj['createdAt'] = $createdAt; + $self = clone $this; + $self['createdAt'] = $createdAt; - return $obj; + return $self; } /** @@ -273,10 +270,10 @@ public function withCreatedAt(string $createdAt): self */ public function withFilterInQueueIDs(array $filterInQueueIDs): self { - $obj = clone $this; - $obj['filterInQueueIds'] = $filterInQueueIDs; + $self = clone $this; + $self['filterInQueueIDs'] = $filterInQueueIDs; - return $obj; + return $self; } /** @@ -284,10 +281,10 @@ public function withFilterInQueueIDs(array $filterInQueueIDs): self */ public function withFreeText(bool $freeText): self { - $obj = clone $this; - $obj['freeText'] = $freeText; + $self = clone $this; + $self['freeText'] = $freeText; - return $obj; + return $self; } /** @@ -295,10 +292,10 @@ public function withFreeText(bool $freeText): self */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -308,10 +305,10 @@ public function withName(string $name): self */ public function withPosition(Position|string $position): self { - $obj = clone $this; - $obj['position'] = $position; + $self = clone $this; + $self['position'] = $position; - return $obj; + return $self; } /** @@ -321,10 +318,10 @@ public function withPosition(Position|string $position): self */ public function withPossibleValues(array $possibleValues): self { - $obj = clone $this; - $obj['possibleValues'] = $possibleValues; + $self = clone $this; + $self['possibleValues'] = $possibleValues; - return $obj; + return $self; } /** @@ -335,10 +332,10 @@ public function withPossibleValues(array $possibleValues): self public function withQueueBehaviour( QueueBehaviour|string $queueBehaviour ): self { - $obj = clone $this; - $obj['queueBehaviour'] = $queueBehaviour; + $self = clone $this; + $self['queueBehaviour'] = $queueBehaviour; - return $obj; + return $self; } /** @@ -346,10 +343,10 @@ public function withQueueBehaviour( */ public function withValueRequired(bool $valueRequired): self { - $obj = clone $this; - $obj['valueRequired'] = $valueRequired; + $self = clone $this; + $self['valueRequired'] = $valueRequired; - return $obj; + return $self; } /** @@ -360,15 +357,15 @@ public function withValueRequired(bool $valueRequired): self * name: string, * url: string, * description?: string|null, - * moderationActionId?: string|null, + * moderationActionID?: string|null, * }> $webhooks */ public function withWebhooks(array $webhooks): self { - $obj = clone $this; - $obj['webhooks'] = $webhooks; + $self = clone $this; + $self['webhooks'] = $webhooks; - return $obj; + return $self; } /** @@ -376,10 +373,10 @@ public function withWebhooks(array $webhooks): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -387,10 +384,10 @@ public function withDescription(?string $description): self */ public function withKey(?string $key): self { - $obj = clone $this; - $obj['key'] = $key; + $self = clone $this; + $self['key'] = $key; - return $obj; + return $self; } /** @@ -400,9 +397,9 @@ public function withKey(?string $key): self */ public function withType(Type|string|null $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } } diff --git a/src/Actions/ActionGetResponse/PossibleValue.php b/src/Actions/ActionGetResponse/PossibleValue.php index 012ad96..466b34f 100644 --- a/src/Actions/ActionGetResponse/PossibleValue.php +++ b/src/Actions/ActionGetResponse/PossibleValue.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Actions\ActionGetResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,7 +19,7 @@ final class PossibleValue implements BaseModel /** * The value of the action. */ - #[Api] + #[Required] public string $value; /** @@ -48,11 +48,11 @@ public function __construct() */ public static function with(string $value): self { - $obj = new self; + $self = new self; - $obj['value'] = $value; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -60,9 +60,9 @@ public static function with(string $value): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj['value'] = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Actions/ActionGetResponse/Webhook.php b/src/Actions/ActionGetResponse/Webhook.php index 7bd6f83..0dbd4de 100644 --- a/src/Actions/ActionGetResponse/Webhook.php +++ b/src/Actions/ActionGetResponse/Webhook.php @@ -4,7 +4,8 @@ namespace ModerationAPI\Actions\ActionGetResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -14,7 +15,7 @@ * name: string, * url: string, * description?: string|null, - * moderationActionId?: string|null, + * moderationActionID?: string|null, * } */ final class Webhook implements BaseModel @@ -25,32 +26,32 @@ final class Webhook implements BaseModel /** * The ID of the webhook. */ - #[Api] + #[Required] public string $id; /** * The webhook's name, used to identify it in the dashboard. */ - #[Api] + #[Required] public string $name; /** * The webhook's URL. We'll call this URL when the event occurs. */ - #[Api] + #[Required] public string $url; /** * The webhook's description. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * The ID of the moderation action to trigger the webhook on. Only used for moderation action webhooks. */ - #[Api(nullable: true, optional: true)] - public ?string $moderationActionId; + #[Optional('moderationActionId', nullable: true)] + public ?string $moderationActionID; /** * `new Webhook()` is missing required properties by the API. @@ -81,18 +82,18 @@ public static function with( string $name, string $url, ?string $description = null, - ?string $moderationActionId = null, + ?string $moderationActionID = null, ): self { - $obj = new self; + $self = new self; - $obj['id'] = $id; - $obj['name'] = $name; - $obj['url'] = $url; + $self['id'] = $id; + $self['name'] = $name; + $self['url'] = $url; - null !== $description && $obj['description'] = $description; - null !== $moderationActionId && $obj['moderationActionId'] = $moderationActionId; + null !== $description && $self['description'] = $description; + null !== $moderationActionID && $self['moderationActionID'] = $moderationActionID; - return $obj; + return $self; } /** @@ -100,10 +101,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -111,10 +112,10 @@ public function withID(string $id): self */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -122,10 +123,10 @@ public function withName(string $name): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -133,10 +134,10 @@ public function withURL(string $url): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -144,9 +145,9 @@ public function withDescription(?string $description): self */ public function withModerationActionID(?string $moderationActionID): self { - $obj = clone $this; - $obj['moderationActionId'] = $moderationActionID; + $self = clone $this; + $self['moderationActionID'] = $moderationActionID; - return $obj; + return $self; } } diff --git a/src/Actions/ActionListParams.php b/src/Actions/ActionListParams.php index 7f13d32..90b4be8 100644 --- a/src/Actions/ActionListParams.php +++ b/src/Actions/ActionListParams.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Actions; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Concerns\SdkParams; use ModerationAPI\Core\Contracts\BaseModel; @@ -14,7 +14,7 @@ * * @see ModerationAPI\Services\ActionsService::list() * - * @phpstan-type ActionListParamsShape = array{queueId?: string} + * @phpstan-type ActionListParamsShape = array{queueID?: string} */ final class ActionListParams implements BaseModel { @@ -22,8 +22,8 @@ final class ActionListParams implements BaseModel use SdkModel; use SdkParams; - #[Api(optional: true)] - public ?string $queueId; + #[Optional] + public ?string $queueID; public function __construct() { @@ -35,20 +35,20 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(?string $queueId = null): self + public static function with(?string $queueID = null): self { - $obj = new self; + $self = new self; - null !== $queueId && $obj['queueId'] = $queueId; + null !== $queueID && $self['queueID'] = $queueID; - return $obj; + return $self; } public function withQueueID(string $queueID): self { - $obj = clone $this; - $obj['queueId'] = $queueID; + $self = clone $this; + $self['queueID'] = $queueID; - return $obj; + return $self; } } diff --git a/src/Actions/ActionListResponseItem.php b/src/Actions/ActionListResponseItem.php index 326c585..b490486 100644 --- a/src/Actions/ActionListResponseItem.php +++ b/src/Actions/ActionListResponseItem.php @@ -9,7 +9,8 @@ use ModerationAPI\Actions\ActionListResponseItem\QueueBehaviour; use ModerationAPI\Actions\ActionListResponseItem\Type; use ModerationAPI\Actions\ActionListResponseItem\Webhook; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -18,7 +19,7 @@ * id: string, * builtIn: bool|null, * createdAt: string, - * filterInQueueIds: list, + * filterInQueueIDs: list, * freeText: bool, * name: string, * position: value-of, @@ -39,39 +40,39 @@ final class ActionListResponseItem implements BaseModel /** * The ID of the action. */ - #[Api] + #[Required] public string $id; /** * Whether the action is a built-in action or a custom one. */ - #[Api] + #[Required] public ?bool $builtIn; /** * The date the action was created. */ - #[Api] + #[Required] public string $createdAt; /** * The IDs of the queues the action is available in. * - * @var list $filterInQueueIds + * @var list $filterInQueueIDs */ - #[Api(list: 'string')] - public array $filterInQueueIds; + #[Required('filterInQueueIds', list: 'string')] + public array $filterInQueueIDs; /** * Whether the action allows any text to be entered as a value or if it must be one of the possible values. */ - #[Api] + #[Required] public bool $freeText; /** * The name of the action. */ - #[Api] + #[Required] public string $name; /** @@ -79,7 +80,7 @@ final class ActionListResponseItem implements BaseModel * * @var value-of $position */ - #[Api(enum: Position::class)] + #[Required(enum: Position::class)] public string $position; /** @@ -87,7 +88,7 @@ final class ActionListResponseItem implements BaseModel * * @var list $possibleValues */ - #[Api(list: PossibleValue::class)] + #[Required(list: PossibleValue::class)] public array $possibleValues; /** @@ -95,13 +96,13 @@ final class ActionListResponseItem implements BaseModel * * @var value-of $queueBehaviour */ - #[Api(enum: QueueBehaviour::class)] + #[Required(enum: QueueBehaviour::class)] public string $queueBehaviour; /** * Whether the action requires a value to be executed. */ - #[Api] + #[Required] public bool $valueRequired; /** @@ -109,19 +110,19 @@ final class ActionListResponseItem implements BaseModel * * @var list $webhooks */ - #[Api(list: Webhook::class)] + #[Required(list: Webhook::class)] public array $webhooks; /** * The description of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * User defined key of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $key; /** @@ -129,7 +130,7 @@ final class ActionListResponseItem implements BaseModel * * @var value-of|null $type */ - #[Api(enum: Type::class, nullable: true, optional: true)] + #[Optional(enum: Type::class, nullable: true)] public ?string $type; /** @@ -141,7 +142,7 @@ final class ActionListResponseItem implements BaseModel * id: ..., * builtIn: ..., * createdAt: ..., - * filterInQueueIds: ..., + * filterInQueueIDs: ..., * freeText: ..., * name: ..., * position: ..., @@ -179,7 +180,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $filterInQueueIds + * @param list $filterInQueueIDs * @param Position|value-of $position * @param list $possibleValues * @param QueueBehaviour|value-of $queueBehaviour @@ -188,7 +189,7 @@ public function __construct() * name: string, * url: string, * description?: string|null, - * moderationActionId?: string|null, + * moderationActionID?: string|null, * }> $webhooks * @param Type|value-of|null $type */ @@ -197,7 +198,7 @@ public static function with( string $createdAt, string $name, ?bool $builtIn = false, - array $filterInQueueIds = [], + array $filterInQueueIDs = [], bool $freeText = false, Position|string $position = 'ALL_QUEUES', array $possibleValues = [], @@ -208,25 +209,25 @@ public static function with( ?string $key = null, Type|string|null $type = null, ): self { - $obj = new self; - - $obj['id'] = $id; - $obj['builtIn'] = $builtIn; - $obj['createdAt'] = $createdAt; - $obj['filterInQueueIds'] = $filterInQueueIds; - $obj['freeText'] = $freeText; - $obj['name'] = $name; - $obj['position'] = $position; - $obj['possibleValues'] = $possibleValues; - $obj['queueBehaviour'] = $queueBehaviour; - $obj['valueRequired'] = $valueRequired; - $obj['webhooks'] = $webhooks; - - null !== $description && $obj['description'] = $description; - null !== $key && $obj['key'] = $key; - null !== $type && $obj['type'] = $type; - - return $obj; + $self = new self; + + $self['id'] = $id; + $self['builtIn'] = $builtIn; + $self['createdAt'] = $createdAt; + $self['filterInQueueIDs'] = $filterInQueueIDs; + $self['freeText'] = $freeText; + $self['name'] = $name; + $self['position'] = $position; + $self['possibleValues'] = $possibleValues; + $self['queueBehaviour'] = $queueBehaviour; + $self['valueRequired'] = $valueRequired; + $self['webhooks'] = $webhooks; + + null !== $description && $self['description'] = $description; + null !== $key && $self['key'] = $key; + null !== $type && $self['type'] = $type; + + return $self; } /** @@ -234,10 +235,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -245,10 +246,10 @@ public function withID(string $id): self */ public function withBuiltIn(?bool $builtIn): self { - $obj = clone $this; - $obj['builtIn'] = $builtIn; + $self = clone $this; + $self['builtIn'] = $builtIn; - return $obj; + return $self; } /** @@ -256,10 +257,10 @@ public function withBuiltIn(?bool $builtIn): self */ public function withCreatedAt(string $createdAt): self { - $obj = clone $this; - $obj['createdAt'] = $createdAt; + $self = clone $this; + $self['createdAt'] = $createdAt; - return $obj; + return $self; } /** @@ -269,10 +270,10 @@ public function withCreatedAt(string $createdAt): self */ public function withFilterInQueueIDs(array $filterInQueueIDs): self { - $obj = clone $this; - $obj['filterInQueueIds'] = $filterInQueueIDs; + $self = clone $this; + $self['filterInQueueIDs'] = $filterInQueueIDs; - return $obj; + return $self; } /** @@ -280,10 +281,10 @@ public function withFilterInQueueIDs(array $filterInQueueIDs): self */ public function withFreeText(bool $freeText): self { - $obj = clone $this; - $obj['freeText'] = $freeText; + $self = clone $this; + $self['freeText'] = $freeText; - return $obj; + return $self; } /** @@ -291,10 +292,10 @@ public function withFreeText(bool $freeText): self */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -304,10 +305,10 @@ public function withName(string $name): self */ public function withPosition(Position|string $position): self { - $obj = clone $this; - $obj['position'] = $position; + $self = clone $this; + $self['position'] = $position; - return $obj; + return $self; } /** @@ -317,10 +318,10 @@ public function withPosition(Position|string $position): self */ public function withPossibleValues(array $possibleValues): self { - $obj = clone $this; - $obj['possibleValues'] = $possibleValues; + $self = clone $this; + $self['possibleValues'] = $possibleValues; - return $obj; + return $self; } /** @@ -331,10 +332,10 @@ public function withPossibleValues(array $possibleValues): self public function withQueueBehaviour( QueueBehaviour|string $queueBehaviour ): self { - $obj = clone $this; - $obj['queueBehaviour'] = $queueBehaviour; + $self = clone $this; + $self['queueBehaviour'] = $queueBehaviour; - return $obj; + return $self; } /** @@ -342,10 +343,10 @@ public function withQueueBehaviour( */ public function withValueRequired(bool $valueRequired): self { - $obj = clone $this; - $obj['valueRequired'] = $valueRequired; + $self = clone $this; + $self['valueRequired'] = $valueRequired; - return $obj; + return $self; } /** @@ -356,15 +357,15 @@ public function withValueRequired(bool $valueRequired): self * name: string, * url: string, * description?: string|null, - * moderationActionId?: string|null, + * moderationActionID?: string|null, * }> $webhooks */ public function withWebhooks(array $webhooks): self { - $obj = clone $this; - $obj['webhooks'] = $webhooks; + $self = clone $this; + $self['webhooks'] = $webhooks; - return $obj; + return $self; } /** @@ -372,10 +373,10 @@ public function withWebhooks(array $webhooks): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -383,10 +384,10 @@ public function withDescription(?string $description): self */ public function withKey(?string $key): self { - $obj = clone $this; - $obj['key'] = $key; + $self = clone $this; + $self['key'] = $key; - return $obj; + return $self; } /** @@ -396,9 +397,9 @@ public function withKey(?string $key): self */ public function withType(Type|string|null $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } } diff --git a/src/Actions/ActionListResponseItem/PossibleValue.php b/src/Actions/ActionListResponseItem/PossibleValue.php index 98988ce..c0986f9 100644 --- a/src/Actions/ActionListResponseItem/PossibleValue.php +++ b/src/Actions/ActionListResponseItem/PossibleValue.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Actions\ActionListResponseItem; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,7 +19,7 @@ final class PossibleValue implements BaseModel /** * The value of the action. */ - #[Api] + #[Required] public string $value; /** @@ -48,11 +48,11 @@ public function __construct() */ public static function with(string $value): self { - $obj = new self; + $self = new self; - $obj['value'] = $value; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -60,9 +60,9 @@ public static function with(string $value): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj['value'] = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Actions/ActionListResponseItem/Webhook.php b/src/Actions/ActionListResponseItem/Webhook.php index e90b742..736ec39 100644 --- a/src/Actions/ActionListResponseItem/Webhook.php +++ b/src/Actions/ActionListResponseItem/Webhook.php @@ -4,7 +4,8 @@ namespace ModerationAPI\Actions\ActionListResponseItem; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -14,7 +15,7 @@ * name: string, * url: string, * description?: string|null, - * moderationActionId?: string|null, + * moderationActionID?: string|null, * } */ final class Webhook implements BaseModel @@ -25,32 +26,32 @@ final class Webhook implements BaseModel /** * The ID of the webhook. */ - #[Api] + #[Required] public string $id; /** * The webhook's name, used to identify it in the dashboard. */ - #[Api] + #[Required] public string $name; /** * The webhook's URL. We'll call this URL when the event occurs. */ - #[Api] + #[Required] public string $url; /** * The webhook's description. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * The ID of the moderation action to trigger the webhook on. Only used for moderation action webhooks. */ - #[Api(nullable: true, optional: true)] - public ?string $moderationActionId; + #[Optional('moderationActionId', nullable: true)] + public ?string $moderationActionID; /** * `new Webhook()` is missing required properties by the API. @@ -81,18 +82,18 @@ public static function with( string $name, string $url, ?string $description = null, - ?string $moderationActionId = null, + ?string $moderationActionID = null, ): self { - $obj = new self; + $self = new self; - $obj['id'] = $id; - $obj['name'] = $name; - $obj['url'] = $url; + $self['id'] = $id; + $self['name'] = $name; + $self['url'] = $url; - null !== $description && $obj['description'] = $description; - null !== $moderationActionId && $obj['moderationActionId'] = $moderationActionId; + null !== $description && $self['description'] = $description; + null !== $moderationActionID && $self['moderationActionID'] = $moderationActionID; - return $obj; + return $self; } /** @@ -100,10 +101,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -111,10 +112,10 @@ public function withID(string $id): self */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -122,10 +123,10 @@ public function withName(string $name): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -133,10 +134,10 @@ public function withURL(string $url): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -144,9 +145,9 @@ public function withDescription(?string $description): self */ public function withModerationActionID(?string $moderationActionID): self { - $obj = clone $this; - $obj['moderationActionId'] = $moderationActionID; + $self = clone $this; + $self['moderationActionID'] = $moderationActionID; - return $obj; + return $self; } } diff --git a/src/Actions/ActionNewResponse.php b/src/Actions/ActionNewResponse.php index fa9c736..616afab 100644 --- a/src/Actions/ActionNewResponse.php +++ b/src/Actions/ActionNewResponse.php @@ -8,18 +8,17 @@ use ModerationAPI\Actions\ActionNewResponse\PossibleValue; use ModerationAPI\Actions\ActionNewResponse\QueueBehaviour; use ModerationAPI\Actions\ActionNewResponse\Type; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type ActionNewResponseShape = array{ * id: string, * builtIn: bool|null, * createdAt: string, - * filterInQueueIds: list, + * filterInQueueIDs: list, * freeText: bool, * name: string, * position: value-of, @@ -31,49 +30,47 @@ * type?: value-of|null, * } */ -final class ActionNewResponse implements BaseModel, ResponseConverter +final class ActionNewResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * The ID of the action. */ - #[Api] + #[Required] public string $id; /** * Whether the action is a built-in action or a custom one. */ - #[Api] + #[Required] public ?bool $builtIn; /** * The date the action was created. */ - #[Api] + #[Required] public string $createdAt; /** * The IDs of the queues the action is available in. * - * @var list $filterInQueueIds + * @var list $filterInQueueIDs */ - #[Api(list: 'string')] - public array $filterInQueueIds; + #[Required('filterInQueueIds', list: 'string')] + public array $filterInQueueIDs; /** * Whether the action allows any text to be entered as a value or if it must be one of the possible values. */ - #[Api] + #[Required] public bool $freeText; /** * The name of the action. */ - #[Api] + #[Required] public string $name; /** @@ -81,7 +78,7 @@ final class ActionNewResponse implements BaseModel, ResponseConverter * * @var value-of $position */ - #[Api(enum: Position::class)] + #[Required(enum: Position::class)] public string $position; /** @@ -89,7 +86,7 @@ final class ActionNewResponse implements BaseModel, ResponseConverter * * @var list $possibleValues */ - #[Api(list: PossibleValue::class)] + #[Required(list: PossibleValue::class)] public array $possibleValues; /** @@ -97,25 +94,25 @@ final class ActionNewResponse implements BaseModel, ResponseConverter * * @var value-of $queueBehaviour */ - #[Api(enum: QueueBehaviour::class)] + #[Required(enum: QueueBehaviour::class)] public string $queueBehaviour; /** * Whether the action requires a value to be executed. */ - #[Api] + #[Required] public bool $valueRequired; /** * The description of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * User defined key of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $key; /** @@ -123,7 +120,7 @@ final class ActionNewResponse implements BaseModel, ResponseConverter * * @var value-of|null $type */ - #[Api(enum: Type::class, nullable: true, optional: true)] + #[Optional(enum: Type::class, nullable: true)] public ?string $type; /** @@ -135,7 +132,7 @@ final class ActionNewResponse implements BaseModel, ResponseConverter * id: ..., * builtIn: ..., * createdAt: ..., - * filterInQueueIds: ..., + * filterInQueueIDs: ..., * freeText: ..., * name: ..., * position: ..., @@ -171,7 +168,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $filterInQueueIds + * @param list $filterInQueueIDs * @param Position|value-of $position * @param list $possibleValues * @param QueueBehaviour|value-of $queueBehaviour @@ -182,7 +179,7 @@ public static function with( string $createdAt, string $name, ?bool $builtIn = false, - array $filterInQueueIds = [], + array $filterInQueueIDs = [], bool $freeText = false, Position|string $position = 'ALL_QUEUES', array $possibleValues = [], @@ -192,24 +189,24 @@ public static function with( ?string $key = null, Type|string|null $type = null, ): self { - $obj = new self; - - $obj['id'] = $id; - $obj['builtIn'] = $builtIn; - $obj['createdAt'] = $createdAt; - $obj['filterInQueueIds'] = $filterInQueueIds; - $obj['freeText'] = $freeText; - $obj['name'] = $name; - $obj['position'] = $position; - $obj['possibleValues'] = $possibleValues; - $obj['queueBehaviour'] = $queueBehaviour; - $obj['valueRequired'] = $valueRequired; - - null !== $description && $obj['description'] = $description; - null !== $key && $obj['key'] = $key; - null !== $type && $obj['type'] = $type; - - return $obj; + $self = new self; + + $self['id'] = $id; + $self['builtIn'] = $builtIn; + $self['createdAt'] = $createdAt; + $self['filterInQueueIDs'] = $filterInQueueIDs; + $self['freeText'] = $freeText; + $self['name'] = $name; + $self['position'] = $position; + $self['possibleValues'] = $possibleValues; + $self['queueBehaviour'] = $queueBehaviour; + $self['valueRequired'] = $valueRequired; + + null !== $description && $self['description'] = $description; + null !== $key && $self['key'] = $key; + null !== $type && $self['type'] = $type; + + return $self; } /** @@ -217,10 +214,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -228,10 +225,10 @@ public function withID(string $id): self */ public function withBuiltIn(?bool $builtIn): self { - $obj = clone $this; - $obj['builtIn'] = $builtIn; + $self = clone $this; + $self['builtIn'] = $builtIn; - return $obj; + return $self; } /** @@ -239,10 +236,10 @@ public function withBuiltIn(?bool $builtIn): self */ public function withCreatedAt(string $createdAt): self { - $obj = clone $this; - $obj['createdAt'] = $createdAt; + $self = clone $this; + $self['createdAt'] = $createdAt; - return $obj; + return $self; } /** @@ -252,10 +249,10 @@ public function withCreatedAt(string $createdAt): self */ public function withFilterInQueueIDs(array $filterInQueueIDs): self { - $obj = clone $this; - $obj['filterInQueueIds'] = $filterInQueueIDs; + $self = clone $this; + $self['filterInQueueIDs'] = $filterInQueueIDs; - return $obj; + return $self; } /** @@ -263,10 +260,10 @@ public function withFilterInQueueIDs(array $filterInQueueIDs): self */ public function withFreeText(bool $freeText): self { - $obj = clone $this; - $obj['freeText'] = $freeText; + $self = clone $this; + $self['freeText'] = $freeText; - return $obj; + return $self; } /** @@ -274,10 +271,10 @@ public function withFreeText(bool $freeText): self */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -287,10 +284,10 @@ public function withName(string $name): self */ public function withPosition(Position|string $position): self { - $obj = clone $this; - $obj['position'] = $position; + $self = clone $this; + $self['position'] = $position; - return $obj; + return $self; } /** @@ -300,10 +297,10 @@ public function withPosition(Position|string $position): self */ public function withPossibleValues(array $possibleValues): self { - $obj = clone $this; - $obj['possibleValues'] = $possibleValues; + $self = clone $this; + $self['possibleValues'] = $possibleValues; - return $obj; + return $self; } /** @@ -314,10 +311,10 @@ public function withPossibleValues(array $possibleValues): self public function withQueueBehaviour( QueueBehaviour|string $queueBehaviour ): self { - $obj = clone $this; - $obj['queueBehaviour'] = $queueBehaviour; + $self = clone $this; + $self['queueBehaviour'] = $queueBehaviour; - return $obj; + return $self; } /** @@ -325,10 +322,10 @@ public function withQueueBehaviour( */ public function withValueRequired(bool $valueRequired): self { - $obj = clone $this; - $obj['valueRequired'] = $valueRequired; + $self = clone $this; + $self['valueRequired'] = $valueRequired; - return $obj; + return $self; } /** @@ -336,10 +333,10 @@ public function withValueRequired(bool $valueRequired): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -347,10 +344,10 @@ public function withDescription(?string $description): self */ public function withKey(?string $key): self { - $obj = clone $this; - $obj['key'] = $key; + $self = clone $this; + $self['key'] = $key; - return $obj; + return $self; } /** @@ -360,9 +357,9 @@ public function withKey(?string $key): self */ public function withType(Type|string|null $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } } diff --git a/src/Actions/ActionNewResponse/PossibleValue.php b/src/Actions/ActionNewResponse/PossibleValue.php index 92ebb0a..c0c1e00 100644 --- a/src/Actions/ActionNewResponse/PossibleValue.php +++ b/src/Actions/ActionNewResponse/PossibleValue.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Actions\ActionNewResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,7 +19,7 @@ final class PossibleValue implements BaseModel /** * The value of the action. */ - #[Api] + #[Required] public string $value; /** @@ -48,11 +48,11 @@ public function __construct() */ public static function with(string $value): self { - $obj = new self; + $self = new self; - $obj['value'] = $value; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -60,9 +60,9 @@ public static function with(string $value): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj['value'] = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Actions/ActionUpdateParams.php b/src/Actions/ActionUpdateParams.php index 0198946..7fd58e3 100644 --- a/src/Actions/ActionUpdateParams.php +++ b/src/Actions/ActionUpdateParams.php @@ -9,7 +9,7 @@ use ModerationAPI\Actions\ActionUpdateParams\QueueBehaviour; use ModerationAPI\Actions\ActionUpdateParams\Type; use ModerationAPI\Actions\ActionUpdateParams\Webhook; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Concerns\SdkParams; use ModerationAPI\Core\Contracts\BaseModel; @@ -22,7 +22,7 @@ * @phpstan-type ActionUpdateParamsShape = array{ * builtIn?: bool|null, * description?: string|null, - * filterInQueueIds?: list, + * filterInQueueIDs?: list, * freeText?: bool, * key?: string|null, * name?: string, @@ -45,39 +45,39 @@ final class ActionUpdateParams implements BaseModel /** * Whether the action is a built-in action or a custom one. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?bool $builtIn; /** * The description of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * The IDs of the queues the action is available in. * - * @var list|null $filterInQueueIds + * @var list|null $filterInQueueIDs */ - #[Api(list: 'string', optional: true)] - public ?array $filterInQueueIds; + #[Optional('filterInQueueIds', list: 'string')] + public ?array $filterInQueueIDs; /** * Whether the action allows any text to be entered as a value or if it must be one of the possible values. */ - #[Api(optional: true)] + #[Optional] public ?bool $freeText; /** * User defined key of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $key; /** * The name of the action. */ - #[Api(optional: true)] + #[Optional] public ?string $name; /** @@ -85,7 +85,7 @@ final class ActionUpdateParams implements BaseModel * * @var value-of|null $position */ - #[Api(enum: Position::class, optional: true)] + #[Optional(enum: Position::class)] public ?string $position; /** @@ -93,7 +93,7 @@ final class ActionUpdateParams implements BaseModel * * @var list|null $possibleValues */ - #[Api(list: PossibleValue::class, optional: true)] + #[Optional(list: PossibleValue::class)] public ?array $possibleValues; /** @@ -101,7 +101,7 @@ final class ActionUpdateParams implements BaseModel * * @var value-of|null $queueBehaviour */ - #[Api(enum: QueueBehaviour::class, optional: true)] + #[Optional(enum: QueueBehaviour::class)] public ?string $queueBehaviour; /** @@ -109,13 +109,13 @@ final class ActionUpdateParams implements BaseModel * * @var value-of|null $type */ - #[Api(enum: Type::class, nullable: true, optional: true)] + #[Optional(enum: Type::class, nullable: true)] public ?string $type; /** * Whether the action requires a value to be executed. */ - #[Api(optional: true)] + #[Optional] public ?bool $valueRequired; /** @@ -123,7 +123,7 @@ final class ActionUpdateParams implements BaseModel * * @var list|null $webhooks */ - #[Api(list: Webhook::class, optional: true)] + #[Optional(list: Webhook::class)] public ?array $webhooks; public function __construct() @@ -136,7 +136,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $filterInQueueIds + * @param list $filterInQueueIDs * @param Position|value-of $position * @param list $possibleValues * @param QueueBehaviour|value-of $queueBehaviour @@ -148,7 +148,7 @@ public function __construct() public static function with( ?bool $builtIn = null, ?string $description = null, - ?array $filterInQueueIds = null, + ?array $filterInQueueIDs = null, ?bool $freeText = null, ?string $key = null, ?string $name = null, @@ -159,22 +159,22 @@ public static function with( ?bool $valueRequired = null, ?array $webhooks = null, ): self { - $obj = new self; - - null !== $builtIn && $obj['builtIn'] = $builtIn; - null !== $description && $obj['description'] = $description; - null !== $filterInQueueIds && $obj['filterInQueueIds'] = $filterInQueueIds; - null !== $freeText && $obj['freeText'] = $freeText; - null !== $key && $obj['key'] = $key; - null !== $name && $obj['name'] = $name; - null !== $position && $obj['position'] = $position; - null !== $possibleValues && $obj['possibleValues'] = $possibleValues; - null !== $queueBehaviour && $obj['queueBehaviour'] = $queueBehaviour; - null !== $type && $obj['type'] = $type; - null !== $valueRequired && $obj['valueRequired'] = $valueRequired; - null !== $webhooks && $obj['webhooks'] = $webhooks; - - return $obj; + $self = new self; + + null !== $builtIn && $self['builtIn'] = $builtIn; + null !== $description && $self['description'] = $description; + null !== $filterInQueueIDs && $self['filterInQueueIDs'] = $filterInQueueIDs; + null !== $freeText && $self['freeText'] = $freeText; + null !== $key && $self['key'] = $key; + null !== $name && $self['name'] = $name; + null !== $position && $self['position'] = $position; + null !== $possibleValues && $self['possibleValues'] = $possibleValues; + null !== $queueBehaviour && $self['queueBehaviour'] = $queueBehaviour; + null !== $type && $self['type'] = $type; + null !== $valueRequired && $self['valueRequired'] = $valueRequired; + null !== $webhooks && $self['webhooks'] = $webhooks; + + return $self; } /** @@ -182,10 +182,10 @@ public static function with( */ public function withBuiltIn(?bool $builtIn): self { - $obj = clone $this; - $obj['builtIn'] = $builtIn; + $self = clone $this; + $self['builtIn'] = $builtIn; - return $obj; + return $self; } /** @@ -193,10 +193,10 @@ public function withBuiltIn(?bool $builtIn): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -206,10 +206,10 @@ public function withDescription(?string $description): self */ public function withFilterInQueueIDs(array $filterInQueueIDs): self { - $obj = clone $this; - $obj['filterInQueueIds'] = $filterInQueueIDs; + $self = clone $this; + $self['filterInQueueIDs'] = $filterInQueueIDs; - return $obj; + return $self; } /** @@ -217,10 +217,10 @@ public function withFilterInQueueIDs(array $filterInQueueIDs): self */ public function withFreeText(bool $freeText): self { - $obj = clone $this; - $obj['freeText'] = $freeText; + $self = clone $this; + $self['freeText'] = $freeText; - return $obj; + return $self; } /** @@ -228,10 +228,10 @@ public function withFreeText(bool $freeText): self */ public function withKey(?string $key): self { - $obj = clone $this; - $obj['key'] = $key; + $self = clone $this; + $self['key'] = $key; - return $obj; + return $self; } /** @@ -239,10 +239,10 @@ public function withKey(?string $key): self */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -252,10 +252,10 @@ public function withName(string $name): self */ public function withPosition(Position|string $position): self { - $obj = clone $this; - $obj['position'] = $position; + $self = clone $this; + $self['position'] = $position; - return $obj; + return $self; } /** @@ -265,10 +265,10 @@ public function withPosition(Position|string $position): self */ public function withPossibleValues(array $possibleValues): self { - $obj = clone $this; - $obj['possibleValues'] = $possibleValues; + $self = clone $this; + $self['possibleValues'] = $possibleValues; - return $obj; + return $self; } /** @@ -279,10 +279,10 @@ public function withPossibleValues(array $possibleValues): self public function withQueueBehaviour( QueueBehaviour|string $queueBehaviour ): self { - $obj = clone $this; - $obj['queueBehaviour'] = $queueBehaviour; + $self = clone $this; + $self['queueBehaviour'] = $queueBehaviour; - return $obj; + return $self; } /** @@ -292,10 +292,10 @@ public function withQueueBehaviour( */ public function withType(Type|string|null $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } /** @@ -303,10 +303,10 @@ public function withType(Type|string|null $type): self */ public function withValueRequired(bool $valueRequired): self { - $obj = clone $this; - $obj['valueRequired'] = $valueRequired; + $self = clone $this; + $self['valueRequired'] = $valueRequired; - return $obj; + return $self; } /** @@ -318,9 +318,9 @@ public function withValueRequired(bool $valueRequired): self */ public function withWebhooks(array $webhooks): self { - $obj = clone $this; - $obj['webhooks'] = $webhooks; + $self = clone $this; + $self['webhooks'] = $webhooks; - return $obj; + return $self; } } diff --git a/src/Actions/ActionUpdateParams/PossibleValue.php b/src/Actions/ActionUpdateParams/PossibleValue.php index 1ac637b..e77a725 100644 --- a/src/Actions/ActionUpdateParams/PossibleValue.php +++ b/src/Actions/ActionUpdateParams/PossibleValue.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Actions\ActionUpdateParams; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,7 +19,7 @@ final class PossibleValue implements BaseModel /** * The value of the action. */ - #[Api] + #[Required] public string $value; /** @@ -48,11 +48,11 @@ public function __construct() */ public static function with(string $value): self { - $obj = new self; + $self = new self; - $obj['value'] = $value; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -60,9 +60,9 @@ public static function with(string $value): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj['value'] = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Actions/ActionUpdateParams/Webhook.php b/src/Actions/ActionUpdateParams/Webhook.php index 47504d3..9e76c62 100644 --- a/src/Actions/ActionUpdateParams/Webhook.php +++ b/src/Actions/ActionUpdateParams/Webhook.php @@ -4,7 +4,8 @@ namespace ModerationAPI\Actions\ActionUpdateParams; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -21,25 +22,25 @@ final class Webhook implements BaseModel /** * The webhook's name, used to identify it in the dashboard. */ - #[Api] + #[Required] public string $name; /** * The webhook's URL. We'll call this URL when the event occurs. */ - #[Api] + #[Required] public string $url; /** * ID of an existing webhook or undefined if this is a new webhook. */ - #[Api(optional: true)] + #[Optional] public ?string $id; /** * The webhook's description. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** @@ -72,15 +73,15 @@ public static function with( ?string $id = null, ?string $description = null ): self { - $obj = new self; + $self = new self; - $obj['name'] = $name; - $obj['url'] = $url; + $self['name'] = $name; + $self['url'] = $url; - null !== $id && $obj['id'] = $id; - null !== $description && $obj['description'] = $description; + null !== $id && $self['id'] = $id; + null !== $description && $self['description'] = $description; - return $obj; + return $self; } /** @@ -88,10 +89,10 @@ public static function with( */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -99,10 +100,10 @@ public function withName(string $name): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -110,10 +111,10 @@ public function withURL(string $url): self */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -121,9 +122,9 @@ public function withID(string $id): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } } diff --git a/src/Actions/ActionUpdateResponse.php b/src/Actions/ActionUpdateResponse.php index 60f788c..9bb8c28 100644 --- a/src/Actions/ActionUpdateResponse.php +++ b/src/Actions/ActionUpdateResponse.php @@ -8,18 +8,17 @@ use ModerationAPI\Actions\ActionUpdateResponse\PossibleValue; use ModerationAPI\Actions\ActionUpdateResponse\QueueBehaviour; use ModerationAPI\Actions\ActionUpdateResponse\Type; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type ActionUpdateResponseShape = array{ * id: string, * builtIn: bool|null, * createdAt: string, - * filterInQueueIds: list, + * filterInQueueIDs: list, * freeText: bool, * name: string, * position: value-of, @@ -31,49 +30,47 @@ * type?: value-of|null, * } */ -final class ActionUpdateResponse implements BaseModel, ResponseConverter +final class ActionUpdateResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * The ID of the action. */ - #[Api] + #[Required] public string $id; /** * Whether the action is a built-in action or a custom one. */ - #[Api] + #[Required] public ?bool $builtIn; /** * The date the action was created. */ - #[Api] + #[Required] public string $createdAt; /** * The IDs of the queues the action is available in. * - * @var list $filterInQueueIds + * @var list $filterInQueueIDs */ - #[Api(list: 'string')] - public array $filterInQueueIds; + #[Required('filterInQueueIds', list: 'string')] + public array $filterInQueueIDs; /** * Whether the action allows any text to be entered as a value or if it must be one of the possible values. */ - #[Api] + #[Required] public bool $freeText; /** * The name of the action. */ - #[Api] + #[Required] public string $name; /** @@ -81,7 +78,7 @@ final class ActionUpdateResponse implements BaseModel, ResponseConverter * * @var value-of $position */ - #[Api(enum: Position::class)] + #[Required(enum: Position::class)] public string $position; /** @@ -89,7 +86,7 @@ final class ActionUpdateResponse implements BaseModel, ResponseConverter * * @var list $possibleValues */ - #[Api(list: PossibleValue::class)] + #[Required(list: PossibleValue::class)] public array $possibleValues; /** @@ -97,25 +94,25 @@ final class ActionUpdateResponse implements BaseModel, ResponseConverter * * @var value-of $queueBehaviour */ - #[Api(enum: QueueBehaviour::class)] + #[Required(enum: QueueBehaviour::class)] public string $queueBehaviour; /** * Whether the action requires a value to be executed. */ - #[Api] + #[Required] public bool $valueRequired; /** * The description of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $description; /** * User defined key of the action. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $key; /** @@ -123,7 +120,7 @@ final class ActionUpdateResponse implements BaseModel, ResponseConverter * * @var value-of|null $type */ - #[Api(enum: Type::class, nullable: true, optional: true)] + #[Optional(enum: Type::class, nullable: true)] public ?string $type; /** @@ -135,7 +132,7 @@ final class ActionUpdateResponse implements BaseModel, ResponseConverter * id: ..., * builtIn: ..., * createdAt: ..., - * filterInQueueIds: ..., + * filterInQueueIDs: ..., * freeText: ..., * name: ..., * position: ..., @@ -171,7 +168,7 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $filterInQueueIds + * @param list $filterInQueueIDs * @param Position|value-of $position * @param list $possibleValues * @param QueueBehaviour|value-of $queueBehaviour @@ -182,7 +179,7 @@ public static function with( string $createdAt, string $name, ?bool $builtIn = false, - array $filterInQueueIds = [], + array $filterInQueueIDs = [], bool $freeText = false, Position|string $position = 'ALL_QUEUES', array $possibleValues = [], @@ -192,24 +189,24 @@ public static function with( ?string $key = null, Type|string|null $type = null, ): self { - $obj = new self; - - $obj['id'] = $id; - $obj['builtIn'] = $builtIn; - $obj['createdAt'] = $createdAt; - $obj['filterInQueueIds'] = $filterInQueueIds; - $obj['freeText'] = $freeText; - $obj['name'] = $name; - $obj['position'] = $position; - $obj['possibleValues'] = $possibleValues; - $obj['queueBehaviour'] = $queueBehaviour; - $obj['valueRequired'] = $valueRequired; - - null !== $description && $obj['description'] = $description; - null !== $key && $obj['key'] = $key; - null !== $type && $obj['type'] = $type; - - return $obj; + $self = new self; + + $self['id'] = $id; + $self['builtIn'] = $builtIn; + $self['createdAt'] = $createdAt; + $self['filterInQueueIDs'] = $filterInQueueIDs; + $self['freeText'] = $freeText; + $self['name'] = $name; + $self['position'] = $position; + $self['possibleValues'] = $possibleValues; + $self['queueBehaviour'] = $queueBehaviour; + $self['valueRequired'] = $valueRequired; + + null !== $description && $self['description'] = $description; + null !== $key && $self['key'] = $key; + null !== $type && $self['type'] = $type; + + return $self; } /** @@ -217,10 +214,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -228,10 +225,10 @@ public function withID(string $id): self */ public function withBuiltIn(?bool $builtIn): self { - $obj = clone $this; - $obj['builtIn'] = $builtIn; + $self = clone $this; + $self['builtIn'] = $builtIn; - return $obj; + return $self; } /** @@ -239,10 +236,10 @@ public function withBuiltIn(?bool $builtIn): self */ public function withCreatedAt(string $createdAt): self { - $obj = clone $this; - $obj['createdAt'] = $createdAt; + $self = clone $this; + $self['createdAt'] = $createdAt; - return $obj; + return $self; } /** @@ -252,10 +249,10 @@ public function withCreatedAt(string $createdAt): self */ public function withFilterInQueueIDs(array $filterInQueueIDs): self { - $obj = clone $this; - $obj['filterInQueueIds'] = $filterInQueueIDs; + $self = clone $this; + $self['filterInQueueIDs'] = $filterInQueueIDs; - return $obj; + return $self; } /** @@ -263,10 +260,10 @@ public function withFilterInQueueIDs(array $filterInQueueIDs): self */ public function withFreeText(bool $freeText): self { - $obj = clone $this; - $obj['freeText'] = $freeText; + $self = clone $this; + $self['freeText'] = $freeText; - return $obj; + return $self; } /** @@ -274,10 +271,10 @@ public function withFreeText(bool $freeText): self */ public function withName(string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -287,10 +284,10 @@ public function withName(string $name): self */ public function withPosition(Position|string $position): self { - $obj = clone $this; - $obj['position'] = $position; + $self = clone $this; + $self['position'] = $position; - return $obj; + return $self; } /** @@ -300,10 +297,10 @@ public function withPosition(Position|string $position): self */ public function withPossibleValues(array $possibleValues): self { - $obj = clone $this; - $obj['possibleValues'] = $possibleValues; + $self = clone $this; + $self['possibleValues'] = $possibleValues; - return $obj; + return $self; } /** @@ -314,10 +311,10 @@ public function withPossibleValues(array $possibleValues): self public function withQueueBehaviour( QueueBehaviour|string $queueBehaviour ): self { - $obj = clone $this; - $obj['queueBehaviour'] = $queueBehaviour; + $self = clone $this; + $self['queueBehaviour'] = $queueBehaviour; - return $obj; + return $self; } /** @@ -325,10 +322,10 @@ public function withQueueBehaviour( */ public function withValueRequired(bool $valueRequired): self { - $obj = clone $this; - $obj['valueRequired'] = $valueRequired; + $self = clone $this; + $self['valueRequired'] = $valueRequired; - return $obj; + return $self; } /** @@ -336,10 +333,10 @@ public function withValueRequired(bool $valueRequired): self */ public function withDescription(?string $description): self { - $obj = clone $this; - $obj['description'] = $description; + $self = clone $this; + $self['description'] = $description; - return $obj; + return $self; } /** @@ -347,10 +344,10 @@ public function withDescription(?string $description): self */ public function withKey(?string $key): self { - $obj = clone $this; - $obj['key'] = $key; + $self = clone $this; + $self['key'] = $key; - return $obj; + return $self; } /** @@ -360,9 +357,9 @@ public function withKey(?string $key): self */ public function withType(Type|string|null $type): self { - $obj = clone $this; - $obj['type'] = $type; + $self = clone $this; + $self['type'] = $type; - return $obj; + return $self; } } diff --git a/src/Actions/ActionUpdateResponse/PossibleValue.php b/src/Actions/ActionUpdateResponse/PossibleValue.php index e16dfab..7e5eb99 100644 --- a/src/Actions/ActionUpdateResponse/PossibleValue.php +++ b/src/Actions/ActionUpdateResponse/PossibleValue.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Actions\ActionUpdateResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,7 +19,7 @@ final class PossibleValue implements BaseModel /** * The value of the action. */ - #[Api] + #[Required] public string $value; /** @@ -48,11 +48,11 @@ public function __construct() */ public static function with(string $value): self { - $obj = new self; + $self = new self; - $obj['value'] = $value; + $self['value'] = $value; - return $obj; + return $self; } /** @@ -60,9 +60,9 @@ public static function with(string $value): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj['value'] = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Actions/Execute/ExecuteExecuteByIDParams.php b/src/Actions/Execute/ExecuteExecuteByIDParams.php index 7c09d3f..d64792e 100644 --- a/src/Actions/Execute/ExecuteExecuteByIDParams.php +++ b/src/Actions/Execute/ExecuteExecuteByIDParams.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Actions\Execute; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Concerns\SdkParams; use ModerationAPI\Core\Contracts\BaseModel; @@ -16,9 +16,9 @@ * @see ModerationAPI\Services\Actions\ExecuteService::executeByID() * * @phpstan-type ExecuteExecuteByIDParamsShape = array{ - * authorIds?: list, - * contentIds?: list, - * queueId?: string, + * authorIDs?: list, + * contentIDs?: list, + * queueID?: string, * value?: string, * } */ @@ -31,29 +31,29 @@ final class ExecuteExecuteByIDParams implements BaseModel /** * IDs of the authors to apply the action to. * - * @var list|null $authorIds + * @var list|null $authorIDs */ - #[Api(list: 'string', optional: true)] - public ?array $authorIds; + #[Optional('authorIds', list: 'string')] + public ?array $authorIDs; /** * The IDs of the content items to perform the action on. * - * @var list|null $contentIds + * @var list|null $contentIDs */ - #[Api(list: 'string', optional: true)] - public ?array $contentIds; + #[Optional('contentIds', list: 'string')] + public ?array $contentIDs; /** * The ID of the queue the action was performed from if any. */ - #[Api(optional: true)] - public ?string $queueId; + #[Optional('queueId')] + public ?string $queueID; /** * The value of the action. Useful to set a reason for the action etc. */ - #[Api(optional: true)] + #[Optional] public ?string $value; public function __construct() @@ -66,23 +66,23 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $authorIds - * @param list $contentIds + * @param list $authorIDs + * @param list $contentIDs */ public static function with( - ?array $authorIds = null, - ?array $contentIds = null, - ?string $queueId = null, + ?array $authorIDs = null, + ?array $contentIDs = null, + ?string $queueID = null, ?string $value = null, ): self { - $obj = new self; + $self = new self; - null !== $authorIds && $obj['authorIds'] = $authorIds; - null !== $contentIds && $obj['contentIds'] = $contentIds; - null !== $queueId && $obj['queueId'] = $queueId; - null !== $value && $obj['value'] = $value; + null !== $authorIDs && $self['authorIDs'] = $authorIDs; + null !== $contentIDs && $self['contentIDs'] = $contentIDs; + null !== $queueID && $self['queueID'] = $queueID; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** @@ -92,10 +92,10 @@ public static function with( */ public function withAuthorIDs(array $authorIDs): self { - $obj = clone $this; - $obj['authorIds'] = $authorIDs; + $self = clone $this; + $self['authorIDs'] = $authorIDs; - return $obj; + return $self; } /** @@ -105,10 +105,10 @@ public function withAuthorIDs(array $authorIDs): self */ public function withContentIDs(array $contentIDs): self { - $obj = clone $this; - $obj['contentIds'] = $contentIDs; + $self = clone $this; + $self['contentIDs'] = $contentIDs; - return $obj; + return $self; } /** @@ -116,10 +116,10 @@ public function withContentIDs(array $contentIDs): self */ public function withQueueID(string $queueID): self { - $obj = clone $this; - $obj['queueId'] = $queueID; + $self = clone $this; + $self['queueID'] = $queueID; - return $obj; + return $self; } /** @@ -127,9 +127,9 @@ public function withQueueID(string $queueID): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj['value'] = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Actions/Execute/ExecuteExecuteByIDResponse.php b/src/Actions/Execute/ExecuteExecuteByIDResponse.php index d5e6976..c7e4a37 100644 --- a/src/Actions/Execute/ExecuteExecuteByIDResponse.php +++ b/src/Actions/Execute/ExecuteExecuteByIDResponse.php @@ -4,42 +4,38 @@ namespace ModerationAPI\Actions\Execute; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type ExecuteExecuteByIDResponseShape = array{ - * actionId: string, ids: list, success: bool + * actionID: string, ids: list, success: bool * } */ -final class ExecuteExecuteByIDResponse implements BaseModel, ResponseConverter +final class ExecuteExecuteByIDResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * The ID of the action. */ - #[Api] - public string $actionId; + #[Required('actionId')] + public string $actionID; /** * The IDs of the content items. * * @var list $ids */ - #[Api(list: 'string')] + #[Required(list: 'string')] public array $ids; /** * Action executed successfully. */ - #[Api] + #[Required] public bool $success; /** @@ -47,7 +43,7 @@ final class ExecuteExecuteByIDResponse implements BaseModel, ResponseConverter * * To enforce required parameters use * ``` - * ExecuteExecuteByIDResponse::with(actionId: ..., ids: ..., success: ...) + * ExecuteExecuteByIDResponse::with(actionID: ..., ids: ..., success: ...) * ``` * * Otherwise ensure the following setters are called @@ -72,17 +68,17 @@ public function __construct() * @param list $ids */ public static function with( - string $actionId, + string $actionID, array $ids, bool $success ): self { - $obj = new self; + $self = new self; - $obj['actionId'] = $actionId; - $obj['ids'] = $ids; - $obj['success'] = $success; + $self['actionID'] = $actionID; + $self['ids'] = $ids; + $self['success'] = $success; - return $obj; + return $self; } /** @@ -90,10 +86,10 @@ public static function with( */ public function withActionID(string $actionID): self { - $obj = clone $this; - $obj['actionId'] = $actionID; + $self = clone $this; + $self['actionID'] = $actionID; - return $obj; + return $self; } /** @@ -103,10 +99,10 @@ public function withActionID(string $actionID): self */ public function withIDs(array $ids): self { - $obj = clone $this; - $obj['ids'] = $ids; + $self = clone $this; + $self['ids'] = $ids; - return $obj; + return $self; } /** @@ -114,9 +110,9 @@ public function withIDs(array $ids): self */ public function withSuccess(bool $success): self { - $obj = clone $this; - $obj['success'] = $success; + $self = clone $this; + $self['success'] = $success; - return $obj; + return $self; } } diff --git a/src/Actions/Execute/ExecuteExecuteParams.php b/src/Actions/Execute/ExecuteExecuteParams.php index 406ffea..2073f29 100644 --- a/src/Actions/Execute/ExecuteExecuteParams.php +++ b/src/Actions/Execute/ExecuteExecuteParams.php @@ -4,7 +4,8 @@ namespace ModerationAPI\Actions\Execute; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Concerns\SdkParams; use ModerationAPI\Core\Contracts\BaseModel; @@ -16,10 +17,10 @@ * * @phpstan-type ExecuteExecuteParamsShape = array{ * actionKey: string, - * authorIds?: list, - * contentIds?: list, + * authorIDs?: list, + * contentIDs?: list, * duration?: float, - * queueId?: string, + * queueID?: string, * value?: string, * } */ @@ -32,41 +33,41 @@ final class ExecuteExecuteParams implements BaseModel /** * ID or key of the action to execute. */ - #[Api] + #[Required] public string $actionKey; /** * IDs of the authors to apply the action to. Provide this or contentIds. * - * @var list|null $authorIds + * @var list|null $authorIDs */ - #[Api(list: 'string', optional: true)] - public ?array $authorIds; + #[Optional('authorIds', list: 'string')] + public ?array $authorIDs; /** * IDs of the content items to apply the action to. Provide this or authorIds. * - * @var list|null $contentIds + * @var list|null $contentIDs */ - #[Api(list: 'string', optional: true)] - public ?array $contentIds; + #[Optional('contentIds', list: 'string')] + public ?array $contentIDs; /** * Optional duration in milliseconds for actions with timeouts. */ - #[Api(optional: true)] + #[Optional] public ?float $duration; /** * Optional queue ID if the action is queue-specific. */ - #[Api(optional: true)] - public ?string $queueId; + #[Optional('queueId')] + public ?string $queueID; /** * Optional value to provide with the action. */ - #[Api(optional: true)] + #[Optional] public ?string $value; /** @@ -93,28 +94,28 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param list $authorIds - * @param list $contentIds + * @param list $authorIDs + * @param list $contentIDs */ public static function with( string $actionKey, - ?array $authorIds = null, - ?array $contentIds = null, + ?array $authorIDs = null, + ?array $contentIDs = null, ?float $duration = null, - ?string $queueId = null, + ?string $queueID = null, ?string $value = null, ): self { - $obj = new self; + $self = new self; - $obj['actionKey'] = $actionKey; + $self['actionKey'] = $actionKey; - null !== $authorIds && $obj['authorIds'] = $authorIds; - null !== $contentIds && $obj['contentIds'] = $contentIds; - null !== $duration && $obj['duration'] = $duration; - null !== $queueId && $obj['queueId'] = $queueId; - null !== $value && $obj['value'] = $value; + null !== $authorIDs && $self['authorIDs'] = $authorIDs; + null !== $contentIDs && $self['contentIDs'] = $contentIDs; + null !== $duration && $self['duration'] = $duration; + null !== $queueID && $self['queueID'] = $queueID; + null !== $value && $self['value'] = $value; - return $obj; + return $self; } /** @@ -122,10 +123,10 @@ public static function with( */ public function withActionKey(string $actionKey): self { - $obj = clone $this; - $obj['actionKey'] = $actionKey; + $self = clone $this; + $self['actionKey'] = $actionKey; - return $obj; + return $self; } /** @@ -135,10 +136,10 @@ public function withActionKey(string $actionKey): self */ public function withAuthorIDs(array $authorIDs): self { - $obj = clone $this; - $obj['authorIds'] = $authorIDs; + $self = clone $this; + $self['authorIDs'] = $authorIDs; - return $obj; + return $self; } /** @@ -148,10 +149,10 @@ public function withAuthorIDs(array $authorIDs): self */ public function withContentIDs(array $contentIDs): self { - $obj = clone $this; - $obj['contentIds'] = $contentIDs; + $self = clone $this; + $self['contentIDs'] = $contentIDs; - return $obj; + return $self; } /** @@ -159,10 +160,10 @@ public function withContentIDs(array $contentIDs): self */ public function withDuration(float $duration): self { - $obj = clone $this; - $obj['duration'] = $duration; + $self = clone $this; + $self['duration'] = $duration; - return $obj; + return $self; } /** @@ -170,10 +171,10 @@ public function withDuration(float $duration): self */ public function withQueueID(string $queueID): self { - $obj = clone $this; - $obj['queueId'] = $queueID; + $self = clone $this; + $self['queueID'] = $queueID; - return $obj; + return $self; } /** @@ -181,9 +182,9 @@ public function withQueueID(string $queueID): self */ public function withValue(string $value): self { - $obj = clone $this; - $obj['value'] = $value; + $self = clone $this; + $self['value'] = $value; - return $obj; + return $self; } } diff --git a/src/Actions/Execute/ExecuteExecuteResponse.php b/src/Actions/Execute/ExecuteExecuteResponse.php index 2eece6f..6b941bf 100644 --- a/src/Actions/Execute/ExecuteExecuteResponse.php +++ b/src/Actions/Execute/ExecuteExecuteResponse.php @@ -4,28 +4,24 @@ namespace ModerationAPI\Actions\Execute; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * Execution result. * * @phpstan-type ExecuteExecuteResponseShape = array{success: bool} */ -final class ExecuteExecuteResponse implements BaseModel, ResponseConverter +final class ExecuteExecuteResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Whether the action was executed successfully. */ - #[Api] + #[Required] public bool $success; /** @@ -54,11 +50,11 @@ public function __construct() */ public static function with(bool $success): self { - $obj = new self; + $self = new self; - $obj['success'] = $success; + $self['success'] = $success; - return $obj; + return $self; } /** @@ -66,9 +62,9 @@ public static function with(bool $success): self */ public function withSuccess(bool $success): self { - $obj = clone $this; - $obj['success'] = $success; + $self = clone $this; + $self['success'] = $success; - return $obj; + return $self; } } diff --git a/src/Auth/AuthGetResponse.php b/src/Auth/AuthGetResponse.php index 947bd13..835c986 100644 --- a/src/Auth/AuthGetResponse.php +++ b/src/Auth/AuthGetResponse.php @@ -4,32 +4,28 @@ namespace ModerationAPI\Auth; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type AuthGetResponseShape = array{message: string, status: string} */ -final class AuthGetResponse implements BaseModel, ResponseConverter +final class AuthGetResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Message of the authentication. */ - #[Api] + #[Required] public string $message; /** * Status of the authentication. */ - #[Api] + #[Required] public string $status; /** @@ -58,12 +54,12 @@ public function __construct() */ public static function with(string $message, string $status): self { - $obj = new self; + $self = new self; - $obj['message'] = $message; - $obj['status'] = $status; + $self['message'] = $message; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -71,10 +67,10 @@ public static function with(string $message, string $status): self */ public function withMessage(string $message): self { - $obj = clone $this; - $obj['message'] = $message; + $self = clone $this; + $self['message'] = $message; - return $obj; + return $self; } /** @@ -82,9 +78,9 @@ public function withMessage(string $message): self */ public function withStatus(string $status): self { - $obj = clone $this; - $obj['status'] = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } } diff --git a/src/Auth/AuthNewResponse.php b/src/Auth/AuthNewResponse.php index 0bb3710..17dbd12 100644 --- a/src/Auth/AuthNewResponse.php +++ b/src/Auth/AuthNewResponse.php @@ -4,40 +4,36 @@ namespace ModerationAPI\Auth; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type AuthNewResponseShape = array{ * message: string, project: string, status: string * } */ -final class AuthNewResponse implements BaseModel, ResponseConverter +final class AuthNewResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Message of the authentication. */ - #[Api] + #[Required] public string $message; /** * Name of the authenticated project. */ - #[Api] + #[Required] public string $project; /** * Status of the authentication. */ - #[Api] + #[Required] public string $status; /** @@ -69,13 +65,13 @@ public static function with( string $project, string $status ): self { - $obj = new self; + $self = new self; - $obj['message'] = $message; - $obj['project'] = $project; - $obj['status'] = $status; + $self['message'] = $message; + $self['project'] = $project; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -83,10 +79,10 @@ public static function with( */ public function withMessage(string $message): self { - $obj = clone $this; - $obj['message'] = $message; + $self = clone $this; + $self['message'] = $message; - return $obj; + return $self; } /** @@ -94,10 +90,10 @@ public function withMessage(string $message): self */ public function withProject(string $project): self { - $obj = clone $this; - $obj['project'] = $project; + $self = clone $this; + $self['project'] = $project; - return $obj; + return $self; } /** @@ -105,9 +101,9 @@ public function withProject(string $project): self */ public function withStatus(string $status): self { - $obj = clone $this; - $obj['status'] = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorCreateParams.php b/src/Authors/AuthorCreateParams.php index 9f62ed9..5956b1e 100644 --- a/src/Authors/AuthorCreateParams.php +++ b/src/Authors/AuthorCreateParams.php @@ -5,7 +5,8 @@ namespace ModerationAPI\Authors; use ModerationAPI\Authors\AuthorCreateParams\Metadata; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Concerns\SdkParams; use ModerationAPI\Core\Contracts\BaseModel; @@ -16,20 +17,20 @@ * @see ModerationAPI\Services\AuthorsService::create() * * @phpstan-type AuthorCreateParamsShape = array{ - * external_id: string, + * externalID: string, * email?: string|null, - * external_link?: string|null, - * first_seen?: float, - * last_seen?: float, - * manual_trust_level?: float|null, + * externalLink?: string|null, + * firstSeen?: float, + * lastSeen?: float, + * manualTrustLevel?: float|null, * metadata?: Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * }, * name?: string|null, - * profile_picture?: string|null, + * profilePicture?: string|null, * } */ final class AuthorCreateParams implements BaseModel @@ -41,60 +42,60 @@ final class AuthorCreateParams implements BaseModel /** * External ID of the user, typically the ID of the author in your database. */ - #[Api] - public string $external_id; + #[Required('external_id')] + public string $externalID; /** * Author email address. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $email; /** * URL of the author's external profile. */ - #[Api(nullable: true, optional: true)] - public ?string $external_link; + #[Optional('external_link', nullable: true)] + public ?string $externalLink; /** * Timestamp when author first appeared. */ - #[Api(optional: true)] - public ?float $first_seen; + #[Optional('first_seen')] + public ?float $firstSeen; /** * Timestamp of last activity. */ - #[Api(optional: true)] - public ?float $last_seen; + #[Optional('last_seen')] + public ?float $lastSeen; - #[Api(nullable: true, optional: true)] - public ?float $manual_trust_level; + #[Optional('manual_trust_level', nullable: true)] + public ?float $manualTrustLevel; /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. */ - #[Api(optional: true)] + #[Optional] public ?Metadata $metadata; /** * Author name or identifier. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $name; /** * URL of the author's profile picture. */ - #[Api(nullable: true, optional: true)] - public ?string $profile_picture; + #[Optional('profile_picture', nullable: true)] + public ?string $profilePicture; /** * `new AuthorCreateParams()` is missing required properties by the API. * * To enforce required parameters use * ``` - * AuthorCreateParams::with(external_id: ...) + * AuthorCreateParams::with(externalID: ...) * ``` * * Otherwise ensure the following setters are called @@ -114,37 +115,37 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata */ public static function with( - string $external_id, + string $externalID, ?string $email = null, - ?string $external_link = null, - ?float $first_seen = null, - ?float $last_seen = null, - ?float $manual_trust_level = null, + ?string $externalLink = null, + ?float $firstSeen = null, + ?float $lastSeen = null, + ?float $manualTrustLevel = null, Metadata|array|null $metadata = null, ?string $name = null, - ?string $profile_picture = null, + ?string $profilePicture = null, ): self { - $obj = new self; + $self = new self; - $obj['external_id'] = $external_id; + $self['externalID'] = $externalID; - null !== $email && $obj['email'] = $email; - null !== $external_link && $obj['external_link'] = $external_link; - null !== $first_seen && $obj['first_seen'] = $first_seen; - null !== $last_seen && $obj['last_seen'] = $last_seen; - null !== $manual_trust_level && $obj['manual_trust_level'] = $manual_trust_level; - null !== $metadata && $obj['metadata'] = $metadata; - null !== $name && $obj['name'] = $name; - null !== $profile_picture && $obj['profile_picture'] = $profile_picture; + null !== $email && $self['email'] = $email; + null !== $externalLink && $self['externalLink'] = $externalLink; + null !== $firstSeen && $self['firstSeen'] = $firstSeen; + null !== $lastSeen && $self['lastSeen'] = $lastSeen; + null !== $manualTrustLevel && $self['manualTrustLevel'] = $manualTrustLevel; + null !== $metadata && $self['metadata'] = $metadata; + null !== $name && $self['name'] = $name; + null !== $profilePicture && $self['profilePicture'] = $profilePicture; - return $obj; + return $self; } /** @@ -152,10 +153,10 @@ public static function with( */ public function withExternalID(string $externalID): self { - $obj = clone $this; - $obj['external_id'] = $externalID; + $self = clone $this; + $self['externalID'] = $externalID; - return $obj; + return $self; } /** @@ -163,10 +164,10 @@ public function withExternalID(string $externalID): self */ public function withEmail(?string $email): self { - $obj = clone $this; - $obj['email'] = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } /** @@ -174,10 +175,10 @@ public function withEmail(?string $email): self */ public function withExternalLink(?string $externalLink): self { - $obj = clone $this; - $obj['external_link'] = $externalLink; + $self = clone $this; + $self['externalLink'] = $externalLink; - return $obj; + return $self; } /** @@ -185,10 +186,10 @@ public function withExternalLink(?string $externalLink): self */ public function withFirstSeen(float $firstSeen): self { - $obj = clone $this; - $obj['first_seen'] = $firstSeen; + $self = clone $this; + $self['firstSeen'] = $firstSeen; - return $obj; + return $self; } /** @@ -196,36 +197,36 @@ public function withFirstSeen(float $firstSeen): self */ public function withLastSeen(float $lastSeen): self { - $obj = clone $this; - $obj['last_seen'] = $lastSeen; + $self = clone $this; + $self['lastSeen'] = $lastSeen; - return $obj; + return $self; } public function withManualTrustLevel(?float $manualTrustLevel): self { - $obj = clone $this; - $obj['manual_trust_level'] = $manualTrustLevel; + $self = clone $this; + $self['manualTrustLevel'] = $manualTrustLevel; - return $obj; + return $self; } /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata */ public function withMetadata(Metadata|array $metadata): self { - $obj = clone $this; - $obj['metadata'] = $metadata; + $self = clone $this; + $self['metadata'] = $metadata; - return $obj; + return $self; } /** @@ -233,10 +234,10 @@ public function withMetadata(Metadata|array $metadata): self */ public function withName(?string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -244,9 +245,9 @@ public function withName(?string $name): self */ public function withProfilePicture(?string $profilePicture): self { - $obj = clone $this; - $obj['profile_picture'] = $profilePicture; + $self = clone $this; + $self['profilePicture'] = $profilePicture; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorCreateParams/Metadata.php b/src/Authors/AuthorCreateParams/Metadata.php index b7c1fe8..e20bd20 100644 --- a/src/Authors/AuthorCreateParams/Metadata.php +++ b/src/Authors/AuthorCreateParams/Metadata.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorCreateParams; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -12,10 +12,10 @@ * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @phpstan-type MetadataShape = array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } */ final class Metadata implements BaseModel @@ -26,26 +26,26 @@ final class Metadata implements BaseModel /** * Whether the author's email is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $email_verified; + #[Optional('email_verified', nullable: true)] + public ?bool $emailVerified; /** * Whether the author's identity is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $identity_verified; + #[Optional('identity_verified', nullable: true)] + public ?bool $identityVerified; /** * Whether the author is a paying customer. */ - #[Api(nullable: true, optional: true)] - public ?bool $is_paying_customer; + #[Optional('is_paying_customer', nullable: true)] + public ?bool $isPayingCustomer; /** * Whether the author's phone number is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $phone_verified; + #[Optional('phone_verified', nullable: true)] + public ?bool $phoneVerified; public function __construct() { @@ -58,19 +58,19 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?bool $email_verified = null, - ?bool $identity_verified = null, - ?bool $is_paying_customer = null, - ?bool $phone_verified = null, + ?bool $emailVerified = null, + ?bool $identityVerified = null, + ?bool $isPayingCustomer = null, + ?bool $phoneVerified = null, ): self { - $obj = new self; + $self = new self; - null !== $email_verified && $obj['email_verified'] = $email_verified; - null !== $identity_verified && $obj['identity_verified'] = $identity_verified; - null !== $is_paying_customer && $obj['is_paying_customer'] = $is_paying_customer; - null !== $phone_verified && $obj['phone_verified'] = $phone_verified; + null !== $emailVerified && $self['emailVerified'] = $emailVerified; + null !== $identityVerified && $self['identityVerified'] = $identityVerified; + null !== $isPayingCustomer && $self['isPayingCustomer'] = $isPayingCustomer; + null !== $phoneVerified && $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } /** @@ -78,10 +78,10 @@ public static function with( */ public function withEmailVerified(?bool $emailVerified): self { - $obj = clone $this; - $obj['email_verified'] = $emailVerified; + $self = clone $this; + $self['emailVerified'] = $emailVerified; - return $obj; + return $self; } /** @@ -89,10 +89,10 @@ public function withEmailVerified(?bool $emailVerified): self */ public function withIdentityVerified(?bool $identityVerified): self { - $obj = clone $this; - $obj['identity_verified'] = $identityVerified; + $self = clone $this; + $self['identityVerified'] = $identityVerified; - return $obj; + return $self; } /** @@ -100,10 +100,10 @@ public function withIdentityVerified(?bool $identityVerified): self */ public function withIsPayingCustomer(?bool $isPayingCustomer): self { - $obj = clone $this; - $obj['is_paying_customer'] = $isPayingCustomer; + $self = clone $this; + $self['isPayingCustomer'] = $isPayingCustomer; - return $obj; + return $self; } /** @@ -111,9 +111,9 @@ public function withIsPayingCustomer(?bool $isPayingCustomer): self */ public function withPhoneVerified(?bool $phoneVerified): self { - $obj = clone $this; - $obj['phone_verified'] = $phoneVerified; + $self = clone $this; + $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorDeleteResponse.php b/src/Authors/AuthorDeleteResponse.php index 43d00f3..276e48c 100644 --- a/src/Authors/AuthorDeleteResponse.php +++ b/src/Authors/AuthorDeleteResponse.php @@ -4,23 +4,19 @@ namespace ModerationAPI\Authors; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type AuthorDeleteResponseShape = array{success: bool} */ -final class AuthorDeleteResponse implements BaseModel, ResponseConverter +final class AuthorDeleteResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - - #[Api] + #[Required] public bool $success; /** @@ -49,18 +45,18 @@ public function __construct() */ public static function with(bool $success): self { - $obj = new self; + $self = new self; - $obj['success'] = $success; + $self['success'] = $success; - return $obj; + return $self; } public function withSuccess(bool $success): self { - $obj = clone $this; - $obj['success'] = $success; + $self = clone $this; + $self['success'] = $success; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorGetResponse.php b/src/Authors/AuthorGetResponse.php index 44c6af7..482e8d6 100644 --- a/src/Authors/AuthorGetResponse.php +++ b/src/Authors/AuthorGetResponse.php @@ -10,123 +10,120 @@ use ModerationAPI\Authors\AuthorGetResponse\RiskEvaluation; use ModerationAPI\Authors\AuthorGetResponse\Status; use ModerationAPI\Authors\AuthorGetResponse\TrustLevel; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type AuthorGetResponseShape = array{ * id: string, * block: Block|null, - * first_seen: float, - * last_seen: float, + * firstSeen: float, + * lastSeen: float, * metadata: Metadata, * metrics: Metrics, - * risk_evaluation: RiskEvaluation|null, + * riskEvaluation: RiskEvaluation|null, * status: value-of, - * trust_level: TrustLevel, + * trustLevel: TrustLevel, * email?: string|null, - * external_id?: string|null, - * external_link?: string|null, - * last_incident?: float|null, + * externalID?: string|null, + * externalLink?: string|null, + * lastIncident?: float|null, * name?: string|null, - * profile_picture?: string|null, + * profilePicture?: string|null, * } */ -final class AuthorGetResponse implements BaseModel, ResponseConverter +final class AuthorGetResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Author ID in Moderation API. */ - #[Api] + #[Required] public string $id; /** * Block or suspension details, if applicable. Null if the author is enabled. */ - #[Api] + #[Required] public ?Block $block; /** * Timestamp when author first appeared. */ - #[Api] - public float $first_seen; + #[Required('first_seen')] + public float $firstSeen; /** * Timestamp of last activity. */ - #[Api] - public float $last_seen; + #[Required('last_seen')] + public float $lastSeen; /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. */ - #[Api] + #[Required] public Metadata $metadata; - #[Api] + #[Required] public Metrics $metrics; /** * Risk assessment details, if available. */ - #[Api] - public ?RiskEvaluation $risk_evaluation; + #[Required('risk_evaluation')] + public ?RiskEvaluation $riskEvaluation; /** * Current author status. * * @var value-of $status */ - #[Api(enum: Status::class)] + #[Required(enum: Status::class)] public string $status; - #[Api] - public TrustLevel $trust_level; + #[Required('trust_level')] + public TrustLevel $trustLevel; /** * Author email address. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $email; /** * The author's ID from your system. */ - #[Api(nullable: true, optional: true)] - public ?string $external_id; + #[Optional('external_id', nullable: true)] + public ?string $externalID; /** * URL of the author's external profile. */ - #[Api(nullable: true, optional: true)] - public ?string $external_link; + #[Optional('external_link', nullable: true)] + public ?string $externalLink; /** * Timestamp of last incident. */ - #[Api(nullable: true, optional: true)] - public ?float $last_incident; + #[Optional('last_incident', nullable: true)] + public ?float $lastIncident; /** * Author name or identifier. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $name; /** * URL of the author's profile picture. */ - #[Api(nullable: true, optional: true)] - public ?string $profile_picture; + #[Optional('profile_picture', nullable: true)] + public ?string $profilePicture; /** * `new AuthorGetResponse()` is missing required properties by the API. @@ -136,13 +133,13 @@ final class AuthorGetResponse implements BaseModel, ResponseConverter * AuthorGetResponse::with( * id: ..., * block: ..., - * first_seen: ..., - * last_seen: ..., + * firstSeen: ..., + * lastSeen: ..., * metadata: ..., * metrics: ..., - * risk_evaluation: ..., + * riskEvaluation: ..., * status: ..., - * trust_level: ..., + * trustLevel: ..., * ) * ``` * @@ -173,55 +170,55 @@ public function __construct() * * @param Block|array{reason?: string|null, until?: float|null}|null $block * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata * @param Metrics|array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } $metrics - * @param RiskEvaluation|array{risk_level?: float|null}|null $risk_evaluation + * @param RiskEvaluation|array{riskLevel?: float|null}|null $riskEvaluation * @param Status|value-of $status - * @param TrustLevel|array{level: float, manual: bool} $trust_level + * @param TrustLevel|array{level: float, manual: bool} $trustLevel */ public static function with( string $id, Block|array|null $block, - float $first_seen, - float $last_seen, + float $firstSeen, + float $lastSeen, Metadata|array $metadata, Metrics|array $metrics, - RiskEvaluation|array|null $risk_evaluation, + RiskEvaluation|array|null $riskEvaluation, Status|string $status, - TrustLevel|array $trust_level, + TrustLevel|array $trustLevel, ?string $email = null, - ?string $external_id = null, - ?string $external_link = null, - ?float $last_incident = null, + ?string $externalID = null, + ?string $externalLink = null, + ?float $lastIncident = null, ?string $name = null, - ?string $profile_picture = null, + ?string $profilePicture = null, ): self { - $obj = new self; - - $obj['id'] = $id; - $obj['block'] = $block; - $obj['first_seen'] = $first_seen; - $obj['last_seen'] = $last_seen; - $obj['metadata'] = $metadata; - $obj['metrics'] = $metrics; - $obj['risk_evaluation'] = $risk_evaluation; - $obj['status'] = $status; - $obj['trust_level'] = $trust_level; - - null !== $email && $obj['email'] = $email; - null !== $external_id && $obj['external_id'] = $external_id; - null !== $external_link && $obj['external_link'] = $external_link; - null !== $last_incident && $obj['last_incident'] = $last_incident; - null !== $name && $obj['name'] = $name; - null !== $profile_picture && $obj['profile_picture'] = $profile_picture; - - return $obj; + $self = new self; + + $self['id'] = $id; + $self['block'] = $block; + $self['firstSeen'] = $firstSeen; + $self['lastSeen'] = $lastSeen; + $self['metadata'] = $metadata; + $self['metrics'] = $metrics; + $self['riskEvaluation'] = $riskEvaluation; + $self['status'] = $status; + $self['trustLevel'] = $trustLevel; + + null !== $email && $self['email'] = $email; + null !== $externalID && $self['externalID'] = $externalID; + null !== $externalLink && $self['externalLink'] = $externalLink; + null !== $lastIncident && $self['lastIncident'] = $lastIncident; + null !== $name && $self['name'] = $name; + null !== $profilePicture && $self['profilePicture'] = $profilePicture; + + return $self; } /** @@ -229,10 +226,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -242,10 +239,10 @@ public function withID(string $id): self */ public function withBlock(Block|array|null $block): self { - $obj = clone $this; - $obj['block'] = $block; + $self = clone $this; + $self['block'] = $block; - return $obj; + return $self; } /** @@ -253,10 +250,10 @@ public function withBlock(Block|array|null $block): self */ public function withFirstSeen(float $firstSeen): self { - $obj = clone $this; - $obj['first_seen'] = $firstSeen; + $self = clone $this; + $self['firstSeen'] = $firstSeen; - return $obj; + return $self; } /** @@ -264,55 +261,55 @@ public function withFirstSeen(float $firstSeen): self */ public function withLastSeen(float $lastSeen): self { - $obj = clone $this; - $obj['last_seen'] = $lastSeen; + $self = clone $this; + $self['lastSeen'] = $lastSeen; - return $obj; + return $self; } /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata */ public function withMetadata(Metadata|array $metadata): self { - $obj = clone $this; - $obj['metadata'] = $metadata; + $self = clone $this; + $self['metadata'] = $metadata; - return $obj; + return $self; } /** * @param Metrics|array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } $metrics */ public function withMetrics(Metrics|array $metrics): self { - $obj = clone $this; - $obj['metrics'] = $metrics; + $self = clone $this; + $self['metrics'] = $metrics; - return $obj; + return $self; } /** * Risk assessment details, if available. * - * @param RiskEvaluation|array{risk_level?: float|null}|null $riskEvaluation + * @param RiskEvaluation|array{riskLevel?: float|null}|null $riskEvaluation */ public function withRiskEvaluation( RiskEvaluation|array|null $riskEvaluation ): self { - $obj = clone $this; - $obj['risk_evaluation'] = $riskEvaluation; + $self = clone $this; + $self['riskEvaluation'] = $riskEvaluation; - return $obj; + return $self; } /** @@ -322,10 +319,10 @@ public function withRiskEvaluation( */ public function withStatus(Status|string $status): self { - $obj = clone $this; - $obj['status'] = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -333,10 +330,10 @@ public function withStatus(Status|string $status): self */ public function withTrustLevel(TrustLevel|array $trustLevel): self { - $obj = clone $this; - $obj['trust_level'] = $trustLevel; + $self = clone $this; + $self['trustLevel'] = $trustLevel; - return $obj; + return $self; } /** @@ -344,10 +341,10 @@ public function withTrustLevel(TrustLevel|array $trustLevel): self */ public function withEmail(?string $email): self { - $obj = clone $this; - $obj['email'] = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } /** @@ -355,10 +352,10 @@ public function withEmail(?string $email): self */ public function withExternalID(?string $externalID): self { - $obj = clone $this; - $obj['external_id'] = $externalID; + $self = clone $this; + $self['externalID'] = $externalID; - return $obj; + return $self; } /** @@ -366,10 +363,10 @@ public function withExternalID(?string $externalID): self */ public function withExternalLink(?string $externalLink): self { - $obj = clone $this; - $obj['external_link'] = $externalLink; + $self = clone $this; + $self['externalLink'] = $externalLink; - return $obj; + return $self; } /** @@ -377,10 +374,10 @@ public function withExternalLink(?string $externalLink): self */ public function withLastIncident(?float $lastIncident): self { - $obj = clone $this; - $obj['last_incident'] = $lastIncident; + $self = clone $this; + $self['lastIncident'] = $lastIncident; - return $obj; + return $self; } /** @@ -388,10 +385,10 @@ public function withLastIncident(?float $lastIncident): self */ public function withName(?string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -399,9 +396,9 @@ public function withName(?string $name): self */ public function withProfilePicture(?string $profilePicture): self { - $obj = clone $this; - $obj['profile_picture'] = $profilePicture; + $self = clone $this; + $self['profilePicture'] = $profilePicture; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorGetResponse/Block.php b/src/Authors/AuthorGetResponse/Block.php index c1bb986..a192cba 100644 --- a/src/Authors/AuthorGetResponse/Block.php +++ b/src/Authors/AuthorGetResponse/Block.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorGetResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class Block implements BaseModel /** * The moderators reason why the author was blocked or suspended. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * The timestamp until which they are blocked if the author is suspended. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?float $until; public function __construct() @@ -44,12 +44,12 @@ public static function with( ?string $reason = null, ?float $until = null ): self { - $obj = new self; + $self = new self; - null !== $reason && $obj['reason'] = $reason; - null !== $until && $obj['until'] = $until; + null !== $reason && $self['reason'] = $reason; + null !== $until && $self['until'] = $until; - return $obj; + return $self; } /** @@ -57,10 +57,10 @@ public static function with( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj['reason'] = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -68,9 +68,9 @@ public function withReason(?string $reason): self */ public function withUntil(?float $until): self { - $obj = clone $this; - $obj['until'] = $until; + $self = clone $this; + $self['until'] = $until; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorGetResponse/Metadata.php b/src/Authors/AuthorGetResponse/Metadata.php index b9edf25..a3f3763 100644 --- a/src/Authors/AuthorGetResponse/Metadata.php +++ b/src/Authors/AuthorGetResponse/Metadata.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorGetResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -12,10 +12,10 @@ * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @phpstan-type MetadataShape = array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } */ final class Metadata implements BaseModel @@ -26,26 +26,26 @@ final class Metadata implements BaseModel /** * Whether the author's email is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $email_verified; + #[Optional('email_verified', nullable: true)] + public ?bool $emailVerified; /** * Whether the author's identity is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $identity_verified; + #[Optional('identity_verified', nullable: true)] + public ?bool $identityVerified; /** * Whether the author is a paying customer. */ - #[Api(nullable: true, optional: true)] - public ?bool $is_paying_customer; + #[Optional('is_paying_customer', nullable: true)] + public ?bool $isPayingCustomer; /** * Whether the author's phone number is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $phone_verified; + #[Optional('phone_verified', nullable: true)] + public ?bool $phoneVerified; public function __construct() { @@ -58,19 +58,19 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?bool $email_verified = null, - ?bool $identity_verified = null, - ?bool $is_paying_customer = null, - ?bool $phone_verified = null, + ?bool $emailVerified = null, + ?bool $identityVerified = null, + ?bool $isPayingCustomer = null, + ?bool $phoneVerified = null, ): self { - $obj = new self; + $self = new self; - null !== $email_verified && $obj['email_verified'] = $email_verified; - null !== $identity_verified && $obj['identity_verified'] = $identity_verified; - null !== $is_paying_customer && $obj['is_paying_customer'] = $is_paying_customer; - null !== $phone_verified && $obj['phone_verified'] = $phone_verified; + null !== $emailVerified && $self['emailVerified'] = $emailVerified; + null !== $identityVerified && $self['identityVerified'] = $identityVerified; + null !== $isPayingCustomer && $self['isPayingCustomer'] = $isPayingCustomer; + null !== $phoneVerified && $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } /** @@ -78,10 +78,10 @@ public static function with( */ public function withEmailVerified(?bool $emailVerified): self { - $obj = clone $this; - $obj['email_verified'] = $emailVerified; + $self = clone $this; + $self['emailVerified'] = $emailVerified; - return $obj; + return $self; } /** @@ -89,10 +89,10 @@ public function withEmailVerified(?bool $emailVerified): self */ public function withIdentityVerified(?bool $identityVerified): self { - $obj = clone $this; - $obj['identity_verified'] = $identityVerified; + $self = clone $this; + $self['identityVerified'] = $identityVerified; - return $obj; + return $self; } /** @@ -100,10 +100,10 @@ public function withIdentityVerified(?bool $identityVerified): self */ public function withIsPayingCustomer(?bool $isPayingCustomer): self { - $obj = clone $this; - $obj['is_paying_customer'] = $isPayingCustomer; + $self = clone $this; + $self['isPayingCustomer'] = $isPayingCustomer; - return $obj; + return $self; } /** @@ -111,9 +111,9 @@ public function withIsPayingCustomer(?bool $isPayingCustomer): self */ public function withPhoneVerified(?bool $phoneVerified): self { - $obj = clone $this; - $obj['phone_verified'] = $phoneVerified; + $self = clone $this; + $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorGetResponse/Metrics.php b/src/Authors/AuthorGetResponse/Metrics.php index ec443d1..a19ea48 100644 --- a/src/Authors/AuthorGetResponse/Metrics.php +++ b/src/Authors/AuthorGetResponse/Metrics.php @@ -4,13 +4,14 @@ namespace ModerationAPI\Authors\AuthorGetResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * @phpstan-type MetricsShape = array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } */ final class Metrics implements BaseModel @@ -21,27 +22,27 @@ final class Metrics implements BaseModel /** * Number of flagged content pieces. */ - #[Api] - public float $flagged_content; + #[Required('flagged_content')] + public float $flaggedContent; /** * Total pieces of content. */ - #[Api] - public float $total_content; + #[Required('total_content')] + public float $totalContent; /** * Average sentiment score of content (-1 to 1). Requires a sentiment model in your project. */ - #[Api(nullable: true, optional: true)] - public ?float $average_sentiment; + #[Optional('average_sentiment', nullable: true)] + public ?float $averageSentiment; /** * `new Metrics()` is missing required properties by the API. * * To enforce required parameters use * ``` - * Metrics::with(flagged_content: ..., total_content: ...) + * Metrics::with(flaggedContent: ..., totalContent: ...) * ``` * * Otherwise ensure the following setters are called @@ -61,18 +62,18 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - float $flagged_content, - float $total_content, - ?float $average_sentiment = null, + float $flaggedContent, + float $totalContent, + ?float $averageSentiment = null ): self { - $obj = new self; + $self = new self; - $obj['flagged_content'] = $flagged_content; - $obj['total_content'] = $total_content; + $self['flaggedContent'] = $flaggedContent; + $self['totalContent'] = $totalContent; - null !== $average_sentiment && $obj['average_sentiment'] = $average_sentiment; + null !== $averageSentiment && $self['averageSentiment'] = $averageSentiment; - return $obj; + return $self; } /** @@ -80,10 +81,10 @@ public static function with( */ public function withFlaggedContent(float $flaggedContent): self { - $obj = clone $this; - $obj['flagged_content'] = $flaggedContent; + $self = clone $this; + $self['flaggedContent'] = $flaggedContent; - return $obj; + return $self; } /** @@ -91,10 +92,10 @@ public function withFlaggedContent(float $flaggedContent): self */ public function withTotalContent(float $totalContent): self { - $obj = clone $this; - $obj['total_content'] = $totalContent; + $self = clone $this; + $self['totalContent'] = $totalContent; - return $obj; + return $self; } /** @@ -102,9 +103,9 @@ public function withTotalContent(float $totalContent): self */ public function withAverageSentiment(?float $averageSentiment): self { - $obj = clone $this; - $obj['average_sentiment'] = $averageSentiment; + $self = clone $this; + $self['averageSentiment'] = $averageSentiment; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorGetResponse/RiskEvaluation.php b/src/Authors/AuthorGetResponse/RiskEvaluation.php index 8bb2b90..5549c99 100644 --- a/src/Authors/AuthorGetResponse/RiskEvaluation.php +++ b/src/Authors/AuthorGetResponse/RiskEvaluation.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Authors\AuthorGetResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Risk assessment details, if available. * - * @phpstan-type RiskEvaluationShape = array{risk_level?: float|null} + * @phpstan-type RiskEvaluationShape = array{riskLevel?: float|null} */ final class RiskEvaluation implements BaseModel { @@ -21,8 +21,8 @@ final class RiskEvaluation implements BaseModel /** * Calculated risk level based on more than 10 behavioral signals. */ - #[Api(nullable: true, optional: true)] - public ?float $risk_level; + #[Optional('risk_level', nullable: true)] + public ?float $riskLevel; public function __construct() { @@ -34,13 +34,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(?float $risk_level = null): self + public static function with(?float $riskLevel = null): self { - $obj = new self; + $self = new self; - null !== $risk_level && $obj['risk_level'] = $risk_level; + null !== $riskLevel && $self['riskLevel'] = $riskLevel; - return $obj; + return $self; } /** @@ -48,9 +48,9 @@ public static function with(?float $risk_level = null): self */ public function withRiskLevel(?float $riskLevel): self { - $obj = clone $this; - $obj['risk_level'] = $riskLevel; + $self = clone $this; + $self['riskLevel'] = $riskLevel; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorGetResponse/TrustLevel.php b/src/Authors/AuthorGetResponse/TrustLevel.php index d4768d8..b7e7ead 100644 --- a/src/Authors/AuthorGetResponse/TrustLevel.php +++ b/src/Authors/AuthorGetResponse/TrustLevel.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorGetResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class TrustLevel implements BaseModel /** * Author trust level (-1, 0, 1, 2, 3, or 4). */ - #[Api] + #[Required] public float $level; /** * True if the trust level was set manually by a moderator. */ - #[Api] + #[Required] public bool $manual; /** @@ -54,12 +54,12 @@ public function __construct() */ public static function with(float $level, bool $manual): self { - $obj = new self; + $self = new self; - $obj['level'] = $level; - $obj['manual'] = $manual; + $self['level'] = $level; + $self['manual'] = $manual; - return $obj; + return $self; } /** @@ -67,10 +67,10 @@ public static function with(float $level, bool $manual): self */ public function withLevel(float $level): self { - $obj = clone $this; - $obj['level'] = $level; + $self = clone $this; + $self['level'] = $level; - return $obj; + return $self; } /** @@ -78,9 +78,9 @@ public function withLevel(float $level): self */ public function withManual(bool $manual): self { - $obj = clone $this; - $obj['manual'] = $manual; + $self = clone $this; + $self['manual'] = $manual; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorListParams.php b/src/Authors/AuthorListParams.php index 1d88c10..f8717de 100644 --- a/src/Authors/AuthorListParams.php +++ b/src/Authors/AuthorListParams.php @@ -6,7 +6,7 @@ use ModerationAPI\Authors\AuthorListParams\SortBy; use ModerationAPI\Authors\AuthorListParams\SortDirection; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Concerns\SdkParams; use ModerationAPI\Core\Contracts\BaseModel; @@ -32,29 +32,29 @@ final class AuthorListParams implements BaseModel use SdkModel; use SdkParams; - #[Api(optional: true)] + #[Optional] public ?string $contentTypes; - #[Api(optional: true)] + #[Optional] public ?string $lastActiveDate; - #[Api(optional: true)] + #[Optional] public ?string $memberSinceDate; /** * Page number to fetch. */ - #[Api(optional: true)] + #[Optional] public ?float $pageNumber; /** * Number of authors per page. */ - #[Api(optional: true)] + #[Optional] public ?float $pageSize; /** @var value-of|null $sortBy */ - #[Api(enum: SortBy::class, optional: true)] + #[Optional(enum: SortBy::class)] public ?string $sortBy; /** @@ -62,7 +62,7 @@ final class AuthorListParams implements BaseModel * * @var value-of|null $sortDirection */ - #[Api(enum: SortDirection::class, optional: true)] + #[Optional(enum: SortDirection::class)] public ?string $sortDirection; public function __construct() @@ -87,41 +87,41 @@ public static function with( SortBy|string|null $sortBy = null, SortDirection|string|null $sortDirection = null, ): self { - $obj = new self; + $self = new self; - null !== $contentTypes && $obj['contentTypes'] = $contentTypes; - null !== $lastActiveDate && $obj['lastActiveDate'] = $lastActiveDate; - null !== $memberSinceDate && $obj['memberSinceDate'] = $memberSinceDate; - null !== $pageNumber && $obj['pageNumber'] = $pageNumber; - null !== $pageSize && $obj['pageSize'] = $pageSize; - null !== $sortBy && $obj['sortBy'] = $sortBy; - null !== $sortDirection && $obj['sortDirection'] = $sortDirection; + null !== $contentTypes && $self['contentTypes'] = $contentTypes; + null !== $lastActiveDate && $self['lastActiveDate'] = $lastActiveDate; + null !== $memberSinceDate && $self['memberSinceDate'] = $memberSinceDate; + null !== $pageNumber && $self['pageNumber'] = $pageNumber; + null !== $pageSize && $self['pageSize'] = $pageSize; + null !== $sortBy && $self['sortBy'] = $sortBy; + null !== $sortDirection && $self['sortDirection'] = $sortDirection; - return $obj; + return $self; } public function withContentTypes(string $contentTypes): self { - $obj = clone $this; - $obj['contentTypes'] = $contentTypes; + $self = clone $this; + $self['contentTypes'] = $contentTypes; - return $obj; + return $self; } public function withLastActiveDate(string $lastActiveDate): self { - $obj = clone $this; - $obj['lastActiveDate'] = $lastActiveDate; + $self = clone $this; + $self['lastActiveDate'] = $lastActiveDate; - return $obj; + return $self; } public function withMemberSinceDate(string $memberSinceDate): self { - $obj = clone $this; - $obj['memberSinceDate'] = $memberSinceDate; + $self = clone $this; + $self['memberSinceDate'] = $memberSinceDate; - return $obj; + return $self; } /** @@ -129,10 +129,10 @@ public function withMemberSinceDate(string $memberSinceDate): self */ public function withPageNumber(float $pageNumber): self { - $obj = clone $this; - $obj['pageNumber'] = $pageNumber; + $self = clone $this; + $self['pageNumber'] = $pageNumber; - return $obj; + return $self; } /** @@ -140,10 +140,10 @@ public function withPageNumber(float $pageNumber): self */ public function withPageSize(float $pageSize): self { - $obj = clone $this; - $obj['pageSize'] = $pageSize; + $self = clone $this; + $self['pageSize'] = $pageSize; - return $obj; + return $self; } /** @@ -151,10 +151,10 @@ public function withPageSize(float $pageSize): self */ public function withSortBy(SortBy|string $sortBy): self { - $obj = clone $this; - $obj['sortBy'] = $sortBy; + $self = clone $this; + $self['sortBy'] = $sortBy; - return $obj; + return $self; } /** @@ -164,9 +164,9 @@ public function withSortBy(SortBy|string $sortBy): self */ public function withSortDirection(SortDirection|string $sortDirection): self { - $obj = clone $this; - $obj['sortDirection'] = $sortDirection; + $self = clone $this; + $self['sortDirection'] = $sortDirection; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorListResponse.php b/src/Authors/AuthorListResponse.php index 37df57f..0097476 100644 --- a/src/Authors/AuthorListResponse.php +++ b/src/Authors/AuthorListResponse.php @@ -12,29 +12,25 @@ use ModerationAPI\Authors\AuthorListResponse\Author\Status; use ModerationAPI\Authors\AuthorListResponse\Author\TrustLevel; use ModerationAPI\Authors\AuthorListResponse\Pagination; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type AuthorListResponseShape = array{ * authors: list, pagination: Pagination * } */ -final class AuthorListResponse implements BaseModel, ResponseConverter +final class AuthorListResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** @var list $authors */ - #[Api(list: Author::class)] + #[Required(list: Author::class)] public array $authors; - #[Api] + #[Required] public Pagination $pagination; /** @@ -64,19 +60,19 @@ public function __construct() * @param list, - * trust_level: TrustLevel, + * trustLevel: TrustLevel, * email?: string|null, - * external_id?: string|null, - * external_link?: string|null, - * last_incident?: float|null, + * externalID?: string|null, + * externalLink?: string|null, + * lastIncident?: float|null, * name?: string|null, - * profile_picture?: string|null, + * profilePicture?: string|null, * }> $authors * @param Pagination|array{ * hasNextPage: bool, @@ -90,39 +86,39 @@ public static function with( array $authors, Pagination|array $pagination ): self { - $obj = new self; + $self = new self; - $obj['authors'] = $authors; - $obj['pagination'] = $pagination; + $self['authors'] = $authors; + $self['pagination'] = $pagination; - return $obj; + return $self; } /** * @param list, - * trust_level: TrustLevel, + * trustLevel: TrustLevel, * email?: string|null, - * external_id?: string|null, - * external_link?: string|null, - * last_incident?: float|null, + * externalID?: string|null, + * externalLink?: string|null, + * lastIncident?: float|null, * name?: string|null, - * profile_picture?: string|null, + * profilePicture?: string|null, * }> $authors */ public function withAuthors(array $authors): self { - $obj = clone $this; - $obj['authors'] = $authors; + $self = clone $this; + $self['authors'] = $authors; - return $obj; + return $self; } /** @@ -136,9 +132,9 @@ public function withAuthors(array $authors): self */ public function withPagination(Pagination|array $pagination): self { - $obj = clone $this; - $obj['pagination'] = $pagination; + $self = clone $this; + $self['pagination'] = $pagination; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorListResponse/Author.php b/src/Authors/AuthorListResponse/Author.php index 9589485..3b7a556 100644 --- a/src/Authors/AuthorListResponse/Author.php +++ b/src/Authors/AuthorListResponse/Author.php @@ -10,7 +10,8 @@ use ModerationAPI\Authors\AuthorListResponse\Author\RiskEvaluation; use ModerationAPI\Authors\AuthorListResponse\Author\Status; use ModerationAPI\Authors\AuthorListResponse\Author\TrustLevel; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -18,19 +19,19 @@ * @phpstan-type AuthorShape = array{ * id: string, * block: Block|null, - * first_seen: float, - * last_seen: float, + * firstSeen: float, + * lastSeen: float, * metadata: Metadata, * metrics: Metrics, - * risk_evaluation: RiskEvaluation|null, + * riskEvaluation: RiskEvaluation|null, * status: value-of, - * trust_level: TrustLevel, + * trustLevel: TrustLevel, * email?: string|null, - * external_id?: string|null, - * external_link?: string|null, - * last_incident?: float|null, + * externalID?: string|null, + * externalLink?: string|null, + * lastIncident?: float|null, * name?: string|null, - * profile_picture?: string|null, + * profilePicture?: string|null, * } */ final class Author implements BaseModel @@ -41,88 +42,88 @@ final class Author implements BaseModel /** * Author ID in Moderation API. */ - #[Api] + #[Required] public string $id; /** * Block or suspension details, if applicable. Null if the author is enabled. */ - #[Api] + #[Required] public ?Block $block; /** * Timestamp when author first appeared. */ - #[Api] - public float $first_seen; + #[Required('first_seen')] + public float $firstSeen; /** * Timestamp of last activity. */ - #[Api] - public float $last_seen; + #[Required('last_seen')] + public float $lastSeen; /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. */ - #[Api] + #[Required] public Metadata $metadata; - #[Api] + #[Required] public Metrics $metrics; /** * Risk assessment details, if available. */ - #[Api] - public ?RiskEvaluation $risk_evaluation; + #[Required('risk_evaluation')] + public ?RiskEvaluation $riskEvaluation; /** * Current author status. * * @var value-of $status */ - #[Api(enum: Status::class)] + #[Required(enum: Status::class)] public string $status; - #[Api] - public TrustLevel $trust_level; + #[Required('trust_level')] + public TrustLevel $trustLevel; /** * Author email address. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $email; /** * The author's ID from your system. */ - #[Api(nullable: true, optional: true)] - public ?string $external_id; + #[Optional('external_id', nullable: true)] + public ?string $externalID; /** * URL of the author's external profile. */ - #[Api(nullable: true, optional: true)] - public ?string $external_link; + #[Optional('external_link', nullable: true)] + public ?string $externalLink; /** * Timestamp of last incident. */ - #[Api(nullable: true, optional: true)] - public ?float $last_incident; + #[Optional('last_incident', nullable: true)] + public ?float $lastIncident; /** * Author name or identifier. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $name; /** * URL of the author's profile picture. */ - #[Api(nullable: true, optional: true)] - public ?string $profile_picture; + #[Optional('profile_picture', nullable: true)] + public ?string $profilePicture; /** * `new Author()` is missing required properties by the API. @@ -132,13 +133,13 @@ final class Author implements BaseModel * Author::with( * id: ..., * block: ..., - * first_seen: ..., - * last_seen: ..., + * firstSeen: ..., + * lastSeen: ..., * metadata: ..., * metrics: ..., - * risk_evaluation: ..., + * riskEvaluation: ..., * status: ..., - * trust_level: ..., + * trustLevel: ..., * ) * ``` * @@ -169,55 +170,55 @@ public function __construct() * * @param Block|array{reason?: string|null, until?: float|null}|null $block * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata * @param Metrics|array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } $metrics - * @param RiskEvaluation|array{risk_level?: float|null}|null $risk_evaluation + * @param RiskEvaluation|array{riskLevel?: float|null}|null $riskEvaluation * @param Status|value-of $status - * @param TrustLevel|array{level: float, manual: bool} $trust_level + * @param TrustLevel|array{level: float, manual: bool} $trustLevel */ public static function with( string $id, Block|array|null $block, - float $first_seen, - float $last_seen, + float $firstSeen, + float $lastSeen, Metadata|array $metadata, Metrics|array $metrics, - RiskEvaluation|array|null $risk_evaluation, + RiskEvaluation|array|null $riskEvaluation, Status|string $status, - TrustLevel|array $trust_level, + TrustLevel|array $trustLevel, ?string $email = null, - ?string $external_id = null, - ?string $external_link = null, - ?float $last_incident = null, + ?string $externalID = null, + ?string $externalLink = null, + ?float $lastIncident = null, ?string $name = null, - ?string $profile_picture = null, + ?string $profilePicture = null, ): self { - $obj = new self; - - $obj['id'] = $id; - $obj['block'] = $block; - $obj['first_seen'] = $first_seen; - $obj['last_seen'] = $last_seen; - $obj['metadata'] = $metadata; - $obj['metrics'] = $metrics; - $obj['risk_evaluation'] = $risk_evaluation; - $obj['status'] = $status; - $obj['trust_level'] = $trust_level; - - null !== $email && $obj['email'] = $email; - null !== $external_id && $obj['external_id'] = $external_id; - null !== $external_link && $obj['external_link'] = $external_link; - null !== $last_incident && $obj['last_incident'] = $last_incident; - null !== $name && $obj['name'] = $name; - null !== $profile_picture && $obj['profile_picture'] = $profile_picture; - - return $obj; + $self = new self; + + $self['id'] = $id; + $self['block'] = $block; + $self['firstSeen'] = $firstSeen; + $self['lastSeen'] = $lastSeen; + $self['metadata'] = $metadata; + $self['metrics'] = $metrics; + $self['riskEvaluation'] = $riskEvaluation; + $self['status'] = $status; + $self['trustLevel'] = $trustLevel; + + null !== $email && $self['email'] = $email; + null !== $externalID && $self['externalID'] = $externalID; + null !== $externalLink && $self['externalLink'] = $externalLink; + null !== $lastIncident && $self['lastIncident'] = $lastIncident; + null !== $name && $self['name'] = $name; + null !== $profilePicture && $self['profilePicture'] = $profilePicture; + + return $self; } /** @@ -225,10 +226,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -238,10 +239,10 @@ public function withID(string $id): self */ public function withBlock(Block|array|null $block): self { - $obj = clone $this; - $obj['block'] = $block; + $self = clone $this; + $self['block'] = $block; - return $obj; + return $self; } /** @@ -249,10 +250,10 @@ public function withBlock(Block|array|null $block): self */ public function withFirstSeen(float $firstSeen): self { - $obj = clone $this; - $obj['first_seen'] = $firstSeen; + $self = clone $this; + $self['firstSeen'] = $firstSeen; - return $obj; + return $self; } /** @@ -260,55 +261,55 @@ public function withFirstSeen(float $firstSeen): self */ public function withLastSeen(float $lastSeen): self { - $obj = clone $this; - $obj['last_seen'] = $lastSeen; + $self = clone $this; + $self['lastSeen'] = $lastSeen; - return $obj; + return $self; } /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata */ public function withMetadata(Metadata|array $metadata): self { - $obj = clone $this; - $obj['metadata'] = $metadata; + $self = clone $this; + $self['metadata'] = $metadata; - return $obj; + return $self; } /** * @param Metrics|array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } $metrics */ public function withMetrics(Metrics|array $metrics): self { - $obj = clone $this; - $obj['metrics'] = $metrics; + $self = clone $this; + $self['metrics'] = $metrics; - return $obj; + return $self; } /** * Risk assessment details, if available. * - * @param RiskEvaluation|array{risk_level?: float|null}|null $riskEvaluation + * @param RiskEvaluation|array{riskLevel?: float|null}|null $riskEvaluation */ public function withRiskEvaluation( RiskEvaluation|array|null $riskEvaluation ): self { - $obj = clone $this; - $obj['risk_evaluation'] = $riskEvaluation; + $self = clone $this; + $self['riskEvaluation'] = $riskEvaluation; - return $obj; + return $self; } /** @@ -318,10 +319,10 @@ public function withRiskEvaluation( */ public function withStatus(Status|string $status): self { - $obj = clone $this; - $obj['status'] = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -329,10 +330,10 @@ public function withStatus(Status|string $status): self */ public function withTrustLevel(TrustLevel|array $trustLevel): self { - $obj = clone $this; - $obj['trust_level'] = $trustLevel; + $self = clone $this; + $self['trustLevel'] = $trustLevel; - return $obj; + return $self; } /** @@ -340,10 +341,10 @@ public function withTrustLevel(TrustLevel|array $trustLevel): self */ public function withEmail(?string $email): self { - $obj = clone $this; - $obj['email'] = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } /** @@ -351,10 +352,10 @@ public function withEmail(?string $email): self */ public function withExternalID(?string $externalID): self { - $obj = clone $this; - $obj['external_id'] = $externalID; + $self = clone $this; + $self['externalID'] = $externalID; - return $obj; + return $self; } /** @@ -362,10 +363,10 @@ public function withExternalID(?string $externalID): self */ public function withExternalLink(?string $externalLink): self { - $obj = clone $this; - $obj['external_link'] = $externalLink; + $self = clone $this; + $self['externalLink'] = $externalLink; - return $obj; + return $self; } /** @@ -373,10 +374,10 @@ public function withExternalLink(?string $externalLink): self */ public function withLastIncident(?float $lastIncident): self { - $obj = clone $this; - $obj['last_incident'] = $lastIncident; + $self = clone $this; + $self['lastIncident'] = $lastIncident; - return $obj; + return $self; } /** @@ -384,10 +385,10 @@ public function withLastIncident(?float $lastIncident): self */ public function withName(?string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -395,9 +396,9 @@ public function withName(?string $name): self */ public function withProfilePicture(?string $profilePicture): self { - $obj = clone $this; - $obj['profile_picture'] = $profilePicture; + $self = clone $this; + $self['profilePicture'] = $profilePicture; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorListResponse/Author/Block.php b/src/Authors/AuthorListResponse/Author/Block.php index c746429..4ee4e7e 100644 --- a/src/Authors/AuthorListResponse/Author/Block.php +++ b/src/Authors/AuthorListResponse/Author/Block.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorListResponse\Author; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class Block implements BaseModel /** * The moderators reason why the author was blocked or suspended. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * The timestamp until which they are blocked if the author is suspended. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?float $until; public function __construct() @@ -44,12 +44,12 @@ public static function with( ?string $reason = null, ?float $until = null ): self { - $obj = new self; + $self = new self; - null !== $reason && $obj['reason'] = $reason; - null !== $until && $obj['until'] = $until; + null !== $reason && $self['reason'] = $reason; + null !== $until && $self['until'] = $until; - return $obj; + return $self; } /** @@ -57,10 +57,10 @@ public static function with( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj['reason'] = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -68,9 +68,9 @@ public function withReason(?string $reason): self */ public function withUntil(?float $until): self { - $obj = clone $this; - $obj['until'] = $until; + $self = clone $this; + $self['until'] = $until; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorListResponse/Author/Metadata.php b/src/Authors/AuthorListResponse/Author/Metadata.php index 1d88096..a03f9a4 100644 --- a/src/Authors/AuthorListResponse/Author/Metadata.php +++ b/src/Authors/AuthorListResponse/Author/Metadata.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorListResponse\Author; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -12,10 +12,10 @@ * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @phpstan-type MetadataShape = array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } */ final class Metadata implements BaseModel @@ -26,26 +26,26 @@ final class Metadata implements BaseModel /** * Whether the author's email is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $email_verified; + #[Optional('email_verified', nullable: true)] + public ?bool $emailVerified; /** * Whether the author's identity is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $identity_verified; + #[Optional('identity_verified', nullable: true)] + public ?bool $identityVerified; /** * Whether the author is a paying customer. */ - #[Api(nullable: true, optional: true)] - public ?bool $is_paying_customer; + #[Optional('is_paying_customer', nullable: true)] + public ?bool $isPayingCustomer; /** * Whether the author's phone number is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $phone_verified; + #[Optional('phone_verified', nullable: true)] + public ?bool $phoneVerified; public function __construct() { @@ -58,19 +58,19 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?bool $email_verified = null, - ?bool $identity_verified = null, - ?bool $is_paying_customer = null, - ?bool $phone_verified = null, + ?bool $emailVerified = null, + ?bool $identityVerified = null, + ?bool $isPayingCustomer = null, + ?bool $phoneVerified = null, ): self { - $obj = new self; + $self = new self; - null !== $email_verified && $obj['email_verified'] = $email_verified; - null !== $identity_verified && $obj['identity_verified'] = $identity_verified; - null !== $is_paying_customer && $obj['is_paying_customer'] = $is_paying_customer; - null !== $phone_verified && $obj['phone_verified'] = $phone_verified; + null !== $emailVerified && $self['emailVerified'] = $emailVerified; + null !== $identityVerified && $self['identityVerified'] = $identityVerified; + null !== $isPayingCustomer && $self['isPayingCustomer'] = $isPayingCustomer; + null !== $phoneVerified && $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } /** @@ -78,10 +78,10 @@ public static function with( */ public function withEmailVerified(?bool $emailVerified): self { - $obj = clone $this; - $obj['email_verified'] = $emailVerified; + $self = clone $this; + $self['emailVerified'] = $emailVerified; - return $obj; + return $self; } /** @@ -89,10 +89,10 @@ public function withEmailVerified(?bool $emailVerified): self */ public function withIdentityVerified(?bool $identityVerified): self { - $obj = clone $this; - $obj['identity_verified'] = $identityVerified; + $self = clone $this; + $self['identityVerified'] = $identityVerified; - return $obj; + return $self; } /** @@ -100,10 +100,10 @@ public function withIdentityVerified(?bool $identityVerified): self */ public function withIsPayingCustomer(?bool $isPayingCustomer): self { - $obj = clone $this; - $obj['is_paying_customer'] = $isPayingCustomer; + $self = clone $this; + $self['isPayingCustomer'] = $isPayingCustomer; - return $obj; + return $self; } /** @@ -111,9 +111,9 @@ public function withIsPayingCustomer(?bool $isPayingCustomer): self */ public function withPhoneVerified(?bool $phoneVerified): self { - $obj = clone $this; - $obj['phone_verified'] = $phoneVerified; + $self = clone $this; + $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorListResponse/Author/Metrics.php b/src/Authors/AuthorListResponse/Author/Metrics.php index 64aa202..a02cb5b 100644 --- a/src/Authors/AuthorListResponse/Author/Metrics.php +++ b/src/Authors/AuthorListResponse/Author/Metrics.php @@ -4,13 +4,14 @@ namespace ModerationAPI\Authors\AuthorListResponse\Author; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * @phpstan-type MetricsShape = array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } */ final class Metrics implements BaseModel @@ -21,27 +22,27 @@ final class Metrics implements BaseModel /** * Number of flagged content pieces. */ - #[Api] - public float $flagged_content; + #[Required('flagged_content')] + public float $flaggedContent; /** * Total pieces of content. */ - #[Api] - public float $total_content; + #[Required('total_content')] + public float $totalContent; /** * Average sentiment score of content (-1 to 1). Requires a sentiment model in your project. */ - #[Api(nullable: true, optional: true)] - public ?float $average_sentiment; + #[Optional('average_sentiment', nullable: true)] + public ?float $averageSentiment; /** * `new Metrics()` is missing required properties by the API. * * To enforce required parameters use * ``` - * Metrics::with(flagged_content: ..., total_content: ...) + * Metrics::with(flaggedContent: ..., totalContent: ...) * ``` * * Otherwise ensure the following setters are called @@ -61,18 +62,18 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - float $flagged_content, - float $total_content, - ?float $average_sentiment = null, + float $flaggedContent, + float $totalContent, + ?float $averageSentiment = null ): self { - $obj = new self; + $self = new self; - $obj['flagged_content'] = $flagged_content; - $obj['total_content'] = $total_content; + $self['flaggedContent'] = $flaggedContent; + $self['totalContent'] = $totalContent; - null !== $average_sentiment && $obj['average_sentiment'] = $average_sentiment; + null !== $averageSentiment && $self['averageSentiment'] = $averageSentiment; - return $obj; + return $self; } /** @@ -80,10 +81,10 @@ public static function with( */ public function withFlaggedContent(float $flaggedContent): self { - $obj = clone $this; - $obj['flagged_content'] = $flaggedContent; + $self = clone $this; + $self['flaggedContent'] = $flaggedContent; - return $obj; + return $self; } /** @@ -91,10 +92,10 @@ public function withFlaggedContent(float $flaggedContent): self */ public function withTotalContent(float $totalContent): self { - $obj = clone $this; - $obj['total_content'] = $totalContent; + $self = clone $this; + $self['totalContent'] = $totalContent; - return $obj; + return $self; } /** @@ -102,9 +103,9 @@ public function withTotalContent(float $totalContent): self */ public function withAverageSentiment(?float $averageSentiment): self { - $obj = clone $this; - $obj['average_sentiment'] = $averageSentiment; + $self = clone $this; + $self['averageSentiment'] = $averageSentiment; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorListResponse/Author/RiskEvaluation.php b/src/Authors/AuthorListResponse/Author/RiskEvaluation.php index 584cad0..0e6e09f 100644 --- a/src/Authors/AuthorListResponse/Author/RiskEvaluation.php +++ b/src/Authors/AuthorListResponse/Author/RiskEvaluation.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Authors\AuthorListResponse\Author; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Risk assessment details, if available. * - * @phpstan-type RiskEvaluationShape = array{risk_level?: float|null} + * @phpstan-type RiskEvaluationShape = array{riskLevel?: float|null} */ final class RiskEvaluation implements BaseModel { @@ -21,8 +21,8 @@ final class RiskEvaluation implements BaseModel /** * Calculated risk level based on more than 10 behavioral signals. */ - #[Api(nullable: true, optional: true)] - public ?float $risk_level; + #[Optional('risk_level', nullable: true)] + public ?float $riskLevel; public function __construct() { @@ -34,13 +34,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(?float $risk_level = null): self + public static function with(?float $riskLevel = null): self { - $obj = new self; + $self = new self; - null !== $risk_level && $obj['risk_level'] = $risk_level; + null !== $riskLevel && $self['riskLevel'] = $riskLevel; - return $obj; + return $self; } /** @@ -48,9 +48,9 @@ public static function with(?float $risk_level = null): self */ public function withRiskLevel(?float $riskLevel): self { - $obj = clone $this; - $obj['risk_level'] = $riskLevel; + $self = clone $this; + $self['riskLevel'] = $riskLevel; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorListResponse/Author/TrustLevel.php b/src/Authors/AuthorListResponse/Author/TrustLevel.php index 3008faf..6aad5b7 100644 --- a/src/Authors/AuthorListResponse/Author/TrustLevel.php +++ b/src/Authors/AuthorListResponse/Author/TrustLevel.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorListResponse\Author; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class TrustLevel implements BaseModel /** * Author trust level (-1, 0, 1, 2, 3, or 4). */ - #[Api] + #[Required] public float $level; /** * True if the trust level was set manually by a moderator. */ - #[Api] + #[Required] public bool $manual; /** @@ -54,12 +54,12 @@ public function __construct() */ public static function with(float $level, bool $manual): self { - $obj = new self; + $self = new self; - $obj['level'] = $level; - $obj['manual'] = $manual; + $self['level'] = $level; + $self['manual'] = $manual; - return $obj; + return $self; } /** @@ -67,10 +67,10 @@ public static function with(float $level, bool $manual): self */ public function withLevel(float $level): self { - $obj = clone $this; - $obj['level'] = $level; + $self = clone $this; + $self['level'] = $level; - return $obj; + return $self; } /** @@ -78,9 +78,9 @@ public function withLevel(float $level): self */ public function withManual(bool $manual): self { - $obj = clone $this; - $obj['manual'] = $manual; + $self = clone $this; + $self['manual'] = $manual; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorListResponse/Pagination.php b/src/Authors/AuthorListResponse/Pagination.php index cbf132d..f91da2e 100644 --- a/src/Authors/AuthorListResponse/Pagination.php +++ b/src/Authors/AuthorListResponse/Pagination.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorListResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -22,19 +22,19 @@ final class Pagination implements BaseModel /** @use SdkModel */ use SdkModel; - #[Api] + #[Required] public bool $hasNextPage; - #[Api] + #[Required] public bool $hasPreviousPage; - #[Api] + #[Required] public float $pageNumber; - #[Api] + #[Required] public float $pageSize; - #[Api] + #[Required] public float $total; /** @@ -79,54 +79,54 @@ public static function with( float $pageSize, float $total, ): self { - $obj = new self; + $self = new self; - $obj['hasNextPage'] = $hasNextPage; - $obj['hasPreviousPage'] = $hasPreviousPage; - $obj['pageNumber'] = $pageNumber; - $obj['pageSize'] = $pageSize; - $obj['total'] = $total; + $self['hasNextPage'] = $hasNextPage; + $self['hasPreviousPage'] = $hasPreviousPage; + $self['pageNumber'] = $pageNumber; + $self['pageSize'] = $pageSize; + $self['total'] = $total; - return $obj; + return $self; } public function withHasNextPage(bool $hasNextPage): self { - $obj = clone $this; - $obj['hasNextPage'] = $hasNextPage; + $self = clone $this; + $self['hasNextPage'] = $hasNextPage; - return $obj; + return $self; } public function withHasPreviousPage(bool $hasPreviousPage): self { - $obj = clone $this; - $obj['hasPreviousPage'] = $hasPreviousPage; + $self = clone $this; + $self['hasPreviousPage'] = $hasPreviousPage; - return $obj; + return $self; } public function withPageNumber(float $pageNumber): self { - $obj = clone $this; - $obj['pageNumber'] = $pageNumber; + $self = clone $this; + $self['pageNumber'] = $pageNumber; - return $obj; + return $self; } public function withPageSize(float $pageSize): self { - $obj = clone $this; - $obj['pageSize'] = $pageSize; + $self = clone $this; + $self['pageSize'] = $pageSize; - return $obj; + return $self; } public function withTotal(float $total): self { - $obj = clone $this; - $obj['total'] = $total; + $self = clone $this; + $self['total'] = $total; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorNewResponse.php b/src/Authors/AuthorNewResponse.php index d481a18..7accc08 100644 --- a/src/Authors/AuthorNewResponse.php +++ b/src/Authors/AuthorNewResponse.php @@ -10,123 +10,120 @@ use ModerationAPI\Authors\AuthorNewResponse\RiskEvaluation; use ModerationAPI\Authors\AuthorNewResponse\Status; use ModerationAPI\Authors\AuthorNewResponse\TrustLevel; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type AuthorNewResponseShape = array{ * id: string, * block: Block|null, - * first_seen: float, - * last_seen: float, + * firstSeen: float, + * lastSeen: float, * metadata: Metadata, * metrics: Metrics, - * risk_evaluation: RiskEvaluation|null, + * riskEvaluation: RiskEvaluation|null, * status: value-of, - * trust_level: TrustLevel, + * trustLevel: TrustLevel, * email?: string|null, - * external_id?: string|null, - * external_link?: string|null, - * last_incident?: float|null, + * externalID?: string|null, + * externalLink?: string|null, + * lastIncident?: float|null, * name?: string|null, - * profile_picture?: string|null, + * profilePicture?: string|null, * } */ -final class AuthorNewResponse implements BaseModel, ResponseConverter +final class AuthorNewResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Author ID in Moderation API. */ - #[Api] + #[Required] public string $id; /** * Block or suspension details, if applicable. Null if the author is enabled. */ - #[Api] + #[Required] public ?Block $block; /** * Timestamp when author first appeared. */ - #[Api] - public float $first_seen; + #[Required('first_seen')] + public float $firstSeen; /** * Timestamp of last activity. */ - #[Api] - public float $last_seen; + #[Required('last_seen')] + public float $lastSeen; /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. */ - #[Api] + #[Required] public Metadata $metadata; - #[Api] + #[Required] public Metrics $metrics; /** * Risk assessment details, if available. */ - #[Api] - public ?RiskEvaluation $risk_evaluation; + #[Required('risk_evaluation')] + public ?RiskEvaluation $riskEvaluation; /** * Current author status. * * @var value-of $status */ - #[Api(enum: Status::class)] + #[Required(enum: Status::class)] public string $status; - #[Api] - public TrustLevel $trust_level; + #[Required('trust_level')] + public TrustLevel $trustLevel; /** * Author email address. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $email; /** * The author's ID from your system. */ - #[Api(nullable: true, optional: true)] - public ?string $external_id; + #[Optional('external_id', nullable: true)] + public ?string $externalID; /** * URL of the author's external profile. */ - #[Api(nullable: true, optional: true)] - public ?string $external_link; + #[Optional('external_link', nullable: true)] + public ?string $externalLink; /** * Timestamp of last incident. */ - #[Api(nullable: true, optional: true)] - public ?float $last_incident; + #[Optional('last_incident', nullable: true)] + public ?float $lastIncident; /** * Author name or identifier. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $name; /** * URL of the author's profile picture. */ - #[Api(nullable: true, optional: true)] - public ?string $profile_picture; + #[Optional('profile_picture', nullable: true)] + public ?string $profilePicture; /** * `new AuthorNewResponse()` is missing required properties by the API. @@ -136,13 +133,13 @@ final class AuthorNewResponse implements BaseModel, ResponseConverter * AuthorNewResponse::with( * id: ..., * block: ..., - * first_seen: ..., - * last_seen: ..., + * firstSeen: ..., + * lastSeen: ..., * metadata: ..., * metrics: ..., - * risk_evaluation: ..., + * riskEvaluation: ..., * status: ..., - * trust_level: ..., + * trustLevel: ..., * ) * ``` * @@ -173,55 +170,55 @@ public function __construct() * * @param Block|array{reason?: string|null, until?: float|null}|null $block * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata * @param Metrics|array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } $metrics - * @param RiskEvaluation|array{risk_level?: float|null}|null $risk_evaluation + * @param RiskEvaluation|array{riskLevel?: float|null}|null $riskEvaluation * @param Status|value-of $status - * @param TrustLevel|array{level: float, manual: bool} $trust_level + * @param TrustLevel|array{level: float, manual: bool} $trustLevel */ public static function with( string $id, Block|array|null $block, - float $first_seen, - float $last_seen, + float $firstSeen, + float $lastSeen, Metadata|array $metadata, Metrics|array $metrics, - RiskEvaluation|array|null $risk_evaluation, + RiskEvaluation|array|null $riskEvaluation, Status|string $status, - TrustLevel|array $trust_level, + TrustLevel|array $trustLevel, ?string $email = null, - ?string $external_id = null, - ?string $external_link = null, - ?float $last_incident = null, + ?string $externalID = null, + ?string $externalLink = null, + ?float $lastIncident = null, ?string $name = null, - ?string $profile_picture = null, + ?string $profilePicture = null, ): self { - $obj = new self; - - $obj['id'] = $id; - $obj['block'] = $block; - $obj['first_seen'] = $first_seen; - $obj['last_seen'] = $last_seen; - $obj['metadata'] = $metadata; - $obj['metrics'] = $metrics; - $obj['risk_evaluation'] = $risk_evaluation; - $obj['status'] = $status; - $obj['trust_level'] = $trust_level; - - null !== $email && $obj['email'] = $email; - null !== $external_id && $obj['external_id'] = $external_id; - null !== $external_link && $obj['external_link'] = $external_link; - null !== $last_incident && $obj['last_incident'] = $last_incident; - null !== $name && $obj['name'] = $name; - null !== $profile_picture && $obj['profile_picture'] = $profile_picture; - - return $obj; + $self = new self; + + $self['id'] = $id; + $self['block'] = $block; + $self['firstSeen'] = $firstSeen; + $self['lastSeen'] = $lastSeen; + $self['metadata'] = $metadata; + $self['metrics'] = $metrics; + $self['riskEvaluation'] = $riskEvaluation; + $self['status'] = $status; + $self['trustLevel'] = $trustLevel; + + null !== $email && $self['email'] = $email; + null !== $externalID && $self['externalID'] = $externalID; + null !== $externalLink && $self['externalLink'] = $externalLink; + null !== $lastIncident && $self['lastIncident'] = $lastIncident; + null !== $name && $self['name'] = $name; + null !== $profilePicture && $self['profilePicture'] = $profilePicture; + + return $self; } /** @@ -229,10 +226,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -242,10 +239,10 @@ public function withID(string $id): self */ public function withBlock(Block|array|null $block): self { - $obj = clone $this; - $obj['block'] = $block; + $self = clone $this; + $self['block'] = $block; - return $obj; + return $self; } /** @@ -253,10 +250,10 @@ public function withBlock(Block|array|null $block): self */ public function withFirstSeen(float $firstSeen): self { - $obj = clone $this; - $obj['first_seen'] = $firstSeen; + $self = clone $this; + $self['firstSeen'] = $firstSeen; - return $obj; + return $self; } /** @@ -264,55 +261,55 @@ public function withFirstSeen(float $firstSeen): self */ public function withLastSeen(float $lastSeen): self { - $obj = clone $this; - $obj['last_seen'] = $lastSeen; + $self = clone $this; + $self['lastSeen'] = $lastSeen; - return $obj; + return $self; } /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata */ public function withMetadata(Metadata|array $metadata): self { - $obj = clone $this; - $obj['metadata'] = $metadata; + $self = clone $this; + $self['metadata'] = $metadata; - return $obj; + return $self; } /** * @param Metrics|array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } $metrics */ public function withMetrics(Metrics|array $metrics): self { - $obj = clone $this; - $obj['metrics'] = $metrics; + $self = clone $this; + $self['metrics'] = $metrics; - return $obj; + return $self; } /** * Risk assessment details, if available. * - * @param RiskEvaluation|array{risk_level?: float|null}|null $riskEvaluation + * @param RiskEvaluation|array{riskLevel?: float|null}|null $riskEvaluation */ public function withRiskEvaluation( RiskEvaluation|array|null $riskEvaluation ): self { - $obj = clone $this; - $obj['risk_evaluation'] = $riskEvaluation; + $self = clone $this; + $self['riskEvaluation'] = $riskEvaluation; - return $obj; + return $self; } /** @@ -322,10 +319,10 @@ public function withRiskEvaluation( */ public function withStatus(Status|string $status): self { - $obj = clone $this; - $obj['status'] = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -333,10 +330,10 @@ public function withStatus(Status|string $status): self */ public function withTrustLevel(TrustLevel|array $trustLevel): self { - $obj = clone $this; - $obj['trust_level'] = $trustLevel; + $self = clone $this; + $self['trustLevel'] = $trustLevel; - return $obj; + return $self; } /** @@ -344,10 +341,10 @@ public function withTrustLevel(TrustLevel|array $trustLevel): self */ public function withEmail(?string $email): self { - $obj = clone $this; - $obj['email'] = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } /** @@ -355,10 +352,10 @@ public function withEmail(?string $email): self */ public function withExternalID(?string $externalID): self { - $obj = clone $this; - $obj['external_id'] = $externalID; + $self = clone $this; + $self['externalID'] = $externalID; - return $obj; + return $self; } /** @@ -366,10 +363,10 @@ public function withExternalID(?string $externalID): self */ public function withExternalLink(?string $externalLink): self { - $obj = clone $this; - $obj['external_link'] = $externalLink; + $self = clone $this; + $self['externalLink'] = $externalLink; - return $obj; + return $self; } /** @@ -377,10 +374,10 @@ public function withExternalLink(?string $externalLink): self */ public function withLastIncident(?float $lastIncident): self { - $obj = clone $this; - $obj['last_incident'] = $lastIncident; + $self = clone $this; + $self['lastIncident'] = $lastIncident; - return $obj; + return $self; } /** @@ -388,10 +385,10 @@ public function withLastIncident(?float $lastIncident): self */ public function withName(?string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -399,9 +396,9 @@ public function withName(?string $name): self */ public function withProfilePicture(?string $profilePicture): self { - $obj = clone $this; - $obj['profile_picture'] = $profilePicture; + $self = clone $this; + $self['profilePicture'] = $profilePicture; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorNewResponse/Block.php b/src/Authors/AuthorNewResponse/Block.php index bbf2650..7df8130 100644 --- a/src/Authors/AuthorNewResponse/Block.php +++ b/src/Authors/AuthorNewResponse/Block.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorNewResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class Block implements BaseModel /** * The moderators reason why the author was blocked or suspended. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * The timestamp until which they are blocked if the author is suspended. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?float $until; public function __construct() @@ -44,12 +44,12 @@ public static function with( ?string $reason = null, ?float $until = null ): self { - $obj = new self; + $self = new self; - null !== $reason && $obj['reason'] = $reason; - null !== $until && $obj['until'] = $until; + null !== $reason && $self['reason'] = $reason; + null !== $until && $self['until'] = $until; - return $obj; + return $self; } /** @@ -57,10 +57,10 @@ public static function with( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj['reason'] = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -68,9 +68,9 @@ public function withReason(?string $reason): self */ public function withUntil(?float $until): self { - $obj = clone $this; - $obj['until'] = $until; + $self = clone $this; + $self['until'] = $until; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorNewResponse/Metadata.php b/src/Authors/AuthorNewResponse/Metadata.php index a134946..5759804 100644 --- a/src/Authors/AuthorNewResponse/Metadata.php +++ b/src/Authors/AuthorNewResponse/Metadata.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorNewResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -12,10 +12,10 @@ * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @phpstan-type MetadataShape = array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } */ final class Metadata implements BaseModel @@ -26,26 +26,26 @@ final class Metadata implements BaseModel /** * Whether the author's email is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $email_verified; + #[Optional('email_verified', nullable: true)] + public ?bool $emailVerified; /** * Whether the author's identity is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $identity_verified; + #[Optional('identity_verified', nullable: true)] + public ?bool $identityVerified; /** * Whether the author is a paying customer. */ - #[Api(nullable: true, optional: true)] - public ?bool $is_paying_customer; + #[Optional('is_paying_customer', nullable: true)] + public ?bool $isPayingCustomer; /** * Whether the author's phone number is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $phone_verified; + #[Optional('phone_verified', nullable: true)] + public ?bool $phoneVerified; public function __construct() { @@ -58,19 +58,19 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?bool $email_verified = null, - ?bool $identity_verified = null, - ?bool $is_paying_customer = null, - ?bool $phone_verified = null, + ?bool $emailVerified = null, + ?bool $identityVerified = null, + ?bool $isPayingCustomer = null, + ?bool $phoneVerified = null, ): self { - $obj = new self; + $self = new self; - null !== $email_verified && $obj['email_verified'] = $email_verified; - null !== $identity_verified && $obj['identity_verified'] = $identity_verified; - null !== $is_paying_customer && $obj['is_paying_customer'] = $is_paying_customer; - null !== $phone_verified && $obj['phone_verified'] = $phone_verified; + null !== $emailVerified && $self['emailVerified'] = $emailVerified; + null !== $identityVerified && $self['identityVerified'] = $identityVerified; + null !== $isPayingCustomer && $self['isPayingCustomer'] = $isPayingCustomer; + null !== $phoneVerified && $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } /** @@ -78,10 +78,10 @@ public static function with( */ public function withEmailVerified(?bool $emailVerified): self { - $obj = clone $this; - $obj['email_verified'] = $emailVerified; + $self = clone $this; + $self['emailVerified'] = $emailVerified; - return $obj; + return $self; } /** @@ -89,10 +89,10 @@ public function withEmailVerified(?bool $emailVerified): self */ public function withIdentityVerified(?bool $identityVerified): self { - $obj = clone $this; - $obj['identity_verified'] = $identityVerified; + $self = clone $this; + $self['identityVerified'] = $identityVerified; - return $obj; + return $self; } /** @@ -100,10 +100,10 @@ public function withIdentityVerified(?bool $identityVerified): self */ public function withIsPayingCustomer(?bool $isPayingCustomer): self { - $obj = clone $this; - $obj['is_paying_customer'] = $isPayingCustomer; + $self = clone $this; + $self['isPayingCustomer'] = $isPayingCustomer; - return $obj; + return $self; } /** @@ -111,9 +111,9 @@ public function withIsPayingCustomer(?bool $isPayingCustomer): self */ public function withPhoneVerified(?bool $phoneVerified): self { - $obj = clone $this; - $obj['phone_verified'] = $phoneVerified; + $self = clone $this; + $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorNewResponse/Metrics.php b/src/Authors/AuthorNewResponse/Metrics.php index a7e927a..d4500d2 100644 --- a/src/Authors/AuthorNewResponse/Metrics.php +++ b/src/Authors/AuthorNewResponse/Metrics.php @@ -4,13 +4,14 @@ namespace ModerationAPI\Authors\AuthorNewResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * @phpstan-type MetricsShape = array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } */ final class Metrics implements BaseModel @@ -21,27 +22,27 @@ final class Metrics implements BaseModel /** * Number of flagged content pieces. */ - #[Api] - public float $flagged_content; + #[Required('flagged_content')] + public float $flaggedContent; /** * Total pieces of content. */ - #[Api] - public float $total_content; + #[Required('total_content')] + public float $totalContent; /** * Average sentiment score of content (-1 to 1). Requires a sentiment model in your project. */ - #[Api(nullable: true, optional: true)] - public ?float $average_sentiment; + #[Optional('average_sentiment', nullable: true)] + public ?float $averageSentiment; /** * `new Metrics()` is missing required properties by the API. * * To enforce required parameters use * ``` - * Metrics::with(flagged_content: ..., total_content: ...) + * Metrics::with(flaggedContent: ..., totalContent: ...) * ``` * * Otherwise ensure the following setters are called @@ -61,18 +62,18 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - float $flagged_content, - float $total_content, - ?float $average_sentiment = null, + float $flaggedContent, + float $totalContent, + ?float $averageSentiment = null ): self { - $obj = new self; + $self = new self; - $obj['flagged_content'] = $flagged_content; - $obj['total_content'] = $total_content; + $self['flaggedContent'] = $flaggedContent; + $self['totalContent'] = $totalContent; - null !== $average_sentiment && $obj['average_sentiment'] = $average_sentiment; + null !== $averageSentiment && $self['averageSentiment'] = $averageSentiment; - return $obj; + return $self; } /** @@ -80,10 +81,10 @@ public static function with( */ public function withFlaggedContent(float $flaggedContent): self { - $obj = clone $this; - $obj['flagged_content'] = $flaggedContent; + $self = clone $this; + $self['flaggedContent'] = $flaggedContent; - return $obj; + return $self; } /** @@ -91,10 +92,10 @@ public function withFlaggedContent(float $flaggedContent): self */ public function withTotalContent(float $totalContent): self { - $obj = clone $this; - $obj['total_content'] = $totalContent; + $self = clone $this; + $self['totalContent'] = $totalContent; - return $obj; + return $self; } /** @@ -102,9 +103,9 @@ public function withTotalContent(float $totalContent): self */ public function withAverageSentiment(?float $averageSentiment): self { - $obj = clone $this; - $obj['average_sentiment'] = $averageSentiment; + $self = clone $this; + $self['averageSentiment'] = $averageSentiment; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorNewResponse/RiskEvaluation.php b/src/Authors/AuthorNewResponse/RiskEvaluation.php index 553ad7f..9f1c77c 100644 --- a/src/Authors/AuthorNewResponse/RiskEvaluation.php +++ b/src/Authors/AuthorNewResponse/RiskEvaluation.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Authors\AuthorNewResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Risk assessment details, if available. * - * @phpstan-type RiskEvaluationShape = array{risk_level?: float|null} + * @phpstan-type RiskEvaluationShape = array{riskLevel?: float|null} */ final class RiskEvaluation implements BaseModel { @@ -21,8 +21,8 @@ final class RiskEvaluation implements BaseModel /** * Calculated risk level based on more than 10 behavioral signals. */ - #[Api(nullable: true, optional: true)] - public ?float $risk_level; + #[Optional('risk_level', nullable: true)] + public ?float $riskLevel; public function __construct() { @@ -34,13 +34,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(?float $risk_level = null): self + public static function with(?float $riskLevel = null): self { - $obj = new self; + $self = new self; - null !== $risk_level && $obj['risk_level'] = $risk_level; + null !== $riskLevel && $self['riskLevel'] = $riskLevel; - return $obj; + return $self; } /** @@ -48,9 +48,9 @@ public static function with(?float $risk_level = null): self */ public function withRiskLevel(?float $riskLevel): self { - $obj = clone $this; - $obj['risk_level'] = $riskLevel; + $self = clone $this; + $self['riskLevel'] = $riskLevel; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorNewResponse/TrustLevel.php b/src/Authors/AuthorNewResponse/TrustLevel.php index a9f65ee..9478dfb 100644 --- a/src/Authors/AuthorNewResponse/TrustLevel.php +++ b/src/Authors/AuthorNewResponse/TrustLevel.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorNewResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class TrustLevel implements BaseModel /** * Author trust level (-1, 0, 1, 2, 3, or 4). */ - #[Api] + #[Required] public float $level; /** * True if the trust level was set manually by a moderator. */ - #[Api] + #[Required] public bool $manual; /** @@ -54,12 +54,12 @@ public function __construct() */ public static function with(float $level, bool $manual): self { - $obj = new self; + $self = new self; - $obj['level'] = $level; - $obj['manual'] = $manual; + $self['level'] = $level; + $self['manual'] = $manual; - return $obj; + return $self; } /** @@ -67,10 +67,10 @@ public static function with(float $level, bool $manual): self */ public function withLevel(float $level): self { - $obj = clone $this; - $obj['level'] = $level; + $self = clone $this; + $self['level'] = $level; - return $obj; + return $self; } /** @@ -78,9 +78,9 @@ public function withLevel(float $level): self */ public function withManual(bool $manual): self { - $obj = clone $this; - $obj['manual'] = $manual; + $self = clone $this; + $self['manual'] = $manual; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorUpdateParams.php b/src/Authors/AuthorUpdateParams.php index d2571cf..63c65d1 100644 --- a/src/Authors/AuthorUpdateParams.php +++ b/src/Authors/AuthorUpdateParams.php @@ -5,7 +5,7 @@ namespace ModerationAPI\Authors; use ModerationAPI\Authors\AuthorUpdateParams\Metadata; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Concerns\SdkParams; use ModerationAPI\Core\Contracts\BaseModel; @@ -17,18 +17,18 @@ * * @phpstan-type AuthorUpdateParamsShape = array{ * email?: string|null, - * external_link?: string|null, - * first_seen?: float, - * last_seen?: float, - * manual_trust_level?: float|null, + * externalLink?: string|null, + * firstSeen?: float, + * lastSeen?: float, + * manualTrustLevel?: float|null, * metadata?: Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * }, * name?: string|null, - * profile_picture?: string|null, + * profilePicture?: string|null, * } */ final class AuthorUpdateParams implements BaseModel @@ -40,47 +40,47 @@ final class AuthorUpdateParams implements BaseModel /** * Author email address. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $email; /** * URL of the author's external profile. */ - #[Api(nullable: true, optional: true)] - public ?string $external_link; + #[Optional('external_link', nullable: true)] + public ?string $externalLink; /** * Timestamp when author first appeared. */ - #[Api(optional: true)] - public ?float $first_seen; + #[Optional('first_seen')] + public ?float $firstSeen; /** * Timestamp of last activity. */ - #[Api(optional: true)] - public ?float $last_seen; + #[Optional('last_seen')] + public ?float $lastSeen; - #[Api(nullable: true, optional: true)] - public ?float $manual_trust_level; + #[Optional('manual_trust_level', nullable: true)] + public ?float $manualTrustLevel; /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. */ - #[Api(optional: true)] + #[Optional] public ?Metadata $metadata; /** * Author name or identifier. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $name; /** * URL of the author's profile picture. */ - #[Api(nullable: true, optional: true)] - public ?string $profile_picture; + #[Optional('profile_picture', nullable: true)] + public ?string $profilePicture; public function __construct() { @@ -93,34 +93,34 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata */ public static function with( ?string $email = null, - ?string $external_link = null, - ?float $first_seen = null, - ?float $last_seen = null, - ?float $manual_trust_level = null, + ?string $externalLink = null, + ?float $firstSeen = null, + ?float $lastSeen = null, + ?float $manualTrustLevel = null, Metadata|array|null $metadata = null, ?string $name = null, - ?string $profile_picture = null, + ?string $profilePicture = null, ): self { - $obj = new self; - - null !== $email && $obj['email'] = $email; - null !== $external_link && $obj['external_link'] = $external_link; - null !== $first_seen && $obj['first_seen'] = $first_seen; - null !== $last_seen && $obj['last_seen'] = $last_seen; - null !== $manual_trust_level && $obj['manual_trust_level'] = $manual_trust_level; - null !== $metadata && $obj['metadata'] = $metadata; - null !== $name && $obj['name'] = $name; - null !== $profile_picture && $obj['profile_picture'] = $profile_picture; - - return $obj; + $self = new self; + + null !== $email && $self['email'] = $email; + null !== $externalLink && $self['externalLink'] = $externalLink; + null !== $firstSeen && $self['firstSeen'] = $firstSeen; + null !== $lastSeen && $self['lastSeen'] = $lastSeen; + null !== $manualTrustLevel && $self['manualTrustLevel'] = $manualTrustLevel; + null !== $metadata && $self['metadata'] = $metadata; + null !== $name && $self['name'] = $name; + null !== $profilePicture && $self['profilePicture'] = $profilePicture; + + return $self; } /** @@ -128,10 +128,10 @@ public static function with( */ public function withEmail(?string $email): self { - $obj = clone $this; - $obj['email'] = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } /** @@ -139,10 +139,10 @@ public function withEmail(?string $email): self */ public function withExternalLink(?string $externalLink): self { - $obj = clone $this; - $obj['external_link'] = $externalLink; + $self = clone $this; + $self['externalLink'] = $externalLink; - return $obj; + return $self; } /** @@ -150,10 +150,10 @@ public function withExternalLink(?string $externalLink): self */ public function withFirstSeen(float $firstSeen): self { - $obj = clone $this; - $obj['first_seen'] = $firstSeen; + $self = clone $this; + $self['firstSeen'] = $firstSeen; - return $obj; + return $self; } /** @@ -161,36 +161,36 @@ public function withFirstSeen(float $firstSeen): self */ public function withLastSeen(float $lastSeen): self { - $obj = clone $this; - $obj['last_seen'] = $lastSeen; + $self = clone $this; + $self['lastSeen'] = $lastSeen; - return $obj; + return $self; } public function withManualTrustLevel(?float $manualTrustLevel): self { - $obj = clone $this; - $obj['manual_trust_level'] = $manualTrustLevel; + $self = clone $this; + $self['manualTrustLevel'] = $manualTrustLevel; - return $obj; + return $self; } /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata */ public function withMetadata(Metadata|array $metadata): self { - $obj = clone $this; - $obj['metadata'] = $metadata; + $self = clone $this; + $self['metadata'] = $metadata; - return $obj; + return $self; } /** @@ -198,10 +198,10 @@ public function withMetadata(Metadata|array $metadata): self */ public function withName(?string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -209,9 +209,9 @@ public function withName(?string $name): self */ public function withProfilePicture(?string $profilePicture): self { - $obj = clone $this; - $obj['profile_picture'] = $profilePicture; + $self = clone $this; + $self['profilePicture'] = $profilePicture; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorUpdateParams/Metadata.php b/src/Authors/AuthorUpdateParams/Metadata.php index 07c20c7..639b65b 100644 --- a/src/Authors/AuthorUpdateParams/Metadata.php +++ b/src/Authors/AuthorUpdateParams/Metadata.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorUpdateParams; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -12,10 +12,10 @@ * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @phpstan-type MetadataShape = array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } */ final class Metadata implements BaseModel @@ -26,26 +26,26 @@ final class Metadata implements BaseModel /** * Whether the author's email is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $email_verified; + #[Optional('email_verified', nullable: true)] + public ?bool $emailVerified; /** * Whether the author's identity is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $identity_verified; + #[Optional('identity_verified', nullable: true)] + public ?bool $identityVerified; /** * Whether the author is a paying customer. */ - #[Api(nullable: true, optional: true)] - public ?bool $is_paying_customer; + #[Optional('is_paying_customer', nullable: true)] + public ?bool $isPayingCustomer; /** * Whether the author's phone number is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $phone_verified; + #[Optional('phone_verified', nullable: true)] + public ?bool $phoneVerified; public function __construct() { @@ -58,19 +58,19 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?bool $email_verified = null, - ?bool $identity_verified = null, - ?bool $is_paying_customer = null, - ?bool $phone_verified = null, + ?bool $emailVerified = null, + ?bool $identityVerified = null, + ?bool $isPayingCustomer = null, + ?bool $phoneVerified = null, ): self { - $obj = new self; + $self = new self; - null !== $email_verified && $obj['email_verified'] = $email_verified; - null !== $identity_verified && $obj['identity_verified'] = $identity_verified; - null !== $is_paying_customer && $obj['is_paying_customer'] = $is_paying_customer; - null !== $phone_verified && $obj['phone_verified'] = $phone_verified; + null !== $emailVerified && $self['emailVerified'] = $emailVerified; + null !== $identityVerified && $self['identityVerified'] = $identityVerified; + null !== $isPayingCustomer && $self['isPayingCustomer'] = $isPayingCustomer; + null !== $phoneVerified && $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } /** @@ -78,10 +78,10 @@ public static function with( */ public function withEmailVerified(?bool $emailVerified): self { - $obj = clone $this; - $obj['email_verified'] = $emailVerified; + $self = clone $this; + $self['emailVerified'] = $emailVerified; - return $obj; + return $self; } /** @@ -89,10 +89,10 @@ public function withEmailVerified(?bool $emailVerified): self */ public function withIdentityVerified(?bool $identityVerified): self { - $obj = clone $this; - $obj['identity_verified'] = $identityVerified; + $self = clone $this; + $self['identityVerified'] = $identityVerified; - return $obj; + return $self; } /** @@ -100,10 +100,10 @@ public function withIdentityVerified(?bool $identityVerified): self */ public function withIsPayingCustomer(?bool $isPayingCustomer): self { - $obj = clone $this; - $obj['is_paying_customer'] = $isPayingCustomer; + $self = clone $this; + $self['isPayingCustomer'] = $isPayingCustomer; - return $obj; + return $self; } /** @@ -111,9 +111,9 @@ public function withIsPayingCustomer(?bool $isPayingCustomer): self */ public function withPhoneVerified(?bool $phoneVerified): self { - $obj = clone $this; - $obj['phone_verified'] = $phoneVerified; + $self = clone $this; + $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorUpdateResponse.php b/src/Authors/AuthorUpdateResponse.php index e323eab..552a3f2 100644 --- a/src/Authors/AuthorUpdateResponse.php +++ b/src/Authors/AuthorUpdateResponse.php @@ -10,123 +10,120 @@ use ModerationAPI\Authors\AuthorUpdateResponse\RiskEvaluation; use ModerationAPI\Authors\AuthorUpdateResponse\Status; use ModerationAPI\Authors\AuthorUpdateResponse\TrustLevel; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type AuthorUpdateResponseShape = array{ * id: string, * block: Block|null, - * first_seen: float, - * last_seen: float, + * firstSeen: float, + * lastSeen: float, * metadata: Metadata, * metrics: Metrics, - * risk_evaluation: RiskEvaluation|null, + * riskEvaluation: RiskEvaluation|null, * status: value-of, - * trust_level: TrustLevel, + * trustLevel: TrustLevel, * email?: string|null, - * external_id?: string|null, - * external_link?: string|null, - * last_incident?: float|null, + * externalID?: string|null, + * externalLink?: string|null, + * lastIncident?: float|null, * name?: string|null, - * profile_picture?: string|null, + * profilePicture?: string|null, * } */ -final class AuthorUpdateResponse implements BaseModel, ResponseConverter +final class AuthorUpdateResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * Author ID in Moderation API. */ - #[Api] + #[Required] public string $id; /** * Block or suspension details, if applicable. Null if the author is enabled. */ - #[Api] + #[Required] public ?Block $block; /** * Timestamp when author first appeared. */ - #[Api] - public float $first_seen; + #[Required('first_seen')] + public float $firstSeen; /** * Timestamp of last activity. */ - #[Api] - public float $last_seen; + #[Required('last_seen')] + public float $lastSeen; /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. */ - #[Api] + #[Required] public Metadata $metadata; - #[Api] + #[Required] public Metrics $metrics; /** * Risk assessment details, if available. */ - #[Api] - public ?RiskEvaluation $risk_evaluation; + #[Required('risk_evaluation')] + public ?RiskEvaluation $riskEvaluation; /** * Current author status. * * @var value-of $status */ - #[Api(enum: Status::class)] + #[Required(enum: Status::class)] public string $status; - #[Api] - public TrustLevel $trust_level; + #[Required('trust_level')] + public TrustLevel $trustLevel; /** * Author email address. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $email; /** * The author's ID from your system. */ - #[Api(nullable: true, optional: true)] - public ?string $external_id; + #[Optional('external_id', nullable: true)] + public ?string $externalID; /** * URL of the author's external profile. */ - #[Api(nullable: true, optional: true)] - public ?string $external_link; + #[Optional('external_link', nullable: true)] + public ?string $externalLink; /** * Timestamp of last incident. */ - #[Api(nullable: true, optional: true)] - public ?float $last_incident; + #[Optional('last_incident', nullable: true)] + public ?float $lastIncident; /** * Author name or identifier. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $name; /** * URL of the author's profile picture. */ - #[Api(nullable: true, optional: true)] - public ?string $profile_picture; + #[Optional('profile_picture', nullable: true)] + public ?string $profilePicture; /** * `new AuthorUpdateResponse()` is missing required properties by the API. @@ -136,13 +133,13 @@ final class AuthorUpdateResponse implements BaseModel, ResponseConverter * AuthorUpdateResponse::with( * id: ..., * block: ..., - * first_seen: ..., - * last_seen: ..., + * firstSeen: ..., + * lastSeen: ..., * metadata: ..., * metrics: ..., - * risk_evaluation: ..., + * riskEvaluation: ..., * status: ..., - * trust_level: ..., + * trustLevel: ..., * ) * ``` * @@ -173,55 +170,55 @@ public function __construct() * * @param Block|array{reason?: string|null, until?: float|null}|null $block * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata * @param Metrics|array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } $metrics - * @param RiskEvaluation|array{risk_level?: float|null}|null $risk_evaluation + * @param RiskEvaluation|array{riskLevel?: float|null}|null $riskEvaluation * @param Status|value-of $status - * @param TrustLevel|array{level: float, manual: bool} $trust_level + * @param TrustLevel|array{level: float, manual: bool} $trustLevel */ public static function with( string $id, Block|array|null $block, - float $first_seen, - float $last_seen, + float $firstSeen, + float $lastSeen, Metadata|array $metadata, Metrics|array $metrics, - RiskEvaluation|array|null $risk_evaluation, + RiskEvaluation|array|null $riskEvaluation, Status|string $status, - TrustLevel|array $trust_level, + TrustLevel|array $trustLevel, ?string $email = null, - ?string $external_id = null, - ?string $external_link = null, - ?float $last_incident = null, + ?string $externalID = null, + ?string $externalLink = null, + ?float $lastIncident = null, ?string $name = null, - ?string $profile_picture = null, + ?string $profilePicture = null, ): self { - $obj = new self; - - $obj['id'] = $id; - $obj['block'] = $block; - $obj['first_seen'] = $first_seen; - $obj['last_seen'] = $last_seen; - $obj['metadata'] = $metadata; - $obj['metrics'] = $metrics; - $obj['risk_evaluation'] = $risk_evaluation; - $obj['status'] = $status; - $obj['trust_level'] = $trust_level; - - null !== $email && $obj['email'] = $email; - null !== $external_id && $obj['external_id'] = $external_id; - null !== $external_link && $obj['external_link'] = $external_link; - null !== $last_incident && $obj['last_incident'] = $last_incident; - null !== $name && $obj['name'] = $name; - null !== $profile_picture && $obj['profile_picture'] = $profile_picture; - - return $obj; + $self = new self; + + $self['id'] = $id; + $self['block'] = $block; + $self['firstSeen'] = $firstSeen; + $self['lastSeen'] = $lastSeen; + $self['metadata'] = $metadata; + $self['metrics'] = $metrics; + $self['riskEvaluation'] = $riskEvaluation; + $self['status'] = $status; + $self['trustLevel'] = $trustLevel; + + null !== $email && $self['email'] = $email; + null !== $externalID && $self['externalID'] = $externalID; + null !== $externalLink && $self['externalLink'] = $externalLink; + null !== $lastIncident && $self['lastIncident'] = $lastIncident; + null !== $name && $self['name'] = $name; + null !== $profilePicture && $self['profilePicture'] = $profilePicture; + + return $self; } /** @@ -229,10 +226,10 @@ public static function with( */ public function withID(string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } /** @@ -242,10 +239,10 @@ public function withID(string $id): self */ public function withBlock(Block|array|null $block): self { - $obj = clone $this; - $obj['block'] = $block; + $self = clone $this; + $self['block'] = $block; - return $obj; + return $self; } /** @@ -253,10 +250,10 @@ public function withBlock(Block|array|null $block): self */ public function withFirstSeen(float $firstSeen): self { - $obj = clone $this; - $obj['first_seen'] = $firstSeen; + $self = clone $this; + $self['firstSeen'] = $firstSeen; - return $obj; + return $self; } /** @@ -264,55 +261,55 @@ public function withFirstSeen(float $firstSeen): self */ public function withLastSeen(float $lastSeen): self { - $obj = clone $this; - $obj['last_seen'] = $lastSeen; + $self = clone $this; + $self['lastSeen'] = $lastSeen; - return $obj; + return $self; } /** * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @param Metadata|array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } $metadata */ public function withMetadata(Metadata|array $metadata): self { - $obj = clone $this; - $obj['metadata'] = $metadata; + $self = clone $this; + $self['metadata'] = $metadata; - return $obj; + return $self; } /** * @param Metrics|array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } $metrics */ public function withMetrics(Metrics|array $metrics): self { - $obj = clone $this; - $obj['metrics'] = $metrics; + $self = clone $this; + $self['metrics'] = $metrics; - return $obj; + return $self; } /** * Risk assessment details, if available. * - * @param RiskEvaluation|array{risk_level?: float|null}|null $riskEvaluation + * @param RiskEvaluation|array{riskLevel?: float|null}|null $riskEvaluation */ public function withRiskEvaluation( RiskEvaluation|array|null $riskEvaluation ): self { - $obj = clone $this; - $obj['risk_evaluation'] = $riskEvaluation; + $self = clone $this; + $self['riskEvaluation'] = $riskEvaluation; - return $obj; + return $self; } /** @@ -322,10 +319,10 @@ public function withRiskEvaluation( */ public function withStatus(Status|string $status): self { - $obj = clone $this; - $obj['status'] = $status; + $self = clone $this; + $self['status'] = $status; - return $obj; + return $self; } /** @@ -333,10 +330,10 @@ public function withStatus(Status|string $status): self */ public function withTrustLevel(TrustLevel|array $trustLevel): self { - $obj = clone $this; - $obj['trust_level'] = $trustLevel; + $self = clone $this; + $self['trustLevel'] = $trustLevel; - return $obj; + return $self; } /** @@ -344,10 +341,10 @@ public function withTrustLevel(TrustLevel|array $trustLevel): self */ public function withEmail(?string $email): self { - $obj = clone $this; - $obj['email'] = $email; + $self = clone $this; + $self['email'] = $email; - return $obj; + return $self; } /** @@ -355,10 +352,10 @@ public function withEmail(?string $email): self */ public function withExternalID(?string $externalID): self { - $obj = clone $this; - $obj['external_id'] = $externalID; + $self = clone $this; + $self['externalID'] = $externalID; - return $obj; + return $self; } /** @@ -366,10 +363,10 @@ public function withExternalID(?string $externalID): self */ public function withExternalLink(?string $externalLink): self { - $obj = clone $this; - $obj['external_link'] = $externalLink; + $self = clone $this; + $self['externalLink'] = $externalLink; - return $obj; + return $self; } /** @@ -377,10 +374,10 @@ public function withExternalLink(?string $externalLink): self */ public function withLastIncident(?float $lastIncident): self { - $obj = clone $this; - $obj['last_incident'] = $lastIncident; + $self = clone $this; + $self['lastIncident'] = $lastIncident; - return $obj; + return $self; } /** @@ -388,10 +385,10 @@ public function withLastIncident(?float $lastIncident): self */ public function withName(?string $name): self { - $obj = clone $this; - $obj['name'] = $name; + $self = clone $this; + $self['name'] = $name; - return $obj; + return $self; } /** @@ -399,9 +396,9 @@ public function withName(?string $name): self */ public function withProfilePicture(?string $profilePicture): self { - $obj = clone $this; - $obj['profile_picture'] = $profilePicture; + $self = clone $this; + $self['profilePicture'] = $profilePicture; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorUpdateResponse/Block.php b/src/Authors/AuthorUpdateResponse/Block.php index 0793dd0..6b0dcbc 100644 --- a/src/Authors/AuthorUpdateResponse/Block.php +++ b/src/Authors/AuthorUpdateResponse/Block.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorUpdateResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -21,13 +21,13 @@ final class Block implements BaseModel /** * The moderators reason why the author was blocked or suspended. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?string $reason; /** * The timestamp until which they are blocked if the author is suspended. */ - #[Api(nullable: true, optional: true)] + #[Optional(nullable: true)] public ?float $until; public function __construct() @@ -44,12 +44,12 @@ public static function with( ?string $reason = null, ?float $until = null ): self { - $obj = new self; + $self = new self; - null !== $reason && $obj['reason'] = $reason; - null !== $until && $obj['until'] = $until; + null !== $reason && $self['reason'] = $reason; + null !== $until && $self['until'] = $until; - return $obj; + return $self; } /** @@ -57,10 +57,10 @@ public static function with( */ public function withReason(?string $reason): self { - $obj = clone $this; - $obj['reason'] = $reason; + $self = clone $this; + $self['reason'] = $reason; - return $obj; + return $self; } /** @@ -68,9 +68,9 @@ public function withReason(?string $reason): self */ public function withUntil(?float $until): self { - $obj = clone $this; - $obj['until'] = $until; + $self = clone $this; + $self['until'] = $until; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorUpdateResponse/Metadata.php b/src/Authors/AuthorUpdateResponse/Metadata.php index bab1ab8..97d5822 100644 --- a/src/Authors/AuthorUpdateResponse/Metadata.php +++ b/src/Authors/AuthorUpdateResponse/Metadata.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorUpdateResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -12,10 +12,10 @@ * Additional metadata provided by your system. We recommend including any relevant information that may assist in the moderation process. * * @phpstan-type MetadataShape = array{ - * email_verified?: bool|null, - * identity_verified?: bool|null, - * is_paying_customer?: bool|null, - * phone_verified?: bool|null, + * emailVerified?: bool|null, + * identityVerified?: bool|null, + * isPayingCustomer?: bool|null, + * phoneVerified?: bool|null, * } */ final class Metadata implements BaseModel @@ -26,26 +26,26 @@ final class Metadata implements BaseModel /** * Whether the author's email is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $email_verified; + #[Optional('email_verified', nullable: true)] + public ?bool $emailVerified; /** * Whether the author's identity is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $identity_verified; + #[Optional('identity_verified', nullable: true)] + public ?bool $identityVerified; /** * Whether the author is a paying customer. */ - #[Api(nullable: true, optional: true)] - public ?bool $is_paying_customer; + #[Optional('is_paying_customer', nullable: true)] + public ?bool $isPayingCustomer; /** * Whether the author's phone number is verified. */ - #[Api(nullable: true, optional: true)] - public ?bool $phone_verified; + #[Optional('phone_verified', nullable: true)] + public ?bool $phoneVerified; public function __construct() { @@ -58,19 +58,19 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - ?bool $email_verified = null, - ?bool $identity_verified = null, - ?bool $is_paying_customer = null, - ?bool $phone_verified = null, + ?bool $emailVerified = null, + ?bool $identityVerified = null, + ?bool $isPayingCustomer = null, + ?bool $phoneVerified = null, ): self { - $obj = new self; + $self = new self; - null !== $email_verified && $obj['email_verified'] = $email_verified; - null !== $identity_verified && $obj['identity_verified'] = $identity_verified; - null !== $is_paying_customer && $obj['is_paying_customer'] = $is_paying_customer; - null !== $phone_verified && $obj['phone_verified'] = $phone_verified; + null !== $emailVerified && $self['emailVerified'] = $emailVerified; + null !== $identityVerified && $self['identityVerified'] = $identityVerified; + null !== $isPayingCustomer && $self['isPayingCustomer'] = $isPayingCustomer; + null !== $phoneVerified && $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } /** @@ -78,10 +78,10 @@ public static function with( */ public function withEmailVerified(?bool $emailVerified): self { - $obj = clone $this; - $obj['email_verified'] = $emailVerified; + $self = clone $this; + $self['emailVerified'] = $emailVerified; - return $obj; + return $self; } /** @@ -89,10 +89,10 @@ public function withEmailVerified(?bool $emailVerified): self */ public function withIdentityVerified(?bool $identityVerified): self { - $obj = clone $this; - $obj['identity_verified'] = $identityVerified; + $self = clone $this; + $self['identityVerified'] = $identityVerified; - return $obj; + return $self; } /** @@ -100,10 +100,10 @@ public function withIdentityVerified(?bool $identityVerified): self */ public function withIsPayingCustomer(?bool $isPayingCustomer): self { - $obj = clone $this; - $obj['is_paying_customer'] = $isPayingCustomer; + $self = clone $this; + $self['isPayingCustomer'] = $isPayingCustomer; - return $obj; + return $self; } /** @@ -111,9 +111,9 @@ public function withIsPayingCustomer(?bool $isPayingCustomer): self */ public function withPhoneVerified(?bool $phoneVerified): self { - $obj = clone $this; - $obj['phone_verified'] = $phoneVerified; + $self = clone $this; + $self['phoneVerified'] = $phoneVerified; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorUpdateResponse/Metrics.php b/src/Authors/AuthorUpdateResponse/Metrics.php index 28c650c..c102071 100644 --- a/src/Authors/AuthorUpdateResponse/Metrics.php +++ b/src/Authors/AuthorUpdateResponse/Metrics.php @@ -4,13 +4,14 @@ namespace ModerationAPI\Authors\AuthorUpdateResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * @phpstan-type MetricsShape = array{ - * flagged_content: float, total_content: float, average_sentiment?: float|null + * flaggedContent: float, totalContent: float, averageSentiment?: float|null * } */ final class Metrics implements BaseModel @@ -21,27 +22,27 @@ final class Metrics implements BaseModel /** * Number of flagged content pieces. */ - #[Api] - public float $flagged_content; + #[Required('flagged_content')] + public float $flaggedContent; /** * Total pieces of content. */ - #[Api] - public float $total_content; + #[Required('total_content')] + public float $totalContent; /** * Average sentiment score of content (-1 to 1). Requires a sentiment model in your project. */ - #[Api(nullable: true, optional: true)] - public ?float $average_sentiment; + #[Optional('average_sentiment', nullable: true)] + public ?float $averageSentiment; /** * `new Metrics()` is missing required properties by the API. * * To enforce required parameters use * ``` - * Metrics::with(flagged_content: ..., total_content: ...) + * Metrics::with(flaggedContent: ..., totalContent: ...) * ``` * * Otherwise ensure the following setters are called @@ -61,18 +62,18 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. */ public static function with( - float $flagged_content, - float $total_content, - ?float $average_sentiment = null, + float $flaggedContent, + float $totalContent, + ?float $averageSentiment = null ): self { - $obj = new self; + $self = new self; - $obj['flagged_content'] = $flagged_content; - $obj['total_content'] = $total_content; + $self['flaggedContent'] = $flaggedContent; + $self['totalContent'] = $totalContent; - null !== $average_sentiment && $obj['average_sentiment'] = $average_sentiment; + null !== $averageSentiment && $self['averageSentiment'] = $averageSentiment; - return $obj; + return $self; } /** @@ -80,10 +81,10 @@ public static function with( */ public function withFlaggedContent(float $flaggedContent): self { - $obj = clone $this; - $obj['flagged_content'] = $flaggedContent; + $self = clone $this; + $self['flaggedContent'] = $flaggedContent; - return $obj; + return $self; } /** @@ -91,10 +92,10 @@ public function withFlaggedContent(float $flaggedContent): self */ public function withTotalContent(float $totalContent): self { - $obj = clone $this; - $obj['total_content'] = $totalContent; + $self = clone $this; + $self['totalContent'] = $totalContent; - return $obj; + return $self; } /** @@ -102,9 +103,9 @@ public function withTotalContent(float $totalContent): self */ public function withAverageSentiment(?float $averageSentiment): self { - $obj = clone $this; - $obj['average_sentiment'] = $averageSentiment; + $self = clone $this; + $self['averageSentiment'] = $averageSentiment; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorUpdateResponse/RiskEvaluation.php b/src/Authors/AuthorUpdateResponse/RiskEvaluation.php index d9907fc..8396723 100644 --- a/src/Authors/AuthorUpdateResponse/RiskEvaluation.php +++ b/src/Authors/AuthorUpdateResponse/RiskEvaluation.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Authors\AuthorUpdateResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Risk assessment details, if available. * - * @phpstan-type RiskEvaluationShape = array{risk_level?: float|null} + * @phpstan-type RiskEvaluationShape = array{riskLevel?: float|null} */ final class RiskEvaluation implements BaseModel { @@ -21,8 +21,8 @@ final class RiskEvaluation implements BaseModel /** * Calculated risk level based on more than 10 behavioral signals. */ - #[Api(nullable: true, optional: true)] - public ?float $risk_level; + #[Optional('risk_level', nullable: true)] + public ?float $riskLevel; public function __construct() { @@ -34,13 +34,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(?float $risk_level = null): self + public static function with(?float $riskLevel = null): self { - $obj = new self; + $self = new self; - null !== $risk_level && $obj['risk_level'] = $risk_level; + null !== $riskLevel && $self['riskLevel'] = $riskLevel; - return $obj; + return $self; } /** @@ -48,9 +48,9 @@ public static function with(?float $risk_level = null): self */ public function withRiskLevel(?float $riskLevel): self { - $obj = clone $this; - $obj['risk_level'] = $riskLevel; + $self = clone $this; + $self['riskLevel'] = $riskLevel; - return $obj; + return $self; } } diff --git a/src/Authors/AuthorUpdateResponse/TrustLevel.php b/src/Authors/AuthorUpdateResponse/TrustLevel.php index e7f473b..4b60de7 100644 --- a/src/Authors/AuthorUpdateResponse/TrustLevel.php +++ b/src/Authors/AuthorUpdateResponse/TrustLevel.php @@ -4,7 +4,7 @@ namespace ModerationAPI\Authors\AuthorUpdateResponse; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -19,13 +19,13 @@ final class TrustLevel implements BaseModel /** * Author trust level (-1, 0, 1, 2, 3, or 4). */ - #[Api] + #[Required] public float $level; /** * True if the trust level was set manually by a moderator. */ - #[Api] + #[Required] public bool $manual; /** @@ -54,12 +54,12 @@ public function __construct() */ public static function with(float $level, bool $manual): self { - $obj = new self; + $self = new self; - $obj['level'] = $level; - $obj['manual'] = $manual; + $self['level'] = $level; + $self['manual'] = $manual; - return $obj; + return $self; } /** @@ -67,10 +67,10 @@ public static function with(float $level, bool $manual): self */ public function withLevel(float $level): self { - $obj = clone $this; - $obj['level'] = $level; + $self = clone $this; + $self['level'] = $level; - return $obj; + return $self; } /** @@ -78,9 +78,9 @@ public function withLevel(float $level): self */ public function withManual(bool $manual): self { - $obj = clone $this; - $obj['manual'] = $manual; + $self = clone $this; + $self['manual'] = $manual; - return $obj; + return $self; } } diff --git a/src/Client.php b/src/Client.php index 2b68ac4..be2f97b 100644 --- a/src/Client.php +++ b/src/Client.php @@ -74,9 +74,9 @@ public function __construct(?string $secretKey = null, ?string $baseUrl = null) headers: [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', - 'User-Agent' => sprintf('moderation-api/PHP %s', '0.2.0'), + 'User-Agent' => sprintf('moderation-api/PHP %s', '0.3.0'), 'X-Stainless-Lang' => 'php', - 'X-Stainless-Package-Version' => '0.2.0', + 'X-Stainless-Package-Version' => '0.3.0', 'X-Stainless-OS' => $this->getNormalizedOS(), 'X-Stainless-Arch' => $this->getNormalizedArchitecture(), 'X-Stainless-Runtime' => 'php', diff --git a/src/Content/ContentSubmitParams.php b/src/Content/ContentSubmitParams.php index f816dc9..201a7f6 100644 --- a/src/Content/ContentSubmitParams.php +++ b/src/Content/ContentSubmitParams.php @@ -35,7 +35,8 @@ use ModerationAPI\Content\ContentSubmitParams\Policy\ToxicitySevere; use ModerationAPI\Content\ContentSubmitParams\Policy\URLMasking; use ModerationAPI\Content\ContentSubmitParams\Policy\Violence; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Concerns\SdkParams; use ModerationAPI\Core\Contracts\BaseModel; @@ -44,52 +45,52 @@ * @see ModerationAPI\Services\ContentService::submit() * * @phpstan-type ContentSubmitParamsShape = array{ - * content: Text|array{text: string, type: 'text'}|Image|array{ - * type: 'image', url: string - * }|Video|array{type: 'video', url: string}|Audio|array{ - * type: 'audio', url: string + * content: Text|array{text: string, type?: 'text'}|Image|array{ + * type?: 'image', url: string + * }|Video|array{type?: 'video', url: string}|Audio|array{ + * type?: 'audio', url: string * }|Object1|array{ * data: array, - * type: 'object', + * type?: 'object', * }, - * authorId?: string, + * authorID?: string, * channel?: string, - * contentId?: string, - * conversationId?: string, + * contentID?: string, + * conversationID?: string, * doNotStore?: bool, * metadata?: array, * metaType?: MetaType|value-of, * policies?: list + * id?: 'illicit_tobacco', flag: bool + * }|IllicitGambling|array{id?: 'illicit_gambling', flag: bool}|Sexual|array{ + * id?: 'sexual', flag: bool + * }|Flirtation|array{id?: 'flirtation', flag: bool}|Profanity|array{ + * id?: 'profanity', flag: bool + * }|Violence|array{id?: 'violence', flag: bool}|SelfHarm|array{ + * id?: 'self_harm', flag: bool + * }|Spam|array{id?: 'spam', flag: bool}|SelfPromotion|array{ + * id?: 'self_promotion', flag: bool + * }|Political|array{id?: 'political', flag: bool}|Religion|array{ + * id?: 'religion', flag: bool + * }|CodeAbuse|array{id?: 'code_abuse', flag: bool}|PiiMasking|array{ + * id?: 'pii', entities: array * }|URLMasking|array{ - * id: 'url', + * id?: 'url', * entities: array, * }|Guideline|array{ - * id: 'guideline', flag: bool, guidelineKey: string, instructions: string + * id?: 'guideline', flag: bool, guidelineKey: string, instructions: string * }>, * } */ @@ -102,37 +103,37 @@ final class ContentSubmitParams implements BaseModel /** * The content sent for moderation. */ - #[Api] + #[Required] public Text|Image|Video|Audio|Object1 $content; /** * The author of the content. */ - #[Api(optional: true)] - public ?string $authorId; + #[Optional('authorId')] + public ?string $authorID; /** * Provide a channel ID or key. Will use the project's default channel if not provided. */ - #[Api(optional: true)] + #[Optional] public ?string $channel; /** * The unique ID of the content in your database. */ - #[Api(optional: true)] - public ?string $contentId; + #[Optional('contentId')] + public ?string $contentID; /** * For example the ID of a chat room or a post. */ - #[Api(optional: true)] - public ?string $conversationId; + #[Optional('conversationId')] + public ?string $conversationID; /** * Do not store the content. The content won't enter the review queue. */ - #[Api(optional: true)] + #[Optional] public ?bool $doNotStore; /** @@ -140,7 +141,7 @@ final class ContentSubmitParams implements BaseModel * * @var array|null $metadata */ - #[Api(map: 'mixed', optional: true)] + #[Optional(map: 'mixed')] public ?array $metadata; /** @@ -148,7 +149,7 @@ final class ContentSubmitParams implements BaseModel * * @var value-of|null $metaType */ - #[Api(enum: MetaType::class, optional: true)] + #[Optional(enum: MetaType::class)] public ?string $metaType; /** @@ -156,7 +157,7 @@ final class ContentSubmitParams implements BaseModel * * @var list|null $policies */ - #[Api(list: Policy::class, optional: true)] + #[Optional(list: Policy::class)] public ?array $policies; /** @@ -183,91 +184,95 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param Text|array{text: string, type: 'text'}|Image|array{ - * type: 'image', url: string - * }|Video|array{type: 'video', url: string}|Audio|array{ - * type: 'audio', url: string + * @param Text|array{text: string, type?: 'text'}|Image|array{ + * type?: 'image', url: string + * }|Video|array{type?: 'video', url: string}|Audio|array{ + * type?: 'audio', url: string * }|Object1|array{ * data: array, - * type: 'object', + * type?: 'object', * } $content * @param array $metadata * @param MetaType|value-of $metaType * @param list}|URLMasking|array{ - * id: 'url', + * id?: 'personal_information', flag: bool + * }|ToxicitySevere|array{id?: 'toxicity_severe', flag: bool}|Hate|array{ + * id?: 'hate', flag: bool + * }|Illicit|array{id?: 'illicit', flag: bool}|IllicitDrugs|array{ + * id?: 'illicit_drugs', flag: bool + * }|IllicitAlcohol|array{ + * id?: 'illicit_alcohol', flag: bool + * }|IllicitFirearms|array{ + * id?: 'illicit_firearms', flag: bool + * }|IllicitTobacco|array{ + * id?: 'illicit_tobacco', flag: bool + * }|IllicitGambling|array{id?: 'illicit_gambling', flag: bool}|Sexual|array{ + * id?: 'sexual', flag: bool + * }|Flirtation|array{id?: 'flirtation', flag: bool}|Profanity|array{ + * id?: 'profanity', flag: bool + * }|Violence|array{id?: 'violence', flag: bool}|SelfHarm|array{ + * id?: 'self_harm', flag: bool + * }|Spam|array{id?: 'spam', flag: bool}|SelfPromotion|array{ + * id?: 'self_promotion', flag: bool + * }|Political|array{id?: 'political', flag: bool}|Religion|array{ + * id?: 'religion', flag: bool + * }|CodeAbuse|array{id?: 'code_abuse', flag: bool}|PiiMasking|array{ + * id?: 'pii', entities: array + * }|URLMasking|array{ + * id?: 'url', * entities: array, * }|Guideline|array{ - * id: 'guideline', flag: bool, guidelineKey: string, instructions: string + * id?: 'guideline', flag: bool, guidelineKey: string, instructions: string * }> $policies */ public static function with( Text|array|Image|Video|Audio|Object1 $content, - ?string $authorId = null, + ?string $authorID = null, ?string $channel = null, - ?string $contentId = null, - ?string $conversationId = null, + ?string $contentID = null, + ?string $conversationID = null, ?bool $doNotStore = null, ?array $metadata = null, MetaType|string|null $metaType = null, ?array $policies = null, ): self { - $obj = new self; + $self = new self; - $obj['content'] = $content; + $self['content'] = $content; - null !== $authorId && $obj['authorId'] = $authorId; - null !== $channel && $obj['channel'] = $channel; - null !== $contentId && $obj['contentId'] = $contentId; - null !== $conversationId && $obj['conversationId'] = $conversationId; - null !== $doNotStore && $obj['doNotStore'] = $doNotStore; - null !== $metadata && $obj['metadata'] = $metadata; - null !== $metaType && $obj['metaType'] = $metaType; - null !== $policies && $obj['policies'] = $policies; + null !== $authorID && $self['authorID'] = $authorID; + null !== $channel && $self['channel'] = $channel; + null !== $contentID && $self['contentID'] = $contentID; + null !== $conversationID && $self['conversationID'] = $conversationID; + null !== $doNotStore && $self['doNotStore'] = $doNotStore; + null !== $metadata && $self['metadata'] = $metadata; + null !== $metaType && $self['metaType'] = $metaType; + null !== $policies && $self['policies'] = $policies; - return $obj; + return $self; } /** * The content sent for moderation. * - * @param Text|array{text: string, type: 'text'}|Image|array{ - * type: 'image', url: string - * }|Video|array{type: 'video', url: string}|Audio|array{ - * type: 'audio', url: string + * @param Text|array{text: string, type?: 'text'}|Image|array{ + * type?: 'image', url: string + * }|Video|array{type?: 'video', url: string}|Audio|array{ + * type?: 'audio', url: string * }|Object1|array{ * data: array, - * type: 'object', + * type?: 'object', * } $content */ public function withContent( Text|array|Image|Video|Audio|Object1 $content ): self { - $obj = clone $this; - $obj['content'] = $content; + $self = clone $this; + $self['content'] = $content; - return $obj; + return $self; } /** @@ -275,10 +280,10 @@ public function withContent( */ public function withAuthorID(string $authorID): self { - $obj = clone $this; - $obj['authorId'] = $authorID; + $self = clone $this; + $self['authorID'] = $authorID; - return $obj; + return $self; } /** @@ -286,10 +291,10 @@ public function withAuthorID(string $authorID): self */ public function withChannel(string $channel): self { - $obj = clone $this; - $obj['channel'] = $channel; + $self = clone $this; + $self['channel'] = $channel; - return $obj; + return $self; } /** @@ -297,10 +302,10 @@ public function withChannel(string $channel): self */ public function withContentID(string $contentID): self { - $obj = clone $this; - $obj['contentId'] = $contentID; + $self = clone $this; + $self['contentID'] = $contentID; - return $obj; + return $self; } /** @@ -308,10 +313,10 @@ public function withContentID(string $contentID): self */ public function withConversationID(string $conversationID): self { - $obj = clone $this; - $obj['conversationId'] = $conversationID; + $self = clone $this; + $self['conversationID'] = $conversationID; - return $obj; + return $self; } /** @@ -319,10 +324,10 @@ public function withConversationID(string $conversationID): self */ public function withDoNotStore(bool $doNotStore): self { - $obj = clone $this; - $obj['doNotStore'] = $doNotStore; + $self = clone $this; + $self['doNotStore'] = $doNotStore; - return $obj; + return $self; } /** @@ -332,10 +337,10 @@ public function withDoNotStore(bool $doNotStore): self */ public function withMetadata(array $metadata): self { - $obj = clone $this; - $obj['metadata'] = $metadata; + $self = clone $this; + $self['metadata'] = $metadata; - return $obj; + return $self; } /** @@ -345,49 +350,53 @@ public function withMetadata(array $metadata): self */ public function withMetaType(MetaType|string $metaType): self { - $obj = clone $this; - $obj['metaType'] = $metaType; + $self = clone $this; + $self['metaType'] = $metaType; - return $obj; + return $self; } /** * (Enterprise) override the channel policies for this moderation request only. * * @param list}|URLMasking|array{ - * id: 'url', + * id?: 'personal_information', flag: bool + * }|ToxicitySevere|array{id?: 'toxicity_severe', flag: bool}|Hate|array{ + * id?: 'hate', flag: bool + * }|Illicit|array{id?: 'illicit', flag: bool}|IllicitDrugs|array{ + * id?: 'illicit_drugs', flag: bool + * }|IllicitAlcohol|array{ + * id?: 'illicit_alcohol', flag: bool + * }|IllicitFirearms|array{ + * id?: 'illicit_firearms', flag: bool + * }|IllicitTobacco|array{ + * id?: 'illicit_tobacco', flag: bool + * }|IllicitGambling|array{id?: 'illicit_gambling', flag: bool}|Sexual|array{ + * id?: 'sexual', flag: bool + * }|Flirtation|array{id?: 'flirtation', flag: bool}|Profanity|array{ + * id?: 'profanity', flag: bool + * }|Violence|array{id?: 'violence', flag: bool}|SelfHarm|array{ + * id?: 'self_harm', flag: bool + * }|Spam|array{id?: 'spam', flag: bool}|SelfPromotion|array{ + * id?: 'self_promotion', flag: bool + * }|Political|array{id?: 'political', flag: bool}|Religion|array{ + * id?: 'religion', flag: bool + * }|CodeAbuse|array{id?: 'code_abuse', flag: bool}|PiiMasking|array{ + * id?: 'pii', entities: array + * }|URLMasking|array{ + * id?: 'url', * entities: array, * }|Guideline|array{ - * id: 'guideline', flag: bool, guidelineKey: string, instructions: string + * id?: 'guideline', flag: bool, guidelineKey: string, instructions: string * }> $policies */ public function withPolicies(array $policies): self { - $obj = clone $this; - $obj['policies'] = $policies; + $self = clone $this; + $self['policies'] = $policies; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Content/Audio.php b/src/Content/ContentSubmitParams/Content/Audio.php index be8e61a..6771041 100644 --- a/src/Content/ContentSubmitParams/Content/Audio.php +++ b/src/Content/ContentSubmitParams/Content/Audio.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Content\ContentSubmitParams\Content; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Audio. * - * @phpstan-type AudioShape = array{type: 'audio', url: string} + * @phpstan-type AudioShape = array{type?: 'audio', url: string} */ final class Audio implements BaseModel { @@ -19,13 +19,13 @@ final class Audio implements BaseModel use SdkModel; /** @var 'audio' $type */ - #[Api] + #[Required] public string $type = 'audio'; /** * The URL of the audio content. */ - #[Api] + #[Required] public string $url; /** @@ -54,11 +54,11 @@ public function __construct() */ public static function with(string $url): self { - $obj = new self; + $self = new self; - $obj['url'] = $url; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $url): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Content/Image.php b/src/Content/ContentSubmitParams/Content/Image.php index e44cb4e..86124e4 100644 --- a/src/Content/ContentSubmitParams/Content/Image.php +++ b/src/Content/ContentSubmitParams/Content/Image.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Content\ContentSubmitParams\Content; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Image. * - * @phpstan-type ImageShape = array{type: 'image', url: string} + * @phpstan-type ImageShape = array{type?: 'image', url: string} */ final class Image implements BaseModel { @@ -19,13 +19,13 @@ final class Image implements BaseModel use SdkModel; /** @var 'image' $type */ - #[Api] + #[Required] public string $type = 'image'; /** * A public URL of the image content. */ - #[Api] + #[Required] public string $url; /** @@ -54,11 +54,11 @@ public function __construct() */ public static function with(string $url): self { - $obj = new self; + $self = new self; - $obj['url'] = $url; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $url): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Content/Object1.php b/src/Content/ContentSubmitParams/Content/Object1.php index b78f19d..a827ee7 100644 --- a/src/Content/ContentSubmitParams/Content/Object1.php +++ b/src/Content/ContentSubmitParams/Content/Object1.php @@ -9,7 +9,7 @@ use ModerationAPI\Content\ContentSubmitParams\Content\Object1\Data\Image; use ModerationAPI\Content\ContentSubmitParams\Content\Object1\Data\Text; use ModerationAPI\Content\ContentSubmitParams\Content\Object1\Data\Video; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -18,7 +18,7 @@ * * @phpstan-type Object1Shape = array{ * data: array, - * type: 'object', + * type?: 'object', * } */ final class Object1 implements BaseModel @@ -27,7 +27,7 @@ final class Object1 implements BaseModel use SdkModel; /** @var 'object' $type */ - #[Api] + #[Required] public string $type = 'object'; /** @@ -35,7 +35,7 @@ final class Object1 implements BaseModel * * @var array $data */ - #[Api(map: Data::class)] + #[Required(map: Data::class)] public array $data; /** @@ -63,42 +63,42 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param array $data */ public static function with(array $data): self { - $obj = new self; + $self = new self; - $obj['data'] = $data; + $self['data'] = $data; - return $obj; + return $self; } /** * Values in the object. Can be mixed content types. * * @param array $data */ public function withData(array $data): self { - $obj = clone $this; - $obj['data'] = $data; + $self = clone $this; + $self['data'] = $data; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Content/Object1/Data/Audio.php b/src/Content/ContentSubmitParams/Content/Object1/Data/Audio.php index e62a625..f354cba 100644 --- a/src/Content/ContentSubmitParams/Content/Object1/Data/Audio.php +++ b/src/Content/ContentSubmitParams/Content/Object1/Data/Audio.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Content\ContentSubmitParams\Content\Object1\Data; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Audio. * - * @phpstan-type AudioShape = array{type: 'audio', url: string} + * @phpstan-type AudioShape = array{type?: 'audio', url: string} */ final class Audio implements BaseModel { @@ -19,13 +19,13 @@ final class Audio implements BaseModel use SdkModel; /** @var 'audio' $type */ - #[Api] + #[Required] public string $type = 'audio'; /** * The URL of the audio content. */ - #[Api] + #[Required] public string $url; /** @@ -54,11 +54,11 @@ public function __construct() */ public static function with(string $url): self { - $obj = new self; + $self = new self; - $obj['url'] = $url; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $url): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Content/Object1/Data/Image.php b/src/Content/ContentSubmitParams/Content/Object1/Data/Image.php index dfe5718..f2f26bb 100644 --- a/src/Content/ContentSubmitParams/Content/Object1/Data/Image.php +++ b/src/Content/ContentSubmitParams/Content/Object1/Data/Image.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Content\ContentSubmitParams\Content\Object1\Data; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Image. * - * @phpstan-type ImageShape = array{type: 'image', url: string} + * @phpstan-type ImageShape = array{type?: 'image', url: string} */ final class Image implements BaseModel { @@ -19,13 +19,13 @@ final class Image implements BaseModel use SdkModel; /** @var 'image' $type */ - #[Api] + #[Required] public string $type = 'image'; /** * A public URL of the image content. */ - #[Api] + #[Required] public string $url; /** @@ -54,11 +54,11 @@ public function __construct() */ public static function with(string $url): self { - $obj = new self; + $self = new self; - $obj['url'] = $url; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $url): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Content/Object1/Data/Text.php b/src/Content/ContentSubmitParams/Content/Object1/Data/Text.php index f145390..4ae5447 100644 --- a/src/Content/ContentSubmitParams/Content/Object1/Data/Text.php +++ b/src/Content/ContentSubmitParams/Content/Object1/Data/Text.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Content\ContentSubmitParams\Content\Object1\Data; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Text. * - * @phpstan-type TextShape = array{text: string, type: 'text'} + * @phpstan-type TextShape = array{text: string, type?: 'text'} */ final class Text implements BaseModel { @@ -19,13 +19,13 @@ final class Text implements BaseModel use SdkModel; /** @var 'text' $type */ - #[Api] + #[Required] public string $type = 'text'; /** * The content text. */ - #[Api] + #[Required] public string $text; /** @@ -54,11 +54,11 @@ public function __construct() */ public static function with(string $text): self { - $obj = new self; + $self = new self; - $obj['text'] = $text; + $self['text'] = $text; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $text): self */ public function withText(string $text): self { - $obj = clone $this; - $obj['text'] = $text; + $self = clone $this; + $self['text'] = $text; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Content/Object1/Data/Video.php b/src/Content/ContentSubmitParams/Content/Object1/Data/Video.php index b9fa6e3..a32009d 100644 --- a/src/Content/ContentSubmitParams/Content/Object1/Data/Video.php +++ b/src/Content/ContentSubmitParams/Content/Object1/Data/Video.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Content\ContentSubmitParams\Content\Object1\Data; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Video. * - * @phpstan-type VideoShape = array{type: 'video', url: string} + * @phpstan-type VideoShape = array{type?: 'video', url: string} */ final class Video implements BaseModel { @@ -19,13 +19,13 @@ final class Video implements BaseModel use SdkModel; /** @var 'video' $type */ - #[Api] + #[Required] public string $type = 'video'; /** * A public URL of the video content. */ - #[Api] + #[Required] public string $url; /** @@ -54,11 +54,11 @@ public function __construct() */ public static function with(string $url): self { - $obj = new self; + $self = new self; - $obj['url'] = $url; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $url): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Content/Text.php b/src/Content/ContentSubmitParams/Content/Text.php index 0c404ca..43406b3 100644 --- a/src/Content/ContentSubmitParams/Content/Text.php +++ b/src/Content/ContentSubmitParams/Content/Text.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Content\ContentSubmitParams\Content; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Text. * - * @phpstan-type TextShape = array{text: string, type: 'text'} + * @phpstan-type TextShape = array{text: string, type?: 'text'} */ final class Text implements BaseModel { @@ -19,13 +19,13 @@ final class Text implements BaseModel use SdkModel; /** @var 'text' $type */ - #[Api] + #[Required] public string $type = 'text'; /** * The content text. */ - #[Api] + #[Required] public string $text; /** @@ -54,11 +54,11 @@ public function __construct() */ public static function with(string $text): self { - $obj = new self; + $self = new self; - $obj['text'] = $text; + $self['text'] = $text; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $text): self */ public function withText(string $text): self { - $obj = clone $this; - $obj['text'] = $text; + $self = clone $this; + $self['text'] = $text; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Content/Video.php b/src/Content/ContentSubmitParams/Content/Video.php index 08b86ea..6bb5dc5 100644 --- a/src/Content/ContentSubmitParams/Content/Video.php +++ b/src/Content/ContentSubmitParams/Content/Video.php @@ -4,14 +4,14 @@ namespace ModerationAPI\Content\ContentSubmitParams\Content; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * Video. * - * @phpstan-type VideoShape = array{type: 'video', url: string} + * @phpstan-type VideoShape = array{type?: 'video', url: string} */ final class Video implements BaseModel { @@ -19,13 +19,13 @@ final class Video implements BaseModel use SdkModel; /** @var 'video' $type */ - #[Api] + #[Required] public string $type = 'video'; /** * A public URL of the video content. */ - #[Api] + #[Required] public string $url; /** @@ -54,11 +54,11 @@ public function __construct() */ public static function with(string $url): self { - $obj = new self; + $self = new self; - $obj['url'] = $url; + $self['url'] = $url; - return $obj; + return $self; } /** @@ -66,9 +66,9 @@ public static function with(string $url): self */ public function withURL(string $url): self { - $obj = clone $this; - $obj['url'] = $url; + $self = clone $this; + $self['url'] = $url; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/CodeAbuse.php b/src/Content/ContentSubmitParams/Policy/CodeAbuse.php index 47a2f7d..1f00b84 100644 --- a/src/Content/ContentSubmitParams/Policy/CodeAbuse.php +++ b/src/Content/ContentSubmitParams/Policy/CodeAbuse.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type CodeAbuseShape = array{id: 'code_abuse', flag: bool} + * @phpstan-type CodeAbuseShape = array{id?: 'code_abuse', flag: bool} */ final class CodeAbuse implements BaseModel { @@ -17,10 +17,10 @@ final class CodeAbuse implements BaseModel use SdkModel; /** @var 'code_abuse' $id */ - #[Api] + #[Required] public string $id = 'code_abuse'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Flirtation.php b/src/Content/ContentSubmitParams/Policy/Flirtation.php index 190dda8..9232ba7 100644 --- a/src/Content/ContentSubmitParams/Policy/Flirtation.php +++ b/src/Content/ContentSubmitParams/Policy/Flirtation.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type FlirtationShape = array{id: 'flirtation', flag: bool} + * @phpstan-type FlirtationShape = array{id?: 'flirtation', flag: bool} */ final class Flirtation implements BaseModel { @@ -17,10 +17,10 @@ final class Flirtation implements BaseModel use SdkModel; /** @var 'flirtation' $id */ - #[Api] + #[Required] public string $id = 'flirtation'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Guideline.php b/src/Content/ContentSubmitParams/Policy/Guideline.php index e209e79..2412b50 100644 --- a/src/Content/ContentSubmitParams/Policy/Guideline.php +++ b/src/Content/ContentSubmitParams/Policy/Guideline.php @@ -4,13 +4,13 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * @phpstan-type GuidelineShape = array{ - * id: 'guideline', flag: bool, guidelineKey: string, instructions: string + * id?: 'guideline', flag: bool, guidelineKey: string, instructions: string * } */ final class Guideline implements BaseModel @@ -19,16 +19,16 @@ final class Guideline implements BaseModel use SdkModel; /** @var 'guideline' $id */ - #[Api] + #[Required] public string $id = 'guideline'; - #[Api] + #[Required] public bool $flag; - #[Api] + #[Required] public string $guidelineKey; - #[Api] + #[Required] public string $instructions; /** @@ -60,36 +60,36 @@ public static function with( string $guidelineKey, string $instructions ): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; - $obj['guidelineKey'] = $guidelineKey; - $obj['instructions'] = $instructions; + $self['flag'] = $flag; + $self['guidelineKey'] = $guidelineKey; + $self['instructions'] = $instructions; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } public function withGuidelineKey(string $guidelineKey): self { - $obj = clone $this; - $obj['guidelineKey'] = $guidelineKey; + $self = clone $this; + $self['guidelineKey'] = $guidelineKey; - return $obj; + return $self; } public function withInstructions(string $instructions): self { - $obj = clone $this; - $obj['instructions'] = $instructions; + $self = clone $this; + $self['instructions'] = $instructions; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Hate.php b/src/Content/ContentSubmitParams/Policy/Hate.php index d78951b..565421e 100644 --- a/src/Content/ContentSubmitParams/Policy/Hate.php +++ b/src/Content/ContentSubmitParams/Policy/Hate.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type HateShape = array{id: 'hate', flag: bool} + * @phpstan-type HateShape = array{id?: 'hate', flag: bool} */ final class Hate implements BaseModel { @@ -17,10 +17,10 @@ final class Hate implements BaseModel use SdkModel; /** @var 'hate' $id */ - #[Api] + #[Required] public string $id = 'hate'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Illicit.php b/src/Content/ContentSubmitParams/Policy/Illicit.php index 86f5b0e..44ad94a 100644 --- a/src/Content/ContentSubmitParams/Policy/Illicit.php +++ b/src/Content/ContentSubmitParams/Policy/Illicit.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type IllicitShape = array{id: 'illicit', flag: bool} + * @phpstan-type IllicitShape = array{id?: 'illicit', flag: bool} */ final class Illicit implements BaseModel { @@ -17,10 +17,10 @@ final class Illicit implements BaseModel use SdkModel; /** @var 'illicit' $id */ - #[Api] + #[Required] public string $id = 'illicit'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/IllicitAlcohol.php b/src/Content/ContentSubmitParams/Policy/IllicitAlcohol.php index 24e4f73..de716aa 100644 --- a/src/Content/ContentSubmitParams/Policy/IllicitAlcohol.php +++ b/src/Content/ContentSubmitParams/Policy/IllicitAlcohol.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type IllicitAlcoholShape = array{id: 'illicit_alcohol', flag: bool} + * @phpstan-type IllicitAlcoholShape = array{id?: 'illicit_alcohol', flag: bool} */ final class IllicitAlcohol implements BaseModel { @@ -17,10 +17,10 @@ final class IllicitAlcohol implements BaseModel use SdkModel; /** @var 'illicit_alcohol' $id */ - #[Api] + #[Required] public string $id = 'illicit_alcohol'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/IllicitDrugs.php b/src/Content/ContentSubmitParams/Policy/IllicitDrugs.php index 80eaa7e..9ac3cdd 100644 --- a/src/Content/ContentSubmitParams/Policy/IllicitDrugs.php +++ b/src/Content/ContentSubmitParams/Policy/IllicitDrugs.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type IllicitDrugsShape = array{id: 'illicit_drugs', flag: bool} + * @phpstan-type IllicitDrugsShape = array{id?: 'illicit_drugs', flag: bool} */ final class IllicitDrugs implements BaseModel { @@ -17,10 +17,10 @@ final class IllicitDrugs implements BaseModel use SdkModel; /** @var 'illicit_drugs' $id */ - #[Api] + #[Required] public string $id = 'illicit_drugs'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/IllicitFirearms.php b/src/Content/ContentSubmitParams/Policy/IllicitFirearms.php index f9c1923..67a07d8 100644 --- a/src/Content/ContentSubmitParams/Policy/IllicitFirearms.php +++ b/src/Content/ContentSubmitParams/Policy/IllicitFirearms.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type IllicitFirearmsShape = array{id: 'illicit_firearms', flag: bool} + * @phpstan-type IllicitFirearmsShape = array{id?: 'illicit_firearms', flag: bool} */ final class IllicitFirearms implements BaseModel { @@ -17,10 +17,10 @@ final class IllicitFirearms implements BaseModel use SdkModel; /** @var 'illicit_firearms' $id */ - #[Api] + #[Required] public string $id = 'illicit_firearms'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/IllicitGambling.php b/src/Content/ContentSubmitParams/Policy/IllicitGambling.php index c661d2b..5b962f3 100644 --- a/src/Content/ContentSubmitParams/Policy/IllicitGambling.php +++ b/src/Content/ContentSubmitParams/Policy/IllicitGambling.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type IllicitGamblingShape = array{id: 'illicit_gambling', flag: bool} + * @phpstan-type IllicitGamblingShape = array{id?: 'illicit_gambling', flag: bool} */ final class IllicitGambling implements BaseModel { @@ -17,10 +17,10 @@ final class IllicitGambling implements BaseModel use SdkModel; /** @var 'illicit_gambling' $id */ - #[Api] + #[Required] public string $id = 'illicit_gambling'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/IllicitTobacco.php b/src/Content/ContentSubmitParams/Policy/IllicitTobacco.php index 9924510..df3bd3c 100644 --- a/src/Content/ContentSubmitParams/Policy/IllicitTobacco.php +++ b/src/Content/ContentSubmitParams/Policy/IllicitTobacco.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type IllicitTobaccoShape = array{id: 'illicit_tobacco', flag: bool} + * @phpstan-type IllicitTobaccoShape = array{id?: 'illicit_tobacco', flag: bool} */ final class IllicitTobacco implements BaseModel { @@ -17,10 +17,10 @@ final class IllicitTobacco implements BaseModel use SdkModel; /** @var 'illicit_tobacco' $id */ - #[Api] + #[Required] public string $id = 'illicit_tobacco'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/PersonalInformation.php b/src/Content/ContentSubmitParams/Policy/PersonalInformation.php index 0210782..3f8c6b3 100644 --- a/src/Content/ContentSubmitParams/Policy/PersonalInformation.php +++ b/src/Content/ContentSubmitParams/Policy/PersonalInformation.php @@ -4,13 +4,13 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** * @phpstan-type PersonalInformationShape = array{ - * id: 'personal_information', flag: bool + * id?: 'personal_information', flag: bool * } */ final class PersonalInformation implements BaseModel @@ -19,10 +19,10 @@ final class PersonalInformation implements BaseModel use SdkModel; /** @var 'personal_information' $id */ - #[Api] + #[Required] public string $id = 'personal_information'; - #[Api] + #[Required] public bool $flag; /** @@ -51,18 +51,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/PiiMasking.php b/src/Content/ContentSubmitParams/Policy/PiiMasking.php index ac49b6d..b08c642 100644 --- a/src/Content/ContentSubmitParams/Policy/PiiMasking.php +++ b/src/Content/ContentSubmitParams/Policy/PiiMasking.php @@ -6,12 +6,14 @@ use ModerationAPI\Content\ContentSubmitParams\Policy\PiiMasking\Entity; use ModerationAPI\Content\ContentSubmitParams\Policy\PiiMasking\Entity\ID; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type PiiMaskingShape = array{id: 'pii', entities: array} + * @phpstan-type PiiMaskingShape = array{ + * id?: 'pii', entities: array + * } */ final class PiiMasking implements BaseModel { @@ -19,11 +21,11 @@ final class PiiMasking implements BaseModel use SdkModel; /** @var 'pii' $id */ - #[Api] + #[Required] public string $id = 'pii'; /** @var array $entities */ - #[Api(map: Entity::class)] + #[Required(map: Entity::class)] public array $entities; /** @@ -60,11 +62,11 @@ public function __construct() */ public static function with(array $entities): self { - $obj = new self; + $self = new self; - $obj['entities'] = $entities; + $self['entities'] = $entities; - return $obj; + return $self; } /** @@ -78,9 +80,9 @@ public static function with(array $entities): self */ public function withEntities(array $entities): self { - $obj = clone $this; - $obj['entities'] = $entities; + $self = clone $this; + $self['entities'] = $entities; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/PiiMasking/Entity.php b/src/Content/ContentSubmitParams/Policy/PiiMasking/Entity.php index 183578f..240c287 100644 --- a/src/Content/ContentSubmitParams/Policy/PiiMasking/Entity.php +++ b/src/Content/ContentSubmitParams/Policy/PiiMasking/Entity.php @@ -5,7 +5,8 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy\PiiMasking; use ModerationAPI\Content\ContentSubmitParams\Policy\PiiMasking\Entity\ID; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -24,19 +25,19 @@ final class Entity implements BaseModel use SdkModel; /** @var value-of $id */ - #[Api(enum: ID::class)] + #[Required(enum: ID::class)] public string $id; - #[Api] + #[Required] public bool $enable; - #[Api] + #[Required] public bool $flag; - #[Api] + #[Required] public bool $shouldMask; - #[Api(optional: true)] + #[Optional] public ?string $mask; /** @@ -72,16 +73,16 @@ public static function with( bool $shouldMask, ?string $mask = null, ): self { - $obj = new self; + $self = new self; - $obj['id'] = $id; - $obj['enable'] = $enable; - $obj['flag'] = $flag; - $obj['shouldMask'] = $shouldMask; + $self['id'] = $id; + $self['enable'] = $enable; + $self['flag'] = $flag; + $self['shouldMask'] = $shouldMask; - null !== $mask && $obj['mask'] = $mask; + null !== $mask && $self['mask'] = $mask; - return $obj; + return $self; } /** @@ -89,41 +90,41 @@ public static function with( */ public function withID(ID|string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } public function withEnable(bool $enable): self { - $obj = clone $this; - $obj['enable'] = $enable; + $self = clone $this; + $self['enable'] = $enable; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } public function withShouldMask(bool $shouldMask): self { - $obj = clone $this; - $obj['shouldMask'] = $shouldMask; + $self = clone $this; + $self['shouldMask'] = $shouldMask; - return $obj; + return $self; } public function withMask(string $mask): self { - $obj = clone $this; - $obj['mask'] = $mask; + $self = clone $this; + $self['mask'] = $mask; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Political.php b/src/Content/ContentSubmitParams/Policy/Political.php index bf61891..53a0ac6 100644 --- a/src/Content/ContentSubmitParams/Policy/Political.php +++ b/src/Content/ContentSubmitParams/Policy/Political.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type PoliticalShape = array{id: 'political', flag: bool} + * @phpstan-type PoliticalShape = array{id?: 'political', flag: bool} */ final class Political implements BaseModel { @@ -17,10 +17,10 @@ final class Political implements BaseModel use SdkModel; /** @var 'political' $id */ - #[Api] + #[Required] public string $id = 'political'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Profanity.php b/src/Content/ContentSubmitParams/Policy/Profanity.php index 5cb4fca..7200d73 100644 --- a/src/Content/ContentSubmitParams/Policy/Profanity.php +++ b/src/Content/ContentSubmitParams/Policy/Profanity.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type ProfanityShape = array{id: 'profanity', flag: bool} + * @phpstan-type ProfanityShape = array{id?: 'profanity', flag: bool} */ final class Profanity implements BaseModel { @@ -17,10 +17,10 @@ final class Profanity implements BaseModel use SdkModel; /** @var 'profanity' $id */ - #[Api] + #[Required] public string $id = 'profanity'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Religion.php b/src/Content/ContentSubmitParams/Policy/Religion.php index 0f809b2..a1fe729 100644 --- a/src/Content/ContentSubmitParams/Policy/Religion.php +++ b/src/Content/ContentSubmitParams/Policy/Religion.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type ReligionShape = array{id: 'religion', flag: bool} + * @phpstan-type ReligionShape = array{id?: 'religion', flag: bool} */ final class Religion implements BaseModel { @@ -17,10 +17,10 @@ final class Religion implements BaseModel use SdkModel; /** @var 'religion' $id */ - #[Api] + #[Required] public string $id = 'religion'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/SelfHarm.php b/src/Content/ContentSubmitParams/Policy/SelfHarm.php index cdc37ac..dab39ce 100644 --- a/src/Content/ContentSubmitParams/Policy/SelfHarm.php +++ b/src/Content/ContentSubmitParams/Policy/SelfHarm.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type SelfHarmShape = array{id: 'self_harm', flag: bool} + * @phpstan-type SelfHarmShape = array{id?: 'self_harm', flag: bool} */ final class SelfHarm implements BaseModel { @@ -17,10 +17,10 @@ final class SelfHarm implements BaseModel use SdkModel; /** @var 'self_harm' $id */ - #[Api] + #[Required] public string $id = 'self_harm'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/SelfPromotion.php b/src/Content/ContentSubmitParams/Policy/SelfPromotion.php index 5f4bc35..47a7da4 100644 --- a/src/Content/ContentSubmitParams/Policy/SelfPromotion.php +++ b/src/Content/ContentSubmitParams/Policy/SelfPromotion.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type SelfPromotionShape = array{id: 'self_promotion', flag: bool} + * @phpstan-type SelfPromotionShape = array{id?: 'self_promotion', flag: bool} */ final class SelfPromotion implements BaseModel { @@ -17,10 +17,10 @@ final class SelfPromotion implements BaseModel use SdkModel; /** @var 'self_promotion' $id */ - #[Api] + #[Required] public string $id = 'self_promotion'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Sexual.php b/src/Content/ContentSubmitParams/Policy/Sexual.php index 623a3b4..73d7786 100644 --- a/src/Content/ContentSubmitParams/Policy/Sexual.php +++ b/src/Content/ContentSubmitParams/Policy/Sexual.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type SexualShape = array{id: 'sexual', flag: bool} + * @phpstan-type SexualShape = array{id?: 'sexual', flag: bool} */ final class Sexual implements BaseModel { @@ -17,10 +17,10 @@ final class Sexual implements BaseModel use SdkModel; /** @var 'sexual' $id */ - #[Api] + #[Required] public string $id = 'sexual'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Spam.php b/src/Content/ContentSubmitParams/Policy/Spam.php index 5a2c62d..8981910 100644 --- a/src/Content/ContentSubmitParams/Policy/Spam.php +++ b/src/Content/ContentSubmitParams/Policy/Spam.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type SpamShape = array{id: 'spam', flag: bool} + * @phpstan-type SpamShape = array{id?: 'spam', flag: bool} */ final class Spam implements BaseModel { @@ -17,10 +17,10 @@ final class Spam implements BaseModel use SdkModel; /** @var 'spam' $id */ - #[Api] + #[Required] public string $id = 'spam'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Toxicity.php b/src/Content/ContentSubmitParams/Policy/Toxicity.php index 6b1788f..588915b 100644 --- a/src/Content/ContentSubmitParams/Policy/Toxicity.php +++ b/src/Content/ContentSubmitParams/Policy/Toxicity.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type ToxicityShape = array{id: 'toxicity', flag: bool} + * @phpstan-type ToxicityShape = array{id?: 'toxicity', flag: bool} */ final class Toxicity implements BaseModel { @@ -17,10 +17,10 @@ final class Toxicity implements BaseModel use SdkModel; /** @var 'toxicity' $id */ - #[Api] + #[Required] public string $id = 'toxicity'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/ToxicitySevere.php b/src/Content/ContentSubmitParams/Policy/ToxicitySevere.php index 7f84835..e54e9e2 100644 --- a/src/Content/ContentSubmitParams/Policy/ToxicitySevere.php +++ b/src/Content/ContentSubmitParams/Policy/ToxicitySevere.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type ToxicitySevereShape = array{id: 'toxicity_severe', flag: bool} + * @phpstan-type ToxicitySevereShape = array{id?: 'toxicity_severe', flag: bool} */ final class ToxicitySevere implements BaseModel { @@ -17,10 +17,10 @@ final class ToxicitySevere implements BaseModel use SdkModel; /** @var 'toxicity_severe' $id */ - #[Api] + #[Required] public string $id = 'toxicity_severe'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/URLMasking.php b/src/Content/ContentSubmitParams/Policy/URLMasking.php index 23ff1f7..87d6ca5 100644 --- a/src/Content/ContentSubmitParams/Policy/URLMasking.php +++ b/src/Content/ContentSubmitParams/Policy/URLMasking.php @@ -6,12 +6,14 @@ use ModerationAPI\Content\ContentSubmitParams\Policy\URLMasking\Entity; use ModerationAPI\Content\ContentSubmitParams\Policy\URLMasking\Entity\ID; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type URLMaskingShape = array{id: 'url', entities: array} + * @phpstan-type URLMaskingShape = array{ + * id?: 'url', entities: array + * } */ final class URLMasking implements BaseModel { @@ -19,11 +21,11 @@ final class URLMasking implements BaseModel use SdkModel; /** @var 'url' $id */ - #[Api] + #[Required] public string $id = 'url'; /** @var array $entities */ - #[Api(map: Entity::class)] + #[Required(map: Entity::class)] public array $entities; /** @@ -60,11 +62,11 @@ public function __construct() */ public static function with(array $entities): self { - $obj = new self; + $self = new self; - $obj['entities'] = $entities; + $self['entities'] = $entities; - return $obj; + return $self; } /** @@ -78,9 +80,9 @@ public static function with(array $entities): self */ public function withEntities(array $entities): self { - $obj = clone $this; - $obj['entities'] = $entities; + $self = clone $this; + $self['entities'] = $entities; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/URLMasking/Entity.php b/src/Content/ContentSubmitParams/Policy/URLMasking/Entity.php index 3bb4c4e..cfe0c83 100644 --- a/src/Content/ContentSubmitParams/Policy/URLMasking/Entity.php +++ b/src/Content/ContentSubmitParams/Policy/URLMasking/Entity.php @@ -5,7 +5,8 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy\URLMasking; use ModerationAPI\Content\ContentSubmitParams\Policy\URLMasking\Entity\ID; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; @@ -24,19 +25,19 @@ final class Entity implements BaseModel use SdkModel; /** @var value-of $id */ - #[Api(enum: ID::class)] + #[Required(enum: ID::class)] public string $id; - #[Api] + #[Required] public bool $enable; - #[Api] + #[Required] public bool $flag; - #[Api] + #[Required] public bool $shouldMask; - #[Api(optional: true)] + #[Optional] public ?string $mask; /** @@ -72,16 +73,16 @@ public static function with( bool $shouldMask, ?string $mask = null, ): self { - $obj = new self; + $self = new self; - $obj['id'] = $id; - $obj['enable'] = $enable; - $obj['flag'] = $flag; - $obj['shouldMask'] = $shouldMask; + $self['id'] = $id; + $self['enable'] = $enable; + $self['flag'] = $flag; + $self['shouldMask'] = $shouldMask; - null !== $mask && $obj['mask'] = $mask; + null !== $mask && $self['mask'] = $mask; - return $obj; + return $self; } /** @@ -89,41 +90,41 @@ public static function with( */ public function withID(ID|string $id): self { - $obj = clone $this; - $obj['id'] = $id; + $self = clone $this; + $self['id'] = $id; - return $obj; + return $self; } public function withEnable(bool $enable): self { - $obj = clone $this; - $obj['enable'] = $enable; + $self = clone $this; + $self['enable'] = $enable; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } public function withShouldMask(bool $shouldMask): self { - $obj = clone $this; - $obj['shouldMask'] = $shouldMask; + $self = clone $this; + $self['shouldMask'] = $shouldMask; - return $obj; + return $self; } public function withMask(string $mask): self { - $obj = clone $this; - $obj['mask'] = $mask; + $self = clone $this; + $self['mask'] = $mask; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitParams/Policy/Violence.php b/src/Content/ContentSubmitParams/Policy/Violence.php index f12b48f..a957865 100644 --- a/src/Content/ContentSubmitParams/Policy/Violence.php +++ b/src/Content/ContentSubmitParams/Policy/Violence.php @@ -4,12 +4,12 @@ namespace ModerationAPI\Content\ContentSubmitParams\Policy; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; use ModerationAPI\Core\Contracts\BaseModel; /** - * @phpstan-type ViolenceShape = array{id: 'violence', flag: bool} + * @phpstan-type ViolenceShape = array{id?: 'violence', flag: bool} */ final class Violence implements BaseModel { @@ -17,10 +17,10 @@ final class Violence implements BaseModel use SdkModel; /** @var 'violence' $id */ - #[Api] + #[Required] public string $id = 'violence'; - #[Api] + #[Required] public bool $flag; /** @@ -49,18 +49,18 @@ public function __construct() */ public static function with(bool $flag): self { - $obj = new self; + $self = new self; - $obj['flag'] = $flag; + $self['flag'] = $flag; - return $obj; + return $self; } public function withFlag(bool $flag): self { - $obj = clone $this; - $obj['flag'] = $flag; + $self = clone $this; + $self['flag'] = $flag; - return $obj; + return $self; } } diff --git a/src/Content/ContentSubmitResponse.php b/src/Content/ContentSubmitResponse.php index da666e2..48cff18 100644 --- a/src/Content/ContentSubmitResponse.php +++ b/src/Content/ContentSubmitResponse.php @@ -28,11 +28,10 @@ use ModerationAPI\Content\ContentSubmitResponse\Recommendation; use ModerationAPI\Content\ContentSubmitResponse\Recommendation\Action; use ModerationAPI\Content\ContentSubmitResponse\Recommendation\ReasonCode; -use ModerationAPI\Core\Attributes\Api; +use ModerationAPI\Core\Attributes\Optional; +use ModerationAPI\Core\Attributes\Required; use ModerationAPI\Core\Concerns\SdkModel; -use ModerationAPI\Core\Concerns\SdkResponse; use ModerationAPI\Core\Contracts\BaseModel; -use ModerationAPI\Core\Conversion\Contracts\ResponseConverter; /** * @phpstan-type ContentSubmitResponseShape = array{ @@ -46,29 +45,27 @@ * errors?: list|null, * } */ -final class ContentSubmitResponse implements BaseModel, ResponseConverter +final class ContentSubmitResponse implements BaseModel { /** @use SdkModel */ use SdkModel; - use SdkResponse; - /** * The author of the content if your account has authors enabled. Requires you to send authorId when submitting content. */ - #[Api] + #[Required] public ?Author $author; /** * Potentially modified content. */ - #[Api] + #[Required] public Content $content; /** * The evaluation of the content after running the channel policies. */ - #[Api] + #[Required] public Evaluation $evaluation; /** @@ -76,13 +73,13 @@ final class ContentSubmitResponse implements BaseModel, ResponseConverter * * @var list $insights */ - #[Api(list: Insight::class)] + #[Required(list: Insight::class)] public array $insights; /** * Metadata about the moderation request. */ - #[Api] + #[Required] public Meta $meta; /** @@ -90,13 +87,13 @@ final class ContentSubmitResponse implements BaseModel, ResponseConverter * * @var list $policies */ - #[Api(list: Policy::class)] + #[Required(list: Policy::class)] public array $policies; /** * The recommendation for the content based on the evaluation. */ - #[Api] + #[Required] public Recommendation $recommendation; /** @@ -104,7 +101,7 @@ final class ContentSubmitResponse implements BaseModel, ResponseConverter * * @var list|null $errors */ - #[Api(list: Error::class, optional: true)] + #[Optional(list: Error::class)] public ?array $errors; /** @@ -150,8 +147,8 @@ public function __construct() * id: string, * block: Block|null, * status: value-of, - * trust_level: TrustLevel, - * external_id?: string|null, + * trustLevel: TrustLevel, + * externalID?: string|null, * }|null $author * @param Content|array{ * id: string, @@ -159,43 +156,43 @@ public function __construct() * modified: string|array|array|null, * } $content * @param Evaluation|array{ - * flag_probability: float, + * flagProbability: float, * flagged: bool, - * severity_score: float, - * unicode_spoofed?: bool|null, + * severityScore: float, + * unicodeSpoofed?: bool|null, * } $evaluation * @param list|null, * }|LanguageInsight|array{ - * id: 'language', probability: float, type: 'insight', value: string|null + * id?: 'language', probability: float, type?: 'insight', value: string|null * }> $insights * @param Meta|array{ - * channel_key: string, + * channelKey: string, * status: value-of, * timestamp: float, * usage: float, - * processing_time?: string|null, + * processingTime?: string|null, * } $meta * @param list|null, + * type?: 'classifier', + * flaggedFields?: list|null, * labels?: list