Skip to content

Commit 151fded

Browse files
chrisdengsogithub-actions[bot]
authored andcommitted
feat: regenerate from the OpenAPI spec
1 parent 36ffaac commit 151fded

482 files changed

Lines changed: 5610 additions & 5827 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/release-notes/v1.0.0.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## moderation-api/sdk-php 1.0.0
2+
3+
The first stable version of the PHP SDK. Read the breaking changes before you upgrade.
4+
5+
```bash
6+
composer require moderation-api/sdk-php:^1.0
7+
```
8+
9+
### PHP-specific changes
10+
11+
- Requires PHP 8.2 or later (was 8.1).
12+
- The namespace is `ModerationApi` (was `ModerationAPI`). Create the client with `ModerationApi\ModerationApi::builder()->setSecurity($key)->build()`.
13+
- Requests are typed objects, for example `new Operations\SubmitContentRequest(content: new Operations\TextRequest(text: '...'))`, and responses carry the result in `->object`.
14+
- Verify webhooks with `ModerationApi\WebhookSignature::constructEvent($payload, $signature)`.
15+
### What's new
16+
17+
- **Covers the whole API**, including the management API (`projects`, `channels`), wordlists and the review queue.
18+
- **Automatic pagination.** List methods return an iterator that fetches the next page for you.
19+
- **Clear errors.** One error class per HTTP status (`BadRequestError`, `NotFoundError`, `RateLimitError`, ...). Every error has a specific `code` (for example `invalid_api_key`, `quota_exceeded` or `author_not_found`), a `request_id` and a `doc_url`. See [Errors](https://docs.moderationapi.com/api-reference/errors).
20+
- **Retries** with exponential backoff on `429` and `5xx`, and timeouts per client or per request.
21+
- **Webhook verification** that reads the secret from `MODAPI_WEBHOOK_SECRET`.
22+
23+
### Breaking changes
24+
25+
The SDK is now generated from our OpenAPI spec with a new generator. Most calls keep their names, but check these:
26+
27+
- **List responses** are `{ data, pagination }` instead of a plain array or a resource-specific shape, and list methods take `page` and `pageSize`.
28+
- **Errors** have a new body: `code` is the specific error code, not the HTTP category. The old `data` field is gone.
29+
- **Renamed:** `account.list` is now `account.retrieve`, and `actions.execute.execute` is now `actions.execute`.
30+
- **Removed:** `actions.execute.executeByID` (use `actions.execute` with `actionId` or `actionKey`), `auth.*`, and `content.stream` (see [Real-time voice](https://docs.moderationapi.com/content-moderation/real-time-voice)).
31+
- **Organization keys** work only with `projects` and `channels`; project keys work with everything else. Use one client per key. See the README.
32+
33+
The license is unchanged: Apache-2.0.

‎.github/workflows/publish-packagist.yml‎

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
11
# Maintained in moderation-api/sdk-generator (custom/php). Edits here are overwritten.
2-
# Packagist reads the version from the release tag.
2+
# Every push to main whose package version has no release tag yet publishes
3+
# that version and creates the GitHub release (notes: .github/release-notes/vX.Y.Z.md
4+
# if present, otherwise generated from the merged pull requests).
5+
# Packagist reads the version from the tag, so the release comes first.
36
name: Publish Packagist
47
on:
5-
release:
6-
types: [published]
8+
push:
9+
branches: [main]
710
workflow_dispatch:
811

12+
concurrency: release
13+
914
permissions:
10-
contents: read
15+
contents: write
1116

1217
jobs:
1318
publish:
1419
runs-on: ubuntu-latest
1520
steps:
21+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22+
- name: Read the version
23+
run: |
24+
echo "VERSION=$(sed -n 's/^ version: //p' .speakeasy/gen.yaml | head -n 1)" >> "$GITHUB_ENV"
25+
- name: Check for an unreleased version
26+
id: version
27+
run: |
28+
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
29+
if git ls-remote --exit-code --tags origin "refs/tags/v${VERSION}" >/dev/null; then
30+
echo "v${VERSION} is already released."
31+
echo "release=false" >> "$GITHUB_OUTPUT"
32+
else
33+
echo "release=true" >> "$GITHUB_OUTPUT"
34+
fi
35+
- name: Create the GitHub release
36+
if: steps.version.outputs.release == 'true'
37+
env:
38+
GH_TOKEN: ${{ github.token }}
39+
run: |
40+
notes=".github/release-notes/v${VERSION}.md"
41+
if [ -f "$notes" ]; then
42+
gh release create "v${VERSION}" --target "$GITHUB_SHA" --title "v${VERSION}" --notes-file "$notes"
43+
else
44+
gh release create "v${VERSION}" --target "$GITHUB_SHA" --title "v${VERSION}" --generate-notes
45+
fi
1646
- name: Tell Packagist to update
47+
if: steps.version.outputs.release == 'true'
1748
run: |-
1849
curl --fail-with-body -X POST -H 'Content-Type: application/json' "https://packagist.org/api/update-package?username=${PACKAGIST_USERNAME}&apiToken=${PACKAGIST_SAFE_KEY}" -d '{"repository":"https://github.com/moderation-api/sdk-php"}'
1950
env:

0 commit comments

Comments
 (0)