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.9.0"
".": "0.10.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%2Fmoderation-api-fb621278289bf54b9c00e8cadce0cc9fa89506ec908464fdb99d66620a953f0a.yml
openapi_spec_hash: c2a3e2de6f910fc28c7ccd88bf722e06
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/moderation-api%2Fmoderation-api-ad93e48ef2ee1066fe81553c7ac1f3be24037c6e1976778acb8b13baedbe5821.yml
openapi_spec_hash: 06e01ccb380f068bff3a571b58089a94
config_hash: 6b825a08e19dfb747c5dc1766502b789
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.10.0 (2026-03-16)

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

### Features

* **api:** api update ([56bebd7](https://github.com/moderation-api/sdk-php/commit/56bebd7744e60e179eae796ab5eb41667574b92f))


### Chores

* **internal:** codegen related update ([5ef0410](https://github.com/moderation-api/sdk-php/commit/5ef04106c2b4ab4c3d3eeff8c13798016aefca5a))

## 0.9.0 (2026-03-03)

Full Changelog: [v0.8.0...v0.9.0](https://github.com/moderation-api/sdk-php/compare/v0.8.0...v0.9.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.9.0"
composer require "moderation-api/sdk-php 0.10.0"
```

<!-- x-release-please-end -->
Expand Down
7 changes: 5 additions & 2 deletions src/Content/ContentSubmitParams/Policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use ModerationAPI\Content\ContentSubmitParams\Policy\Toxicity;
use ModerationAPI\Content\ContentSubmitParams\Policy\ToxicitySevere;
use ModerationAPI\Content\ContentSubmitParams\Policy\URLMasking;
use ModerationAPI\Content\ContentSubmitParams\Policy\URLRisk;
use ModerationAPI\Content\ContentSubmitParams\Policy\Violence;
use ModerationAPI\Core\Concerns\SdkUnion;
use ModerationAPI\Core\Conversion\Contracts\Converter;
Expand Down Expand Up @@ -60,10 +61,11 @@
* @phpstan-import-type CodeAbuseShape from \ModerationAPI\Content\ContentSubmitParams\Policy\CodeAbuse
* @phpstan-import-type PiiMaskingShape from \ModerationAPI\Content\ContentSubmitParams\Policy\PiiMasking
* @phpstan-import-type URLMaskingShape from \ModerationAPI\Content\ContentSubmitParams\Policy\URLMasking
* @phpstan-import-type URLRiskShape from \ModerationAPI\Content\ContentSubmitParams\Policy\URLRisk
* @phpstan-import-type GuidelineShape from \ModerationAPI\Content\ContentSubmitParams\Policy\Guideline
*
* @phpstan-type PolicyVariants = Toxicity|PersonalInformation|ToxicitySevere|Hate|Illicit|IllicitDrugs|IllicitAlcohol|IllicitFirearms|IllicitTobacco|IllicitGambling|Cannabis|Adult|Crypto|Sexual|Flirtation|Profanity|Violence|SelfHarm|Spam|SelfPromotion|Political|Religion|CodeAbuse|PiiMasking|URLMasking|Guideline
* @phpstan-type PolicyShape = PolicyVariants|ToxicityShape|PersonalInformationShape|ToxicitySevereShape|HateShape|IllicitShape|IllicitDrugsShape|IllicitAlcoholShape|IllicitFirearmsShape|IllicitTobaccoShape|IllicitGamblingShape|CannabisShape|AdultShape|CryptoShape|SexualShape|FlirtationShape|ProfanityShape|ViolenceShape|SelfHarmShape|SpamShape|SelfPromotionShape|PoliticalShape|ReligionShape|CodeAbuseShape|PiiMaskingShape|URLMaskingShape|GuidelineShape
* @phpstan-type PolicyVariants = Toxicity|PersonalInformation|ToxicitySevere|Hate|Illicit|IllicitDrugs|IllicitAlcohol|IllicitFirearms|IllicitTobacco|IllicitGambling|Cannabis|Adult|Crypto|Sexual|Flirtation|Profanity|Violence|SelfHarm|Spam|SelfPromotion|Political|Religion|CodeAbuse|PiiMasking|URLMasking|URLRisk|Guideline
* @phpstan-type PolicyShape = PolicyVariants|ToxicityShape|PersonalInformationShape|ToxicitySevereShape|HateShape|IllicitShape|IllicitDrugsShape|IllicitAlcoholShape|IllicitFirearmsShape|IllicitTobaccoShape|IllicitGamblingShape|CannabisShape|AdultShape|CryptoShape|SexualShape|FlirtationShape|ProfanityShape|ViolenceShape|SelfHarmShape|SpamShape|SelfPromotionShape|PoliticalShape|ReligionShape|CodeAbuseShape|PiiMaskingShape|URLMaskingShape|URLRiskShape|GuidelineShape
*/
final class Policy implements ConverterSource
{
Expand Down Expand Up @@ -100,6 +102,7 @@ public static function variants(): array
CodeAbuse::class,
PiiMasking::class,
URLMasking::class,
URLRisk::class,
Guideline::class,
];
}
Expand Down
93 changes: 93 additions & 0 deletions src/Content/ContentSubmitParams/Policy/URLRisk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

declare(strict_types=1);

namespace ModerationAPI\Content\ContentSubmitParams\Policy;

use ModerationAPI\Core\Attributes\Optional;
use ModerationAPI\Core\Attributes\Required;
use ModerationAPI\Core\Concerns\SdkModel;
use ModerationAPI\Core\Contracts\BaseModel;

/**
* @phpstan-type URLRiskShape = array{
* id: 'url_risk', flag: bool, threshold?: float|null
* }
*/
final class URLRisk implements BaseModel
{
/** @use SdkModel<URLRiskShape> */
use SdkModel;

/** @var 'url_risk' $id */
#[Required]
public string $id = 'url_risk';

#[Required]
public bool $flag;

#[Optional]
public ?float $threshold;

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

/**
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*/
public static function with(bool $flag, ?float $threshold = null): self
{
$self = new self;

$self['flag'] = $flag;

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

return $self;
}

/**
* @param 'url_risk' $id
*/
public function withID(string $id): self
{
$self = clone $this;
$self['id'] = $id;

return $self;
}

public function withFlag(bool $flag): self
{
$self = clone $this;
$self['flag'] = $flag;

return $self;
}

public function withThreshold(float $threshold): self
{
$self = clone $this;
$self['threshold'] = $threshold;

return $self;
}
}
31 changes: 31 additions & 0 deletions src/Core/Conversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,37 @@ private static function tryConvert(Converter|ConverterSource|string $target, mix

return $value;

case 'DateTimeInterface':
case 'DateTimeImmutable':
if (is_string($value)) {
try {
++$state->maybe;

return new \DateTimeImmutable($value);
} catch (\Exception) {
--$state->maybe;
}
}

++$state->no;

return $value;

case 'DateTime':
if (is_string($value)) {
try {
++$state->maybe;

return new \DateTime($value);
} catch (\Exception) {
--$state->maybe;
}
}

++$state->no;

return $value;

default:
++$state->no;

Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace ModerationAPI;

// x-release-please-start-version
const VERSION = '0.9.0';
const VERSION = '0.10.0';
// x-release-please-end