Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.15.0"
".": "0.16.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 27
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-4750d2b76a21489b3dd82d7b7ad6d4cccc33b9827821c7fb5120cfdcc23b9088.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api/moderation-api-5d59d9b7fffd1ac6f329a62fdc42c97bfa7821168eeea0d686a2d48d90963c34.yml
openapi_spec_hash: 61cd471624938b233f02dc17416946f2
config_hash: 13d10207114afb65f7ac4e21f4c0e358
config_hash: 9d144cc6c49d3fd53e5b4472c1e22165
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.16.0 (2026-05-08)

Full Changelog: [v0.15.0...v0.16.0](https://github.com/moderation-api/sdk-php/compare/v0.15.0...v0.16.0)

### Features

* **api:** manual updates ([1367008](https://github.com/moderation-api/sdk-php/commit/1367008288383ae72f728c0bef059f04e1c8d9be))

## 0.15.0 (2026-05-08)

Full Changelog: [v0.14.0...v0.15.0](https://github.com/moderation-api/sdk-php/compare/v0.14.0...v0.15.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The REST API documentation can be found on [docs.moderationapi.com](https://docs
<!-- x-release-please-start-version -->

```
composer require "moderation-api/sdk-php 0.15.0"
composer require "moderation-api/sdk-php 0.16.0"
```

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

declare(strict_types=1);

namespace ModerationAPI\Queue;

use ModerationAPI\Core\Concerns\SdkUnion;
use ModerationAPI\Core\Conversion\Contracts\Converter;
use ModerationAPI\Core\Conversion\Contracts\ConverterSource;
use ModerationAPI\Queue\WebhookEvent\AuthorActionEvent;
use ModerationAPI\Queue\WebhookEvent\AuthorBlockedEvent;
use ModerationAPI\Queue\WebhookEvent\AuthorSuspendedEvent;
use ModerationAPI\Queue\WebhookEvent\AuthorTrustLevelChangedEvent;
use ModerationAPI\Queue\WebhookEvent\AuthorUnblockedEvent;
use ModerationAPI\Queue\WebhookEvent\AuthorUpdatedEvent;
use ModerationAPI\Queue\WebhookEvent\QueueItemActionEvent;
use ModerationAPI\Queue\WebhookEvent\QueueItemAllowedEvent;
use ModerationAPI\Queue\WebhookEvent\QueueItemCompletedEvent;
use ModerationAPI\Queue\WebhookEvent\QueueItemRejectedEvent;

/**
* Discriminated union of every v2 webhook event. Switch on `type` to narrow to a specific event shape.
*
* @phpstan-import-type AuthorBlockedEventShape from \ModerationAPI\Queue\WebhookEvent\AuthorBlockedEvent
* @phpstan-import-type AuthorUnblockedEventShape from \ModerationAPI\Queue\WebhookEvent\AuthorUnblockedEvent
* @phpstan-import-type AuthorSuspendedEventShape from \ModerationAPI\Queue\WebhookEvent\AuthorSuspendedEvent
* @phpstan-import-type AuthorUpdatedEventShape from \ModerationAPI\Queue\WebhookEvent\AuthorUpdatedEvent
* @phpstan-import-type AuthorTrustLevelChangedEventShape from \ModerationAPI\Queue\WebhookEvent\AuthorTrustLevelChangedEvent
* @phpstan-import-type AuthorActionEventShape from \ModerationAPI\Queue\WebhookEvent\AuthorActionEvent
* @phpstan-import-type QueueItemCompletedEventShape from \ModerationAPI\Queue\WebhookEvent\QueueItemCompletedEvent
* @phpstan-import-type QueueItemActionEventShape from \ModerationAPI\Queue\WebhookEvent\QueueItemActionEvent
* @phpstan-import-type QueueItemRejectedEventShape from \ModerationAPI\Queue\WebhookEvent\QueueItemRejectedEvent
* @phpstan-import-type QueueItemAllowedEventShape from \ModerationAPI\Queue\WebhookEvent\QueueItemAllowedEvent
*
* @phpstan-type WebhookEventVariants = AuthorBlockedEvent|AuthorUnblockedEvent|AuthorSuspendedEvent|AuthorUpdatedEvent|AuthorTrustLevelChangedEvent|AuthorActionEvent|QueueItemCompletedEvent|QueueItemActionEvent|QueueItemRejectedEvent|QueueItemAllowedEvent
* @phpstan-type WebhookEventShape = WebhookEventVariants|AuthorBlockedEventShape|AuthorUnblockedEventShape|AuthorSuspendedEventShape|AuthorUpdatedEventShape|AuthorTrustLevelChangedEventShape|AuthorActionEventShape|QueueItemCompletedEventShape|QueueItemActionEventShape|QueueItemRejectedEventShape|QueueItemAllowedEventShape
*/
final class WebhookEvent implements ConverterSource
{
use SdkUnion;

public static function discriminator(): string
{
return 'type';
}

/**
* @return list<string|Converter|ConverterSource>|array<string,string|Converter|ConverterSource>
*/
public static function variants(): array
{
return [
'author.blocked' => AuthorBlockedEvent::class,
'author.unblocked' => AuthorUnblockedEvent::class,
'author.suspended' => AuthorSuspendedEvent::class,
'author.updated' => AuthorUpdatedEvent::class,
'author.trust_level_changed' => AuthorTrustLevelChangedEvent::class,
'author.action' => AuthorActionEvent::class,
'queue_item.completed' => QueueItemCompletedEvent::class,
'queue_item.action' => QueueItemActionEvent::class,
'queue_item.rejected' => QueueItemRejectedEvent::class,
'queue_item.allowed' => QueueItemAllowedEvent::class,
];
}
}
151 changes: 151 additions & 0 deletions src/Queue/WebhookEvent/AuthorActionEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php

declare(strict_types=1);

namespace ModerationAPI\Queue\WebhookEvent;

use ModerationAPI\Core\Attributes\Required;
use ModerationAPI\Core\Concerns\SdkModel;
use ModerationAPI\Core\Contracts\BaseModel;
use ModerationAPI\Queue\WebhookEvent\AuthorActionEvent\Data;

/**
* @phpstan-import-type DataShape from \ModerationAPI\Queue\WebhookEvent\AuthorActionEvent\Data
*
* @phpstan-type AuthorActionEventShape = array{
* id: string,
* apiVersion: 'v2',
* created: \DateTimeInterface,
* data: Data|DataShape,
* type: 'author.action',
* }
*/
final class AuthorActionEvent implements BaseModel
{
/** @use SdkModel<AuthorActionEventShape> */
use SdkModel;

/** @var 'v2' $apiVersion */
#[Required('api_version')]
public string $apiVersion = 'v2';

/**
* The event type.
*
* @var 'author.action' $type
*/
#[Required]
public string $type = 'author.action';

/**
* Stable event ID. Use this to dedupe retries.
*/
#[Required]
public string $id;

/**
* ISO 8601 timestamp of when the event was emitted.
*/
#[Required]
public \DateTimeInterface $created;

#[Required]
public Data $data;

/**
* `new AuthorActionEvent()` is missing required properties by the API.
*
* To enforce required parameters use
* ```
* AuthorActionEvent::with(id: ..., created: ..., data: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new AuthorActionEvent)->withID(...)->withCreated(...)->withData(...)
* ```
*/
public function __construct()
{
$this->initialize();
}

/**
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param Data|DataShape $data
*/
public static function with(
string $id,
\DateTimeInterface $created,
Data|array $data
): self {
$self = new self;

$self['id'] = $id;
$self['created'] = $created;
$self['data'] = $data;

return $self;
}

/**
* Stable event ID. Use this to dedupe retries.
*/
public function withID(string $id): self
{
$self = clone $this;
$self['id'] = $id;

return $self;
}

/**
* @param 'v2' $apiVersion
*/
public function withAPIVersion(string $apiVersion): self
{
$self = clone $this;
$self['apiVersion'] = $apiVersion;

return $self;
}

/**
* ISO 8601 timestamp of when the event was emitted.
*/
public function withCreated(\DateTimeInterface $created): self
{
$self = clone $this;
$self['created'] = $created;

return $self;
}

/**
* @param Data|DataShape $data
*/
public function withData(Data|array $data): self
{
$self = clone $this;
$self['data'] = $data;

return $self;
}

/**
* The event type.
*
* @param 'author.action' $type
*/
public function withType(string $type): self
{
$self = clone $this;
$self['type'] = $type;

return $self;
}
}
70 changes: 70 additions & 0 deletions src/Queue/WebhookEvent/AuthorActionEvent/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

declare(strict_types=1);

namespace ModerationAPI\Queue\WebhookEvent\AuthorActionEvent;

use ModerationAPI\Core\Attributes\Required;
use ModerationAPI\Core\Concerns\SdkModel;
use ModerationAPI\Core\Contracts\BaseModel;
use ModerationAPI\Queue\WebhookEvent\AuthorActionEvent\Data\Object_;

/**
* @phpstan-import-type ObjectShape from \ModerationAPI\Queue\WebhookEvent\AuthorActionEvent\Data\Object_
*
* @phpstan-type DataShape = array{object: Object_|ObjectShape}
*/
final class Data implements BaseModel
{
/** @use SdkModel<DataShape> */
use SdkModel;

#[Required]
public Object_ $object;

/**
* `new Data()` is missing required properties by the API.
*
* To enforce required parameters use
* ```
* Data::with(object: ...)
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new Data)->withObject(...)
* ```
*/
public function __construct()
{
$this->initialize();
}

/**
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param Object_|ObjectShape $object
*/
public static function with(Object_|array $object): self
{
$self = new self;

$self['object'] = $object;

return $self;
}

/**
* @param Object_|ObjectShape $object
*/
public function withObject(Object_|array $object): self
{
$self = clone $this;
$self['object'] = $object;

return $self;
}
}
Loading