diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index e27be283..00000000 --- a/.editorconfig +++ /dev/null @@ -1,15 +0,0 @@ -# This file is for unifying the coding style for different editors and IDEs -# editorconfig.org - -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 4 - -[*.md] -trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 4c4dbe73..3e7d094a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,16 @@ -# Path-based git attributes -# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html +*.php diff=php -# Ignore all test and documentation with "export-ignore". -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis.yml export-ignore -/phpunit.xml.dist export-ignore -/scrutinizer.yml export-ignore -/tests export-ignore +/.github export-ignore +/bin export-ignore +/scripts export-ignore +/tests export-ignore + +/.gitattributes export-ignore +/.gitignore export-ignore +/.php-cs-fixer.dist.php export-ignore +/.phpactor.json export-ignore +/.release-please-manifest.json export-ignore +/.stats.yml export-ignore +/phpstan.dist.neon export-ignore +/phpunit.xml.dist export-ignore +/release-please-config.json export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..c2ebea8b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: CI +on: + push: + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' + +jobs: + lint: + timeout-minutes: 10 + name: lint + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-php' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up PHP + uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0 + with: + php-version: '8.3' + + - name: Run Bootstrap + run: ./scripts/bootstrap + + - name: Run lints + run: ./scripts/lint + test: + timeout-minutes: 10 + name: test + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-php' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up PHP + uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0 + with: + php-version: '8.3' + + - name: Run bootstrap + run: ./scripts/bootstrap + + - name: Run tests + run: ./scripts/test diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 8cba38a5..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: PHP Coverage CI - -on: [ push, pull_request ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest - - # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" - # Docs: https://getcomposer.org/doc/articles/scripts.md - - - name: Run test suite - run: ./vendor/bin/phpunit --coverage-clover coverage.xml - - - name: Upload to codecov - run: bash <(curl -s https://codecov.io/bash) diff --git a/.github/workflows/publish-packagist.yml b/.github/workflows/publish-packagist.yml new file mode 100644 index 00000000..e8509fa2 --- /dev/null +++ b/.github/workflows/publish-packagist.yml @@ -0,0 +1,21 @@ +name: Publish Packagist +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Publish to Packagist + run: |- + 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/imagekit-developer/imagekit-php"}' + env: + PACKAGIST_USERNAME: ${{ secrets.IMAGE_KIT_PACKAGIST_USERNAME || secrets.PACKAGIST_USERNAME }} + PACKAGIST_SAFE_KEY: ${{ secrets.IMAGE_KIT_PACKAGIST_SAFE_KEY || secrets.PACKAGIST_SAFE_KEY }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 00000000..1af22484 --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,22 @@ +name: Release Doctor +on: + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'imagekit-developer/imagekit-php' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + PACKAGIST_USERNAME: ${{ secrets.IMAGE_KIT_PACKAGIST_USERNAME || secrets.PACKAGIST_USERNAME }} + PACKAGIST_SAFE_KEY: ${{ secrets.IMAGE_KIT_PACKAGIST_SAFE_KEY || secrets.PACKAGIST_SAFE_KEY }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index eded823b..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: PHP Test CI - -on: [ push, pull_request ] - -jobs: - build: - runs-on: ${{ matrix.operating-system }} - strategy: - matrix: - operating-system: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ] - php-versions: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ] - phpunit-versions: [ 'latest' ] - steps: - - uses: actions/checkout@v1 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '${{ matrix.php-versions }}' - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest - - # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" - # Docs: https://getcomposer.org/doc/articles/scripts.md - - - name: Run test suite - run: ./vendor/bin/phpunit diff --git a/.github/workflows/wiki.yml b/.github/workflows/wiki.yml deleted file mode 100644 index 85568a30..00000000 --- a/.github/workflows/wiki.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Automatic update project documentation - -on: - push: - branches: - - master - tags: - - '*' - -jobs: - update_wiki: - runs-on: ubuntu-latest - steps: - - name: Checkouting project code... - uses: actions/checkout@v2 - - name: Updating wiki... - uses: impresscms-dev/phpdocs-wiki-update-action@v1.0.0 - with: - wiki_github_update_token: ${{ secrets.WIKI_GITHUB_UPDATE_TOKEN }} - wiki_github_update_user: ${{ secrets.WIKI_GITHUB_UPDATE_USER }} - engine: clean/phpdoc-md - class_root_namespace: ImageKit - include: | - ImageKit\** diff --git a/.gitignore b/.gitignore index 5f842560..71d6d159 100644 --- a/.gitignore +++ b/.gitignore @@ -1,42 +1,13 @@ -# IntelliJ - PhpStorm and PyCharm -.idea -*.iml -*.ipr -*.iws - -# Netbeans -nbproject -.nbproject -.nbproject/* -nbproject/* -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -nbactions.xml -nb-configuration.xml - -# Mac OSX -.DS_Store -# Thumbnails -._* -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - -# SublimeText project files -/*.sublime-project -*.sublime-workspace - -build -docs -vendor -composer.phar +docs/ +.idea/ +.php-cs-fixer.cache +.php-cs-fixer.php +.phpunit.cache phpunit.xml -.vscode -.phpunit* -sample/vendor -sample/composer.lock +playground/ +*.swo +*.swp +vendor/ -*.phar +# do not edit! excludes generated files used internally +.artifacts/ diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000..d46a37f9 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,19 @@ +setParallelConfig(ParallelConfigFactory::detect()) + ->setFinder(Finder::create()->in([__DIR__.'/src', __DIR__.'/tests'])) + ->setRules([ + '@PhpCsFixer' => true, + 'phpdoc_align' => false, + 'new_with_parentheses' => ['named_class' => false], + 'ordered_types' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], + 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], + ]) +; diff --git a/.phpactor.json b/.phpactor.json new file mode 100644 index 00000000..97fdd060 --- /dev/null +++ b/.phpactor.json @@ -0,0 +1,6 @@ +{ + "indexer.exclude_patterns": ["vendor"], + "language_server_completion.trim_leading_dollar": true, + "language_server_php_cs_fixer.enabled": false, + "language_server_phpstan.enabled": true +} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..3d2ac0bd --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 00000000..c1c7ec9d --- /dev/null +++ b/.stats.yml @@ -0,0 +1,4 @@ +configured_endpoints: 47 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-5280e65473c0c42b7f41216fd22aeb469acb5f54b6ee1a3181f3ec9b7a19dc17.yml +openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d +config_hash: 7960882e624d385c4d9aecca2132adad diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..72c9c81d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,179 @@ +# Changelog + +## 0.1.0 (2026-05-23) + +Full Changelog: [v0.0.1...v0.1.0](https://github.com/imagekit-developer/imagekit-php/compare/v0.0.1...v0.1.0) + +### ⚠ BREAKING CHANGES + +* remove unused webhook params +* replace special flag type `omittable` with just `null` +* use aliases for phpstan types +* improve identifier renaming for names that clash with builtins +* use camel casing for all class properties +* **client:** redesign methods +* remove confusing `toArray()` alias to `__serialize()` in favour of `toProperties()` +* expose services and service contracts + +### Features + +* add `BaseResponse` class for accessing raw responses ([f7102f9](https://github.com/imagekit-developer/imagekit-php/commit/f7102f9b0eb254f51e210ee9a5106cdbff98b3a6)) +* add idempotency header support ([aabdd47](https://github.com/imagekit-developer/imagekit-php/commit/aabdd475e597cf8a33699651aeaa7fc6d8681b52)) +* add setters to constant parameters ([2a1cdf8](https://github.com/imagekit-developer/imagekit-php/commit/2a1cdf802ce25941729d92632ac88ec11d708fda)) +* allow both model class instances and arrays in setters ([eee2c6e](https://github.com/imagekit-developer/imagekit-php/commit/eee2c6ec19c56a1635840341ee047f6e3b790142)) +* **api:** add BaseWebhookEvent ([84f5b7c](https://github.com/imagekit-developer/imagekit-php/commit/84f5b7c65eb1b7b23fdda823aca71c51b73023e3)) +* **api:** add customMetadata property to folder schema ([2b8763e](https://github.com/imagekit-developer/imagekit-php/commit/2b8763e03a721ac880ff51dc41a0b5a075916bf2)) +* **api:** add GetImageAttributesOptions and ResponsiveImageAttributes schemas; update resource references in main.yaml; remove dummy endpoint ([f2b5264](https://github.com/imagekit-developer/imagekit-php/commit/f2b52643c14ced1fe4264ddc4517c3394b0cc507)) +* **api:** add no-enlarge crop modes and colorize transformation ([ffebb94](https://github.com/imagekit-developer/imagekit-php/commit/ffebb946ee7e6ceca5824d9fb0ded368ba439431)) +* **api:** add path policy related non-breaking changes ([b961183](https://github.com/imagekit-developer/imagekit-php/commit/b961183d52e6374915bb9d1d403c89f561ed53a2)) +* **api:** Add saved extensions API and enhance transformation options ([2299402](https://github.com/imagekit-developer/imagekit-php/commit/229940265d3a5e7ba42bf3fd5ecaec92d67c1e6d)) +* **api:** add selectedFieldsSchema in upload and list API response ([24b3de1](https://github.com/imagekit-developer/imagekit-php/commit/24b3de13174ce310577db618727add52833b00ef)) +* **api:** add webhook verification ([f229b60](https://github.com/imagekit-developer/imagekit-php/commit/f229b603c92e55e54ebf745b07bc97a86ec04358)) +* **api:** dam related webhook events ([a9623d9](https://github.com/imagekit-developer/imagekit-php/commit/a9623d953b519a3b526dc98993a8e762459a0eae)) +* **api:** dpr type update ([ee5e13b](https://github.com/imagekit-developer/imagekit-php/commit/ee5e13b4b0776354070b0fb51a6acd56743bb680)) +* **api:** extract UpdateFileDetailsRequest to model ([8628e12](https://github.com/imagekit-developer/imagekit-php/commit/8628e12e2bdb99f3755bb1ea960547876fcccf00)) +* **api:** fix spec indentation ([c98a0fb](https://github.com/imagekit-developer/imagekit-php/commit/c98a0fbfa6db3824d263d51e1b50446fb6344877)) +* **api:** fix upload API request params ([d79cd68](https://github.com/imagekit-developer/imagekit-php/commit/d79cd6841ecb59fd1360663036af57b27c00f8fa)) +* **api:** indentation fix ([8190166](https://github.com/imagekit-developer/imagekit-php/commit/8190166ab4aeef88bc35fec0140ea7bbedbc3d77)) +* **api:** Introduce lxc, lyc, lap parameters in overlays. ([0f57760](https://github.com/imagekit-developer/imagekit-php/commit/0f5776049a1c25d6d957d1f93d919db41ea3de33)) +* **api:** manual updates ([9c45ffa](https://github.com/imagekit-developer/imagekit-php/commit/9c45ffaa1995b69c467d307238b2882944b3c7ad)) +* **api:** manual updates ([333c06b](https://github.com/imagekit-developer/imagekit-php/commit/333c06bedfbe8d5a91d1549ad5d67f05e794d159)) +* **api:** manual updates ([2d65a57](https://github.com/imagekit-developer/imagekit-php/commit/2d65a573684fed507cfb7397f73ef22b9d9e8f94)) +* **api:** manual updates ([bfc46ad](https://github.com/imagekit-developer/imagekit-php/commit/bfc46add70562512b60928554638368443b6e38c)) +* **api:** manual updates ([46dbc22](https://github.com/imagekit-developer/imagekit-php/commit/46dbc22461339a6be4f275f57b4f74a6fc2e4625)) +* **api:** manual updates ([e5c1428](https://github.com/imagekit-developer/imagekit-php/commit/e5c142868fae36f9f88f4142b98b47a1abbbaa1c)) +* **api:** manual updates ([2361086](https://github.com/imagekit-developer/imagekit-php/commit/2361086b4a3578fc04ac20da138d1ebcf3f92852)) +* **api:** manual updates ([de13f68](https://github.com/imagekit-developer/imagekit-php/commit/de13f687044f442b41ec1de7a72c2fd3ad27f1e1)) +* **api:** manual updates ([79f9906](https://github.com/imagekit-developer/imagekit-php/commit/79f9906770fee9602f9b1ed6397b5b00f015bcd2)) +* **api:** manual updates ([0daa175](https://github.com/imagekit-developer/imagekit-php/commit/0daa17580a73ebd447e344f01fa36f1fb593dd4d)) +* **api:** manual updates ([6ec4a94](https://github.com/imagekit-developer/imagekit-php/commit/6ec4a94508922f91f34d9b58226e047de6c40399)) +* **api:** manual updates ([2ebe4bf](https://github.com/imagekit-developer/imagekit-php/commit/2ebe4bffb958f8cd8c923b285bdb79b4d93ea755)) +* **api:** manual updates ([8aecc6e](https://github.com/imagekit-developer/imagekit-php/commit/8aecc6ee1d42589a554687c3a8138ff764ba223f)) +* **api:** manual updates ([3ac5bb6](https://github.com/imagekit-developer/imagekit-php/commit/3ac5bb60ab1b828c27a17e8d499309c1ac077dd9)) +* **api:** manual updates ([864a1aa](https://github.com/imagekit-developer/imagekit-php/commit/864a1aa121d394cbc89a9b305d03177777fe173e)) +* **api:** merge with main to bring back missing parameters ([313dcf4](https://github.com/imagekit-developer/imagekit-php/commit/313dcf40608dae77f12045de3e77878b33edd638)) +* **api:** remove Stainless attribution from readme ([a6f01f0](https://github.com/imagekit-developer/imagekit-php/commit/a6f01f0756a28bb4deafc5f65480aad544c12947)) +* **api:** revert dpr breaking change ([b97b7d6](https://github.com/imagekit-developer/imagekit-php/commit/b97b7d6717de6ffcd76dff3d159081f7bfd31360)) +* **api:** update api docs link ([aff2c75](https://github.com/imagekit-developer/imagekit-php/commit/aff2c753975007fed90c0400fef40c50a42d5587)) +* **api:** Update env var name ([a3edfdd](https://github.com/imagekit-developer/imagekit-php/commit/a3edfdd78c4a8aa37d18c74d0adade953a63d834)) +* **api:** update package names for Python and PHP targets in configuration ([264d6cf](https://github.com/imagekit-developer/imagekit-php/commit/264d6cf84f2853f08a2457d22b9aade5e7c6d375)) +* **api:** update webhook event names and remove DAM prefix ([e53bd51](https://github.com/imagekit-developer/imagekit-php/commit/e53bd5165e47bbe6d15413fa34120947afa3b28c)) +* **api:** updated docs ([8970696](https://github.com/imagekit-developer/imagekit-php/commit/8970696de6da93147e3e9cacc7e80a59dadaa5f3)) +* **client:** add raw methods ([049e837](https://github.com/imagekit-developer/imagekit-php/commit/049e837e2827e68c6cada81e7e35e3ddef23beb9)) +* **client:** redesign methods ([bf6c4d6](https://github.com/imagekit-developer/imagekit-php/commit/bf6c4d658f92eb53b032dafe0c3569cb4e8a0c2a)) +* **client:** support raw responses ([cc5397d](https://github.com/imagekit-developer/imagekit-php/commit/cc5397ddbb7a5a58b22f25037a76cc502a972692)) +* **client:** use real enums ([0b65863](https://github.com/imagekit-developer/imagekit-php/commit/0b65863c45d58bf52bca76cfa8f7560e381d7dc9)) +* expose services and service contracts ([1329184](https://github.com/imagekit-developer/imagekit-php/commit/13291847d68a49a7468bf64dac797124ad8b2178)) +* improve identifier renaming for names that clash with builtins ([629e73b](https://github.com/imagekit-developer/imagekit-php/commit/629e73bd717a76d55f745a1b25dcec1e38d692d6)) +* improved phpstan type annotations ([29c5644](https://github.com/imagekit-developer/imagekit-php/commit/29c564459ff158230f1efcfd80115ff911022c86)) +* remove confusing `toArray()` alias to `__serialize()` in favour of `toProperties()` ([6b0dfb3](https://github.com/imagekit-developer/imagekit-php/commit/6b0dfb31fc142c9c34f061ba48f469973ade55a3)) +* replace special flag type `omittable` with just `null` ([37f7fda](https://github.com/imagekit-developer/imagekit-php/commit/37f7fdabd844ff3bef85aae719b02ded1da5aadf)) +* simplify and make the phpstan types more consistent ([a48eabf](https://github.com/imagekit-developer/imagekit-php/commit/a48eabf27bc0717621987efcace7886a9611e10b)) +* split out services into normal & raw types ([72581b3](https://github.com/imagekit-developer/imagekit-php/commit/72581b38ac28d0bc43aa76e0df66a66a53c744e5)) +* support setting headers via env ([ca265ee](https://github.com/imagekit-developer/imagekit-php/commit/ca265eedd4fdf0c13f8dc90525ff1c28845fcc5e)) +* support unwrapping envelopes ([387f46c](https://github.com/imagekit-developer/imagekit-php/commit/387f46c0d4956e0df99308f0c407c17bc23970ae)) +* use `$_ENV` aware getenv helper ([ad42299](https://github.com/imagekit-developer/imagekit-php/commit/ad42299eeecb6784d17adf834fa522d03a62d801)) +* use aliases for phpstan types ([b7e0d88](https://github.com/imagekit-developer/imagekit-php/commit/b7e0d887e721da064ebce2d8f4319af258170d5e)) +* use camel casing for all class properties ([64f685c](https://github.com/imagekit-developer/imagekit-php/commit/64f685c64536578e988e610150d2b85a7d28529d)) + + +### Bug Fixes + +* a number of serialization errors ([328063f](https://github.com/imagekit-developer/imagekit-php/commit/328063f0ab0c9604527c9adb1dc5015778e52de1)) +* add ai-tasks property to response schemas with enum values ([4694d71](https://github.com/imagekit-developer/imagekit-php/commit/4694d7135602bdbac9d7ad210f4bba10fa5a3693)) +* **api:** add missing embeddedMetadata and video properties to FileDetails ([d42768b](https://github.com/imagekit-developer/imagekit-php/commit/d42768bef461fd55c7e45213518caadadbc77c4c)) +* **api:** extract shared schemas to prevent Go webhook union breaking changes ([68c5081](https://github.com/imagekit-developer/imagekit-php/commit/68c5081d55cfcfe59a960e12e8c2c5fec62d3183)) +* **api:** rename DamFile events to File for consistency ([3841282](https://github.com/imagekit-developer/imagekit-php/commit/3841282a5cfb0001a4674247a54cfd6fea359f9b)) +* **ci:** release doctor workflow ([5a4ecfc](https://github.com/imagekit-developer/imagekit-php/commit/5a4ecfc9579954ed381c99fe5cba7d1cca3e8520)) +* **client:** elide client methods in docs ([d3e94af](https://github.com/imagekit-developer/imagekit-php/commit/d3e94af126fa9bf00a0a704aa9fbc8e37125447a)) +* **client:** handle C-style escaped characters ([497b114](https://github.com/imagekit-developer/imagekit-php/commit/497b114e1861becb85e3e6682ae6421a1a607857)) +* **client:** properly generate file params ([60d37dc](https://github.com/imagekit-developer/imagekit-php/commit/60d37dc437cbdf8cead0be7cc62072975400605b)) +* **client:** properly import fully qualified names ([2da9342](https://github.com/imagekit-developer/imagekit-php/commit/2da9342a698593e82e15db1b8966b888684a862e)) +* **client:** resolve serialization issue with unions and enums ([ab78911](https://github.com/imagekit-developer/imagekit-php/commit/ab78911fb20ccaedcf28d7facf05a93d8633d624)) +* correctly serialize dates ([cfc1686](https://github.com/imagekit-developer/imagekit-php/commit/cfc16863ed169c087bd75f0b9a66715aab8aa80f)) +* decorate with enum label for all enum classes ([c3ea060](https://github.com/imagekit-developer/imagekit-php/commit/c3ea060ee47054167b8db064d3b423065fb106c1)) +* guzzle requires special handling to enable streaming ([b0f95d6](https://github.com/imagekit-developer/imagekit-php/commit/b0f95d62d3af6efd2f78e2a63f52a2f4df65c36b)) +* inverted retry condition ([493710d](https://github.com/imagekit-developer/imagekit-php/commit/493710dc24182fc6c2162a9554e45402ab43a2f7)) +* **php:** fix typo in options parsing ([2809bb4](https://github.com/imagekit-developer/imagekit-php/commit/2809bb451cd619af703ec50d29eba0b1a19371cf)) +* phpStan linter errors ([4cb4ba0](https://github.com/imagekit-developer/imagekit-php/commit/4cb4ba01a9054a10d74cad43d64228f685bfde2e)) +* populate enum-typed properties with enum instances ([9c715d0](https://github.com/imagekit-developer/imagekit-php/commit/9c715d0280fbb44b77db3fc1338ab13959c57378)) +* remove unused webhook params ([0aea279](https://github.com/imagekit-developer/imagekit-php/commit/0aea279726fe6954cfdfc84c121e45ce9342f7b4)) +* rename invalid types ([59bcbf0](https://github.com/imagekit-developer/imagekit-php/commit/59bcbf0d82436725efb8f63c405a088ab92b10c2)) +* revert accidental code deletion ([7649278](https://github.com/imagekit-developer/imagekit-php/commit/7649278a7a6c5e74a7f58e1743c1843f3f1f1f47)) +* revert enum parsing change that lead to unconditional failure ([cc2e7bd](https://github.com/imagekit-developer/imagekit-php/commit/cc2e7bd5a1919234353281c80c75e4049ab4b894)) +* support arrays in query param construction ([6f1f9dd](https://github.com/imagekit-developer/imagekit-php/commit/6f1f9dd3d46c7122dd103a6d721e51c20066a142)) +* typos in README.md ([d731ff1](https://github.com/imagekit-developer/imagekit-php/commit/d731ff1d6f21a3ac47c758e87e8219664962f1fb)) +* used redirect count instead of retry count in base client ([c8864b8](https://github.com/imagekit-developer/imagekit-php/commit/c8864b87a493e4d51647f4efc6ae5320102d955d)) +* vocab field is required ([a1f0a2c](https://github.com/imagekit-developer/imagekit-php/commit/a1f0a2c5c1867b9b6101d39eea7e8b70d32e34b9)) + + +### Chores + +* add git attributes and composer lock file ([40f7b97](https://github.com/imagekit-developer/imagekit-php/commit/40f7b97fa95c8c82feb267e006872c5107a0a26c)) +* add license ([c0f6216](https://github.com/imagekit-developer/imagekit-php/commit/c0f621686ed7fc92fd4618393bbdc4ad7bea8a91)) +* be more targeted in suppressing superfluous linter warnings ([577f528](https://github.com/imagekit-developer/imagekit-php/commit/577f5285b139a39f605dc3e38773eb0ecf5bbef5)) +* better support for phpstan ([574a0bb](https://github.com/imagekit-developer/imagekit-php/commit/574a0bbda02bdae57ec2a5655aee2f1264d8a1c3)) +* client instantiation refactor ([8341019](https://github.com/imagekit-developer/imagekit-php/commit/834101926d2a3ad566a8c3880e1a5a0dffde9f63)) +* **client:** refactor error type constructors ([cecffe1](https://github.com/imagekit-developer/imagekit-php/commit/cecffe1980bb81dedee05968b8046c95c4db02d1)) +* **client:** send metadata headers ([130ede9](https://github.com/imagekit-developer/imagekit-php/commit/130ede91a7873981a7696eb90b70c1e1780c8215)) +* **docs:** update readme formatting ([2831746](https://github.com/imagekit-developer/imagekit-php/commit/283174604767a8fe614ca521462f691572a695a4)) +* document parameter object usage ([c959bcf](https://github.com/imagekit-developer/imagekit-php/commit/c959bcf6d18e0f078fbed9d50c05d6feb1d81a42)) +* ensure constant values are marked as optional in array types ([59bab21](https://github.com/imagekit-developer/imagekit-php/commit/59bab215c6165b2290ca08bb3aee44d16721a308)) +* fix lints in UnionOf ([a57c7cc](https://github.com/imagekit-developer/imagekit-php/commit/a57c7cc9f5131daea2a45d261b414a3deed3adba)) +* formatting ([a11b751](https://github.com/imagekit-developer/imagekit-php/commit/a11b7519be814fe8955f2a3d564b342572883cf2)) +* **internal:** add a basic client test ([2994f2d](https://github.com/imagekit-developer/imagekit-php/commit/2994f2d6f65889a67ceccfb274944b517f86793f)) +* **internal:** codegen related update ([32cccc6](https://github.com/imagekit-developer/imagekit-php/commit/32cccc6bf639fb685938afb689b46f5b65106c12)) +* **internal:** codegen related update ([65b995a](https://github.com/imagekit-developer/imagekit-php/commit/65b995aa83c6cf09fa55f784cf06fd3c8f95c0ff)) +* **internal:** codegen related update ([cc9408e](https://github.com/imagekit-developer/imagekit-php/commit/cc9408e49527807fd3a91d07c226d380b52247de)) +* **internal:** codegen related update ([87b1637](https://github.com/imagekit-developer/imagekit-php/commit/87b1637ba7e0943ebd19f65cbadd9857cc6deb80)) +* **internal:** codegen related update ([0215531](https://github.com/imagekit-developer/imagekit-php/commit/0215531088e798a7ffbb41fc92afdba93e615305)) +* **internal:** codegen related update ([c91e314](https://github.com/imagekit-developer/imagekit-php/commit/c91e31405811b0ec13c47d6640c80e4ac988bca4)) +* **internal:** codegen related update ([ce694ee](https://github.com/imagekit-developer/imagekit-php/commit/ce694eea2c03e9b50fb0055980a7789fd2fdaf63)) +* **internal:** codegen related update ([10d85fa](https://github.com/imagekit-developer/imagekit-php/commit/10d85fa72d5cf2e3025f7fafd495f651372ccaa0)) +* **internal:** codegen related update ([e896f2b](https://github.com/imagekit-developer/imagekit-php/commit/e896f2bf3e12423cec0f242ab9c19eb268fd3b87)) +* **internal:** codegen related update ([7d97124](https://github.com/imagekit-developer/imagekit-php/commit/7d97124eff55d2d54e6b1877174bc2eb7206665c)) +* **internal:** codegen related update ([65e8d5f](https://github.com/imagekit-developer/imagekit-php/commit/65e8d5ff7c465323eb396caaab93870c09f94e84)) +* **internal:** codegen related update ([8cce69f](https://github.com/imagekit-developer/imagekit-php/commit/8cce69f9353760cd01788b3ae56718dbdbddc540)) +* **internal:** codegen related update ([cd71972](https://github.com/imagekit-developer/imagekit-php/commit/cd71972213770889ed4417a69849a9c4504b5d00)) +* **internal:** codegen related update ([cf2eb10](https://github.com/imagekit-developer/imagekit-php/commit/cf2eb10b550e628dcd50528ea1ba6d18aba812f3)) +* **internal:** codegen related update ([bde112f](https://github.com/imagekit-developer/imagekit-php/commit/bde112f4d3a020051e13c581c3ff7bc89f7b27a9)) +* **internal:** codegen related update ([76b7d1a](https://github.com/imagekit-developer/imagekit-php/commit/76b7d1a3bec0ff36b996eceb7af07a54f4a8439a)) +* **internal:** ignore stainless-internal artifacts ([8e06db7](https://github.com/imagekit-developer/imagekit-php/commit/8e06db7959b044ab844db8eb2ca530740f01b084)) +* **internal:** minor test script reformatting ([4572ac9](https://github.com/imagekit-developer/imagekit-php/commit/4572ac94b4784db86b2fe41e4458e73d1c6e98e8)) +* **internal:** php cs fixer should not be memory limited ([ffce92f](https://github.com/imagekit-developer/imagekit-php/commit/ffce92feb7a761600be48db66c357ac4be6a27b4)) +* **internal:** refactor auth by moving concern from base client into client ([a29d53f](https://github.com/imagekit-developer/imagekit-php/commit/a29d53f233f62dfccfa69e7487fdf8bc79f19d57)) +* **internal:** refactor base client internals ([aba7242](https://github.com/imagekit-developer/imagekit-php/commit/aba7242684bdef5c8926ef4f1e7b0909650cbf17)) +* **internal:** remove mock server code ([bc5a3ed](https://github.com/imagekit-developer/imagekit-php/commit/bc5a3ed131b03c042fa8020f0b85d8d0ab70546a)) +* **internal:** restructure some imports ([9a9fe93](https://github.com/imagekit-developer/imagekit-php/commit/9a9fe9357a5a0a614bd2f546a4606698cb289a8f)) +* **internal:** tweak CI branches ([df01794](https://github.com/imagekit-developer/imagekit-php/commit/df01794af8a40d7154495cdc1c33cb51c3875cf2)) +* **internal:** update `actions/checkout` version ([a086098](https://github.com/imagekit-developer/imagekit-php/commit/a08609804375fcbb528ca08b82cf935d7f6dddf5)) +* **internal:** update phpstan comments ([5b9a607](https://github.com/imagekit-developer/imagekit-php/commit/5b9a60764c121078ddebc742a9f1787b8d5dac1a)) +* **internal:** upgrade phpunit ([ac20448](https://github.com/imagekit-developer/imagekit-php/commit/ac20448a0f856ea1afa12b120dd59d3d33384cfc)) +* none ([a29b310](https://github.com/imagekit-developer/imagekit-php/commit/a29b310c8c6d916ecb9098e81ab4c1f29034e506)) +* **readme:** remove beta warning now that we're in ga ([1c52ed5](https://github.com/imagekit-developer/imagekit-php/commit/1c52ed5f2b1cadca880e71230a475077e9fc749a)) +* refactor methods ([759837c](https://github.com/imagekit-developer/imagekit-php/commit/759837c405f3861d56b463b84e2344cf0a3a82f7)) +* switch from `#[Api(optional: true|false)]` to `#[Required]|#[Optional]` for annotations ([229f706](https://github.com/imagekit-developer/imagekit-php/commit/229f706c0368dbbd51cf56a683eba73c301c1b89)) +* sync repo ([bb14ef3](https://github.com/imagekit-developer/imagekit-php/commit/bb14ef396deb2b1bccc1e8d80da4bd47e3a04427)) +* typing updates ([4208922](https://github.com/imagekit-developer/imagekit-php/commit/420892242261f1a4e5099a1dbfe7bd2705ce88c5)) +* update mock server docs ([d02f1aa](https://github.com/imagekit-developer/imagekit-php/commit/d02f1aa5f9b7dbe551ae0822943ea38c0622a825)) +* update SDK settings ([6913a6d](https://github.com/imagekit-developer/imagekit-php/commit/6913a6de33f625b50dc0aa5881e1208e136c8b2a)) +* use `$self = clone $this;` instead of `$obj = clone $this;` ([1baa8c0](https://github.com/imagekit-developer/imagekit-php/commit/1baa8c086edb663887b7a8ffe7975e5c1e96b203)) +* use non-trivial test assertions ([bcbfa80](https://github.com/imagekit-developer/imagekit-php/commit/bcbfa809e6b7e3f995cd8cddf8b55da68a89bedf)) +* use pascal case for phpstan typedefs ([8d8f4fc](https://github.com/imagekit-developer/imagekit-php/commit/8d8f4fcc8d20dd6ccdb4825f438e14ec71bb4600)) +* use single quote strings ([2a67006](https://github.com/imagekit-developer/imagekit-php/commit/2a67006f8a94fec12ca7d862cd6340d6a1b39f4e)) + + +### Documentation + +* correct typo in default value description for custom metadata field ([d0d0590](https://github.com/imagekit-developer/imagekit-php/commit/d0d0590988600c967eb2d54f0bf3c06868dc6942)) +* improve examples ([333a5f5](https://github.com/imagekit-developer/imagekit-php/commit/333a5f51772b14a4e82ee4504f32f21fec6c4863)) + + +### Refactors + +* AITags to singular AITag schema with array items pattern ([15d5ae5](https://github.com/imagekit-developer/imagekit-php/commit/15d5ae51731a0f47527aeb3643b2cf75cc69151c)) + + +### Build System + +* **php:** set production target ([04e6535](https://github.com/imagekit-developer/imagekit-php/commit/04e65354ac22903e38ca02a0e4d95207bdaf9ce0)) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md deleted file mode 100644 index 2f857ed7..00000000 --- a/DEVELOPMENT.md +++ /dev/null @@ -1,25 +0,0 @@ -## Installing dependencies - -Install the project dependencies by running the following command in terminal - -``` -composer install -``` - -## Running the tests - -``` -vendor/bin/phpunit -``` - -## Sample Code Instruction - -To run sample code go to the sample directory and run - -``` -php sample.php -``` - -## Support - -For any feedback or to report any issues or general implementation support, please reach out to [support@imagekit.io](mailto:support@imagekit.io) \ No newline at end of file diff --git a/LICENSE b/LICENSE index 8b976bea..20278610 100644 --- a/LICENSE +++ b/LICENSE @@ -1,20 +1,201 @@ -MIT License - -Copyright (c) 2020 Imagekit - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2026 Image Kit + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 69c9d458..38e5e4aa 100644 --- a/README.md +++ b/README.md @@ -1,1238 +1,207 @@ -# PHP SDK for ImageKit +# Image Kit PHP API library -[![Packagist](https://img.shields.io/packagist/v/imagekit/imagekit.svg)](https://packagist.org/packages/imagekit/imagekit) [![Packagist](https://img.shields.io/packagist/dt/imagekit/imagekit.svg)](https://packagist.org/packages/imagekit/imagekit) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![codecov](https://codecov.io/gh/imagekit-developer/imagekit-php/branch/master/graph/badge.svg)](https://codecov.io/gh/imagekit-developer/imagekit-php) [![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow&style=social)](https://twitter.com/ImagekitIo) -[![PHP Test CI](https://github.com/imagekit-developer/imagekit-php/actions/workflows/test.yml/badge.svg)](https://github.com/imagekit-developer/imagekit-php/actions/workflows/test.yml) [![PHP Coverage CI](https://github.com/imagekit-developer/imagekit-php/actions/workflows/coverage.yml/badge.svg)](https://github.com/imagekit-developer/imagekit-php/actions/workflows/coverage.yml) [![Wiki Documentation](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/imagekit-developer/imagekit-php/wiki) +The Image Kit PHP library provides convenient access to the Image Kit REST API from any PHP 8.1.0+ application. -PHP SDK for [ImageKit](https://imagekit.io/) implements the new APIs and interface for different file operations. +## Documentation -ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes. - -- [Key Features](#key-features) -- [Requirements](#requirements) -- [Version Support](#version-support) -- [Breaking changes](#breaking-changes) -- [Installation](#installation) -- [Usage](#usage) -- [Getting Started](#getting-started) -- [Quick Examples](#quick-examples) - * [Create an ImageKit Instance](#create-an-imagekit-instance) - * [URL Generation](#url-generation) - * [File Upload](#file-upload) -- [Demo Application](#demo-application) -- [URL Generation](#url-generation-1) -- [Signed URL & Image Transformations](#applying-chained-transformations-common-image-manipulations--signed-url) -- [Server-side File Upload](#server-side-file-upload) -- [File Management](#file-management) -- [Custom Metadata Fields API](#custom-metadata-fields-api) -- [Utility Function](#utility-functions) -- [Opening Issues](#opening-issues) -- [Support](#support) -- [Resources](#resources) -- [License](#license) - -## Key Features -- [URL Generation](#url-generation) -- [Transformations](#1-chained-transformations-as-a-query-parameter) -- [Secure URLS](#6-signed-url) -- [File Upload](#server-side-file-upload) -- [File Management](#file-management) - -## Requirements -* PHP 5.6+ -* [JSON PHP Extension](https://www.php.net/manual/en/book.json.php) -* [cURL PHP Extension](https://www.php.net/manual/en/book.curl.php) - -## Version Support -| SDK Version | PHP 5.4 | PHP 5.5 | PHP 5.6 | PHP 7.x | PHP 8.x | -|-------------|---------|---------|---------|---------|---------| -| 4.x | ❌ | ❌ | ✔️ | ✔️ |✔️ | -| 3.x | ❌ | ❌ | ✔️ | ✔️ |✔️ | -| 2.x | ❌ | ❌ | ✔️ | ✔️ |✔️ | -| 1.x | ❌ | ✔️ | ✔️ | ✔️ |✔️ | - -## Breaking changes - -### Upgrading from 3.x to 4.x version - -1. Overlay syntax update - -* In version 4.0.0, we've removed the old overlay syntax parameters for transformations, such as `oi`, `ot`, `obg`, and [more](https://docs.imagekit.io/features/image-transformations/overlay). These parameters are deprecated and will start returning errors when used in URLs. Please migrate to the new layers syntax that supports overlay nesting, provides better positional control, and allows more transformations at the layer level. You can start with [examples](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#examples) to learn quickly. -* You can migrate to the new layers syntax using the `raw` transformation parameter. +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). ## Installation -You can install the bindings via [Composer](http://getcomposer.org/). Run the following command: + -```bash -composer require imagekit/imagekit ``` -To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading): -```php -require_once('vendor/autoload.php'); +composer require "imagekit/imagekit 0.1.0" ``` -## Usage - -You can use this PHP SDK for three different methods - URL generation, file upload, and file management. The usage of the SDK has been explained below. - -* `URL Generation` -* `File Upload` -* `File Management` - -## Getting Started -1. **Sign up for ImageKit** – Before you begin, you need to sign up for an [ImageKit account](https://imagekit.io/registration/) -2. Get your [API Keys](https://docs.imagekit.io/api-reference/api-introduction/api-keys) from [developer options](https://imagekit.io/dashboard/developer) inside the dashboard. -3. **Minimum requirements** – To use PHP SDK, your system must meet the minimum requirements, including having **PHP >= 5.6**. We highly recommend having it compiled with the cURL extension and cURL 7.16.2+ compiled with a TLS backend (e.g., NSS or OpenSSL). -4. **Install the SDK** – Using Composer is the recommended way to install the ImageKit SDK for PHP. The SDK is available via [Packagist](http://packagist.org/) under the [`imagekit/imagekit`](https://packagist.org/packages/imagekit/imagekit) package. If Composer is installed globally on your system, you can run the following in the base directory of your project to add the SDK as a dependency: - ``` - composer require imagekit/imagekit - ``` - Please see the [Installation](#installation) section for more detailed information about installing. -5. **Using the SDK** – The best way to become familiar with how to use the SDK is to follow the examples provided in the [quick start guide](https://docs.imagekit.io/getting-started/quickstart-guides/php). - -## Quick Examples + -#### Create an ImageKit Instance -```php -// Require the Composer autoloader. -require 'vendor/autoload.php'; -use ImageKit\ImageKit; - -$imageKit = new ImageKit( - "your_public_key", - "your_private_key", - "your_url_endpoint" -); -``` +## Usage -#### URL Generation -```php -// For URL Generation, works for both images and videos -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - ] -); -echo $imageURL; -``` +This library uses named parameters to specify optional arguments. +Parameters with a default value must be set by name. -#### File Upload ```php -// For File Upload -$uploadFile = $imageKit->uploadFile([ - 'file' => 'file-url', # required, "binary","base64" or "file url" - 'fileName' => 'new-file' # required - 'checks' => '"file.size" < "1mb"' // optional `checks` parameters can be used to run server-side checks before files are uploaded to the Media Library. -]); -``` - -#### Response Structure -Following is the response for [server-side file upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload#response-code-and-structure-json) - -```json -{ - "error": null, - "result": { - "fileId": "6286329dfef1b033aee60211", - "name": "your_file_name_S-PgGysnR.jpg", - "size": 94466, - "versionInfo": { - "id": "6286329dfef1b033aee60211", - "name": "Version 1" - }, - "filePath": "/your_file_name_S-PgGysnR.jpg", - "url": "https://ik.imagekit.io/demo/your_file_name_S-PgGysnR.jpg", - "fileType": "image", - "height": 640, - "width": 960, - "thumbnailUrl": "https://ik.imagekit.io/demo/tr:n-ik_ml_thumbnail/your_file_name_S-PgGysnR.jpg", - "tags": [], - "AITags": null, - "customMetadata": { }, - "extensionStatus": {} - }, - "responseMetadata":{ - "headers":{ - "access-control-allow-origin": "*", - "x-ik-requestid": "e98f2464-2a86-4934-a5ab-9a226df012c9", - "content-type": "application/json; charset=utf-8", - "content-length": "434", - "etag": 'W/"1b2-reNzjRCFNt45rEyD7yFY/dk+Ghg"', - "date": "Thu, 16 Jun 2022 14:22:01 GMT", - "x-request-id": "e98f2464-2a86-4934-a5ab-9a226df012c9" - }, - "raw":{ - "fileId": "6286329dfef1b033aee60211", - "name": "your_file_name_S-PgGysnR.jpg", - "size": 94466, - "versionInfo": { - "id": "6286329dfef1b033aee60211", - "name": "Version 1" - }, - "filePath": "/your_file_name_S-PgGysnR.jpg", - "url": "https://ik.imagekit.io/demo/your_file_name_S-PgGysnR.jpg", - "fileType": "image", - "height": 640, - "width": 960, - "thumbnailUrl": "https://ik.imagekit.io/demo/tr:n-ik_ml_thumbnail/your_file_name_S-PgGysnR.jpg", - "tags": [], - "AITags": null, - "customMetadata": { }, - "extensionStatus": {} - }, - "statusCode":200 - } -} -``` - -## Demo application - -* Step-by-step PHP quick start guide - https://docs.imagekit.io/getting-started/quickstart-guides/php -* You can also run the demo application in this repository's [sample](/sample) folder. - ```sh - cd sample - php sample.php - ``` - -## URL generation +url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400' - ] - ] - ] +$client = new Client( + privateKey: getenv('IMAGEKIT_PRIVATE_KEY') ?: 'My Private Key', + password: getenv('OPTIONAL_IMAGEKIT_IGNORES_THIS') ?: 'do_not_set', ); -``` - -#### Response - -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg -``` - -### Using full image URL -This method allows you to add transformation parameters to an absolute URL. For example, if you have configured a custom CNAME and have absolute asset URLs in your database or CMS, you will often need this. - -#### Example -```php -$imageURL = $imageKit->url([ - 'src' => 'https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400' - ] - ] -]); -``` - -#### Response -``` -https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/default-image.jpg -``` - -The `$imageKit->url()` method accepts the following parameters. - -| Option | Description | -| :-------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| urlEndpoint | Optional. The base URL to be appended before the path of the image. If not specified, the URL Endpoint specified at the time of SDK initialization is used. For example, https://ik.imagekit.io/your_imagekit_id/endpoint/ | -| path | Conditional. This is the path at which the image exists. For example, `/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. | -| src | Conditional. This is the complete URL of an image already mapped to ImageKit. For example, `https://ik.imagekit.io/your_imagekit_id/endpoint/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. | -| transformation | Optional. An array of objects specifying the transformation to be applied in the URL. The transformation name and the value should be specified as a key-value pair in the object. Different steps of a [chained transformation](https://docs.imagekit.io/features/image-transformations/chained-transformations) can be specified as different objects of the array. The complete [List of supported transformations](#list-of-supported-transformations) in the SDK and some examples of using them are given later. If you use a transformation name that is not specified in the SDK, it gets applied as it is in the URL. | -| transformationPosition | Optional. The default value is `path` which places the transformation string as a path parameter in the URL. It can also be specified as `query`, which adds the transformation string as the query parameter `tr` in the URL. The transformation string is always added as a query parameter if you use the `src` parameter to create the URL. | -| queryParameters | Optional. These are the other query parameters that you want to add to the final URL. These can be any query parameters and are not necessarily related to ImageKit. Especially useful if you want to add some versioning parameters to your URLs. | -| signed | Optional. Boolean. The default value is `false`. If set to `true`, the SDK generates a signed image URL adding the image signature to the image URL. | -| expireSeconds | Optional. Integer. It is used along with the `signed` parameter. It specifies the time in seconds from now when the signed URL will expire. If specified, the URL contains the expiry timestamp in the URL, and the image signature is modified accordingly. - -### Applying chained transformations, common image manipulations & signed URL - -This section covers the basics: - -* [Chained Transformations as a query parameter](#1-chained-transformations-as-a-query-parameter) -* [Image enhancement & color manipulation](#2-image-enhancement-and-color-manipulation) -* [Resizing images and videos](#3-resizing-images-and-videos) -* [Quality manipulation](#4-quality-manipulation) -* [Adding overlays](#5-adding-overlays) -* [Signed URL](#6-signed-url) -The PHP SDK gives a name to each transformation parameter e.g. `height` for `h` and `width` for `w` parameter. It makes your code more readable. See the [Full list of supported transformations](#list-of-supported-transformations). - -👉 If the property does not match any of the available options, it is added as it is. For example: -```php -[ - 'effectGray' => 'e-grayscale' -] -// and -[ - 'e-grayscale' => '' -] -// works the same -``` -👉 Note that you can also use the `h` and `w` parameters instead of `height` and `width`. - -For more examples, check the [Demo Application](https://github.com/imagekit-developer/imagekit-php/tree/master/sample). - - -### 1. Chained transformations as a query parameter - -#### Example -```php -$imageURL = $imageKit->url([ - 'path' => '/default-image.jpg', - 'urlEndpoint' => 'https://ik.imagekit.io/your_imagekit_id/endpoint/', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400' - ], - [ - 'rotation' => 90 - ], - ], - 'transformationPosition' => 'query' -]); -``` -#### Response -``` -https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300,w-400:rt-90 -``` - -### 2. Image enhancement and color manipulation - -Some transformations like [contrast stretch](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#contrast-stretch-e-contrast) , [sharpen](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#sharpen-e-sharpen) and [unsharp mask](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#unsharp-mask-e-usm) can be added to the URL with or without any other value. To use such transforms without specifying a value, specify the value as "-" in the transformation object. Otherwise, specify the value that you want to be added to this transformation. - -#### Example -```php -$imageURL = $imageKit->url([ - 'src' => 'https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg', - 'transformation' => - [ - [ - 'format' => 'jpg', - 'progressive' => true, - 'effectSharpen' => '-', - 'effectContrast' => '1' - ] - ] -]); -``` -#### Response -``` -https://ik.imagekit.io/your_imagekit_id/endpoint/tr:f-jpg,pr-true,e-sharpen,e-contrast-1/default-image.jpg -``` - -### 3. Resizing images and videos -Let's resize the image to `width` 400 and `height` 300. -Check detailed instructions on [resize, crop, and other Common transformations](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations) - -#### Example -```php -$imageURL = $imageKit->url(array( - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - ] - ] -)); -``` -#### Response -``` -https://ik.imagekit.io/your_imagekit_id/tr:w-400,h-300/default-image.jpg -``` - -### 4. Quality manipulation -You can use the [quality parameter](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#quality-q) to change quality like this. - -#### Example -```php -$imageURL = $imageKit->url(array( - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'quality' => '40', - ] - ] -)); -``` +$response = $client->files->upload( + file: FileParam::fromString('https://www.example.com/public-url.jpg', filename: uniqid('file-upload-', true)), + fileName: 'file-name.jpg', +); -#### Response -``` -https://ik.imagekit.io/your_imagekit_id/tr:q-40/default-image.jpg +var_dump($response->videoCodec); ``` -### 5. Adding overlays - -ImageKit.io enables you to apply overlays to [images](https://docs.imagekit.io/features/image-transformations/overlay-using-layers) and [videos](https://docs.imagekit.io/features/video-transformation/overlay) using the raw parameter with the concept of [layers](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#layers). The raw parameter facilitates incorporating transformations directly in the URL. A layer is a distinct type of transformation that allows you to define an asset to serve as an overlay, along with its positioning and additional transformations. - -#### Text as overlays +### Value Objects -You can add any text string over a base video or image using a text layer (l-text). - -For example: - -```php -$imageURL = $imageKit->url(array( - 'path' => '/default-image.jpg', - 'urlEndpoint' => 'https://ik.imagekit.io/your_imagekit_id' - - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'raw': "l-text,i-Imagekit,fs-50,l-end" - ] - ] -)); -``` -#### Sample Result URL -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-text,i-Imagekit,fs-50,l-end/default-image.jpg -``` +It is recommended to use the static `with` constructor `Dog::with(name: "Joey")` +and named parameters to initialize value objects. -#### Image as overlays +However, builders are also provided `(new Dog)->withName("Joey")`. -You can add an image over a base video or image using an image layer (l-image). +### Handling errors -For example: +When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `ImageKit\Core\Exceptions\APIException` will be thrown: ```php -$imageURL = $imageKit->url(array( - 'path' => '/default-image.jpg', - 'urlEndpoint' => 'https://ik.imagekit.io/your_imagekit_id' - - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'raw': "l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end" - ] - ] -)); -``` -#### Sample Result URL -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end/default-image.jpg -``` +url(array( - 'path' => '/img/sample-video.mp4', - 'urlEndpoint' => 'https://ik.imagekit.io/your_imagekit_id' - - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'raw': "l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end" - ] - ] -)); -``` -#### Sample Result URL -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end/img/sample-video.mp4 -``` - -### 6. Arithmetic expressions in transformations - -ImageKit allows use of [arithmetic expressions](https://docs.imagekit.io/features/arithmetic-expressions-in-transformations) in certain dimension and position-related parameters, making media transformations more flexible and dynamic. - -For example: - -```php -$imageURL = $imageKit->url(array( - 'path' => '/default-image.jpg', - 'urlEndpoint' => 'https://ik.imagekit.io/your_imagekit_id' - 'transformation' => [ - [ - "height": "ih_div_2", - "width": "iw_div_4", - "border": "cw_mul_0.05_yellow" - ] - ] -)); -``` - -#### Sample Result URL -``` -https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-iw_div_4,h-ih_div_2,b-cw_mul_0.05_yellow -`` - -### 7. Signed URL - -For example, the signed URL expires in 300 seconds with the default URL endpoint and other query parameters. -For a detailed explanation of the signed URL, refer to this [documentation](https://docs.imagekit.io/features/security/signed-urls). - -#### Example -```php -$imageURL = $imageKit->url([ - "path" => "/default-image.jpg", - "queryParameters" => - [ - "v" => "123" - ], - "transformation" => [ - [ - "height" => "300", - "width" => "400" - ] - ], - "signed" => true, - "expireSeconds" => 300, -]); -``` -#### Response -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg?v=123&ik-t=1654183277&ik-s=f98618f264a9ccb3c017e7b7441e86d1bc9a7ebb -``` - -You can manage [security settings](https://docs.imagekit.io/features/security#restricting-unsigned-urls) from the dashboard to prevent unsigned URLs usage. In that case, if the URL doesn't have a signature `ik-s` parameter or the signature is invalid, ImageKit will return a forbidden error instead of an actual image. - -### List of supported transformations - -The complete list of transformations supported and their usage in ImageKit can be found in the docs for [images](https://docs.imagekit.io/features/image-transformations) and [videos](https://docs.imagekit.io/features/video-transformation). The SDK gives a name to each transformation parameter, making the code simpler, making the code simpler, and readable. - -If a transformation is supported in ImageKit, but a name for it cannot be found in the table below, then use the transformation code from ImageKit docs as the name when using the `url` function. - -If you want to generate transformations in your application and add them to the URL as it is, use the `raw` parameter. - -| Supported Transformation Name | Translates to parameter | -|-------------------------------|-------------------------| -| height | h | -| width | w | -| aspectRatio | ar | -| quality | q | -| crop | c | -| cropMode | cm | -| x | x | -| y | y | -| focus | fo | -| format | f | -| radius | r | -| background | bg | -| border | b | -| rotation | rt | -| blur | bl | -| named | n | -| progressive | pr | -| lossless | lo | -| trim | t | -| metadata | md | -| colorProfile | cp | -| defaultImage | di | -| dpr | dpr | -| effectSharpen | e-sharpen | -| effectUSM | e-usm | -| effectContrast | e-contrast | -| effectGray | e-grayscale | -| effectShadow | e-shadow | -| effectGradient | e-gradient | -| original | orig | -| raw | `replaced by the parameter value` | - - -## Server-side File Upload - -The SDK provides a simple interface using the `$imageKit->uploadFile()` method to upload files to the [ImageKit Media Library](https://imagekit.io/dashboard/media-library). - -- [Server-side file upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload). -- [Supported file types and extensions](https://docs.imagekit.io/api-reference/upload-file-api#allowed-file-types-for-uploading). - -#### Basic Usage -```php -$uploadFile = $imageKit->uploadFile([ - 'file' => 'your_file', // required, "binary","base64" or "file url" - 'fileName' => 'your_file_name.jpg', // required - 'checks' => '"file.size" < "1mb"', // optional `checks` parameters can be used to run server-side checks before files are uploaded to the Media Library. -]); -``` -#### Response -```json -{ - "error": null, - "result": { - "fileId": "6286329dfef1b033aee60211", - "name": "your_file_name_S-PgGysnR.jpg", - "size": 94466, - "versionInfo": { - "id": "6286329dfef1b033aee60211", - "name": "Version 1" - }, - "filePath": "/your_file_name_S-PgGysnR.jpg", - "url": "https://ik.imagekit.io/demo/your_file_name_S-PgGysnR.jpg", - "fileType": "image", - "height": 640, - "width": 960, - "thumbnailUrl": "https://ik.imagekit.io/demo/tr:n-ik_ml_thumbnail/your_file_name_S-PgGysnR.jpg", - "tags": [], - "AITags": null, - "customMetadata": { }, - "extensionStatus": {} - }, - "responseMetadata":{ - "headers":{ - "access-control-allow-origin": "*", - "x-ik-requestid": "e98f2464-2a86-4934-a5ab-9a226df012c9", - "content-type": "application/json; charset=utf-8", - "content-length": "434", - "etag": 'W/"1b2-reNzjRCFNt45rEyD7yFY/dk+Ghg"', - "date": "Thu, 16 Jun 2022 14:22:01 GMT", - "x-request-id": "e98f2464-2a86-4934-a5ab-9a226df012c9" - }, - "raw":{ - "fileId": "6286329dfef1b033aee60211", - "name": "your_file_name_S-PgGysnR.jpg", - "size": 94466, - "versionInfo": { - "id": "6286329dfef1b033aee60211", - "name": "Version 1" - }, - "filePath": "/your_file_name_S-PgGysnR.jpg", - "url": "https://ik.imagekit.io/demo/your_file_name_S-PgGysnR.jpg", - "fileType": "image", - "height": 640, - "width": 960, - "thumbnailUrl": "https://ik.imagekit.io/demo/tr:n-ik_ml_thumbnail/your_file_name_S-PgGysnR.jpg", - "tags": [], - "AITags": null, - "customMetadata": { }, - "extensionStatus": {} - }, - "statusCode":200 - } +try { + $response = $client->files->upload( + file: FileParam::fromString('https://www.example.com/public-url.jpg', filename: uniqid('file-upload-', true)), + fileName: 'file-name.jpg', + ); +} catch (APIConnectionException $e) { + echo "The server could not be reached", PHP_EOL; + var_dump($e->getPrevious()); +} catch (RateLimitException $e) { + echo "A 429 status code was received; we should back off a bit.", PHP_EOL; +} catch (APIStatusException $e) { + echo "Another non-200-range status code was received", PHP_EOL; + echo $e->getMessage(); } ``` -#### Optional Parameters -Please refer to [server-side file upload API request structure](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload#request-structure-multipart-form-data) for a detailed explanation of mandatory and optional parameters. - -```php -// Attempt File Uplaod -$uploadFile = $imageKit->uploadFile([ - 'file' => 'your_file', // required, "binary","base64" or "file url" - 'fileName' => 'your_file_name.jpg', // required - // Optional Parameters - "useUniqueFileName" => true, // true|false - "tags" => implode(",",["abd", "def"]), // max: 500 chars - "folder" => "/sample-folder", - "isPrivateFile" => false, // true|false - "customCoordinates" => implode(",", ["10", "10", "100", "100"]), // max: 500 chars - "responseFields" => implode(",", ["tags", "customMetadata"]), - "extensions" => [ - [ - "name" => "remove-bg", - "options" => [ // refer https://docs.imagekit.io/extensions/overview - "add_shadow" => true - ] - ] - ], - "webhookUrl" => "https://example.com/webhook", - "overwriteFile" => true, // in case of false useUniqueFileName should be true - "overwriteAITags" => true, // set to false in order to preserve overwriteAITags - "overwriteTags" => true, - "overwriteCustomMetadata" => true, - 'transformation' => [ - 'pre' => 'l-text,i-Imagekit,fs-50,l-end', - 'post' => [ - [ - 'type' => 'transformation', - 'value' => 'h-100' - ] - ] - ], - 'checks' => '"file.size" < "1mb"', // optional `checks` parameters can be used to run server-side checks before files are uploaded to the Media Library. - 'isPublished' => true, - // "customMetadata" => [ - // "SKU" => "VS882HJ2JD", - // "price" => 599.99, - // ] -]); -``` - -## File Management - -The SDK provides a simple interface for all the following [Media APIs](https://docs.imagekit.io/api-reference/media-api) to manage your files. - -### 1. List and Search Files - -This API can list all the uploaded files and folders in your [ImageKit.io](https://docs.imagekit.io/api-reference/media-api) media library. - -Refer to the [list and search file API](https://docs.imagekit.io/api-reference/media-api/list-and-search-files) for a better understanding of the **request & response structure**. - -#### Example -```php -$listFiles = $imageKit->listFiles(); -``` -#### Applying Filters -Filter out the files with an object specifying the parameters. - -```php -$listFiles = $imageKit->listFiles([ - "type" => "file", // file, file-version or folder - "sort" => "ASC_CREATED", - "path" => "/", // folder path - "fileType" => "all", // all, image, non-image - "limit" => 10, // min:1, max:1000 - "skip" => 0, // min:0 -]); -``` - -#### Advance Search -In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and providing this generated string as the value of the `searchQuery`. - -```php -$listFiles = $imageKit->listFiles([ - "searchQuery" => '(size < "1mb" AND width > 500) OR (tags IN ["summer-sale","banner"])', -]); -``` -Detailed documentation can be found here for [advance search queries](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#advanced-search-queries). -### 2. Get File Details +Error codes are as follows: -This API will get all the details and attributes of the current version of the asset. +| Cause | Error Type | +| ---------------- | ------------------------------ | +| HTTP 400 | `BadRequestException` | +| HTTP 401 | `AuthenticationException` | +| HTTP 403 | `PermissionDeniedException` | +| HTTP 404 | `NotFoundException` | +| HTTP 409 | `ConflictException` | +| HTTP 422 | `UnprocessableEntityException` | +| HTTP 429 | `RateLimitException` | +| HTTP >= 500 | `InternalServerException` | +| Other HTTP error | `APIStatusException` | +| Timeout | `APITimeoutException` | +| Network error | `APIConnectionException` | -Refer to the [get file details API](https://docs.imagekit.io/api-reference/media-api/get-file-details) for a better understanding of the **request & response structure**. +### Retries -#### Example -```php -$getFileDetails = $imageKit->getFileDetails('file_id'); -``` +Certain errors will be automatically retried 2 times by default, with a short exponential backoff. -### 3. Get File Version Details +Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default. -This API can get you all the details and attributes for the provided version of the file. +You can use the `maxRetries` option to configure or disable this: -Refer to the [get file version details API](https://docs.imagekit.io/api-reference/media-api/get-file-version-details) for a better understanding of the **request & response structure**. - -#### Example ```php -$getFileVersionDetails = $imageKit->getFileVersionDetails('file_id','version_id'); -``` +getFileVersions('file_id'); -``` - -### 5. Update File Details - -Update file details such as `tags`, `customCoordinates` attributes, remove existing `AITags`, and apply [extensions](https://docs.imagekit.io/extensions/overview) using update file details API. This operation can only be performed only on the current version of an asset. - -Refer to the [update file details API](https://docs.imagekit.io/api-reference/media-api/update-file-details) for better understanding about the **request & response structure**. - -#### Example -```php -// Update parameters -$updateData = [ - "removeAITags" => "all", // "all" or ["tag1","tag2"] - "webhookUrl" => "https://example.com/webhook", - "extensions" => [ - [ - "name" => "remove-bg", - "options" => [ // refer https://docs.imagekit.io/extensions/overview - "add_shadow" => true - ] - ], - [ - "name" => "google-auto-tagging", - ] - ], - "tags" => ["tag1", "tag2"], - "customCoordinates" => "10,10,100,100", - // "customMetadata" => [ - // "SKU" => "VS882HJ2JD", - // "price" => 599.99, - // ] -]; +// Configure the default for all requests: +$client = new Client(requestOptions: ['maxRetries' => 0]); -// Attempt Update -$updateFileDetails = $imageKit->updateFileDetails( - 'file_id', - $updateData +// Or, configure per-request: +$result = $client->files->upload( + file: FileParam::fromString('https://www.example.com/public-url.jpg', filename: uniqid('file-upload-', true)), + fileName: 'file-name.jpg', + requestOptions: ['maxRetries' => 5], ); ``` -**Update publish status** - -If `publish` is included in the update options, no other parameters are allowed. If any are present, an error will be returned: `Your request cannot contain any other parameters when publish is present`. - -#### Example -```php -// Update parameters -$updateData = [ - "publish" => [ - "isPublished" => true, - "includeFileVersions" => true - ] -]; - -// Attempt Update -$updateFileDetails = $imageKit->updateFileDetails( - 'file_id', - $updateData -); -``` - -### 6. Add Tags (Bulk) API - -Add tags to multiple files in a single request. The method accepts an array of `fileIds` of the files and an array of `tags` that have to be added to those files. - -Refer to the [add tags (Bulk) API](https://docs.imagekit.io/api-reference/media-api/add-tags-bulk) for a better understanding of the **request & response structure**. - -#### Example -```php -$fileIds = ['file_id1','file_id2']; -$tags = ['image_tag_1', 'image_tag_2']; - -$bulkAddTags = $imageKit->bulkAddTags($fileIds, $tags); -``` - -### 7. Remove Tags (Bulk) API - -Remove tags from multiple files in a single request. The method accepts an array of `fileIds` of the files and an array of `tags` that have to be removed from those files. - -Refer to the [remove tags (Bulk) API](https://docs.imagekit.io/api-reference/media-api/remove-tags-bulk) for a better understanding of the **request & response structure**. - -#### Example -```php -$fileIds = ['file_id1','file_id2']; -$tags = ['image_tag_1', 'image_tag_2']; - -$bulkRemoveTags = $imageKit->bulkRemoveTags($fileIds, $tags); -``` - -### 8. Remove AI Tags (Bulk) API - -Remove AI tags from multiple files in a single request. The method accepts an array of `fileIds` of the files and an array of `AITags` that have to be removed from those files. - -Refer to the [remove AI Tags (Bulk) API](https://docs.imagekit.io/api-reference/media-api/remove-aitags-bulk) for a better understanding of the **request & response structure**. - -#### Example -```php -$fileIds = ['file_id1','file_id2']; -$AITags = ['image_AITag_1', 'image_AITag_2']; - -$bulkRemoveTags = $imageKit->bulkRemoveTags($fileIds, $AITags); -``` - -### 9. Delete File API - -You can programmatically delete uploaded files in the media library using delete file API. - -> If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. However, you can purge the cache using [Purge Cache API](#21-purge-cache-api). - -Refer to the [delete file API](https://docs.imagekit.io/api-reference/media-api/delete-file) for better understanding about the **request & response structure**. - -#### Basic Usage -```php -$fileId = 'file_id'; -$deleteFile = $imageKit->deleteFile($fileId); -``` - -### 10. Delete File Version API - -Using the delete file version API, you can programmatically delete the uploaded file version in the media library. - -> You can delete only the non-current version of a file. - -Refer to the [delete file version API](https://docs.imagekit.io/api-reference/media-api/delete-file-version) for a better understanding of the **request & response structure**. - -#### Example -```php -$fileId = 'file_id'; -$versionId = 'version_id'; -$deleteFileVersion = $imageKit->deleteFileVersion($fileId, $versionId); -``` - -### 11. Delete Files (Bulk) API +### File uploads -Deletes multiple files and their versions from the media library. +Request parameters that correspond to file uploads can be passed as a resource returned by `fopen()`, a string of file contents, or a `FileParam` instance. -Refer to the [delete files (Bulk) API](https://docs.imagekit.io/api-reference/media-api/delete-files-bulk) for a better understanding of the **request & response structure**. - -#### Example ```php -$fileIds = ["5e1c13d0c55ec3437c451406", ...]; -$deleteFiles = $imageKit->bulkDeleteFiles($fileIds); -``` - - -### 12. Copy File API - -This will copy a file from one folder to another. - -> If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history. - -Refer to the [copy file API](https://docs.imagekit.io/api-reference/media-api/copy-file) for a better understanding of the **request & response structure**. - -#### Basic Usage -```php -$sourceFilePath = '/sample-folder1/sample-file.jpg'; -$destinationPath = '/sample-folder2/'; -$includeFileVersions = false; - -$copyFile = $imageKit->copy([ - 'sourceFilePath' => $sourceFilePath, - 'destinationPath' => $destinationPath, - 'includeFileVersions' => $includeFileVersions -]); -``` - -### 13. Move File API - -This will move a file and all its versions from one folder to another. - -> If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file. +move([ - 'sourceFilePath' => $sourceFilePath, - 'destinationPath' => $destinationPath -]); -``` - -### 14. Rename File API - -Using Rename File API, you can programmatically rename an already existing file in the media library. This operation would rename all versions of the file. - -> The old URLs will stop working. However, the file/file version URLs cached on CDN will continue to work unless a purge is requested. - -Refer to the [rename file API](https://docs.imagekit.io/api-reference/media-api/rename-file) for a better understanding of the **request & response structure**. - -#### Example -```php -// Purge Cache would default to false - -$filePath = '/sample-folder/sample-file.jpg'; -$newFileName = 'sample-file2.jpg'; -$renameFile = $imageKit->rename([ - 'filePath' => $filePath, - 'newFileName' => $newFileName, -]); -``` -When `purgeCache` is set to `true`, response will return `purgeRequestId`. This `purgeRequestId` can be used to get the purge request status. -```php -$filePath = '/sample-folder/sample-file.jpg'; -$newFileName = 'sample-file2.jpg'; -$renameFile = $imageKit->rename([ - 'filePath' => $filePath, - 'newFileName' => $newFileName, -],true); -``` - -### 15. Restore File Version API - -This will restore the provided file version to a different version of the file. The newly restored version of the file will be returned in the response. - -Refer to the [restore file version API](https://docs.imagekit.io/api-reference/media-api/restore-file-version) for a better understanding of the **request & response structure**. - -#### Example -```php -$fileId = 'fileId'; -$versionId = 'versionId'; -$restoreFileVersion = $imageKit->restoreFileVersion([ - 'fileId' => $fileId, - 'versionId' => $versionId, -]); -``` - -### 16. Create Folder API - -This will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created. - -Refer to the [create folder API](https://docs.imagekit.io/api-reference/media-api/create-folder) for a better understanding of the **request & response structure**. - -#### Example -```php -$folderName = 'new-folder'; -$parentFolderPath = '/'; -$createFolder = $imageKit->createFolder([ - 'folderName' => $folderName, - 'parentFolderPath' => $parentFolderPath, -]); -``` - -### 17. Delete Folder API - -This will delete the specified folder and all nested files, their versions & folders. This action cannot be undone. - -Refer to the [delete folder API](https://docs.imagekit.io/api-reference/media-api/delete-folder) for a better understanding of the **request & response structure**. - -#### Example -```php -$folderPath = '/new-folder'; -$deleteFolder = $imageKit->deleteFolder($folderPath); -``` - -### 18. Copy Folder API - -This will copy one folder into another. - -Refer to the [copy folder API](https://docs.imagekit.io/api-reference/media-api/copy-folder) for a better understanding of the **request & response structure**. - -#### Example -```php -$sourceFolderPath = '/source-folder/'; -$destinationPath = '/destination-folder/'; -$includeFileVersions = false; -$copyFolder = $imageKit->copyFolder([ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - 'includeFileVersions' => $includeFileVersions -]); -``` - -### 19. Move Folder API - -This will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. - -> If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history. - -Refer to the [move folder API](https://docs.imagekit.io/api-reference/media-api/move-folder) for a better understanding of the **request & response structure**. - -#### Example -```php -$sourceFolderPath = '/sample-folder/'; -$destinationPath = '/destination-folder/'; -$moveFolder = $imageKit->moveFolder([ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath -]); -``` - -### 20. Bulk Job Status API - -This endpoint allows you to get the status of a bulk operation e.g. [Copy Folder API](#18-copy-folder-api) or [Move Folder API](#19-move-folder-api). - -Refer to the [bulk job status API](https://docs.imagekit.io/api-reference/media-api/copy-move-folder-status) for a better understanding of the **request & response structure**. - -#### Example -```php -$jobId = 'jobId'; -$bulkJobStatus = $imageKit->getBulkJobStatus($jobId); -``` - -### 21. Purge Cache API - -This will purge CDN and ImageKit.io's internal cache. In response, `requestId` is returned, which can be used to fetch the status of the submitted purge request with [Purge Cache Status API](#22-purge-cache-status-api). - -Refer to the [Purge Cache API](https://docs.imagekit.io/api-reference/media-api/purge-cache) for a better understanding of the **request & response structure**. - -#### Example -```php -$image_url = 'https://ik.imagekit.io/demo/sample-folder/sample-file.jpg'; -$purgeCache = $imageKit->purgeCache($image_url); -``` - -You can purge the cache for multiple files. Check [purge cache multiple files](https://docs.imagekit.io/api-reference/media-api/purge-cache#purge-cache-for-multiple-files). - -### 22. Purge Cache Status API - -Get the purge cache request status using the `requestId` returned when a purge cache request gets submitted with [Purge Cache API](#21-purge-cache-api) - -Refer to the [Purge Cache Status API](https://docs.imagekit.io/api-reference/media-api/purge-cache-status) for a better understanding of the **request & response structure**. - -#### Example -```php -$cacheRequestId = '598821f949c0a938d57563bd'; -$purgeCacheStatus = $imageKit->purgeCacheStatus($cacheRequestId); -``` - -### 23. Get File Metadata API (From File ID) - -Get the image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API. - -Refer to the [get image metadata for uploaded media files API](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files) for a better understanding of the **request & response structure**. - -#### Example -```php -$fileId = '598821f949c0a938d57563bd'; -$getFileMetadata = $imageKit->getFileMetaData($fileId); -``` - -### 24. Get File Metadata API (From Remote URL) - -Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. - -Refer to the [get image metadata from remote URL API](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-from-remote-url) for a better understanding of the **request & response structure**. +// Pass a string with filename and content type: +$contents = file_get_contents('/path/to/file'); +// Pass a string with filename and content type: +$response = $client->files->upload( + file: FileParam::fromString($contents, filename: '/path/to/file', contentType: '…'), +); -#### Example -```php -$image_url = 'https://ik.imagekit.io/demo/sample-folder/sample-file.jpg'; -$getFileMetadataFromRemoteURL = $imageKit->getFileMetadataFromRemoteURL($image_url); +// Pass in only a string (where applicable) +$response = $client->files->upload(file: '…'); + +// Pass an open resource: +$fd = fopen('/path/to/file', 'r'); +try { + $response = $client->files->upload( + file: FileParam::fromResource($fd, filename: '/path/to/file', contentType: '…'), + ); +} finally { + fclose($fd); +} ``` -## Custom Metadata Fields API - -Imagekit.io allows you to define a `schema` for your metadata keys, and the value filled against that key will have to adhere to those rules. You can [create](#1-create-fields), [read](#2-get-fields) and [update](#3-update-fields) custom metadata rules and update your file with custom metadata value in [file update API](#5-update-file-details) or [file upload API](#server-side-file-upload). -For a detailed explanation, refer to the [custom metadata fields documentation](https://docs.imagekit.io/api-reference/custom-metadata-fields-api). +## Advanced concepts +### Making custom or undocumented requests -### 1. Create Fields +#### Undocumented properties -Create a custom metadata field with this API. +You can send undocumented parameters to any endpoint, and read undocumented response properties, like so: -Refer to the [create custom metadata fields API](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field) for a better understanding of the **request & response structure**. +Note: the `extra*` parameters of the same name overrides the documented parameters. -#### Example ```php -$body = [ - "name" => "price", // required - "label" => "Unit Price", // required - "schema" => [ // required - "type" => 'Number', // required - "minValue" => 1000, - "maxValue" => 5000, - ], -]; - -$createCustomMetadataField = $imageKit->createCustomMetadataField($body); -``` - -Check for the [allowed values in the schema](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field#allowed-values-in-the-schema-object). +getCustomMetadataField($includeDeleted); -``` +use ImageKit\Core\FileParam; -### 3. Update Fields - -Update an existing custom metadata field's `label` or `schema`. - -Refer to the [update custom metadata fields API](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field) for a better understanding of the **request & response structure**. - -#### Example -```php -$customMetadataFieldId = '598821f949c0a938d57563dd'; -$body = [ - "label" => "Net Price", - "schema" => [ - "type"=>'Number' - ], -]; - -$updateCustomMetadataField = $imageKit->updateCustomMetadataField($customMetadataFieldId, $body); +$response = $client->files->upload( + file: FileParam::fromString('https://www.example.com/public-url.jpg', filename: uniqid('file-upload-', true)), + fileName: 'file-name.jpg', + requestOptions: [ + 'extraQueryParams' => ['my_query_parameter' => 'value'], + 'extraBodyParams' => ['my_body_parameter' => 'value'], + 'extraHeaders' => ['my-header' => 'value'], + ], +); ``` -Check for the [allowed values in the schema](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field#allowed-values-in-the-schema-object). - +#### Undocumented request params -### 4. Delete Fields +If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above. -Delete a custom metadata field. +#### Undocumented endpoints -Refer to the [delete custom metadata fields API](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/delete-custom-metadata-field) for a better understanding of the **request & response structure**. +To make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so: -#### Example ```php -$customMetadataFieldId = '598821f949c0a938d57563dd'; +deleteCustomMetadataField($customMetadataFieldId); +$response = $client->request( + method: "post", + path: '/undocumented/endpoint', + query: ['dog' => 'woof'], + headers: ['useful-header' => 'interesting-value'], + body: ['hello' => 'world'] +); ``` +## Versioning -## Utility functions - -We have included the following commonly used utility functions in this SDK. +This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time. -### Authentication parameter generation +This package considers improvements to the (non-runtime) PHPDoc type definitions to be non-breaking changes. -If you want to implement client-side file upload, you will need a `token`, `expiry` timestamp, and a valid `signature` for that upload. The SDK provides a simple method you can use in your code to generate these authentication parameters. - -_Note: The Private API Key should never be exposed in any client-side code. You must always generate these authentication parameters on the server-side_ - -```php -$imageKit->getAuthenticationParameters($token = "", $expire = 0); -``` - -Returns - -```json -{ - "token": "5d1c4a22-54f2-40bb-9e8c-99daaeeb7307", - "expire": 1654207193, - "signature": "a03a88b814570a3d92919c16a1b8bd4491f053c3" -} -``` - -Both the `token` and `expire` parameters are optional. If not specified, the SDK internally generates a random token and a valid expiry timestamp. The value of the `token` and `expire` used to create the signature is always returned in the response, whether they are provided in input or not. - -### Distance calculation between two pHash values - -Perceptual hashing allows you to construct a hash value that uniquely identifies an input image based on the contents of an image. [ImageKit.io metadata API](https://docs.imagekit.io/api-reference/metadata-api) returns the pHash value of an image in the response. You can use this value to find a duplicate (or similar) image by calculating the distance between the pHash value of the two images. - -This SDK exposes `pHashDistance` function to calculate the distance between two pHash values. It accepts two pHash hexadecimal strings and returns a numeric value indicative of the level of difference between the two images. - -```php - $imageKit->pHashDistance($firstHash ,$secondHash); -``` - -#### Distance calculation examples - -```php -$imageKit->pHashDistance('f06830ca9f1e3e90', 'f06830ca9f1e3e90'); -// output: 0 (same image) - -$imageKit->pHashDistance('2d5ad3936d2e015b', '2d6ed293db36a4fb'); -// output: 17 (similar images) - -$imageKit->pHashDistance('a4a65595ac94518b', '7838873e791f8400'); -// output: 37 (dissimilar images) -``` - -## Opening Issues -If you encounter a bug with `imagekit-php` we would like to hear about it. Search the existing issues and try to make sure your problem doesn't already exist before opening a new issue. It's helpful if you include the version of `imagekit-php`, PHP version, and OS you're using. Please include a stack trace and a simple workflow to reproduce the case when appropriate, too. - - -## Support - -For any feedback or to report any issues or general implementation support, please reach out to [support@imagekit.io](mailto:support@imagekit.io) - -## Resources +## Requirements -- [Main website](https://imagekit.io) - Main Website. -- [Documentation](https://docs.imagekit.io) - For both getting started and in-depth SDK usage information. -- [PHP quick start guide](https://docs.imagekit.io/getting-started/quickstart-guides/php) +PHP 8.1.0 or higher. -## License +## Contributing -Released under the MIT license. \ No newline at end of file +See [the contributing documentation](https://github.com/imagekit-developer/imagekit-php/tree/master/CONTRIBUTING.md). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..8e64327a --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +# Security Policy + +## Reporting Security Issues + +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. + +To report a security issue, please contact the Stainless team at security@stainless.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Image Kit, please follow the respective company's security reporting guidelines. + +### Image Kit Terms and Policies + +Please contact developer@imagekit.io for any questions or concerns regarding the security of our services. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 00000000..cf571b62 --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${PACKAGIST_USERNAME}" ]; then + errors+=("The PACKAGIST_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${PACKAGIST_SAFE_KEY}" ]; then + errors+=("The PACKAGIST_SAFE_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/composer.json b/composer.json index 32efa114..28e6cfee 100644 --- a/composer.json +++ b/composer.json @@ -1,46 +1,57 @@ { - "authors": [ - { - "name": "Imagekit", - "homepage": "https://github.com/imagekit-developer/imagekit-php/graphs/contributors" - } + "$schema": "https://getcomposer.org/schema.json", + "license": "Apache-2.0", + "autoload": { + "files": [ + "src/Version.php" ], - "autoload": { - "psr-4": { - "ImageKit\\": "src/ImageKit/" - } + "psr-4": { + "ImageKit\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true, + "php-http/discovery": false, + "phpstan/extension-installer": true }, - "autoload-dev": { - "psr-4": { - "ImageKit\\Tests\\": "tests/" - } + "platform": { + "php": "8.3" }, - "description": "PHP library for Imagekit", - "homepage": "https://github.com/imagekit-developer/imagekit-php", - "keywords": [ - "library", - "imagekit", - "image management" - ], - "license": "MIT", - "name": "imagekit/imagekit", - "require": { - "php": ">=5.6.0", - "ext-curl": "*", - "guzzlehttp/guzzle": "~6.0 || ~7.0", - "ext-json": "*", - "beberlei/assert": "^2.9.9" - }, - "config": { - "platform": { - "php": "5.6" - } - }, - "require-dev": { - "phpunit/phpunit": "^5.7.27" - }, - "support": { - "email": "support@imagekit.io" - }, - "type": "library" + "preferred-install": "dist", + "sort-packages": true + }, + "description": "Image Kit PHP SDK", + "name": "imagekit/imagekit", + "require": { + "php": "^8.1", + "php-http/discovery": "^1", + "psr/http-client": "^1", + "psr/http-client-implementation": "^1", + "psr/http-factory-implementation": "^1", + "psr/http-message": "^1|^2", + "standard-webhooks/standard-webhooks": "^1" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3", + "guzzlehttp/guzzle": "^7", + "nyholm/psr7": "^1", + "pestphp/pest": "^3", + "php-http/mock-client": "^1", + "phpstan/extension-installer": "^1", + "phpstan/phpstan": "^2", + "phpstan/phpstan-phpunit": "^2", + "phpunit/phpunit": "^11", + "symfony/http-client": "^7" + }, + "scripts": { + "build:docs": "curl --etag-save ./vendor/ag.etags --etag-compare ./vendor/ag.etags --create-dirs --remote-name --output-dir ./vendor/bin --no-progress-meter -- https://github.com/ApiGen/ApiGen/releases/latest/download/apigen.phar && php ./vendor/bin/apigen.phar --output docs -- src", + "lint": "./scripts/lint", + "test": "./scripts/test" + } } diff --git a/composer.lock b/composer.lock index 7594938f..d86fa57a 100644 --- a/composer.lock +++ b/composer.lock @@ -1,2395 +1,7099 @@ { - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "39a1be44588c84272c5860de8d14993c", - "packages": [ - { - "name": "beberlei/assert", - "version": "v2.9.9", - "source": { - "type": "git", - "url": "https://github.com/beberlei/assert.git", - "reference": "124317de301b7c91d5fce34c98bba2c6925bec95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/124317de301b7c91d5fce34c98bba2c6925bec95", - "reference": "124317de301b7c91d5fce34c98bba2c6925bec95", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": ">=5.3" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.1.1", - "phpunit/phpunit": "^4.8.35|^5.7" - }, - "type": "library", - "autoload": { - "files": [ - "lib/Assert/functions.php" - ], - "psr-4": { - "Assert\\": "lib/Assert" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de", - "role": "Lead Developer" - }, - { - "name": "Richard Quadling", - "email": "rquadling@gmail.com", - "role": "Collaborator" - } - ], - "description": "Thin assertion library for input validation in business models.", - "keywords": [ - "assert", - "assertion", - "validation" - ], - "support": { - "issues": "https://github.com/beberlei/assert/issues", - "source": "https://github.com/beberlei/assert/tree/v2.9.9" - }, - "time": "2019-05-28T15:27:37+00:00" - }, - { - "name": "guzzlehttp/guzzle", - "version": "6.5.8", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "a52f0440530b54fa079ce76e8c5d196a42cad981" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/a52f0440530b54fa079ce76e8c5d196a42cad981", - "reference": "a52f0440530b54fa079ce76e8c5d196a42cad981", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.9", - "php": ">=5.5", - "symfony/polyfill-intl-idn": "^1.17" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.1" - }, - "suggest": { - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.5-dev" - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Jeremy Lindblom", - "email": "jeremeamia@gmail.com", - "homepage": "https://github.com/jeremeamia" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "support": { - "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/6.5.8" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", - "type": "tidelift" - } - ], - "time": "2022-06-20T22:16:07+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "1.5.3", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/67ab6e18aaa14d753cc148911d273f6e6cb6721e", - "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "support": { - "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.3" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", - "type": "tidelift" - } - ], - "time": "2023-05-21T12:31:43+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "1.9.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/e4490cabc77465aaee90b20cfc9a770f8c04be6b", - "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10" - }, - "suggest": { - "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "support": { - "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/1.9.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", - "type": "tidelift" - } - ], - "time": "2023-04-17T16:00:37+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v2.0.21", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "96c132c7f2f7bc3230723b66e89f8f150b29d5ae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/96c132c7f2f7bc3230723b66e89f8f150b29d5ae", - "reference": "96c132c7f2f7bc3230723b66e89f8f150b29d5ae", - "shasum": "" - }, - "require": { - "php": ">=5.2.0" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "autoload": { - "files": [ - "lib/random.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/random_compat/issues", - "source": "https://github.com/paragonie/random_compat" - }, - "time": "2022-02-16T17:07:03+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-message/tree/master" - }, - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" - }, - "time": "2019-03-08T08:55:37+00:00" - }, - { - "name": "symfony/polyfill-intl-idn", - "version": "v1.19.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "4ad5115c0f5d5172a9fe8147675ec6de266d8826" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/4ad5115c0f5d5172a9fe8147675ec6de266d8826", - "reference": "4ad5115c0f5d5172a9fe8147675ec6de266d8826", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/polyfill-intl-normalizer": "^1.10", - "symfony/polyfill-php70": "^1.10", - "symfony/polyfill-php72": "^1.10" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Idn\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Laurent Bassin", - "email": "laurent@bassin.info" - }, - { - "name": "Trevor Rowbotham", - "email": "trevor.rowbotham@pm.me" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "idn", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.19.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-21T09:57:48+00:00" - }, - { - "name": "symfony/polyfill-intl-normalizer", - "version": "v1.19.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8db0ae7936b42feb370840cf24de1a144fb0ef27" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8db0ae7936b42feb370840cf24de1a144fb0ef27", - "reference": "8db0ae7936b42feb370840cf24de1a144fb0ef27", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's Normalizer class and related functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "intl", - "normalizer", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.19.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-23T09:01:57+00:00" - }, - { - "name": "symfony/polyfill-php70", - "version": "v1.19.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "3fe414077251a81a1b15b1c709faf5c2fbae3d4e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/3fe414077251a81a1b15b1c709faf5c2fbae3d4e", - "reference": "3fe414077251a81a1b15b1c709faf5c2fbae3d4e", - "shasum": "" - }, - "require": { - "paragonie/random_compat": "~1.0|~2.0|~9.99", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php70/tree/v1.19.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-23T09:01:57+00:00" - }, - { - "name": "symfony/polyfill-php72", - "version": "v1.19.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "beecef6b463b06954638f02378f52496cb84bacc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/beecef6b463b06954638f02378f52496cb84bacc", - "reference": "beecef6b463b06954638f02378f52496cb84bacc", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.19.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-23T09:01:57+00:00" - } - ], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.0.5" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2015-06-14T21:17:01+00:00" - }, - { - "name": "myclabs/deep-copy", - "version": "1.7.0", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^4.1" - }, - "type": "library", - "autoload": { - "files": [ - "src/DeepCopy/deep_copy.php" - ], - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "support": { - "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.x" - }, - "time": "2017-10-19T19:58:43+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/master" - }, - "time": "2017-09-11T18:02:19+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "3.3.2", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bf329f6c1aadea3299f08ee804682b7c45b326a2", - "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", - "webmozart/assert": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/release/3.x" - }, - "time": "2017-11-10T14:09:06+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "0.4.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", - "shasum": "" - }, - "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/master" - }, - "time": "2017-07-14T14:27:02+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.10.3", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.10.3" - }, - "time": "2020-03-05T15:02:03+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "4.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^5.6 || ^7.0", - "phpunit/php-file-iterator": "^1.3", - "phpunit/php-text-template": "^1.2", - "phpunit/php-token-stream": "^1.4.2 || ^2.0", - "sebastian/code-unit-reverse-lookup": "^1.0", - "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "^1.0 || ^2.0" - }, - "require-dev": { - "ext-xdebug": "^2.1.4", - "phpunit/phpunit": "^5.7" - }, - "suggest": { - "ext-xdebug": "^2.5.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/4.0" - }, - "time": "2017-04-02T07:44:40+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/1.4.5" - }, - "time": "2017-11-27T13:52:08+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" - }, - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.9", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/master" - }, - "time": "2017-02-26T11:10:40+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.12", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", - "source": "https://github.com/sebastianbergmann/php-token-stream/tree/1.4" - }, - "abandoned": true, - "time": "2017-12-04T08:55:13+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "5.7.27", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.0", - "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^4.0.4", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "^1.2.4", - "sebastian/diff": "^1.4.3", - "sebastian/environment": "^1.3.4 || ^2.0", - "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.1", - "sebastian/object-enumerator": "~2.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "^1.0.6|^2.0.1", - "symfony/yaml": "~2.1|~3.0|~4.0" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2" - }, - "require-dev": { - "ext-pdo": "*" - }, - "suggest": { - "ext-xdebug": "*", - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.7.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/5.7.27" - }, - "time": "2018-02-01T05:50:59+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "3.4.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.6 || ^7.0", - "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^1.2 || ^2.0" - }, - "conflict": { - "phpunit/phpunit": "<5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "support": { - "irc": "irc://irc.freenode.net/phpunit", - "issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues", - "source": "https://github.com/sebastianbergmann/phpunit-mock-objects/tree/3.4" - }, - "abandoned": true, - "time": "2017-06-30T09:13:00+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/1de8cd5c010cb153fcd68b8d0f64606f523f7619", - "reference": "1de8cd5c010cb153fcd68b8d0f64606f523f7619", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "phpunit/phpunit": "^8.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-11-30T08:15:22+00:00" - }, - { - "name": "sebastian/comparator", - "version": "1.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/1.2" - }, - "time": "2017-01-29T09:50:25+00:00" - }, - { - "name": "sebastian/diff", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/1.4" - }, - "time": "2017-05-22T07:24:03+00:00" - }, - { - "name": "sebastian/environment", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/master" - }, - "time": "2016-11-26T07:53:53+00:00" - }, - { - "name": "sebastian/exporter", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~2.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/master" - }, - "time": "2016-11-19T08:54:04+00:00" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "support": { - "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/1.1.1" - }, - "time": "2015-10-12T03:26:01+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", - "shasum": "" - }, - "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/master" - }, - "time": "2017-02-18T15:18:39+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "support": { - "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/master" - }, - "time": "2016-11-19T07:33:16+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "shasum": "" - }, - "require": { - "php": ">=5.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/master" - }, - "time": "2015-07-28T20:34:47+00:00" - }, - { - "name": "sebastian/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "support": { - "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/master" - }, - "time": "2016-10-03T07:35:21+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.19.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/aed596913b70fae57be53d86faa2e9ef85a2297b", - "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.19.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-23T09:01:57+00:00" - }, - { - "name": "symfony/yaml", - "version": "v3.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "88289caa3c166321883f67fe5130188ebbb47094" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/88289caa3c166321883f67fe5130188ebbb47094", - "reference": "88289caa3c166321883f67fe5130188ebbb47094", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/yaml/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-24T10:57:07+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.9.1", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", - "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<3.9.1" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" - }, - "type": "library", - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.9.1" - }, - "time": "2020-07-08T17:02:28+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.6.0", + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "ecd99353efa1e6aa997a3cdd27edad14", + "packages": [ + { + "name": "php-http/discovery", + "version": "1.20.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "82fe4c73ef3363caed49ff8dd1539ba06044910d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/82fe4c73ef3363caed49ff8dd1539ba06044910d", + "reference": "82fe4c73ef3363caed49ff8dd1539ba06044910d", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0|^2.0", + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0", + "zendframework/zend-diactoros": "*" + }, + "provide": { + "php-http/async-client-implementation": "*", + "php-http/client-implementation": "*", + "psr/http-client-implementation": "*", + "psr/http-factory-implementation": "*", + "psr/http-message-implementation": "*" + }, + "require-dev": { + "composer/composer": "^1.0.2|^2.0", + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1 || ^7.3", + "sebastian/comparator": "^3.0.5 || ^4.0.8", + "symfony/phpunit-bridge": "^6.4.4 || ^7.0.1" + }, + "type": "composer-plugin", + "extra": { + "class": "Http\\Discovery\\Composer\\Plugin", + "plugin-optional": true + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + }, + "exclude-from-classmap": [ + "src/Composer/Plugin.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr17", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.20.0" + }, + "time": "2024-10-02T11:20:13+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "standard-webhooks/standard-webhooks", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/standard-webhooks/standard-webhooks.git", + "reference": "b03a68fe8b1904de92ba1df669dc8bd9c8226df3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/standard-webhooks/standard-webhooks/zipball/b03a68fe8b1904de92ba1df669dc8bd9c8226df3", + "reference": "b03a68fe8b1904de92ba1df669dc8bd9c8226df3", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0 || ^10.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "StandardWebhooks\\": "libraries/php/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Standard Webhooks - Open source tools and guidelines for sending webhooks easily, securely, and reliably", + "homepage": "https://www.standardwebhooks.com", + "keywords": [ + "hmac", + "signature", + "standard-webhooks", + "verification", + "webhooks" + ], + "support": { + "issues": "https://github.com/standard-webhooks/standard-webhooks/issues", + "source": "https://github.com/standard-webhooks/standard-webhooks/tree/v1.0.0" + }, + "time": "2025-12-10T17:57:04+00:00" + } + ], + "packages-dev": [ + { + "name": "brianium/paratest", + "version": "v7.8.5", + "source": { + "type": "git", + "url": "https://github.com/paratestphp/paratest.git", + "reference": "9b324c8fc319cf9728b581c7a90e1c8f6361c5e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/9b324c8fc319cf9728b581c7a90e1c8f6361c5e5", + "reference": "9b324c8fc319cf9728b581c7a90e1c8f6361c5e5", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-simplexml": "*", + "fidry/cpu-core-counter": "^1.3.0", + "jean85/pretty-package-versions": "^2.1.1", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "phpunit/php-code-coverage": "^11.0.12", + "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-timer": "^7.0.1", + "phpunit/phpunit": "^11.5.46", + "sebastian/environment": "^7.2.1", + "symfony/console": "^6.4.22 || ^7.3.4 || ^8.0.3", + "symfony/process": "^6.4.20 || ^7.3.4 || ^8.0.3" + }, + "require-dev": { + "doctrine/coding-standard": "^12.0.0", + "ext-pcov": "*", + "ext-posix": "*", + "phpstan/phpstan": "^2.1.33", + "phpstan/phpstan-deprecation-rules": "^2.0.3", + "phpstan/phpstan-phpunit": "^2.0.11", + "phpstan/phpstan-strict-rules": "^2.0.7", + "squizlabs/php_codesniffer": "^3.13.5", + "symfony/filesystem": "^6.4.13 || ^7.3.2 || ^8.0.1" + }, + "bin": [ + "bin/paratest", + "bin/paratest_for_phpstorm" + ], + "type": "library", + "autoload": { + "psr-4": { + "ParaTest\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Scaturro", + "email": "scaturrob@gmail.com", + "role": "Developer" + }, + { + "name": "Filippo Tessarotto", + "email": "zoeslam@gmail.com", + "role": "Developer" + } + ], + "description": "Parallel testing for PHP", + "homepage": "https://github.com/paratestphp/paratest", + "keywords": [ + "concurrent", + "parallel", + "phpunit", + "testing" + ], + "support": { + "issues": "https://github.com/paratestphp/paratest/issues", + "source": "https://github.com/paratestphp/paratest/tree/v7.8.5" + }, + "funding": [ + { + "url": "https://github.com/sponsors/Slamdunk", + "type": "github" + }, + { + "url": "https://paypal.me/filippotessarotto", + "type": "paypal" + } + ], + "time": "2026-01-08T08:02:38+00:00" + }, + { + "name": "clue/ndjson-react", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/clue/reactphp-ndjson.git", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", + "react/event-loop": "^1.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Clue\\React\\NDJson\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + } + ], + "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.", + "homepage": "https://github.com/clue/reactphp-ndjson", + "keywords": [ + "NDJSON", + "json", + "jsonlines", + "newline", + "reactphp", + "streaming" + ], + "support": { + "issues": "https://github.com/clue/reactphp-ndjson/issues", + "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0" + }, + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-12-23T10:58:28+00:00" + }, + { + "name": "clue/stream-filter", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/clue/stream-filter.git", + "reference": "049509fef80032cb3f051595029ab75b49a3c2f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/stream-filter/zipball/049509fef80032cb3f051595029ab75b49a3c2f7", + "reference": "049509fef80032cb3f051595029ab75b49a3c2f7", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "Clue\\StreamFilter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ], + "support": { + "issues": "https://github.com/clue/stream-filter/issues", + "source": "https://github.com/clue/stream-filter/tree/v1.7.0" + }, + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2023-12-20T15:40:13+00:00" + }, + { + "name": "composer/pcre", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-11-12T16:29:46+00:00" + }, + { + "name": "composer/semver", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "reference": "198166618906cb2de69b95d7d47e5fa8aa1b2b95", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.11", + "symfony/phpunit-bridge": "^3 || ^7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + } + ], + "time": "2025-08-20T19:15:30+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.5", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-05-06T16:37:16+00:00" + }, + { + "name": "doctrine/deprecations", + "version": "1.1.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38", + "reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "phpunit/phpunit": "<=7.5 || >=13" + }, + "require-dev": { + "doctrine/coding-standard": "^9 || ^12 || ^13", + "phpstan/phpstan": "1.4.10 || 2.1.11", + "phpstan/phpstan-phpunit": "^1.0 || ^2", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12", + "psr/log": "^1 || ^2 || ^3" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/1.1.5" + }, + "time": "2025-04-07T20:06:18+00:00" + }, + { + "name": "evenement/evenement", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/igorw/evenement.git", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^9 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Evenement\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "description": "Événement is a very simple event dispatching library for PHP", + "keywords": [ + "event-dispatcher", + "event-emitter" + ], + "support": { + "issues": "https://github.com/igorw/evenement/issues", + "source": "https://github.com/igorw/evenement/tree/v3.0.2" + }, + "time": "2023-08-08T05:53:35+00:00" + }, + { + "name": "fidry/cpu-core-counter", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/theofidry/cpu-core-counter.git", + "reference": "db9508f7b1474469d9d3c53b86f817e344732678" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678", + "reference": "db9508f7b1474469d9d3c53b86f817e344732678", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "fidry/makefile": "^0.2.0", + "fidry/php-cs-fixer-config": "^1.1.2", + "phpstan/extension-installer": "^1.2.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-deprecation-rules": "^2.0.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^8.5.31 || ^9.5.26", + "webmozarts/strict-phpunit": "^7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Fidry\\CpuCoreCounter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Théo FIDRY", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Tiny utility to get the number of CPU cores.", + "keywords": [ + "CPU", + "core" + ], + "support": { + "issues": "https://github.com/theofidry/cpu-core-counter/issues", + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.3.0" + }, + "funding": [ + { + "url": "https://github.com/theofidry", + "type": "github" + } + ], + "time": "2025-08-14T07:29:31+00:00" + }, + { + "name": "filp/whoops", + "version": "2.18.4", + "source": { + "type": "git", + "url": "https://github.com/filp/whoops.git", + "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/filp/whoops/zipball/d2102955e48b9fd9ab24280a7ad12ed552752c4d", + "reference": "d2102955e48b9fd9ab24280a7ad12ed552752c4d", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "psr/log": "^1.0.1 || ^2.0 || ^3.0" + }, + "require-dev": { + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.3", + "symfony/var-dumper": "^4.0 || ^5.0" + }, + "suggest": { + "symfony/var-dumper": "Pretty print complex values better with var-dumper available", + "whoops/soap": "Formats errors as SOAP responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Whoops\\": "src/Whoops/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Filipe Dobreira", + "homepage": "https://github.com/filp", + "role": "Developer" + } + ], + "description": "php error handling for cool kids", + "homepage": "https://filp.github.io/whoops/", + "keywords": [ + "error", + "exception", + "handling", + "library", + "throwable", + "whoops" + ], + "support": { + "issues": "https://github.com/filp/whoops/issues", + "source": "https://github.com/filp/whoops/tree/2.18.4" + }, + "funding": [ + { + "url": "https://github.com/denis-sokolov", + "type": "github" + } + ], + "time": "2025-08-08T12:00:00+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v3.92.5", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", + "reference": "260cc8c4a1d2f6d2f22cd4f9c70aa72e55ebac58" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/260cc8c4a1d2f6d2f22cd4f9c70aa72e55ebac58", + "reference": "260cc8c4a1d2f6d2f22cd4f9c70aa72e55ebac58", + "shasum": "" + }, + "require": { + "clue/ndjson-react": "^1.3", + "composer/semver": "^3.4", + "composer/xdebug-handler": "^3.0.5", + "ext-filter": "*", + "ext-hash": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "fidry/cpu-core-counter": "^1.3", + "php": "^7.4 || ^8.0", + "react/child-process": "^0.6.6", + "react/event-loop": "^1.5", + "react/socket": "^1.16", + "react/stream": "^1.4", + "sebastian/diff": "^4.0.6 || ^5.1.1 || ^6.0.2 || ^7.0", + "symfony/console": "^5.4.47 || ^6.4.24 || ^7.0 || ^8.0", + "symfony/event-dispatcher": "^5.4.45 || ^6.4.24 || ^7.0 || ^8.0", + "symfony/filesystem": "^5.4.45 || ^6.4.24 || ^7.0 || ^8.0", + "symfony/finder": "^5.4.45 || ^6.4.24 || ^7.0 || ^8.0", + "symfony/options-resolver": "^5.4.45 || ^6.4.24 || ^7.0 || ^8.0", + "symfony/polyfill-mbstring": "^1.33", + "symfony/polyfill-php80": "^1.33", + "symfony/polyfill-php81": "^1.33", + "symfony/polyfill-php84": "^1.33", + "symfony/process": "^5.4.47 || ^6.4.24 || ^7.2 || ^8.0", + "symfony/stopwatch": "^5.4.45 || ^6.4.24 || ^7.0 || ^8.0" + }, + "require-dev": { + "facile-it/paraunit": "^1.3.1 || ^2.7", + "infection/infection": "^0.31", + "justinrainbow/json-schema": "^6.6", + "keradus/cli-executor": "^2.3", + "mikey179/vfsstream": "^1.6.12", + "php-coveralls/php-coveralls": "^2.9", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.6", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.6", + "phpunit/phpunit": "^9.6.31 || ^10.5.60 || ^11.5.46", + "symfony/polyfill-php85": "^1.33", + "symfony/var-dumper": "^5.4.48 || ^6.4.26 || ^7.4.0 || ^8.0", + "symfony/yaml": "^5.4.45 || ^6.4.30 || ^7.4.1 || ^8.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + }, + "exclude-from-classmap": [ + "src/**/Internal/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "keywords": [ + "Static code analysis", + "fixer", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.92.5" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2026-01-08T21:57:37+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.10.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", + "reference": "b51ac707cfa420b7bfd4e4d5e510ba8008e822b4", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^2.3", + "guzzlehttp/psr7": "^2.8", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", - "ext-json": "*" + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.10.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2025-08-23T22:36:01+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "481557b130ef3790cf82b713667b43030dc9c957" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957", + "reference": "481557b130ef3790cf82b713667b43030dc9c957", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.44 || ^9.6.25" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.3.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2025-08-22T14:34:08+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.9.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "7d0ed42f28e42d61352a7a79de682e5e67fec884" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/7d0ed42f28e42d61352a7a79de682e5e67fec884", + "reference": "7d0ed42f28e42d61352a7a79de682e5e67fec884", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "jshttp/mime-db": "1.54.0.1", + "phpunit/phpunit": "^8.5.44 || ^9.6.25" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.9.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2026-03-10T16:41:02+00:00" + }, + { + "name": "jean85/pretty-package-versions", + "version": "2.1.1", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a", + "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2.1.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.2", + "jean85/composer-provided-replaced-stub-package": "^1.0", + "phpstan/phpstan": "^2.0", + "phpunit/phpunit": "^7.5|^8.5|^9.6", + "rector/rector": "^2.0", + "vimeo/psalm": "^4.3 || ^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Jean85\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" + } + ], + "description": "A library to get pretty versions strings of installed dependencies", + "keywords": [ + "composer", + "package", + "release", + "versions" + ], + "support": { + "issues": "https://github.com/Jean85/pretty-package-versions/issues", + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.1" + }, + "time": "2025-03-19T14:43:43+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.13.4", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2025-08-01T08:46:24+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v5.7.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82", + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0" + }, + "time": "2025-12-06T11:56:16+00:00" + }, + { + "name": "nunomaduro/collision", + "version": "v8.8.3", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/collision.git", + "reference": "1dc9e88d105699d0fee8bb18890f41b274f6b4c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/1dc9e88d105699d0fee8bb18890f41b274f6b4c4", + "reference": "1dc9e88d105699d0fee8bb18890f41b274f6b4c4", + "shasum": "" + }, + "require": { + "filp/whoops": "^2.18.1", + "nunomaduro/termwind": "^2.3.1", + "php": "^8.2.0", + "symfony/console": "^7.3.0" + }, + "conflict": { + "laravel/framework": "<11.44.2 || >=13.0.0", + "phpunit/phpunit": "<11.5.15 || >=13.0.0" + }, + "require-dev": { + "brianium/paratest": "^7.8.3", + "larastan/larastan": "^3.4.2", + "laravel/framework": "^11.44.2 || ^12.18", + "laravel/pint": "^1.22.1", + "laravel/sail": "^1.43.1", + "laravel/sanctum": "^4.1.1", + "laravel/tinker": "^2.10.1", + "orchestra/testbench-core": "^9.12.0 || ^10.4", + "pestphp/pest": "^3.8.2 || ^4.0.0", + "sebastian/environment": "^7.2.1 || ^8.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider" + ] + }, + "branch-alias": { + "dev-8.x": "8.x-dev" + } + }, + "autoload": { + "files": [ + "./src/Adapters/Phpunit/Autoload.php" + ], + "psr-4": { + "NunoMaduro\\Collision\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Cli error handling for console/command-line PHP applications.", + "keywords": [ + "artisan", + "cli", + "command-line", + "console", + "dev", + "error", + "handling", + "laravel", + "laravel-zero", + "php", + "symfony" + ], + "support": { + "issues": "https://github.com/nunomaduro/collision/issues", + "source": "https://github.com/nunomaduro/collision" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2025-11-20T02:55:25+00:00" + }, + { + "name": "nunomaduro/termwind", + "version": "v2.3.3", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/termwind.git", + "reference": "6fb2a640ff502caace8e05fd7be3b503a7e1c017" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/6fb2a640ff502caace8e05fd7be3b503a7e1c017", + "reference": "6fb2a640ff502caace8e05fd7be3b503a7e1c017", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^8.2", + "symfony/console": "^7.3.6" + }, + "require-dev": { + "illuminate/console": "^11.46.1", + "laravel/pint": "^1.25.1", + "mockery/mockery": "^1.6.12", + "pestphp/pest": "^2.36.0 || ^3.8.4 || ^4.1.3", + "phpstan/phpstan": "^1.12.32", + "phpstan/phpstan-strict-rules": "^1.6.2", + "symfony/var-dumper": "^7.3.5", + "thecodingmachine/phpstan-strict-rules": "^1.0.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Termwind\\Laravel\\TermwindServiceProvider" + ] + }, + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "files": [ + "src/Functions.php" + ], + "psr-4": { + "Termwind\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Its like Tailwind CSS, but for the console.", + "keywords": [ + "cli", + "console", + "css", + "package", + "php", + "style" + ], + "support": { + "issues": "https://github.com/nunomaduro/termwind/issues", + "source": "https://github.com/nunomaduro/termwind/tree/v2.3.3" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://github.com/xiCO2k", + "type": "github" + } + ], + "time": "2025-11-20T02:34:59+00:00" + }, + { + "name": "nyholm/psr7", + "version": "1.8.2", + "source": { + "type": "git", + "url": "https://github.com/Nyholm/psr7.git", + "reference": "a71f2b11690f4b24d099d6b16690a90ae14fc6f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nyholm/psr7/zipball/a71f2b11690f4b24d099d6b16690a90ae14fc6f3", + "reference": "a71f2b11690f4b24d099d6b16690a90ae14fc6f3", + "shasum": "" + }, + "require": { + "php": ">=7.2", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0", + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "http-interop/http-factory-tests": "^0.9", + "php-http/message-factory": "^1.0", + "php-http/psr7-integration-tests": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.4", + "symfony/error-handler": "^4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Nyholm\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + }, + { + "name": "Martijn van der Ven", + "email": "martijn@vanderven.se" + } + ], + "description": "A fast PHP7 implementation of PSR-7", + "homepage": "https://tnyholm.se", + "keywords": [ + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/Nyholm/psr7/issues", + "source": "https://github.com/Nyholm/psr7/tree/1.8.2" + }, + "funding": [ + { + "url": "https://github.com/Zegnat", + "type": "github" + }, + { + "url": "https://github.com/nyholm", + "type": "github" + } + ], + "time": "2024-09-09T07:06:30+00:00" + }, + { + "name": "pestphp/pest", + "version": "v3.8.5", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest.git", + "reference": "7796630eafcfd1c02660cecdde3bc6984fbf01f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest/zipball/7796630eafcfd1c02660cecdde3bc6984fbf01f4", + "reference": "7796630eafcfd1c02660cecdde3bc6984fbf01f4", + "shasum": "" + }, + "require": { + "brianium/paratest": "^7.8.5", + "nunomaduro/collision": "^8.8.3", + "nunomaduro/termwind": "^2.3.3", + "pestphp/pest-plugin": "^3.0.0", + "pestphp/pest-plugin-arch": "^3.1.1", + "pestphp/pest-plugin-mutate": "^3.0.5", + "php": "^8.2.0", + "phpunit/phpunit": "^11.5.50" + }, + "conflict": { + "filp/whoops": "<2.16.0", + "phpunit/phpunit": ">11.5.50", + "sebastian/exporter": "<6.0.0", + "webmozart/assert": "<1.11.0" + }, + "require-dev": { + "pestphp/pest-dev-tools": "^3.4.0", + "pestphp/pest-plugin-type-coverage": "^3.6.1", + "symfony/process": "^7.4.4" + }, + "bin": [ + "bin/pest" + ], + "type": "library", + "extra": { + "pest": { + "plugins": [ + "Pest\\Mutate\\Plugins\\Mutate", + "Pest\\Plugins\\Configuration", + "Pest\\Plugins\\Bail", + "Pest\\Plugins\\Cache", + "Pest\\Plugins\\Coverage", + "Pest\\Plugins\\Init", + "Pest\\Plugins\\Environment", + "Pest\\Plugins\\Help", + "Pest\\Plugins\\Memory", + "Pest\\Plugins\\Only", + "Pest\\Plugins\\Printer", + "Pest\\Plugins\\ProcessIsolation", + "Pest\\Plugins\\Profile", + "Pest\\Plugins\\Retry", + "Pest\\Plugins\\Snapshot", + "Pest\\Plugins\\Verbose", + "Pest\\Plugins\\Version", + "Pest\\Plugins\\Parallel" + ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "files": [ + "src/Functions.php", + "src/Pest.php" + ], + "psr-4": { + "Pest\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "The elegant PHP Testing Framework.", + "keywords": [ + "framework", + "pest", + "php", + "test", + "testing", + "unit" + ], + "support": { + "issues": "https://github.com/pestphp/pest/issues", + "source": "https://github.com/pestphp/pest/tree/v3.8.5" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2026-01-28T01:33:45+00:00" }, - "platform-dev": [], - "platform-overrides": { - "php": "5.6" + { + "name": "pestphp/pest-plugin", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin.git", + "reference": "e79b26c65bc11c41093b10150c1341cc5cdbea83" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin/zipball/e79b26c65bc11c41093b10150c1341cc5cdbea83", + "reference": "e79b26c65bc11c41093b10150c1341cc5cdbea83", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0.0", + "composer-runtime-api": "^2.2.2", + "php": "^8.2" + }, + "conflict": { + "pestphp/pest": "<3.0.0" + }, + "require-dev": { + "composer/composer": "^2.7.9", + "pestphp/pest": "^3.0.0", + "pestphp/pest-dev-tools": "^3.0.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Pest\\Plugin\\Manager" + }, + "autoload": { + "psr-4": { + "Pest\\Plugin\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The Pest plugin manager", + "keywords": [ + "framework", + "manager", + "pest", + "php", + "plugin", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin/tree/v3.0.0" + }, + "funding": [ + { + "url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2024-09-08T23:21:41+00:00" + }, + { + "name": "pestphp/pest-plugin-arch", + "version": "v3.1.1", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin-arch.git", + "reference": "db7bd9cb1612b223e16618d85475c6f63b9c8daa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/db7bd9cb1612b223e16618d85475c6f63b9c8daa", + "reference": "db7bd9cb1612b223e16618d85475c6f63b9c8daa", + "shasum": "" + }, + "require": { + "pestphp/pest-plugin": "^3.0.0", + "php": "^8.2", + "ta-tikoma/phpunit-architecture-test": "^0.8.4" + }, + "require-dev": { + "pestphp/pest": "^3.8.1", + "pestphp/pest-dev-tools": "^3.4.0" + }, + "type": "library", + "extra": { + "pest": { + "plugins": [ + "Pest\\Arch\\Plugin" + ] + } + }, + "autoload": { + "files": [ + "src/Autoload.php" + ], + "psr-4": { + "Pest\\Arch\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "The Arch plugin for Pest PHP.", + "keywords": [ + "arch", + "architecture", + "framework", + "pest", + "php", + "plugin", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin-arch/tree/v3.1.1" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2025-04-16T22:59:48+00:00" + }, + { + "name": "pestphp/pest-plugin-mutate", + "version": "v3.0.5", + "source": { + "type": "git", + "url": "https://github.com/pestphp/pest-plugin-mutate.git", + "reference": "e10dbdc98c9e2f3890095b4fe2144f63a5717e08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pestphp/pest-plugin-mutate/zipball/e10dbdc98c9e2f3890095b4fe2144f63a5717e08", + "reference": "e10dbdc98c9e2f3890095b4fe2144f63a5717e08", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^5.2.0", + "pestphp/pest-plugin": "^3.0.0", + "php": "^8.2", + "psr/simple-cache": "^3.0.0" + }, + "require-dev": { + "pestphp/pest": "^3.0.8", + "pestphp/pest-dev-tools": "^3.0.0", + "pestphp/pest-plugin-type-coverage": "^3.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Pest\\Mutate\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sandro Gehri", + "email": "sandrogehri@gmail.com" + } + ], + "description": "Mutates your code to find untested cases", + "keywords": [ + "framework", + "mutate", + "mutation", + "pest", + "php", + "plugin", + "test", + "testing", + "unit" + ], + "support": { + "source": "https://github.com/pestphp/pest-plugin-mutate/tree/v3.0.5" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/gehrisandro", + "type": "github" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + } + ], + "time": "2024-09-22T07:54:40+00:00" }, - "plugin-api-version": "2.2.0" + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "php-http/client-common", + "version": "2.7.3", + "source": { + "type": "git", + "url": "https://github.com/php-http/client-common.git", + "reference": "dcc6de29c90dd74faab55f71b79d89409c4bf0c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/client-common/zipball/dcc6de29c90dd74faab55f71b79d89409c4bf0c1", + "reference": "dcc6de29c90dd74faab55f71b79d89409c4bf0c1", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/httplug": "^2.0", + "php-http/message": "^1.6", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0 || ^2.0", + "symfony/options-resolver": "~4.0.15 || ~4.1.9 || ^4.2.1 || ^5.0 || ^6.0 || ^7.0 || ^8.0", + "symfony/polyfill-php80": "^1.17" + }, + "require-dev": { + "doctrine/instantiator": "^1.1", + "guzzlehttp/psr7": "^1.4", + "nyholm/psr7": "^1.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.33 || ^9.6.7" + }, + "suggest": { + "ext-json": "To detect JSON responses with the ContentTypePlugin", + "ext-libxml": "To detect XML responses with the ContentTypePlugin", + "php-http/cache-plugin": "PSR-6 Cache plugin", + "php-http/logger-plugin": "PSR-3 Logger plugin", + "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Client\\Common\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Common HTTP Client implementations and tools for HTTPlug", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "common", + "http", + "httplug" + ], + "support": { + "issues": "https://github.com/php-http/client-common/issues", + "source": "https://github.com/php-http/client-common/tree/2.7.3" + }, + "time": "2025-11-29T19:12:34+00:00" + }, + { + "name": "php-http/httplug", + "version": "2.4.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "5cad731844891a4c282f3f3e1b582c46839d22f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/5cad731844891a4c282f3f3e1b582c46839d22f4", + "reference": "5cad731844891a4c282f3f3e1b582c46839d22f4", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/promise": "^1.1", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.1 || ^5.0 || ^6.0", + "phpspec/phpspec": "^5.1 || ^6.0 || ^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "support": { + "issues": "https://github.com/php-http/httplug/issues", + "source": "https://github.com/php-http/httplug/tree/2.4.1" + }, + "time": "2024-09-23T11:39:58+00:00" + }, + { + "name": "php-http/message", + "version": "1.16.2", + "source": { + "type": "git", + "url": "https://github.com/php-http/message.git", + "reference": "06dd5e8562f84e641bf929bfe699ee0f5ce8080a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message/zipball/06dd5e8562f84e641bf929bfe699ee0f5ce8080a", + "reference": "06dd5e8562f84e641bf929bfe699ee0f5ce8080a", + "shasum": "" + }, + "require": { + "clue/stream-filter": "^1.5", + "php": "^7.2 || ^8.0", + "psr/http-message": "^1.1 || ^2.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.6", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0 || ^2.0", + "laminas/laminas-diactoros": "^2.0 || ^3.0", + "php-http/message-factory": "^1.0.2", + "phpspec/phpspec": "^5.1 || ^6.3 || ^7.1", + "slim/slim": "^3.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "laminas/laminas-diactoros": "Used with Diactoros Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation" + }, + "type": "library", + "autoload": { + "files": [ + "src/filters.php" + ], + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", + "keywords": [ + "http", + "message", + "psr-7" + ], + "support": { + "issues": "https://github.com/php-http/message/issues", + "source": "https://github.com/php-http/message/tree/1.16.2" + }, + "time": "2024-10-02T11:34:13+00:00" + }, + { + "name": "php-http/mock-client", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/mock-client.git", + "reference": "81f558234421f7da58ed015604a03808996017d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/mock-client/zipball/81f558234421f7da58ed015604a03808996017d0", + "reference": "81f558234421f7da58ed015604a03808996017d0", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/client-common": "^2.0", + "php-http/discovery": "^1.16", + "php-http/httplug": "^2.0", + "psr/http-client": "^1.0", + "psr/http-factory-implementation": "^1.0", + "psr/http-message": "^1.0 || ^2.0", + "symfony/polyfill-php80": "^1.17" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0", + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "phpspec/phpspec": "^5.1 || ^6.1 || ^7.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Mock\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David de Boer", + "email": "david@ddeboer.nl" + } + ], + "description": "Mock HTTP client", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http", + "mock", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/mock-client/issues", + "source": "https://github.com/php-http/mock-client/tree/1.6.1" + }, + "time": "2024-10-31T10:30:18+00:00" + }, + { + "name": "php-http/promise", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/fc85b1fba37c169a69a07ef0d5a8075770cc1f83", + "reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.3.2 || ^6.3", + "phpspec/phpspec": "^5.1.2 || ^6.2 || ^7.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/php-http/promise/issues", + "source": "https://github.com/php-http/promise/tree/1.3.1" + }, + "time": "2024-03-15T13:55:21+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "5.6.6", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "5cee1d3dfc2d2aa6599834520911d246f656bcb8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/5cee1d3dfc2d2aa6599834520911d246f656bcb8", + "reference": "5cee1d3dfc2d2aa6599834520911d246f656bcb8", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.1", + "ext-filter": "*", + "php": "^7.4 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.7", + "phpstan/phpdoc-parser": "^1.7|^2.0", + "webmozart/assert": "^1.9.1 || ^2" + }, + "require-dev": { + "mockery/mockery": "~1.3.5 || ~1.6.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "psalm/phar": "^5.26" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.6" + }, + "time": "2025-12-22T21:13:58+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.12.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "92a98ada2b93d9b201a613cb5a33584dde25f195" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/92a98ada2b93d9b201a613cb5a33584dde25f195", + "reference": "92a98ada2b93d9b201a613cb5a33584dde25f195", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.0", + "php": "^7.3 || ^8.0", + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^1.18|^2.0" + }, + "require-dev": { + "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/rector": "^0.13.9", + "vimeo/psalm": "^4.25" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.12.0" + }, + "time": "2025-11-21T15:09:14+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0 || ^2.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.4.3" + }, + "time": "2024-09-04T20:21:43+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "1e0cd5370df5dd2e556a36b9c62f62e555870495" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/1e0cd5370df5dd2e556a36b9c62f62e555870495", + "reference": "1e0cd5370df5dd2e556a36b9c62f62e555870495", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^5.3.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.3.0" + }, + "time": "2025-08-30T15:50:23+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "2.1.33", + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9e800e6bee7d5bd02784d4c6069b48032d16224f", + "reference": "9e800e6bee7d5bd02784d4c6069b48032d16224f", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2025-12-05T10:24:31+00:00" + }, + { + "name": "phpstan/phpstan-phpunit", + "version": "2.0.11", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-phpunit.git", + "reference": "5e30669bef866eff70db8b58d72a5c185aa82414" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/5e30669bef866eff70db8b58d72a5c185aa82414", + "reference": "5e30669bef866eff70db8b58d72a5c185aa82414", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.32" + }, + "conflict": { + "phpunit/phpunit": "<7.0" + }, + "require-dev": { + "nikic/php-parser": "^5", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPUnit extensions and rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-phpunit/issues", + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.11" + }, + "time": "2025-12-19T09:05:35+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "11.0.12", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "2c1ed04922802c15e1de5d7447b4856de949cf56" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2c1ed04922802c15e1de5d7447b4856de949cf56", + "reference": "2c1ed04922802c15e1de5d7447b4856de949cf56", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^5.7.0", + "php": ">=8.2", + "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-text-template": "^4.0.1", + "sebastian/code-unit-reverse-lookup": "^4.0.1", + "sebastian/complexity": "^4.0.1", + "sebastian/environment": "^7.2.1", + "sebastian/lines-of-code": "^3.0.1", + "sebastian/version": "^5.0.2", + "theseer/tokenizer": "^1.3.1" + }, + "require-dev": { + "phpunit/phpunit": "^11.5.46" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "11.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.12" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/php-code-coverage", + "type": "tidelift" + } + ], + "time": "2025-12-24T07:01:01+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "5.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/2f3a64888c814fc235386b7387dd5b5ed92ad903", + "reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/php-file-iterator", + "type": "tidelift" + } + ], + "time": "2026-02-02T13:52:54+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "5.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "c1ca3814734c07492b3d4c5f794f4b0995333da2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/c1ca3814734c07492b3d4c5f794f4b0995333da2", + "reference": "c1ca3814734c07492b3d4c5f794f4b0995333da2", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^11.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "security": "https://github.com/sebastianbergmann/php-invoker/security/policy", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/5.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T05:07:44+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "3e0404dc6b300e6bf56415467ebcb3fe4f33e964" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/3e0404dc6b300e6bf56415467ebcb3fe4f33e964", + "reference": "3e0404dc6b300e6bf56415467ebcb3fe4f33e964", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/4.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T05:08:43+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "7.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3b415def83fbcb41f991d9ebf16ae4ad8b7837b3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3b415def83fbcb41f991d9ebf16ae4ad8b7837b3", + "reference": "3b415def83fbcb41f991d9ebf16ae4ad8b7837b3", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "7.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "security": "https://github.com/sebastianbergmann/php-timer/security/policy", + "source": "https://github.com/sebastianbergmann/php-timer/tree/7.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T05:09:35+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "11.5.50", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "fdfc727f0fcacfeb8fcb30c7e5da173125b58be3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fdfc727f0fcacfeb8fcb30c7e5da173125b58be3", + "reference": "fdfc727f0fcacfeb8fcb30c7e5da173125b58be3", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.13.4", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=8.2", + "phpunit/php-code-coverage": "^11.0.12", + "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-invoker": "^5.0.1", + "phpunit/php-text-template": "^4.0.1", + "phpunit/php-timer": "^7.0.1", + "sebastian/cli-parser": "^3.0.2", + "sebastian/code-unit": "^3.0.3", + "sebastian/comparator": "^6.3.3", + "sebastian/diff": "^6.0.2", + "sebastian/environment": "^7.2.1", + "sebastian/exporter": "^6.3.2", + "sebastian/global-state": "^7.0.2", + "sebastian/object-enumerator": "^6.0.1", + "sebastian/type": "^5.1.3", + "sebastian/version": "^5.0.2", + "staabm/side-effects-detector": "^1.0.5" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "11.5-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.50" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2026-01-27T05:59:18+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/log", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.2" + }, + "time": "2024-09-11T13:17:53+00:00" + }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "react/cache", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/cache.git", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/promise": "^3.0 || ^2.0 || ^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, Promise-based cache interface for ReactPHP", + "keywords": [ + "cache", + "caching", + "promise", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/cache/issues", + "source": "https://github.com/reactphp/cache/tree/v1.2.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2022-11-30T15:59:55+00:00" + }, + { + "name": "react/child-process", + "version": "v0.6.7", + "source": { + "type": "git", + "url": "https://github.com/reactphp/child-process.git", + "reference": "970f0e71945556422ee4570ccbabaedc3cf04ad3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/child-process/zipball/970f0e71945556422ee4570ccbabaedc3cf04ad3", + "reference": "970f0e71945556422ee4570ccbabaedc3cf04ad3", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/event-loop": "^1.2", + "react/stream": "^1.4" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/socket": "^1.16", + "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\ChildProcess\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven library for executing child processes with ReactPHP.", + "keywords": [ + "event-driven", + "process", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/child-process/issues", + "source": "https://github.com/reactphp/child-process/tree/v0.6.7" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2025-12-23T15:25:20+00:00" + }, + { + "name": "react/dns", + "version": "v1.14.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/dns.git", + "reference": "7562c05391f42701c1fccf189c8225fece1cd7c3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/dns/zipball/7562c05391f42701c1fccf189c8225fece1cd7c3", + "reference": "7562c05391f42701c1fccf189c8225fece1cd7c3", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/cache": "^1.0 || ^0.6 || ^0.5", + "react/event-loop": "^1.2", + "react/promise": "^3.2 || ^2.7 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4.3 || ^3 || ^2", + "react/promise-timer": "^1.11" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Dns\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async DNS resolver for ReactPHP", + "keywords": [ + "async", + "dns", + "dns-resolver", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/dns/issues", + "source": "https://github.com/reactphp/dns/tree/v1.14.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2025-11-18T19:34:28+00:00" + }, + { + "name": "react/event-loop", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/event-loop.git", + "reference": "ba276bda6083df7e0050fd9b33f66ad7a4ac747a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/ba276bda6083df7e0050fd9b33f66ad7a4ac747a", + "reference": "ba276bda6083df7e0050fd9b33f66ad7a4ac747a", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "suggest": { + "ext-pcntl": "For signal handling support when using the StreamSelectLoop" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\EventLoop\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", + "keywords": [ + "asynchronous", + "event-loop" + ], + "support": { + "issues": "https://github.com/reactphp/event-loop/issues", + "source": "https://github.com/reactphp/event-loop/tree/v1.6.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2025-11-17T20:46:25+00:00" + }, + { + "name": "react/promise", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "23444f53a813a3296c1368bb104793ce8d88f04a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/23444f53a813a3296c1368bb104793ce8d88f04a", + "reference": "23444f53a813a3296c1368bb104793ce8d88f04a", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpstan/phpstan": "1.12.28 || 1.4.10", + "phpunit/phpunit": "^9.6 || ^7.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], + "support": { + "issues": "https://github.com/reactphp/promise/issues", + "source": "https://github.com/reactphp/promise/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2025-08-19T18:57:03+00:00" + }, + { + "name": "react/socket", + "version": "v1.17.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/socket.git", + "reference": "ef5b17b81f6f60504c539313f94f2d826c5faa08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/socket/zipball/ef5b17b81f6f60504c539313f94f2d826c5faa08", + "reference": "ef5b17b81f6f60504c539313f94f2d826c5faa08", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/dns": "^1.13", + "react/event-loop": "^1.2", + "react/promise": "^3.2 || ^2.6 || ^1.2.1", + "react/stream": "^1.4" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4.3 || ^3.3 || ^2", + "react/promise-stream": "^1.4", + "react/promise-timer": "^1.11" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Socket\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", + "keywords": [ + "Connection", + "Socket", + "async", + "reactphp", + "stream" + ], + "support": { + "issues": "https://github.com/reactphp/socket/issues", + "source": "https://github.com/reactphp/socket/tree/v1.17.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2025-11-19T20:47:34+00:00" + }, + { + "name": "react/stream", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/stream.git", + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d", + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.8", + "react/event-loop": "^1.2" + }, + "require-dev": { + "clue/stream-filter": "~1.2", + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", + "keywords": [ + "event-driven", + "io", + "non-blocking", + "pipe", + "reactphp", + "readable", + "stream", + "writable" + ], + "support": { + "issues": "https://github.com/reactphp/stream/issues", + "source": "https://github.com/reactphp/stream/tree/v1.4.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-06-11T12:45:25+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "15c5dd40dc4f38794d383bb95465193f5e0ae180" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/15c5dd40dc4f38794d383bb95465193f5e0ae180", + "reference": "15c5dd40dc4f38794d383bb95465193f5e0ae180", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T04:41:36+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "54391c61e4af8078e5b276ab082b6d3c54c9ad64" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/54391c61e4af8078e5b276ab082b6d3c54c9ad64", + "reference": "54391c61e4af8078e5b276ab082b6d3c54c9ad64", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "security": "https://github.com/sebastianbergmann/code-unit/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit/tree/3.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2025-03-19T07:56:08+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "183a9b2632194febd219bb9246eee421dad8d45e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/183a9b2632194febd219bb9246eee421dad8d45e", + "reference": "183a9b2632194febd219bb9246eee421dad8d45e", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "security": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/4.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T04:45:54+00:00" + }, + { + "name": "sebastian/comparator", + "version": "6.3.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2c95e1e86cb8dd41beb8d502057d1081ccc8eca9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2c95e1e86cb8dd41beb8d502057d1081ccc8eca9", + "reference": "2c95e1e86cb8dd41beb8d502057d1081ccc8eca9", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-mbstring": "*", + "php": ">=8.2", + "sebastian/diff": "^6.0", + "sebastian/exporter": "^6.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.4" + }, + "suggest": { + "ext-bcmath": "For comparing BcMath\\Number objects" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/comparator", + "type": "tidelift" + } + ], + "time": "2026-01-24T09:26:40+00:00" + }, + { + "name": "sebastian/complexity", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "ee41d384ab1906c68852636b6de493846e13e5a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/ee41d384ab1906c68852636b6de493846e13e5a0", + "reference": "ee41d384ab1906c68852636b6de493846e13e5a0", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^5.0", + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/4.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T04:49:50+00:00" + }, + { + "name": "sebastian/diff", + "version": "6.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "b4ccd857127db5d41a5b676f24b51371d76d8544" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/b4ccd857127db5d41a5b676f24b51371d76d8544", + "reference": "b4ccd857127db5d41a5b676f24b51371d76d8544", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/6.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T04:53:05+00:00" + }, + { + "name": "sebastian/environment", + "version": "7.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "a5c75038693ad2e8d4b6c15ba2403532647830c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/a5c75038693ad2e8d4b6c15ba2403532647830c4", + "reference": "a5c75038693ad2e8d4b6c15ba2403532647830c4", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "7.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "https://github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "security": "https://github.com/sebastianbergmann/environment/security/policy", + "source": "https://github.com/sebastianbergmann/environment/tree/7.2.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/environment", + "type": "tidelift" + } + ], + "time": "2025-05-21T11:55:47+00:00" + }, + { + "name": "sebastian/exporter", + "version": "6.3.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "70a298763b40b213ec087c51c739efcaa90bcd74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74", + "reference": "70a298763b40b213ec087c51c739efcaa90bcd74", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=8.2", + "sebastian/recursion-context": "^6.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/6.3.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/exporter", + "type": "tidelift" + } + ], + "time": "2025-09-24T06:12:51+00:00" + }, + { + "name": "sebastian/global-state", + "version": "7.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "3be331570a721f9a4b5917f4209773de17f747d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7", + "reference": "3be331570a721f9a4b5917f4209773de17f747d7", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "7.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "https://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/7.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T04:57:36+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "d36ad0d782e5756913e42ad87cb2890f4ffe467a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d36ad0d782e5756913e42ad87cb2890f4ffe467a", + "reference": "d36ad0d782e5756913e42ad87cb2890f4ffe467a", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^5.0", + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T04:58:38+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "f5b498e631a74204185071eb41f33f38d64608aa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa", + "reference": "f5b498e631a74204185071eb41f33f38d64608aa", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "security": "https://github.com/sebastianbergmann/object-enumerator/security/policy", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/6.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T05:00:13+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "6e1a43b411b2ad34146dee7524cb13a068bb35f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9", + "reference": "6e1a43b411b2ad34146dee7524cb13a068bb35f9", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "security": "https://github.com/sebastianbergmann/object-reflector/security/policy", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/4.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-07-03T05:01:32+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "6.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc", + "reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "security": "https://github.com/sebastianbergmann/recursion-context/security/policy", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/recursion-context", + "type": "tidelift" + } + ], + "time": "2025-08-13T04:42:22+00:00" + }, + { + "name": "sebastian/type", + "version": "5.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449", + "reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "security": "https://github.com/sebastianbergmann/type/security/policy", + "source": "https://github.com/sebastianbergmann/type/tree/5.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/type", + "type": "tidelift" + } + ], + "time": "2025-08-09T06:55:48+00:00" + }, + { + "name": "sebastian/version", + "version": "5.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c687e3387b99f5b03b6caa64c74b63e2936ff874" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874", + "reference": "c687e3387b99f5b03b6caa64c74b63e2936ff874", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "security": "https://github.com/sebastianbergmann/version/security/policy", + "source": "https://github.com/sebastianbergmann/version/tree/5.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-10-09T05:16:32+00:00" + }, + { + "name": "staabm/side-effects-detector", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/staabm/side-effects-detector.git", + "reference": "d8334211a140ce329c13726d4a715adbddd0a163" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163", + "reference": "d8334211a140ce329c13726d4a715adbddd0a163", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^1.12.6", + "phpunit/phpunit": "^9.6.21", + "symfony/var-dumper": "^5.4.43", + "tomasvotruba/type-coverage": "1.0.0", + "tomasvotruba/unused-public": "1.0.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A static analysis tool to detect side effects in PHP code", + "keywords": [ + "static analysis" + ], + "support": { + "issues": "https://github.com/staabm/side-effects-detector/issues", + "source": "https://github.com/staabm/side-effects-detector/tree/1.0.5" + }, + "funding": [ + { + "url": "https://github.com/staabm", + "type": "github" + } + ], + "time": "2024-10-20T05:08:20+00:00" + }, + { + "name": "symfony/console", + "version": "v7.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "732a9ca6cd9dfd940c639062d5edbde2f6727fb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/732a9ca6cd9dfd940c639062d5edbde2f6727fb6", + "reference": "732a9ca6cd9dfd940c639062d5edbde2f6727fb6", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/string": "^7.2|^8.0" + }, + "conflict": { + "symfony/dependency-injection": "<6.4", + "symfony/dotenv": "<6.4", + "symfony/event-dispatcher": "<6.4", + "symfony/lock": "<6.4", + "symfony/process": "<6.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0|^8.0", + "symfony/dependency-injection": "^6.4|^7.0|^8.0", + "symfony/event-dispatcher": "^6.4|^7.0|^8.0", + "symfony/http-foundation": "^6.4|^7.0|^8.0", + "symfony/http-kernel": "^6.4|^7.0|^8.0", + "symfony/lock": "^6.4|^7.0|^8.0", + "symfony/messenger": "^6.4|^7.0|^8.0", + "symfony/process": "^6.4|^7.0|^8.0", + "symfony/stopwatch": "^6.4|^7.0|^8.0", + "symfony/var-dumper": "^6.4|^7.0|^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command-line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v7.4.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-12-23T14:50:43+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-25T14:21:43+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v7.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "9dddcddff1ef974ad87b3708e4b442dc38b2261d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9dddcddff1ef974ad87b3708e4b442dc38b2261d", + "reference": "9dddcddff1ef974ad87b3708e4b442dc38b2261d", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/event-dispatcher-contracts": "^2.5|^3" + }, + "conflict": { + "symfony/dependency-injection": "<6.4", + "symfony/service-contracts": "<2.5" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0|^8.0", + "symfony/dependency-injection": "^6.4|^7.0|^8.0", + "symfony/error-handler": "^6.4|^7.0|^8.0", + "symfony/expression-language": "^6.4|^7.0|^8.0", + "symfony/framework-bundle": "^6.4|^7.0|^8.0", + "symfony/http-foundation": "^6.4|^7.0|^8.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/stopwatch": "^6.4|^7.0|^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v7.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-10-28T09:38:46+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v3.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "59eb412e93815df44f05f342958efa9f46b1e586" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586", + "reference": "59eb412e93815df44f05f342958efa9f46b1e586", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/event-dispatcher": "^1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-25T14:21:43+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v7.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "d551b38811096d0be9c4691d406991b47c0c630a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/d551b38811096d0be9c4691d406991b47c0c630a", + "reference": "d551b38811096d0be9c4691d406991b47c0c630a", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "require-dev": { + "symfony/process": "^6.4|^7.0|^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v7.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-11-27T13:27:24+00:00" + }, + { + "name": "symfony/finder", + "version": "v7.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "fffe05569336549b20a1be64250b40516d6e8d06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/fffe05569336549b20a1be64250b40516d6e8d06", + "reference": "fffe05569336549b20a1be64250b40516d6e8d06", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "symfony/filesystem": "^6.4|^7.0|^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v7.4.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-12-23T14:50:43+00:00" + }, + { + "name": "symfony/http-client", + "version": "v7.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-client.git", + "reference": "d01dfac1e0dc99f18da48b18101c23ce57929616" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-client/zipball/d01dfac1e0dc99f18da48b18101c23ce57929616", + "reference": "d01dfac1e0dc99f18da48b18101c23ce57929616", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/log": "^1|^2|^3", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/http-client-contracts": "~3.4.4|^3.5.2", + "symfony/polyfill-php83": "^1.29", + "symfony/service-contracts": "^2.5|^3" + }, + "conflict": { + "amphp/amp": "<2.5", + "amphp/socket": "<1.1", + "php-http/discovery": "<1.15", + "symfony/http-foundation": "<6.4" + }, + "provide": { + "php-http/async-client-implementation": "*", + "php-http/client-implementation": "*", + "psr/http-client-implementation": "1.0", + "symfony/http-client-implementation": "3.0" + }, + "require-dev": { + "amphp/http-client": "^4.2.1|^5.0", + "amphp/http-tunnel": "^1.0|^2.0", + "guzzlehttp/promises": "^1.4|^2.0", + "nyholm/psr7": "^1.0", + "php-http/httplug": "^1.0|^2.0", + "psr/http-client": "^1.0", + "symfony/amphp-http-client-meta": "^1.0|^2.0", + "symfony/cache": "^6.4|^7.0|^8.0", + "symfony/dependency-injection": "^6.4|^7.0|^8.0", + "symfony/http-kernel": "^6.4|^7.0|^8.0", + "symfony/messenger": "^6.4|^7.0|^8.0", + "symfony/process": "^6.4|^7.0|^8.0", + "symfony/rate-limiter": "^6.4|^7.0|^8.0", + "symfony/stopwatch": "^6.4|^7.0|^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpClient\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides powerful methods to fetch HTTP resources synchronously or asynchronously", + "homepage": "https://symfony.com", + "keywords": [ + "http" + ], + "support": { + "source": "https://github.com/symfony/http-client/tree/v7.4.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-12-23T14:50:43+00:00" + }, + { + "name": "symfony/http-client-contracts", + "version": "v3.6.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-client-contracts.git", + "reference": "75d7043853a42837e68111812f4d964b01e5101c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/75d7043853a42837e68111812f4d964b01e5101c", + "reference": "75d7043853a42837e68111812f4d964b01e5101c", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\HttpClient\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to HTTP clients", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/http-client-contracts/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-04-29T11:18:49+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v7.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "b38026df55197f9e39a44f3215788edf83187b80" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/b38026df55197f9e39a44f3215788edf83187b80", + "reference": "b38026df55197f9e39a44f3215788edf83187b80", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v7.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-11-12T15:39:26+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70", + "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-27T09:58:17+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "3833d7255cc303546435cb650316bff708a1c75c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", + "reference": "3833d7255cc303546435cb650316bff708a1c75c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", + "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-12-23T08:48:59+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-01-02T08:10:11+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php83", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php83.git", + "reference": "17f6f9a6b1735c0f163024d959f700cfbc5155e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/17f6f9a6b1735c0f163024d959f700cfbc5155e5", + "reference": "17f6f9a6b1735c0f163024d959f700cfbc5155e5", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php83\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php83/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-07-08T02:45:35+00:00" + }, + { + "name": "symfony/polyfill-php84", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php84.git", + "reference": "d8ced4d875142b6a7426000426b8abc631d6b191" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/d8ced4d875142b6a7426000426b8abc631d6b191", + "reference": "d8ced4d875142b6a7426000426b8abc631d6b191", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php84\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php84/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-24T13:30:11+00:00" + }, + { + "name": "symfony/process", + "version": "v7.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "2f8e1a6cdf590ca63715da4d3a7a3327404a523f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/2f8e1a6cdf590ca63715da4d3a7a3327404a523f", + "reference": "2f8e1a6cdf590ca63715da4d3a7a3327404a523f", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v7.4.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-12-19T10:00:43+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v3.6.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43", + "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.6-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v3.6.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-07-15T11:30:57+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v7.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "8a24af0a2e8a872fb745047180649b8418303084" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/8a24af0a2e8a872fb745047180649b8418303084", + "reference": "8a24af0a2e8a872fb745047180649b8418303084", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/service-contracts": "^2.5|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v7.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-08-04T07:05:15+00:00" + }, + { + "name": "symfony/string", + "version": "v7.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "d50e862cb0a0e0886f73ca1f31b865efbb795003" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/d50e862cb0a0e0886f73ca1f31b865efbb795003", + "reference": "d50e862cb0a0e0886f73ca1f31b865efbb795003", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3.0", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.33", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.5" + }, + "require-dev": { + "symfony/emoji": "^7.1|^8.0", + "symfony/http-client": "^6.4|^7.0|^8.0", + "symfony/intl": "^6.4|^7.0|^8.0", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^6.4|^7.0|^8.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v7.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-11-27T13:27:24+00:00" + }, + { + "name": "ta-tikoma/phpunit-architecture-test", + "version": "0.8.5", + "source": { + "type": "git", + "url": "https://github.com/ta-tikoma/phpunit-architecture-test.git", + "reference": "cf6fb197b676ba716837c886baca842e4db29005" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/cf6fb197b676ba716837c886baca842e4db29005", + "reference": "cf6fb197b676ba716837c886baca842e4db29005", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18.0 || ^5.0.0", + "php": "^8.1.0", + "phpdocumentor/reflection-docblock": "^5.3.0", + "phpunit/phpunit": "^10.5.5 || ^11.0.0 || ^12.0.0", + "symfony/finder": "^6.4.0 || ^7.0.0" + }, + "require-dev": { + "laravel/pint": "^1.13.7", + "phpstan/phpstan": "^1.10.52" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPUnit\\Architecture\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ni Shi", + "email": "futik0ma011@gmail.com" + }, + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Methods for testing application architecture", + "keywords": [ + "architecture", + "phpunit", + "stucture", + "test", + "testing" + ], + "support": { + "issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues", + "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.8.5" + }, + "time": "2025-04-20T20:23:40+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.3.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2025-11-17T20:03:58+00:00" + }, + { + "name": "webmozart/assert", + "version": "2.1.1", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "bdbabc199a7ba9965484e4725d66170e5711323b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/bdbabc199a7ba9965484e4725d66170e5711323b", + "reference": "bdbabc199a7ba9965484e4725d66170e5711323b", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-date": "*", + "ext-filter": "*", + "php": "^8.2" + }, + "suggest": { + "ext-intl": "", + "ext-simplexml": "", + "ext-spl": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-feature/2-0": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + }, + { + "name": "Woody Gilk", + "email": "woody.gilk@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/2.1.1" + }, + "time": "2026-01-08T11:28:40+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^8.1" + }, + "platform-dev": {}, + "platform-overrides": { + "php": "8.3" + }, + "plugin-api-version": "2.6.0" } diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 00000000..1cdf47d8 --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,14 @@ +parameters: + level: max + phpVersion: + min: 80100 + max: 80499 + paths: + - src + - tests + ignoreErrors: + - identifier: parameter.defaultValue + - identifier: trait.unused + - identifier: property.onlyWritten + + reportUnmatchedIgnoredErrors: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 00dd3c89..41860103 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,17 +1,18 @@ - + - - - src - - - - - tests - - + cacheDirectory=".phpunit.cache" + colors="true" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" +> + + + ./src + + + + + ./tests + + diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..83bea623 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "php", + "extra-files": [ + "README.md", + "src/Version.php" + ] +} \ No newline at end of file diff --git a/sample/README.md b/sample/README.md deleted file mode 100644 index 2b83ab87..00000000 --- a/sample/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Running the sample application - -### Step 1 -Open `sample.php` and fill the account details: -```php -$public_key = 'your_public_key'; -$your_private_key = 'your_private_key'; -$url_end_point = 'https://ik.imagekit.io/demo'; -``` - -### Step 2: -Run the `sample.php` file. -```bash -php sample.php -``` \ No newline at end of file diff --git a/sample/file_management/index.php b/sample/file_management/index.php deleted file mode 100644 index 2d8e3ada..00000000 --- a/sample/file_management/index.php +++ /dev/null @@ -1,319 +0,0 @@ -listFiles(); - -echo "\n\n"; -echo "1. List All Files: \n"; -echo "\033[01;32m".print_r($listFiles,true)."\033[0m"; -echo "\n"; - -$file_id = $listFiles->result[0]->fileId; -$version_id = $listFiles->result[0]->versionInfo->id; -$filePath = $listFiles->result[0]->filePath; -$sourceFilePath = $listFiles->result[0]->filePath; - -// List Filtered Files - -$listFilteredFiles = $imageKit->listFiles([ - "type" => "file", - "sort" => "ASC_CREATED", - "path" => "/sample-folder", - "fileType" => "all", - "limit" => 10, - "skip" => 0, - "tags" => ["tag3","tag4"], -]); - -echo "\n\n"; -echo "2. List Filtered Files: \n"; -echo "\033[01;32m".print_r($listFilteredFiles,true)."\033[0m"; -echo "\n"; - -// Advance Search Filtered Files - -$advanceSearchFilteredFiles = $imageKit->listFiles([ - "searchQuery" => '(size < "50kb" AND width > 500) OR (tags IN ["summer-sale","banner"])', -]); - -echo "\n\n"; -echo "3. Advance Search Filtered Files: \n"; -echo "\033[01;32m".print_r($advanceSearchFilteredFiles,true)."\033[0m"; -echo "\n"; - -// Get File Details -$getFileDetails = $imageKit->getFileDetails($file_id); - -echo "\n\n"; -echo "4. Get File Details: \n"; -echo "\033[01;32m".print_r($getFileDetails,true)."\033[0m"; -echo "\n"; - -// Get File Version Details -$getFileVersionDetails = $imageKit->getFileVersionDetails($file_id,$version_id); - -echo "\n\n"; -echo "5. Get File Version Details: \n"; -echo "\033[01;32m".print_r($getFileVersionDetails,true)."\033[0m"; -echo "\n"; - -// Get File Versions -$getFileVersions = $imageKit->getFileVersions($file_id); - - -echo "\n\n"; -echo "6. Get File Versions: \n"; -echo "\033[01;32m".print_r($getFileVersions,true)."\033[0m"; -echo "\n"; - -// Update File Details -$updateData = [ - "removeAITags" => "all", // "all" or ["tag1","tag2"] - "webhookUrl" => "https://example.com/webhook", - "tags" => ["tag3", "tag4"], -]; - -$updateFileDetails = $imageKit->updateFileDetails( - $file_id, - $updateData -); - -echo "\n\n"; -echo "7. Update File Details: \n"; -echo "\033[01;32m".print_r($updateFileDetails,true)."\033[0m"; -echo "\n"; - -// Add Tags (Bulk) -$fileIds = [$file_id]; -$tags = ['image_tag_1', 'image_tag_2']; - -$bulkAddTags = $imageKit->bulkAddTags($fileIds, $tags); - -echo "\n\n"; -echo "8. Add Tags (Bulk): \n"; -echo "\033[01;32m".print_r($bulkAddTags,true)."\033[0m"; -echo "\n"; - -// Remove Tags (Bulk) -$fileIds = [$file_id]; -$tags = ['image_tag_1', 'image_tag_2']; - -$bulkRemoveTags = $imageKit->bulkRemoveTags($fileIds, $tags); - -echo "\n\n"; -echo "9. Remove Tags (Bulk): \n"; -echo "\033[01;32m".print_r($bulkRemoveTags,true)."\033[0m"; -echo "\n"; - -// Remove AI Tags (Bulk) -$fileIds = [$file_id]; -$AITags = ['image_AITag_1', 'image_AITag_2']; - -$bulkRemoveAITags = $imageKit->bulkRemoveAITags($fileIds, $AITags); - -echo "\n\n"; -echo "10. Remove AI Tags (Bulk): \n"; -echo "\033[01;32m".print_r($bulkRemoveAITags,true)."\033[0m"; -echo "\n"; - -// Copy File - -$destinationPath = '/sample-folder2/'; -$copyFile = $imageKit->copy([ - 'sourceFilePath' => $sourceFilePath, - 'destinationPath' => $destinationPath, - 'includeFileVersions' => false -]); - -echo "\n\n"; -echo "11. Copy File: \n"; -echo "\033[01;32m".print_r($copyFile,true)."\033[0m"; -echo "\n"; - -// Move File - -$destinationPath = '/'; -$moveFile = $imageKit->move([ - 'sourceFilePath' => '/sample-folder2/default-image.jpg', - 'destinationPath' => $destinationPath -]); - -echo "\n\n"; -echo "12. Move File: \n"; -echo "\033[01;32m".print_r($moveFile,true)."\033[0m"; -echo "\n"; - -// Rename File with purge cache false - -$newFileName = 'sample-file2.jpg'; -$renameFile = $imageKit->rename([ - 'filePath' => $filePath, - 'newFileName' => $newFileName, - 'purgeCache' => false -]); - -echo "\n\n"; -echo "13. Rename File with Pruge Cache False: \n"; -echo "\033[01;32m".print_r($renameFile,true)."\033[0m"; -echo "\n"; - -// Rename File with Purge Cache true - -$newFileName = 'sample-file3.jpg'; -$renameFile = $imageKit->renameFile([ - 'filePath' => $filePath, - 'newFileName' => $newFileName, -], true); - -echo "\n\n"; -echo "14. Rename File with Pruge Cache True: \n"; -echo "\033[01;32m".print_r($renameFile,true)."\033[0m"; -echo "\n"; - -// Restore File Version - -$restoreFileVersion = $imageKit->restoreFileVersion([ - 'fileId' => $file_id, - 'versionId' => $version_id, -]); - -echo "\n\n"; -echo "15. Restore File Version: \n"; -echo "\033[01;32m".print_r($restoreFileVersion,true)."\033[0m"; -echo "\n"; - -// Create Folder - -$folderName = 'new-folder'; -$parentFolderPath = '/'; -$createFolder = $imageKit->createFolder([ - 'folderName' => $folderName, - 'parentFolderPath' => $parentFolderPath, -]); - -echo "\n\n"; -echo "16. Create Folder: \n"; -echo "\033[01;32m".print_r($createFolder,true)."\033[0m"; -echo "\n"; - -// Copy Folder - -$sourceFolderPath = $folderName; -$destinationPath = '/sample-folder'; -$includeFileVersions = false; -$copyFolder = $imageKit->copyFolder([ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - 'includeFileVersions' => $includeFileVersions -]); - -echo "\n\n"; -echo "17. Copy Folder: \n"; -echo "\033[01;32m".print_r($copyFolder,true)."\033[0m"; -echo "\n"; - -// Move Folder - -$sourceFolderPath = $folderName; -$destinationPath = '/sample-folder'; -$moveFolder = $imageKit->moveFolder([ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath -]); - -$job_id = $moveFolder->result->jobId; - -echo "\n\n"; -echo "18. Move Folder: \n"; -echo "\033[01;32m".print_r($moveFolder,true)."\033[0m"; -echo "\n"; - - -// Delete Folder -$folderPath = '/sample-folder/new-folder'; -$deleteFolder = $imageKit->deleteFolder($folderPath); - -echo "\n\n"; -echo "19. Delete Folder: \n"; -echo "\033[01;32m".print_r($deleteFolder,true)."\033[0m"; -echo "\n"; - -// Bulk Job Status - -$bulkJobStatus = $imageKit->getBulkJobStatus($job_id); - -echo "\n\n"; -echo "20. Bulk Job Status: \n"; -echo "\033[01;32m".print_r($bulkJobStatus,true)."\033[0m"; -echo "\n"; - -// Purge Cache - -$image_url = $url_end_point.'/sample-folder/default-image.jpg'; -$purgeCache = $imageKit->purgeCache($image_url); -$cacheRequestId = $purgeCache->result->requestId; -echo "\n\n"; -echo "21. Purge Cache: \n"; -echo "\033[01;32m".print_r($purgeCache,true)."\033[0m"; -echo "\n"; - -// Purge Cache Status - -$getPurgeCacheStatus = $imageKit->getPurgeCacheStatus($cacheRequestId); - -echo "\n\n"; -echo "22. Purge Cache Status: \n"; -echo "\033[01;32m".print_r($getPurgeCacheStatus,true)."\033[0m"; -echo "\n"; - -// Get File Metadata (From File ID) - -$getFileMetadata = $imageKit->getFileMetaData($file_id); - -echo "\n\n"; -echo "23. Get File Metadata (From File ID): \n"; -echo "\033[01;32m".print_r($getFileMetadata,true)."\033[0m"; -echo "\n"; - -// Get File Metadata (From Remote URL) - -$getFileMetadata = $imageKit->getFileMetadataFromRemoteURL($image_url); - -echo "\n\n"; -echo "24. Get File Metadata (From Remote URL): \n"; -echo "\033[01;32m".print_r($getFileMetadata,true)."\033[0m"; -echo "\n"; - -// Delete File Version - -$deleteFileVersion = $imageKit->deleteFileVersion($file_id, $version_id); - -echo "\n\n"; -echo "25. Delete File Version: \n"; -echo "\033[01;32m".print_r($deleteFileVersion,true)."\033[0m"; -echo "\n"; - -// Delete File - -$deleteFile = $imageKit->deleteFile($file_id); - -echo "\n\n"; -echo "26. Delete File: \n"; -echo "\033[01;32m".print_r($deleteFile,true)."\033[0m"; -echo "\n"; - -// Delete Files (Bulk) - -$fileIds = [$file_id]; -$deleteFiles = $imageKit->bulkDeleteFiles($fileIds); - -echo "\n\n"; -echo "27. Delete Files (Bulk): \n"; -echo "\033[01;32m".print_r($deleteFiles,true)."\033[0m"; -echo "\n"; diff --git a/sample/metadata/index.php b/sample/metadata/index.php deleted file mode 100644 index 4c2fbed3..00000000 --- a/sample/metadata/index.php +++ /dev/null @@ -1,62 +0,0 @@ - "net_price", // required - "label" => "Net Price", // required - "schema" => [ // required - "type" => 'Number', // required - "minValue" => 1000, - "maxValue" => 5000, - ], -]; - -$createCustomMetadataField = $imageKit->createCustomMetadataField($body); - -echo "\n\n"; -echo "1. Create Fields: \n"; -echo "\033[01;32m".print_r($createCustomMetadataField,true)."\033[0m"; -echo "\n"; - -// Get Fields - -$includeDeleted = false; -$getCustomMetadataFields = $imageKit->getCustomMetadataFields($includeDeleted); -$customMetadataFieldId = $getCustomMetadataFields->result[0]->id; - -echo "\n\n"; -echo "2. Get Fields: \n"; -echo "\033[01;32m".print_r($getCustomMetadataFields,true)."\033[0m"; -echo "\n"; - -// Update Field - -$body = [ - "label" => "Net Price2", - "schema" => [ - "type"=>'Number' - ], -]; - -$updateCustomMetadataField = $imageKit->updateCustomMetadataField($customMetadataFieldId, $body); - -echo "\n\n"; -echo "3. Update Field: \n"; -echo "\033[01;32m".print_r($updateCustomMetadataField,true)."\033[0m"; -echo "\n"; - -// Delete Field - -$deleteCustomMetadataField = $imageKit->deleteCustomMetadataField($customMetadataFieldId); - -echo "\n\n"; -echo "4. Delete Field: \n"; -echo "\033[01;32m".print_r($deleteCustomMetadataField,true)."\033[0m"; -echo "\n"; - diff --git a/sample/sample.php b/sample/sample.php deleted file mode 100644 index ac3cc383..00000000 --- a/sample/sample.php +++ /dev/null @@ -1,31 +0,0 @@ -uploadFile([ - 'file' => $encodedImageData, - 'fileName' => 'sample-base64-upload', - 'folder' => 'sample-folder', - 'tags' => implode(['abd', 'def']), - 'useUniqueFileName' => false, - 'customCoordinates' => implode(',', ['10', '10', '100', '100']), - 'transformation' => [ - 'pre' => 'l-text,i-Imagekit,fs-50,l-end', - 'post' => [ - [ - 'type' => 'transformation', - 'value' => 'h-100' - ] - ] - ], -]); - -echo "\n\n"; -echo "1. Upload Image (Base64) - Response: \n"; -echo "\033[01;32m".print_r($uploadFile, true)."\033[0m"; -echo "\n"; - -// Upload Image - Binary - -$uploadFile = $imageKit->uploadFile([ - 'file' => fopen(__DIR__ . '/sample_image.jpeg', 'r'), - 'fileName' => 'sample-binary-upload', - 'folder' => 'sample-folder', - 'tags' => implode(['abd', 'def']), - 'useUniqueFileName' => true, - 'customCoordinates' => implode(',', ['10', '10', '100', '100']), - 'transformation' => [ - 'pre' => 'l-text,i-Imagekit,fs-50,l-end', - 'post' => [ - [ - 'type' => 'transformation', - 'value' => 'h-100' - ] - ] - ], -]); - -echo "\n\n"; -echo "2. Upload Image (Binary) - Response: \n"; -echo "\033[01;32m".print_r($uploadFile, true)."\033[0m"; -echo "\n"; - - -// Upload Image - URL - -$uploadFile = $imageKit->uploadFile([ - 'file' => $sample_file_url, - 'fileName' => 'sample-url-upload', - 'folder' => 'sample-folder', - 'tags' => implode(['abd', 'def']), - 'useUniqueFileName' => true, - 'customCoordinates' => implode(',', ['10', '10', '100', '100']), - 'transformation' => [ - 'pre' => 'l-text,i-Imagekit,fs-50,l-end', - 'post' => [ - [ - 'type' => 'transformation', - 'value' => 'h-100' - ] - ] - ], -]); - -echo "\n\n"; -echo "3. Upload Image (URL) - Response: \n"; -echo "\033[01;32m".print_r($uploadFile, true)."\033[0m"; -echo "\n"; diff --git a/sample/upload_api/sample_image.jpeg b/sample/upload_api/sample_image.jpeg deleted file mode 100644 index 44283cdf..00000000 Binary files a/sample/upload_api/sample_image.jpeg and /dev/null differ diff --git a/sample/url_generation/chained_transformations.php b/sample/url_generation/chained_transformations.php deleted file mode 100644 index 6b3bd330..00000000 --- a/sample/url_generation/chained_transformations.php +++ /dev/null @@ -1,54 +0,0 @@ -url( - [ - 'path' => '/default-image.jpg', - - // It means first resize the image to 400x300 and then rotate 90 degrees - 'transformation' => [ - [ - 'width' => '400', - 'height' => '300', - ], - [ - 'rotation' => '90' - ] - ], - ] -); - -echo "\n\n"; -echo "1. Resized then rotated Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Rotate then Resize - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - - // It means first rotate the image to 90 degress and then resize it to 400x300 - 'transformation' => [ - [ - 'rotation' => '90' - ], - [ - 'width' => '400', - 'height' => '300', - ], - ], - ] -); - -echo "\n\n"; -echo "2. Retotated then resized Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - diff --git a/sample/url_generation/image_enhancement_and_color_manipulation.php b/sample/url_generation/image_enhancement_and_color_manipulation.php deleted file mode 100644 index dc83b116..00000000 --- a/sample/url_generation/image_enhancement_and_color_manipulation.php +++ /dev/null @@ -1,105 +0,0 @@ -url( - [ - 'src' => 'https://ik.imagekit.io/demo/sample_image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'effectContrast' => '', - ] - ], - ] -); - -echo "\n\n"; -echo "1. Contrast stretch Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Sharpen (e-sharpen) -// https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#sharpen-e-sharpen - -$imageURL = $imageKit->url( - [ - 'src' => 'https://ik.imagekit.io/demo/sample_image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'effectSharpen' => '10', - ] - ], - ] -); - -echo "\n\n"; -echo "2. Sharpen Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Unsharp mask (e-usm) -// https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#unsharp-mask-e-usm - -$imageURL = $imageKit->url( - [ - 'src' => 'https://ik.imagekit.io/demo/sample_image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'effectUSM' => '2-2-0.8-0.024', // radius=2, sigma=2, amount=0.8, threshold=0.024 - ] - ], - ] -); - -echo "\n\n"; -echo "3. Unsharp mask Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Shadow (e-shadow) -// https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#shadow-e-shadow - -$imageURL = $imageKit->url( - [ - 'src' => 'https://ik.imagekit.io/demo/sample_image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'effectShadow' => 'bl-15_st-40_x-10_y-N5' - ] - ], - ] -); - -echo "\n\n"; -echo "4. Shadow image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Gradient (e-gradient) -// https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#gradient-e-gradient - -$imageURL = $imageKit->url( - [ - 'src' => 'https://ik.imagekit.io/demo/sample_image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'effectGradient' => 'from-red_to-white', - ] - ], - ] -); - -echo "\n\n"; -echo "5. Gradient image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; \ No newline at end of file diff --git a/sample/url_generation/index.php b/sample/url_generation/index.php deleted file mode 100644 index bf586543..00000000 --- a/sample/url_generation/index.php +++ /dev/null @@ -1,11 +0,0 @@ -url( - [ - 'path' => '/default-image.jpg', - ] -); - -echo "\n\n"; -echo "1. URL for Image with relative path: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// URL for Image with relative path and custom URL Endpoint - -$imageURL = $imageKit->url( - [ - 'urlEndpoint' => $url_end_point . '/sample-folder', - 'path' => '/default-image.jpg', - ] -); - - -echo "\n\n"; -echo "2. URL for Image with relative path and Custom URL Endpoint: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// URL for Image with absolute url - -$imageURL = $imageKit->url( - [ - 'src' => 'https://ik.imagekit.io/test/default-image.jpg' - ] -); - -echo "\n\n"; -echo "3. URL for Image with Absolute URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Resizing Images - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - ], - ], - ] -); - -echo "\n\n"; -echo "4. Resized Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Pad resize crop strategy (cm-pad_resize) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#pad-resize-crop-strategy-cm-pad_resize - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'cropMode' => 'pad_resize', - 'background' => 'F3F3F3' - ], - ], - ] -); - -echo "\n\n"; -echo "5. Pad Resize Crop Strategy Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Pad resize crop strategy with Focus (fo) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#pad-resize-crop-strategy-cm-pad_resize -// More on 'fo' - https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#focus-fo - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'cropMode' => 'pad_resize', - 'background' => 'D3D3D3', - 'focus' => 'left', - ], - ], - ] -); - -echo "\n\n"; -echo "6. Pad Resize Crop Strategy with Focus-Left Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Forced crop strategy (c-force) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#forced-crop-strategy-c-force - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'crop' => 'force', - 'background' => 'F3F3F3', - ], - ], - ] -); - -echo "\n\n"; -echo "7. Forced Crop Strategy Strategy Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Max-size cropping strategy (c-at_max) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#max-size-cropping-strategy-c-at_max - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'crop' => 'at_max', - ], - ], - ] -); - -echo "\n\n"; -echo "8. Max-size cropping strategy Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Min-size cropping strategy (c-at_least) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#min-size-cropping-strategy-c-at_least - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'crop' => 'at_least', - ], - ], - ] -); - -echo "\n\n"; -echo "9. Min-size cropping strategy Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Maintain ratio crop strategy c-maintain_ratio (center-top) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#maintain-ratio-crop-strategy-c-maintain_ratio - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'crop' => 'maintain_ratio', - ], - ], - ] -); - -echo "\n\n"; -echo "10. Maintain ratio cropping strategy (center-top) Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Maintain ratio crop strategy with fo-custom -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#maintain-ratio-crop-strategy-c-maintain_ratio - -$imageURL = $imageKit->url( - [ - 'src' => 'https://ik.imagekit.io/demo/img/bike-image.jpeg', - 'transformation' => [ - [ - 'height' => '300', - 'width' => '400', - 'focus' => 'custom', - ], - ], - ] -); - -echo "\n\n"; -echo "11. Maintain ratio cropping strategy with fo-custom Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Extract crop strategy cm-extract (default center extract) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#extract-crop-strategy-cm-extract - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'width' => '200', - 'height' => '200', - 'cropMode' => 'extract', - ], - ], - ] -); - -echo "\n\n"; -echo "12. Extract crop strategy (default center extract) Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Extract crop strategy cm-extract (relative focus) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#extract-crop-strategy-cm-extract - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'width' => '200', - 'height' => '200', - 'cropMode' => 'extract', - 'focus' => 'bottom_right', - ], - ], - ] -); - -echo "\n\n"; -echo "13. Extract crop strategy (relative focus) Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Extract crop strategy cm-extract (focus with x,y coordinates) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#examples-focus-using-cropped-image-coordinates - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'width' => '200', - 'height' => '200', - 'cropMode' => 'extract', - 'x' => '100', - 'y' => '300', - ], - ], - ] -); - -echo "\n\n"; -echo "14. Extract crop strategy (Focus with X,Y Coordinates) Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Extract crop strategy cm-extract (focus using xc,yc center coordinates) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#examples-focus-using-cropped-image-coordinates - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'width' => '200', - 'height' => '200', - 'cropMode' => 'extract', - 'xc' => '100', - 'yc' => '300', - ], - ], - ] -); - -echo "\n\n"; -echo "15. Extract crop strategy (Focus using center Coordinates XC, YC) Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Extract crop strategy cm-extract (focus with custom coordinates) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#example-focus-using-custom-coordinates - -$imageURL = $imageKit->url( - [ - 'src' => 'https://ik.imagekit.io/demo/img/bike-image.jpeg', - 'transformation' => [ - [ - 'width' => '200', - 'height' => '200', - 'cropMode' => 'extract', - 'focus' => 'custom' - ], - ], - ] -); - -echo "\n\n"; -echo "16. Extract crop strategy (Focus using custom coordinates) Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Pad extract crop strategy (cm-pad_extract) -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#pad-extract-crop-strategy-cm-pad_extract - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'width' => '200', - 'height' => '200', - 'cropMode' => 'pad_extract', - 'background' => 'F3F3F3', - ], - ], - ] -); - -echo "\n\n"; -echo "17. Pad extract crop strategy Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Quality manipulation - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'quality' => '40', - ], - ], - ] -); - -echo "\n\n"; -echo "18. Quality Manipulated Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Blur Image - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'blur' => '40', // 1-100 - ], - ], - ] -); - -echo "\n\n"; -echo "19. Blur Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Grayscale Image (e-grayscale) - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'effectGray' => '', - ], - ], - ] -); - -echo "\n\n"; -echo "20. Grayscale Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Trim edges - -$imageURL = $imageKit->url( - [ - 'src' => 'https://ik.imagekit.io/demo/img/trim_example_BkgQVu7oX.png', - 'transformation' => [ - [ - 'trim' => 'true', // true|Number - ], - ], - ] -); - -echo "\n\n"; -echo "21. Trim edges Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - - -// Bordered Image -// https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations#border-b - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'border' => '10_FF0000', // width_hexcolor - ], - ], - ] -); - -echo "\n\n"; -echo "22. Bordered Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Rotate Image - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'rotate' => '180', // degrees - ], - ], - ] -); - -echo "\n\n"; -echo "23. Rotated Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Radius - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - // 'radius' => '100', - 'radius' => 'max', - ], - ], - ] -); - -echo "\n\n"; -echo "24. Radius Applied Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Background color - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'width' => '1200', - 'height' => '1200', - 'cropMode' => 'pad_extract', - 'background' => '272B38', - ], - ], - ] -); - -echo "\n\n"; -echo "25. Background color Applied Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; - -// Download Image - -$imageURL = $imageKit->url( - [ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'width' => '1200', - 'height' => '1200', - 'cropMode' => 'pad_extract', - 'background' => '272B38', - ], - ], - 'queryParameters' => [ - 'ik-attachment' => 'true' - ] - ] -); - -echo "\n\n"; -echo "26. Download Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; diff --git a/sample/url_generation/signed_url.php b/sample/url_generation/signed_url.php deleted file mode 100644 index 896ebf45..00000000 --- a/sample/url_generation/signed_url.php +++ /dev/null @@ -1,27 +0,0 @@ -url([ - "path" => "/default-image.jpg", - "queryParameters" => - [ - "v" => "123" - ], - "transformation" => [ - [ - "height" => "300", - "width" => "400" - ] - ], - "signed" => true, - "expireSeconds" => 300, // 300 seconds -]); - -echo "\n\n"; -echo "Singed Image URL: \n"; -echo "\033[01;32m$imageURL\033[0m"; -echo "\n"; diff --git a/sample/utility/index.php b/sample/utility/index.php deleted file mode 100644 index bbd8cea6..00000000 --- a/sample/utility/index.php +++ /dev/null @@ -1,26 +0,0 @@ -getAuthenticationParameters($token = "", $expire = 0); - -echo "\n\n"; -echo "1. Authentication parameter generation: \n"; -echo "\033[01;32m".print_r($authenticationParameters,true)."\033[0m"; -echo "\n"; - -// Distance calculation between two pHash values -$firstHash='f06830ca9f1e3e90'; -$secondHash='f06830ca9f1e3e90'; -$pHashDistance = $imageKit->pHashDistance($firstHash ,$secondHash); - -echo "\n\n"; -echo "2. Distance calculation between two pHash values: \n"; -echo "\033[01;32m".print_r($pHashDistance,true)."\033[0m"; -echo "\n"; - diff --git a/scripts/bootstrap b/scripts/bootstrap new file mode 100755 index 00000000..0010226e --- /dev/null +++ b/scripts/bootstrap @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +echo "==> Running composer install" +exec -- composer install --no-interaction diff --git a/scripts/clean b/scripts/clean new file mode 100755 index 00000000..5d9a765b --- /dev/null +++ b/scripts/clean @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +echo "==> Cleaning up..." +exec -- rm -fr -- ./vendor/ ./.php-cs-fixer.cache diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..8e633516 --- /dev/null +++ b/scripts/format @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +echo "==> Running php-cs-fixer" +exec -- ./vendor/bin/php-cs-fixer fix diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..211ce906 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +echo "==> Running PHPStan" +exec -- ./vendor/bin/phpstan analyse --memory-limit=12G diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..63df1370 --- /dev/null +++ b/scripts/test @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + + + +exec -- ./vendor/bin/pest --colors=always diff --git a/src/Accounts/Origins/OriginCreateParams.php b/src/Accounts/Origins/OriginCreateParams.php new file mode 100644 index 00000000..d36feb97 --- /dev/null +++ b/src/Accounts/Origins/OriginCreateParams.php @@ -0,0 +1,468 @@ + */ + use SdkModel; + use SdkParams; + + /** @var 'AKENEO_PIM' $type */ + #[Required] + public string $type = 'AKENEO_PIM'; + + /** + * Access key for the bucket. + */ + #[Required] + public string $accessKey; + + #[Required] + public string $bucket; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * Secret key for the bucket. + */ + #[Required] + public string $secretKey; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + #[Optional] + public ?string $prefix; + + /** + * Custom S3-compatible endpoint. + */ + #[Required] + public string $endpoint; + + /** + * Use path-style S3 URLs? + */ + #[Optional] + public ?bool $s3ForcePathStyle; + + /** + * Akeneo instance base URL. + */ + #[Required('baseUrl')] + public string $baseURL; + + /** + * Forward the Host header to origin? + */ + #[Optional] + public ?bool $forwardHostHeaderToOrigin; + + #[Required] + public string $clientEmail; + + #[Required] + public string $privateKey; + + #[Required] + public string $accountName; + + #[Required] + public string $container; + + #[Required] + public string $sasToken; + + /** + * Akeneo API client ID. + */ + #[Required('clientId')] + public string $clientID; + + /** + * Akeneo API client secret. + */ + #[Required] + public string $clientSecret; + + /** + * Akeneo API password. + */ + #[Required] + public string $password; + + /** + * Akeneo API username. + */ + #[Required] + public string $username; + + /** + * `new OriginCreateParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * OriginCreateParams::with( + * accessKey: ..., + * bucket: ..., + * name: ..., + * secretKey: ..., + * endpoint: ..., + * baseURL: ..., + * clientEmail: ..., + * privateKey: ..., + * accountName: ..., + * container: ..., + * sasToken: ..., + * clientID: ..., + * clientSecret: ..., + * password: ..., + * username: ..., + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new OriginCreateParams) + * ->withAccessKey(...) + * ->withBucket(...) + * ->withName(...) + * ->withSecretKey(...) + * ->withEndpoint(...) + * ->withBaseURL(...) + * ->withClientEmail(...) + * ->withPrivateKey(...) + * ->withAccountName(...) + * ->withContainer(...) + * ->withSasToken(...) + * ->withClientID(...) + * ->withClientSecret(...) + * ->withPassword(...) + * ->withUsername(...) + * ``` + */ + 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( + string $accessKey, + string $bucket, + string $name, + string $secretKey, + string $endpoint, + string $baseURL, + string $clientEmail, + string $privateKey, + string $accountName, + string $container, + string $sasToken, + string $clientID, + string $clientSecret, + string $password, + string $username, + ?string $baseURLForCanonicalHeader = null, + ?bool $includeCanonicalHeader = null, + ?string $prefix = null, + ?bool $s3ForcePathStyle = null, + ?bool $forwardHostHeaderToOrigin = null, + ): self { + $self = new self; + + $self['accessKey'] = $accessKey; + $self['bucket'] = $bucket; + $self['name'] = $name; + $self['secretKey'] = $secretKey; + $self['endpoint'] = $endpoint; + $self['baseURL'] = $baseURL; + $self['clientEmail'] = $clientEmail; + $self['privateKey'] = $privateKey; + $self['accountName'] = $accountName; + $self['container'] = $container; + $self['sasToken'] = $sasToken; + $self['clientID'] = $clientID; + $self['clientSecret'] = $clientSecret; + $self['password'] = $password; + $self['username'] = $username; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + null !== $prefix && $self['prefix'] = $prefix; + null !== $s3ForcePathStyle && $self['s3ForcePathStyle'] = $s3ForcePathStyle; + null !== $forwardHostHeaderToOrigin && $self['forwardHostHeaderToOrigin'] = $forwardHostHeaderToOrigin; + + return $self; + } + + /** + * @param 'AKENEO_PIM' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Access key for the bucket. + */ + public function withAccessKey(string $accessKey): self + { + $self = clone $this; + $self['accessKey'] = $accessKey; + + return $self; + } + + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Secret key for the bucket. + */ + public function withSecretKey(string $secretKey): self + { + $self = clone $this; + $self['secretKey'] = $secretKey; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } + + /** + * Custom S3-compatible endpoint. + */ + public function withEndpoint(string $endpoint): self + { + $self = clone $this; + $self['endpoint'] = $endpoint; + + return $self; + } + + /** + * Use path-style S3 URLs? + */ + public function withS3ForcePathStyle(bool $s3ForcePathStyle): self + { + $self = clone $this; + $self['s3ForcePathStyle'] = $s3ForcePathStyle; + + return $self; + } + + /** + * Akeneo instance base URL. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Forward the Host header to origin? + */ + public function withForwardHostHeaderToOrigin( + bool $forwardHostHeaderToOrigin + ): self { + $self = clone $this; + $self['forwardHostHeaderToOrigin'] = $forwardHostHeaderToOrigin; + + return $self; + } + + public function withClientEmail(string $clientEmail): self + { + $self = clone $this; + $self['clientEmail'] = $clientEmail; + + return $self; + } + + public function withPrivateKey(string $privateKey): self + { + $self = clone $this; + $self['privateKey'] = $privateKey; + + return $self; + } + + public function withAccountName(string $accountName): self + { + $self = clone $this; + $self['accountName'] = $accountName; + + return $self; + } + + public function withContainer(string $container): self + { + $self = clone $this; + $self['container'] = $container; + + return $self; + } + + public function withSasToken(string $sasToken): self + { + $self = clone $this; + $self['sasToken'] = $sasToken; + + return $self; + } + + /** + * Akeneo API client ID. + */ + public function withClientID(string $clientID): self + { + $self = clone $this; + $self['clientID'] = $clientID; + + return $self; + } + + /** + * Akeneo API client secret. + */ + public function withClientSecret(string $clientSecret): self + { + $self = clone $this; + $self['clientSecret'] = $clientSecret; + + return $self; + } + + /** + * Akeneo API password. + */ + public function withPassword(string $password): self + { + $self = clone $this; + $self['password'] = $password; + + return $self; + } + + /** + * Akeneo API username. + */ + public function withUsername(string $username): self + { + $self = clone $this; + $self['username'] = $username; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginRequest.php b/src/Accounts/Origins/OriginRequest.php new file mode 100644 index 00000000..08918583 --- /dev/null +++ b/src/Accounts/Origins/OriginRequest.php @@ -0,0 +1,59 @@ +|array + */ + public static function variants(): array + { + return [ + 'S3' => S3::class, + 'S3_COMPATIBLE' => S3Compatible::class, + 'CLOUDINARY_BACKUP' => CloudinaryBackup::class, + 'WEB_FOLDER' => WebFolder::class, + 'WEB_PROXY' => WebProxy::class, + 'GCS' => GoogleCloudStorageGcs::class, + 'AZURE_BLOB' => AzureBlobStorage::class, + 'AKENEO_PIM' => AkeneoPim::class, + ]; + } +} diff --git a/src/Accounts/Origins/OriginRequest/AkeneoPim.php b/src/Accounts/Origins/OriginRequest/AkeneoPim.php new file mode 100644 index 00000000..11da7ced --- /dev/null +++ b/src/Accounts/Origins/OriginRequest/AkeneoPim.php @@ -0,0 +1,244 @@ + */ + use SdkModel; + + /** @var 'AKENEO_PIM' $type */ + #[Required] + public string $type = 'AKENEO_PIM'; + + /** + * Akeneo instance base URL. + */ + #[Required('baseUrl')] + public string $baseURL; + + /** + * Akeneo API client ID. + */ + #[Required('clientId')] + public string $clientID; + + /** + * Akeneo API client secret. + */ + #[Required] + public string $clientSecret; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * Akeneo API password. + */ + #[Required] + public string $password; + + /** + * Akeneo API username. + */ + #[Required] + public string $username; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + /** + * `new AkeneoPim()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AkeneoPim::with( + * baseURL: ..., + * clientID: ..., + * clientSecret: ..., + * name: ..., + * password: ..., + * username: ..., + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AkeneoPim) + * ->withBaseURL(...) + * ->withClientID(...) + * ->withClientSecret(...) + * ->withName(...) + * ->withPassword(...) + * ->withUsername(...) + * ``` + */ + 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( + string $baseURL, + string $clientID, + string $clientSecret, + string $name, + string $password, + string $username, + ?string $baseURLForCanonicalHeader = null, + ?bool $includeCanonicalHeader = null, + ): self { + $self = new self; + + $self['baseURL'] = $baseURL; + $self['clientID'] = $clientID; + $self['clientSecret'] = $clientSecret; + $self['name'] = $name; + $self['password'] = $password; + $self['username'] = $username; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Akeneo instance base URL. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Akeneo API client ID. + */ + public function withClientID(string $clientID): self + { + $self = clone $this; + $self['clientID'] = $clientID; + + return $self; + } + + /** + * Akeneo API client secret. + */ + public function withClientSecret(string $clientSecret): self + { + $self = clone $this; + $self['clientSecret'] = $clientSecret; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Akeneo API password. + */ + public function withPassword(string $password): self + { + $self = clone $this; + $self['password'] = $password; + + return $self; + } + + /** + * @param 'AKENEO_PIM' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Akeneo API username. + */ + public function withUsername(string $username): self + { + $self = clone $this; + $self['username'] = $username; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginRequest/AzureBlobStorage.php b/src/Accounts/Origins/OriginRequest/AzureBlobStorage.php new file mode 100644 index 00000000..3b42220b --- /dev/null +++ b/src/Accounts/Origins/OriginRequest/AzureBlobStorage.php @@ -0,0 +1,193 @@ + */ + use SdkModel; + + /** @var 'AZURE_BLOB' $type */ + #[Required] + public string $type = 'AZURE_BLOB'; + + #[Required] + public string $accountName; + + #[Required] + public string $container; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + #[Required] + public string $sasToken; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + #[Optional] + public ?string $prefix; + + /** + * `new AzureBlobStorage()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureBlobStorage::with( + * accountName: ..., container: ..., name: ..., sasToken: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureBlobStorage) + * ->withAccountName(...) + * ->withContainer(...) + * ->withName(...) + * ->withSasToken(...) + * ``` + */ + 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( + string $accountName, + string $container, + string $name, + string $sasToken, + ?string $baseURLForCanonicalHeader = null, + ?bool $includeCanonicalHeader = null, + ?string $prefix = null, + ): self { + $self = new self; + + $self['accountName'] = $accountName; + $self['container'] = $container; + $self['name'] = $name; + $self['sasToken'] = $sasToken; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + null !== $prefix && $self['prefix'] = $prefix; + + return $self; + } + + public function withAccountName(string $accountName): self + { + $self = clone $this; + $self['accountName'] = $accountName; + + return $self; + } + + public function withContainer(string $container): self + { + $self = clone $this; + $self['container'] = $container; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + public function withSasToken(string $sasToken): self + { + $self = clone $this; + $self['sasToken'] = $sasToken; + + return $self; + } + + /** + * @param 'AZURE_BLOB' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginRequest/CloudinaryBackup.php b/src/Accounts/Origins/OriginRequest/CloudinaryBackup.php new file mode 100644 index 00000000..da0561fc --- /dev/null +++ b/src/Accounts/Origins/OriginRequest/CloudinaryBackup.php @@ -0,0 +1,215 @@ + */ + use SdkModel; + + /** @var 'CLOUDINARY_BACKUP' $type */ + #[Required] + public string $type = 'CLOUDINARY_BACKUP'; + + /** + * Access key for the bucket. + */ + #[Required] + public string $accessKey; + + /** + * S3 bucket name. + */ + #[Required] + public string $bucket; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * Secret key for the bucket. + */ + #[Required] + public string $secretKey; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + /** + * Path prefix inside the bucket. + */ + #[Optional] + public ?string $prefix; + + /** + * `new CloudinaryBackup()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * CloudinaryBackup::with(accessKey: ..., bucket: ..., name: ..., secretKey: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new CloudinaryBackup) + * ->withAccessKey(...) + * ->withBucket(...) + * ->withName(...) + * ->withSecretKey(...) + * ``` + */ + 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( + string $accessKey, + string $bucket, + string $name, + string $secretKey, + ?string $baseURLForCanonicalHeader = null, + ?bool $includeCanonicalHeader = null, + ?string $prefix = null, + ): self { + $self = new self; + + $self['accessKey'] = $accessKey; + $self['bucket'] = $bucket; + $self['name'] = $name; + $self['secretKey'] = $secretKey; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + null !== $prefix && $self['prefix'] = $prefix; + + return $self; + } + + /** + * Access key for the bucket. + */ + public function withAccessKey(string $accessKey): self + { + $self = clone $this; + $self['accessKey'] = $accessKey; + + return $self; + } + + /** + * S3 bucket name. + */ + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Secret key for the bucket. + */ + public function withSecretKey(string $secretKey): self + { + $self = clone $this; + $self['secretKey'] = $secretKey; + + return $self; + } + + /** + * @param 'CLOUDINARY_BACKUP' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Path prefix inside the bucket. + */ + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginRequest/GoogleCloudStorageGcs.php b/src/Accounts/Origins/OriginRequest/GoogleCloudStorageGcs.php new file mode 100644 index 00000000..e867b814 --- /dev/null +++ b/src/Accounts/Origins/OriginRequest/GoogleCloudStorageGcs.php @@ -0,0 +1,193 @@ + */ + use SdkModel; + + /** @var 'GCS' $type */ + #[Required] + public string $type = 'GCS'; + + #[Required] + public string $bucket; + + #[Required] + public string $clientEmail; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + #[Required] + public string $privateKey; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + #[Optional] + public ?string $prefix; + + /** + * `new GoogleCloudStorageGcs()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * GoogleCloudStorageGcs::with( + * bucket: ..., clientEmail: ..., name: ..., privateKey: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new GoogleCloudStorageGcs) + * ->withBucket(...) + * ->withClientEmail(...) + * ->withName(...) + * ->withPrivateKey(...) + * ``` + */ + 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( + string $bucket, + string $clientEmail, + string $name, + string $privateKey, + ?string $baseURLForCanonicalHeader = null, + ?bool $includeCanonicalHeader = null, + ?string $prefix = null, + ): self { + $self = new self; + + $self['bucket'] = $bucket; + $self['clientEmail'] = $clientEmail; + $self['name'] = $name; + $self['privateKey'] = $privateKey; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + null !== $prefix && $self['prefix'] = $prefix; + + return $self; + } + + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + public function withClientEmail(string $clientEmail): self + { + $self = clone $this; + $self['clientEmail'] = $clientEmail; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + public function withPrivateKey(string $privateKey): self + { + $self = clone $this; + $self['privateKey'] = $privateKey; + + return $self; + } + + /** + * @param 'GCS' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginRequest/S3.php b/src/Accounts/Origins/OriginRequest/S3.php new file mode 100644 index 00000000..cd4c3c79 --- /dev/null +++ b/src/Accounts/Origins/OriginRequest/S3.php @@ -0,0 +1,211 @@ + */ + use SdkModel; + + /** @var 'S3' $type */ + #[Required] + public string $type = 'S3'; + + /** + * Access key for the bucket. + */ + #[Required] + public string $accessKey; + + /** + * S3 bucket name. + */ + #[Required] + public string $bucket; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * Secret key for the bucket. + */ + #[Required] + public string $secretKey; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + /** + * Path prefix inside the bucket. + */ + #[Optional] + public ?string $prefix; + + /** + * `new S3()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * S3::with(accessKey: ..., bucket: ..., name: ..., secretKey: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new S3)->withAccessKey(...)->withBucket(...)->withName(...)->withSecretKey(...) + * ``` + */ + 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( + string $accessKey, + string $bucket, + string $name, + string $secretKey, + ?string $baseURLForCanonicalHeader = null, + ?bool $includeCanonicalHeader = null, + ?string $prefix = null, + ): self { + $self = new self; + + $self['accessKey'] = $accessKey; + $self['bucket'] = $bucket; + $self['name'] = $name; + $self['secretKey'] = $secretKey; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + null !== $prefix && $self['prefix'] = $prefix; + + return $self; + } + + /** + * Access key for the bucket. + */ + public function withAccessKey(string $accessKey): self + { + $self = clone $this; + $self['accessKey'] = $accessKey; + + return $self; + } + + /** + * S3 bucket name. + */ + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Secret key for the bucket. + */ + public function withSecretKey(string $secretKey): self + { + $self = clone $this; + $self['secretKey'] = $secretKey; + + return $self; + } + + /** + * @param 'S3' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Path prefix inside the bucket. + */ + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginRequest/S3Compatible.php b/src/Accounts/Origins/OriginRequest/S3Compatible.php new file mode 100644 index 00000000..fac8cf60 --- /dev/null +++ b/src/Accounts/Origins/OriginRequest/S3Compatible.php @@ -0,0 +1,258 @@ + */ + use SdkModel; + + /** @var 'S3_COMPATIBLE' $type */ + #[Required] + public string $type = 'S3_COMPATIBLE'; + + /** + * Access key for the bucket. + */ + #[Required] + public string $accessKey; + + /** + * S3 bucket name. + */ + #[Required] + public string $bucket; + + /** + * Custom S3-compatible endpoint. + */ + #[Required] + public string $endpoint; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * Secret key for the bucket. + */ + #[Required] + public string $secretKey; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + /** + * Path prefix inside the bucket. + */ + #[Optional] + public ?string $prefix; + + /** + * Use path-style S3 URLs? + */ + #[Optional] + public ?bool $s3ForcePathStyle; + + /** + * `new S3Compatible()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * S3Compatible::with( + * accessKey: ..., bucket: ..., endpoint: ..., name: ..., secretKey: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new S3Compatible) + * ->withAccessKey(...) + * ->withBucket(...) + * ->withEndpoint(...) + * ->withName(...) + * ->withSecretKey(...) + * ``` + */ + 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( + string $accessKey, + string $bucket, + string $endpoint, + string $name, + string $secretKey, + ?string $baseURLForCanonicalHeader = null, + ?bool $includeCanonicalHeader = null, + ?string $prefix = null, + ?bool $s3ForcePathStyle = null, + ): self { + $self = new self; + + $self['accessKey'] = $accessKey; + $self['bucket'] = $bucket; + $self['endpoint'] = $endpoint; + $self['name'] = $name; + $self['secretKey'] = $secretKey; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + null !== $prefix && $self['prefix'] = $prefix; + null !== $s3ForcePathStyle && $self['s3ForcePathStyle'] = $s3ForcePathStyle; + + return $self; + } + + /** + * Access key for the bucket. + */ + public function withAccessKey(string $accessKey): self + { + $self = clone $this; + $self['accessKey'] = $accessKey; + + return $self; + } + + /** + * S3 bucket name. + */ + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + /** + * Custom S3-compatible endpoint. + */ + public function withEndpoint(string $endpoint): self + { + $self = clone $this; + $self['endpoint'] = $endpoint; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Secret key for the bucket. + */ + public function withSecretKey(string $secretKey): self + { + $self = clone $this; + $self['secretKey'] = $secretKey; + + return $self; + } + + /** + * @param 'S3_COMPATIBLE' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Path prefix inside the bucket. + */ + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } + + /** + * Use path-style S3 URLs? + */ + public function withS3ForcePathStyle(bool $s3ForcePathStyle): self + { + $self = clone $this; + $self['s3ForcePathStyle'] = $s3ForcePathStyle; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginRequest/WebFolder.php b/src/Accounts/Origins/OriginRequest/WebFolder.php new file mode 100644 index 00000000..885195b6 --- /dev/null +++ b/src/Accounts/Origins/OriginRequest/WebFolder.php @@ -0,0 +1,172 @@ + */ + use SdkModel; + + /** @var 'WEB_FOLDER' $type */ + #[Required] + public string $type = 'WEB_FOLDER'; + + /** + * Root URL for the web folder origin. + */ + #[Required('baseUrl')] + public string $baseURL; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Forward the Host header to origin? + */ + #[Optional] + public ?bool $forwardHostHeaderToOrigin; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + /** + * `new WebFolder()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * WebFolder::with(baseURL: ..., name: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new WebFolder)->withBaseURL(...)->withName(...) + * ``` + */ + 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( + string $baseURL, + string $name, + ?string $baseURLForCanonicalHeader = null, + ?bool $forwardHostHeaderToOrigin = null, + ?bool $includeCanonicalHeader = null, + ): self { + $self = new self; + + $self['baseURL'] = $baseURL; + $self['name'] = $name; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $forwardHostHeaderToOrigin && $self['forwardHostHeaderToOrigin'] = $forwardHostHeaderToOrigin; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Root URL for the web folder origin. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * @param 'WEB_FOLDER' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Forward the Host header to origin? + */ + public function withForwardHostHeaderToOrigin( + bool $forwardHostHeaderToOrigin + ): self { + $self = clone $this; + $self['forwardHostHeaderToOrigin'] = $forwardHostHeaderToOrigin; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginRequest/WebProxy.php b/src/Accounts/Origins/OriginRequest/WebProxy.php new file mode 100644 index 00000000..b4ab0fc1 --- /dev/null +++ b/src/Accounts/Origins/OriginRequest/WebProxy.php @@ -0,0 +1,131 @@ + */ + use SdkModel; + + /** @var 'WEB_PROXY' $type */ + #[Required] + public string $type = 'WEB_PROXY'; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + /** + * `new WebProxy()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * WebProxy::with(name: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new WebProxy)->withName(...) + * ``` + */ + 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( + string $name, + ?string $baseURLForCanonicalHeader = null, + ?bool $includeCanonicalHeader = null, + ): self { + $self = new self; + + $self['name'] = $name; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * @param 'WEB_PROXY' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginResponse.php b/src/Accounts/Origins/OriginResponse.php new file mode 100644 index 00000000..2a4d4c8e --- /dev/null +++ b/src/Accounts/Origins/OriginResponse.php @@ -0,0 +1,59 @@ +|array + */ + public static function variants(): array + { + return [ + 'S3' => S3::class, + 'S3_COMPATIBLE' => S3Compatible::class, + 'CLOUDINARY_BACKUP' => CloudinaryBackup::class, + 'WEB_FOLDER' => WebFolder::class, + 'WEB_PROXY' => WebProxy::class, + 'GCS' => GoogleCloudStorageGcs::class, + 'AZURE_BLOB' => AzureBlobStorage::class, + 'AKENEO_PIM' => AkeneoPim::class, + ]; + } +} diff --git a/src/Accounts/Origins/OriginResponse/AkeneoPim.php b/src/Accounts/Origins/OriginResponse/AkeneoPim.php new file mode 100644 index 00000000..84b2accf --- /dev/null +++ b/src/Accounts/Origins/OriginResponse/AkeneoPim.php @@ -0,0 +1,175 @@ + */ + use SdkModel; + + /** @var 'AKENEO_PIM' $type */ + #[Required] + public string $type = 'AKENEO_PIM'; + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + #[Required] + public string $id; + + /** + * Akeneo instance base URL. + */ + #[Required('baseUrl')] + public string $baseURL; + + /** + * Whether to send a Canonical header. + */ + #[Required] + public bool $includeCanonicalHeader; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * `new AkeneoPim()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AkeneoPim::with(id: ..., baseURL: ..., includeCanonicalHeader: ..., name: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AkeneoPim) + * ->withID(...) + * ->withBaseURL(...) + * ->withIncludeCanonicalHeader(...) + * ->withName(...) + * ``` + */ + 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( + string $id, + string $baseURL, + string $name, + bool $includeCanonicalHeader = false, + ?string $baseURLForCanonicalHeader = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['baseURL'] = $baseURL; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + $self['name'] = $name; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Akeneo instance base URL. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * @param 'AKENEO_PIM' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginResponse/AzureBlobStorage.php b/src/Accounts/Origins/OriginResponse/AzureBlobStorage.php new file mode 100644 index 00000000..45df2f63 --- /dev/null +++ b/src/Accounts/Origins/OriginResponse/AzureBlobStorage.php @@ -0,0 +1,206 @@ + */ + use SdkModel; + + /** @var 'AZURE_BLOB' $type */ + #[Required] + public string $type = 'AZURE_BLOB'; + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + #[Required] + public string $id; + + #[Required] + public string $accountName; + + #[Required] + public string $container; + + /** + * Whether to send a Canonical header. + */ + #[Required] + public bool $includeCanonicalHeader; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + #[Required] + public string $prefix; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * `new AzureBlobStorage()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AzureBlobStorage::with( + * id: ..., + * accountName: ..., + * container: ..., + * includeCanonicalHeader: ..., + * name: ..., + * prefix: ..., + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AzureBlobStorage) + * ->withID(...) + * ->withAccountName(...) + * ->withContainer(...) + * ->withIncludeCanonicalHeader(...) + * ->withName(...) + * ->withPrefix(...) + * ``` + */ + 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( + string $id, + string $accountName, + string $container, + string $name, + string $prefix, + bool $includeCanonicalHeader = false, + ?string $baseURLForCanonicalHeader = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['accountName'] = $accountName; + $self['container'] = $container; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + $self['name'] = $name; + $self['prefix'] = $prefix; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + public function withAccountName(string $accountName): self + { + $self = clone $this; + $self['accountName'] = $accountName; + + return $self; + } + + public function withContainer(string $container): self + { + $self = clone $this; + $self['container'] = $container; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } + + /** + * @param 'AZURE_BLOB' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginResponse/CloudinaryBackup.php b/src/Accounts/Origins/OriginResponse/CloudinaryBackup.php new file mode 100644 index 00000000..fba1c65d --- /dev/null +++ b/src/Accounts/Origins/OriginResponse/CloudinaryBackup.php @@ -0,0 +1,198 @@ + */ + use SdkModel; + + /** @var 'CLOUDINARY_BACKUP' $type */ + #[Required] + public string $type = 'CLOUDINARY_BACKUP'; + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + #[Required] + public string $id; + + /** + * S3 bucket name. + */ + #[Required] + public string $bucket; + + /** + * Whether to send a Canonical header. + */ + #[Required] + public bool $includeCanonicalHeader; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * Path prefix inside the bucket. + */ + #[Required] + public string $prefix; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * `new CloudinaryBackup()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * CloudinaryBackup::with( + * id: ..., bucket: ..., includeCanonicalHeader: ..., name: ..., prefix: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new CloudinaryBackup) + * ->withID(...) + * ->withBucket(...) + * ->withIncludeCanonicalHeader(...) + * ->withName(...) + * ->withPrefix(...) + * ``` + */ + 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( + string $id, + string $bucket, + string $name, + string $prefix, + bool $includeCanonicalHeader = false, + ?string $baseURLForCanonicalHeader = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['bucket'] = $bucket; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + $self['name'] = $name; + $self['prefix'] = $prefix; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * S3 bucket name. + */ + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Path prefix inside the bucket. + */ + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } + + /** + * @param 'CLOUDINARY_BACKUP' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginResponse/GoogleCloudStorageGcs.php b/src/Accounts/Origins/OriginResponse/GoogleCloudStorageGcs.php new file mode 100644 index 00000000..cb998b0b --- /dev/null +++ b/src/Accounts/Origins/OriginResponse/GoogleCloudStorageGcs.php @@ -0,0 +1,206 @@ + */ + use SdkModel; + + /** @var 'GCS' $type */ + #[Required] + public string $type = 'GCS'; + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + #[Required] + public string $id; + + #[Required] + public string $bucket; + + #[Required] + public string $clientEmail; + + /** + * Whether to send a Canonical header. + */ + #[Required] + public bool $includeCanonicalHeader; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + #[Required] + public string $prefix; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * `new GoogleCloudStorageGcs()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * GoogleCloudStorageGcs::with( + * id: ..., + * bucket: ..., + * clientEmail: ..., + * includeCanonicalHeader: ..., + * name: ..., + * prefix: ..., + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new GoogleCloudStorageGcs) + * ->withID(...) + * ->withBucket(...) + * ->withClientEmail(...) + * ->withIncludeCanonicalHeader(...) + * ->withName(...) + * ->withPrefix(...) + * ``` + */ + 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( + string $id, + string $bucket, + string $clientEmail, + string $name, + string $prefix, + bool $includeCanonicalHeader = false, + ?string $baseURLForCanonicalHeader = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['bucket'] = $bucket; + $self['clientEmail'] = $clientEmail; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + $self['name'] = $name; + $self['prefix'] = $prefix; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + public function withClientEmail(string $clientEmail): self + { + $self = clone $this; + $self['clientEmail'] = $clientEmail; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } + + /** + * @param 'GCS' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginResponse/S3.php b/src/Accounts/Origins/OriginResponse/S3.php new file mode 100644 index 00000000..b62e9ef4 --- /dev/null +++ b/src/Accounts/Origins/OriginResponse/S3.php @@ -0,0 +1,198 @@ + */ + use SdkModel; + + /** @var 'S3' $type */ + #[Required] + public string $type = 'S3'; + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + #[Required] + public string $id; + + /** + * S3 bucket name. + */ + #[Required] + public string $bucket; + + /** + * Whether to send a Canonical header. + */ + #[Required] + public bool $includeCanonicalHeader; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * Path prefix inside the bucket. + */ + #[Required] + public string $prefix; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * `new S3()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * S3::with( + * id: ..., bucket: ..., includeCanonicalHeader: ..., name: ..., prefix: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new S3) + * ->withID(...) + * ->withBucket(...) + * ->withIncludeCanonicalHeader(...) + * ->withName(...) + * ->withPrefix(...) + * ``` + */ + 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( + string $id, + string $bucket, + string $name, + string $prefix, + bool $includeCanonicalHeader = false, + ?string $baseURLForCanonicalHeader = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['bucket'] = $bucket; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + $self['name'] = $name; + $self['prefix'] = $prefix; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * S3 bucket name. + */ + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Path prefix inside the bucket. + */ + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } + + /** + * @param 'S3' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginResponse/S3Compatible.php b/src/Accounts/Origins/OriginResponse/S3Compatible.php new file mode 100644 index 00000000..78078b4a --- /dev/null +++ b/src/Accounts/Origins/OriginResponse/S3Compatible.php @@ -0,0 +1,246 @@ + */ + use SdkModel; + + /** @var 'S3_COMPATIBLE' $type */ + #[Required] + public string $type = 'S3_COMPATIBLE'; + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + #[Required] + public string $id; + + /** + * S3 bucket name. + */ + #[Required] + public string $bucket; + + /** + * Custom S3-compatible endpoint. + */ + #[Required] + public string $endpoint; + + /** + * Whether to send a Canonical header. + */ + #[Required] + public bool $includeCanonicalHeader; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * Path prefix inside the bucket. + */ + #[Required] + public string $prefix; + + /** + * Use path-style S3 URLs? + */ + #[Required] + public bool $s3ForcePathStyle; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * `new S3Compatible()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * S3Compatible::with( + * id: ..., + * bucket: ..., + * endpoint: ..., + * includeCanonicalHeader: ..., + * name: ..., + * prefix: ..., + * s3ForcePathStyle: ..., + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new S3Compatible) + * ->withID(...) + * ->withBucket(...) + * ->withEndpoint(...) + * ->withIncludeCanonicalHeader(...) + * ->withName(...) + * ->withPrefix(...) + * ->withS3ForcePathStyle(...) + * ``` + */ + 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( + string $id, + string $bucket, + string $endpoint, + string $name, + string $prefix, + bool $includeCanonicalHeader = false, + bool $s3ForcePathStyle = false, + ?string $baseURLForCanonicalHeader = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['bucket'] = $bucket; + $self['endpoint'] = $endpoint; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + $self['name'] = $name; + $self['prefix'] = $prefix; + $self['s3ForcePathStyle'] = $s3ForcePathStyle; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * S3 bucket name. + */ + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + /** + * Custom S3-compatible endpoint. + */ + public function withEndpoint(string $endpoint): self + { + $self = clone $this; + $self['endpoint'] = $endpoint; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Path prefix inside the bucket. + */ + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } + + /** + * Use path-style S3 URLs? + */ + public function withS3ForcePathStyle(bool $s3ForcePathStyle): self + { + $self = clone $this; + $self['s3ForcePathStyle'] = $s3ForcePathStyle; + + return $self; + } + + /** + * @param 'S3_COMPATIBLE' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginResponse/WebFolder.php b/src/Accounts/Origins/OriginResponse/WebFolder.php new file mode 100644 index 00000000..85234356 --- /dev/null +++ b/src/Accounts/Origins/OriginResponse/WebFolder.php @@ -0,0 +1,203 @@ + */ + use SdkModel; + + /** @var 'WEB_FOLDER' $type */ + #[Required] + public string $type = 'WEB_FOLDER'; + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + #[Required] + public string $id; + + /** + * Root URL for the web folder origin. + */ + #[Required('baseUrl')] + public string $baseURL; + + /** + * Forward the Host header to origin? + */ + #[Required] + public bool $forwardHostHeaderToOrigin; + + /** + * Whether to send a Canonical header. + */ + #[Required] + public bool $includeCanonicalHeader; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * `new WebFolder()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * WebFolder::with( + * id: ..., + * baseURL: ..., + * forwardHostHeaderToOrigin: ..., + * includeCanonicalHeader: ..., + * name: ..., + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new WebFolder) + * ->withID(...) + * ->withBaseURL(...) + * ->withForwardHostHeaderToOrigin(...) + * ->withIncludeCanonicalHeader(...) + * ->withName(...) + * ``` + */ + 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( + string $id, + string $baseURL, + string $name, + bool $forwardHostHeaderToOrigin = false, + bool $includeCanonicalHeader = false, + ?string $baseURLForCanonicalHeader = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['baseURL'] = $baseURL; + $self['forwardHostHeaderToOrigin'] = $forwardHostHeaderToOrigin; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + $self['name'] = $name; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Root URL for the web folder origin. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Forward the Host header to origin? + */ + public function withForwardHostHeaderToOrigin( + bool $forwardHostHeaderToOrigin + ): self { + $self = clone $this; + $self['forwardHostHeaderToOrigin'] = $forwardHostHeaderToOrigin; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * @param 'WEB_FOLDER' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginResponse/WebProxy.php b/src/Accounts/Origins/OriginResponse/WebProxy.php new file mode 100644 index 00000000..a460f0fc --- /dev/null +++ b/src/Accounts/Origins/OriginResponse/WebProxy.php @@ -0,0 +1,151 @@ + */ + use SdkModel; + + /** @var 'WEB_PROXY' $type */ + #[Required] + public string $type = 'WEB_PROXY'; + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + #[Required] + public string $id; + + /** + * Whether to send a Canonical header. + */ + #[Required] + public bool $includeCanonicalHeader; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * `new WebProxy()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * WebProxy::with(id: ..., includeCanonicalHeader: ..., name: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new WebProxy)->withID(...)->withIncludeCanonicalHeader(...)->withName(...) + * ``` + */ + 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( + string $id, + string $name, + bool $includeCanonicalHeader = false, + ?string $baseURLForCanonicalHeader = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + $self['name'] = $name; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * @param 'WEB_PROXY' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } +} diff --git a/src/Accounts/Origins/OriginUpdateParams.php b/src/Accounts/Origins/OriginUpdateParams.php new file mode 100644 index 00000000..1abf1736 --- /dev/null +++ b/src/Accounts/Origins/OriginUpdateParams.php @@ -0,0 +1,468 @@ + */ + use SdkModel; + use SdkParams; + + /** @var 'AKENEO_PIM' $type */ + #[Required] + public string $type = 'AKENEO_PIM'; + + /** + * Access key for the bucket. + */ + #[Required] + public string $accessKey; + + #[Required] + public string $bucket; + + /** + * Display name of the origin. + */ + #[Required] + public string $name; + + /** + * Secret key for the bucket. + */ + #[Required] + public string $secretKey; + + /** + * URL used in the Canonical header (if enabled). + */ + #[Optional('baseUrlForCanonicalHeader')] + public ?string $baseURLForCanonicalHeader; + + /** + * Whether to send a Canonical header. + */ + #[Optional] + public ?bool $includeCanonicalHeader; + + #[Optional] + public ?string $prefix; + + /** + * Custom S3-compatible endpoint. + */ + #[Required] + public string $endpoint; + + /** + * Use path-style S3 URLs? + */ + #[Optional] + public ?bool $s3ForcePathStyle; + + /** + * Akeneo instance base URL. + */ + #[Required('baseUrl')] + public string $baseURL; + + /** + * Forward the Host header to origin? + */ + #[Optional] + public ?bool $forwardHostHeaderToOrigin; + + #[Required] + public string $clientEmail; + + #[Required] + public string $privateKey; + + #[Required] + public string $accountName; + + #[Required] + public string $container; + + #[Required] + public string $sasToken; + + /** + * Akeneo API client ID. + */ + #[Required('clientId')] + public string $clientID; + + /** + * Akeneo API client secret. + */ + #[Required] + public string $clientSecret; + + /** + * Akeneo API password. + */ + #[Required] + public string $password; + + /** + * Akeneo API username. + */ + #[Required] + public string $username; + + /** + * `new OriginUpdateParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * OriginUpdateParams::with( + * accessKey: ..., + * bucket: ..., + * name: ..., + * secretKey: ..., + * endpoint: ..., + * baseURL: ..., + * clientEmail: ..., + * privateKey: ..., + * accountName: ..., + * container: ..., + * sasToken: ..., + * clientID: ..., + * clientSecret: ..., + * password: ..., + * username: ..., + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new OriginUpdateParams) + * ->withAccessKey(...) + * ->withBucket(...) + * ->withName(...) + * ->withSecretKey(...) + * ->withEndpoint(...) + * ->withBaseURL(...) + * ->withClientEmail(...) + * ->withPrivateKey(...) + * ->withAccountName(...) + * ->withContainer(...) + * ->withSasToken(...) + * ->withClientID(...) + * ->withClientSecret(...) + * ->withPassword(...) + * ->withUsername(...) + * ``` + */ + 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( + string $accessKey, + string $bucket, + string $name, + string $secretKey, + string $endpoint, + string $baseURL, + string $clientEmail, + string $privateKey, + string $accountName, + string $container, + string $sasToken, + string $clientID, + string $clientSecret, + string $password, + string $username, + ?string $baseURLForCanonicalHeader = null, + ?bool $includeCanonicalHeader = null, + ?string $prefix = null, + ?bool $s3ForcePathStyle = null, + ?bool $forwardHostHeaderToOrigin = null, + ): self { + $self = new self; + + $self['accessKey'] = $accessKey; + $self['bucket'] = $bucket; + $self['name'] = $name; + $self['secretKey'] = $secretKey; + $self['endpoint'] = $endpoint; + $self['baseURL'] = $baseURL; + $self['clientEmail'] = $clientEmail; + $self['privateKey'] = $privateKey; + $self['accountName'] = $accountName; + $self['container'] = $container; + $self['sasToken'] = $sasToken; + $self['clientID'] = $clientID; + $self['clientSecret'] = $clientSecret; + $self['password'] = $password; + $self['username'] = $username; + + null !== $baseURLForCanonicalHeader && $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + null !== $includeCanonicalHeader && $self['includeCanonicalHeader'] = $includeCanonicalHeader; + null !== $prefix && $self['prefix'] = $prefix; + null !== $s3ForcePathStyle && $self['s3ForcePathStyle'] = $s3ForcePathStyle; + null !== $forwardHostHeaderToOrigin && $self['forwardHostHeaderToOrigin'] = $forwardHostHeaderToOrigin; + + return $self; + } + + /** + * @param 'AKENEO_PIM' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Access key for the bucket. + */ + public function withAccessKey(string $accessKey): self + { + $self = clone $this; + $self['accessKey'] = $accessKey; + + return $self; + } + + public function withBucket(string $bucket): self + { + $self = clone $this; + $self['bucket'] = $bucket; + + return $self; + } + + /** + * Display name of the origin. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Secret key for the bucket. + */ + public function withSecretKey(string $secretKey): self + { + $self = clone $this; + $self['secretKey'] = $secretKey; + + return $self; + } + + /** + * URL used in the Canonical header (if enabled). + */ + public function withBaseURLForCanonicalHeader( + string $baseURLForCanonicalHeader + ): self { + $self = clone $this; + $self['baseURLForCanonicalHeader'] = $baseURLForCanonicalHeader; + + return $self; + } + + /** + * Whether to send a Canonical header. + */ + public function withIncludeCanonicalHeader( + bool $includeCanonicalHeader + ): self { + $self = clone $this; + $self['includeCanonicalHeader'] = $includeCanonicalHeader; + + return $self; + } + + public function withPrefix(string $prefix): self + { + $self = clone $this; + $self['prefix'] = $prefix; + + return $self; + } + + /** + * Custom S3-compatible endpoint. + */ + public function withEndpoint(string $endpoint): self + { + $self = clone $this; + $self['endpoint'] = $endpoint; + + return $self; + } + + /** + * Use path-style S3 URLs? + */ + public function withS3ForcePathStyle(bool $s3ForcePathStyle): self + { + $self = clone $this; + $self['s3ForcePathStyle'] = $s3ForcePathStyle; + + return $self; + } + + /** + * Akeneo instance base URL. + */ + public function withBaseURL(string $baseURL): self + { + $self = clone $this; + $self['baseURL'] = $baseURL; + + return $self; + } + + /** + * Forward the Host header to origin? + */ + public function withForwardHostHeaderToOrigin( + bool $forwardHostHeaderToOrigin + ): self { + $self = clone $this; + $self['forwardHostHeaderToOrigin'] = $forwardHostHeaderToOrigin; + + return $self; + } + + public function withClientEmail(string $clientEmail): self + { + $self = clone $this; + $self['clientEmail'] = $clientEmail; + + return $self; + } + + public function withPrivateKey(string $privateKey): self + { + $self = clone $this; + $self['privateKey'] = $privateKey; + + return $self; + } + + public function withAccountName(string $accountName): self + { + $self = clone $this; + $self['accountName'] = $accountName; + + return $self; + } + + public function withContainer(string $container): self + { + $self = clone $this; + $self['container'] = $container; + + return $self; + } + + public function withSasToken(string $sasToken): self + { + $self = clone $this; + $self['sasToken'] = $sasToken; + + return $self; + } + + /** + * Akeneo API client ID. + */ + public function withClientID(string $clientID): self + { + $self = clone $this; + $self['clientID'] = $clientID; + + return $self; + } + + /** + * Akeneo API client secret. + */ + public function withClientSecret(string $clientSecret): self + { + $self = clone $this; + $self['clientSecret'] = $clientSecret; + + return $self; + } + + /** + * Akeneo API password. + */ + public function withPassword(string $password): self + { + $self = clone $this; + $self['password'] = $password; + + return $self; + } + + /** + * Akeneo API username. + */ + public function withUsername(string $username): self + { + $self = clone $this; + $self['username'] = $username; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointCreateParams.php b/src/Accounts/URLEndpoints/URLEndpointCreateParams.php new file mode 100644 index 00000000..5d5fbb74 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointCreateParams.php @@ -0,0 +1,159 @@ +|null, + * urlPrefix?: string|null, + * urlRewriter?: URLRewriterShape|null, + * } + */ +final class URLEndpointCreateParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * Description of the URL endpoint. + */ + #[Required] + public string $description; + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * + * @var list|null $origins + */ + #[Optional(list: 'string')] + public ?array $origins; + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint). + */ + #[Optional] + public ?string $urlPrefix; + + /** + * Configuration for third-party URL rewriting. + * + * @var URLRewriterVariants|null $urlRewriter + */ + #[Optional(union: URLRewriter::class)] + public CloudinaryURLRewriter|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter; + + /** + * `new URLEndpointCreateParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * URLEndpointCreateParams::with(description: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new URLEndpointCreateParams)->withDescription(...) + * ``` + */ + 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 list|null $origins + * @param URLRewriterShape|null $urlRewriter + */ + public static function with( + string $description, + ?array $origins = null, + ?string $urlPrefix = null, + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter = null, + ): self { + $self = new self; + + $self['description'] = $description; + + null !== $origins && $self['origins'] = $origins; + null !== $urlPrefix && $self['urlPrefix'] = $urlPrefix; + null !== $urlRewriter && $self['urlRewriter'] = $urlRewriter; + + return $self; + } + + /** + * Description of the URL endpoint. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * + * @param list $origins + */ + public function withOrigins(array $origins): self + { + $self = clone $this; + $self['origins'] = $origins; + + return $self; + } + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint). + */ + public function withURLPrefix(string $urlPrefix): self + { + $self = clone $this; + $self['urlPrefix'] = $urlPrefix; + + return $self; + } + + /** + * Configuration for third-party URL rewriting. + * + * @param URLRewriterShape $urlRewriter + */ + public function withURLRewriter( + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter $urlRewriter + ): self { + $self = clone $this; + $self['urlRewriter'] = $urlRewriter; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter.php new file mode 100644 index 00000000..013a7d11 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter.php @@ -0,0 +1,44 @@ +|array + */ + public static function variants(): array + { + return [ + 'CLOUDINARY' => CloudinaryURLRewriter::class, + 'IMGIX' => ImgixURLRewriter::class, + 'AKAMAI' => AkamaiURLRewriter::class, + ]; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter/AkamaiURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter/AkamaiURLRewriter.php new file mode 100644 index 00000000..3426c523 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter/AkamaiURLRewriter.php @@ -0,0 +1,48 @@ + */ + use SdkModel; + + /** @var 'AKAMAI' $type */ + #[Required] + public string $type = 'AKAMAI'; + + 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(): self + { + return new self; + } + + /** + * @param 'AKAMAI' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter/CloudinaryURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter/CloudinaryURLRewriter.php new file mode 100644 index 00000000..56426c4f --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter/CloudinaryURLRewriter.php @@ -0,0 +1,73 @@ + */ + use SdkModel; + + /** @var 'CLOUDINARY' $type */ + #[Required] + public string $type = 'CLOUDINARY'; + + /** + * Whether to preserve `/` in the rewritten URL. + */ + #[Optional] + public ?bool $preserveAssetDeliveryTypes; + + 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 $preserveAssetDeliveryTypes = null): self + { + $self = new self; + + null !== $preserveAssetDeliveryTypes && $self['preserveAssetDeliveryTypes'] = $preserveAssetDeliveryTypes; + + return $self; + } + + /** + * @param 'CLOUDINARY' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Whether to preserve `/` in the rewritten URL. + */ + public function withPreserveAssetDeliveryTypes( + bool $preserveAssetDeliveryTypes + ): self { + $self = clone $this; + $self['preserveAssetDeliveryTypes'] = $preserveAssetDeliveryTypes; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter/ImgixURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter/ImgixURLRewriter.php new file mode 100644 index 00000000..4eadafe0 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointCreateParams/URLRewriter/ImgixURLRewriter.php @@ -0,0 +1,48 @@ + */ + use SdkModel; + + /** @var 'IMGIX' $type */ + #[Required] + public string $type = 'IMGIX'; + + 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(): self + { + return new self; + } + + /** + * @param 'IMGIX' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointRequest.php b/src/Accounts/URLEndpoints/URLEndpointRequest.php new file mode 100644 index 00000000..a3a90292 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointRequest.php @@ -0,0 +1,154 @@ +|null, + * urlPrefix?: string|null, + * urlRewriter?: URLRewriterShape|null, + * } + */ +final class URLEndpointRequest implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Description of the URL endpoint. + */ + #[Required] + public string $description; + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * + * @var list|null $origins + */ + #[Optional(list: 'string')] + public ?array $origins; + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint). + */ + #[Optional] + public ?string $urlPrefix; + + /** + * Configuration for third-party URL rewriting. + * + * @var URLRewriterVariants|null $urlRewriter + */ + #[Optional(union: URLRewriter::class)] + public CloudinaryURLRewriter|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter; + + /** + * `new URLEndpointRequest()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * URLEndpointRequest::with(description: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new URLEndpointRequest)->withDescription(...) + * ``` + */ + 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 list|null $origins + * @param URLRewriterShape|null $urlRewriter + */ + public static function with( + string $description, + ?array $origins = null, + ?string $urlPrefix = null, + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter = null, + ): self { + $self = new self; + + $self['description'] = $description; + + null !== $origins && $self['origins'] = $origins; + null !== $urlPrefix && $self['urlPrefix'] = $urlPrefix; + null !== $urlRewriter && $self['urlRewriter'] = $urlRewriter; + + return $self; + } + + /** + * Description of the URL endpoint. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * + * @param list $origins + */ + public function withOrigins(array $origins): self + { + $self = clone $this; + $self['origins'] = $origins; + + return $self; + } + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint). + */ + public function withURLPrefix(string $urlPrefix): self + { + $self = clone $this; + $self['urlPrefix'] = $urlPrefix; + + return $self; + } + + /** + * Configuration for third-party URL rewriting. + * + * @param URLRewriterShape $urlRewriter + */ + public function withURLRewriter( + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter $urlRewriter + ): self { + $self = clone $this; + $self['urlRewriter'] = $urlRewriter; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter.php new file mode 100644 index 00000000..73515b91 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter.php @@ -0,0 +1,44 @@ +|array + */ + public static function variants(): array + { + return [ + 'CLOUDINARY' => CloudinaryURLRewriter::class, + 'IMGIX' => ImgixURLRewriter::class, + 'AKAMAI' => AkamaiURLRewriter::class, + ]; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter/AkamaiURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter/AkamaiURLRewriter.php new file mode 100644 index 00000000..534e2eaf --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter/AkamaiURLRewriter.php @@ -0,0 +1,48 @@ + */ + use SdkModel; + + /** @var 'AKAMAI' $type */ + #[Required] + public string $type = 'AKAMAI'; + + 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(): self + { + return new self; + } + + /** + * @param 'AKAMAI' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter/CloudinaryURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter/CloudinaryURLRewriter.php new file mode 100644 index 00000000..b2438007 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter/CloudinaryURLRewriter.php @@ -0,0 +1,73 @@ + */ + use SdkModel; + + /** @var 'CLOUDINARY' $type */ + #[Required] + public string $type = 'CLOUDINARY'; + + /** + * Whether to preserve `/` in the rewritten URL. + */ + #[Optional] + public ?bool $preserveAssetDeliveryTypes; + + 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 $preserveAssetDeliveryTypes = null): self + { + $self = new self; + + null !== $preserveAssetDeliveryTypes && $self['preserveAssetDeliveryTypes'] = $preserveAssetDeliveryTypes; + + return $self; + } + + /** + * @param 'CLOUDINARY' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Whether to preserve `/` in the rewritten URL. + */ + public function withPreserveAssetDeliveryTypes( + bool $preserveAssetDeliveryTypes + ): self { + $self = clone $this; + $self['preserveAssetDeliveryTypes'] = $preserveAssetDeliveryTypes; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter/ImgixURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter/ImgixURLRewriter.php new file mode 100644 index 00000000..2f96917c --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointRequest/URLRewriter/ImgixURLRewriter.php @@ -0,0 +1,48 @@ + */ + use SdkModel; + + /** @var 'IMGIX' $type */ + #[Required] + public string $type = 'IMGIX'; + + 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(): self + { + return new self; + } + + /** + * @param 'IMGIX' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointResponse.php b/src/Accounts/URLEndpoints/URLEndpointResponse.php new file mode 100644 index 00000000..af3e773d --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointResponse.php @@ -0,0 +1,180 @@ +, + * urlPrefix: string, + * urlRewriter?: URLRewriterShape|null, + * } + */ +final class URLEndpointResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + */ + #[Required] + public string $id; + + /** + * Description of the URL endpoint. + */ + #[Required] + public string $description; + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * + * @var list $origins + */ + #[Required(list: 'string')] + public array $origins; + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint). + */ + #[Required] + public string $urlPrefix; + + /** + * Configuration for third-party URL rewriting. + * + * @var URLRewriterVariants|null $urlRewriter + */ + #[Optional(union: URLRewriter::class)] + public CloudinaryURLRewriter|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter; + + /** + * `new URLEndpointResponse()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * URLEndpointResponse::with( + * id: ..., description: ..., origins: ..., urlPrefix: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new URLEndpointResponse) + * ->withID(...) + * ->withDescription(...) + * ->withOrigins(...) + * ->withURLPrefix(...) + * ``` + */ + 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 list $origins + * @param URLRewriterShape|null $urlRewriter + */ + public static function with( + string $id, + string $description, + array $origins = [], + string $urlPrefix = '', + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['description'] = $description; + $self['origins'] = $origins; + $self['urlPrefix'] = $urlPrefix; + + null !== $urlRewriter && $self['urlRewriter'] = $urlRewriter; + + return $self; + } + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Description of the URL endpoint. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * + * @param list $origins + */ + public function withOrigins(array $origins): self + { + $self = clone $this; + $self['origins'] = $origins; + + return $self; + } + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint). + */ + public function withURLPrefix(string $urlPrefix): self + { + $self = clone $this; + $self['urlPrefix'] = $urlPrefix; + + return $self; + } + + /** + * Configuration for third-party URL rewriting. + * + * @param URLRewriterShape $urlRewriter + */ + public function withURLRewriter( + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter $urlRewriter + ): self { + $self = clone $this; + $self['urlRewriter'] = $urlRewriter; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter.php new file mode 100644 index 00000000..4670b2e9 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter.php @@ -0,0 +1,44 @@ +|array + */ + public static function variants(): array + { + return [ + 'CLOUDINARY' => CloudinaryURLRewriter::class, + 'IMGIX' => ImgixURLRewriter::class, + 'AKAMAI' => AkamaiURLRewriter::class, + ]; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter/AkamaiURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter/AkamaiURLRewriter.php new file mode 100644 index 00000000..505b599f --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter/AkamaiURLRewriter.php @@ -0,0 +1,48 @@ + */ + use SdkModel; + + /** @var 'AKAMAI' $type */ + #[Required] + public string $type = 'AKAMAI'; + + 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(): self + { + return new self; + } + + /** + * @param 'AKAMAI' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter/CloudinaryURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter/CloudinaryURLRewriter.php new file mode 100644 index 00000000..c4efdb70 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter/CloudinaryURLRewriter.php @@ -0,0 +1,86 @@ + */ + use SdkModel; + + /** @var 'CLOUDINARY' $type */ + #[Required] + public string $type = 'CLOUDINARY'; + + /** + * Whether to preserve `/` in the rewritten URL. + */ + #[Required] + public bool $preserveAssetDeliveryTypes; + + /** + * `new CloudinaryURLRewriter()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * CloudinaryURLRewriter::with(preserveAssetDeliveryTypes: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new CloudinaryURLRewriter)->withPreserveAssetDeliveryTypes(...) + * ``` + */ + 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 $preserveAssetDeliveryTypes = false): self + { + $self = new self; + + $self['preserveAssetDeliveryTypes'] = $preserveAssetDeliveryTypes; + + return $self; + } + + /** + * Whether to preserve `/` in the rewritten URL. + */ + public function withPreserveAssetDeliveryTypes( + bool $preserveAssetDeliveryTypes + ): self { + $self = clone $this; + $self['preserveAssetDeliveryTypes'] = $preserveAssetDeliveryTypes; + + return $self; + } + + /** + * @param 'CLOUDINARY' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter/ImgixURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter/ImgixURLRewriter.php new file mode 100644 index 00000000..e22b4dba --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointResponse/URLRewriter/ImgixURLRewriter.php @@ -0,0 +1,48 @@ + */ + use SdkModel; + + /** @var 'IMGIX' $type */ + #[Required] + public string $type = 'IMGIX'; + + 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(): self + { + return new self; + } + + /** + * @param 'IMGIX' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointUpdateParams.php b/src/Accounts/URLEndpoints/URLEndpointUpdateParams.php new file mode 100644 index 00000000..cfda6c3d --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointUpdateParams.php @@ -0,0 +1,159 @@ +|null, + * urlPrefix?: string|null, + * urlRewriter?: URLRewriterShape|null, + * } + */ +final class URLEndpointUpdateParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * Description of the URL endpoint. + */ + #[Required] + public string $description; + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * + * @var list|null $origins + */ + #[Optional(list: 'string')] + public ?array $origins; + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint). + */ + #[Optional] + public ?string $urlPrefix; + + /** + * Configuration for third-party URL rewriting. + * + * @var URLRewriterVariants|null $urlRewriter + */ + #[Optional(union: URLRewriter::class)] + public CloudinaryURLRewriter|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter; + + /** + * `new URLEndpointUpdateParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * URLEndpointUpdateParams::with(description: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new URLEndpointUpdateParams)->withDescription(...) + * ``` + */ + 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 list|null $origins + * @param URLRewriterShape|null $urlRewriter + */ + public static function with( + string $description, + ?array $origins = null, + ?string $urlPrefix = null, + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter = null, + ): self { + $self = new self; + + $self['description'] = $description; + + null !== $origins && $self['origins'] = $origins; + null !== $urlPrefix && $self['urlPrefix'] = $urlPrefix; + null !== $urlRewriter && $self['urlRewriter'] = $urlRewriter; + + return $self; + } + + /** + * Description of the URL endpoint. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * + * @param list $origins + */ + public function withOrigins(array $origins): self + { + $self = clone $this; + $self['origins'] = $origins; + + return $self; + } + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint). + */ + public function withURLPrefix(string $urlPrefix): self + { + $self = clone $this; + $self['urlPrefix'] = $urlPrefix; + + return $self; + } + + /** + * Configuration for third-party URL rewriting. + * + * @param URLRewriterShape $urlRewriter + */ + public function withURLRewriter( + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter $urlRewriter + ): self { + $self = clone $this; + $self['urlRewriter'] = $urlRewriter; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter.php new file mode 100644 index 00000000..8b2661a1 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter.php @@ -0,0 +1,44 @@ +|array + */ + public static function variants(): array + { + return [ + 'CLOUDINARY' => CloudinaryURLRewriter::class, + 'IMGIX' => ImgixURLRewriter::class, + 'AKAMAI' => AkamaiURLRewriter::class, + ]; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter/AkamaiURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter/AkamaiURLRewriter.php new file mode 100644 index 00000000..ad726587 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter/AkamaiURLRewriter.php @@ -0,0 +1,48 @@ + */ + use SdkModel; + + /** @var 'AKAMAI' $type */ + #[Required] + public string $type = 'AKAMAI'; + + 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(): self + { + return new self; + } + + /** + * @param 'AKAMAI' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter/CloudinaryURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter/CloudinaryURLRewriter.php new file mode 100644 index 00000000..7d42dda6 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter/CloudinaryURLRewriter.php @@ -0,0 +1,73 @@ + */ + use SdkModel; + + /** @var 'CLOUDINARY' $type */ + #[Required] + public string $type = 'CLOUDINARY'; + + /** + * Whether to preserve `/` in the rewritten URL. + */ + #[Optional] + public ?bool $preserveAssetDeliveryTypes; + + 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 $preserveAssetDeliveryTypes = null): self + { + $self = new self; + + null !== $preserveAssetDeliveryTypes && $self['preserveAssetDeliveryTypes'] = $preserveAssetDeliveryTypes; + + return $self; + } + + /** + * @param 'CLOUDINARY' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Whether to preserve `/` in the rewritten URL. + */ + public function withPreserveAssetDeliveryTypes( + bool $preserveAssetDeliveryTypes + ): self { + $self = clone $this; + $self['preserveAssetDeliveryTypes'] = $preserveAssetDeliveryTypes; + + return $self; + } +} diff --git a/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter/ImgixURLRewriter.php b/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter/ImgixURLRewriter.php new file mode 100644 index 00000000..21125d80 --- /dev/null +++ b/src/Accounts/URLEndpoints/URLEndpointUpdateParams/URLRewriter/ImgixURLRewriter.php @@ -0,0 +1,48 @@ + */ + use SdkModel; + + /** @var 'IMGIX' $type */ + #[Required] + public string $type = 'IMGIX'; + + 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(): self + { + return new self; + } + + /** + * @param 'IMGIX' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Accounts/Usage/UsageGetParams.php b/src/Accounts/Usage/UsageGetParams.php new file mode 100644 index 00000000..3c4f6064 --- /dev/null +++ b/src/Accounts/Usage/UsageGetParams.php @@ -0,0 +1,92 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days. + */ + #[Required] + public string $endDate; + + /** + * Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days. + */ + #[Required] + public string $startDate; + + /** + * `new UsageGetParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UsageGetParams::with(endDate: ..., startDate: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UsageGetParams)->withEndDate(...)->withStartDate(...) + * ``` + */ + 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(string $endDate, string $startDate): self + { + $self = new self; + + $self['endDate'] = $endDate; + $self['startDate'] = $startDate; + + return $self; + } + + /** + * Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days. + */ + public function withEndDate(string $endDate): self + { + $self = clone $this; + $self['endDate'] = $endDate; + + return $self; + } + + /** + * Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days. + */ + public function withStartDate(string $startDate): self + { + $self = clone $this; + $self['startDate'] = $startDate; + + return $self; + } +} diff --git a/src/Accounts/Usage/UsageGetResponse.php b/src/Accounts/Usage/UsageGetResponse.php new file mode 100644 index 00000000..d6759c18 --- /dev/null +++ b/src/Accounts/Usage/UsageGetResponse.php @@ -0,0 +1,140 @@ + */ + use SdkModel; + + /** + * Amount of bandwidth used in bytes. + */ + #[Optional] + public ?int $bandwidthBytes; + + /** + * Number of extension units used. + */ + #[Optional] + public ?int $extensionUnitsCount; + + /** + * Storage used by media library in bytes. + */ + #[Optional] + public ?int $mediaLibraryStorageBytes; + + /** + * Storage used by the original cache in bytes. + */ + #[Optional] + public ?int $originalCacheStorageBytes; + + /** + * Number of video processing units used. + */ + #[Optional] + public ?int $videoProcessingUnitsCount; + + 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( + ?int $bandwidthBytes = null, + ?int $extensionUnitsCount = null, + ?int $mediaLibraryStorageBytes = null, + ?int $originalCacheStorageBytes = null, + ?int $videoProcessingUnitsCount = null, + ): self { + $self = new self; + + null !== $bandwidthBytes && $self['bandwidthBytes'] = $bandwidthBytes; + null !== $extensionUnitsCount && $self['extensionUnitsCount'] = $extensionUnitsCount; + null !== $mediaLibraryStorageBytes && $self['mediaLibraryStorageBytes'] = $mediaLibraryStorageBytes; + null !== $originalCacheStorageBytes && $self['originalCacheStorageBytes'] = $originalCacheStorageBytes; + null !== $videoProcessingUnitsCount && $self['videoProcessingUnitsCount'] = $videoProcessingUnitsCount; + + return $self; + } + + /** + * Amount of bandwidth used in bytes. + */ + public function withBandwidthBytes(int $bandwidthBytes): self + { + $self = clone $this; + $self['bandwidthBytes'] = $bandwidthBytes; + + return $self; + } + + /** + * Number of extension units used. + */ + public function withExtensionUnitsCount(int $extensionUnitsCount): self + { + $self = clone $this; + $self['extensionUnitsCount'] = $extensionUnitsCount; + + return $self; + } + + /** + * Storage used by media library in bytes. + */ + public function withMediaLibraryStorageBytes( + int $mediaLibraryStorageBytes + ): self { + $self = clone $this; + $self['mediaLibraryStorageBytes'] = $mediaLibraryStorageBytes; + + return $self; + } + + /** + * Storage used by the original cache in bytes. + */ + public function withOriginalCacheStorageBytes( + int $originalCacheStorageBytes + ): self { + $self = clone $this; + $self['originalCacheStorageBytes'] = $originalCacheStorageBytes; + + return $self; + } + + /** + * Number of video processing units used. + */ + public function withVideoProcessingUnitsCount( + int $videoProcessingUnitsCount + ): self { + $self = clone $this; + $self['videoProcessingUnitsCount'] = $videoProcessingUnitsCount; + + return $self; + } +} diff --git a/src/Assets/AssetListParams.php b/src/Assets/AssetListParams.php new file mode 100644 index 00000000..1d90f4b3 --- /dev/null +++ b/src/Assets/AssetListParams.php @@ -0,0 +1,242 @@ +, + * limit?: int|null, + * path?: string|null, + * searchQuery?: string|null, + * skip?: int|null, + * sort?: null|Sort|value-of, + * type?: null|Type|value-of, + * } + */ +final class AssetListParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * Filter results by file type. + * + * - `all` — include all file types + * - `image` — include only image files + * - `non-image` — include only non-image files (e.g., JS, CSS, video) + * + * @var value-of|null $fileType + */ + #[Optional(enum: FileType::class)] + public ?string $fileType; + + /** + * The maximum number of results to return in response. + */ + #[Optional] + public ?int $limit; + + /** + * Folder path if you want to limit the search within a specific folder. For example, `/sales-banner/` will only search in folder sales-banner. + * + * Note : If your use case involves searching within a folder as well as its subfolders, you can use `path` parameter in `searchQuery` with appropriate operator. + * Checkout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) for more information. + */ + #[Optional] + public ?string $path; + + /** + * Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + * + * Note : When the searchQuery parameter is present, the following query parameters will have no effect on the result: + * + * 1. `tags` + * 2. `type` + * 3. `name` + * + * [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) from examples. + */ + #[Optional] + public ?string $searchQuery; + + /** + * The number of results to skip before returning results. + */ + #[Optional] + public ?int $skip; + + /** + * Sort the results by one of the supported fields in ascending or descending order. + * + * @var value-of|null $sort + */ + #[Optional(enum: Sort::class)] + public ?string $sort; + + /** + * Filter results by asset type. + * + * - `file` — returns only files + * - `file-version` — returns specific file versions + * - `folder` — returns only folders + * - `all` — returns both files and folders (excludes `file-version`) + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + 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 FileType|value-of|null $fileType + * @param Sort|value-of|null $sort + * @param Type|value-of|null $type + */ + public static function with( + FileType|string|null $fileType = null, + ?int $limit = null, + ?string $path = null, + ?string $searchQuery = null, + ?int $skip = null, + Sort|string|null $sort = null, + Type|string|null $type = null, + ): self { + $self = new self; + + null !== $fileType && $self['fileType'] = $fileType; + null !== $limit && $self['limit'] = $limit; + null !== $path && $self['path'] = $path; + null !== $searchQuery && $self['searchQuery'] = $searchQuery; + null !== $skip && $self['skip'] = $skip; + null !== $sort && $self['sort'] = $sort; + null !== $type && $self['type'] = $type; + + return $self; + } + + /** + * Filter results by file type. + * + * - `all` — include all file types + * - `image` — include only image files + * - `non-image` — include only non-image files (e.g., JS, CSS, video) + * + * @param FileType|value-of $fileType + */ + public function withFileType(FileType|string $fileType): self + { + $self = clone $this; + $self['fileType'] = $fileType; + + return $self; + } + + /** + * The maximum number of results to return in response. + */ + public function withLimit(int $limit): self + { + $self = clone $this; + $self['limit'] = $limit; + + return $self; + } + + /** + * Folder path if you want to limit the search within a specific folder. For example, `/sales-banner/` will only search in folder sales-banner. + * + * Note : If your use case involves searching within a folder as well as its subfolders, you can use `path` parameter in `searchQuery` with appropriate operator. + * Checkout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) for more information. + */ + public function withPath(string $path): self + { + $self = clone $this; + $self['path'] = $path; + + return $self; + } + + /** + * Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + * + * Note : When the searchQuery parameter is present, the following query parameters will have no effect on the result: + * + * 1. `tags` + * 2. `type` + * 3. `name` + * + * [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) from examples. + */ + public function withSearchQuery(string $searchQuery): self + { + $self = clone $this; + $self['searchQuery'] = $searchQuery; + + return $self; + } + + /** + * The number of results to skip before returning results. + */ + public function withSkip(int $skip): self + { + $self = clone $this; + $self['skip'] = $skip; + + return $self; + } + + /** + * Sort the results by one of the supported fields in ascending or descending order. + * + * @param Sort|value-of $sort + */ + public function withSort(Sort|string $sort): self + { + $self = clone $this; + $self['sort'] = $sort; + + return $self; + } + + /** + * Filter results by asset type. + * + * - `file` — returns only files + * - `file-version` — returns specific file versions + * - `folder` — returns only folders + * - `all` — returns both files and folders (excludes `file-version`) + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Assets/AssetListParams/FileType.php b/src/Assets/AssetListParams/FileType.php new file mode 100644 index 00000000..8c812108 --- /dev/null +++ b/src/Assets/AssetListParams/FileType.php @@ -0,0 +1,21 @@ +|array + */ + public static function variants(): array + { + return [File::class, 'folder' => Folder::class]; + } +} diff --git a/src/BaseOverlay.php b/src/BaseOverlay.php new file mode 100644 index 00000000..2d1a6986 --- /dev/null +++ b/src/BaseOverlay.php @@ -0,0 +1,129 @@ +, + * position?: null|OverlayPosition|OverlayPositionShape, + * timing?: null|OverlayTiming|OverlayTimingShape, + * } + */ +final class BaseOverlay implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @var value-of|null $layerMode + */ + #[Optional(enum: LayerMode::class)] + public ?string $layerMode; + + /** + * Specifies the overlay's position relative to the parent asset. + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ + #[Optional] + public ?OverlayPosition $position; + + /** + * Specifies timing information for the overlay (only applicable if the base asset is a video). + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ + #[Optional] + public ?OverlayTiming $timing; + + 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 LayerMode|value-of|null $layerMode + * @param OverlayPosition|OverlayPositionShape|null $position + * @param OverlayTiming|OverlayTimingShape|null $timing + */ + public static function with( + LayerMode|string|null $layerMode = null, + OverlayPosition|array|null $position = null, + OverlayTiming|array|null $timing = null, + ): self { + $self = new self; + + null !== $layerMode && $self['layerMode'] = $layerMode; + null !== $position && $self['position'] = $position; + null !== $timing && $self['timing'] = $timing; + + return $self; + } + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @param LayerMode|value-of $layerMode + */ + public function withLayerMode(LayerMode|string $layerMode): self + { + $self = clone $this; + $self['layerMode'] = $layerMode; + + return $self; + } + + /** + * Specifies the overlay's position relative to the parent asset. + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * + * @param OverlayPosition|OverlayPositionShape $position + */ + public function withPosition(OverlayPosition|array $position): self + { + $self = clone $this; + $self['position'] = $position; + + return $self; + } + + /** + * Specifies timing information for the overlay (only applicable if the base asset is a video). + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * + * @param OverlayTiming|OverlayTimingShape $timing + */ + public function withTiming(OverlayTiming|array $timing): self + { + $self = clone $this; + $self['timing'] = $timing; + + return $self; + } +} diff --git a/src/BaseOverlay/LayerMode.php b/src/BaseOverlay/LayerMode.php new file mode 100644 index 00000000..8f40d2f6 --- /dev/null +++ b/src/BaseOverlay/LayerMode.php @@ -0,0 +1,25 @@ +|null, + * description?: string|null, + * extensions?: list|null, + * folder?: string|null, + * isPrivateFile?: bool|null, + * isPublished?: bool|null, + * overwriteAITags?: bool|null, + * overwriteCustomMetadata?: bool|null, + * overwriteFile?: bool|null, + * overwriteTags?: bool|null, + * responseFields?: list>|null, + * tags?: list|null, + * transformation?: null|Transformation|TransformationShape, + * useUniqueFileName?: bool|null, + * webhookURL?: string|null, + * } + */ +final class FileUploadParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * The API accepts any of the following: + * + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request. + */ + #[Required] + public string $file; + + /** + * The name with which the file has to be uploaded. + */ + #[Required] + public string $fileName; + + /** + * This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to authenticate and check that the upload request parameters have not been tampered with after the token has been generated. Learn how to create the token on the page below. This field is only required for authentication when uploading a file from the client side. + * + * **Note**: Sending a JWT that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new token. + * + * + * **⚠️Warning**: JWT must be generated on the server-side because it is generated using your account's private API key. This field is required for authentication when uploading a file from the client-side. + */ + #[Optional] + public ?string $token; + + /** + * Server-side checks to run on the asset. + * Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + */ + #[Optional] + public ?string $checks; + + /** + * Define an important area in the image. This is only relevant for image type files. + * + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be removed. + */ + #[Optional] + public ?string $customCoordinates; + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Optional text to describe the contents of the file. + */ + #[Optional] + public ?string $description; + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * + * @var list|null $extensions + */ + #[Optional(list: ExtensionItem::class)] + public ?array $extensions; + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. Using multiple `/` creates a nested folder. + */ + #[Optional] + public ?string $folder; + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or signed URL. + */ + #[Optional] + public ?bool $isPrivateFile; + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + */ + #[Optional] + public ?bool $isPublished; + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + #[Optional] + public ?bool $overwriteAITags; + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed. + */ + #[Optional] + public ?bool $overwriteCustomMetadata; + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately. + */ + #[Optional] + public ?bool $overwriteFile; + + /** + * If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed. + */ + #[Optional] + public ?bool $overwriteTags; + + /** + * Array of response field keys to include in the API response body. + * + * @var list>|null $responseFields + */ + #[Optional(list: ResponseField::class)] + public ?array $responseFields; + + /** + * Set the tags while uploading the file. + * Provide an array of tag strings (e.g. `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed. + * If this field is not specified and the file is overwritten, the existing tags will be removed. + * + * @var list|null $tags + */ + #[Optional(list: 'string')] + public ?array $tags; + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * + * - `pre` — applied before the file is uploaded to the Media Library. + * Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + * + * - `post` — applied immediately after upload. + * Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + #[Optional] + public ?Transformation $transformation; + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced. + */ + #[Optional] + public ?bool $useUniqueFileName; + + /** + * The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + */ + #[Optional('webhookUrl')] + public ?string $webhookURL; + + /** + * `new FileUploadParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileUploadParams::with(file: ..., fileName: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileUploadParams)->withFile(...)->withFileName(...) + * ``` + */ + 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 array|null $customMetadata + * @param list|null $extensions + * @param list>|null $responseFields + * @param list|null $tags + * @param Transformation|TransformationShape|null $transformation + */ + public static function with( + string|FileParam $file, + string $fileName, + ?string $token = null, + ?string $checks = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?array $extensions = null, + ?string $folder = null, + ?bool $isPrivateFile = null, + ?bool $isPublished = null, + ?bool $overwriteAITags = null, + ?bool $overwriteCustomMetadata = null, + ?bool $overwriteFile = null, + ?bool $overwriteTags = null, + ?array $responseFields = null, + ?array $tags = null, + Transformation|array|null $transformation = null, + ?bool $useUniqueFileName = null, + ?string $webhookURL = null, + ): self { + $self = new self; + + $self['file'] = $file; + $self['fileName'] = $fileName; + + null !== $token && $self['token'] = $token; + null !== $checks && $self['checks'] = $checks; + null !== $customCoordinates && $self['customCoordinates'] = $customCoordinates; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $description && $self['description'] = $description; + null !== $extensions && $self['extensions'] = $extensions; + null !== $folder && $self['folder'] = $folder; + null !== $isPrivateFile && $self['isPrivateFile'] = $isPrivateFile; + null !== $isPublished && $self['isPublished'] = $isPublished; + null !== $overwriteAITags && $self['overwriteAITags'] = $overwriteAITags; + null !== $overwriteCustomMetadata && $self['overwriteCustomMetadata'] = $overwriteCustomMetadata; + null !== $overwriteFile && $self['overwriteFile'] = $overwriteFile; + null !== $overwriteTags && $self['overwriteTags'] = $overwriteTags; + null !== $responseFields && $self['responseFields'] = $responseFields; + null !== $tags && $self['tags'] = $tags; + null !== $transformation && $self['transformation'] = $transformation; + null !== $useUniqueFileName && $self['useUniqueFileName'] = $useUniqueFileName; + null !== $webhookURL && $self['webhookURL'] = $webhookURL; + + return $self; + } + + /** + * The API accepts any of the following: + * + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request. + */ + public function withFile(string|FileParam $file): self + { + $self = clone $this; + $self['file'] = $file; + + return $self; + } + + /** + * The name with which the file has to be uploaded. + */ + public function withFileName(string $fileName): self + { + $self = clone $this; + $self['fileName'] = $fileName; + + return $self; + } + + /** + * This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to authenticate and check that the upload request parameters have not been tampered with after the token has been generated. Learn how to create the token on the page below. This field is only required for authentication when uploading a file from the client side. + * + * **Note**: Sending a JWT that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new token. + * + * + * **⚠️Warning**: JWT must be generated on the server-side because it is generated using your account's private API key. This field is required for authentication when uploading a file from the client-side. + */ + public function withToken(string $token): self + { + $self = clone $this; + $self['token'] = $token; + + return $self; + } + + /** + * Server-side checks to run on the asset. + * Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + */ + public function withChecks(string $checks): self + { + $self = clone $this; + $self['checks'] = $checks; + + return $self; + } + + /** + * Define an important area in the image. This is only relevant for image type files. + * + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be removed. + */ + public function withCustomCoordinates(string $customCoordinates): self + { + $self = clone $this; + $self['customCoordinates'] = $customCoordinates; + + return $self; + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Optional text to describe the contents of the file. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * + * @param list $extensions + */ + public function withExtensions(array $extensions): self + { + $self = clone $this; + $self['extensions'] = $extensions; + + return $self; + } + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. Using multiple `/` creates a nested folder. + */ + public function withFolder(string $folder): self + { + $self = clone $this; + $self['folder'] = $folder; + + return $self; + } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or signed URL. + */ + public function withIsPrivateFile(bool $isPrivateFile): self + { + $self = clone $this; + $self['isPrivateFile'] = $isPrivateFile; + + return $self; + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + */ + public function withIsPublished(bool $isPublished): self + { + $self = clone $this; + $self['isPublished'] = $isPublished; + + return $self; + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + public function withOverwriteAITags(bool $overwriteAITags): self + { + $self = clone $this; + $self['overwriteAITags'] = $overwriteAITags; + + return $self; + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed. + */ + public function withOverwriteCustomMetadata( + bool $overwriteCustomMetadata + ): self { + $self = clone $this; + $self['overwriteCustomMetadata'] = $overwriteCustomMetadata; + + return $self; + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately. + */ + public function withOverwriteFile(bool $overwriteFile): self + { + $self = clone $this; + $self['overwriteFile'] = $overwriteFile; + + return $self; + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed. + */ + public function withOverwriteTags(bool $overwriteTags): self + { + $self = clone $this; + $self['overwriteTags'] = $overwriteTags; + + return $self; + } + + /** + * Array of response field keys to include in the API response body. + * + * @param list> $responseFields + */ + public function withResponseFields(array $responseFields): self + { + $self = clone $this; + $self['responseFields'] = $responseFields; + + return $self; + } + + /** + * Set the tags while uploading the file. + * Provide an array of tag strings (e.g. `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed. + * If this field is not specified and the file is overwritten, the existing tags will be removed. + * + * @param list $tags + */ + public function withTags(array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * + * - `pre` — applied before the file is uploaded to the Media Library. + * Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + * + * - `post` — applied immediately after upload. + * Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @param Transformation|TransformationShape $transformation + */ + public function withTransformation( + Transformation|array $transformation + ): self { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced. + */ + public function withUseUniqueFileName(bool $useUniqueFileName): self + { + $self = clone $this; + $self['useUniqueFileName'] = $useUniqueFileName; + + return $self; + } + + /** + * The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + */ + public function withWebhookURL(string $webhookURL): self + { + $self = clone $this; + $self['webhookURL'] = $webhookURL; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadParams/ResponseField.php b/src/Beta/V2/Files/FileUploadParams/ResponseField.php new file mode 100644 index 00000000..04a9aeb2 --- /dev/null +++ b/src/Beta/V2/Files/FileUploadParams/ResponseField.php @@ -0,0 +1,24 @@ +|null, pre?: string|null + * } + */ +final class Transformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * List of transformations to apply *after* the file is uploaded. + * Each item must match one of the following types: + * `transformation`, `gif-to-video`, `thumbnail`, `abs`. + * + * @var list|null $post + */ + #[Optional(list: Post::class)] + public ?array $post; + + /** + * Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion. + */ + #[Optional] + public ?string $pre; + + 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 list|null $post + */ + public static function with(?array $post = null, ?string $pre = null): self + { + $self = new self; + + null !== $post && $self['post'] = $post; + null !== $pre && $self['pre'] = $pre; + + return $self; + } + + /** + * List of transformations to apply *after* the file is uploaded. + * Each item must match one of the following types: + * `transformation`, `gif-to-video`, `thumbnail`, `abs`. + * + * @param list $post + */ + public function withPost(array $post): self + { + $self = clone $this; + $self['post'] = $post; + + return $self; + } + + /** + * Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion. + */ + public function withPre(string $pre): self + { + $self = clone $this; + $self['pre'] = $pre; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadParams/Transformation/Post.php b/src/Beta/V2/Files/FileUploadParams/Transformation/Post.php new file mode 100644 index 00000000..6f82cf67 --- /dev/null +++ b/src/Beta/V2/Files/FileUploadParams/Transformation/Post.php @@ -0,0 +1,45 @@ +|array + */ + public static function variants(): array + { + return [ + 'transformation' => SimplePostTransformation::class, + 'gif-to-video' => ConvertGifToVideo::class, + 'thumbnail' => GenerateAThumbnail::class, + 'abs' => AdaptiveBitrateStreaming::class, + ]; + } +} diff --git a/src/Beta/V2/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming.php b/src/Beta/V2/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming.php new file mode 100644 index 00000000..8223ea1b --- /dev/null +++ b/src/Beta/V2/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming.php @@ -0,0 +1,116 @@ +, type: 'abs', value: string + * } + */ +final class AdaptiveBitrateStreaming implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * @var 'abs' $type + */ + #[Required] + public string $type = 'abs'; + + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @var value-of $protocol + */ + #[Required(enum: Protocol::class)] + public string $protocol; + + /** + * List of different representations you want to create separated by an underscore. + */ + #[Required] + public string $value; + + /** + * `new AdaptiveBitrateStreaming()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AdaptiveBitrateStreaming::with(protocol: ..., value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AdaptiveBitrateStreaming)->withProtocol(...)->withValue(...) + * ``` + */ + 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 Protocol|value-of $protocol + */ + public static function with(Protocol|string $protocol, string $value): self + { + $self = new self; + + $self['protocol'] = $protocol; + $self['value'] = $value; + + return $self; + } + + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @param Protocol|value-of $protocol + */ + public function withProtocol(Protocol|string $protocol): self + { + $self = clone $this; + $self['protocol'] = $protocol; + + return $self; + } + + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * @param 'abs' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * List of different representations you want to create separated by an underscore. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming/Protocol.php b/src/Beta/V2/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming/Protocol.php new file mode 100644 index 00000000..9be027f5 --- /dev/null +++ b/src/Beta/V2/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming/Protocol.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * Converts an animated GIF into an MP4. + * + * @var 'gif-to-video' $type + */ + #[Required] + public string $type = 'gif-to-video'; + + /** + * Optional transformation string to apply to the output video. + * **Example**: `q-80`. + */ + #[Optional] + public ?string $value; + + 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(?string $value = null): self + { + $self = new self; + + null !== $value && $self['value'] = $value; + + return $self; + } + + /** + * Converts an animated GIF into an MP4. + * + * @param 'gif-to-video' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Optional transformation string to apply to the output video. + * **Example**: `q-80`. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadParams/Transformation/Post/GenerateAThumbnail.php b/src/Beta/V2/Files/FileUploadParams/Transformation/Post/GenerateAThumbnail.php new file mode 100644 index 00000000..23cf5ffb --- /dev/null +++ b/src/Beta/V2/Files/FileUploadParams/Transformation/Post/GenerateAThumbnail.php @@ -0,0 +1,80 @@ + */ + use SdkModel; + + /** + * Generates a thumbnail image. + * + * @var 'thumbnail' $type + */ + #[Required] + public string $type = 'thumbnail'; + + /** + * Optional transformation string. + * **Example**: `w-150,h-150`. + */ + #[Optional] + public ?string $value; + + 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(?string $value = null): self + { + $self = new self; + + null !== $value && $self['value'] = $value; + + return $self; + } + + /** + * Generates a thumbnail image. + * + * @param 'thumbnail' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Optional transformation string. + * **Example**: `w-150,h-150`. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadParams/Transformation/Post/SimplePostTransformation.php b/src/Beta/V2/Files/FileUploadParams/Transformation/Post/SimplePostTransformation.php new file mode 100644 index 00000000..bc515320 --- /dev/null +++ b/src/Beta/V2/Files/FileUploadParams/Transformation/Post/SimplePostTransformation.php @@ -0,0 +1,93 @@ + */ + use SdkModel; + + /** + * Transformation type. + * + * @var 'transformation' $type + */ + #[Required] + public string $type = 'transformation'; + + /** + * Transformation string (e.g. `w-200,h-200`). + * Same syntax as ImageKit URL-based transformations. + */ + #[Required] + public string $value; + + /** + * `new SimplePostTransformation()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SimplePostTransformation::with(value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SimplePostTransformation)->withValue(...) + * ``` + */ + 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(string $value): self + { + $self = new self; + + $self['value'] = $value; + + return $self; + } + + /** + * Transformation type. + * + * @param 'transformation' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Transformation string (e.g. `w-200,h-200`). + * Same syntax as ImageKit URL-based transformations. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse.php b/src/Beta/V2/Files/FileUploadResponse.php new file mode 100644 index 00000000..89f2316f --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse.php @@ -0,0 +1,606 @@ +|null, + * audioCodec?: string|null, + * bitRate?: int|null, + * customCoordinates?: string|null, + * customMetadata?: array|null, + * description?: string|null, + * duration?: int|null, + * embeddedMetadata?: array|null, + * extensionStatus?: null|ExtensionStatus|ExtensionStatusShape, + * fileID?: string|null, + * filePath?: string|null, + * fileType?: string|null, + * height?: float|null, + * isPrivateFile?: bool|null, + * isPublished?: bool|null, + * metadata?: null|Metadata|MetadataShape, + * name?: string|null, + * selectedFieldsSchema?: array|null, + * size?: float|null, + * tags?: list|null, + * thumbnailURL?: string|null, + * url?: string|null, + * versionInfo?: null|VersionInfo|VersionInfoShape, + * videoCodec?: string|null, + * width?: float|null, + * } + */ +final class FileUploadResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * An array of tags assigned to the uploaded file by auto tagging. + * + * @var list|null $aiTags + */ + #[Optional('AITags', list: AITag::class, nullable: true)] + public ?array $aiTags; + + /** + * The audio codec used in the video (only for video). + */ + #[Optional] + public ?string $audioCodec; + + /** + * The bit rate of the video in kbps (only for video). + */ + #[Optional] + public ?int $bitRate; + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in `responseFields` in API request to get the value of this field. + */ + #[Optional(nullable: true)] + public ?string $customCoordinates; + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get `customMetadata` in the upload API response. Before setting any custom metadata on an asset, you have to create the field using custom metadata fields API. Send `customMetadata` in `responseFields` in API request to get the value of this field. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + #[Optional] + public ?string $description; + + /** + * The duration of the video in seconds (only for video). + */ + #[Optional] + public ?int $duration; + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in the upload API response. + * + * @var array|null $embeddedMetadata + */ + #[Optional(map: 'mixed')] + public ?array $embeddedMetadata; + + /** + * Extension names with their processing status at the time of completion of the request. It could have one of the following status values: + * + * `success`: The extension has been successfully applied. + * `failed`: The extension has failed and will not be retried. + * `pending`: The extension will finish processing in some time. On completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + */ + #[Optional] + public ?ExtensionStatus $extensionStatus; + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update action on this file. + */ + #[Optional('fileId')] + public ?string $fileID; + + /** + * The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + */ + #[Optional] + public ?string $filePath; + + /** + * Type of the uploaded file. Possible values are `image`, `non-image`. + */ + #[Optional] + public ?string $fileType; + + /** + * Height of the image in pixels (Only for images). + */ + #[Optional] + public ?float $height; + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` in `responseFields` in API request to get the value of this field. + */ + #[Optional] + public ?bool $isPrivateFile; + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send `isPublished` in `responseFields` in API request to get the value of this field. + */ + #[Optional] + public ?bool $isPublished; + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the upload API response. + */ + #[Optional] + public ?Metadata $metadata; + + /** + * Name of the asset. + */ + #[Optional] + public ?string $name; + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @var array|null $selectedFieldsSchema + */ + #[Optional(map: SelectedFieldsSchema::class)] + public ?array $selectedFieldsSchema; + + /** + * Size of the image file in Bytes. + */ + #[Optional] + public ?float $size; + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send `tags` in `responseFields` in API request to get the value of this field. + * + * @var list|null $tags + */ + #[Optional(list: 'string', nullable: true)] + public ?array $tags; + + /** + * In the case of an image, a small thumbnail URL. + */ + #[Optional('thumbnailUrl')] + public ?string $thumbnailURL; + + /** + * A publicly accessible URL of the file. + */ + #[Optional] + public ?string $url; + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + */ + #[Optional] + public ?VersionInfo $versionInfo; + + /** + * The video codec used in the video (only for video). + */ + #[Optional] + public ?string $videoCodec; + + /** + * Width of the image in pixels (Only for Images). + */ + #[Optional] + public ?float $width; + + 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 list|null $aiTags + * @param array|null $customMetadata + * @param array|null $embeddedMetadata + * @param ExtensionStatus|ExtensionStatusShape|null $extensionStatus + * @param Metadata|MetadataShape|null $metadata + * @param array|null $selectedFieldsSchema + * @param list|null $tags + * @param VersionInfo|VersionInfoShape|null $versionInfo + */ + public static function with( + ?array $aiTags = null, + ?string $audioCodec = null, + ?int $bitRate = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?int $duration = null, + ?array $embeddedMetadata = null, + ExtensionStatus|array|null $extensionStatus = null, + ?string $fileID = null, + ?string $filePath = null, + ?string $fileType = null, + ?float $height = null, + ?bool $isPrivateFile = null, + ?bool $isPublished = null, + Metadata|array|null $metadata = null, + ?string $name = null, + ?array $selectedFieldsSchema = null, + ?float $size = null, + ?array $tags = null, + ?string $thumbnailURL = null, + ?string $url = null, + VersionInfo|array|null $versionInfo = null, + ?string $videoCodec = null, + ?float $width = null, + ): self { + $self = new self; + + null !== $aiTags && $self['aiTags'] = $aiTags; + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $bitRate && $self['bitRate'] = $bitRate; + null !== $customCoordinates && $self['customCoordinates'] = $customCoordinates; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $description && $self['description'] = $description; + null !== $duration && $self['duration'] = $duration; + null !== $embeddedMetadata && $self['embeddedMetadata'] = $embeddedMetadata; + null !== $extensionStatus && $self['extensionStatus'] = $extensionStatus; + null !== $fileID && $self['fileID'] = $fileID; + null !== $filePath && $self['filePath'] = $filePath; + null !== $fileType && $self['fileType'] = $fileType; + null !== $height && $self['height'] = $height; + null !== $isPrivateFile && $self['isPrivateFile'] = $isPrivateFile; + null !== $isPublished && $self['isPublished'] = $isPublished; + null !== $metadata && $self['metadata'] = $metadata; + null !== $name && $self['name'] = $name; + null !== $selectedFieldsSchema && $self['selectedFieldsSchema'] = $selectedFieldsSchema; + null !== $size && $self['size'] = $size; + null !== $tags && $self['tags'] = $tags; + null !== $thumbnailURL && $self['thumbnailURL'] = $thumbnailURL; + null !== $url && $self['url'] = $url; + null !== $versionInfo && $self['versionInfo'] = $versionInfo; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + null !== $width && $self['width'] = $width; + + return $self; + } + + /** + * An array of tags assigned to the uploaded file by auto tagging. + * + * @param list|null $aiTags + */ + public function withAITags(?array $aiTags): self + { + $self = clone $this; + $self['aiTags'] = $aiTags; + + return $self; + } + + /** + * The audio codec used in the video (only for video). + */ + public function withAudioCodec(string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * The bit rate of the video in kbps (only for video). + */ + public function withBitRate(int $bitRate): self + { + $self = clone $this; + $self['bitRate'] = $bitRate; + + return $self; + } + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in `responseFields` in API request to get the value of this field. + */ + public function withCustomCoordinates(?string $customCoordinates): self + { + $self = clone $this; + $self['customCoordinates'] = $customCoordinates; + + return $self; + } + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get `customMetadata` in the upload API response. Before setting any custom metadata on an asset, you have to create the field using custom metadata fields API. Send `customMetadata` in `responseFields` in API request to get the value of this field. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * The duration of the video in seconds (only for video). + */ + public function withDuration(int $duration): self + { + $self = clone $this; + $self['duration'] = $duration; + + return $self; + } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in the upload API response. + * + * @param array $embeddedMetadata + */ + public function withEmbeddedMetadata(array $embeddedMetadata): self + { + $self = clone $this; + $self['embeddedMetadata'] = $embeddedMetadata; + + return $self; + } + + /** + * Extension names with their processing status at the time of completion of the request. It could have one of the following status values: + * + * `success`: The extension has been successfully applied. + * `failed`: The extension has failed and will not be retried. + * `pending`: The extension will finish processing in some time. On completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + * + * @param ExtensionStatus|ExtensionStatusShape $extensionStatus + */ + public function withExtensionStatus( + ExtensionStatus|array $extensionStatus + ): self { + $self = clone $this; + $self['extensionStatus'] = $extensionStatus; + + return $self; + } + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update action on this file. + */ + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } + + /** + * The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + */ + public function withFilePath(string $filePath): self + { + $self = clone $this; + $self['filePath'] = $filePath; + + return $self; + } + + /** + * Type of the uploaded file. Possible values are `image`, `non-image`. + */ + public function withFileType(string $fileType): self + { + $self = clone $this; + $self['fileType'] = $fileType; + + return $self; + } + + /** + * Height of the image in pixels (Only for images). + */ + public function withHeight(float $height): self + { + $self = clone $this; + $self['height'] = $height; + + return $self; + } + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` in `responseFields` in API request to get the value of this field. + */ + public function withIsPrivateFile(bool $isPrivateFile): self + { + $self = clone $this; + $self['isPrivateFile'] = $isPrivateFile; + + return $self; + } + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send `isPublished` in `responseFields` in API request to get the value of this field. + */ + public function withIsPublished(bool $isPublished): self + { + $self = clone $this; + $self['isPublished'] = $isPublished; + + return $self; + } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the upload API response. + * + * @param Metadata|MetadataShape $metadata + */ + public function withMetadata(Metadata|array $metadata): self + { + $self = clone $this; + $self['metadata'] = $metadata; + + return $self; + } + + /** + * Name of the asset. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @param array $selectedFieldsSchema + */ + public function withSelectedFieldsSchema(array $selectedFieldsSchema): self + { + $self = clone $this; + $self['selectedFieldsSchema'] = $selectedFieldsSchema; + + return $self; + } + + /** + * Size of the image file in Bytes. + */ + public function withSize(float $size): self + { + $self = clone $this; + $self['size'] = $size; + + return $self; + } + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send `tags` in `responseFields` in API request to get the value of this field. + * + * @param list|null $tags + */ + public function withTags(?array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } + + /** + * In the case of an image, a small thumbnail URL. + */ + public function withThumbnailURL(string $thumbnailURL): self + { + $self = clone $this; + $self['thumbnailURL'] = $thumbnailURL; + + return $self; + } + + /** + * A publicly accessible URL of the file. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + * + * @param VersionInfo|VersionInfoShape $versionInfo + */ + public function withVersionInfo(VersionInfo|array $versionInfo): self + { + $self = clone $this; + $self['versionInfo'] = $versionInfo; + + return $self; + } + + /** + * The video codec used in the video (only for video). + */ + public function withVideoCodec(string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * Width of the image in pixels (Only for Images). + */ + public function withWidth(float $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse/AITag.php b/src/Beta/V2/Files/FileUploadResponse/AITag.php new file mode 100644 index 00000000..f137fa84 --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse/AITag.php @@ -0,0 +1,97 @@ + */ + use SdkModel; + + /** + * Confidence score of the tag. + */ + #[Optional] + public ?float $confidence; + + /** + * Name of the tag. + */ + #[Optional] + public ?string $name; + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + */ + #[Optional] + public ?string $source; + + 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( + ?float $confidence = null, + ?string $name = null, + ?string $source = null + ): self { + $self = new self; + + null !== $confidence && $self['confidence'] = $confidence; + null !== $name && $self['name'] = $name; + null !== $source && $self['source'] = $source; + + return $self; + } + + /** + * Confidence score of the tag. + */ + public function withConfidence(float $confidence): self + { + $self = clone $this; + $self['confidence'] = $confidence; + + return $self; + } + + /** + * Name of the tag. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + */ + public function withSource(string $source): self + { + $self = clone $this; + $self['source'] = $source; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse/ExtensionStatus.php b/src/Beta/V2/Files/FileUploadResponse/ExtensionStatus.php new file mode 100644 index 00000000..1cee1cbd --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse/ExtensionStatus.php @@ -0,0 +1,149 @@ +, + * aiTasks?: null|AITasks|value-of, + * awsAutoTagging?: null|AwsAutoTagging|value-of, + * googleAutoTagging?: null|GoogleAutoTagging|value-of, + * removeBg?: null|RemoveBg|value-of, + * } + */ +final class ExtensionStatus implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var value-of|null $aiAutoDescription */ + #[Optional('ai-auto-description', enum: AIAutoDescription::class)] + public ?string $aiAutoDescription; + + /** @var value-of|null $aiTasks */ + #[Optional('ai-tasks', enum: AITasks::class)] + public ?string $aiTasks; + + /** @var value-of|null $awsAutoTagging */ + #[Optional('aws-auto-tagging', enum: AwsAutoTagging::class)] + public ?string $awsAutoTagging; + + /** @var value-of|null $googleAutoTagging */ + #[Optional('google-auto-tagging', enum: GoogleAutoTagging::class)] + public ?string $googleAutoTagging; + + /** @var value-of|null $removeBg */ + #[Optional('remove-bg', enum: RemoveBg::class)] + public ?string $removeBg; + + 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 AIAutoDescription|value-of|null $aiAutoDescription + * @param AITasks|value-of|null $aiTasks + * @param AwsAutoTagging|value-of|null $awsAutoTagging + * @param GoogleAutoTagging|value-of|null $googleAutoTagging + * @param RemoveBg|value-of|null $removeBg + */ + public static function with( + AIAutoDescription|string|null $aiAutoDescription = null, + AITasks|string|null $aiTasks = null, + AwsAutoTagging|string|null $awsAutoTagging = null, + GoogleAutoTagging|string|null $googleAutoTagging = null, + RemoveBg|string|null $removeBg = null, + ): self { + $self = new self; + + null !== $aiAutoDescription && $self['aiAutoDescription'] = $aiAutoDescription; + null !== $aiTasks && $self['aiTasks'] = $aiTasks; + null !== $awsAutoTagging && $self['awsAutoTagging'] = $awsAutoTagging; + null !== $googleAutoTagging && $self['googleAutoTagging'] = $googleAutoTagging; + null !== $removeBg && $self['removeBg'] = $removeBg; + + return $self; + } + + /** + * @param AIAutoDescription|value-of $aiAutoDescription + */ + public function withAIAutoDescription( + AIAutoDescription|string $aiAutoDescription + ): self { + $self = clone $this; + $self['aiAutoDescription'] = $aiAutoDescription; + + return $self; + } + + /** + * @param AITasks|value-of $aiTasks + */ + public function withAITasks(AITasks|string $aiTasks): self + { + $self = clone $this; + $self['aiTasks'] = $aiTasks; + + return $self; + } + + /** + * @param AwsAutoTagging|value-of $awsAutoTagging + */ + public function withAwsAutoTagging( + AwsAutoTagging|string $awsAutoTagging + ): self { + $self = clone $this; + $self['awsAutoTagging'] = $awsAutoTagging; + + return $self; + } + + /** + * @param GoogleAutoTagging|value-of $googleAutoTagging + */ + public function withGoogleAutoTagging( + GoogleAutoTagging|string $googleAutoTagging + ): self { + $self = clone $this; + $self['googleAutoTagging'] = $googleAutoTagging; + + return $self; + } + + /** + * @param RemoveBg|value-of $removeBg + */ + public function withRemoveBg(RemoveBg|string $removeBg): self + { + $self = clone $this; + $self['removeBg'] = $removeBg; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse/ExtensionStatus/AIAutoDescription.php b/src/Beta/V2/Files/FileUploadResponse/ExtensionStatus/AIAutoDescription.php new file mode 100644 index 00000000..c38a0dcf --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse/ExtensionStatus/AIAutoDescription.php @@ -0,0 +1,14 @@ +, + * defaultValue?: DefaultValueShape|null, + * isValueRequired?: bool|null, + * maxLength?: float|null, + * maxValue?: MaxValueShape|null, + * minLength?: float|null, + * minValue?: MinValueShape|null, + * readOnly?: bool|null, + * selectOptions?: list|null, + * selectOptionsTruncated?: bool|null, + * } + */ +final class SelectedFieldsSchema implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of the custom metadata field. + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * The default value for this custom metadata field. The value should match the `type` of custom metadata field. + * + * @var DefaultValueVariants|null $defaultValue + */ + #[Optional(union: DefaultValue::class)] + public string|float|bool|array|null $defaultValue; + + /** + * Specifies if the custom metadata field is required or not. + */ + #[Optional] + public ?bool $isValueRequired; + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $maxLength; + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MaxValueVariants|null $maxValue + */ + #[Optional] + public string|float|null $maxValue; + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $minLength; + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MinValueVariants|null $minValue + */ + #[Optional] + public string|float|null $minValue; + + /** + * Indicates whether the custom metadata field is read only. A read only field cannot be modified after being set. This field is configurable only via the **Path policy** feature. + */ + #[Optional] + public ?bool $readOnly; + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @var list|null $selectOptions + */ + #[Optional(list: SelectOption::class)] + public ?array $selectOptions; + + /** + * Specifies if the selectOptions array is truncated. It is truncated when number of options are > 100. + */ + #[Optional] + public ?bool $selectOptionsTruncated; + + /** + * `new SelectedFieldsSchema()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SelectedFieldsSchema::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SelectedFieldsSchema)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param DefaultValueShape|null $defaultValue + * @param MaxValueShape|null $maxValue + * @param MinValueShape|null $minValue + * @param list|null $selectOptions + */ + public static function with( + Type|string $type, + string|float|bool|array|null $defaultValue = null, + ?bool $isValueRequired = null, + ?float $maxLength = null, + string|float|null $maxValue = null, + ?float $minLength = null, + string|float|null $minValue = null, + ?bool $readOnly = null, + ?array $selectOptions = null, + ?bool $selectOptionsTruncated = null, + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $defaultValue && $self['defaultValue'] = $defaultValue; + null !== $isValueRequired && $self['isValueRequired'] = $isValueRequired; + null !== $maxLength && $self['maxLength'] = $maxLength; + null !== $maxValue && $self['maxValue'] = $maxValue; + null !== $minLength && $self['minLength'] = $minLength; + null !== $minValue && $self['minValue'] = $minValue; + null !== $readOnly && $self['readOnly'] = $readOnly; + null !== $selectOptions && $self['selectOptions'] = $selectOptions; + null !== $selectOptionsTruncated && $self['selectOptionsTruncated'] = $selectOptionsTruncated; + + return $self; + } + + /** + * Type of the custom metadata field. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * The default value for this custom metadata field. The value should match the `type` of custom metadata field. + * + * @param DefaultValueShape $defaultValue + */ + public function withDefaultValue( + string|float|bool|array $defaultValue + ): self { + $self = clone $this; + $self['defaultValue'] = $defaultValue; + + return $self; + } + + /** + * Specifies if the custom metadata field is required or not. + */ + public function withIsValueRequired(bool $isValueRequired): self + { + $self = clone $this; + $self['isValueRequired'] = $isValueRequired; + + return $self; + } + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMaxLength(float $maxLength): self + { + $self = clone $this; + $self['maxLength'] = $maxLength; + + return $self; + } + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MaxValueShape $maxValue + */ + public function withMaxValue(string|float $maxValue): self + { + $self = clone $this; + $self['maxValue'] = $maxValue; + + return $self; + } + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMinLength(float $minLength): self + { + $self = clone $this; + $self['minLength'] = $minLength; + + return $self; + } + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MinValueShape $minValue + */ + public function withMinValue(string|float $minValue): self + { + $self = clone $this; + $self['minValue'] = $minValue; + + return $self; + } + + /** + * Indicates whether the custom metadata field is read only. A read only field cannot be modified after being set. This field is configurable only via the **Path policy** feature. + */ + public function withReadOnly(bool $readOnly): self + { + $self = clone $this; + $self['readOnly'] = $readOnly; + + return $self; + } + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @param list $selectOptions + */ + public function withSelectOptions(array $selectOptions): self + { + $self = clone $this; + $self['selectOptions'] = $selectOptions; + + return $self; + } + + /** + * Specifies if the selectOptions array is truncated. It is truncated when number of options are > 100. + */ + public function withSelectOptionsTruncated( + bool $selectOptionsTruncated + ): self { + $self = clone $this; + $self['selectOptionsTruncated'] = $selectOptionsTruncated; + + return $self; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue.php b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue.php new file mode 100644 index 00000000..6a8628ea --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue.php @@ -0,0 +1,32 @@ + + * @phpstan-type DefaultValueShape = DefaultValueVariants|list + */ +final class DefaultValue implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue/Mixed_.php b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue/Mixed_.php new file mode 100644 index 00000000..eb226022 --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/MaxValue.php b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/MaxValue.php new file mode 100644 index 00000000..e9a4ab2c --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/MaxValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/MinValue.php b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/MinValue.php new file mode 100644 index 00000000..8bde7ef4 --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/MinValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/SelectOption.php b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/SelectOption.php new file mode 100644 index 00000000..9f95d64a --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/SelectOption.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/Type.php b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/Type.php new file mode 100644 index 00000000..e41d977e --- /dev/null +++ b/src/Beta/V2/Files/FileUploadResponse/SelectedFieldsSchema/Type.php @@ -0,0 +1,25 @@ + */ + use SdkModel; + + /** + * Unique identifier of the file version. + */ + #[Optional] + public ?string $id; + + /** + * Name of the file version. + */ + #[Optional] + public ?string $name; + + 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(?string $id = null, ?string $name = null): self + { + $self = new self; + + null !== $id && $self['id'] = $id; + null !== $name && $self['name'] = $name; + + return $self; + } + + /** + * Unique identifier of the file version. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Name of the file version. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/Cache/Invalidation/InvalidationCreateParams.php b/src/Cache/Invalidation/InvalidationCreateParams.php new file mode 100644 index 00000000..360e19c8 --- /dev/null +++ b/src/Cache/Invalidation/InvalidationCreateParams.php @@ -0,0 +1,74 @@ + */ + use SdkModel; + use SdkParams; + + /** + * The full URL of the file to be purged. + */ + #[Required] + public string $url; + + /** + * `new InvalidationCreateParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * InvalidationCreateParams::with(url: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new InvalidationCreateParams)->withURL(...) + * ``` + */ + 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(string $url): self + { + $self = new self; + + $self['url'] = $url; + + return $self; + } + + /** + * The full URL of the file to be purged. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } +} diff --git a/src/Cache/Invalidation/InvalidationGetResponse.php b/src/Cache/Invalidation/InvalidationGetResponse.php new file mode 100644 index 00000000..185a5189 --- /dev/null +++ b/src/Cache/Invalidation/InvalidationGetResponse.php @@ -0,0 +1,63 @@ + + * } + */ +final class InvalidationGetResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Status of the purge request. + * + * @var value-of|null $status + */ + #[Optional(enum: Status::class)] + public ?string $status; + + 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 Status|value-of|null $status + */ + public static function with(Status|string|null $status = null): self + { + $self = new self; + + null !== $status && $self['status'] = $status; + + return $self; + } + + /** + * Status of the purge request. + * + * @param Status|value-of $status + */ + public function withStatus(Status|string $status): self + { + $self = clone $this; + $self['status'] = $status; + + return $self; + } +} diff --git a/src/Cache/Invalidation/InvalidationGetResponse/Status.php b/src/Cache/Invalidation/InvalidationGetResponse/Status.php new file mode 100644 index 00000000..3b72a61a --- /dev/null +++ b/src/Cache/Invalidation/InvalidationGetResponse/Status.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * Unique identifier of the purge request. This can be used to check the status of the purge request. + */ + #[Optional('requestId')] + public ?string $requestID; + + 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(?string $requestID = null): self + { + $self = new self; + + null !== $requestID && $self['requestID'] = $requestID; + + return $self; + } + + /** + * Unique identifier of the purge request. This can be used to check the status of the purge request. + */ + public function withRequestID(string $requestID): self + { + $self = clone $this; + $self['requestID'] = $requestID; + + return $self; + } +} diff --git a/src/Client.php b/src/Client.php new file mode 100644 index 00000000..86d08ed0 --- /dev/null +++ b/src/Client.php @@ -0,0 +1,203 @@ +privateKey = (string) ($privateKey ?? Util::getenv( + 'IMAGEKIT_PRIVATE_KEY' + )); + $this->password = (string) ($password ?? Util::getenv( + 'OPTIONAL_IMAGEKIT_IGNORES_THIS' + ) ?: 'do_not_set'); + $this->webhookSecret = (string) ($webhookSecret ?? Util::getenv( + 'IMAGEKIT_WEBHOOK_SECRET' + )); + + $this->baseUrlOverridden = !is_null($baseUrl); + + $baseUrl ??= Util::getenv( + 'IMAGE_KIT_BASE_URL' + ) ?: 'https://api.imagekit.io'; + + $options = RequestOptions::parse( + RequestOptions::with( + uriFactory: Psr17FactoryDiscovery::findUriFactory(), + streamFactory: Psr17FactoryDiscovery::findStreamFactory(), + requestFactory: Psr17FactoryDiscovery::findRequestFactory(), + transporter: Psr18ClientDiscovery::find(), + ), + $requestOptions, + ); + + if (is_null($options->streamingTransporter)) { + assert(!is_null($options->transporter)); + $options->streamingTransporter = new StreamingHttpClient($options->transporter); + } + + /** @var array $headers */ + $headers = [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'User-Agent' => sprintf('ImageKit/PHP %s', VERSION), + 'X-Stainless-Lang' => 'php', + 'X-Stainless-Package-Version' => '0.0.1', + 'X-Stainless-Arch' => Util::machtype(), + 'X-Stainless-OS' => Util::ostype(), + 'X-Stainless-Runtime' => php_sapi_name(), + 'X-Stainless-Runtime-Version' => phpversion(), + ]; + + $customHeadersEnv = Util::getenv('IMAGE_KIT_CUSTOM_HEADERS'); + if (null !== $customHeadersEnv) { + foreach (explode("\n", $customHeadersEnv) as $line) { + $colon = strpos($line, ':'); + if (false !== $colon) { + $headers[trim(substr($line, 0, $colon))] = trim(substr($line, $colon + 1)); + } + } + } + + parent::__construct( + headers: $headers, + baseUrl: $baseUrl, + options: $options + ); + + $this->customMetadataFields = new CustomMetadataFieldsService($this); + $this->files = new FilesService($this); + $this->savedExtensions = new SavedExtensionsService($this); + $this->assets = new AssetsService($this); + $this->cache = new CacheService($this); + $this->folders = new FoldersService($this); + $this->accounts = new AccountsService($this); + $this->beta = new BetaService($this); + $this->webhooks = new WebhooksService($this); + } + + /** @return array */ + protected function authHeaders(): array + { + if (!$this->privateKey && !$this->password) { + return []; + } + + $base64_credentials = base64_encode( + "{$this->privateKey}:{$this->password}" + ); + + return ['Authorization' => "Basic {$base64_credentials}"]; + } + + /** + * @internal + * + * @param string|list $path + * @param array $query + * @param array|null> $headers + * @param RequestOpts|null $opts + * + * @return array{NormalizedRequest, RequestOptions} + */ + protected function buildRequest( + string $method, + string|array $path, + array $query, + array $headers, + mixed $body, + RequestOptions|array|null $opts, + ): array { + return parent::buildRequest( + method: $method, + path: $path, + query: $query, + headers: [...$this->authHeaders(), ...$headers], + body: $body, + opts: $opts, + ); + } +} diff --git a/src/Core.php b/src/Core.php new file mode 100644 index 00000000..1e035bb1 --- /dev/null +++ b/src/Core.php @@ -0,0 +1,5 @@ +|Converter|string|null $type + * @param class-string<\BackedEnum>|Converter|null $enum + * @param class-string|Converter|null $union + * @param class-string|Converter|string|null $list + * @param class-string|Converter|string|null $map + */ + public function __construct( + ?string $apiName = null, + Converter|string|null $type = null, + Converter|string|null $enum = null, + Converter|string|null $union = null, + Converter|string|null $list = null, + Converter|string|null $map = null, + bool $nullable = false, + ) { + parent::__construct(apiName: $apiName, type: $type, enum: $enum, union: $union, list: $list, map: $map, nullable: $nullable); + $this->optional = true; + } +} diff --git a/src/Core/Attributes/Required.php b/src/Core/Attributes/Required.php new file mode 100644 index 00000000..f264dc07 --- /dev/null +++ b/src/Core/Attributes/Required.php @@ -0,0 +1,60 @@ +|Converter|string|null */ + public readonly Converter|string|null $type; + + public readonly ?string $apiName; + + public bool $optional; + + public readonly bool $nullable; + + /** + * @param class-string|Converter|string|null $type + * @param class-string<\BackedEnum>|Converter|null $enum + * @param class-string|Converter|null $union + * @param class-string|Converter|string|null $list + * @param class-string|Converter|string|null $map + */ + public function __construct( + ?string $apiName = null, + Converter|string|null $type = null, + Converter|string|null $enum = null, + Converter|string|null $union = null, + Converter|string|null $list = null, + Converter|string|null $map = null, + bool $nullable = false, + ) { + $type ??= $union; + if (null !== $list) { + $type ??= new ListOf($list); + } + if (null !== $map) { + $type ??= new MapOf($map); + } + if (null !== $enum) { + $type ??= $enum instanceof Converter ? $enum : EnumOf::fromBackedEnum($enum); + } + + $this->apiName = $apiName; + $this->type = $type; + $this->optional = false; + $this->nullable = $nullable; + } +} diff --git a/src/Core/BaseClient.php b/src/Core/BaseClient.php new file mode 100644 index 00000000..89afdd83 --- /dev/null +++ b/src/Core/BaseClient.php @@ -0,0 +1,287 @@ +, + * headers: array>, + * body: mixed, + * } + */ +abstract class BaseClient +{ + protected UriInterface $baseUrl; + + /** + * @internal + * + * @param array|null> $headers + */ + public function __construct( + protected array $headers, + string $baseUrl, + protected ?string $idempotencyHeader = null, + protected RequestOptions $options = new RequestOptions, + ) { + assert(!is_null($this->options->uriFactory)); + $this->baseUrl = $this->options->uriFactory->createUri($baseUrl); + } + + /** + * @param string|list $path + * @param array $query + * @param array $headers + * @param string|int|list|null $unwrap + * @param class-string>|null $page + * @param class-string>|null $stream + * @param RequestOptions|array|null $options + * + * @return BaseResponse + */ + public function request( + string $method, + string|array $path, + array $query = [], + array $headers = [], + mixed $body = null, + string|int|array|null $unwrap = null, + string|Converter|ConverterSource|null $convert = null, + ?string $page = null, + ?string $stream = null, + RequestOptions|array|null $options = [], + ): BaseResponse { + [$req, $opts] = $this->buildRequest( + method: $method, + // @phpstan-ignore argument.type + path: $path, + query: $query, + // @phpstan-ignore argument.type + headers: $headers, + body: $body, + // @phpstan-ignore argument.type + opts: $options, + ); + ['method' => $method, 'path' => $uri, 'headers' => $headers, 'body' => $data] = $req; + assert(!is_null($opts->requestFactory)); + + $request = $opts->requestFactory->createRequest($method, uri: $uri); + $request = Util::withSetHeaders($request, headers: $headers); + $request = $this->transformRequest($request); + + // @phpstan-ignore-next-line argument.type + $rsp = $this->sendRequest($opts, req: $request, data: $data, redirectCount: 0, retryCount: 0); + + // @phpstan-ignore-next-line argument.type + return new RawResponse(client: $this, request: $request, response: $rsp, options: $opts, requestInfo: $req, unwrap: $unwrap, stream: $stream, page: $page, convert: $convert ?? 'null'); + } + + /** + * @internal + */ + protected function generateIdempotencyKey(): string + { + $hex = bin2hex(random_bytes(32)); + + return "stainless-php-retry-{$hex}"; + } + + /** + * @internal + * + * @param string|list $path + * @param array $query + * @param array|null> $headers + * @param RequestOpts|null $opts + * + * @return array{NormalizedRequest, RequestOptions} + */ + protected function buildRequest( + string $method, + string|array $path, + array $query, + array $headers, + mixed $body, + RequestOptions|array|null $opts, + ): array { + $options = RequestOptions::parse($this->options, $opts); + + $parsedPath = Util::parsePath($path); + + /** @var array $mergedQuery */ + $mergedQuery = array_merge_recursive( + $query, + $options->extraQueryParams ?? [] + ); + $uri = Util::joinUri($this->baseUrl, path: $parsedPath, query: $mergedQuery)->__toString(); + $idempotencyHeaders = $this->idempotencyHeader && !array_key_exists($this->idempotencyHeader, array: $headers) + ? [$this->idempotencyHeader => $this->generateIdempotencyKey()] + : []; + + /** @var array|null> $mergedHeaders */ + $mergedHeaders = [ + ...$this->headers, + ...$headers, + ...($options->extraHeaders ?? []), + ...$idempotencyHeaders, + ]; + + $req = ['method' => strtoupper($method), 'path' => $uri, 'query' => $mergedQuery, 'headers' => $mergedHeaders, 'body' => $body]; + + return [$req, $options]; + } + + protected function transformRequest( + RequestInterface $request + ): RequestInterface { + return $request; + } + + /** + * @internal + */ + protected function followRedirect( + ResponseInterface $rsp, + RequestInterface $req + ): RequestInterface { + $location = $rsp->getHeaderLine('Location'); + if (!$location) { + throw new APIConnectionException($req, message: 'Redirection without Location header'); + } + + $uri = Util::joinUri($req->getUri(), path: $location); + + return $req->withUri($uri); + } + + /** + * @internal + */ + protected function shouldRetry( + RequestOptions $opts, + int $retryCount, + ?ResponseInterface $rsp + ): bool { + if ($retryCount >= $opts->maxRetries) { + return false; + } + + $code = $rsp?->getStatusCode(); + if (408 == $code || 409 == $code || 429 == $code || $code >= 500) { + return true; + } + + return false; + } + + /** + * @internal + */ + protected function retryDelay( + RequestOptions $opts, + int $retryCount, + ?ResponseInterface $rsp + ): float { + if (!empty($header = $rsp?->getHeaderLine('retry-after'))) { + if (is_numeric($header)) { + return floatval($header); + } + + try { + $date = new \DateTimeImmutable($header); + $span = time() - $date->getTimestamp(); + + return max(0.0, $span); + } catch (\DateMalformedStringException) { + } + } + + $scale = $retryCount ** 2; + $jitter = 1 - (0.25 * mt_rand() / mt_getrandmax()); + $naive = $opts->initialRetryDelay * $scale * $jitter; + + return max(0.0, min($naive, $opts->maxRetryDelay)); + } + + /** + * @internal + * + * @param bool|int|float|string|resource|\Traversable|array|null $data + */ + protected function sendRequest( + RequestOptions $opts, + RequestInterface $req, + mixed $data, + int $retryCount, + int $redirectCount, + ): ResponseInterface { + assert(null !== $opts->streamFactory && null !== $opts->transporter); + + /** @var RequestInterface */ + $req = $req->withHeader('X-Stainless-Retry-Count', strval($retryCount)); + $req = Util::withSetBody($opts->streamFactory, req: $req, body: $data); + + $transporter = Util::isStreamingRequest($req) + ? ($opts->streamingTransporter ?? $opts->transporter) + : $opts->transporter; + + $rsp = null; + $err = null; + + try { + $rsp = $transporter->sendRequest($req); + } catch (ClientExceptionInterface $e) { + $err = $e; + } + + $code = $rsp?->getStatusCode(); + + if ($code >= 300 && $code < 400) { + assert(!is_null($rsp)); + + if ($redirectCount >= 20) { + throw new APIConnectionException($req, message: 'Maximum redirects exceeded'); + } + + $req = $this->followRedirect($rsp, req: $req); + + return $this->sendRequest($opts, req: $req, data: $data, retryCount: $retryCount, redirectCount: ++$redirectCount); + } + + if ($code >= 400 || is_null($rsp)) { + if (!$this->shouldRetry($opts, retryCount: $retryCount, rsp: $rsp)) { + $exn = is_null($rsp) ? new APIConnectionException($req, previous: $err) : APIStatusException::from(request: $req, response: $rsp); + + throw $exn; + } + + $seconds = $this->retryDelay($opts, retryCount: $retryCount, rsp: $rsp); + $floor = floor($seconds); + time_nanosleep((int) $floor, nanoseconds: (int) ($seconds - $floor) * 10 ** 9); + + return $this->sendRequest($opts, req: $req, data: $data, retryCount: ++$retryCount, redirectCount: $redirectCount); + } + + return $rsp; + } +} diff --git a/src/Core/Concerns/ResponseProxy.php b/src/Core/Concerns/ResponseProxy.php new file mode 100644 index 00000000..709bfc4f --- /dev/null +++ b/src/Core/Concerns/ResponseProxy.php @@ -0,0 +1,101 @@ +response->getProtocolVersion(); + } + + public function withProtocolVersion(string $version): static + { + $self = clone $this; + $self->response = $this->response->withProtocolVersion($version); + + return $self; + } + + public function getHeaders(): array + { + return $this->response->getHeaders(); + } + + public function hasHeader(string $name): bool + { + return $this->response->hasHeader($name); + } + + public function getHeader(string $name): array + { + return $this->response->getHeader($name); + } + + public function getHeaderLine(string $name): string + { + return $this->response->getHeaderLine($name); + } + + public function withHeader(string $name, $value): static + { + $self = clone $this; + $self->response = $this->response->withHeader($name, value: $value); + + return $self; + } + + public function withAddedHeader(string $name, $value): static + { + $self = clone $this; + $self->response = $this->response->withAddedHeader($name, value: $value); + + return $self; + } + + public function withoutHeader(string $name): static + { + $self = clone $this; + $self->response = $this->response->withoutHeader($name); + + return $self; + } + + public function getBody(): StreamInterface + { + return $this->response->getBody(); + } + + public function withBody(StreamInterface $body): static + { + $self = clone $this; + $self->response = $this->response->withBody($body); + + return $self; + } + + public function getStatusCode(): int + { + return $this->response->getStatusCode(); + } + + public function withStatus(int $code, string $reasonPhrase = ''): static + { + $self = clone $this; + $self->response = $this->response->withstatus($code, reasonPhrase: $reasonPhrase); + + return $self; + } + + public function getReasonPhrase(): string + { + return $this->response->getReasonPhrase(); + } +} diff --git a/src/Core/Concerns/SdkEnum.php b/src/Core/Concerns/SdkEnum.php new file mode 100644 index 00000000..c47f7343 --- /dev/null +++ b/src/Core/Concerns/SdkEnum.php @@ -0,0 +1,34 @@ +getReflectionConstants() as $constant) { + if ($constant->isPublic()) { + array_push($acc, $constant->getValue()); + } + } + + // @phpstan-ignore-next-line return.type + return static::$converter = new EnumOf($acc); + } +} diff --git a/src/Core/Concerns/SdkModel.php b/src/Core/Concerns/SdkModel.php new file mode 100644 index 00000000..98948b2b --- /dev/null +++ b/src/Core/Concerns/SdkModel.php @@ -0,0 +1,285 @@ + + */ +trait SdkModel +{ + private static ModelOf $converter; + + /** + * @var array keeps track of undocumented data + */ + private array $_data = []; + + /** + * @internal + * + * @return array + */ + public function __serialize(): array + { + $properties = $this->toProperties(); + + return array_map(static fn ($v) => self::serialize($v), array: $properties); + } + + /** + * @internal + * + * @param array $data + */ + public function __unserialize(array $data): void + { + foreach ($data as $key => $value) { + // @phpstan-ignore-next-line argument.type + $this->offsetSet($key, value: $value); + } + } + + /** + * @internal + * + * @return array + */ + public function __debugInfo(): array + { + return $this->__serialize(); + } + + /** + * @internal + */ + public function __toString(): string + { + return Util::prettyEncodeJson($this->__debugInfo()); + } + + /** + * @internal + * + * Magic get is intended to occur when we have manually unset + * a native class property, indicating an omitted value, + * or a property overridden with an incongruent type + * + * @throws \Exception + */ + public function __get(string $key): mixed + { + if (!array_key_exists($key, array: self::$converter->properties)) { + throw new \RuntimeException("Property '{$key}' does not exist in {$this}::class"); + } + + // The unset property was overridden by a value with an incongruent type. + // It's forbidden for an optional value to be `null` in the payload. + if (array_key_exists($key, array: $this->_data)) { + throw new \Exception( + "The {$key} property is overridden, use the array access ['{$key}'] syntax to the raw payload property.", + ); + } + + // An optional property which was unset to be omitted from serialized is being accessed. + // Return null to match user's expectations. + // @phpstan-ignore-next-line return.type + return null; + } + + /** + * @internal + * + * @return Shape + */ + public function toProperties(): array + { + // @phpstan-ignore-next-line return.type + return [...Util::get_object_vars($this), ...$this->_data]; + } + + /** + * @internal + * + * @param key-of $offset + */ + public function offsetExists(mixed $offset): bool + { + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!is_string($offset)) { + throw new \InvalidArgumentException; + } + + if (array_key_exists($offset, array: $this->_data)) { + return true; + } + + if (array_key_exists($offset, array: self::$converter->properties)) { + if (isset($this->{$offset})) { + return true; + } + + $property = self::$converter->properties[$offset]->property; + + return $property->isInitialized($this); + } + + return false; + } + + /** + * @internal + * + * @param key-of $offset + */ + public function &offsetGet(mixed $offset): mixed + { + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!is_string($offset)) { + throw new \InvalidArgumentException; + } + + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!$this->offsetExists($offset)) { + // @phpstan-ignore-next-line return.type + return null; + } + + if (array_key_exists($offset, array: $this->_data)) { + // @phpstan-ignore-next-line return.type + return $this->_data[$offset]; + } + + // @phpstan-ignore-next-line return.type + return $this->{$offset}; + } + + /** + * @internal + * + * @param key-of $offset + */ + public function offsetSet(mixed $offset, mixed $value): void + { + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!is_string($offset)) { + throw new \InvalidArgumentException; + } + + $type = array_key_exists($offset, array: self::$converter->properties) + ? self::$converter->properties[$offset]->type + : 'mixed'; + + $coerced = Conversion::coerce($type, value: $value, state: new CoerceState(translateNames: false)); + + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (property_exists($this, property: $offset)) { + try { + // @phpstan-ignore-next-line assign.propertyType + $this->{$offset} = $coerced; + unset($this->_data[$offset]); + + return; + // @phpstan-ignore-next-line catch.neverThrown + } catch (\TypeError) { + unset($this->{$offset}); + } + } + + $this->_data[$offset] = $coerced; + } + + /** + * @internal + * + * @param key-of $offset + */ + public function offsetUnset(mixed $offset): void + { + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (!is_string($offset)) { + throw new \InvalidArgumentException; + } + + // @phpstan-ignore-next-line function.alreadyNarrowedType + if (property_exists($this, property: $offset)) { + unset($this->{$offset}); + } + + unset($this->_data[$offset]); + } + + /** + * @internal + * + * @return array + */ + public function jsonSerialize(): array + { + // @phpstan-ignore-next-line argument.type + return Conversion::dump(self::converter(), value: $this->__serialize()); + } + + /** + * @param array $data + */ + public static function fromArray(array $data): static + { + // @phpstan-ignore-next-line argument.type + return self::converter()->from($data); + } + + /** + * @internal + */ + public static function converter(): Converter + { + if (isset(self::$converter)) { + return self::$converter; + } + + $class = new \ReflectionClass(static::class); + + return self::$converter = new ModelOf($class); + } + + /** + * @internal + */ + private function initialize(): void + { + static::converter(); + + foreach (self::$converter->properties as $name => $info) { + if ($info->optional) { + unset($this->{$name}); + } + } + } + + /** + * @internal + */ + private static function serialize(mixed $value): mixed + { + if ($value instanceof BaseModel) { + return $value->toProperties(); + } + + if (is_array($value)) { + return array_map(static fn ($v) => self::serialize($v), array: $value); + } + + return $value; + } +} diff --git a/src/Core/Concerns/SdkPage.php b/src/Core/Concerns/SdkPage.php new file mode 100644 index 00000000..466eb6f1 --- /dev/null +++ b/src/Core/Concerns/SdkPage.php @@ -0,0 +1,102 @@ + + */ + abstract public function getItems(): array; + + public function hasNextPage(): bool + { + return !is_null($this->nextRequest()); + } + + /** + * Get the next page of results. + * Before calling this method, you must check if there is a next page + * using {@link hasNextPage()}. + * + * @return static of static + * + * @throws APIStatusException + */ + public function getNextPage(): static + { + $next = $this->nextRequest(); + if (!$next) { + throw new \RuntimeException( + 'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.' + ); + } + + [$req, $opts] = $next; + + // @phpstan-ignore-next-line argument.type + /** @var BaseResponse */ + $response = $this->client->request(...$req, convert: $this->convert, page: $this::class, options: $opts); + + // @phpstan-ignore-next-line return.type + return $response->parse(); + } + + /** + * Iterator yielding each page (instance of static). + * + * @return \Generator + */ + public function getIterator(): \Generator + { + $page = $this; + + yield $page; + while ($page->hasNextPage()) { + $page = $page->getNextPage(); + + yield $page; + } + } + + /** + * Iterator yielding each item across all pages. + * + * @return \Generator + */ + public function pagingEachItem(): \Generator + { + foreach ($this as $page) { + foreach ($page->getItems() as $item) { + yield $item; + } + } + } + + /** + * @internal + * + * @return array{NormalizedRequest, RequestOptions} + */ + abstract protected function nextRequest(): ?array; +} diff --git a/src/Core/Concerns/SdkParams.php b/src/Core/Concerns/SdkParams.php new file mode 100644 index 00000000..ab53ae51 --- /dev/null +++ b/src/Core/Concerns/SdkParams.php @@ -0,0 +1,36 @@ +|RequestOptions|null $options + * + * @return array{array, RequestOptions} + */ + public static function parseRequest(mixed $params, array|RequestOptions|null $options): array + { + $converter = self::converter(); + $state = new DumpState; + $dumped = (array) Conversion::dump($converter, value: $params, state: $state); + // @phpstan-ignore-next-line argument.type + $opts = RequestOptions::parse($options); + + if (!$state->canRetry) { + $opts->maxRetries = 0; + } + + // @phpstan-ignore-next-line return.type + return [$dumped, $opts]; + } +} diff --git a/src/Core/Concerns/SdkUnion.php b/src/Core/Concerns/SdkUnion.php new file mode 100644 index 00000000..90e3d812 --- /dev/null +++ b/src/Core/Concerns/SdkUnion.php @@ -0,0 +1,39 @@ +|list + */ + public static function variants(): array + { + return []; + } + + public static function converter(): Converter + { + if (isset(static::$converter)) { + return static::$converter; + } + + return static::$converter = new UnionOf(discriminator: static::discriminator(), variants: static::variants()); + } +} diff --git a/src/Core/Contracts/BaseModel.php b/src/Core/Contracts/BaseModel.php new file mode 100644 index 00000000..ec1fbe74 --- /dev/null +++ b/src/Core/Contracts/BaseModel.php @@ -0,0 +1,18 @@ + + */ +interface BaseModel extends \ArrayAccess, \JsonSerializable, \Stringable, ConverterSource +{ + /** @return array */ + public function toProperties(): array; +} diff --git a/src/Core/Contracts/BasePage.php b/src/Core/Contracts/BasePage.php new file mode 100644 index 00000000..d1fed191 --- /dev/null +++ b/src/Core/Contracts/BasePage.php @@ -0,0 +1,34 @@ + + */ +interface BasePage extends \IteratorAggregate +{ + public function hasNextPage(): bool; + + /** + * @return list + */ + public function getItems(): array; + + /** + * @return static + */ + public function getNextPage(): static; + + /** + * @return \Generator + */ + public function pagingEachItem(): \Generator; +} diff --git a/src/Core/Contracts/BaseResponse.php b/src/Core/Contracts/BaseResponse.php new file mode 100644 index 00000000..f5638ee4 --- /dev/null +++ b/src/Core/Contracts/BaseResponse.php @@ -0,0 +1,21 @@ + + */ +interface BaseStream extends \IteratorAggregate +{ + public function __construct( + Converter|ConverterSource|string $convert, + RequestInterface $request, + ResponseInterface $response, + mixed $parsedBody, + ); + + /** + * Manually force the stream to close early. + * Iterating through will automatically close as well. + */ + public function close(): void; +} diff --git a/src/Core/Conversion.php b/src/Core/Conversion.php new file mode 100644 index 00000000..2d89651f --- /dev/null +++ b/src/Core/Conversion.php @@ -0,0 +1,229 @@ + self::dump_unknown($v, state: $state), array: $value); + } + + if (is_object($value)) { + if ($value instanceof FileParam) { + return $value; + } + + if (is_a($value, class: ConverterSource::class)) { + return $value::converter()->dump($value, state: $state); + } + + if (is_a($value, class: \BackedEnum::class)) { + return $value->value; + } + + if (is_a($value, class: \DateTimeInterface::class)) { + return date_format($value, format: \DateTimeInterface::RFC3339); + } + + if (is_a($value, class: \JsonSerializable::class)) { + return $value->jsonSerialize(); + } + + $acc = get_object_vars($value); + + return empty($acc) ? (object) $acc : self::dump_unknown($acc, state: $state); + } + + return $value; + } + + public static function coerce(Converter|ConverterSource|string $target, mixed $value, CoerceState $state = new CoerceState): mixed + { + if ($value instanceof $target) { + ++$state->yes; + + return $value; + } + + if (is_a($target, class: ConverterSource::class, allow_string: true)) { + $target = $target::converter(); + } + + if ($target instanceof Converter) { + return $target->coerce($value, state: $state); + } + + // BackedEnum class-name targets: wrap in EnumOf so enum values are scored + // against the enum's cases. Without this, tryConvert's default case scores + // any class-name target as `no`, even when the value is a valid enum member. + if (is_a($target, class: \BackedEnum::class, allow_string: true)) { + return EnumOf::fromBackedEnum($target)->coerce($value, state: $state); + } + + return self::tryConvert($target, value: $value, state: $state); + } + + public static function dump(Converter|ConverterSource|string $target, mixed $value, DumpState $state = new DumpState): mixed + { + if ($target instanceof Converter) { + return $target->dump($value, state: $state); + } + + if (is_a($target, class: ConverterSource::class, allow_string: true)) { + return $target::converter()->dump($value, state: $state); + } + + // BackedEnum class-name targets: wrap in EnumOf so enum values are scored + // against the enum's cases. Without this, tryConvert's default case scores + // any class-name target as `no`, even when the value is a valid enum member. + if (is_a($target, class: \BackedEnum::class, allow_string: true)) { + return EnumOf::fromBackedEnum($target)->dump($value, state: $state); + } + + self::tryConvert($target, value: $value, state: $state); + + return self::dump_unknown($value, state: $state); + } + + private static function tryConvert(Converter|ConverterSource|string $target, mixed $value, CoerceState|DumpState $state): mixed + { + switch ($target) { + case 'mixed': + ++$state->yes; + + return $value; + + case 'null': + if (is_null($value)) { + ++$state->yes; + + return null; + } + + ++$state->maybe; + + return null; + + case 'bool': + if (is_bool($value)) { + ++$state->yes; + + return $value; + } + + ++$state->no; + + return $value; + + case 'int': + if (is_int($value)) { + ++$state->yes; + + return $value; + } + + if (is_float($value)) { + ++$state->maybe; + + return (int) $value; + } + + if (is_string($value) && ctype_digit($value)) { + ++$state->maybe; + + return (int) $value; + } + + ++$state->no; + + return $value; + + case 'float': + if (is_numeric($value)) { + ++$state->yes; + + return (float) $value; + } + + if (is_string($value) && is_numeric($value)) { + ++$state->maybe; + + return (float) $value; + } + + ++$state->no; + + return $value; + + case 'string': + if (is_string($value)) { + ++$state->yes; + + return $value; + } + + if (is_numeric($value)) { + ++$state->maybe; + + return (string) $value; + } + + if ($value instanceof \Generator) { + return implode('', iterator_to_array($value)); + } + + ++$state->no; + + 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; + + return $value; + } + } +} diff --git a/src/Core/Conversion/CoerceState.php b/src/Core/Conversion/CoerceState.php new file mode 100644 index 00000000..b1de64d7 --- /dev/null +++ b/src/Core/Conversion/CoerceState.php @@ -0,0 +1,19 @@ +type = $type ?? $enum ?? $union; + assert(!is_null($this->type)); + } + + public function coerce(mixed $value, CoerceState $state): mixed + { + if (!is_array($value)) { + return $value; + } + ++$state->yes; + + $acc = []; + foreach ($value as $k => $v) { + if ($this->nullable && is_null($v)) { + ++$state->yes; + $acc[$k] = null; + } else { + $acc[$k] = Conversion::coerce($this->type, value: $v, state: $state); + } + } + + return $acc; + } + + public function dump(mixed $value, DumpState $state): mixed + { + if (!is_array($value)) { + return Conversion::dump_unknown($value, state: $state); + } + ++$state->yes; + + if (empty($value)) { + return $this->empty(); + } + + $acc = []; + foreach ($value as $k => $v) { + if ($this->nullable && is_null($v)) { + ++$state->yes; + $acc[$k] = null; + } else { + $acc[$k] = Conversion::dump($this->type, value: $v, state: $state); + } + } + + return $acc; + } + + // @phpstan-ignore-next-line missingType.iterableValue + private function empty(): array|object + { + return (object) []; + } +} diff --git a/src/Core/Conversion/Contracts/Converter.php b/src/Core/Conversion/Contracts/Converter.php new file mode 100644 index 00000000..dadf46de --- /dev/null +++ b/src/Core/Conversion/Contracts/Converter.php @@ -0,0 +1,24 @@ +, self> */ + private static array $cache = []; + + /** + * @param list $members + */ + public function __construct(private readonly array $members) + { + $type = 'NULL'; + foreach ($this->members as $member) { + $type = gettype($member); + } + $this->type = $type; + } + + /** @param class-string<\BackedEnum> $enum */ + public static function fromBackedEnum(string $enum): self + { + // @phpstan-ignore-next-line argument.type + return self::$cache[$enum] ??= new self(array_column($enum::cases(), column_key: 'value')); + } + + public function coerce(mixed $value, CoerceState $state): mixed + { + $this->tally($value, state: $state); + + return $value; + } + + public function dump(mixed $value, DumpState $state): mixed + { + $this->tally($value, state: $state); + + return Conversion::dump_unknown($value, state: $state); + } + + private function tally(mixed $value, CoerceState|DumpState $state): void + { + $needle = $value instanceof \BackedEnum ? $value->value : $value; + if (in_array($needle, haystack: $this->members, strict: true)) { + ++$state->yes; + } elseif ($this->type === gettype($needle)) { + ++$state->maybe; + } else { + ++$state->no; + } + } +} diff --git a/src/Core/Conversion/ListOf.php b/src/Core/Conversion/ListOf.php new file mode 100644 index 00000000..31a262e6 --- /dev/null +++ b/src/Core/Conversion/ListOf.php @@ -0,0 +1,22 @@ + + */ + public readonly array $properties; + + /** + * @param \ReflectionClass $class + */ + public function __construct(public readonly \ReflectionClass $class) + { + $properties = []; + + foreach ($this->class->getProperties() as $property) { + $attributes = [...$property->getAttributes(Required::class), ...$property->getAttributes(Optional::class)]; + + if (!empty($attributes)) { + $name = $property->getName(); + $properties[$name] = new PropertyInfo($property); + } + } + $this->properties = $properties; + } + + public function coerce(mixed $value, CoerceState $state): mixed + { + if ($value instanceof $this->class->name) { + ++$state->yes; + + return $value; + } + + if (!is_array($value) || (!empty($value) && array_is_list($value))) { + ++$state->no; + + return $value; + } + + ++$state->yes; + + $val = [...$value]; + $acc = []; + + foreach ($this->properties as $name => $info) { + $srcName = $state->translateNames ? $info->apiName : $name; + if (!array_key_exists($srcName, array: $val)) { + if ($info->optional) { + ++$state->yes; + } elseif ($info->nullable) { + ++$state->maybe; + } else { + ++$state->no; + } + + continue; + } + + $item = $val[$srcName]; + unset($val[$srcName]); + + if (is_null($item) && ($info->nullable || $info->optional)) { + if ($info->nullable) { + ++$state->yes; + } elseif ($info->optional) { + ++$state->maybe; + } + $acc[$name] = null; + } else { + $coerced = Conversion::coerce($info->type, value: $item, state: $state); + $acc[$name] = $coerced; + } + } + + foreach ($val as $name => $item) { + $acc[$name] = $item; + } + + // @phpstan-ignore-next-line return.type + return $this->from($acc); + } + + public function dump(mixed $value, DumpState $state): mixed + { + if ($value instanceof BaseModel) { + $value = $value->toProperties(); + } + + if (is_array($value)) { + ++$state->yes; + $acc = []; + + foreach ($value as $name => $item) { + if (array_key_exists($name, array: $this->properties)) { + ++$state->yes; + $info = $this->properties[$name]; + $acc[$info->apiName] = Conversion::dump($info->type, value: $item, state: $state); + } else { + $acc[$name] = Conversion::dump_unknown($item, state: $state); + } + } + + return empty($acc) ? ((object) $acc) : $acc; + } + + ++$state->no; + + return Conversion::dump_unknown($value, state: $state); + } + + /** + * @param array $data + */ + public function from(array $data): BaseModel + { + $instance = $this->class->newInstanceWithoutConstructor(); + // @phpstan-ignore-next-line + $instance->__unserialize($data); + + return $instance; + } +} diff --git a/src/Core/Conversion/PropertyInfo.php b/src/Core/Conversion/PropertyInfo.php new file mode 100644 index 00000000..0cebd935 --- /dev/null +++ b/src/Core/Conversion/PropertyInfo.php @@ -0,0 +1,79 @@ +getType()?->allowsNull() ?? false; + + $apiName = $property->getName(); + $type = $property->getType(); + $optional = false; + $attributes = [...$property->getAttributes(Required::class), ...$property->getAttributes(Optional::class)]; + + foreach ($attributes as $attr) { + /** @var Required $attribute */ + $attribute = $attr->newInstance(); + + $apiName = $attribute->apiName ?? $apiName; + $optional = $attribute->optional; + $nullable |= $attribute->nullable; + $type = $attribute->type ?? $type; + } + + $this->apiName = $apiName; + $this->type = self::parse($type); + $this->nullable = (bool) $nullable; + $this->optional = $optional; + } + + /** + * @param array|Converter|ConverterSource|\ReflectionType|string|null $type + */ + private static function parse(array|Converter|ConverterSource|\ReflectionType|string|null $type): Converter|ConverterSource|string + { + if (is_string($type) || $type instanceof Converter) { + return $type; + } + + if (is_array($type)) { + // @phpstan-ignore-next-line return.type + return new UnionOf($type); + } + + if ($type instanceof \ReflectionUnionType) { + // @phpstan-ignore-next-line argument.type + return new UnionOf(array_map(static fn ($t) => self::parse($t), array: $type->getTypes())); + } + + if ($type instanceof \ReflectionNamedType) { + return $type->getName(); + } + + if ($type instanceof \ReflectionIntersectionType) { + throw new \ValueError; + } + + return 'mixed'; + } +} diff --git a/src/Core/Conversion/UnionOf.php b/src/Core/Conversion/UnionOf.php new file mode 100644 index 00000000..181643c8 --- /dev/null +++ b/src/Core/Conversion/UnionOf.php @@ -0,0 +1,132 @@ +|list $variants + */ + public function __construct( + private readonly array $variants, + private readonly ?string $discriminator = null, + ) {} + + public function coerce(mixed $value, CoerceState $state): mixed + { + if (!is_null($target = $this->resolveVariant(value: $value))) { + return Conversion::coerce($target, value: $value, state: $state); + } + + $alternatives = []; + foreach ($this->variants as $_ => $variant) { + ++$state->branched; + $newState = new CoerceState; + + $coerced = Conversion::coerce($variant, value: $value, state: $newState); + if (($newState->no + $newState->maybe) === 0) { + $state->yes += $newState->yes; + + return $coerced; + } + if ($newState->maybe > 0) { + $alternatives[] = [[-$newState->yes, -$newState->maybe, $newState->no], $newState, $coerced]; + } + } + + usort( + $alternatives, + static fn (array $a, array $b): int => $a[0][0] <=> $b[0][0] ?: $a[0][1] <=> $b[0][1] ?: $a[0][2] <=> $b[0][2] + ); + + if (empty($alternatives)) { + ++$state->no; + + return $value; + } + + [[,$newState, $best]] = $alternatives; + $state->yes += $newState->yes; + $state->maybe += $newState->maybe; + $state->no += $newState->no; + + return $best; + } + + public function dump(mixed $value, DumpState $state): mixed + { + if (!is_null($target = $this->resolveVariant(value: $value))) { + return Conversion::dump($target, value: $value, state: $state); + } + + $alternatives = []; + foreach ($this->variants as $_ => $variant) { + ++$state->branched; + if ($value instanceof $variant) { + return Conversion::dump($variant, value: $value, state: $state); + } + + $newState = new DumpState; + $dumped = Conversion::dump($variant, value: $value, state: $newState); + if (($newState->no + $newState->maybe) === 0) { + $state->yes += $newState->yes; + + return $dumped; + } + if ($newState->maybe > 0) { + $alternatives[] = [[-$newState->yes, -$newState->maybe, $newState->no], $newState, $dumped]; + } + } + + usort( + $alternatives, + static fn (array $a, array $b): int => $a[0][0] <=> $b[0][0] ?: $a[0][1] <=> $b[0][1] ?: $a[0][2] <=> $b[0][2] + ); + + if (empty($alternatives)) { + ++$state->no; + + return Conversion::dump_unknown($value, state: $state); + } + + [[,$newState, $best]] = $alternatives; + $state->yes += $newState->yes; + $state->maybe += $newState->maybe; + $state->no += $newState->no; + + return $best; + } + + private function resolveVariant( + mixed $value, + ): Converter|ConverterSource|string|null { + if ($value instanceof BaseModel) { + return $value::class; + } + + if ( + null !== $this->discriminator + && is_array($value) + && array_key_exists($this->discriminator, array: $value) + ) { + $discriminator = $value[$this->discriminator]; + if (!is_string($discriminator)) { + return null; + } + + return $this->variants[$discriminator] ?? null; + } + + return null; + } +} diff --git a/src/Core/Exceptions/APIConnectionException.php b/src/Core/Exceptions/APIConnectionException.php new file mode 100644 index 00000000..c897edb5 --- /dev/null +++ b/src/Core/Exceptions/APIConnectionException.php @@ -0,0 +1,9 @@ +response = $response; + $this->status = $response->getStatusCode(); + + $summary = Util::prettyEncodeJson(['status' => $this->status, 'body' => Util::decodeJson($response->getBody())]); + + if ('' != $message) { + $summary .= $message.PHP_EOL.$summary; + } + + parent::__construct(request: $request, message: $summary, previous: $previous); + } + + public static function from( + RequestInterface $request, + ResponseInterface $response, + string $message = '' + ): self { + $status = $response->getStatusCode(); + + $cls = match (true) { + 400 === $status => BadRequestException::class, + 401 === $status => AuthenticationException::class, + 403 === $status => PermissionDeniedException::class, + 404 === $status => NotFoundException::class, + 409 === $status => ConflictException::class, + 422 === $status => UnprocessableEntityException::class, + 429 === $status => RateLimitException::class, + $status >= 500 => InternalServerException::class, + default => APIStatusException::class + }; + + return new $cls(request: $request, response: $response, message: $message); + } +} diff --git a/src/Core/Exceptions/APITimeoutException.php b/src/Core/Exceptions/APITimeoutException.php new file mode 100644 index 00000000..94d0216a --- /dev/null +++ b/src/Core/Exceptions/APITimeoutException.php @@ -0,0 +1,19 @@ +files->upload(file: FileParam::fromResource(fopen('data.csv', 'r'))); + * + * // From a string: + * $client->files->upload(file: FileParam::fromString('csv data...', 'data.csv')); + * ``` + */ +final class FileParam +{ + public const DEFAULT_CONTENT_TYPE = 'application/octet-stream'; + + /** + * @param resource|string $data the file content as a resource or string + */ + private function __construct( + public readonly mixed $data, + public readonly string $filename, + public readonly string $contentType = self::DEFAULT_CONTENT_TYPE, + ) {} + + /** + * Create a FileParam from an open resource (e.g. from fopen()). + * + * @param resource $resource an open file resource + * @param string|null $filename Override the filename. Defaults to the resource URI basename. + * @param string $contentType override the content type + */ + public static function fromResource(mixed $resource, ?string $filename = null, string $contentType = self::DEFAULT_CONTENT_TYPE): self + { + if (!is_resource($resource)) { + throw new \InvalidArgumentException('Expected a resource, got '.get_debug_type($resource)); + } + + if (is_null($filename)) { + $meta = stream_get_meta_data($resource); + $filename = basename($meta['uri'] ?? 'upload'); + } + + return new self($resource, filename: $filename, contentType: $contentType); + } + + /** + * Create a FileParam from a string. + * + * @param string $content the file content + * @param string $filename the filename for the Content-Disposition header + * @param string $contentType override the content type + */ + public static function fromString(string $content, string $filename, string $contentType = self::DEFAULT_CONTENT_TYPE): self + { + return new self($content, filename: $filename, contentType: $contentType); + } +} diff --git a/src/Core/Implementation/RawResponse.php b/src/Core/Implementation/RawResponse.php new file mode 100644 index 00000000..2e0c8f5b --- /dev/null +++ b/src/Core/Implementation/RawResponse.php @@ -0,0 +1,106 @@ + + */ +class RawResponse implements BaseResponse +{ + use ResponseProxy; + + private mixed $decodedBody; + + /** @var R */ + private mixed $coercedResponse; + + private bool $decoded = false; + private bool $coerced = false; + + /** + * @param NormalizedRequest $requestInfo + * @param list|string|int|null $unwrap + */ + public function __construct( + private BaseClient $client, + private RequestOptions $options, + private RequestInterface $request, + private ResponseInterface $response, + private array $requestInfo, + private array|string|int|null $unwrap, + private Converter|ConverterSource|string $convert, + private ?string $page, + private ?string $stream, + ) {} + + public function getRequest(): RequestInterface + { + return $this->request; + } + + public function parse(): mixed + { + if (!$this->coerced) { + if (!is_null($this->stream)) { + // @phpstan-ignore-next-line assign.propertyType + $this->coercedResponse = new $this->stream( + convert: $this->convert, + request: $this->request, + response: $this->response, + parsedBody: $this->getDecoded(), + ); + } elseif (!is_null($this->page)) { + // @phpstan-ignore-next-line assign.propertyType + $this->coercedResponse = new $this->page( + convert: $this->convert, + client: $this->client, + requestInfo: $this->requestInfo, + options: $this->options, + response: $this->response, + parsedBody: $this->getDecoded(), + ); + } else { + // @phpstan-ignore-next-line assign.propertyType + $this->coercedResponse = Conversion::coerce( + $this->convert, + value: $this->getDecoded(), + ); + } + + $this->coerced = true; + } + + return $this->coercedResponse; + } + + private function getDecoded(): mixed + { + if (!$this->decoded) { + $decoded = Util::decodeContent($this->response); + if (!is_null($this->unwrap)) { + $decoded = Util::dig($decoded, key: $this->unwrap); + } + $this->decodedBody = $decoded; + $this->decoded = true; + } + + return $this->decodedBody; + } +} diff --git a/src/Core/Implementation/StreamingHttpClient.php b/src/Core/Implementation/StreamingHttpClient.php new file mode 100644 index 00000000..6beb2593 --- /dev/null +++ b/src/Core/Implementation/StreamingHttpClient.php @@ -0,0 +1,29 @@ +inner, '\GuzzleHttp\Client')) { + return $this->inner->send($request, ['stream' => true]); + } + + return $this->inner->sendRequest($request); + } +} diff --git a/src/Core/Util.php b/src/Core/Util.php new file mode 100644 index 00000000..4b60030b --- /dev/null +++ b/src/Core/Util.php @@ -0,0 +1,577 @@ + + */ + public static function get_object_vars(object $object): array + { + return get_object_vars($object); + } + + public static function machtype(): string + { + $arch = php_uname('m'); + + return match (true) { + str_contains($arch, 'aarch64'), str_contains($arch, 'arm64') => 'arm64', + str_contains($arch, 'x86_64'), str_contains($arch, 'amd64') => 'x64', + str_contains($arch, 'i386'), str_contains($arch, 'i686') => 'x32', + str_contains($arch, 'arm') => 'arm', + default => 'unknown', + }; + } + + public static function ostype(): string + { + return match ($os = strtolower(PHP_OS_FAMILY)) { + 'linux' => 'Linux', + 'darwin' => 'MacOS', + 'windows' => 'Windows', + 'solaris' => 'Solaris', + // @phpstan-ignore-next-line match.alwaysFalse + 'bsd', 'freebsd', 'openbsd' => 'BSD', + default => "Other:{$os}", + }; + } + + /** + * @template T + * + * @param array $array + * @param array $map + * + * @return array + */ + public static function array_transform_keys(array $array, array $map): array + { + $acc = []; + foreach ($array as $key => $value) { + $acc[$map[$key] ?? $key] = $value; + } + + return $acc; + } + + public static function strVal(mixed $value): string + { + if (is_bool($value)) { + return $value ? 'true' : 'false'; + } + + if (is_object($value) && is_a($value, class: \DateTimeInterface::class)) { + return date_format($value, format: \DateTimeInterface::RFC3339); + } + + // @phpstan-ignore-next-line argument.type + return strval($value); + } + + /** + * @param callable $callback + */ + public static function mapRecursive(mixed $callback, mixed $value): mixed + { + $mapped = match (true) { + is_array($value) => array_map(static fn ($v) => self::mapRecursive($callback, value: $v), $value), + default => $value, + }; + + return $callback($mapped); + } + + public static function removeNulls(mixed $value): mixed + { + $mapped = self::mapRecursive( + static fn ($vs) => is_array($vs) && !array_is_list($vs) ? array_filter($vs, callback: static fn ($v) => !is_null($v)) : $vs, + value: $value + ); + + return $mapped; + } + + /** + * @param string|int|list|callable $key + */ + public static function dig( + mixed $array, + string|int|array|callable $key + ): mixed { + if (is_callable($key)) { + return $key($array); + } + + if (is_array($array)) { + if ((is_string($key) || is_int($key)) && array_key_exists($key, array: $array)) { + return $array[$key]; + } + + if (is_array($key) && !empty($key)) { + if (array_key_exists($fst = $key[0], array: $array)) { + return self::dig($array[$fst], key: array_slice($key, 1)); + } + } + } + + return null; + } + + /** + * @param string|list $path + */ + public static function parsePath(string|array $path): string + { + if (is_string($path)) { + return $path; + } + + if (empty($path)) { + return ''; + } + + [$template] = $path; + $mapped = array_map(static fn ($s) => rawurlencode(self::strVal($s)), array: array_slice($path, 1)); + + return sprintf($template, ...$mapped); + } + + /** + * @param array $query + */ + public static function joinUri( + UriInterface $base, + string $path, + array $query = [] + ): UriInterface { + $parsed = parse_url($path); + if ($scheme = $parsed['scheme'] ?? null) { + $base = $base->withScheme($scheme); + } + if ($host = $parsed['host'] ?? null) { + $base = $base->withHost($host); + } + if ($port = $parsed['port'] ?? null) { + $base = $base->withPort($port); + } + if (($user = $parsed['user'] ?? null) || ($pass = $parsed['pass'] ?? null)) { + $base = $base->withUserInfo($user ?? '', $pass ?? null); + } + if ($path = $parsed['path'] ?? null) { + $base = str_starts_with($path, '/') ? $base->withPath($path) : $base->withPath($base->getPath().'/'.$path); + } + + [$q1, $q2] = [[], []]; + parse_str($base->getQuery(), $q1); + parse_str($parsed['query'] ?? '', $q2); + + $mergedQuery = array_merge_recursive($q1, $q2, $query); + + /** @var array */ + $normalizedQuery = self::mapRecursive( + static fn ($v) => is_bool($v) || is_numeric($v) ? self::strVal($v) : $v, + value: $mergedQuery + ); + $qs = http_build_query($normalizedQuery, encoding_type: PHP_QUERY_RFC3986); + + return $base->withQuery($qs); + } + + public static function isStreamingRequest(RequestInterface $request): bool + { + $accept = $request->getHeaderLine('Accept'); + + return !empty(array_filter( + self::STREAMING_CONTENT_TYPE, + static fn (string $pattern) => (bool) preg_match($pattern, subject: $accept), + )); + } + + /** + * @param array|null> $headers + */ + public static function withSetHeaders( + RequestInterface $req, + array $headers + ): RequestInterface { + foreach ($headers as $name => $value) { + if (is_null($value)) { + /** @var RequestInterface */ + $req = $req->withoutHeader($name); + } else { + $value = is_array($value) ? array_map(static fn ($v) => self::strVal($v), array: $value) : self::strVal($value); + + /** @var RequestInterface */ + $req = $req->withHeader($name, $value); + } + } + + return $req; + } + + /** + * @return \Iterator + */ + public static function streamIterator(StreamInterface $stream): \Iterator + { + if (!$stream->isReadable()) { + return; + } + + try { + while (!$stream->eof()) { + yield $stream->read(self::BUF_SIZE); + } + } finally { + $stream->close(); + } + } + + /** + * @param bool|int|float|string|resource|\Traversable|array|null $body + */ + public static function withSetBody( + StreamFactoryInterface $factory, + RequestInterface $req, + mixed $body + ): RequestInterface { + if ($body instanceof StreamInterface) { + /** @var RequestInterface */ + return $req->withBody($body); + } + + $contentType = $req->getHeaderLine('Content-Type'); + if (preg_match(self::JSON_CONTENT_TYPE, $contentType)) { + if (is_array($body) || is_object($body)) { + $encoded = json_encode($body, flags: self::JSON_ENCODE_FLAGS); + $stream = $factory->createStream($encoded); + + /** @var RequestInterface */ + return $req->withBody($stream); + } + } + + if (preg_match('/^multipart\/form-data/', $contentType)) { + [$boundary, $gen] = self::encodeMultipartStreaming($body); + $encoded = implode('', iterator_to_array($gen, preserve_keys: false)); + $stream = $factory->createStream($encoded); + + /** @var RequestInterface */ + return $req->withHeader('Content-Type', "{$contentType}; boundary={$boundary}")->withBody($stream); + } + + if (is_resource($body)) { + $stream = $factory->createStreamFromResource($body); + + /** @var RequestInterface */ + return $req->withBody($stream); + } + + if (is_string($body)) { + $stream = $factory->createStream($body); + + // @var RequestInterface + return $req->withBody($stream); + } + + return $req; + } + + /** + * @param \Iterator $stream + * + * @return \Iterator + */ + public static function decodeLines(\Iterator $stream): \Iterator + { + $buf = ''; + foreach ($stream as $chunk) { + $buf .= $chunk; + while (($pos = strpos($buf, "\n")) !== false) { + yield substr($buf, 0, $pos); + $buf = substr($buf, $pos + 1); + } + } + if ('' !== $buf) { + yield $buf; + } + } + + /** + * @param \Iterator $lines + * + * @return \Generator + */ + public static function decodeSSE(\Iterator $lines): \Generator + { + $blank = ['event' => null, 'data' => null, 'id' => null, 'retry' => null]; + $acc = []; + + foreach ($lines as $line) { + $line = rtrim($line); + if ('' === $line) { + if (empty($acc)) { + continue; + } + + yield [...$blank, ...$acc]; + $acc = []; + } + + if (str_starts_with($line, ':')) { + continue; + } + + $matches = []; + if (preg_match('/^([^:]+):\s?(.*)$/', $line, $matches)) { + [, $field, $value] = $matches; + + switch ($field) { + case 'event': + $acc['event'] = $value; + + break; + + case 'data': + if (isset($acc['data'])) { + $acc['data'] .= "\n".$value; + } else { + $acc['data'] = $value; + } + + break; + + case 'id': + $acc['id'] = $value; + + break; + + case 'retry': + $acc['retry'] = (int) $value; + + break; + } + } + } + + if (!empty($acc)) { + yield [...$blank, ...$acc]; + } + } + + public static function decodeJson(string $json): mixed + { + return json_decode($json, associative: true, flags: JSON_THROW_ON_ERROR); + } + + public static function decodeContent(ResponseInterface $rsp): mixed + { + if (204 == $rsp->getStatusCode()) { + return null; + } + + $content_type = $rsp->getHeaderLine('Content-Type'); + $body = $rsp->getBody(); + + if (preg_match(self::JSON_CONTENT_TYPE, subject: $content_type)) { + $json = $body->getContents(); + + return self::decodeJson($json); + } + + if (preg_match(self::JSONL_CONTENT_TYPE, subject: $content_type)) { + $it = self::streamIterator($body); + $lines = self::decodeLines($it); + + return (function () use ($lines) { + foreach ($lines as $line) { + yield static::decodeJson($line); + } + })(); + } + + if (str_contains($content_type, needle: 'text/event-stream')) { + $it = self::streamIterator($body); + $lines = self::decodeLines($it); + + return self::decodeSSE($lines); + } + + return self::streamIterator($body); + } + + public static function prettyEncodeJson(mixed $obj): string + { + return json_encode($obj, flags: JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) ?: ''; + } + + /** + * @param list $closing + * + * @return \Generator + */ + private static function writeMultipartContent( + mixed $val, + array &$closing, + ?string $contentType = null + ): \Generator { + $contentLine = "Content-Type: %s\r\n\r\n"; + + if ($val instanceof FileParam) { + $ct = $val->contentType ?? $contentType; + + yield sprintf($contentLine, $ct); + $data = $val->data; + if (is_string($data)) { + yield $data; + } else { // resource + while (!feof($data)) { + if ($read = fread($data, length: self::BUF_SIZE)) { + yield $read; + } + } + } + } elseif (is_string($val) || is_numeric($val) || is_bool($val)) { + yield sprintf($contentLine, $contentType ?? 'text/plain'); + + yield self::strVal($val); + } else { + yield sprintf($contentLine, $contentType ?? 'application/json'); + + yield json_encode($val, flags: self::JSON_ENCODE_FLAGS); + } + + yield "\r\n"; + } + + /** + * @param list $closing + * + * @return \Generator + */ + private static function writeMultipartChunk( + string $boundary, + ?string $key, + mixed $val, + array &$closing + ): \Generator { + yield "--{$boundary}\r\n"; + + yield 'Content-Disposition: form-data'; + + if (!is_null($key)) { + $name = str_replace(['"', "\r", "\n"], replace: '', subject: $key); + + yield "; name=\"{$name}\""; + } + + // File uploads require a filename in the Content-Disposition header, + // e.g. `Content-Disposition: form-data; name="file"; filename="data.csv"` + // Without this, many servers will reject the upload with a 400. + if ($val instanceof FileParam) { + $filename = str_replace(['"', "\r", "\n"], replace: '', subject: $val->filename); + + yield "; filename=\"{$filename}\""; + } + + yield "\r\n"; + foreach (self::writeMultipartContent($val, closing: $closing) as $chunk) { + yield $chunk; + } + } + + /** + * Expands list arrays into separate multipart parts, applying the configured array key format. + * + * @param list $closing + * + * @return \Generator + */ + private static function writeMultipartField( + string $boundary, + ?string $key, + mixed $val, + array &$closing + ): \Generator { + if (is_array($val) && array_is_list($val)) { + foreach ($val as $item) { + yield from self::writeMultipartField(boundary: $boundary, key: $key, val: $item, closing: $closing); + } + } else { + yield from self::writeMultipartChunk(boundary: $boundary, key: $key, val: $val, closing: $closing); + } + } + + /** + * @param bool|int|float|string|resource|\Traversable|array|null $body + * + * @return array{string, \Generator} + */ + private static function encodeMultipartStreaming(mixed $body): array + { + $boundary = rtrim(strtr(base64_encode(random_bytes(60)), '+/', '-_'), '='); + $gen = (function () use ($boundary, $body) { + $closing = []; + + try { + if (is_array($body) || is_object($body)) { + foreach ((array) $body as $key => $val) { + yield from static::writeMultipartField(boundary: $boundary, key: $key, val: $val, closing: $closing); + } + } else { + yield from static::writeMultipartField(boundary: $boundary, key: null, val: $body, closing: $closing); + } + + yield "--{$boundary}--\r\n"; + } finally { + foreach ($closing as $c) { + $c(); + } + } + })(); + + return [$boundary, $gen]; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataField.php b/src/CustomMetadataFields/CustomMetadataField.php new file mode 100644 index 00000000..415487b0 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataField.php @@ -0,0 +1,141 @@ + */ + use SdkModel; + + /** + * Unique identifier for the custom metadata field. Use this to update the field. + */ + #[Required] + public string $id; + + /** + * Human readable name of the custom metadata field. This name is displayed as form field label to the users while setting field value on the asset in the media library UI. + */ + #[Required] + public string $label; + + /** + * API name of the custom metadata field. This becomes the key while setting `customMetadata` (key-value object) for an asset using upload or update API. + */ + #[Required] + public string $name; + + /** + * An object that describes the rules for the custom metadata field value. + */ + #[Required] + public Schema $schema; + + /** + * `new CustomMetadataField()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * CustomMetadataField::with(id: ..., label: ..., name: ..., schema: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new CustomMetadataField) + * ->withID(...) + * ->withLabel(...) + * ->withName(...) + * ->withSchema(...) + * ``` + */ + 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 Schema|SchemaShape $schema + */ + public static function with( + string $id, + string $label, + string $name, + Schema|array $schema + ): self { + $self = new self; + + $self['id'] = $id; + $self['label'] = $label; + $self['name'] = $name; + $self['schema'] = $schema; + + return $self; + } + + /** + * Unique identifier for the custom metadata field. Use this to update the field. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Human readable name of the custom metadata field. This name is displayed as form field label to the users while setting field value on the asset in the media library UI. + */ + public function withLabel(string $label): self + { + $self = clone $this; + $self['label'] = $label; + + return $self; + } + + /** + * API name of the custom metadata field. This becomes the key while setting `customMetadata` (key-value object) for an asset using upload or update API. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * An object that describes the rules for the custom metadata field value. + * + * @param Schema|SchemaShape $schema + */ + public function withSchema(Schema|array $schema): self + { + $self = clone $this; + $self['schema'] = $schema; + + return $self; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataField/Schema.php b/src/CustomMetadataFields/CustomMetadataField/Schema.php new file mode 100644 index 00000000..18e262ba --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataField/Schema.php @@ -0,0 +1,254 @@ +, + * defaultValue?: DefaultValueShape|null, + * isValueRequired?: bool|null, + * maxLength?: float|null, + * maxValue?: MaxValueShape|null, + * minLength?: float|null, + * minValue?: MinValueShape|null, + * selectOptions?: list|null, + * } + */ +final class Schema implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of the custom metadata field. + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * The default value for this custom metadata field. Data type of default value depends on the field type. + * + * @var DefaultValueVariants|null $defaultValue + */ + #[Optional(union: DefaultValue::class)] + public string|float|bool|array|null $defaultValue; + + /** + * Specifies if the this custom metadata field is required or not. + */ + #[Optional] + public ?bool $isValueRequired; + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $maxLength; + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MaxValueVariants|null $maxValue + */ + #[Optional] + public string|float|null $maxValue; + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $minLength; + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MinValueVariants|null $minValue + */ + #[Optional] + public string|float|null $minValue; + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @var list|null $selectOptions + */ + #[Optional(list: SelectOption::class)] + public ?array $selectOptions; + + /** + * `new Schema()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Schema::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Schema)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param DefaultValueShape|null $defaultValue + * @param MaxValueShape|null $maxValue + * @param MinValueShape|null $minValue + * @param list|null $selectOptions + */ + public static function with( + Type|string $type, + string|float|bool|array|null $defaultValue = null, + ?bool $isValueRequired = null, + ?float $maxLength = null, + string|float|null $maxValue = null, + ?float $minLength = null, + string|float|null $minValue = null, + ?array $selectOptions = null, + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $defaultValue && $self['defaultValue'] = $defaultValue; + null !== $isValueRequired && $self['isValueRequired'] = $isValueRequired; + null !== $maxLength && $self['maxLength'] = $maxLength; + null !== $maxValue && $self['maxValue'] = $maxValue; + null !== $minLength && $self['minLength'] = $minLength; + null !== $minValue && $self['minValue'] = $minValue; + null !== $selectOptions && $self['selectOptions'] = $selectOptions; + + return $self; + } + + /** + * Type of the custom metadata field. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * The default value for this custom metadata field. Data type of default value depends on the field type. + * + * @param DefaultValueShape $defaultValue + */ + public function withDefaultValue( + string|float|bool|array $defaultValue + ): self { + $self = clone $this; + $self['defaultValue'] = $defaultValue; + + return $self; + } + + /** + * Specifies if the this custom metadata field is required or not. + */ + public function withIsValueRequired(bool $isValueRequired): self + { + $self = clone $this; + $self['isValueRequired'] = $isValueRequired; + + return $self; + } + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMaxLength(float $maxLength): self + { + $self = clone $this; + $self['maxLength'] = $maxLength; + + return $self; + } + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MaxValueShape $maxValue + */ + public function withMaxValue(string|float $maxValue): self + { + $self = clone $this; + $self['maxValue'] = $maxValue; + + return $self; + } + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMinLength(float $minLength): self + { + $self = clone $this; + $self['minLength'] = $minLength; + + return $self; + } + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MinValueShape $minValue + */ + public function withMinValue(string|float $minValue): self + { + $self = clone $this; + $self['minValue'] = $minValue; + + return $self; + } + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @param list $selectOptions + */ + public function withSelectOptions(array $selectOptions): self + { + $self = clone $this; + $self['selectOptions'] = $selectOptions; + + return $self; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataField/Schema/DefaultValue.php b/src/CustomMetadataFields/CustomMetadataField/Schema/DefaultValue.php new file mode 100644 index 00000000..16fb1365 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataField/Schema/DefaultValue.php @@ -0,0 +1,32 @@ + + * @phpstan-type DefaultValueShape = DefaultValueVariants|list + */ +final class DefaultValue implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataField/Schema/DefaultValue/Mixed_.php b/src/CustomMetadataFields/CustomMetadataField/Schema/DefaultValue/Mixed_.php new file mode 100644 index 00000000..eb6905b8 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataField/Schema/DefaultValue/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataField/Schema/MaxValue.php b/src/CustomMetadataFields/CustomMetadataField/Schema/MaxValue.php new file mode 100644 index 00000000..19073221 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataField/Schema/MaxValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataField/Schema/MinValue.php b/src/CustomMetadataFields/CustomMetadataField/Schema/MinValue.php new file mode 100644 index 00000000..cf627712 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataField/Schema/MinValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataField/Schema/SelectOption.php b/src/CustomMetadataFields/CustomMetadataField/Schema/SelectOption.php new file mode 100644 index 00000000..501e46fd --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataField/Schema/SelectOption.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataField/Schema/Type.php b/src/CustomMetadataFields/CustomMetadataField/Schema/Type.php new file mode 100644 index 00000000..3c5e1691 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataField/Schema/Type.php @@ -0,0 +1,25 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. + */ + #[Required] + public string $label; + + /** + * API name of the custom metadata field. This should be unique across all (including deleted) custom metadata fields. + */ + #[Required] + public string $name; + + #[Required] + public Schema $schema; + + /** + * `new CustomMetadataFieldCreateParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * CustomMetadataFieldCreateParams::with(label: ..., name: ..., schema: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new CustomMetadataFieldCreateParams) + * ->withLabel(...) + * ->withName(...) + * ->withSchema(...) + * ``` + */ + 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 Schema|SchemaShape $schema + */ + public static function with( + string $label, + string $name, + Schema|array $schema + ): self { + $self = new self; + + $self['label'] = $label; + $self['name'] = $name; + $self['schema'] = $schema; + + return $self; + } + + /** + * Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. + */ + public function withLabel(string $label): self + { + $self = clone $this; + $self['label'] = $label; + + return $self; + } + + /** + * API name of the custom metadata field. This should be unique across all (including deleted) custom metadata fields. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * @param Schema|SchemaShape $schema + */ + public function withSchema(Schema|array $schema): self + { + $self = clone $this; + $self['schema'] = $schema; + + return $self; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema.php b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema.php new file mode 100644 index 00000000..0e699657 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema.php @@ -0,0 +1,252 @@ +, + * defaultValue?: DefaultValueShape|null, + * isValueRequired?: bool|null, + * maxLength?: float|null, + * maxValue?: MaxValueShape|null, + * minLength?: float|null, + * minValue?: MinValueShape|null, + * selectOptions?: list|null, + * } + */ +final class Schema implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of the custom metadata field. + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field. + * + * @var DefaultValueVariants|null $defaultValue + */ + #[Optional(union: DefaultValue::class)] + public string|float|bool|array|null $defaultValue; + + /** + * Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body. + */ + #[Optional] + public ?bool $isValueRequired; + + /** + * Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $maxLength; + + /** + * Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value. + * + * @var MaxValueVariants|null $maxValue + */ + #[Optional] + public string|float|null $maxValue; + + /** + * Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $minLength; + + /** + * Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value. + * + * @var MinValueVariants|null $minValue + */ + #[Optional] + public string|float|null $minValue; + + /** + * An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`. + * + * @var list|null $selectOptions + */ + #[Optional(list: SelectOption::class)] + public ?array $selectOptions; + + /** + * `new Schema()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Schema::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Schema)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param DefaultValueShape|null $defaultValue + * @param MaxValueShape|null $maxValue + * @param MinValueShape|null $minValue + * @param list|null $selectOptions + */ + public static function with( + Type|string $type, + string|float|bool|array|null $defaultValue = null, + ?bool $isValueRequired = null, + ?float $maxLength = null, + string|float|null $maxValue = null, + ?float $minLength = null, + string|float|null $minValue = null, + ?array $selectOptions = null, + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $defaultValue && $self['defaultValue'] = $defaultValue; + null !== $isValueRequired && $self['isValueRequired'] = $isValueRequired; + null !== $maxLength && $self['maxLength'] = $maxLength; + null !== $maxValue && $self['maxValue'] = $maxValue; + null !== $minLength && $self['minLength'] = $minLength; + null !== $minValue && $self['minValue'] = $minValue; + null !== $selectOptions && $self['selectOptions'] = $selectOptions; + + return $self; + } + + /** + * Type of the custom metadata field. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field. + * + * @param DefaultValueShape $defaultValue + */ + public function withDefaultValue( + string|float|bool|array $defaultValue + ): self { + $self = clone $this; + $self['defaultValue'] = $defaultValue; + + return $self; + } + + /** + * Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body. + */ + public function withIsValueRequired(bool $isValueRequired): self + { + $self = clone $this; + $self['isValueRequired'] = $isValueRequired; + + return $self; + } + + /** + * Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`. + */ + public function withMaxLength(float $maxLength): self + { + $self = clone $this; + $self['maxLength'] = $maxLength; + + return $self; + } + + /** + * Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value. + * + * @param MaxValueShape $maxValue + */ + public function withMaxValue(string|float $maxValue): self + { + $self = clone $this; + $self['maxValue'] = $maxValue; + + return $self; + } + + /** + * Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`. + */ + public function withMinLength(float $minLength): self + { + $self = clone $this; + $self['minLength'] = $minLength; + + return $self; + } + + /** + * Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value. + * + * @param MinValueShape $minValue + */ + public function withMinValue(string|float $minValue): self + { + $self = clone $this; + $self['minValue'] = $minValue; + + return $self; + } + + /** + * An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`. + * + * @param list $selectOptions + */ + public function withSelectOptions(array $selectOptions): self + { + $self = clone $this; + $self['selectOptions'] = $selectOptions; + + return $self; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/DefaultValue.php b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/DefaultValue.php new file mode 100644 index 00000000..783cbc57 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/DefaultValue.php @@ -0,0 +1,32 @@ + + * @phpstan-type DefaultValueShape = DefaultValueVariants|list + */ +final class DefaultValue implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/DefaultValue/Mixed_.php b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/DefaultValue/Mixed_.php new file mode 100644 index 00000000..5f579928 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/DefaultValue/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/MaxValue.php b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/MaxValue.php new file mode 100644 index 00000000..7f76b4a1 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/MaxValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/MinValue.php b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/MinValue.php new file mode 100644 index 00000000..81ec0a2f --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/MinValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/SelectOption.php b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/SelectOption.php new file mode 100644 index 00000000..792afdb4 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/SelectOption.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/Type.php b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/Type.php new file mode 100644 index 00000000..9918b486 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldCreateParams/Schema/Type.php @@ -0,0 +1,25 @@ + + */ +final class CustomMetadataFieldDeleteResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + 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(): self + { + return new self; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldListParams.php b/src/CustomMetadataFields/CustomMetadataFieldListParams.php new file mode 100644 index 00000000..be00d9be --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldListParams.php @@ -0,0 +1,84 @@ + */ + use SdkModel; + use SdkParams; + + /** + * The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata fields. Useful for determining path-specific field selections when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use. + */ + #[Optional] + public ?string $folderPath; + + /** + * Set it to `true` to include deleted field objects in the API response. + */ + #[Optional] + public ?bool $includeDeleted; + + 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( + ?string $folderPath = null, + ?bool $includeDeleted = null + ): self { + $self = new self; + + null !== $folderPath && $self['folderPath'] = $folderPath; + null !== $includeDeleted && $self['includeDeleted'] = $includeDeleted; + + return $self; + } + + /** + * The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata fields. Useful for determining path-specific field selections when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use. + */ + public function withFolderPath(string $folderPath): self + { + $self = clone $this; + $self['folderPath'] = $folderPath; + + return $self; + } + + /** + * Set it to `true` to include deleted field objects in the API response. + */ + public function withIncludeDeleted(bool $includeDeleted): self + { + $self = clone $this; + $self['includeDeleted'] = $includeDeleted; + + return $self; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldUpdateParams.php b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams.php new file mode 100644 index 00000000..a653f397 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams.php @@ -0,0 +1,89 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. This parameter is required if `schema` is not provided. + */ + #[Optional] + public ?string $label; + + /** + * An object that describes the rules for the custom metadata key. This parameter is required if `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the `schema`. The schema will be validated as per the existing `type`. + */ + #[Optional] + public ?Schema $schema; + + 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 Schema|SchemaShape|null $schema + */ + public static function with( + ?string $label = null, + Schema|array|null $schema = null + ): self { + $self = new self; + + null !== $label && $self['label'] = $label; + null !== $schema && $self['schema'] = $schema; + + return $self; + } + + /** + * Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. This parameter is required if `schema` is not provided. + */ + public function withLabel(string $label): self + { + $self = clone $this; + $self['label'] = $label; + + return $self; + } + + /** + * An object that describes the rules for the custom metadata key. This parameter is required if `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the `schema`. The schema will be validated as per the existing `type`. + * + * @param Schema|SchemaShape $schema + */ + public function withSchema(Schema|array $schema): self + { + $self = clone $this; + $self['schema'] = $schema; + + return $self; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema.php b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema.php new file mode 100644 index 00000000..c8c84f9c --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema.php @@ -0,0 +1,212 @@ +|null, + * } + */ +final class Schema implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field. + * + * @var DefaultValueVariants|null $defaultValue + */ + #[Optional(union: DefaultValue::class)] + public string|float|bool|array|null $defaultValue; + + /** + * Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body. + */ + #[Optional] + public ?bool $isValueRequired; + + /** + * Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $maxLength; + + /** + * Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value. + * + * @var MaxValueVariants|null $maxValue + */ + #[Optional] + public string|float|null $maxValue; + + /** + * Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $minLength; + + /** + * Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value. + * + * @var MinValueVariants|null $minValue + */ + #[Optional] + public string|float|null $minValue; + + /** + * An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`. + * + * @var list|null $selectOptions + */ + #[Optional(list: SelectOption::class)] + public ?array $selectOptions; + + 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 DefaultValueShape|null $defaultValue + * @param MaxValueShape|null $maxValue + * @param MinValueShape|null $minValue + * @param list|null $selectOptions + */ + public static function with( + string|float|bool|array|null $defaultValue = null, + ?bool $isValueRequired = null, + ?float $maxLength = null, + string|float|null $maxValue = null, + ?float $minLength = null, + string|float|null $minValue = null, + ?array $selectOptions = null, + ): self { + $self = new self; + + null !== $defaultValue && $self['defaultValue'] = $defaultValue; + null !== $isValueRequired && $self['isValueRequired'] = $isValueRequired; + null !== $maxLength && $self['maxLength'] = $maxLength; + null !== $maxValue && $self['maxValue'] = $maxValue; + null !== $minLength && $self['minLength'] = $minLength; + null !== $minValue && $self['minValue'] = $minValue; + null !== $selectOptions && $self['selectOptions'] = $selectOptions; + + return $self; + } + + /** + * The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field. + * + * @param DefaultValueShape $defaultValue + */ + public function withDefaultValue( + string|float|bool|array $defaultValue + ): self { + $self = clone $this; + $self['defaultValue'] = $defaultValue; + + return $self; + } + + /** + * Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body. + */ + public function withIsValueRequired(bool $isValueRequired): self + { + $self = clone $this; + $self['isValueRequired'] = $isValueRequired; + + return $self; + } + + /** + * Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`. + */ + public function withMaxLength(float $maxLength): self + { + $self = clone $this; + $self['maxLength'] = $maxLength; + + return $self; + } + + /** + * Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value. + * + * @param MaxValueShape $maxValue + */ + public function withMaxValue(string|float $maxValue): self + { + $self = clone $this; + $self['maxValue'] = $maxValue; + + return $self; + } + + /** + * Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`. + */ + public function withMinLength(float $minLength): self + { + $self = clone $this; + $self['minLength'] = $minLength; + + return $self; + } + + /** + * Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value. + * + * @param MinValueShape $minValue + */ + public function withMinValue(string|float $minValue): self + { + $self = clone $this; + $self['minValue'] = $minValue; + + return $self; + } + + /** + * An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`. + * + * @param list $selectOptions + */ + public function withSelectOptions(array $selectOptions): self + { + $self = clone $this; + $self['selectOptions'] = $selectOptions; + + return $self; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/DefaultValue.php b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/DefaultValue.php new file mode 100644 index 00000000..41b9726c --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/DefaultValue.php @@ -0,0 +1,32 @@ + + * @phpstan-type DefaultValueShape = DefaultValueVariants|list + */ +final class DefaultValue implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/DefaultValue/Mixed_.php b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/DefaultValue/Mixed_.php new file mode 100644 index 00000000..28e55b44 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/DefaultValue/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/MaxValue.php b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/MaxValue.php new file mode 100644 index 00000000..194f409b --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/MaxValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/MinValue.php b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/MinValue.php new file mode 100644 index 00000000..b3552c30 --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/MinValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/SelectOption.php b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/SelectOption.php new file mode 100644 index 00000000..8153af9c --- /dev/null +++ b/src/CustomMetadataFields/CustomMetadataFieldUpdateParams/Schema/SelectOption.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/ExtensionConfig.php b/src/ExtensionConfig.php new file mode 100644 index 00000000..bb6698d1 --- /dev/null +++ b/src/ExtensionConfig.php @@ -0,0 +1,47 @@ +|array + */ + public static function variants(): array + { + return [ + AutoTaggingExtension::class, + 'remove-bg' => RemovedotBgExtension::class, + 'ai-auto-description' => AutoDescriptionExtension::class, + 'ai-tasks' => AITasksExtension::class, + ]; + } +} diff --git a/src/ExtensionConfig/AITasksExtension.php b/src/ExtensionConfig/AITasksExtension.php new file mode 100644 index 00000000..dc838b5d --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension.php @@ -0,0 +1,101 @@ + + * } + */ +final class AITasksExtension implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Specifies the AI tasks extension for automated image analysis using AI models. + * + * @var 'ai-tasks' $name + */ + #[Required] + public string $name = 'ai-tasks'; + + /** + * Array of task objects defining AI operations to perform on the asset. + * + * @var list $tasks + */ + #[Required(list: Task::class)] + public array $tasks; + + /** + * `new AITasksExtension()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AITasksExtension::with(tasks: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AITasksExtension)->withTasks(...) + * ``` + */ + 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 list $tasks + */ + public static function with(array $tasks): self + { + $self = new self; + + $self['tasks'] = $tasks; + + return $self; + } + + /** + * Specifies the AI tasks extension for automated image analysis using AI models. + * + * @param 'ai-tasks' $name + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Array of task objects defining AI operations to perform on the asset. + * + * @param list $tasks + */ + public function withTasks(array $tasks): self + { + $self = clone $this; + $self['tasks'] = $tasks; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task.php b/src/ExtensionConfig/AITasksExtension/Task.php new file mode 100644 index 00000000..e7c7c4ac --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task.php @@ -0,0 +1,42 @@ +|array + */ + public static function variants(): array + { + return [ + 'select_tags' => AITaskSelectTags::class, + 'select_metadata' => AITaskSelectMetadata::class, + 'yes_no' => AITaskYesNo::class, + ]; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskSelectMetadata.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskSelectMetadata.php new file mode 100644 index 00000000..deb722bb --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskSelectMetadata.php @@ -0,0 +1,185 @@ +|null, + * } + */ +final class AITaskSelectMetadata implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Task type that analyzes the image and sets a custom metadata field value from a vocabulary. + * + * @var 'select_metadata' $type + */ + #[Required] + public string $type = 'select_metadata'; + + /** + * Name of the custom metadata field to set. The field must exist in your account. + */ + #[Required] + public string $field; + + /** + * The question or instruction for the AI to analyze the image. + */ + #[Required] + public string $instruction; + + /** + * Maximum number of values to select from the vocabulary. + */ + #[Optional('max_selections')] + public ?int $maxSelections; + + /** + * Minimum number of values to select from the vocabulary. + */ + #[Optional('min_selections')] + public ?int $minSelections; + + /** + * An array of possible values matching the custom metadata field type. If not provided for SingleSelect or MultiSelect field types, all values from the custom metadata field definition will be used. When providing large vocabularies (above 30 items), the AI may not strictly adhere to the list. + * + * @var list|null $vocabulary + */ + #[Optional(list: Vocabulary::class)] + public ?array $vocabulary; + + /** + * `new AITaskSelectMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AITaskSelectMetadata::with(field: ..., instruction: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AITaskSelectMetadata)->withField(...)->withInstruction(...) + * ``` + */ + 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 list|null $vocabulary + */ + public static function with( + string $field, + string $instruction, + ?int $maxSelections = null, + ?int $minSelections = null, + ?array $vocabulary = null, + ): self { + $self = new self; + + $self['field'] = $field; + $self['instruction'] = $instruction; + + null !== $maxSelections && $self['maxSelections'] = $maxSelections; + null !== $minSelections && $self['minSelections'] = $minSelections; + null !== $vocabulary && $self['vocabulary'] = $vocabulary; + + return $self; + } + + /** + * Name of the custom metadata field to set. The field must exist in your account. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } + + /** + * The question or instruction for the AI to analyze the image. + */ + public function withInstruction(string $instruction): self + { + $self = clone $this; + $self['instruction'] = $instruction; + + return $self; + } + + /** + * Task type that analyzes the image and sets a custom metadata field value from a vocabulary. + * + * @param 'select_metadata' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Maximum number of values to select from the vocabulary. + */ + public function withMaxSelections(int $maxSelections): self + { + $self = clone $this; + $self['maxSelections'] = $maxSelections; + + return $self; + } + + /** + * Minimum number of values to select from the vocabulary. + */ + public function withMinSelections(int $minSelections): self + { + $self = clone $this; + $self['minSelections'] = $minSelections; + + return $self; + } + + /** + * An array of possible values matching the custom metadata field type. If not provided for SingleSelect or MultiSelect field types, all values from the custom metadata field definition will be used. When providing large vocabularies (above 30 items), the AI may not strictly adhere to the list. + * + * @param list $vocabulary + */ + public function withVocabulary(array $vocabulary): self + { + $self = clone $this; + $self['vocabulary'] = $vocabulary; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskSelectMetadata/Vocabulary.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskSelectMetadata/Vocabulary.php new file mode 100644 index 00000000..87ba89b9 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskSelectMetadata/Vocabulary.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskSelectTags.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskSelectTags.php new file mode 100644 index 00000000..63099b66 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskSelectTags.php @@ -0,0 +1,161 @@ +|null, + * } + */ +final class AITaskSelectTags implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Task type that analyzes the image and adds matching tags from a vocabulary. + * + * @var 'select_tags' $type + */ + #[Required] + public string $type = 'select_tags'; + + /** + * The question or instruction for the AI to analyze the image. + */ + #[Required] + public string $instruction; + + /** + * Maximum number of tags to select from the vocabulary. + */ + #[Optional('max_selections')] + public ?int $maxSelections; + + /** + * Minimum number of tags to select from the vocabulary. + */ + #[Optional('min_selections')] + public ?int $minSelections; + + /** + * Array of possible tag values. The combined length of all strings must not exceed 500 characters, and values cannot include the `%` character. When providing large vocabularies (more than 30 items), the AI may not follow the list strictly. + * + * @var list|null $vocabulary + */ + #[Optional(list: 'string')] + public ?array $vocabulary; + + /** + * `new AITaskSelectTags()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AITaskSelectTags::with(instruction: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AITaskSelectTags)->withInstruction(...) + * ``` + */ + 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 list|null $vocabulary + */ + public static function with( + string $instruction, + ?int $maxSelections = null, + ?int $minSelections = null, + ?array $vocabulary = null, + ): self { + $self = new self; + + $self['instruction'] = $instruction; + + null !== $maxSelections && $self['maxSelections'] = $maxSelections; + null !== $minSelections && $self['minSelections'] = $minSelections; + null !== $vocabulary && $self['vocabulary'] = $vocabulary; + + return $self; + } + + /** + * The question or instruction for the AI to analyze the image. + */ + public function withInstruction(string $instruction): self + { + $self = clone $this; + $self['instruction'] = $instruction; + + return $self; + } + + /** + * Task type that analyzes the image and adds matching tags from a vocabulary. + * + * @param 'select_tags' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Maximum number of tags to select from the vocabulary. + */ + public function withMaxSelections(int $maxSelections): self + { + $self = clone $this; + $self['maxSelections'] = $maxSelections; + + return $self; + } + + /** + * Minimum number of tags to select from the vocabulary. + */ + public function withMinSelections(int $minSelections): self + { + $self = clone $this; + $self['minSelections'] = $minSelections; + + return $self; + } + + /** + * Array of possible tag values. The combined length of all strings must not exceed 500 characters, and values cannot include the `%` character. When providing large vocabularies (more than 30 items), the AI may not follow the list strictly. + * + * @param list $vocabulary + */ + public function withVocabulary(array $vocabulary): self + { + $self = clone $this; + $self['vocabulary'] = $vocabulary; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo.php new file mode 100644 index 00000000..f5bdebf3 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo.php @@ -0,0 +1,172 @@ + */ + use SdkModel; + + /** + * Task type that asks a yes/no question and executes actions based on the answer. + * + * @var 'yes_no' $type + */ + #[Required] + public string $type = 'yes_no'; + + /** + * The yes/no question for the AI to answer about the image. + */ + #[Required] + public string $instruction; + + /** + * Actions to execute if the AI answers no. + */ + #[Optional('on_no')] + public ?OnNo $onNo; + + /** + * Actions to execute if the AI cannot determine the answer. + */ + #[Optional('on_unknown')] + public ?OnUnknown $onUnknown; + + /** + * Actions to execute if the AI answers yes. + */ + #[Optional('on_yes')] + public ?OnYes $onYes; + + /** + * `new AITaskYesNo()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AITaskYesNo::with(instruction: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AITaskYesNo)->withInstruction(...) + * ``` + */ + 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 OnNo|OnNoShape|null $onNo + * @param OnUnknown|OnUnknownShape|null $onUnknown + * @param OnYes|OnYesShape|null $onYes + */ + public static function with( + string $instruction, + OnNo|array|null $onNo = null, + OnUnknown|array|null $onUnknown = null, + OnYes|array|null $onYes = null, + ): self { + $self = new self; + + $self['instruction'] = $instruction; + + null !== $onNo && $self['onNo'] = $onNo; + null !== $onUnknown && $self['onUnknown'] = $onUnknown; + null !== $onYes && $self['onYes'] = $onYes; + + return $self; + } + + /** + * The yes/no question for the AI to answer about the image. + */ + public function withInstruction(string $instruction): self + { + $self = clone $this; + $self['instruction'] = $instruction; + + return $self; + } + + /** + * Task type that asks a yes/no question and executes actions based on the answer. + * + * @param 'yes_no' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Actions to execute if the AI answers no. + * + * @param OnNo|OnNoShape $onNo + */ + public function withOnNo(OnNo|array $onNo): self + { + $self = clone $this; + $self['onNo'] = $onNo; + + return $self; + } + + /** + * Actions to execute if the AI cannot determine the answer. + * + * @param OnUnknown|OnUnknownShape $onUnknown + */ + public function withOnUnknown(OnUnknown|array $onUnknown): self + { + $self = clone $this; + $self['onUnknown'] = $onUnknown; + + return $self; + } + + /** + * Actions to execute if the AI answers yes. + * + * @param OnYes|OnYesShape $onYes + */ + public function withOnYes(OnYes|array $onYes): self + { + $self = clone $this; + $self['onYes'] = $onYes; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo.php new file mode 100644 index 00000000..f2795843 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo.php @@ -0,0 +1,145 @@ +|null, + * removeTags?: list|null, + * setMetadata?: list|null, + * unsetMetadata?: list|null, + * } + */ +final class OnNo implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Array of tag strings to add to the asset. + * + * @var list|null $addTags + */ + #[Optional('add_tags', list: 'string')] + public ?array $addTags; + + /** + * Array of tag strings to remove from the asset. + * + * @var list|null $removeTags + */ + #[Optional('remove_tags', list: 'string')] + public ?array $removeTags; + + /** + * Array of custom metadata field updates. + * + * @var list|null $setMetadata + */ + #[Optional('set_metadata', list: SetMetadata::class)] + public ?array $setMetadata; + + /** + * Array of custom metadata fields to remove. + * + * @var list|null $unsetMetadata + */ + #[Optional('unset_metadata', list: UnsetMetadata::class)] + public ?array $unsetMetadata; + + 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 list|null $addTags + * @param list|null $removeTags + * @param list|null $setMetadata + * @param list|null $unsetMetadata + */ + public static function with( + ?array $addTags = null, + ?array $removeTags = null, + ?array $setMetadata = null, + ?array $unsetMetadata = null, + ): self { + $self = new self; + + null !== $addTags && $self['addTags'] = $addTags; + null !== $removeTags && $self['removeTags'] = $removeTags; + null !== $setMetadata && $self['setMetadata'] = $setMetadata; + null !== $unsetMetadata && $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } + + /** + * Array of tag strings to add to the asset. + * + * @param list $addTags + */ + public function withAddTags(array $addTags): self + { + $self = clone $this; + $self['addTags'] = $addTags; + + return $self; + } + + /** + * Array of tag strings to remove from the asset. + * + * @param list $removeTags + */ + public function withRemoveTags(array $removeTags): self + { + $self = clone $this; + $self['removeTags'] = $removeTags; + + return $self; + } + + /** + * Array of custom metadata field updates. + * + * @param list $setMetadata + */ + public function withSetMetadata(array $setMetadata): self + { + $self = clone $this; + $self['setMetadata'] = $setMetadata; + + return $self; + } + + /** + * Array of custom metadata fields to remove. + * + * @param list $unsetMetadata + */ + public function withUnsetMetadata(array $unsetMetadata): self + { + $self = clone $this; + $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata.php new file mode 100644 index 00000000..ed5a1488 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata.php @@ -0,0 +1,98 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to set. + */ + #[Required] + public string $field; + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @var ValueVariants $value + */ + #[Required(union: Value::class)] + public string|float|bool|array $value; + + /** + * `new SetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SetMetadata::with(field: ..., value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SetMetadata)->withField(...)->withValue(...) + * ``` + */ + 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 ValueShape $value + */ + public static function with( + string $field, + string|float|bool|array $value + ): self { + $self = new self; + + $self['field'] = $field; + $self['value'] = $value; + + return $self; + } + + /** + * Name of the custom metadata field to set. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @param ValueShape $value + */ + public function withValue(string|float|bool|array $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value.php new file mode 100644 index 00000000..7572a321 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value.php @@ -0,0 +1,32 @@ + + * @phpstan-type ValueShape = ValueVariants|list + */ +final class Value implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value/Mixed_.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value/Mixed_.php new file mode 100644 index 00000000..f35eb7bb --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/UnsetMetadata.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/UnsetMetadata.php new file mode 100644 index 00000000..d516ece7 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnNo/UnsetMetadata.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to remove. + */ + #[Required] + public string $field; + + /** + * `new UnsetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UnsetMetadata::with(field: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UnsetMetadata)->withField(...) + * ``` + */ + 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(string $field): self + { + $self = new self; + + $self['field'] = $field; + + return $self; + } + + /** + * Name of the custom metadata field to remove. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown.php new file mode 100644 index 00000000..f18bfb9b --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown.php @@ -0,0 +1,145 @@ +|null, + * removeTags?: list|null, + * setMetadata?: list|null, + * unsetMetadata?: list|null, + * } + */ +final class OnUnknown implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Array of tag strings to add to the asset. + * + * @var list|null $addTags + */ + #[Optional('add_tags', list: 'string')] + public ?array $addTags; + + /** + * Array of tag strings to remove from the asset. + * + * @var list|null $removeTags + */ + #[Optional('remove_tags', list: 'string')] + public ?array $removeTags; + + /** + * Array of custom metadata field updates. + * + * @var list|null $setMetadata + */ + #[Optional('set_metadata', list: SetMetadata::class)] + public ?array $setMetadata; + + /** + * Array of custom metadata fields to remove. + * + * @var list|null $unsetMetadata + */ + #[Optional('unset_metadata', list: UnsetMetadata::class)] + public ?array $unsetMetadata; + + 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 list|null $addTags + * @param list|null $removeTags + * @param list|null $setMetadata + * @param list|null $unsetMetadata + */ + public static function with( + ?array $addTags = null, + ?array $removeTags = null, + ?array $setMetadata = null, + ?array $unsetMetadata = null, + ): self { + $self = new self; + + null !== $addTags && $self['addTags'] = $addTags; + null !== $removeTags && $self['removeTags'] = $removeTags; + null !== $setMetadata && $self['setMetadata'] = $setMetadata; + null !== $unsetMetadata && $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } + + /** + * Array of tag strings to add to the asset. + * + * @param list $addTags + */ + public function withAddTags(array $addTags): self + { + $self = clone $this; + $self['addTags'] = $addTags; + + return $self; + } + + /** + * Array of tag strings to remove from the asset. + * + * @param list $removeTags + */ + public function withRemoveTags(array $removeTags): self + { + $self = clone $this; + $self['removeTags'] = $removeTags; + + return $self; + } + + /** + * Array of custom metadata field updates. + * + * @param list $setMetadata + */ + public function withSetMetadata(array $setMetadata): self + { + $self = clone $this; + $self['setMetadata'] = $setMetadata; + + return $self; + } + + /** + * Array of custom metadata fields to remove. + * + * @param list $unsetMetadata + */ + public function withUnsetMetadata(array $unsetMetadata): self + { + $self = clone $this; + $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata.php new file mode 100644 index 00000000..66db67ec --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata.php @@ -0,0 +1,98 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to set. + */ + #[Required] + public string $field; + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @var ValueVariants $value + */ + #[Required(union: Value::class)] + public string|float|bool|array $value; + + /** + * `new SetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SetMetadata::with(field: ..., value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SetMetadata)->withField(...)->withValue(...) + * ``` + */ + 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 ValueShape $value + */ + public static function with( + string $field, + string|float|bool|array $value + ): self { + $self = new self; + + $self['field'] = $field; + $self['value'] = $value; + + return $self; + } + + /** + * Name of the custom metadata field to set. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @param ValueShape $value + */ + public function withValue(string|float|bool|array $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value.php new file mode 100644 index 00000000..32a48506 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value.php @@ -0,0 +1,32 @@ + + * @phpstan-type ValueShape = ValueVariants|list + */ +final class Value implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value/Mixed_.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value/Mixed_.php new file mode 100644 index 00000000..f6f779fe --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/UnsetMetadata.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/UnsetMetadata.php new file mode 100644 index 00000000..aefe5155 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnUnknown/UnsetMetadata.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to remove. + */ + #[Required] + public string $field; + + /** + * `new UnsetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UnsetMetadata::with(field: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UnsetMetadata)->withField(...) + * ``` + */ + 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(string $field): self + { + $self = new self; + + $self['field'] = $field; + + return $self; + } + + /** + * Name of the custom metadata field to remove. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes.php new file mode 100644 index 00000000..ee5a6e49 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes.php @@ -0,0 +1,145 @@ +|null, + * removeTags?: list|null, + * setMetadata?: list|null, + * unsetMetadata?: list|null, + * } + */ +final class OnYes implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Array of tag strings to add to the asset. + * + * @var list|null $addTags + */ + #[Optional('add_tags', list: 'string')] + public ?array $addTags; + + /** + * Array of tag strings to remove from the asset. + * + * @var list|null $removeTags + */ + #[Optional('remove_tags', list: 'string')] + public ?array $removeTags; + + /** + * Array of custom metadata field updates. + * + * @var list|null $setMetadata + */ + #[Optional('set_metadata', list: SetMetadata::class)] + public ?array $setMetadata; + + /** + * Array of custom metadata fields to remove. + * + * @var list|null $unsetMetadata + */ + #[Optional('unset_metadata', list: UnsetMetadata::class)] + public ?array $unsetMetadata; + + 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 list|null $addTags + * @param list|null $removeTags + * @param list|null $setMetadata + * @param list|null $unsetMetadata + */ + public static function with( + ?array $addTags = null, + ?array $removeTags = null, + ?array $setMetadata = null, + ?array $unsetMetadata = null, + ): self { + $self = new self; + + null !== $addTags && $self['addTags'] = $addTags; + null !== $removeTags && $self['removeTags'] = $removeTags; + null !== $setMetadata && $self['setMetadata'] = $setMetadata; + null !== $unsetMetadata && $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } + + /** + * Array of tag strings to add to the asset. + * + * @param list $addTags + */ + public function withAddTags(array $addTags): self + { + $self = clone $this; + $self['addTags'] = $addTags; + + return $self; + } + + /** + * Array of tag strings to remove from the asset. + * + * @param list $removeTags + */ + public function withRemoveTags(array $removeTags): self + { + $self = clone $this; + $self['removeTags'] = $removeTags; + + return $self; + } + + /** + * Array of custom metadata field updates. + * + * @param list $setMetadata + */ + public function withSetMetadata(array $setMetadata): self + { + $self = clone $this; + $self['setMetadata'] = $setMetadata; + + return $self; + } + + /** + * Array of custom metadata fields to remove. + * + * @param list $unsetMetadata + */ + public function withUnsetMetadata(array $unsetMetadata): self + { + $self = clone $this; + $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata.php new file mode 100644 index 00000000..187dffac --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata.php @@ -0,0 +1,98 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to set. + */ + #[Required] + public string $field; + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @var ValueVariants $value + */ + #[Required(union: Value::class)] + public string|float|bool|array $value; + + /** + * `new SetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SetMetadata::with(field: ..., value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SetMetadata)->withField(...)->withValue(...) + * ``` + */ + 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 ValueShape $value + */ + public static function with( + string $field, + string|float|bool|array $value + ): self { + $self = new self; + + $self['field'] = $field; + $self['value'] = $value; + + return $self; + } + + /** + * Name of the custom metadata field to set. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @param ValueShape $value + */ + public function withValue(string|float|bool|array $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value.php new file mode 100644 index 00000000..727626b6 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value.php @@ -0,0 +1,32 @@ + + * @phpstan-type ValueShape = ValueVariants|list + */ +final class Value implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value/Mixed_.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value/Mixed_.php new file mode 100644 index 00000000..f5d43583 --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/UnsetMetadata.php b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/UnsetMetadata.php new file mode 100644 index 00000000..13828e0a --- /dev/null +++ b/src/ExtensionConfig/AITasksExtension/Task/AITaskYesNo/OnYes/UnsetMetadata.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to remove. + */ + #[Required] + public string $field; + + /** + * `new UnsetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UnsetMetadata::with(field: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UnsetMetadata)->withField(...) + * ``` + */ + 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(string $field): self + { + $self = new self; + + $self['field'] = $field; + + return $self; + } + + /** + * Name of the custom metadata field to remove. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } +} diff --git a/src/ExtensionConfig/AutoDescriptionExtension.php b/src/ExtensionConfig/AutoDescriptionExtension.php new file mode 100644 index 00000000..7cecf12f --- /dev/null +++ b/src/ExtensionConfig/AutoDescriptionExtension.php @@ -0,0 +1,54 @@ + */ + use SdkModel; + + /** + * Specifies the auto description extension. + * + * @var 'ai-auto-description' $name + */ + #[Required] + public string $name = 'ai-auto-description'; + + 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(): self + { + return new self; + } + + /** + * Specifies the auto description extension. + * + * @param 'ai-auto-description' $name + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/ExtensionConfig/AutoTaggingExtension.php b/src/ExtensionConfig/AutoTaggingExtension.php new file mode 100644 index 00000000..a3f76b70 --- /dev/null +++ b/src/ExtensionConfig/AutoTaggingExtension.php @@ -0,0 +1,119 @@ + + * } + */ +final class AutoTaggingExtension implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Maximum number of tags to attach to the asset. + */ + #[Required] + public int $maxTags; + + /** + * Minimum confidence level for tags to be considered valid. + */ + #[Required] + public int $minConfidence; + + /** + * Specifies the auto-tagging extension used. + * + * @var value-of $name + */ + #[Required(enum: Name::class)] + public string $name; + + /** + * `new AutoTaggingExtension()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AutoTaggingExtension::with(maxTags: ..., minConfidence: ..., name: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AutoTaggingExtension) + * ->withMaxTags(...) + * ->withMinConfidence(...) + * ->withName(...) + * ``` + */ + 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 Name|value-of $name + */ + public static function with( + int $maxTags, + int $minConfidence, + Name|string $name + ): self { + $self = new self; + + $self['maxTags'] = $maxTags; + $self['minConfidence'] = $minConfidence; + $self['name'] = $name; + + return $self; + } + + /** + * Maximum number of tags to attach to the asset. + */ + public function withMaxTags(int $maxTags): self + { + $self = clone $this; + $self['maxTags'] = $maxTags; + + return $self; + } + + /** + * Minimum confidence level for tags to be considered valid. + */ + public function withMinConfidence(int $minConfidence): self + { + $self = clone $this; + $self['minConfidence'] = $minConfidence; + + return $self; + } + + /** + * Specifies the auto-tagging extension used. + * + * @param Name|value-of $name + */ + public function withName(Name|string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/ExtensionConfig/AutoTaggingExtension/Name.php b/src/ExtensionConfig/AutoTaggingExtension/Name.php new file mode 100644 index 00000000..30463fb2 --- /dev/null +++ b/src/ExtensionConfig/AutoTaggingExtension/Name.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * Specifies the background removal extension. + * + * @var 'remove-bg' $name + */ + #[Required] + public string $name = 'remove-bg'; + + #[Optional] + public ?Options $options; + + 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 Options|OptionsShape|null $options + */ + public static function with(Options|array|null $options = null): self + { + $self = new self; + + null !== $options && $self['options'] = $options; + + return $self; + } + + /** + * Specifies the background removal extension. + * + * @param 'remove-bg' $name + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * @param Options|OptionsShape $options + */ + public function withOptions(Options|array $options): self + { + $self = clone $this; + $self['options'] = $options; + + return $self; + } +} diff --git a/src/ExtensionConfig/RemovedotBgExtension/Options.php b/src/ExtensionConfig/RemovedotBgExtension/Options.php new file mode 100644 index 00000000..031a1f2a --- /dev/null +++ b/src/ExtensionConfig/RemovedotBgExtension/Options.php @@ -0,0 +1,117 @@ + */ + use SdkModel; + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding shadows is currently only supported for car photos. + */ + #[Optional('add_shadow')] + public ?bool $addShadow; + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or color name (e.g., "green"). If this parameter is set, `bg_image_url` must be empty. + */ + #[Optional('bg_color')] + public ?string $bgColor; + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be empty. + */ + #[Optional('bg_image_url')] + public ?string $bgImageURL; + + /** + * Allows semi-transparent regions in the result. Default is true. Note: Semitransparency is currently only supported for car windows. + */ + #[Optional] + public ?bool $semitransparency; + + 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 $addShadow = null, + ?string $bgColor = null, + ?string $bgImageURL = null, + ?bool $semitransparency = null, + ): self { + $self = new self; + + null !== $addShadow && $self['addShadow'] = $addShadow; + null !== $bgColor && $self['bgColor'] = $bgColor; + null !== $bgImageURL && $self['bgImageURL'] = $bgImageURL; + null !== $semitransparency && $self['semitransparency'] = $semitransparency; + + return $self; + } + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding shadows is currently only supported for car photos. + */ + public function withAddShadow(bool $addShadow): self + { + $self = clone $this; + $self['addShadow'] = $addShadow; + + return $self; + } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or color name (e.g., "green"). If this parameter is set, `bg_image_url` must be empty. + */ + public function withBgColor(string $bgColor): self + { + $self = clone $this; + $self['bgColor'] = $bgColor; + + return $self; + } + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be empty. + */ + public function withBgImageURL(string $bgImageURL): self + { + $self = clone $this; + $self['bgImageURL'] = $bgImageURL; + + return $self; + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: Semitransparency is currently only supported for car windows. + */ + public function withSemitransparency(bool $semitransparency): self + { + $self = clone $this; + $self['semitransparency'] = $semitransparency; + + return $self; + } +} diff --git a/src/ExtensionItem.php b/src/ExtensionItem.php new file mode 100644 index 00000000..16d96692 --- /dev/null +++ b/src/ExtensionItem.php @@ -0,0 +1,48 @@ +|array + */ + public static function variants(): array + { + return [ + AutoTaggingExtension::class, + 'remove-bg' => RemovedotBgExtension::class, + 'ai-auto-description' => AutoDescriptionExtension::class, + 'ai-tasks' => AITasksExtension::class, + 'saved-extension' => SavedExtensionReference::class, + ]; + } +} diff --git a/src/ExtensionItem/AITasksExtension.php b/src/ExtensionItem/AITasksExtension.php new file mode 100644 index 00000000..17d7e397 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension.php @@ -0,0 +1,101 @@ + + * } + */ +final class AITasksExtension implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Specifies the AI tasks extension for automated image analysis using AI models. + * + * @var 'ai-tasks' $name + */ + #[Required] + public string $name = 'ai-tasks'; + + /** + * Array of task objects defining AI operations to perform on the asset. + * + * @var list $tasks + */ + #[Required(list: Task::class)] + public array $tasks; + + /** + * `new AITasksExtension()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AITasksExtension::with(tasks: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AITasksExtension)->withTasks(...) + * ``` + */ + 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 list $tasks + */ + public static function with(array $tasks): self + { + $self = new self; + + $self['tasks'] = $tasks; + + return $self; + } + + /** + * Specifies the AI tasks extension for automated image analysis using AI models. + * + * @param 'ai-tasks' $name + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Array of task objects defining AI operations to perform on the asset. + * + * @param list $tasks + */ + public function withTasks(array $tasks): self + { + $self = clone $this; + $self['tasks'] = $tasks; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task.php b/src/ExtensionItem/AITasksExtension/Task.php new file mode 100644 index 00000000..bab2348c --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task.php @@ -0,0 +1,42 @@ +|array + */ + public static function variants(): array + { + return [ + 'select_tags' => AITaskSelectTags::class, + 'select_metadata' => AITaskSelectMetadata::class, + 'yes_no' => AITaskYesNo::class, + ]; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskSelectMetadata.php b/src/ExtensionItem/AITasksExtension/Task/AITaskSelectMetadata.php new file mode 100644 index 00000000..156edeff --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskSelectMetadata.php @@ -0,0 +1,185 @@ +|null, + * } + */ +final class AITaskSelectMetadata implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Task type that analyzes the image and sets a custom metadata field value from a vocabulary. + * + * @var 'select_metadata' $type + */ + #[Required] + public string $type = 'select_metadata'; + + /** + * Name of the custom metadata field to set. The field must exist in your account. + */ + #[Required] + public string $field; + + /** + * The question or instruction for the AI to analyze the image. + */ + #[Required] + public string $instruction; + + /** + * Maximum number of values to select from the vocabulary. + */ + #[Optional('max_selections')] + public ?int $maxSelections; + + /** + * Minimum number of values to select from the vocabulary. + */ + #[Optional('min_selections')] + public ?int $minSelections; + + /** + * An array of possible values matching the custom metadata field type. If not provided for SingleSelect or MultiSelect field types, all values from the custom metadata field definition will be used. When providing large vocabularies (above 30 items), the AI may not strictly adhere to the list. + * + * @var list|null $vocabulary + */ + #[Optional(list: Vocabulary::class)] + public ?array $vocabulary; + + /** + * `new AITaskSelectMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AITaskSelectMetadata::with(field: ..., instruction: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AITaskSelectMetadata)->withField(...)->withInstruction(...) + * ``` + */ + 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 list|null $vocabulary + */ + public static function with( + string $field, + string $instruction, + ?int $maxSelections = null, + ?int $minSelections = null, + ?array $vocabulary = null, + ): self { + $self = new self; + + $self['field'] = $field; + $self['instruction'] = $instruction; + + null !== $maxSelections && $self['maxSelections'] = $maxSelections; + null !== $minSelections && $self['minSelections'] = $minSelections; + null !== $vocabulary && $self['vocabulary'] = $vocabulary; + + return $self; + } + + /** + * Name of the custom metadata field to set. The field must exist in your account. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } + + /** + * The question or instruction for the AI to analyze the image. + */ + public function withInstruction(string $instruction): self + { + $self = clone $this; + $self['instruction'] = $instruction; + + return $self; + } + + /** + * Task type that analyzes the image and sets a custom metadata field value from a vocabulary. + * + * @param 'select_metadata' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Maximum number of values to select from the vocabulary. + */ + public function withMaxSelections(int $maxSelections): self + { + $self = clone $this; + $self['maxSelections'] = $maxSelections; + + return $self; + } + + /** + * Minimum number of values to select from the vocabulary. + */ + public function withMinSelections(int $minSelections): self + { + $self = clone $this; + $self['minSelections'] = $minSelections; + + return $self; + } + + /** + * An array of possible values matching the custom metadata field type. If not provided for SingleSelect or MultiSelect field types, all values from the custom metadata field definition will be used. When providing large vocabularies (above 30 items), the AI may not strictly adhere to the list. + * + * @param list $vocabulary + */ + public function withVocabulary(array $vocabulary): self + { + $self = clone $this; + $self['vocabulary'] = $vocabulary; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskSelectMetadata/Vocabulary.php b/src/ExtensionItem/AITasksExtension/Task/AITaskSelectMetadata/Vocabulary.php new file mode 100644 index 00000000..96fd064f --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskSelectMetadata/Vocabulary.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskSelectTags.php b/src/ExtensionItem/AITasksExtension/Task/AITaskSelectTags.php new file mode 100644 index 00000000..94f379c0 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskSelectTags.php @@ -0,0 +1,161 @@ +|null, + * } + */ +final class AITaskSelectTags implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Task type that analyzes the image and adds matching tags from a vocabulary. + * + * @var 'select_tags' $type + */ + #[Required] + public string $type = 'select_tags'; + + /** + * The question or instruction for the AI to analyze the image. + */ + #[Required] + public string $instruction; + + /** + * Maximum number of tags to select from the vocabulary. + */ + #[Optional('max_selections')] + public ?int $maxSelections; + + /** + * Minimum number of tags to select from the vocabulary. + */ + #[Optional('min_selections')] + public ?int $minSelections; + + /** + * Array of possible tag values. The combined length of all strings must not exceed 500 characters, and values cannot include the `%` character. When providing large vocabularies (more than 30 items), the AI may not follow the list strictly. + * + * @var list|null $vocabulary + */ + #[Optional(list: 'string')] + public ?array $vocabulary; + + /** + * `new AITaskSelectTags()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AITaskSelectTags::with(instruction: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AITaskSelectTags)->withInstruction(...) + * ``` + */ + 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 list|null $vocabulary + */ + public static function with( + string $instruction, + ?int $maxSelections = null, + ?int $minSelections = null, + ?array $vocabulary = null, + ): self { + $self = new self; + + $self['instruction'] = $instruction; + + null !== $maxSelections && $self['maxSelections'] = $maxSelections; + null !== $minSelections && $self['minSelections'] = $minSelections; + null !== $vocabulary && $self['vocabulary'] = $vocabulary; + + return $self; + } + + /** + * The question or instruction for the AI to analyze the image. + */ + public function withInstruction(string $instruction): self + { + $self = clone $this; + $self['instruction'] = $instruction; + + return $self; + } + + /** + * Task type that analyzes the image and adds matching tags from a vocabulary. + * + * @param 'select_tags' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Maximum number of tags to select from the vocabulary. + */ + public function withMaxSelections(int $maxSelections): self + { + $self = clone $this; + $self['maxSelections'] = $maxSelections; + + return $self; + } + + /** + * Minimum number of tags to select from the vocabulary. + */ + public function withMinSelections(int $minSelections): self + { + $self = clone $this; + $self['minSelections'] = $minSelections; + + return $self; + } + + /** + * Array of possible tag values. The combined length of all strings must not exceed 500 characters, and values cannot include the `%` character. When providing large vocabularies (more than 30 items), the AI may not follow the list strictly. + * + * @param list $vocabulary + */ + public function withVocabulary(array $vocabulary): self + { + $self = clone $this; + $self['vocabulary'] = $vocabulary; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo.php new file mode 100644 index 00000000..eab84588 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo.php @@ -0,0 +1,172 @@ + */ + use SdkModel; + + /** + * Task type that asks a yes/no question and executes actions based on the answer. + * + * @var 'yes_no' $type + */ + #[Required] + public string $type = 'yes_no'; + + /** + * The yes/no question for the AI to answer about the image. + */ + #[Required] + public string $instruction; + + /** + * Actions to execute if the AI answers no. + */ + #[Optional('on_no')] + public ?OnNo $onNo; + + /** + * Actions to execute if the AI cannot determine the answer. + */ + #[Optional('on_unknown')] + public ?OnUnknown $onUnknown; + + /** + * Actions to execute if the AI answers yes. + */ + #[Optional('on_yes')] + public ?OnYes $onYes; + + /** + * `new AITaskYesNo()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AITaskYesNo::with(instruction: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AITaskYesNo)->withInstruction(...) + * ``` + */ + 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 OnNo|OnNoShape|null $onNo + * @param OnUnknown|OnUnknownShape|null $onUnknown + * @param OnYes|OnYesShape|null $onYes + */ + public static function with( + string $instruction, + OnNo|array|null $onNo = null, + OnUnknown|array|null $onUnknown = null, + OnYes|array|null $onYes = null, + ): self { + $self = new self; + + $self['instruction'] = $instruction; + + null !== $onNo && $self['onNo'] = $onNo; + null !== $onUnknown && $self['onUnknown'] = $onUnknown; + null !== $onYes && $self['onYes'] = $onYes; + + return $self; + } + + /** + * The yes/no question for the AI to answer about the image. + */ + public function withInstruction(string $instruction): self + { + $self = clone $this; + $self['instruction'] = $instruction; + + return $self; + } + + /** + * Task type that asks a yes/no question and executes actions based on the answer. + * + * @param 'yes_no' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Actions to execute if the AI answers no. + * + * @param OnNo|OnNoShape $onNo + */ + public function withOnNo(OnNo|array $onNo): self + { + $self = clone $this; + $self['onNo'] = $onNo; + + return $self; + } + + /** + * Actions to execute if the AI cannot determine the answer. + * + * @param OnUnknown|OnUnknownShape $onUnknown + */ + public function withOnUnknown(OnUnknown|array $onUnknown): self + { + $self = clone $this; + $self['onUnknown'] = $onUnknown; + + return $self; + } + + /** + * Actions to execute if the AI answers yes. + * + * @param OnYes|OnYesShape $onYes + */ + public function withOnYes(OnYes|array $onYes): self + { + $self = clone $this; + $self['onYes'] = $onYes; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo.php new file mode 100644 index 00000000..60a99c77 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo.php @@ -0,0 +1,145 @@ +|null, + * removeTags?: list|null, + * setMetadata?: list|null, + * unsetMetadata?: list|null, + * } + */ +final class OnNo implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Array of tag strings to add to the asset. + * + * @var list|null $addTags + */ + #[Optional('add_tags', list: 'string')] + public ?array $addTags; + + /** + * Array of tag strings to remove from the asset. + * + * @var list|null $removeTags + */ + #[Optional('remove_tags', list: 'string')] + public ?array $removeTags; + + /** + * Array of custom metadata field updates. + * + * @var list|null $setMetadata + */ + #[Optional('set_metadata', list: SetMetadata::class)] + public ?array $setMetadata; + + /** + * Array of custom metadata fields to remove. + * + * @var list|null $unsetMetadata + */ + #[Optional('unset_metadata', list: UnsetMetadata::class)] + public ?array $unsetMetadata; + + 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 list|null $addTags + * @param list|null $removeTags + * @param list|null $setMetadata + * @param list|null $unsetMetadata + */ + public static function with( + ?array $addTags = null, + ?array $removeTags = null, + ?array $setMetadata = null, + ?array $unsetMetadata = null, + ): self { + $self = new self; + + null !== $addTags && $self['addTags'] = $addTags; + null !== $removeTags && $self['removeTags'] = $removeTags; + null !== $setMetadata && $self['setMetadata'] = $setMetadata; + null !== $unsetMetadata && $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } + + /** + * Array of tag strings to add to the asset. + * + * @param list $addTags + */ + public function withAddTags(array $addTags): self + { + $self = clone $this; + $self['addTags'] = $addTags; + + return $self; + } + + /** + * Array of tag strings to remove from the asset. + * + * @param list $removeTags + */ + public function withRemoveTags(array $removeTags): self + { + $self = clone $this; + $self['removeTags'] = $removeTags; + + return $self; + } + + /** + * Array of custom metadata field updates. + * + * @param list $setMetadata + */ + public function withSetMetadata(array $setMetadata): self + { + $self = clone $this; + $self['setMetadata'] = $setMetadata; + + return $self; + } + + /** + * Array of custom metadata fields to remove. + * + * @param list $unsetMetadata + */ + public function withUnsetMetadata(array $unsetMetadata): self + { + $self = clone $this; + $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata.php new file mode 100644 index 00000000..734a59c4 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata.php @@ -0,0 +1,98 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to set. + */ + #[Required] + public string $field; + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @var ValueVariants $value + */ + #[Required(union: Value::class)] + public string|float|bool|array $value; + + /** + * `new SetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SetMetadata::with(field: ..., value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SetMetadata)->withField(...)->withValue(...) + * ``` + */ + 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 ValueShape $value + */ + public static function with( + string $field, + string|float|bool|array $value + ): self { + $self = new self; + + $self['field'] = $field; + $self['value'] = $value; + + return $self; + } + + /** + * Name of the custom metadata field to set. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @param ValueShape $value + */ + public function withValue(string|float|bool|array $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value.php new file mode 100644 index 00000000..d93e6313 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value.php @@ -0,0 +1,32 @@ + + * @phpstan-type ValueShape = ValueVariants|list + */ +final class Value implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value/Mixed_.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value/Mixed_.php new file mode 100644 index 00000000..34892471 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/SetMetadata/Value/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/UnsetMetadata.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/UnsetMetadata.php new file mode 100644 index 00000000..9cb0b711 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnNo/UnsetMetadata.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to remove. + */ + #[Required] + public string $field; + + /** + * `new UnsetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UnsetMetadata::with(field: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UnsetMetadata)->withField(...) + * ``` + */ + 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(string $field): self + { + $self = new self; + + $self['field'] = $field; + + return $self; + } + + /** + * Name of the custom metadata field to remove. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown.php new file mode 100644 index 00000000..1d3fcdf6 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown.php @@ -0,0 +1,145 @@ +|null, + * removeTags?: list|null, + * setMetadata?: list|null, + * unsetMetadata?: list|null, + * } + */ +final class OnUnknown implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Array of tag strings to add to the asset. + * + * @var list|null $addTags + */ + #[Optional('add_tags', list: 'string')] + public ?array $addTags; + + /** + * Array of tag strings to remove from the asset. + * + * @var list|null $removeTags + */ + #[Optional('remove_tags', list: 'string')] + public ?array $removeTags; + + /** + * Array of custom metadata field updates. + * + * @var list|null $setMetadata + */ + #[Optional('set_metadata', list: SetMetadata::class)] + public ?array $setMetadata; + + /** + * Array of custom metadata fields to remove. + * + * @var list|null $unsetMetadata + */ + #[Optional('unset_metadata', list: UnsetMetadata::class)] + public ?array $unsetMetadata; + + 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 list|null $addTags + * @param list|null $removeTags + * @param list|null $setMetadata + * @param list|null $unsetMetadata + */ + public static function with( + ?array $addTags = null, + ?array $removeTags = null, + ?array $setMetadata = null, + ?array $unsetMetadata = null, + ): self { + $self = new self; + + null !== $addTags && $self['addTags'] = $addTags; + null !== $removeTags && $self['removeTags'] = $removeTags; + null !== $setMetadata && $self['setMetadata'] = $setMetadata; + null !== $unsetMetadata && $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } + + /** + * Array of tag strings to add to the asset. + * + * @param list $addTags + */ + public function withAddTags(array $addTags): self + { + $self = clone $this; + $self['addTags'] = $addTags; + + return $self; + } + + /** + * Array of tag strings to remove from the asset. + * + * @param list $removeTags + */ + public function withRemoveTags(array $removeTags): self + { + $self = clone $this; + $self['removeTags'] = $removeTags; + + return $self; + } + + /** + * Array of custom metadata field updates. + * + * @param list $setMetadata + */ + public function withSetMetadata(array $setMetadata): self + { + $self = clone $this; + $self['setMetadata'] = $setMetadata; + + return $self; + } + + /** + * Array of custom metadata fields to remove. + * + * @param list $unsetMetadata + */ + public function withUnsetMetadata(array $unsetMetadata): self + { + $self = clone $this; + $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata.php new file mode 100644 index 00000000..97a5d086 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata.php @@ -0,0 +1,98 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to set. + */ + #[Required] + public string $field; + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @var ValueVariants $value + */ + #[Required(union: Value::class)] + public string|float|bool|array $value; + + /** + * `new SetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SetMetadata::with(field: ..., value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SetMetadata)->withField(...)->withValue(...) + * ``` + */ + 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 ValueShape $value + */ + public static function with( + string $field, + string|float|bool|array $value + ): self { + $self = new self; + + $self['field'] = $field; + $self['value'] = $value; + + return $self; + } + + /** + * Name of the custom metadata field to set. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @param ValueShape $value + */ + public function withValue(string|float|bool|array $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value.php new file mode 100644 index 00000000..ddb63eb2 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value.php @@ -0,0 +1,32 @@ + + * @phpstan-type ValueShape = ValueVariants|list + */ +final class Value implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value/Mixed_.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value/Mixed_.php new file mode 100644 index 00000000..ad5f8e0f --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/SetMetadata/Value/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/UnsetMetadata.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/UnsetMetadata.php new file mode 100644 index 00000000..4e367df9 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnUnknown/UnsetMetadata.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to remove. + */ + #[Required] + public string $field; + + /** + * `new UnsetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UnsetMetadata::with(field: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UnsetMetadata)->withField(...) + * ``` + */ + 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(string $field): self + { + $self = new self; + + $self['field'] = $field; + + return $self; + } + + /** + * Name of the custom metadata field to remove. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes.php new file mode 100644 index 00000000..f413daca --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes.php @@ -0,0 +1,145 @@ +|null, + * removeTags?: list|null, + * setMetadata?: list|null, + * unsetMetadata?: list|null, + * } + */ +final class OnYes implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Array of tag strings to add to the asset. + * + * @var list|null $addTags + */ + #[Optional('add_tags', list: 'string')] + public ?array $addTags; + + /** + * Array of tag strings to remove from the asset. + * + * @var list|null $removeTags + */ + #[Optional('remove_tags', list: 'string')] + public ?array $removeTags; + + /** + * Array of custom metadata field updates. + * + * @var list|null $setMetadata + */ + #[Optional('set_metadata', list: SetMetadata::class)] + public ?array $setMetadata; + + /** + * Array of custom metadata fields to remove. + * + * @var list|null $unsetMetadata + */ + #[Optional('unset_metadata', list: UnsetMetadata::class)] + public ?array $unsetMetadata; + + 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 list|null $addTags + * @param list|null $removeTags + * @param list|null $setMetadata + * @param list|null $unsetMetadata + */ + public static function with( + ?array $addTags = null, + ?array $removeTags = null, + ?array $setMetadata = null, + ?array $unsetMetadata = null, + ): self { + $self = new self; + + null !== $addTags && $self['addTags'] = $addTags; + null !== $removeTags && $self['removeTags'] = $removeTags; + null !== $setMetadata && $self['setMetadata'] = $setMetadata; + null !== $unsetMetadata && $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } + + /** + * Array of tag strings to add to the asset. + * + * @param list $addTags + */ + public function withAddTags(array $addTags): self + { + $self = clone $this; + $self['addTags'] = $addTags; + + return $self; + } + + /** + * Array of tag strings to remove from the asset. + * + * @param list $removeTags + */ + public function withRemoveTags(array $removeTags): self + { + $self = clone $this; + $self['removeTags'] = $removeTags; + + return $self; + } + + /** + * Array of custom metadata field updates. + * + * @param list $setMetadata + */ + public function withSetMetadata(array $setMetadata): self + { + $self = clone $this; + $self['setMetadata'] = $setMetadata; + + return $self; + } + + /** + * Array of custom metadata fields to remove. + * + * @param list $unsetMetadata + */ + public function withUnsetMetadata(array $unsetMetadata): self + { + $self = clone $this; + $self['unsetMetadata'] = $unsetMetadata; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata.php new file mode 100644 index 00000000..6d82f7e7 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata.php @@ -0,0 +1,98 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to set. + */ + #[Required] + public string $field; + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @var ValueVariants $value + */ + #[Required(union: Value::class)] + public string|float|bool|array $value; + + /** + * `new SetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SetMetadata::with(field: ..., value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SetMetadata)->withField(...)->withValue(...) + * ``` + */ + 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 ValueShape $value + */ + public static function with( + string $field, + string|float|bool|array $value + ): self { + $self = new self; + + $self['field'] = $field; + $self['value'] = $value; + + return $self; + } + + /** + * Name of the custom metadata field to set. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } + + /** + * Value to set for the custom metadata field. The value type should match the custom metadata field type. + * + * @param ValueShape $value + */ + public function withValue(string|float|bool|array $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value.php new file mode 100644 index 00000000..139d6170 --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value.php @@ -0,0 +1,32 @@ + + * @phpstan-type ValueShape = ValueVariants|list + */ +final class Value implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value/Mixed_.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value/Mixed_.php new file mode 100644 index 00000000..4c3e83ea --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/SetMetadata/Value/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/UnsetMetadata.php b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/UnsetMetadata.php new file mode 100644 index 00000000..efbce1ab --- /dev/null +++ b/src/ExtensionItem/AITasksExtension/Task/AITaskYesNo/OnYes/UnsetMetadata.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * Name of the custom metadata field to remove. + */ + #[Required] + public string $field; + + /** + * `new UnsetMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UnsetMetadata::with(field: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UnsetMetadata)->withField(...) + * ``` + */ + 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(string $field): self + { + $self = new self; + + $self['field'] = $field; + + return $self; + } + + /** + * Name of the custom metadata field to remove. + */ + public function withField(string $field): self + { + $self = clone $this; + $self['field'] = $field; + + return $self; + } +} diff --git a/src/ExtensionItem/AutoDescriptionExtension.php b/src/ExtensionItem/AutoDescriptionExtension.php new file mode 100644 index 00000000..18a552f8 --- /dev/null +++ b/src/ExtensionItem/AutoDescriptionExtension.php @@ -0,0 +1,54 @@ + */ + use SdkModel; + + /** + * Specifies the auto description extension. + * + * @var 'ai-auto-description' $name + */ + #[Required] + public string $name = 'ai-auto-description'; + + 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(): self + { + return new self; + } + + /** + * Specifies the auto description extension. + * + * @param 'ai-auto-description' $name + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/ExtensionItem/AutoTaggingExtension.php b/src/ExtensionItem/AutoTaggingExtension.php new file mode 100644 index 00000000..5363463c --- /dev/null +++ b/src/ExtensionItem/AutoTaggingExtension.php @@ -0,0 +1,119 @@ + + * } + */ +final class AutoTaggingExtension implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Maximum number of tags to attach to the asset. + */ + #[Required] + public int $maxTags; + + /** + * Minimum confidence level for tags to be considered valid. + */ + #[Required] + public int $minConfidence; + + /** + * Specifies the auto-tagging extension used. + * + * @var value-of $name + */ + #[Required(enum: Name::class)] + public string $name; + + /** + * `new AutoTaggingExtension()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AutoTaggingExtension::with(maxTags: ..., minConfidence: ..., name: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AutoTaggingExtension) + * ->withMaxTags(...) + * ->withMinConfidence(...) + * ->withName(...) + * ``` + */ + 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 Name|value-of $name + */ + public static function with( + int $maxTags, + int $minConfidence, + Name|string $name + ): self { + $self = new self; + + $self['maxTags'] = $maxTags; + $self['minConfidence'] = $minConfidence; + $self['name'] = $name; + + return $self; + } + + /** + * Maximum number of tags to attach to the asset. + */ + public function withMaxTags(int $maxTags): self + { + $self = clone $this; + $self['maxTags'] = $maxTags; + + return $self; + } + + /** + * Minimum confidence level for tags to be considered valid. + */ + public function withMinConfidence(int $minConfidence): self + { + $self = clone $this; + $self['minConfidence'] = $minConfidence; + + return $self; + } + + /** + * Specifies the auto-tagging extension used. + * + * @param Name|value-of $name + */ + public function withName(Name|string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/ExtensionItem/AutoTaggingExtension/Name.php b/src/ExtensionItem/AutoTaggingExtension/Name.php new file mode 100644 index 00000000..853dc5ad --- /dev/null +++ b/src/ExtensionItem/AutoTaggingExtension/Name.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * Specifies the background removal extension. + * + * @var 'remove-bg' $name + */ + #[Required] + public string $name = 'remove-bg'; + + #[Optional] + public ?Options $options; + + 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 Options|OptionsShape|null $options + */ + public static function with(Options|array|null $options = null): self + { + $self = new self; + + null !== $options && $self['options'] = $options; + + return $self; + } + + /** + * Specifies the background removal extension. + * + * @param 'remove-bg' $name + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * @param Options|OptionsShape $options + */ + public function withOptions(Options|array $options): self + { + $self = clone $this; + $self['options'] = $options; + + return $self; + } +} diff --git a/src/ExtensionItem/RemovedotBgExtension/Options.php b/src/ExtensionItem/RemovedotBgExtension/Options.php new file mode 100644 index 00000000..7bd2192f --- /dev/null +++ b/src/ExtensionItem/RemovedotBgExtension/Options.php @@ -0,0 +1,117 @@ + */ + use SdkModel; + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding shadows is currently only supported for car photos. + */ + #[Optional('add_shadow')] + public ?bool $addShadow; + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or color name (e.g., "green"). If this parameter is set, `bg_image_url` must be empty. + */ + #[Optional('bg_color')] + public ?string $bgColor; + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be empty. + */ + #[Optional('bg_image_url')] + public ?string $bgImageURL; + + /** + * Allows semi-transparent regions in the result. Default is true. Note: Semitransparency is currently only supported for car windows. + */ + #[Optional] + public ?bool $semitransparency; + + 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 $addShadow = null, + ?string $bgColor = null, + ?string $bgImageURL = null, + ?bool $semitransparency = null, + ): self { + $self = new self; + + null !== $addShadow && $self['addShadow'] = $addShadow; + null !== $bgColor && $self['bgColor'] = $bgColor; + null !== $bgImageURL && $self['bgImageURL'] = $bgImageURL; + null !== $semitransparency && $self['semitransparency'] = $semitransparency; + + return $self; + } + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding shadows is currently only supported for car photos. + */ + public function withAddShadow(bool $addShadow): self + { + $self = clone $this; + $self['addShadow'] = $addShadow; + + return $self; + } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or color name (e.g., "green"). If this parameter is set, `bg_image_url` must be empty. + */ + public function withBgColor(string $bgColor): self + { + $self = clone $this; + $self['bgColor'] = $bgColor; + + return $self; + } + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be empty. + */ + public function withBgImageURL(string $bgImageURL): self + { + $self = clone $this; + $self['bgImageURL'] = $bgImageURL; + + return $self; + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: Semitransparency is currently only supported for car windows. + */ + public function withSemitransparency(bool $semitransparency): self + { + $self = clone $this; + $self['semitransparency'] = $semitransparency; + + return $self; + } +} diff --git a/src/ExtensionItem/SavedExtensionReference.php b/src/ExtensionItem/SavedExtensionReference.php new file mode 100644 index 00000000..2f7da2ef --- /dev/null +++ b/src/ExtensionItem/SavedExtensionReference.php @@ -0,0 +1,91 @@ + */ + use SdkModel; + + /** + * Indicates this is a reference to a saved extension. + * + * @var 'saved-extension' $name + */ + #[Required] + public string $name = 'saved-extension'; + + /** + * The unique ID of the saved extension to apply. + */ + #[Required] + public string $id; + + /** + * `new SavedExtensionReference()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SavedExtensionReference::with(id: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SavedExtensionReference)->withID(...) + * ``` + */ + 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(string $id): self + { + $self = new self; + + $self['id'] = $id; + + return $self; + } + + /** + * The unique ID of the saved extension to apply. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Indicates this is a reference to a saved extension. + * + * @param 'saved-extension' $name + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/Files/Bulk/BulkAddTagsParams.php b/src/Files/Bulk/BulkAddTagsParams.php new file mode 100644 index 00000000..1eee40f3 --- /dev/null +++ b/src/Files/Bulk/BulkAddTagsParams.php @@ -0,0 +1,105 @@ +, tags: list + * } + */ +final class BulkAddTagsParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * An array of fileIds to which you want to add tags. + * + * @var list $fileIDs + */ + #[Required('fileIds', list: 'string')] + public array $fileIDs; + + /** + * An array of tags that you want to add to the files. + * + * @var list $tags + */ + #[Required(list: 'string')] + public array $tags; + + /** + * `new BulkAddTagsParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BulkAddTagsParams::with(fileIDs: ..., tags: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BulkAddTagsParams)->withFileIDs(...)->withTags(...) + * ``` + */ + 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 list $fileIDs + * @param list $tags + */ + public static function with(array $fileIDs, array $tags): self + { + $self = new self; + + $self['fileIDs'] = $fileIDs; + $self['tags'] = $tags; + + return $self; + } + + /** + * An array of fileIds to which you want to add tags. + * + * @param list $fileIDs + */ + public function withFileIDs(array $fileIDs): self + { + $self = clone $this; + $self['fileIDs'] = $fileIDs; + + return $self; + } + + /** + * An array of tags that you want to add to the files. + * + * @param list $tags + */ + public function withTags(array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } +} diff --git a/src/Files/Bulk/BulkAddTagsResponse.php b/src/Files/Bulk/BulkAddTagsResponse.php new file mode 100644 index 00000000..1c34f22b --- /dev/null +++ b/src/Files/Bulk/BulkAddTagsResponse.php @@ -0,0 +1,63 @@ +|null + * } + */ +final class BulkAddTagsResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * An array of fileIds that in which tags were successfully added. + * + * @var list|null $successfullyUpdatedFileIDs + */ + #[Optional('successfullyUpdatedFileIds', list: 'string')] + public ?array $successfullyUpdatedFileIDs; + + 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 list|null $successfullyUpdatedFileIDs + */ + public static function with(?array $successfullyUpdatedFileIDs = null): self + { + $self = new self; + + null !== $successfullyUpdatedFileIDs && $self['successfullyUpdatedFileIDs'] = $successfullyUpdatedFileIDs; + + return $self; + } + + /** + * An array of fileIds that in which tags were successfully added. + * + * @param list $successfullyUpdatedFileIDs + */ + public function withSuccessfullyUpdatedFileIDs( + array $successfullyUpdatedFileIDs + ): self { + $self = clone $this; + $self['successfullyUpdatedFileIDs'] = $successfullyUpdatedFileIDs; + + return $self; + } +} diff --git a/src/Files/Bulk/BulkDeleteParams.php b/src/Files/Bulk/BulkDeleteParams.php new file mode 100644 index 00000000..2886101e --- /dev/null +++ b/src/Files/Bulk/BulkDeleteParams.php @@ -0,0 +1,84 @@ +} + */ +final class BulkDeleteParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * An array of fileIds which you want to delete. + * + * @var list $fileIDs + */ + #[Required('fileIds', list: 'string')] + public array $fileIDs; + + /** + * `new BulkDeleteParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BulkDeleteParams::with(fileIDs: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BulkDeleteParams)->withFileIDs(...) + * ``` + */ + 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 list $fileIDs + */ + public static function with(array $fileIDs): self + { + $self = new self; + + $self['fileIDs'] = $fileIDs; + + return $self; + } + + /** + * An array of fileIds which you want to delete. + * + * @param list $fileIDs + */ + public function withFileIDs(array $fileIDs): self + { + $self = clone $this; + $self['fileIDs'] = $fileIDs; + + return $self; + } +} diff --git a/src/Files/Bulk/BulkDeleteResponse.php b/src/Files/Bulk/BulkDeleteResponse.php new file mode 100644 index 00000000..6283cf47 --- /dev/null +++ b/src/Files/Bulk/BulkDeleteResponse.php @@ -0,0 +1,63 @@ +|null + * } + */ +final class BulkDeleteResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * An array of fileIds that were successfully deleted. + * + * @var list|null $successfullyDeletedFileIDs + */ + #[Optional('successfullyDeletedFileIds', list: 'string')] + public ?array $successfullyDeletedFileIDs; + + 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 list|null $successfullyDeletedFileIDs + */ + public static function with(?array $successfullyDeletedFileIDs = null): self + { + $self = new self; + + null !== $successfullyDeletedFileIDs && $self['successfullyDeletedFileIDs'] = $successfullyDeletedFileIDs; + + return $self; + } + + /** + * An array of fileIds that were successfully deleted. + * + * @param list $successfullyDeletedFileIDs + */ + public function withSuccessfullyDeletedFileIDs( + array $successfullyDeletedFileIDs + ): self { + $self = clone $this; + $self['successfullyDeletedFileIDs'] = $successfullyDeletedFileIDs; + + return $self; + } +} diff --git a/src/Files/Bulk/BulkRemoveAITagsParams.php b/src/Files/Bulk/BulkRemoveAITagsParams.php new file mode 100644 index 00000000..fbbe1f5e --- /dev/null +++ b/src/Files/Bulk/BulkRemoveAITagsParams.php @@ -0,0 +1,105 @@ +, fileIDs: list + * } + */ +final class BulkRemoveAITagsParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * An array of AITags that you want to remove from the files. + * + * @var list $aiTags + */ + #[Required('AITags', list: 'string')] + public array $aiTags; + + /** + * An array of fileIds from which you want to remove AITags. + * + * @var list $fileIDs + */ + #[Required('fileIds', list: 'string')] + public array $fileIDs; + + /** + * `new BulkRemoveAITagsParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BulkRemoveAITagsParams::with(aiTags: ..., fileIDs: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BulkRemoveAITagsParams)->withAITags(...)->withFileIDs(...) + * ``` + */ + 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 list $aiTags + * @param list $fileIDs + */ + public static function with(array $aiTags, array $fileIDs): self + { + $self = new self; + + $self['aiTags'] = $aiTags; + $self['fileIDs'] = $fileIDs; + + return $self; + } + + /** + * An array of AITags that you want to remove from the files. + * + * @param list $aiTags + */ + public function withAITags(array $aiTags): self + { + $self = clone $this; + $self['aiTags'] = $aiTags; + + return $self; + } + + /** + * An array of fileIds from which you want to remove AITags. + * + * @param list $fileIDs + */ + public function withFileIDs(array $fileIDs): self + { + $self = clone $this; + $self['fileIDs'] = $fileIDs; + + return $self; + } +} diff --git a/src/Files/Bulk/BulkRemoveAITagsResponse.php b/src/Files/Bulk/BulkRemoveAITagsResponse.php new file mode 100644 index 00000000..da106c25 --- /dev/null +++ b/src/Files/Bulk/BulkRemoveAITagsResponse.php @@ -0,0 +1,63 @@ +|null + * } + */ +final class BulkRemoveAITagsResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * An array of fileIds that in which AITags were successfully removed. + * + * @var list|null $successfullyUpdatedFileIDs + */ + #[Optional('successfullyUpdatedFileIds', list: 'string')] + public ?array $successfullyUpdatedFileIDs; + + 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 list|null $successfullyUpdatedFileIDs + */ + public static function with(?array $successfullyUpdatedFileIDs = null): self + { + $self = new self; + + null !== $successfullyUpdatedFileIDs && $self['successfullyUpdatedFileIDs'] = $successfullyUpdatedFileIDs; + + return $self; + } + + /** + * An array of fileIds that in which AITags were successfully removed. + * + * @param list $successfullyUpdatedFileIDs + */ + public function withSuccessfullyUpdatedFileIDs( + array $successfullyUpdatedFileIDs + ): self { + $self = clone $this; + $self['successfullyUpdatedFileIDs'] = $successfullyUpdatedFileIDs; + + return $self; + } +} diff --git a/src/Files/Bulk/BulkRemoveTagsParams.php b/src/Files/Bulk/BulkRemoveTagsParams.php new file mode 100644 index 00000000..dc147943 --- /dev/null +++ b/src/Files/Bulk/BulkRemoveTagsParams.php @@ -0,0 +1,105 @@ +, tags: list + * } + */ +final class BulkRemoveTagsParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * An array of fileIds from which you want to remove tags. + * + * @var list $fileIDs + */ + #[Required('fileIds', list: 'string')] + public array $fileIDs; + + /** + * An array of tags that you want to remove from the files. + * + * @var list $tags + */ + #[Required(list: 'string')] + public array $tags; + + /** + * `new BulkRemoveTagsParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BulkRemoveTagsParams::with(fileIDs: ..., tags: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BulkRemoveTagsParams)->withFileIDs(...)->withTags(...) + * ``` + */ + 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 list $fileIDs + * @param list $tags + */ + public static function with(array $fileIDs, array $tags): self + { + $self = new self; + + $self['fileIDs'] = $fileIDs; + $self['tags'] = $tags; + + return $self; + } + + /** + * An array of fileIds from which you want to remove tags. + * + * @param list $fileIDs + */ + public function withFileIDs(array $fileIDs): self + { + $self = clone $this; + $self['fileIDs'] = $fileIDs; + + return $self; + } + + /** + * An array of tags that you want to remove from the files. + * + * @param list $tags + */ + public function withTags(array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } +} diff --git a/src/Files/Bulk/BulkRemoveTagsResponse.php b/src/Files/Bulk/BulkRemoveTagsResponse.php new file mode 100644 index 00000000..5762922d --- /dev/null +++ b/src/Files/Bulk/BulkRemoveTagsResponse.php @@ -0,0 +1,63 @@ +|null + * } + */ +final class BulkRemoveTagsResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * An array of fileIds that in which tags were successfully removed. + * + * @var list|null $successfullyUpdatedFileIDs + */ + #[Optional('successfullyUpdatedFileIds', list: 'string')] + public ?array $successfullyUpdatedFileIDs; + + 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 list|null $successfullyUpdatedFileIDs + */ + public static function with(?array $successfullyUpdatedFileIDs = null): self + { + $self = new self; + + null !== $successfullyUpdatedFileIDs && $self['successfullyUpdatedFileIDs'] = $successfullyUpdatedFileIDs; + + return $self; + } + + /** + * An array of fileIds that in which tags were successfully removed. + * + * @param list $successfullyUpdatedFileIDs + */ + public function withSuccessfullyUpdatedFileIDs( + array $successfullyUpdatedFileIDs + ): self { + $self = clone $this; + $self['successfullyUpdatedFileIDs'] = $successfullyUpdatedFileIDs; + + return $self; + } +} diff --git a/src/Files/File.php b/src/Files/File.php new file mode 100644 index 00000000..0829a793 --- /dev/null +++ b/src/Files/File.php @@ -0,0 +1,649 @@ +|null, + * audioCodec?: string|null, + * bitRate?: int|null, + * createdAt?: \DateTimeInterface|null, + * customCoordinates?: string|null, + * customMetadata?: array|null, + * description?: string|null, + * duration?: int|null, + * embeddedMetadata?: array|null, + * fileID?: string|null, + * filePath?: string|null, + * fileType?: string|null, + * hasAlpha?: bool|null, + * height?: float|null, + * isPrivateFile?: bool|null, + * isPublished?: bool|null, + * mime?: string|null, + * name?: string|null, + * selectedFieldsSchema?: array|null, + * size?: float|null, + * tags?: list|null, + * thumbnail?: string|null, + * type?: null|Type|value-of, + * updatedAt?: \DateTimeInterface|null, + * url?: string|null, + * versionInfo?: null|VersionInfo|VersionInfoShape, + * videoCodec?: string|null, + * width?: float|null, + * } + */ +final class File implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Array of AI-generated tags associated with the image. If no AITags are set, it will be null. + * + * @var list|null $aiTags + */ + #[Optional('AITags', list: AITag::class, nullable: true)] + public ?array $aiTags; + + /** + * The audio codec used in the video (only for video/audio). + */ + #[Optional] + public ?string $audioCodec; + + /** + * The bit rate of the video in kbps (only for video). + */ + #[Optional] + public ?int $bitRate; + + /** + * Date and time when the file was uploaded. The date and time is in ISO8601 format. + */ + #[Optional] + public ?\DateTimeInterface $createdAt; + + /** + * An string with custom coordinates of the file. + */ + #[Optional(nullable: true)] + public ?string $customCoordinates; + + /** + * An object with custom metadata for the file. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + #[Optional] + public ?string $description; + + /** + * The duration of the video in seconds (only for video). + */ + #[Optional] + public ?int $duration; + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. + * + * @var array|null $embeddedMetadata + */ + #[Optional(map: 'mixed')] + public ?array $embeddedMetadata; + + /** + * Unique identifier of the asset. + */ + #[Optional('fileId')] + public ?string $fileID; + + /** + * Path of the file. This is the path you would use in the URL to access the file. For example, if the file is at the root of the media library, the path will be `/file.jpg`. If the file is inside a folder named `images`, the path will be `/images/file.jpg`. + */ + #[Optional] + public ?string $filePath; + + /** + * Type of the file. Possible values are `image`, `non-image`. + */ + #[Optional] + public ?string $fileType; + + /** + * Specifies if the image has an alpha channel. + */ + #[Optional] + public ?bool $hasAlpha; + + /** + * Height of the file. + */ + #[Optional] + public ?float $height; + + /** + * Specifies if the file is private or not. + */ + #[Optional] + public ?bool $isPrivateFile; + + /** + * Specifies if the file is published or not. + */ + #[Optional] + public ?bool $isPublished; + + /** + * MIME type of the file. + */ + #[Optional] + public ?string $mime; + + /** + * Name of the asset. + */ + #[Optional] + public ?string $name; + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @var array|null $selectedFieldsSchema + */ + #[Optional(map: SelectedFieldsSchema::class)] + public ?array $selectedFieldsSchema; + + /** + * Size of the file in bytes. + */ + #[Optional] + public ?float $size; + + /** + * An array of tags assigned to the file. Tags are used to search files in the media library. + * + * @var list|null $tags + */ + #[Optional(list: 'string', nullable: true)] + public ?array $tags; + + /** + * URL of the thumbnail image. This URL is used to access the thumbnail image of the file in the media library. + */ + #[Optional] + public ?string $thumbnail; + + /** + * Type of the asset. + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + /** + * Date and time when the file was last updated. The date and time is in ISO8601 format. + */ + #[Optional] + public ?\DateTimeInterface $updatedAt; + + /** + * URL of the file. + */ + #[Optional] + public ?string $url; + + /** + * An object with details of the file version. + */ + #[Optional] + public ?VersionInfo $versionInfo; + + /** + * The video codec used in the video (only for video). + */ + #[Optional] + public ?string $videoCodec; + + /** + * Width of the file. + */ + #[Optional] + public ?float $width; + + 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 list|null $aiTags + * @param array|null $customMetadata + * @param array|null $embeddedMetadata + * @param array|null $selectedFieldsSchema + * @param list|null $tags + * @param Type|value-of|null $type + * @param VersionInfo|VersionInfoShape|null $versionInfo + */ + public static function with( + ?array $aiTags = null, + ?string $audioCodec = null, + ?int $bitRate = null, + ?\DateTimeInterface $createdAt = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?int $duration = null, + ?array $embeddedMetadata = null, + ?string $fileID = null, + ?string $filePath = null, + ?string $fileType = null, + ?bool $hasAlpha = null, + ?float $height = null, + ?bool $isPrivateFile = null, + ?bool $isPublished = null, + ?string $mime = null, + ?string $name = null, + ?array $selectedFieldsSchema = null, + ?float $size = null, + ?array $tags = null, + ?string $thumbnail = null, + Type|string|null $type = null, + ?\DateTimeInterface $updatedAt = null, + ?string $url = null, + VersionInfo|array|null $versionInfo = null, + ?string $videoCodec = null, + ?float $width = null, + ): self { + $self = new self; + + null !== $aiTags && $self['aiTags'] = $aiTags; + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $bitRate && $self['bitRate'] = $bitRate; + null !== $createdAt && $self['createdAt'] = $createdAt; + null !== $customCoordinates && $self['customCoordinates'] = $customCoordinates; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $description && $self['description'] = $description; + null !== $duration && $self['duration'] = $duration; + null !== $embeddedMetadata && $self['embeddedMetadata'] = $embeddedMetadata; + null !== $fileID && $self['fileID'] = $fileID; + null !== $filePath && $self['filePath'] = $filePath; + null !== $fileType && $self['fileType'] = $fileType; + null !== $hasAlpha && $self['hasAlpha'] = $hasAlpha; + null !== $height && $self['height'] = $height; + null !== $isPrivateFile && $self['isPrivateFile'] = $isPrivateFile; + null !== $isPublished && $self['isPublished'] = $isPublished; + null !== $mime && $self['mime'] = $mime; + null !== $name && $self['name'] = $name; + null !== $selectedFieldsSchema && $self['selectedFieldsSchema'] = $selectedFieldsSchema; + null !== $size && $self['size'] = $size; + null !== $tags && $self['tags'] = $tags; + null !== $thumbnail && $self['thumbnail'] = $thumbnail; + null !== $type && $self['type'] = $type; + null !== $updatedAt && $self['updatedAt'] = $updatedAt; + null !== $url && $self['url'] = $url; + null !== $versionInfo && $self['versionInfo'] = $versionInfo; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + null !== $width && $self['width'] = $width; + + return $self; + } + + /** + * Array of AI-generated tags associated with the image. If no AITags are set, it will be null. + * + * @param list|null $aiTags + */ + public function withAITags(?array $aiTags): self + { + $self = clone $this; + $self['aiTags'] = $aiTags; + + return $self; + } + + /** + * The audio codec used in the video (only for video/audio). + */ + public function withAudioCodec(string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * The bit rate of the video in kbps (only for video). + */ + public function withBitRate(int $bitRate): self + { + $self = clone $this; + $self['bitRate'] = $bitRate; + + return $self; + } + + /** + * Date and time when the file was uploaded. The date and time is in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * An string with custom coordinates of the file. + */ + public function withCustomCoordinates(?string $customCoordinates): self + { + $self = clone $this; + $self['customCoordinates'] = $customCoordinates; + + return $self; + } + + /** + * An object with custom metadata for the file. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * The duration of the video in seconds (only for video). + */ + public function withDuration(int $duration): self + { + $self = clone $this; + $self['duration'] = $duration; + + return $self; + } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. + * + * @param array $embeddedMetadata + */ + public function withEmbeddedMetadata(array $embeddedMetadata): self + { + $self = clone $this; + $self['embeddedMetadata'] = $embeddedMetadata; + + return $self; + } + + /** + * Unique identifier of the asset. + */ + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } + + /** + * Path of the file. This is the path you would use in the URL to access the file. For example, if the file is at the root of the media library, the path will be `/file.jpg`. If the file is inside a folder named `images`, the path will be `/images/file.jpg`. + */ + public function withFilePath(string $filePath): self + { + $self = clone $this; + $self['filePath'] = $filePath; + + return $self; + } + + /** + * Type of the file. Possible values are `image`, `non-image`. + */ + public function withFileType(string $fileType): self + { + $self = clone $this; + $self['fileType'] = $fileType; + + return $self; + } + + /** + * Specifies if the image has an alpha channel. + */ + public function withHasAlpha(bool $hasAlpha): self + { + $self = clone $this; + $self['hasAlpha'] = $hasAlpha; + + return $self; + } + + /** + * Height of the file. + */ + public function withHeight(float $height): self + { + $self = clone $this; + $self['height'] = $height; + + return $self; + } + + /** + * Specifies if the file is private or not. + */ + public function withIsPrivateFile(bool $isPrivateFile): self + { + $self = clone $this; + $self['isPrivateFile'] = $isPrivateFile; + + return $self; + } + + /** + * Specifies if the file is published or not. + */ + public function withIsPublished(bool $isPublished): self + { + $self = clone $this; + $self['isPublished'] = $isPublished; + + return $self; + } + + /** + * MIME type of the file. + */ + public function withMime(string $mime): self + { + $self = clone $this; + $self['mime'] = $mime; + + return $self; + } + + /** + * Name of the asset. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @param array $selectedFieldsSchema + */ + public function withSelectedFieldsSchema(array $selectedFieldsSchema): self + { + $self = clone $this; + $self['selectedFieldsSchema'] = $selectedFieldsSchema; + + return $self; + } + + /** + * Size of the file in bytes. + */ + public function withSize(float $size): self + { + $self = clone $this; + $self['size'] = $size; + + return $self; + } + + /** + * An array of tags assigned to the file. Tags are used to search files in the media library. + * + * @param list|null $tags + */ + public function withTags(?array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } + + /** + * URL of the thumbnail image. This URL is used to access the thumbnail image of the file in the media library. + */ + public function withThumbnail(string $thumbnail): self + { + $self = clone $this; + $self['thumbnail'] = $thumbnail; + + return $self; + } + + /** + * Type of the asset. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Date and time when the file was last updated. The date and time is in ISO8601 format. + */ + public function withUpdatedAt(\DateTimeInterface $updatedAt): self + { + $self = clone $this; + $self['updatedAt'] = $updatedAt; + + return $self; + } + + /** + * URL of the file. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } + + /** + * An object with details of the file version. + * + * @param VersionInfo|VersionInfoShape $versionInfo + */ + public function withVersionInfo(VersionInfo|array $versionInfo): self + { + $self = clone $this; + $self['versionInfo'] = $versionInfo; + + return $self; + } + + /** + * The video codec used in the video (only for video). + */ + public function withVideoCodec(string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * Width of the file. + */ + public function withWidth(float $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/Files/File/AITag.php b/src/Files/File/AITag.php new file mode 100644 index 00000000..1b45d329 --- /dev/null +++ b/src/Files/File/AITag.php @@ -0,0 +1,97 @@ + */ + use SdkModel; + + /** + * Confidence score of the tag. + */ + #[Optional] + public ?float $confidence; + + /** + * Name of the tag. + */ + #[Optional] + public ?string $name; + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + */ + #[Optional] + public ?string $source; + + 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( + ?float $confidence = null, + ?string $name = null, + ?string $source = null + ): self { + $self = new self; + + null !== $confidence && $self['confidence'] = $confidence; + null !== $name && $self['name'] = $name; + null !== $source && $self['source'] = $source; + + return $self; + } + + /** + * Confidence score of the tag. + */ + public function withConfidence(float $confidence): self + { + $self = clone $this; + $self['confidence'] = $confidence; + + return $self; + } + + /** + * Name of the tag. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + */ + public function withSource(string $source): self + { + $self = clone $this; + $self['source'] = $source; + + return $self; + } +} diff --git a/src/Files/File/SelectedFieldsSchema.php b/src/Files/File/SelectedFieldsSchema.php new file mode 100644 index 00000000..8c9b953e --- /dev/null +++ b/src/Files/File/SelectedFieldsSchema.php @@ -0,0 +1,294 @@ +, + * defaultValue?: DefaultValueShape|null, + * isValueRequired?: bool|null, + * maxLength?: float|null, + * maxValue?: MaxValueShape|null, + * minLength?: float|null, + * minValue?: MinValueShape|null, + * readOnly?: bool|null, + * selectOptions?: list|null, + * selectOptionsTruncated?: bool|null, + * } + */ +final class SelectedFieldsSchema implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of the custom metadata field. + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * The default value for this custom metadata field. The value should match the `type` of custom metadata field. + * + * @var DefaultValueVariants|null $defaultValue + */ + #[Optional(union: DefaultValue::class)] + public string|float|bool|array|null $defaultValue; + + /** + * Specifies if the custom metadata field is required or not. + */ + #[Optional] + public ?bool $isValueRequired; + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $maxLength; + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MaxValueVariants|null $maxValue + */ + #[Optional] + public string|float|null $maxValue; + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $minLength; + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MinValueVariants|null $minValue + */ + #[Optional] + public string|float|null $minValue; + + /** + * Indicates whether the custom metadata field is read only. A read only field cannot be modified after being set. This field is configurable only via the **Path policy** feature. + */ + #[Optional] + public ?bool $readOnly; + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @var list|null $selectOptions + */ + #[Optional(list: SelectOption::class)] + public ?array $selectOptions; + + /** + * Specifies if the selectOptions array is truncated. It is truncated when number of options are > 100. + */ + #[Optional] + public ?bool $selectOptionsTruncated; + + /** + * `new SelectedFieldsSchema()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SelectedFieldsSchema::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SelectedFieldsSchema)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param DefaultValueShape|null $defaultValue + * @param MaxValueShape|null $maxValue + * @param MinValueShape|null $minValue + * @param list|null $selectOptions + */ + public static function with( + Type|string $type, + string|float|bool|array|null $defaultValue = null, + ?bool $isValueRequired = null, + ?float $maxLength = null, + string|float|null $maxValue = null, + ?float $minLength = null, + string|float|null $minValue = null, + ?bool $readOnly = null, + ?array $selectOptions = null, + ?bool $selectOptionsTruncated = null, + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $defaultValue && $self['defaultValue'] = $defaultValue; + null !== $isValueRequired && $self['isValueRequired'] = $isValueRequired; + null !== $maxLength && $self['maxLength'] = $maxLength; + null !== $maxValue && $self['maxValue'] = $maxValue; + null !== $minLength && $self['minLength'] = $minLength; + null !== $minValue && $self['minValue'] = $minValue; + null !== $readOnly && $self['readOnly'] = $readOnly; + null !== $selectOptions && $self['selectOptions'] = $selectOptions; + null !== $selectOptionsTruncated && $self['selectOptionsTruncated'] = $selectOptionsTruncated; + + return $self; + } + + /** + * Type of the custom metadata field. + * + * @param Type|value-of $type + */ + public function withType( + Type|string $type + ): self { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * The default value for this custom metadata field. The value should match the `type` of custom metadata field. + * + * @param DefaultValueShape $defaultValue + */ + public function withDefaultValue( + string|float|bool|array $defaultValue + ): self { + $self = clone $this; + $self['defaultValue'] = $defaultValue; + + return $self; + } + + /** + * Specifies if the custom metadata field is required or not. + */ + public function withIsValueRequired(bool $isValueRequired): self + { + $self = clone $this; + $self['isValueRequired'] = $isValueRequired; + + return $self; + } + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMaxLength(float $maxLength): self + { + $self = clone $this; + $self['maxLength'] = $maxLength; + + return $self; + } + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MaxValueShape $maxValue + */ + public function withMaxValue(string|float $maxValue): self + { + $self = clone $this; + $self['maxValue'] = $maxValue; + + return $self; + } + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMinLength(float $minLength): self + { + $self = clone $this; + $self['minLength'] = $minLength; + + return $self; + } + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MinValueShape $minValue + */ + public function withMinValue(string|float $minValue): self + { + $self = clone $this; + $self['minValue'] = $minValue; + + return $self; + } + + /** + * Indicates whether the custom metadata field is read only. A read only field cannot be modified after being set. This field is configurable only via the **Path policy** feature. + */ + public function withReadOnly(bool $readOnly): self + { + $self = clone $this; + $self['readOnly'] = $readOnly; + + return $self; + } + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @param list $selectOptions + */ + public function withSelectOptions(array $selectOptions): self + { + $self = clone $this; + $self['selectOptions'] = $selectOptions; + + return $self; + } + + /** + * Specifies if the selectOptions array is truncated. It is truncated when number of options are > 100. + */ + public function withSelectOptionsTruncated( + bool $selectOptionsTruncated + ): self { + $self = clone $this; + $self['selectOptionsTruncated'] = $selectOptionsTruncated; + + return $self; + } +} diff --git a/src/Files/File/SelectedFieldsSchema/DefaultValue.php b/src/Files/File/SelectedFieldsSchema/DefaultValue.php new file mode 100644 index 00000000..1a1a2a49 --- /dev/null +++ b/src/Files/File/SelectedFieldsSchema/DefaultValue.php @@ -0,0 +1,32 @@ + + * @phpstan-type DefaultValueShape = DefaultValueVariants|list + */ +final class DefaultValue implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/Files/File/SelectedFieldsSchema/DefaultValue/Mixed_.php b/src/Files/File/SelectedFieldsSchema/DefaultValue/Mixed_.php new file mode 100644 index 00000000..7a2f762e --- /dev/null +++ b/src/Files/File/SelectedFieldsSchema/DefaultValue/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/Files/File/SelectedFieldsSchema/MaxValue.php b/src/Files/File/SelectedFieldsSchema/MaxValue.php new file mode 100644 index 00000000..c06c6ccf --- /dev/null +++ b/src/Files/File/SelectedFieldsSchema/MaxValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/Files/File/SelectedFieldsSchema/MinValue.php b/src/Files/File/SelectedFieldsSchema/MinValue.php new file mode 100644 index 00000000..5a5101b0 --- /dev/null +++ b/src/Files/File/SelectedFieldsSchema/MinValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/Files/File/SelectedFieldsSchema/SelectOption.php b/src/Files/File/SelectedFieldsSchema/SelectOption.php new file mode 100644 index 00000000..dee55d4a --- /dev/null +++ b/src/Files/File/SelectedFieldsSchema/SelectOption.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/Files/File/SelectedFieldsSchema/Type.php b/src/Files/File/SelectedFieldsSchema/Type.php new file mode 100644 index 00000000..6d24b064 --- /dev/null +++ b/src/Files/File/SelectedFieldsSchema/Type.php @@ -0,0 +1,25 @@ + */ + use SdkModel; + + /** + * Unique identifier of the file version. + */ + #[Optional] + public ?string $id; + + /** + * Name of the file version. + */ + #[Optional] + public ?string $name; + + 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(?string $id = null, ?string $name = null): self + { + $self = new self; + + null !== $id && $self['id'] = $id; + null !== $name && $self['name'] = $name; + + return $self; + } + + /** + * Unique identifier of the file version. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Name of the file version. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/Files/FileCopyParams.php b/src/Files/FileCopyParams.php new file mode 100644 index 00000000..bc1e6a3c --- /dev/null +++ b/src/Files/FileCopyParams.php @@ -0,0 +1,121 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Full path to the folder you want to copy the above file into. + */ + #[Required] + public string $destinationPath; + + /** + * The full path of the file you want to copy. + */ + #[Required] + public string $sourceFilePath; + + /** + * Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied. Default value - `false`. + */ + #[Optional] + public ?bool $includeFileVersions; + + /** + * `new FileCopyParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileCopyParams::with(destinationPath: ..., sourceFilePath: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileCopyParams)->withDestinationPath(...)->withSourceFilePath(...) + * ``` + */ + 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( + string $destinationPath, + string $sourceFilePath, + ?bool $includeFileVersions = null, + ): self { + $self = new self; + + $self['destinationPath'] = $destinationPath; + $self['sourceFilePath'] = $sourceFilePath; + + null !== $includeFileVersions && $self['includeFileVersions'] = $includeFileVersions; + + return $self; + } + + /** + * Full path to the folder you want to copy the above file into. + */ + public function withDestinationPath(string $destinationPath): self + { + $self = clone $this; + $self['destinationPath'] = $destinationPath; + + return $self; + } + + /** + * The full path of the file you want to copy. + */ + public function withSourceFilePath(string $sourceFilePath): self + { + $self = clone $this; + $self['sourceFilePath'] = $sourceFilePath; + + return $self; + } + + /** + * Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied. Default value - `false`. + */ + public function withIncludeFileVersions(bool $includeFileVersions): self + { + $self = clone $this; + $self['includeFileVersions'] = $includeFileVersions; + + return $self; + } +} diff --git a/src/Files/FileCopyResponse.php b/src/Files/FileCopyResponse.php new file mode 100644 index 00000000..a4cbf359 --- /dev/null +++ b/src/Files/FileCopyResponse.php @@ -0,0 +1,32 @@ + + */ +final class FileCopyResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + 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(): self + { + return new self; + } +} diff --git a/src/Files/FileMoveParams.php b/src/Files/FileMoveParams.php new file mode 100644 index 00000000..9465649f --- /dev/null +++ b/src/Files/FileMoveParams.php @@ -0,0 +1,98 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Full path to the folder you want to move the above file into. + */ + #[Required] + public string $destinationPath; + + /** + * The full path of the file you want to move. + */ + #[Required] + public string $sourceFilePath; + + /** + * `new FileMoveParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileMoveParams::with(destinationPath: ..., sourceFilePath: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileMoveParams)->withDestinationPath(...)->withSourceFilePath(...) + * ``` + */ + 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( + string $destinationPath, + string $sourceFilePath + ): self { + $self = new self; + + $self['destinationPath'] = $destinationPath; + $self['sourceFilePath'] = $sourceFilePath; + + return $self; + } + + /** + * Full path to the folder you want to move the above file into. + */ + public function withDestinationPath(string $destinationPath): self + { + $self = clone $this; + $self['destinationPath'] = $destinationPath; + + return $self; + } + + /** + * The full path of the file you want to move. + */ + public function withSourceFilePath(string $sourceFilePath): self + { + $self = clone $this; + $self['sourceFilePath'] = $sourceFilePath; + + return $self; + } +} diff --git a/src/Files/FileMoveResponse.php b/src/Files/FileMoveResponse.php new file mode 100644 index 00000000..9173d423 --- /dev/null +++ b/src/Files/FileMoveResponse.php @@ -0,0 +1,32 @@ + + */ +final class FileMoveResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + 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(): self + { + return new self; + } +} diff --git a/src/Files/FileRenameParams.php b/src/Files/FileRenameParams.php new file mode 100644 index 00000000..50717564 --- /dev/null +++ b/src/Files/FileRenameParams.php @@ -0,0 +1,145 @@ + */ + use SdkModel; + use SdkParams; + + /** + * The full path of the file you want to rename. + */ + #[Required] + public string $filePath; + + /** + * The new name of the file. A filename can contain: + * + * Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals in other languages). + * Special Characters: `.`, `_`, and `-`. + * + * Any other character, including space, will be replaced by `_`. + */ + #[Required] + public string $newFileName; + + /** + * Option to purge cache for the old file and its versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove cached content of old file and its versions. This purge request is counted against your monthly purge quota. + * + * Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will remove the file and its versions' URLs and any transformations made using query parameters on this file or its versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation. + * + * + * + * Default value - `false` + */ + #[Optional] + public ?bool $purgeCache; + + /** + * `new FileRenameParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileRenameParams::with(filePath: ..., newFileName: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileRenameParams)->withFilePath(...)->withNewFileName(...) + * ``` + */ + 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( + string $filePath, + string $newFileName, + ?bool $purgeCache = null + ): self { + $self = new self; + + $self['filePath'] = $filePath; + $self['newFileName'] = $newFileName; + + null !== $purgeCache && $self['purgeCache'] = $purgeCache; + + return $self; + } + + /** + * The full path of the file you want to rename. + */ + public function withFilePath(string $filePath): self + { + $self = clone $this; + $self['filePath'] = $filePath; + + return $self; + } + + /** + * The new name of the file. A filename can contain: + * + * Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals in other languages). + * Special Characters: `.`, `_`, and `-`. + * + * Any other character, including space, will be replaced by `_`. + */ + public function withNewFileName(string $newFileName): self + { + $self = clone $this; + $self['newFileName'] = $newFileName; + + return $self; + } + + /** + * Option to purge cache for the old file and its versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove cached content of old file and its versions. This purge request is counted against your monthly purge quota. + * + * Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will remove the file and its versions' URLs and any transformations made using query parameters on this file or its versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation. + * + * + * + * Default value - `false` + */ + public function withPurgeCache(bool $purgeCache): self + { + $self = clone $this; + $self['purgeCache'] = $purgeCache; + + return $self; + } +} diff --git a/src/Files/FileRenameResponse.php b/src/Files/FileRenameResponse.php new file mode 100644 index 00000000..da01c35a --- /dev/null +++ b/src/Files/FileRenameResponse.php @@ -0,0 +1,54 @@ + */ + use SdkModel; + + /** + * Unique identifier of the purge request. This can be used to check the status of the purge request. + */ + #[Optional('purgeRequestId')] + public ?string $purgeRequestID; + + 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(?string $purgeRequestID = null): self + { + $self = new self; + + null !== $purgeRequestID && $self['purgeRequestID'] = $purgeRequestID; + + return $self; + } + + /** + * Unique identifier of the purge request. This can be used to check the status of the purge request. + */ + public function withPurgeRequestID(string $purgeRequestID): self + { + $self = clone $this; + $self['purgeRequestID'] = $purgeRequestID; + + return $self; + } +} diff --git a/src/Files/FileUpdateParams.php b/src/Files/FileUpdateParams.php new file mode 100644 index 00000000..c978c0f5 --- /dev/null +++ b/src/Files/FileUpdateParams.php @@ -0,0 +1,244 @@ +|null, + * description?: string|null, + * extensions?: list|null, + * removeAITags?: RemoveAITagsShape|null, + * tags?: list|null, + * webhookURL?: string|null, + * publish?: null|Publish|PublishShape, + * } + */ +final class FileUpdateParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * Define an important area in the image in the format `x,y,width,height` e.g. `10,10,100,100`. Send `null` to unset this value. + */ + #[Optional(nullable: true)] + public ?string $customCoordinates; + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` value for that key. Before setting any custom metadata on an asset you have to create the field using custom metadata fields API. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Optional text to describe the contents of the file. + */ + #[Optional] + public ?string $description; + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * + * @var list|null $extensions + */ + #[Optional(list: ExtensionItem::class)] + public ?array $extensions; + + /** + * An array of AITags associated with the file that you want to remove, e.g. `["car", "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are processed. + * + * @var RemoveAITagsVariants|null $removeAITags + */ + #[Optional(union: RemoveAITags::class)] + public string|array|null $removeAITags; + + /** + * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to unset all tags associated with the file. + * + * @var list|null $tags + */ + #[Optional(list: 'string', nullable: true)] + public ?array $tags; + + /** + * The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + */ + #[Optional('webhookUrl')] + public ?string $webhookURL; + + /** + * Configure the publication status of a file and its versions. + */ + #[Optional] + public ?Publish $publish; + + 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 array|null $customMetadata + * @param list|null $extensions + * @param RemoveAITagsShape|null $removeAITags + * @param list|null $tags + * @param Publish|PublishShape|null $publish + */ + public static function with( + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?array $extensions = null, + string|array|null $removeAITags = null, + ?array $tags = null, + ?string $webhookURL = null, + Publish|array|null $publish = null, + ): self { + $self = new self; + + null !== $customCoordinates && $self['customCoordinates'] = $customCoordinates; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $description && $self['description'] = $description; + null !== $extensions && $self['extensions'] = $extensions; + null !== $removeAITags && $self['removeAITags'] = $removeAITags; + null !== $tags && $self['tags'] = $tags; + null !== $webhookURL && $self['webhookURL'] = $webhookURL; + null !== $publish && $self['publish'] = $publish; + + return $self; + } + + /** + * Define an important area in the image in the format `x,y,width,height` e.g. `10,10,100,100`. Send `null` to unset this value. + */ + public function withCustomCoordinates(?string $customCoordinates): self + { + $self = clone $this; + $self['customCoordinates'] = $customCoordinates; + + return $self; + } + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` value for that key. Before setting any custom metadata on an asset you have to create the field using custom metadata fields API. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Optional text to describe the contents of the file. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * + * @param list $extensions + */ + public function withExtensions(array $extensions): self + { + $self = clone $this; + $self['extensions'] = $extensions; + + return $self; + } + + /** + * An array of AITags associated with the file that you want to remove, e.g. `["car", "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are processed. + * + * @param RemoveAITagsShape $removeAITags + */ + public function withRemoveAITags(string|array $removeAITags): self + { + $self = clone $this; + $self['removeAITags'] = $removeAITags; + + return $self; + } + + /** + * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to unset all tags associated with the file. + * + * @param list|null $tags + */ + public function withTags(?array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } + + /** + * The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + */ + public function withWebhookURL(string $webhookURL): self + { + $self = clone $this; + $self['webhookURL'] = $webhookURL; + + return $self; + } + + /** + * Configure the publication status of a file and its versions. + * + * @param Publish|PublishShape $publish + */ + public function withPublish(Publish|array $publish): self + { + $self = clone $this; + $self['publish'] = $publish; + + return $self; + } +} diff --git a/src/Files/FileUpdateParams/Publish.php b/src/Files/FileUpdateParams/Publish.php new file mode 100644 index 00000000..958ddc0f --- /dev/null +++ b/src/Files/FileUpdateParams/Publish.php @@ -0,0 +1,94 @@ + */ + use SdkModel; + + /** + * Set to `true` to publish the file. Set to `false` to unpublish the file. + */ + #[Required] + public bool $isPublished; + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` to publish/unpublish only the current version of the file. + */ + #[Optional] + public ?bool $includeFileVersions; + + /** + * `new Publish()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Publish::with(isPublished: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Publish)->withIsPublished(...) + * ``` + */ + 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 $isPublished, + ?bool $includeFileVersions = null + ): self { + $self = new self; + + $self['isPublished'] = $isPublished; + + null !== $includeFileVersions && $self['includeFileVersions'] = $includeFileVersions; + + return $self; + } + + /** + * Set to `true` to publish the file. Set to `false` to unpublish the file. + */ + public function withIsPublished(bool $isPublished): self + { + $self = clone $this; + $self['isPublished'] = $isPublished; + + return $self; + } + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` to publish/unpublish only the current version of the file. + */ + public function withIncludeFileVersions(bool $includeFileVersions): self + { + $self = clone $this; + $self['includeFileVersions'] = $includeFileVersions; + + return $self; + } +} diff --git a/src/Files/FileUpdateParams/RemoveAITags.php b/src/Files/FileUpdateParams/RemoveAITags.php new file mode 100644 index 00000000..315e644c --- /dev/null +++ b/src/Files/FileUpdateParams/RemoveAITags.php @@ -0,0 +1,33 @@ + + * @phpstan-type RemoveAITagsShape = RemoveAITagsVariants + */ +final class RemoveAITags implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return [new ListOf('string'), 'string']; + } +} diff --git a/src/Files/FileUpdateResponse.php b/src/Files/FileUpdateResponse.php new file mode 100644 index 00000000..e7ea8e1b --- /dev/null +++ b/src/Files/FileUpdateResponse.php @@ -0,0 +1,670 @@ +|null, + * audioCodec?: string|null, + * bitRate?: int|null, + * createdAt?: \DateTimeInterface|null, + * customCoordinates?: string|null, + * customMetadata?: array|null, + * description?: string|null, + * duration?: int|null, + * embeddedMetadata?: array|null, + * fileID?: string|null, + * filePath?: string|null, + * fileType?: string|null, + * hasAlpha?: bool|null, + * height?: float|null, + * isPrivateFile?: bool|null, + * isPublished?: bool|null, + * mime?: string|null, + * name?: string|null, + * selectedFieldsSchema?: array|null, + * size?: float|null, + * tags?: list|null, + * thumbnail?: string|null, + * type?: null|Type|value-of, + * updatedAt?: \DateTimeInterface|null, + * url?: string|null, + * versionInfo?: null|VersionInfo|VersionInfoShape, + * videoCodec?: string|null, + * width?: float|null, + * extensionStatus?: null|ExtensionStatus|ExtensionStatusShape, + * } + */ +final class FileUpdateResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Array of AI-generated tags associated with the image. If no AITags are set, it will be null. + * + * @var list|null $aiTags + */ + #[Optional('AITags', list: AITag::class, nullable: true)] + public ?array $aiTags; + + /** + * The audio codec used in the video (only for video/audio). + */ + #[Optional] + public ?string $audioCodec; + + /** + * The bit rate of the video in kbps (only for video). + */ + #[Optional] + public ?int $bitRate; + + /** + * Date and time when the file was uploaded. The date and time is in ISO8601 format. + */ + #[Optional] + public ?\DateTimeInterface $createdAt; + + /** + * An string with custom coordinates of the file. + */ + #[Optional(nullable: true)] + public ?string $customCoordinates; + + /** + * A key-value data associated with the asset. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + #[Optional] + public ?string $description; + + /** + * The duration of the video in seconds (only for video). + */ + #[Optional] + public ?int $duration; + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. + * + * @var array|null $embeddedMetadata + */ + #[Optional(map: 'mixed')] + public ?array $embeddedMetadata; + + /** + * Unique identifier of the asset. + */ + #[Optional('fileId')] + public ?string $fileID; + + /** + * Path of the file. This is the path you would use in the URL to access the file. For example, if the file is at the root of the media library, the path will be `/file.jpg`. If the file is inside a folder named `images`, the path will be `/images/file.jpg`. + */ + #[Optional] + public ?string $filePath; + + /** + * Type of the file. Possible values are `image`, `non-image`. + */ + #[Optional] + public ?string $fileType; + + /** + * Specifies if the image has an alpha channel. + */ + #[Optional] + public ?bool $hasAlpha; + + /** + * Height of the file. + */ + #[Optional] + public ?float $height; + + /** + * Specifies if the file is private or not. + */ + #[Optional] + public ?bool $isPrivateFile; + + /** + * Specifies if the file is published or not. + */ + #[Optional] + public ?bool $isPublished; + + /** + * MIME type of the file. + */ + #[Optional] + public ?string $mime; + + /** + * Name of the asset. + */ + #[Optional] + public ?string $name; + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @var array|null $selectedFieldsSchema + */ + #[Optional(map: SelectedFieldsSchema::class)] + public ?array $selectedFieldsSchema; + + /** + * Size of the file in bytes. + */ + #[Optional] + public ?float $size; + + /** + * An array of tags assigned to the file. Tags are used to search files in the media library. + * + * @var list|null $tags + */ + #[Optional(list: 'string', nullable: true)] + public ?array $tags; + + /** + * URL of the thumbnail image. This URL is used to access the thumbnail image of the file in the media library. + */ + #[Optional] + public ?string $thumbnail; + + /** + * Type of the asset. + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + /** + * Date and time when the file was last updated. The date and time is in ISO8601 format. + */ + #[Optional] + public ?\DateTimeInterface $updatedAt; + + /** + * URL of the file. + */ + #[Optional] + public ?string $url; + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + */ + #[Optional] + public ?VersionInfo $versionInfo; + + /** + * The video codec used in the video (only for video). + */ + #[Optional] + public ?string $videoCodec; + + /** + * Width of the file. + */ + #[Optional] + public ?float $width; + + #[Optional] + public ?ExtensionStatus $extensionStatus; + + 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 list|null $aiTags + * @param array|null $customMetadata + * @param array|null $embeddedMetadata + * @param array|null $selectedFieldsSchema + * @param list|null $tags + * @param Type|value-of|null $type + * @param VersionInfo|VersionInfoShape|null $versionInfo + * @param ExtensionStatus|ExtensionStatusShape|null $extensionStatus + */ + public static function with( + ?array $aiTags = null, + ?string $audioCodec = null, + ?int $bitRate = null, + ?\DateTimeInterface $createdAt = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?int $duration = null, + ?array $embeddedMetadata = null, + ?string $fileID = null, + ?string $filePath = null, + ?string $fileType = null, + ?bool $hasAlpha = null, + ?float $height = null, + ?bool $isPrivateFile = null, + ?bool $isPublished = null, + ?string $mime = null, + ?string $name = null, + ?array $selectedFieldsSchema = null, + ?float $size = null, + ?array $tags = null, + ?string $thumbnail = null, + Type|string|null $type = null, + ?\DateTimeInterface $updatedAt = null, + ?string $url = null, + VersionInfo|array|null $versionInfo = null, + ?string $videoCodec = null, + ?float $width = null, + ExtensionStatus|array|null $extensionStatus = null, + ): self { + $self = new self; + + null !== $aiTags && $self['aiTags'] = $aiTags; + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $bitRate && $self['bitRate'] = $bitRate; + null !== $createdAt && $self['createdAt'] = $createdAt; + null !== $customCoordinates && $self['customCoordinates'] = $customCoordinates; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $description && $self['description'] = $description; + null !== $duration && $self['duration'] = $duration; + null !== $embeddedMetadata && $self['embeddedMetadata'] = $embeddedMetadata; + null !== $fileID && $self['fileID'] = $fileID; + null !== $filePath && $self['filePath'] = $filePath; + null !== $fileType && $self['fileType'] = $fileType; + null !== $hasAlpha && $self['hasAlpha'] = $hasAlpha; + null !== $height && $self['height'] = $height; + null !== $isPrivateFile && $self['isPrivateFile'] = $isPrivateFile; + null !== $isPublished && $self['isPublished'] = $isPublished; + null !== $mime && $self['mime'] = $mime; + null !== $name && $self['name'] = $name; + null !== $selectedFieldsSchema && $self['selectedFieldsSchema'] = $selectedFieldsSchema; + null !== $size && $self['size'] = $size; + null !== $tags && $self['tags'] = $tags; + null !== $thumbnail && $self['thumbnail'] = $thumbnail; + null !== $type && $self['type'] = $type; + null !== $updatedAt && $self['updatedAt'] = $updatedAt; + null !== $url && $self['url'] = $url; + null !== $versionInfo && $self['versionInfo'] = $versionInfo; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + null !== $width && $self['width'] = $width; + null !== $extensionStatus && $self['extensionStatus'] = $extensionStatus; + + return $self; + } + + /** + * Array of AI-generated tags associated with the image. If no AITags are set, it will be null. + * + * @param list|null $aiTags + */ + public function withAITags(?array $aiTags): self + { + $self = clone $this; + $self['aiTags'] = $aiTags; + + return $self; + } + + /** + * The audio codec used in the video (only for video/audio). + */ + public function withAudioCodec(string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * The bit rate of the video in kbps (only for video). + */ + public function withBitRate(int $bitRate): self + { + $self = clone $this; + $self['bitRate'] = $bitRate; + + return $self; + } + + /** + * Date and time when the file was uploaded. The date and time is in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * An string with custom coordinates of the file. + */ + public function withCustomCoordinates(?string $customCoordinates): self + { + $self = clone $this; + $self['customCoordinates'] = $customCoordinates; + + return $self; + } + + /** + * A key-value data associated with the asset. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * The duration of the video in seconds (only for video). + */ + public function withDuration(int $duration): self + { + $self = clone $this; + $self['duration'] = $duration; + + return $self; + } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. + * + * @param array $embeddedMetadata + */ + public function withEmbeddedMetadata(array $embeddedMetadata): self + { + $self = clone $this; + $self['embeddedMetadata'] = $embeddedMetadata; + + return $self; + } + + /** + * Unique identifier of the asset. + */ + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } + + /** + * Path of the file. This is the path you would use in the URL to access the file. For example, if the file is at the root of the media library, the path will be `/file.jpg`. If the file is inside a folder named `images`, the path will be `/images/file.jpg`. + */ + public function withFilePath(string $filePath): self + { + $self = clone $this; + $self['filePath'] = $filePath; + + return $self; + } + + /** + * Type of the file. Possible values are `image`, `non-image`. + */ + public function withFileType(string $fileType): self + { + $self = clone $this; + $self['fileType'] = $fileType; + + return $self; + } + + /** + * Specifies if the image has an alpha channel. + */ + public function withHasAlpha(bool $hasAlpha): self + { + $self = clone $this; + $self['hasAlpha'] = $hasAlpha; + + return $self; + } + + /** + * Height of the file. + */ + public function withHeight(float $height): self + { + $self = clone $this; + $self['height'] = $height; + + return $self; + } + + /** + * Specifies if the file is private or not. + */ + public function withIsPrivateFile(bool $isPrivateFile): self + { + $self = clone $this; + $self['isPrivateFile'] = $isPrivateFile; + + return $self; + } + + /** + * Specifies if the file is published or not. + */ + public function withIsPublished(bool $isPublished): self + { + $self = clone $this; + $self['isPublished'] = $isPublished; + + return $self; + } + + /** + * MIME type of the file. + */ + public function withMime(string $mime): self + { + $self = clone $this; + $self['mime'] = $mime; + + return $self; + } + + /** + * Name of the asset. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @param array $selectedFieldsSchema + */ + public function withSelectedFieldsSchema(array $selectedFieldsSchema): self + { + $self = clone $this; + $self['selectedFieldsSchema'] = $selectedFieldsSchema; + + return $self; + } + + /** + * Size of the file in bytes. + */ + public function withSize(float $size): self + { + $self = clone $this; + $self['size'] = $size; + + return $self; + } + + /** + * An array of tags assigned to the file. Tags are used to search files in the media library. + * + * @param list|null $tags + */ + public function withTags(?array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } + + /** + * URL of the thumbnail image. This URL is used to access the thumbnail image of the file in the media library. + */ + public function withThumbnail(string $thumbnail): self + { + $self = clone $this; + $self['thumbnail'] = $thumbnail; + + return $self; + } + + /** + * Type of the asset. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Date and time when the file was last updated. The date and time is in ISO8601 format. + */ + public function withUpdatedAt(\DateTimeInterface $updatedAt): self + { + $self = clone $this; + $self['updatedAt'] = $updatedAt; + + return $self; + } + + /** + * URL of the file. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + * + * @param VersionInfo|VersionInfoShape $versionInfo + */ + public function withVersionInfo(VersionInfo|array $versionInfo): self + { + $self = clone $this; + $self['versionInfo'] = $versionInfo; + + return $self; + } + + /** + * The video codec used in the video (only for video). + */ + public function withVideoCodec(string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * Width of the file. + */ + public function withWidth(float $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } + + /** + * @param ExtensionStatus|ExtensionStatusShape $extensionStatus + */ + public function withExtensionStatus( + ExtensionStatus|array $extensionStatus + ): self { + $self = clone $this; + $self['extensionStatus'] = $extensionStatus; + + return $self; + } +} diff --git a/src/Files/FileUpdateResponse/ExtensionStatus.php b/src/Files/FileUpdateResponse/ExtensionStatus.php new file mode 100644 index 00000000..a68f6468 --- /dev/null +++ b/src/Files/FileUpdateResponse/ExtensionStatus.php @@ -0,0 +1,141 @@ +, + * aiTasks?: null|AITasks|value-of, + * awsAutoTagging?: null|AwsAutoTagging|value-of, + * googleAutoTagging?: null|GoogleAutoTagging|value-of, + * removeBg?: null|RemoveBg|value-of, + * } + */ +final class ExtensionStatus implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var value-of|null $aiAutoDescription */ + #[Optional('ai-auto-description', enum: AIAutoDescription::class)] + public ?string $aiAutoDescription; + + /** @var value-of|null $aiTasks */ + #[Optional('ai-tasks', enum: AITasks::class)] + public ?string $aiTasks; + + /** @var value-of|null $awsAutoTagging */ + #[Optional('aws-auto-tagging', enum: AwsAutoTagging::class)] + public ?string $awsAutoTagging; + + /** @var value-of|null $googleAutoTagging */ + #[Optional('google-auto-tagging', enum: GoogleAutoTagging::class)] + public ?string $googleAutoTagging; + + /** @var value-of|null $removeBg */ + #[Optional('remove-bg', enum: RemoveBg::class)] + public ?string $removeBg; + + 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 AIAutoDescription|value-of|null $aiAutoDescription + * @param AITasks|value-of|null $aiTasks + * @param AwsAutoTagging|value-of|null $awsAutoTagging + * @param GoogleAutoTagging|value-of|null $googleAutoTagging + * @param RemoveBg|value-of|null $removeBg + */ + public static function with( + AIAutoDescription|string|null $aiAutoDescription = null, + AITasks|string|null $aiTasks = null, + AwsAutoTagging|string|null $awsAutoTagging = null, + GoogleAutoTagging|string|null $googleAutoTagging = null, + RemoveBg|string|null $removeBg = null, + ): self { + $self = new self; + + null !== $aiAutoDescription && $self['aiAutoDescription'] = $aiAutoDescription; + null !== $aiTasks && $self['aiTasks'] = $aiTasks; + null !== $awsAutoTagging && $self['awsAutoTagging'] = $awsAutoTagging; + null !== $googleAutoTagging && $self['googleAutoTagging'] = $googleAutoTagging; + null !== $removeBg && $self['removeBg'] = $removeBg; + + return $self; + } + + /** + * @param AIAutoDescription|value-of $aiAutoDescription + */ + public function withAIAutoDescription( + AIAutoDescription|string $aiAutoDescription + ): self { + $self = clone $this; + $self['aiAutoDescription'] = $aiAutoDescription; + + return $self; + } + + /** + * @param AITasks|value-of $aiTasks + */ + public function withAITasks(AITasks|string $aiTasks): self + { + $self = clone $this; + $self['aiTasks'] = $aiTasks; + + return $self; + } + + /** + * @param AwsAutoTagging|value-of $awsAutoTagging + */ + public function withAwsAutoTagging( + AwsAutoTagging|string $awsAutoTagging + ): self { + $self = clone $this; + $self['awsAutoTagging'] = $awsAutoTagging; + + return $self; + } + + /** + * @param GoogleAutoTagging|value-of $googleAutoTagging + */ + public function withGoogleAutoTagging( + GoogleAutoTagging|string $googleAutoTagging + ): self { + $self = clone $this; + $self['googleAutoTagging'] = $googleAutoTagging; + + return $self; + } + + /** + * @param RemoveBg|value-of $removeBg + */ + public function withRemoveBg(RemoveBg|string $removeBg): self + { + $self = clone $this; + $self['removeBg'] = $removeBg; + + return $self; + } +} diff --git a/src/Files/FileUpdateResponse/ExtensionStatus/AIAutoDescription.php b/src/Files/FileUpdateResponse/ExtensionStatus/AIAutoDescription.php new file mode 100644 index 00000000..ae67f332 --- /dev/null +++ b/src/Files/FileUpdateResponse/ExtensionStatus/AIAutoDescription.php @@ -0,0 +1,14 @@ +|null, + * description?: string|null, + * expire?: int|null, + * extensions?: list|null, + * folder?: string|null, + * isPrivateFile?: bool|null, + * isPublished?: bool|null, + * overwriteAITags?: bool|null, + * overwriteCustomMetadata?: bool|null, + * overwriteFile?: bool|null, + * overwriteTags?: bool|null, + * publicKey?: string|null, + * responseFields?: list>|null, + * signature?: string|null, + * tags?: list|null, + * transformation?: null|Transformation|TransformationShape, + * useUniqueFileName?: bool|null, + * webhookURL?: string|null, + * } + */ +final class FileUploadParams implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + use SdkParams; + + /** + * The API accepts any of the following: + * + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request. + */ + #[Required] + public string $file; + + /** + * The name with which the file has to be uploaded. + * The file name can contain: + * + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + */ + #[Required] + public string $fileName; + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field. + */ + #[Optional] + public ?string $token; + + /** + * Server-side checks to run on the asset. + * Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + #[Optional] + public ?string $checks; + + /** + * Define an important area in the image. This is only relevant for image type files. + * + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be removed. + */ + #[Optional] + public ?string $customCoordinates; + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Optional text to describe the contents of the file. + */ + #[Optional] + public ?string $description; + + /** + * The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side. + */ + #[Optional] + public ?int $expire; + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * + * @var list|null $extensions + */ + #[Optional(list: ExtensionItem::class)] + public ?array $extensions; + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. + * + * The folder name can contain: + * + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + #[Optional] + public ?string $folder; + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or signed URL. + */ + #[Optional] + public ?bool $isPrivateFile; + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + */ + #[Optional] + public ?bool $isPublished; + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + #[Optional] + public ?bool $overwriteAITags; + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed. + */ + #[Optional] + public ?bool $overwriteCustomMetadata; + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately. + */ + #[Optional] + public ?bool $overwriteFile; + + /** + * If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed. + */ + #[Optional] + public ?bool $overwriteTags; + + /** + * Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side. + */ + #[Optional] + public ?string $publicKey; + + /** + * Array of response field keys to include in the API response body. + * + * @var list>|null $responseFields + */ + #[Optional(list: ResponseField::class)] + public ?array $responseFields; + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side. + */ + #[Optional] + public ?string $signature; + + /** + * Set the tags while uploading the file. + * Provide an array of tag strings (e.g. `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed. + * If this field is not specified and the file is overwritten, the existing tags will be removed. + * + * @var list|null $tags + */ + #[Optional(list: 'string')] + public ?array $tags; + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * + * - `pre` — applied before the file is uploaded to the Media Library. + * Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + * + * - `post` — applied immediately after upload. + * Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + #[Optional] + public ?Transformation $transformation; + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced. + */ + #[Optional] + public ?bool $useUniqueFileName; + + /** + * The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + */ + #[Optional('webhookUrl')] + public ?string $webhookURL; + + /** + * `new FileUploadParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileUploadParams::with(file: ..., fileName: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileUploadParams)->withFile(...)->withFileName(...) + * ``` + */ + 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 array|null $customMetadata + * @param list|null $extensions + * @param list>|null $responseFields + * @param list|null $tags + * @param Transformation|TransformationShape|null $transformation + */ + public static function with( + string|FileParam $file, + string $fileName, + ?string $token = null, + ?string $checks = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?int $expire = null, + ?array $extensions = null, + ?string $folder = null, + ?bool $isPrivateFile = null, + ?bool $isPublished = null, + ?bool $overwriteAITags = null, + ?bool $overwriteCustomMetadata = null, + ?bool $overwriteFile = null, + ?bool $overwriteTags = null, + ?string $publicKey = null, + ?array $responseFields = null, + ?string $signature = null, + ?array $tags = null, + Transformation|array|null $transformation = null, + ?bool $useUniqueFileName = null, + ?string $webhookURL = null, + ): self { + $self = new self; + + $self['file'] = $file; + $self['fileName'] = $fileName; + + null !== $token && $self['token'] = $token; + null !== $checks && $self['checks'] = $checks; + null !== $customCoordinates && $self['customCoordinates'] = $customCoordinates; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $description && $self['description'] = $description; + null !== $expire && $self['expire'] = $expire; + null !== $extensions && $self['extensions'] = $extensions; + null !== $folder && $self['folder'] = $folder; + null !== $isPrivateFile && $self['isPrivateFile'] = $isPrivateFile; + null !== $isPublished && $self['isPublished'] = $isPublished; + null !== $overwriteAITags && $self['overwriteAITags'] = $overwriteAITags; + null !== $overwriteCustomMetadata && $self['overwriteCustomMetadata'] = $overwriteCustomMetadata; + null !== $overwriteFile && $self['overwriteFile'] = $overwriteFile; + null !== $overwriteTags && $self['overwriteTags'] = $overwriteTags; + null !== $publicKey && $self['publicKey'] = $publicKey; + null !== $responseFields && $self['responseFields'] = $responseFields; + null !== $signature && $self['signature'] = $signature; + null !== $tags && $self['tags'] = $tags; + null !== $transformation && $self['transformation'] = $transformation; + null !== $useUniqueFileName && $self['useUniqueFileName'] = $useUniqueFileName; + null !== $webhookURL && $self['webhookURL'] = $webhookURL; + + return $self; + } + + /** + * The API accepts any of the following: + * + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request. + */ + public function withFile(string|FileParam $file): self + { + $self = clone $this; + $self['file'] = $file; + + return $self; + } + + /** + * The name with which the file has to be uploaded. + * The file name can contain: + * + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + */ + public function withFileName(string $fileName): self + { + $self = clone $this; + $self['fileName'] = $fileName; + + return $self; + } + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field. + */ + public function withToken(string $token): self + { + $self = clone $this; + $self['token'] = $token; + + return $self; + } + + /** + * Server-side checks to run on the asset. + * Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + public function withChecks(string $checks): self + { + $self = clone $this; + $self['checks'] = $checks; + + return $self; + } + + /** + * Define an important area in the image. This is only relevant for image type files. + * + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be removed. + */ + public function withCustomCoordinates(string $customCoordinates): self + { + $self = clone $this; + $self['customCoordinates'] = $customCoordinates; + + return $self; + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Optional text to describe the contents of the file. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side. + */ + public function withExpire(int $expire): self + { + $self = clone $this; + $self['expire'] = $expire; + + return $self; + } + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * + * @param list $extensions + */ + public function withExtensions(array $extensions): self + { + $self = clone $this; + $self['extensions'] = $extensions; + + return $self; + } + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. + * + * The folder name can contain: + * + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + public function withFolder(string $folder): self + { + $self = clone $this; + $self['folder'] = $folder; + + return $self; + } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or signed URL. + */ + public function withIsPrivateFile(bool $isPrivateFile): self + { + $self = clone $this; + $self['isPrivateFile'] = $isPrivateFile; + + return $self; + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + */ + public function withIsPublished(bool $isPublished): self + { + $self = clone $this; + $self['isPublished'] = $isPublished; + + return $self; + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + public function withOverwriteAITags(bool $overwriteAITags): self + { + $self = clone $this; + $self['overwriteAITags'] = $overwriteAITags; + + return $self; + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed. + */ + public function withOverwriteCustomMetadata( + bool $overwriteCustomMetadata + ): self { + $self = clone $this; + $self['overwriteCustomMetadata'] = $overwriteCustomMetadata; + + return $self; + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately. + */ + public function withOverwriteFile(bool $overwriteFile): self + { + $self = clone $this; + $self['overwriteFile'] = $overwriteFile; + + return $self; + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed. + */ + public function withOverwriteTags(bool $overwriteTags): self + { + $self = clone $this; + $self['overwriteTags'] = $overwriteTags; + + return $self; + } + + /** + * Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side. + */ + public function withPublicKey(string $publicKey): self + { + $self = clone $this; + $self['publicKey'] = $publicKey; + + return $self; + } + + /** + * Array of response field keys to include in the API response body. + * + * @param list> $responseFields + */ + public function withResponseFields(array $responseFields): self + { + $self = clone $this; + $self['responseFields'] = $responseFields; + + return $self; + } + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side. + */ + public function withSignature(string $signature): self + { + $self = clone $this; + $self['signature'] = $signature; + + return $self; + } + + /** + * Set the tags while uploading the file. + * Provide an array of tag strings (e.g. `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed. + * If this field is not specified and the file is overwritten, the existing tags will be removed. + * + * @param list $tags + */ + public function withTags(array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * + * - `pre` — applied before the file is uploaded to the Media Library. + * Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + * + * - `post` — applied immediately after upload. + * Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @param Transformation|TransformationShape $transformation + */ + public function withTransformation( + Transformation|array $transformation + ): self { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced. + */ + public function withUseUniqueFileName(bool $useUniqueFileName): self + { + $self = clone $this; + $self['useUniqueFileName'] = $useUniqueFileName; + + return $self; + } + + /** + * The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + */ + public function withWebhookURL(string $webhookURL): self + { + $self = clone $this; + $self['webhookURL'] = $webhookURL; + + return $self; + } +} diff --git a/src/Files/FileUploadParams/ResponseField.php b/src/Files/FileUploadParams/ResponseField.php new file mode 100644 index 00000000..ad83a282 --- /dev/null +++ b/src/Files/FileUploadParams/ResponseField.php @@ -0,0 +1,24 @@ +|null, pre?: string|null + * } + */ +final class Transformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * List of transformations to apply *after* the file is uploaded. + * Each item must match one of the following types: + * `transformation`, `gif-to-video`, `thumbnail`, `abs`. + * + * @var list|null $post + */ + #[Optional(list: Post::class)] + public ?array $post; + + /** + * Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion. + */ + #[Optional] + public ?string $pre; + + 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 list|null $post + */ + public static function with(?array $post = null, ?string $pre = null): self + { + $self = new self; + + null !== $post && $self['post'] = $post; + null !== $pre && $self['pre'] = $pre; + + return $self; + } + + /** + * List of transformations to apply *after* the file is uploaded. + * Each item must match one of the following types: + * `transformation`, `gif-to-video`, `thumbnail`, `abs`. + * + * @param list $post + */ + public function withPost(array $post): self + { + $self = clone $this; + $self['post'] = $post; + + return $self; + } + + /** + * Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion. + */ + public function withPre(string $pre): self + { + $self = clone $this; + $self['pre'] = $pre; + + return $self; + } +} diff --git a/src/Files/FileUploadParams/Transformation/Post.php b/src/Files/FileUploadParams/Transformation/Post.php new file mode 100644 index 00000000..76f0cc9c --- /dev/null +++ b/src/Files/FileUploadParams/Transformation/Post.php @@ -0,0 +1,45 @@ +|array + */ + public static function variants(): array + { + return [ + 'transformation' => SimplePostTransformation::class, + 'gif-to-video' => ConvertGifToVideo::class, + 'thumbnail' => GenerateAThumbnail::class, + 'abs' => AdaptiveBitrateStreaming::class, + ]; + } +} diff --git a/src/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming.php b/src/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming.php new file mode 100644 index 00000000..f08b45bd --- /dev/null +++ b/src/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming.php @@ -0,0 +1,116 @@ +, type: 'abs', value: string + * } + */ +final class AdaptiveBitrateStreaming implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * @var 'abs' $type + */ + #[Required] + public string $type = 'abs'; + + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @var value-of $protocol + */ + #[Required(enum: Protocol::class)] + public string $protocol; + + /** + * List of different representations you want to create separated by an underscore. + */ + #[Required] + public string $value; + + /** + * `new AdaptiveBitrateStreaming()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * AdaptiveBitrateStreaming::with(protocol: ..., value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new AdaptiveBitrateStreaming)->withProtocol(...)->withValue(...) + * ``` + */ + 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 Protocol|value-of $protocol + */ + public static function with(Protocol|string $protocol, string $value): self + { + $self = new self; + + $self['protocol'] = $protocol; + $self['value'] = $value; + + return $self; + } + + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @param Protocol|value-of $protocol + */ + public function withProtocol(Protocol|string $protocol): self + { + $self = clone $this; + $self['protocol'] = $protocol; + + return $self; + } + + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * @param 'abs' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * List of different representations you want to create separated by an underscore. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming/Protocol.php b/src/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming/Protocol.php new file mode 100644 index 00000000..e7d1b239 --- /dev/null +++ b/src/Files/FileUploadParams/Transformation/Post/AdaptiveBitrateStreaming/Protocol.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * Converts an animated GIF into an MP4. + * + * @var 'gif-to-video' $type + */ + #[Required] + public string $type = 'gif-to-video'; + + /** + * Optional transformation string to apply to the output video. + * **Example**: `q-80`. + */ + #[Optional] + public ?string $value; + + 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(?string $value = null): self + { + $self = new self; + + null !== $value && $self['value'] = $value; + + return $self; + } + + /** + * Converts an animated GIF into an MP4. + * + * @param 'gif-to-video' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Optional transformation string to apply to the output video. + * **Example**: `q-80`. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Files/FileUploadParams/Transformation/Post/GenerateAThumbnail.php b/src/Files/FileUploadParams/Transformation/Post/GenerateAThumbnail.php new file mode 100644 index 00000000..3f1e3eae --- /dev/null +++ b/src/Files/FileUploadParams/Transformation/Post/GenerateAThumbnail.php @@ -0,0 +1,80 @@ + */ + use SdkModel; + + /** + * Generates a thumbnail image. + * + * @var 'thumbnail' $type + */ + #[Required] + public string $type = 'thumbnail'; + + /** + * Optional transformation string. + * **Example**: `w-150,h-150`. + */ + #[Optional] + public ?string $value; + + 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(?string $value = null): self + { + $self = new self; + + null !== $value && $self['value'] = $value; + + return $self; + } + + /** + * Generates a thumbnail image. + * + * @param 'thumbnail' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Optional transformation string. + * **Example**: `w-150,h-150`. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Files/FileUploadParams/Transformation/Post/SimplePostTransformation.php b/src/Files/FileUploadParams/Transformation/Post/SimplePostTransformation.php new file mode 100644 index 00000000..24302772 --- /dev/null +++ b/src/Files/FileUploadParams/Transformation/Post/SimplePostTransformation.php @@ -0,0 +1,93 @@ + */ + use SdkModel; + + /** + * Transformation type. + * + * @var 'transformation' $type + */ + #[Required] + public string $type = 'transformation'; + + /** + * Transformation string (e.g. `w-200,h-200`). + * Same syntax as ImageKit URL-based transformations. + */ + #[Required] + public string $value; + + /** + * `new SimplePostTransformation()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SimplePostTransformation::with(value: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SimplePostTransformation)->withValue(...) + * ``` + */ + 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(string $value): self + { + $self = new self; + + $self['value'] = $value; + + return $self; + } + + /** + * Transformation type. + * + * @param 'transformation' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Transformation string (e.g. `w-200,h-200`). + * Same syntax as ImageKit URL-based transformations. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Files/FileUploadResponse.php b/src/Files/FileUploadResponse.php new file mode 100644 index 00000000..a505ef53 --- /dev/null +++ b/src/Files/FileUploadResponse.php @@ -0,0 +1,605 @@ +|null, + * audioCodec?: string|null, + * bitRate?: int|null, + * customCoordinates?: string|null, + * customMetadata?: array|null, + * description?: string|null, + * duration?: int|null, + * embeddedMetadata?: array|null, + * extensionStatus?: null|ExtensionStatus|ExtensionStatusShape, + * fileID?: string|null, + * filePath?: string|null, + * fileType?: string|null, + * height?: float|null, + * isPrivateFile?: bool|null, + * isPublished?: bool|null, + * metadata?: null|Metadata|MetadataShape, + * name?: string|null, + * selectedFieldsSchema?: array|null, + * size?: float|null, + * tags?: list|null, + * thumbnailURL?: string|null, + * url?: string|null, + * versionInfo?: null|VersionInfo|VersionInfoShape, + * videoCodec?: string|null, + * width?: float|null, + * } + */ +final class FileUploadResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * An array of tags assigned to the uploaded file by auto tagging. + * + * @var list|null $aiTags + */ + #[Optional('AITags', list: AITag::class, nullable: true)] + public ?array $aiTags; + + /** + * The audio codec used in the video (only for video). + */ + #[Optional] + public ?string $audioCodec; + + /** + * The bit rate of the video in kbps (only for video). + */ + #[Optional] + public ?int $bitRate; + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in `responseFields` in API request to get the value of this field. + */ + #[Optional(nullable: true)] + public ?string $customCoordinates; + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get `customMetadata` in the upload API response. Before setting any custom metadata on an asset, you have to create the field using custom metadata fields API. Send `customMetadata` in `responseFields` in API request to get the value of this field. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + #[Optional] + public ?string $description; + + /** + * The duration of the video in seconds (only for video). + */ + #[Optional] + public ?int $duration; + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in the upload API response. + * + * @var array|null $embeddedMetadata + */ + #[Optional(map: 'mixed')] + public ?array $embeddedMetadata; + + /** + * Extension names with their processing status at the time of completion of the request. It could have one of the following status values: + * + * `success`: The extension has been successfully applied. + * `failed`: The extension has failed and will not be retried. + * `pending`: The extension will finish processing in some time. On completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + */ + #[Optional] + public ?ExtensionStatus $extensionStatus; + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update action on this file. + */ + #[Optional('fileId')] + public ?string $fileID; + + /** + * The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + */ + #[Optional] + public ?string $filePath; + + /** + * Type of the uploaded file. Possible values are `image`, `non-image`. + */ + #[Optional] + public ?string $fileType; + + /** + * Height of the image in pixels (Only for images). + */ + #[Optional] + public ?float $height; + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` in `responseFields` in API request to get the value of this field. + */ + #[Optional] + public ?bool $isPrivateFile; + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send `isPublished` in `responseFields` in API request to get the value of this field. + */ + #[Optional] + public ?bool $isPublished; + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the upload API response. + */ + #[Optional] + public ?Metadata $metadata; + + /** + * Name of the asset. + */ + #[Optional] + public ?string $name; + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @var array|null $selectedFieldsSchema + */ + #[Optional(map: SelectedFieldsSchema::class)] + public ?array $selectedFieldsSchema; + + /** + * Size of the image file in Bytes. + */ + #[Optional] + public ?float $size; + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send `tags` in `responseFields` in API request to get the value of this field. + * + * @var list|null $tags + */ + #[Optional(list: 'string', nullable: true)] + public ?array $tags; + + /** + * In the case of an image, a small thumbnail URL. + */ + #[Optional('thumbnailUrl')] + public ?string $thumbnailURL; + + /** + * A publicly accessible URL of the file. + */ + #[Optional] + public ?string $url; + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + */ + #[Optional] + public ?VersionInfo $versionInfo; + + /** + * The video codec used in the video (only for video). + */ + #[Optional] + public ?string $videoCodec; + + /** + * Width of the image in pixels (Only for Images). + */ + #[Optional] + public ?float $width; + + 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 list|null $aiTags + * @param array|null $customMetadata + * @param array|null $embeddedMetadata + * @param ExtensionStatus|ExtensionStatusShape|null $extensionStatus + * @param Metadata|MetadataShape|null $metadata + * @param array|null $selectedFieldsSchema + * @param list|null $tags + * @param VersionInfo|VersionInfoShape|null $versionInfo + */ + public static function with( + ?array $aiTags = null, + ?string $audioCodec = null, + ?int $bitRate = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?int $duration = null, + ?array $embeddedMetadata = null, + ExtensionStatus|array|null $extensionStatus = null, + ?string $fileID = null, + ?string $filePath = null, + ?string $fileType = null, + ?float $height = null, + ?bool $isPrivateFile = null, + ?bool $isPublished = null, + Metadata|array|null $metadata = null, + ?string $name = null, + ?array $selectedFieldsSchema = null, + ?float $size = null, + ?array $tags = null, + ?string $thumbnailURL = null, + ?string $url = null, + VersionInfo|array|null $versionInfo = null, + ?string $videoCodec = null, + ?float $width = null, + ): self { + $self = new self; + + null !== $aiTags && $self['aiTags'] = $aiTags; + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $bitRate && $self['bitRate'] = $bitRate; + null !== $customCoordinates && $self['customCoordinates'] = $customCoordinates; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $description && $self['description'] = $description; + null !== $duration && $self['duration'] = $duration; + null !== $embeddedMetadata && $self['embeddedMetadata'] = $embeddedMetadata; + null !== $extensionStatus && $self['extensionStatus'] = $extensionStatus; + null !== $fileID && $self['fileID'] = $fileID; + null !== $filePath && $self['filePath'] = $filePath; + null !== $fileType && $self['fileType'] = $fileType; + null !== $height && $self['height'] = $height; + null !== $isPrivateFile && $self['isPrivateFile'] = $isPrivateFile; + null !== $isPublished && $self['isPublished'] = $isPublished; + null !== $metadata && $self['metadata'] = $metadata; + null !== $name && $self['name'] = $name; + null !== $selectedFieldsSchema && $self['selectedFieldsSchema'] = $selectedFieldsSchema; + null !== $size && $self['size'] = $size; + null !== $tags && $self['tags'] = $tags; + null !== $thumbnailURL && $self['thumbnailURL'] = $thumbnailURL; + null !== $url && $self['url'] = $url; + null !== $versionInfo && $self['versionInfo'] = $versionInfo; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + null !== $width && $self['width'] = $width; + + return $self; + } + + /** + * An array of tags assigned to the uploaded file by auto tagging. + * + * @param list|null $aiTags + */ + public function withAITags(?array $aiTags): self + { + $self = clone $this; + $self['aiTags'] = $aiTags; + + return $self; + } + + /** + * The audio codec used in the video (only for video). + */ + public function withAudioCodec(string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * The bit rate of the video in kbps (only for video). + */ + public function withBitRate(int $bitRate): self + { + $self = clone $this; + $self['bitRate'] = $bitRate; + + return $self; + } + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in `responseFields` in API request to get the value of this field. + */ + public function withCustomCoordinates(?string $customCoordinates): self + { + $self = clone $this; + $self['customCoordinates'] = $customCoordinates; + + return $self; + } + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get `customMetadata` in the upload API response. Before setting any custom metadata on an asset, you have to create the field using custom metadata fields API. Send `customMetadata` in `responseFields` in API request to get the value of this field. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * The duration of the video in seconds (only for video). + */ + public function withDuration(int $duration): self + { + $self = clone $this; + $self['duration'] = $duration; + + return $self; + } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in the upload API response. + * + * @param array $embeddedMetadata + */ + public function withEmbeddedMetadata(array $embeddedMetadata): self + { + $self = clone $this; + $self['embeddedMetadata'] = $embeddedMetadata; + + return $self; + } + + /** + * Extension names with their processing status at the time of completion of the request. It could have one of the following status values: + * + * `success`: The extension has been successfully applied. + * `failed`: The extension has failed and will not be retried. + * `pending`: The extension will finish processing in some time. On completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + * + * @param ExtensionStatus|ExtensionStatusShape $extensionStatus + */ + public function withExtensionStatus( + ExtensionStatus|array $extensionStatus + ): self { + $self = clone $this; + $self['extensionStatus'] = $extensionStatus; + + return $self; + } + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update action on this file. + */ + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } + + /** + * The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + */ + public function withFilePath(string $filePath): self + { + $self = clone $this; + $self['filePath'] = $filePath; + + return $self; + } + + /** + * Type of the uploaded file. Possible values are `image`, `non-image`. + */ + public function withFileType(string $fileType): self + { + $self = clone $this; + $self['fileType'] = $fileType; + + return $self; + } + + /** + * Height of the image in pixels (Only for images). + */ + public function withHeight(float $height): self + { + $self = clone $this; + $self['height'] = $height; + + return $self; + } + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` in `responseFields` in API request to get the value of this field. + */ + public function withIsPrivateFile(bool $isPrivateFile): self + { + $self = clone $this; + $self['isPrivateFile'] = $isPrivateFile; + + return $self; + } + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send `isPublished` in `responseFields` in API request to get the value of this field. + */ + public function withIsPublished(bool $isPublished): self + { + $self = clone $this; + $self['isPublished'] = $isPublished; + + return $self; + } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the upload API response. + * + * @param Metadata|MetadataShape $metadata + */ + public function withMetadata(Metadata|array $metadata): self + { + $self = clone $this; + $self['metadata'] = $metadata; + + return $self; + } + + /** + * Name of the asset. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @param array $selectedFieldsSchema + */ + public function withSelectedFieldsSchema(array $selectedFieldsSchema): self + { + $self = clone $this; + $self['selectedFieldsSchema'] = $selectedFieldsSchema; + + return $self; + } + + /** + * Size of the image file in Bytes. + */ + public function withSize(float $size): self + { + $self = clone $this; + $self['size'] = $size; + + return $self; + } + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send `tags` in `responseFields` in API request to get the value of this field. + * + * @param list|null $tags + */ + public function withTags(?array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } + + /** + * In the case of an image, a small thumbnail URL. + */ + public function withThumbnailURL(string $thumbnailURL): self + { + $self = clone $this; + $self['thumbnailURL'] = $thumbnailURL; + + return $self; + } + + /** + * A publicly accessible URL of the file. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + * + * @param VersionInfo|VersionInfoShape $versionInfo + */ + public function withVersionInfo(VersionInfo|array $versionInfo): self + { + $self = clone $this; + $self['versionInfo'] = $versionInfo; + + return $self; + } + + /** + * The video codec used in the video (only for video). + */ + public function withVideoCodec(string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * Width of the image in pixels (Only for Images). + */ + public function withWidth(float $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/Files/FileUploadResponse/AITag.php b/src/Files/FileUploadResponse/AITag.php new file mode 100644 index 00000000..c0d1def2 --- /dev/null +++ b/src/Files/FileUploadResponse/AITag.php @@ -0,0 +1,97 @@ + */ + use SdkModel; + + /** + * Confidence score of the tag. + */ + #[Optional] + public ?float $confidence; + + /** + * Name of the tag. + */ + #[Optional] + public ?string $name; + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + */ + #[Optional] + public ?string $source; + + 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( + ?float $confidence = null, + ?string $name = null, + ?string $source = null + ): self { + $self = new self; + + null !== $confidence && $self['confidence'] = $confidence; + null !== $name && $self['name'] = $name; + null !== $source && $self['source'] = $source; + + return $self; + } + + /** + * Confidence score of the tag. + */ + public function withConfidence(float $confidence): self + { + $self = clone $this; + $self['confidence'] = $confidence; + + return $self; + } + + /** + * Name of the tag. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + */ + public function withSource(string $source): self + { + $self = clone $this; + $self['source'] = $source; + + return $self; + } +} diff --git a/src/Files/FileUploadResponse/ExtensionStatus.php b/src/Files/FileUploadResponse/ExtensionStatus.php new file mode 100644 index 00000000..ae08d714 --- /dev/null +++ b/src/Files/FileUploadResponse/ExtensionStatus.php @@ -0,0 +1,149 @@ +, + * aiTasks?: null|AITasks|value-of, + * awsAutoTagging?: null|AwsAutoTagging|value-of, + * googleAutoTagging?: null|GoogleAutoTagging|value-of, + * removeBg?: null|RemoveBg|value-of, + * } + */ +final class ExtensionStatus implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var value-of|null $aiAutoDescription */ + #[Optional('ai-auto-description', enum: AIAutoDescription::class)] + public ?string $aiAutoDescription; + + /** @var value-of|null $aiTasks */ + #[Optional('ai-tasks', enum: AITasks::class)] + public ?string $aiTasks; + + /** @var value-of|null $awsAutoTagging */ + #[Optional('aws-auto-tagging', enum: AwsAutoTagging::class)] + public ?string $awsAutoTagging; + + /** @var value-of|null $googleAutoTagging */ + #[Optional('google-auto-tagging', enum: GoogleAutoTagging::class)] + public ?string $googleAutoTagging; + + /** @var value-of|null $removeBg */ + #[Optional('remove-bg', enum: RemoveBg::class)] + public ?string $removeBg; + + 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 AIAutoDescription|value-of|null $aiAutoDescription + * @param AITasks|value-of|null $aiTasks + * @param AwsAutoTagging|value-of|null $awsAutoTagging + * @param GoogleAutoTagging|value-of|null $googleAutoTagging + * @param RemoveBg|value-of|null $removeBg + */ + public static function with( + AIAutoDescription|string|null $aiAutoDescription = null, + AITasks|string|null $aiTasks = null, + AwsAutoTagging|string|null $awsAutoTagging = null, + GoogleAutoTagging|string|null $googleAutoTagging = null, + RemoveBg|string|null $removeBg = null, + ): self { + $self = new self; + + null !== $aiAutoDescription && $self['aiAutoDescription'] = $aiAutoDescription; + null !== $aiTasks && $self['aiTasks'] = $aiTasks; + null !== $awsAutoTagging && $self['awsAutoTagging'] = $awsAutoTagging; + null !== $googleAutoTagging && $self['googleAutoTagging'] = $googleAutoTagging; + null !== $removeBg && $self['removeBg'] = $removeBg; + + return $self; + } + + /** + * @param AIAutoDescription|value-of $aiAutoDescription + */ + public function withAIAutoDescription( + AIAutoDescription|string $aiAutoDescription + ): self { + $self = clone $this; + $self['aiAutoDescription'] = $aiAutoDescription; + + return $self; + } + + /** + * @param AITasks|value-of $aiTasks + */ + public function withAITasks(AITasks|string $aiTasks): self + { + $self = clone $this; + $self['aiTasks'] = $aiTasks; + + return $self; + } + + /** + * @param AwsAutoTagging|value-of $awsAutoTagging + */ + public function withAwsAutoTagging( + AwsAutoTagging|string $awsAutoTagging + ): self { + $self = clone $this; + $self['awsAutoTagging'] = $awsAutoTagging; + + return $self; + } + + /** + * @param GoogleAutoTagging|value-of $googleAutoTagging + */ + public function withGoogleAutoTagging( + GoogleAutoTagging|string $googleAutoTagging + ): self { + $self = clone $this; + $self['googleAutoTagging'] = $googleAutoTagging; + + return $self; + } + + /** + * @param RemoveBg|value-of $removeBg + */ + public function withRemoveBg(RemoveBg|string $removeBg): self + { + $self = clone $this; + $self['removeBg'] = $removeBg; + + return $self; + } +} diff --git a/src/Files/FileUploadResponse/ExtensionStatus/AIAutoDescription.php b/src/Files/FileUploadResponse/ExtensionStatus/AIAutoDescription.php new file mode 100644 index 00000000..a12ba5f1 --- /dev/null +++ b/src/Files/FileUploadResponse/ExtensionStatus/AIAutoDescription.php @@ -0,0 +1,14 @@ +, + * defaultValue?: DefaultValueShape|null, + * isValueRequired?: bool|null, + * maxLength?: float|null, + * maxValue?: MaxValueShape|null, + * minLength?: float|null, + * minValue?: MinValueShape|null, + * readOnly?: bool|null, + * selectOptions?: list|null, + * selectOptionsTruncated?: bool|null, + * } + */ +final class SelectedFieldsSchema implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of the custom metadata field. + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * The default value for this custom metadata field. The value should match the `type` of custom metadata field. + * + * @var DefaultValueVariants|null $defaultValue + */ + #[Optional(union: DefaultValue::class)] + public string|float|bool|array|null $defaultValue; + + /** + * Specifies if the custom metadata field is required or not. + */ + #[Optional] + public ?bool $isValueRequired; + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $maxLength; + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MaxValueVariants|null $maxValue + */ + #[Optional] + public string|float|null $maxValue; + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $minLength; + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MinValueVariants|null $minValue + */ + #[Optional] + public string|float|null $minValue; + + /** + * Indicates whether the custom metadata field is read only. A read only field cannot be modified after being set. This field is configurable only via the **Path policy** feature. + */ + #[Optional] + public ?bool $readOnly; + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @var list|null $selectOptions + */ + #[Optional(list: SelectOption::class)] + public ?array $selectOptions; + + /** + * Specifies if the selectOptions array is truncated. It is truncated when number of options are > 100. + */ + #[Optional] + public ?bool $selectOptionsTruncated; + + /** + * `new SelectedFieldsSchema()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SelectedFieldsSchema::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SelectedFieldsSchema)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param DefaultValueShape|null $defaultValue + * @param MaxValueShape|null $maxValue + * @param MinValueShape|null $minValue + * @param list|null $selectOptions + */ + public static function with( + Type|string $type, + string|float|bool|array|null $defaultValue = null, + ?bool $isValueRequired = null, + ?float $maxLength = null, + string|float|null $maxValue = null, + ?float $minLength = null, + string|float|null $minValue = null, + ?bool $readOnly = null, + ?array $selectOptions = null, + ?bool $selectOptionsTruncated = null, + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $defaultValue && $self['defaultValue'] = $defaultValue; + null !== $isValueRequired && $self['isValueRequired'] = $isValueRequired; + null !== $maxLength && $self['maxLength'] = $maxLength; + null !== $maxValue && $self['maxValue'] = $maxValue; + null !== $minLength && $self['minLength'] = $minLength; + null !== $minValue && $self['minValue'] = $minValue; + null !== $readOnly && $self['readOnly'] = $readOnly; + null !== $selectOptions && $self['selectOptions'] = $selectOptions; + null !== $selectOptionsTruncated && $self['selectOptionsTruncated'] = $selectOptionsTruncated; + + return $self; + } + + /** + * Type of the custom metadata field. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * The default value for this custom metadata field. The value should match the `type` of custom metadata field. + * + * @param DefaultValueShape $defaultValue + */ + public function withDefaultValue( + string|float|bool|array $defaultValue + ): self { + $self = clone $this; + $self['defaultValue'] = $defaultValue; + + return $self; + } + + /** + * Specifies if the custom metadata field is required or not. + */ + public function withIsValueRequired(bool $isValueRequired): self + { + $self = clone $this; + $self['isValueRequired'] = $isValueRequired; + + return $self; + } + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMaxLength(float $maxLength): self + { + $self = clone $this; + $self['maxLength'] = $maxLength; + + return $self; + } + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MaxValueShape $maxValue + */ + public function withMaxValue(string|float $maxValue): self + { + $self = clone $this; + $self['maxValue'] = $maxValue; + + return $self; + } + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMinLength(float $minLength): self + { + $self = clone $this; + $self['minLength'] = $minLength; + + return $self; + } + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MinValueShape $minValue + */ + public function withMinValue(string|float $minValue): self + { + $self = clone $this; + $self['minValue'] = $minValue; + + return $self; + } + + /** + * Indicates whether the custom metadata field is read only. A read only field cannot be modified after being set. This field is configurable only via the **Path policy** feature. + */ + public function withReadOnly(bool $readOnly): self + { + $self = clone $this; + $self['readOnly'] = $readOnly; + + return $self; + } + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @param list $selectOptions + */ + public function withSelectOptions(array $selectOptions): self + { + $self = clone $this; + $self['selectOptions'] = $selectOptions; + + return $self; + } + + /** + * Specifies if the selectOptions array is truncated. It is truncated when number of options are > 100. + */ + public function withSelectOptionsTruncated( + bool $selectOptionsTruncated + ): self { + $self = clone $this; + $self['selectOptionsTruncated'] = $selectOptionsTruncated; + + return $self; + } +} diff --git a/src/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue.php b/src/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue.php new file mode 100644 index 00000000..cb9739d6 --- /dev/null +++ b/src/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue.php @@ -0,0 +1,32 @@ + + * @phpstan-type DefaultValueShape = DefaultValueVariants|list + */ +final class DefaultValue implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue/Mixed_.php b/src/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue/Mixed_.php new file mode 100644 index 00000000..a5a58458 --- /dev/null +++ b/src/Files/FileUploadResponse/SelectedFieldsSchema/DefaultValue/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/Files/FileUploadResponse/SelectedFieldsSchema/MaxValue.php b/src/Files/FileUploadResponse/SelectedFieldsSchema/MaxValue.php new file mode 100644 index 00000000..968070cd --- /dev/null +++ b/src/Files/FileUploadResponse/SelectedFieldsSchema/MaxValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/Files/FileUploadResponse/SelectedFieldsSchema/MinValue.php b/src/Files/FileUploadResponse/SelectedFieldsSchema/MinValue.php new file mode 100644 index 00000000..7fe54973 --- /dev/null +++ b/src/Files/FileUploadResponse/SelectedFieldsSchema/MinValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/Files/FileUploadResponse/SelectedFieldsSchema/SelectOption.php b/src/Files/FileUploadResponse/SelectedFieldsSchema/SelectOption.php new file mode 100644 index 00000000..a5228945 --- /dev/null +++ b/src/Files/FileUploadResponse/SelectedFieldsSchema/SelectOption.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/Files/FileUploadResponse/SelectedFieldsSchema/Type.php b/src/Files/FileUploadResponse/SelectedFieldsSchema/Type.php new file mode 100644 index 00000000..d987d623 --- /dev/null +++ b/src/Files/FileUploadResponse/SelectedFieldsSchema/Type.php @@ -0,0 +1,25 @@ + */ + use SdkModel; + + /** + * Unique identifier of the file version. + */ + #[Optional] + public ?string $id; + + /** + * Name of the file version. + */ + #[Optional] + public ?string $name; + + 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(?string $id = null, ?string $name = null): self + { + $self = new self; + + null !== $id && $self['id'] = $id; + null !== $name && $self['name'] = $name; + + return $self; + } + + /** + * Unique identifier of the file version. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Name of the file version. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/Files/Folder.php b/src/Files/Folder.php new file mode 100644 index 00000000..f1ee66ff --- /dev/null +++ b/src/Files/Folder.php @@ -0,0 +1,189 @@ +|null, + * folderID?: string|null, + * folderPath?: string|null, + * name?: string|null, + * type?: null|Type|value-of, + * updatedAt?: \DateTimeInterface|null, + * } + */ +final class Folder implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Date and time when the folder was created. The date and time is in ISO8601 format. + */ + #[Optional] + public ?\DateTimeInterface $createdAt; + + /** + * An object with custom metadata for the folder. Returns empty object if no custom metadata is set. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Unique identifier of the asset. + */ + #[Optional('folderId')] + public ?string $folderID; + + /** + * Path of the folder. This is the path you would use in the URL to access the folder. For example, if the folder is at the root of the media library, the path will be /folder. If the folder is inside another folder named images, the path will be /images/folder. + */ + #[Optional] + public ?string $folderPath; + + /** + * Name of the asset. + */ + #[Optional] + public ?string $name; + + /** + * Type of the asset. + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + /** + * Date and time when the folder was last updated. The date and time is in ISO8601 format. + */ + #[Optional] + public ?\DateTimeInterface $updatedAt; + + 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 array|null $customMetadata + * @param Type|value-of|null $type + */ + public static function with( + ?\DateTimeInterface $createdAt = null, + ?array $customMetadata = null, + ?string $folderID = null, + ?string $folderPath = null, + ?string $name = null, + Type|string|null $type = null, + ?\DateTimeInterface $updatedAt = null, + ): self { + $self = new self; + + null !== $createdAt && $self['createdAt'] = $createdAt; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $folderID && $self['folderID'] = $folderID; + null !== $folderPath && $self['folderPath'] = $folderPath; + null !== $name && $self['name'] = $name; + null !== $type && $self['type'] = $type; + null !== $updatedAt && $self['updatedAt'] = $updatedAt; + + return $self; + } + + /** + * Date and time when the folder was created. The date and time is in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * An object with custom metadata for the folder. Returns empty object if no custom metadata is set. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Unique identifier of the asset. + */ + public function withFolderID(string $folderID): self + { + $self = clone $this; + $self['folderID'] = $folderID; + + return $self; + } + + /** + * Path of the folder. This is the path you would use in the URL to access the folder. For example, if the folder is at the root of the media library, the path will be /folder. If the folder is inside another folder named images, the path will be /images/folder. + */ + public function withFolderPath(string $folderPath): self + { + $self = clone $this; + $self['folderPath'] = $folderPath; + + return $self; + } + + /** + * Name of the asset. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Type of the asset. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Date and time when the folder was last updated. The date and time is in ISO8601 format. + */ + public function withUpdatedAt(\DateTimeInterface $updatedAt): self + { + $self = clone $this; + $self['updatedAt'] = $updatedAt; + + return $self; + } +} diff --git a/src/Files/Folder/Type.php b/src/Files/Folder/Type.php new file mode 100644 index 00000000..91836374 --- /dev/null +++ b/src/Files/Folder/Type.php @@ -0,0 +1,13 @@ + */ + use SdkModel; + + /** + * The audio codec used in the video (only for video). + */ + #[Optional] + public ?string $audioCodec; + + /** + * The bit rate of the video in kbps (only for video). + */ + #[Optional] + public ?int $bitRate; + + /** + * The density of the image in DPI. + */ + #[Optional] + public ?int $density; + + /** + * The duration of the video in seconds (only for video). + */ + #[Optional] + public ?int $duration; + + #[Optional] + public ?Exif $exif; + + /** + * The format of the file (e.g., 'jpg', 'mp4'). + */ + #[Optional] + public ?string $format; + + /** + * Indicates if the image has a color profile. + */ + #[Optional] + public ?bool $hasColorProfile; + + /** + * Indicates if the image contains transparent areas. + */ + #[Optional] + public ?bool $hasTransparency; + + /** + * The height of the image or video in pixels. + */ + #[Optional] + public ?int $height; + + /** + * Perceptual hash of the image. + */ + #[Optional] + public ?string $pHash; + + /** + * The quality indicator of the image. + */ + #[Optional] + public ?int $quality; + + /** + * The file size in bytes. + */ + #[Optional] + public ?int $size; + + /** + * The video codec used in the video (only for video). + */ + #[Optional] + public ?string $videoCodec; + + /** + * The width of the image or video in pixels. + */ + #[Optional] + public ?int $width; + + 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 Exif|ExifShape|null $exif + */ + public static function with( + ?string $audioCodec = null, + ?int $bitRate = null, + ?int $density = null, + ?int $duration = null, + Exif|array|null $exif = null, + ?string $format = null, + ?bool $hasColorProfile = null, + ?bool $hasTransparency = null, + ?int $height = null, + ?string $pHash = null, + ?int $quality = null, + ?int $size = null, + ?string $videoCodec = null, + ?int $width = null, + ): self { + $self = new self; + + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $bitRate && $self['bitRate'] = $bitRate; + null !== $density && $self['density'] = $density; + null !== $duration && $self['duration'] = $duration; + null !== $exif && $self['exif'] = $exif; + null !== $format && $self['format'] = $format; + null !== $hasColorProfile && $self['hasColorProfile'] = $hasColorProfile; + null !== $hasTransparency && $self['hasTransparency'] = $hasTransparency; + null !== $height && $self['height'] = $height; + null !== $pHash && $self['pHash'] = $pHash; + null !== $quality && $self['quality'] = $quality; + null !== $size && $self['size'] = $size; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + null !== $width && $self['width'] = $width; + + return $self; + } + + /** + * The audio codec used in the video (only for video). + */ + public function withAudioCodec(string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * The bit rate of the video in kbps (only for video). + */ + public function withBitRate(int $bitRate): self + { + $self = clone $this; + $self['bitRate'] = $bitRate; + + return $self; + } + + /** + * The density of the image in DPI. + */ + public function withDensity(int $density): self + { + $self = clone $this; + $self['density'] = $density; + + return $self; + } + + /** + * The duration of the video in seconds (only for video). + */ + public function withDuration(int $duration): self + { + $self = clone $this; + $self['duration'] = $duration; + + return $self; + } + + /** + * @param Exif|ExifShape $exif + */ + public function withExif(Exif|array $exif): self + { + $self = clone $this; + $self['exif'] = $exif; + + return $self; + } + + /** + * The format of the file (e.g., 'jpg', 'mp4'). + */ + public function withFormat(string $format): self + { + $self = clone $this; + $self['format'] = $format; + + return $self; + } + + /** + * Indicates if the image has a color profile. + */ + public function withHasColorProfile(bool $hasColorProfile): self + { + $self = clone $this; + $self['hasColorProfile'] = $hasColorProfile; + + return $self; + } + + /** + * Indicates if the image contains transparent areas. + */ + public function withHasTransparency(bool $hasTransparency): self + { + $self = clone $this; + $self['hasTransparency'] = $hasTransparency; + + return $self; + } + + /** + * The height of the image or video in pixels. + */ + public function withHeight(int $height): self + { + $self = clone $this; + $self['height'] = $height; + + return $self; + } + + /** + * Perceptual hash of the image. + */ + public function withPHash(string $pHash): self + { + $self = clone $this; + $self['pHash'] = $pHash; + + return $self; + } + + /** + * The quality indicator of the image. + */ + public function withQuality(int $quality): self + { + $self = clone $this; + $self['quality'] = $quality; + + return $self; + } + + /** + * The file size in bytes. + */ + public function withSize(int $size): self + { + $self = clone $this; + $self['size'] = $size; + + return $self; + } + + /** + * The video codec used in the video (only for video). + */ + public function withVideoCodec(string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * The width of the image or video in pixels. + */ + public function withWidth(int $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/Files/Metadata/Exif.php b/src/Files/Metadata/Exif.php new file mode 100644 index 00000000..8eb7274c --- /dev/null +++ b/src/Files/Metadata/Exif.php @@ -0,0 +1,184 @@ +|null, + * thumbnail?: null|Thumbnail|ThumbnailShape, + * } + */ +final class Exif implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Object containing Exif details. + */ + #[Optional] + public ?Exif\Exif $exif; + + /** + * Object containing GPS information. + */ + #[Optional] + public ?Gps $gps; + + /** + * Object containing EXIF image information. + */ + #[Optional] + public ?Image $image; + + /** + * JSON object. + */ + #[Optional] + public ?Interoperability $interoperability; + + /** @var array|null $makernote */ + #[Optional(map: 'mixed')] + public ?array $makernote; + + /** + * Object containing Thumbnail information. + */ + #[Optional] + public ?Thumbnail $thumbnail; + + 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 Exif\Exif|ExifShape1|null $exif + * @param Gps|GpsShape|null $gps + * @param Image|ImageShape|null $image + * @param Interoperability|InteroperabilityShape|null $interoperability + * @param array|null $makernote + * @param Thumbnail|ThumbnailShape|null $thumbnail + */ + public static function with( + Exif\Exif|array|null $exif = null, + Gps|array|null $gps = null, + Image|array|null $image = null, + Interoperability|array|null $interoperability = null, + ?array $makernote = null, + Thumbnail|array|null $thumbnail = null, + ): self { + $self = new self; + + null !== $exif && $self['exif'] = $exif; + null !== $gps && $self['gps'] = $gps; + null !== $image && $self['image'] = $image; + null !== $interoperability && $self['interoperability'] = $interoperability; + null !== $makernote && $self['makernote'] = $makernote; + null !== $thumbnail && $self['thumbnail'] = $thumbnail; + + return $self; + } + + /** + * Object containing Exif details. + * + * @param Exif\Exif|ExifShape1 $exif + */ + public function withExif( + Exif\Exif|array $exif + ): self { + $self = clone $this; + $self['exif'] = $exif; + + return $self; + } + + /** + * Object containing GPS information. + * + * @param Gps|GpsShape $gps + */ + public function withGps(Gps|array $gps): self + { + $self = clone $this; + $self['gps'] = $gps; + + return $self; + } + + /** + * Object containing EXIF image information. + * + * @param Image|ImageShape $image + */ + public function withImage(Image|array $image): self + { + $self = clone $this; + $self['image'] = $image; + + return $self; + } + + /** + * JSON object. + * + * @param Interoperability|InteroperabilityShape $interoperability + */ + public function withInteroperability( + Interoperability|array $interoperability + ): self { + $self = clone $this; + $self['interoperability'] = $interoperability; + + return $self; + } + + /** + * @param array $makernote + */ + public function withMakernote(array $makernote): self + { + $self = clone $this; + $self['makernote'] = $makernote; + + return $self; + } + + /** + * Object containing Thumbnail information. + * + * @param Thumbnail|ThumbnailShape $thumbnail + */ + public function withThumbnail(Thumbnail|array $thumbnail): self + { + $self = clone $this; + $self['thumbnail'] = $thumbnail; + + return $self; + } +} diff --git a/src/Files/Metadata/Exif/Exif.php b/src/Files/Metadata/Exif/Exif.php new file mode 100644 index 00000000..de7e80fa --- /dev/null +++ b/src/Files/Metadata/Exif/Exif.php @@ -0,0 +1,406 @@ + */ + use SdkModel; + + #[Optional('ApertureValue')] + public ?float $apertureValue; + + #[Optional('ColorSpace')] + public ?int $colorSpace; + + #[Optional('CreateDate')] + public ?string $createDate; + + #[Optional('CustomRendered')] + public ?int $customRendered; + + #[Optional('DateTimeOriginal')] + public ?string $dateTimeOriginal; + + #[Optional('ExifImageHeight')] + public ?int $exifImageHeight; + + #[Optional('ExifImageWidth')] + public ?int $exifImageWidth; + + #[Optional('ExifVersion')] + public ?string $exifVersion; + + #[Optional('ExposureCompensation')] + public ?float $exposureCompensation; + + #[Optional('ExposureMode')] + public ?int $exposureMode; + + #[Optional('ExposureProgram')] + public ?int $exposureProgram; + + #[Optional('ExposureTime')] + public ?float $exposureTime; + + #[Optional('Flash')] + public ?int $flash; + + #[Optional('FlashpixVersion')] + public ?string $flashpixVersion; + + #[Optional('FNumber')] + public ?float $fNumber; + + #[Optional('FocalLength')] + public ?int $focalLength; + + #[Optional('FocalPlaneResolutionUnit')] + public ?int $focalPlaneResolutionUnit; + + #[Optional('FocalPlaneXResolution')] + public ?float $focalPlaneXResolution; + + #[Optional('FocalPlaneYResolution')] + public ?float $focalPlaneYResolution; + + #[Optional('InteropOffset')] + public ?int $interopOffset; + + #[Optional('ISO')] + public ?int $iso; + + #[Optional('MeteringMode')] + public ?int $meteringMode; + + #[Optional('SceneCaptureType')] + public ?int $sceneCaptureType; + + #[Optional('ShutterSpeedValue')] + public ?float $shutterSpeedValue; + + #[Optional('SubSecTime')] + public ?string $subSecTime; + + #[Optional('WhiteBalance')] + public ?int $whiteBalance; + + 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( + ?float $apertureValue = null, + ?int $colorSpace = null, + ?string $createDate = null, + ?int $customRendered = null, + ?string $dateTimeOriginal = null, + ?int $exifImageHeight = null, + ?int $exifImageWidth = null, + ?string $exifVersion = null, + ?float $exposureCompensation = null, + ?int $exposureMode = null, + ?int $exposureProgram = null, + ?float $exposureTime = null, + ?int $flash = null, + ?string $flashpixVersion = null, + ?float $fNumber = null, + ?int $focalLength = null, + ?int $focalPlaneResolutionUnit = null, + ?float $focalPlaneXResolution = null, + ?float $focalPlaneYResolution = null, + ?int $interopOffset = null, + ?int $iso = null, + ?int $meteringMode = null, + ?int $sceneCaptureType = null, + ?float $shutterSpeedValue = null, + ?string $subSecTime = null, + ?int $whiteBalance = null, + ): self { + $self = new self; + + null !== $apertureValue && $self['apertureValue'] = $apertureValue; + null !== $colorSpace && $self['colorSpace'] = $colorSpace; + null !== $createDate && $self['createDate'] = $createDate; + null !== $customRendered && $self['customRendered'] = $customRendered; + null !== $dateTimeOriginal && $self['dateTimeOriginal'] = $dateTimeOriginal; + null !== $exifImageHeight && $self['exifImageHeight'] = $exifImageHeight; + null !== $exifImageWidth && $self['exifImageWidth'] = $exifImageWidth; + null !== $exifVersion && $self['exifVersion'] = $exifVersion; + null !== $exposureCompensation && $self['exposureCompensation'] = $exposureCompensation; + null !== $exposureMode && $self['exposureMode'] = $exposureMode; + null !== $exposureProgram && $self['exposureProgram'] = $exposureProgram; + null !== $exposureTime && $self['exposureTime'] = $exposureTime; + null !== $flash && $self['flash'] = $flash; + null !== $flashpixVersion && $self['flashpixVersion'] = $flashpixVersion; + null !== $fNumber && $self['fNumber'] = $fNumber; + null !== $focalLength && $self['focalLength'] = $focalLength; + null !== $focalPlaneResolutionUnit && $self['focalPlaneResolutionUnit'] = $focalPlaneResolutionUnit; + null !== $focalPlaneXResolution && $self['focalPlaneXResolution'] = $focalPlaneXResolution; + null !== $focalPlaneYResolution && $self['focalPlaneYResolution'] = $focalPlaneYResolution; + null !== $interopOffset && $self['interopOffset'] = $interopOffset; + null !== $iso && $self['iso'] = $iso; + null !== $meteringMode && $self['meteringMode'] = $meteringMode; + null !== $sceneCaptureType && $self['sceneCaptureType'] = $sceneCaptureType; + null !== $shutterSpeedValue && $self['shutterSpeedValue'] = $shutterSpeedValue; + null !== $subSecTime && $self['subSecTime'] = $subSecTime; + null !== $whiteBalance && $self['whiteBalance'] = $whiteBalance; + + return $self; + } + + public function withApertureValue(float $apertureValue): self + { + $self = clone $this; + $self['apertureValue'] = $apertureValue; + + return $self; + } + + public function withColorSpace(int $colorSpace): self + { + $self = clone $this; + $self['colorSpace'] = $colorSpace; + + return $self; + } + + public function withCreateDate(string $createDate): self + { + $self = clone $this; + $self['createDate'] = $createDate; + + return $self; + } + + public function withCustomRendered(int $customRendered): self + { + $self = clone $this; + $self['customRendered'] = $customRendered; + + return $self; + } + + public function withDateTimeOriginal(string $dateTimeOriginal): self + { + $self = clone $this; + $self['dateTimeOriginal'] = $dateTimeOriginal; + + return $self; + } + + public function withExifImageHeight(int $exifImageHeight): self + { + $self = clone $this; + $self['exifImageHeight'] = $exifImageHeight; + + return $self; + } + + public function withExifImageWidth(int $exifImageWidth): self + { + $self = clone $this; + $self['exifImageWidth'] = $exifImageWidth; + + return $self; + } + + public function withExifVersion(string $exifVersion): self + { + $self = clone $this; + $self['exifVersion'] = $exifVersion; + + return $self; + } + + public function withExposureCompensation(float $exposureCompensation): self + { + $self = clone $this; + $self['exposureCompensation'] = $exposureCompensation; + + return $self; + } + + public function withExposureMode(int $exposureMode): self + { + $self = clone $this; + $self['exposureMode'] = $exposureMode; + + return $self; + } + + public function withExposureProgram(int $exposureProgram): self + { + $self = clone $this; + $self['exposureProgram'] = $exposureProgram; + + return $self; + } + + public function withExposureTime(float $exposureTime): self + { + $self = clone $this; + $self['exposureTime'] = $exposureTime; + + return $self; + } + + public function withFlash(int $flash): self + { + $self = clone $this; + $self['flash'] = $flash; + + return $self; + } + + public function withFlashpixVersion(string $flashpixVersion): self + { + $self = clone $this; + $self['flashpixVersion'] = $flashpixVersion; + + return $self; + } + + public function withFNumber(float $fNumber): self + { + $self = clone $this; + $self['fNumber'] = $fNumber; + + return $self; + } + + public function withFocalLength(int $focalLength): self + { + $self = clone $this; + $self['focalLength'] = $focalLength; + + return $self; + } + + public function withFocalPlaneResolutionUnit( + int $focalPlaneResolutionUnit + ): self { + $self = clone $this; + $self['focalPlaneResolutionUnit'] = $focalPlaneResolutionUnit; + + return $self; + } + + public function withFocalPlaneXResolution( + float $focalPlaneXResolution + ): self { + $self = clone $this; + $self['focalPlaneXResolution'] = $focalPlaneXResolution; + + return $self; + } + + public function withFocalPlaneYResolution( + float $focalPlaneYResolution + ): self { + $self = clone $this; + $self['focalPlaneYResolution'] = $focalPlaneYResolution; + + return $self; + } + + public function withInteropOffset(int $interopOffset): self + { + $self = clone $this; + $self['interopOffset'] = $interopOffset; + + return $self; + } + + public function withISO(int $iso): self + { + $self = clone $this; + $self['iso'] = $iso; + + return $self; + } + + public function withMeteringMode(int $meteringMode): self + { + $self = clone $this; + $self['meteringMode'] = $meteringMode; + + return $self; + } + + public function withSceneCaptureType(int $sceneCaptureType): self + { + $self = clone $this; + $self['sceneCaptureType'] = $sceneCaptureType; + + return $self; + } + + public function withShutterSpeedValue(float $shutterSpeedValue): self + { + $self = clone $this; + $self['shutterSpeedValue'] = $shutterSpeedValue; + + return $self; + } + + public function withSubSecTime(string $subSecTime): self + { + $self = clone $this; + $self['subSecTime'] = $subSecTime; + + return $self; + } + + public function withWhiteBalance(int $whiteBalance): self + { + $self = clone $this; + $self['whiteBalance'] = $whiteBalance; + + return $self; + } +} diff --git a/src/Files/Metadata/Exif/Gps.php b/src/Files/Metadata/Exif/Gps.php new file mode 100644 index 00000000..f4920c6e --- /dev/null +++ b/src/Files/Metadata/Exif/Gps.php @@ -0,0 +1,56 @@ +|null} + */ +final class Gps implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var list|null $gpsVersionID */ + #[Optional('GPSVersionID', list: 'int')] + public ?array $gpsVersionID; + + 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 list|null $gpsVersionID + */ + public static function with(?array $gpsVersionID = null): self + { + $self = new self; + + null !== $gpsVersionID && $self['gpsVersionID'] = $gpsVersionID; + + return $self; + } + + /** + * @param list $gpsVersionID + */ + public function withGpsVersionID(array $gpsVersionID): self + { + $self = clone $this; + $self['gpsVersionID'] = $gpsVersionID; + + return $self; + } +} diff --git a/src/Files/Metadata/Exif/Image.php b/src/Files/Metadata/Exif/Image.php new file mode 100644 index 00000000..1fe201e7 --- /dev/null +++ b/src/Files/Metadata/Exif/Image.php @@ -0,0 +1,193 @@ + */ + use SdkModel; + + #[Optional('ExifOffset')] + public ?int $exifOffset; + + #[Optional('GPSInfo')] + public ?int $gpsInfo; + + #[Optional('Make')] + public ?string $make; + + #[Optional('Model')] + public ?string $model; + + #[Optional('ModifyDate')] + public ?string $modifyDate; + + #[Optional('Orientation')] + public ?int $orientation; + + #[Optional('ResolutionUnit')] + public ?int $resolutionUnit; + + #[Optional('Software')] + public ?string $software; + + #[Optional('XResolution')] + public ?int $xResolution; + + #[Optional('YCbCrPositioning')] + public ?int $yCbCrPositioning; + + #[Optional('YResolution')] + public ?int $yResolution; + + 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( + ?int $exifOffset = null, + ?int $gpsInfo = null, + ?string $make = null, + ?string $model = null, + ?string $modifyDate = null, + ?int $orientation = null, + ?int $resolutionUnit = null, + ?string $software = null, + ?int $xResolution = null, + ?int $yCbCrPositioning = null, + ?int $yResolution = null, + ): self { + $self = new self; + + null !== $exifOffset && $self['exifOffset'] = $exifOffset; + null !== $gpsInfo && $self['gpsInfo'] = $gpsInfo; + null !== $make && $self['make'] = $make; + null !== $model && $self['model'] = $model; + null !== $modifyDate && $self['modifyDate'] = $modifyDate; + null !== $orientation && $self['orientation'] = $orientation; + null !== $resolutionUnit && $self['resolutionUnit'] = $resolutionUnit; + null !== $software && $self['software'] = $software; + null !== $xResolution && $self['xResolution'] = $xResolution; + null !== $yCbCrPositioning && $self['yCbCrPositioning'] = $yCbCrPositioning; + null !== $yResolution && $self['yResolution'] = $yResolution; + + return $self; + } + + public function withExifOffset(int $exifOffset): self + { + $self = clone $this; + $self['exifOffset'] = $exifOffset; + + return $self; + } + + public function withGpsInfo(int $gpsInfo): self + { + $self = clone $this; + $self['gpsInfo'] = $gpsInfo; + + return $self; + } + + public function withMake(string $make): self + { + $self = clone $this; + $self['make'] = $make; + + return $self; + } + + public function withModel(string $model): self + { + $self = clone $this; + $self['model'] = $model; + + return $self; + } + + public function withModifyDate(string $modifyDate): self + { + $self = clone $this; + $self['modifyDate'] = $modifyDate; + + return $self; + } + + public function withOrientation(int $orientation): self + { + $self = clone $this; + $self['orientation'] = $orientation; + + return $self; + } + + public function withResolutionUnit(int $resolutionUnit): self + { + $self = clone $this; + $self['resolutionUnit'] = $resolutionUnit; + + return $self; + } + + public function withSoftware(string $software): self + { + $self = clone $this; + $self['software'] = $software; + + return $self; + } + + public function withXResolution(int $xResolution): self + { + $self = clone $this; + $self['xResolution'] = $xResolution; + + return $self; + } + + public function withYCbCrPositioning(int $yCbCrPositioning): self + { + $self = clone $this; + $self['yCbCrPositioning'] = $yCbCrPositioning; + + return $self; + } + + public function withYResolution(int $yResolution): self + { + $self = clone $this; + $self['yResolution'] = $yResolution; + + return $self; + } +} diff --git a/src/Files/Metadata/Exif/Interoperability.php b/src/Files/Metadata/Exif/Interoperability.php new file mode 100644 index 00000000..61c6d148 --- /dev/null +++ b/src/Files/Metadata/Exif/Interoperability.php @@ -0,0 +1,66 @@ + */ + use SdkModel; + + #[Optional('InteropIndex')] + public ?string $interopIndex; + + #[Optional('InteropVersion')] + public ?string $interopVersion; + + 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( + ?string $interopIndex = null, + ?string $interopVersion = null + ): self { + $self = new self; + + null !== $interopIndex && $self['interopIndex'] = $interopIndex; + null !== $interopVersion && $self['interopVersion'] = $interopVersion; + + return $self; + } + + public function withInteropIndex(string $interopIndex): self + { + $self = clone $this; + $self['interopIndex'] = $interopIndex; + + return $self; + } + + public function withInteropVersion(string $interopVersion): self + { + $self = clone $this; + $self['interopVersion'] = $interopVersion; + + return $self; + } +} diff --git a/src/Files/Metadata/Exif/Thumbnail.php b/src/Files/Metadata/Exif/Thumbnail.php new file mode 100644 index 00000000..95b2c12e --- /dev/null +++ b/src/Files/Metadata/Exif/Thumbnail.php @@ -0,0 +1,123 @@ + */ + use SdkModel; + + #[Optional('Compression')] + public ?int $compression; + + #[Optional('ResolutionUnit')] + public ?int $resolutionUnit; + + #[Optional('ThumbnailLength')] + public ?int $thumbnailLength; + + #[Optional('ThumbnailOffset')] + public ?int $thumbnailOffset; + + #[Optional('XResolution')] + public ?int $xResolution; + + #[Optional('YResolution')] + public ?int $yResolution; + + 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( + ?int $compression = null, + ?int $resolutionUnit = null, + ?int $thumbnailLength = null, + ?int $thumbnailOffset = null, + ?int $xResolution = null, + ?int $yResolution = null, + ): self { + $self = new self; + + null !== $compression && $self['compression'] = $compression; + null !== $resolutionUnit && $self['resolutionUnit'] = $resolutionUnit; + null !== $thumbnailLength && $self['thumbnailLength'] = $thumbnailLength; + null !== $thumbnailOffset && $self['thumbnailOffset'] = $thumbnailOffset; + null !== $xResolution && $self['xResolution'] = $xResolution; + null !== $yResolution && $self['yResolution'] = $yResolution; + + return $self; + } + + public function withCompression(int $compression): self + { + $self = clone $this; + $self['compression'] = $compression; + + return $self; + } + + public function withResolutionUnit(int $resolutionUnit): self + { + $self = clone $this; + $self['resolutionUnit'] = $resolutionUnit; + + return $self; + } + + public function withThumbnailLength(int $thumbnailLength): self + { + $self = clone $this; + $self['thumbnailLength'] = $thumbnailLength; + + return $self; + } + + public function withThumbnailOffset(int $thumbnailOffset): self + { + $self = clone $this; + $self['thumbnailOffset'] = $thumbnailOffset; + + return $self; + } + + public function withXResolution(int $xResolution): self + { + $self = clone $this; + $self['xResolution'] = $xResolution; + + return $self; + } + + public function withYResolution(int $yResolution): self + { + $self = clone $this; + $self['yResolution'] = $yResolution; + + return $self; + } +} diff --git a/src/Files/Metadata/MetadataGetFromURLParams.php b/src/Files/Metadata/MetadataGetFromURLParams.php new file mode 100644 index 00000000..0b04939b --- /dev/null +++ b/src/Files/Metadata/MetadataGetFromURLParams.php @@ -0,0 +1,74 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Should be a valid file URL. It should be accessible using your ImageKit.io account. + */ + #[Required] + public string $url; + + /** + * `new MetadataGetFromURLParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * MetadataGetFromURLParams::with(url: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new MetadataGetFromURLParams)->withURL(...) + * ``` + */ + 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(string $url): self + { + $self = new self; + + $self['url'] = $url; + + return $self; + } + + /** + * Should be a valid file URL. It should be accessible using your ImageKit.io account. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } +} diff --git a/src/Files/UpdateFileRequest.php b/src/Files/UpdateFileRequest.php new file mode 100644 index 00000000..05bf2da6 --- /dev/null +++ b/src/Files/UpdateFileRequest.php @@ -0,0 +1,33 @@ +|array + */ + public static function variants(): array + { + return [UpdateFileDetails::class, ChangePublicationStatus::class]; + } +} diff --git a/src/Files/UpdateFileRequest/ChangePublicationStatus.php b/src/Files/UpdateFileRequest/ChangePublicationStatus.php new file mode 100644 index 00000000..55f1028d --- /dev/null +++ b/src/Files/UpdateFileRequest/ChangePublicationStatus.php @@ -0,0 +1,63 @@ + */ + use SdkModel; + + /** + * Configure the publication status of a file and its versions. + */ + #[Optional] + public ?Publish $publish; + + 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 Publish|PublishShape|null $publish + */ + public static function with(Publish|array|null $publish = null): self + { + $self = new self; + + null !== $publish && $self['publish'] = $publish; + + return $self; + } + + /** + * Configure the publication status of a file and its versions. + * + * @param Publish|PublishShape $publish + */ + public function withPublish(Publish|array $publish): self + { + $self = clone $this; + $self['publish'] = $publish; + + return $self; + } +} diff --git a/src/Files/UpdateFileRequest/ChangePublicationStatus/Publish.php b/src/Files/UpdateFileRequest/ChangePublicationStatus/Publish.php new file mode 100644 index 00000000..b859f05e --- /dev/null +++ b/src/Files/UpdateFileRequest/ChangePublicationStatus/Publish.php @@ -0,0 +1,94 @@ + */ + use SdkModel; + + /** + * Set to `true` to publish the file. Set to `false` to unpublish the file. + */ + #[Required] + public bool $isPublished; + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` to publish/unpublish only the current version of the file. + */ + #[Optional] + public ?bool $includeFileVersions; + + /** + * `new Publish()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Publish::with(isPublished: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Publish)->withIsPublished(...) + * ``` + */ + 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 $isPublished, + ?bool $includeFileVersions = null + ): self { + $self = new self; + + $self['isPublished'] = $isPublished; + + null !== $includeFileVersions && $self['includeFileVersions'] = $includeFileVersions; + + return $self; + } + + /** + * Set to `true` to publish the file. Set to `false` to unpublish the file. + */ + public function withIsPublished(bool $isPublished): self + { + $self = clone $this; + $self['isPublished'] = $isPublished; + + return $self; + } + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` to publish/unpublish only the current version of the file. + */ + public function withIncludeFileVersions(bool $includeFileVersions): self + { + $self = clone $this; + $self['includeFileVersions'] = $includeFileVersions; + + return $self; + } +} diff --git a/src/Files/UpdateFileRequest/UpdateFileDetails.php b/src/Files/UpdateFileRequest/UpdateFileDetails.php new file mode 100644 index 00000000..a9729b82 --- /dev/null +++ b/src/Files/UpdateFileRequest/UpdateFileDetails.php @@ -0,0 +1,213 @@ +|null, + * description?: string|null, + * extensions?: list|null, + * removeAITags?: RemoveAITagsShape|null, + * tags?: list|null, + * webhookURL?: string|null, + * } + */ +final class UpdateFileDetails implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Define an important area in the image in the format `x,y,width,height` e.g. `10,10,100,100`. Send `null` to unset this value. + */ + #[Optional(nullable: true)] + public ?string $customCoordinates; + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` value for that key. Before setting any custom metadata on an asset you have to create the field using custom metadata fields API. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Optional text to describe the contents of the file. + */ + #[Optional] + public ?string $description; + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * + * @var list|null $extensions + */ + #[Optional(list: ExtensionItem::class)] + public ?array $extensions; + + /** + * An array of AITags associated with the file that you want to remove, e.g. `["car", "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are processed. + * + * @var RemoveAITagsVariants|null $removeAITags + */ + #[Optional(union: RemoveAITags::class)] + public string|array|null $removeAITags; + + /** + * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to unset all tags associated with the file. + * + * @var list|null $tags + */ + #[Optional(list: 'string', nullable: true)] + public ?array $tags; + + /** + * The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + */ + #[Optional('webhookUrl')] + public ?string $webhookURL; + + 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 array|null $customMetadata + * @param list|null $extensions + * @param RemoveAITagsShape|null $removeAITags + * @param list|null $tags + */ + public static function with( + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?array $extensions = null, + string|array|null $removeAITags = null, + ?array $tags = null, + ?string $webhookURL = null, + ): self { + $self = new self; + + null !== $customCoordinates && $self['customCoordinates'] = $customCoordinates; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $description && $self['description'] = $description; + null !== $extensions && $self['extensions'] = $extensions; + null !== $removeAITags && $self['removeAITags'] = $removeAITags; + null !== $tags && $self['tags'] = $tags; + null !== $webhookURL && $self['webhookURL'] = $webhookURL; + + return $self; + } + + /** + * Define an important area in the image in the format `x,y,width,height` e.g. `10,10,100,100`. Send `null` to unset this value. + */ + public function withCustomCoordinates(?string $customCoordinates): self + { + $self = clone $this; + $self['customCoordinates'] = $customCoordinates; + + return $self; + } + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` value for that key. Before setting any custom metadata on an asset you have to create the field using custom metadata fields API. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Optional text to describe the contents of the file. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * + * @param list $extensions + */ + public function withExtensions(array $extensions): self + { + $self = clone $this; + $self['extensions'] = $extensions; + + return $self; + } + + /** + * An array of AITags associated with the file that you want to remove, e.g. `["car", "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are processed. + * + * @param RemoveAITagsShape $removeAITags + */ + public function withRemoveAITags(string|array $removeAITags): self + { + $self = clone $this; + $self['removeAITags'] = $removeAITags; + + return $self; + } + + /** + * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to unset all tags associated with the file. + * + * @param list|null $tags + */ + public function withTags(?array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } + + /** + * The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + */ + public function withWebhookURL(string $webhookURL): self + { + $self = clone $this; + $self['webhookURL'] = $webhookURL; + + return $self; + } +} diff --git a/src/Files/UpdateFileRequest/UpdateFileDetails/RemoveAITags.php b/src/Files/UpdateFileRequest/UpdateFileDetails/RemoveAITags.php new file mode 100644 index 00000000..320af835 --- /dev/null +++ b/src/Files/UpdateFileRequest/UpdateFileDetails/RemoveAITags.php @@ -0,0 +1,33 @@ + + * @phpstan-type RemoveAITagsShape = RemoveAITagsVariants + */ +final class RemoveAITags implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return [new ListOf('string'), 'string']; + } +} diff --git a/src/Files/Versions/VersionDeleteParams.php b/src/Files/Versions/VersionDeleteParams.php new file mode 100644 index 00000000..9e43e7a8 --- /dev/null +++ b/src/Files/Versions/VersionDeleteParams.php @@ -0,0 +1,70 @@ + */ + use SdkModel; + use SdkParams; + + #[Required] + public string $fileID; + + /** + * `new VersionDeleteParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * VersionDeleteParams::with(fileID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new VersionDeleteParams)->withFileID(...) + * ``` + */ + 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(string $fileID): self + { + $self = new self; + + $self['fileID'] = $fileID; + + return $self; + } + + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } +} diff --git a/src/Files/Versions/VersionDeleteResponse.php b/src/Files/Versions/VersionDeleteResponse.php new file mode 100644 index 00000000..9702f2e6 --- /dev/null +++ b/src/Files/Versions/VersionDeleteResponse.php @@ -0,0 +1,32 @@ + + */ +final class VersionDeleteResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + 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(): self + { + return new self; + } +} diff --git a/src/Files/Versions/VersionGetParams.php b/src/Files/Versions/VersionGetParams.php new file mode 100644 index 00000000..224e02c9 --- /dev/null +++ b/src/Files/Versions/VersionGetParams.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + use SdkParams; + + #[Required] + public string $fileID; + + /** + * `new VersionGetParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * VersionGetParams::with(fileID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new VersionGetParams)->withFileID(...) + * ``` + */ + 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(string $fileID): self + { + $self = new self; + + $self['fileID'] = $fileID; + + return $self; + } + + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } +} diff --git a/src/Files/Versions/VersionRestoreParams.php b/src/Files/Versions/VersionRestoreParams.php new file mode 100644 index 00000000..f1db11d7 --- /dev/null +++ b/src/Files/Versions/VersionRestoreParams.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + use SdkParams; + + #[Required] + public string $fileID; + + /** + * `new VersionRestoreParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * VersionRestoreParams::with(fileID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new VersionRestoreParams)->withFileID(...) + * ``` + */ + 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(string $fileID): self + { + $self = new self; + + $self['fileID'] = $fileID; + + return $self; + } + + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } +} diff --git a/src/Folders/FolderCopyParams.php b/src/Folders/FolderCopyParams.php new file mode 100644 index 00000000..89cd83e9 --- /dev/null +++ b/src/Folders/FolderCopyParams.php @@ -0,0 +1,117 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Full path to the destination folder where you want to copy the source folder into. + */ + #[Required] + public string $destinationPath; + + /** + * The full path to the source folder you want to copy. + */ + #[Required] + public string $sourceFolderPath; + + /** + * Option to copy all versions of files that are nested inside the selected folder. By default, only the current version of each file will be copied. When set to true, all versions of each file will be copied. Default value - `false`. + */ + #[Optional] + public ?bool $includeVersions; + + /** + * `new FolderCopyParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FolderCopyParams::with(destinationPath: ..., sourceFolderPath: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FolderCopyParams)->withDestinationPath(...)->withSourceFolderPath(...) + * ``` + */ + 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( + string $destinationPath, + string $sourceFolderPath, + ?bool $includeVersions = null, + ): self { + $self = new self; + + $self['destinationPath'] = $destinationPath; + $self['sourceFolderPath'] = $sourceFolderPath; + + null !== $includeVersions && $self['includeVersions'] = $includeVersions; + + return $self; + } + + /** + * Full path to the destination folder where you want to copy the source folder into. + */ + public function withDestinationPath(string $destinationPath): self + { + $self = clone $this; + $self['destinationPath'] = $destinationPath; + + return $self; + } + + /** + * The full path to the source folder you want to copy. + */ + public function withSourceFolderPath(string $sourceFolderPath): self + { + $self = clone $this; + $self['sourceFolderPath'] = $sourceFolderPath; + + return $self; + } + + /** + * Option to copy all versions of files that are nested inside the selected folder. By default, only the current version of each file will be copied. When set to true, all versions of each file will be copied. Default value - `false`. + */ + public function withIncludeVersions(bool $includeVersions): self + { + $self = clone $this; + $self['includeVersions'] = $includeVersions; + + return $self; + } +} diff --git a/src/Folders/FolderCopyResponse.php b/src/Folders/FolderCopyResponse.php new file mode 100644 index 00000000..f055562e --- /dev/null +++ b/src/Folders/FolderCopyResponse.php @@ -0,0 +1,70 @@ + */ + use SdkModel; + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + */ + #[Required('jobId')] + public string $jobID; + + /** + * `new FolderCopyResponse()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FolderCopyResponse::with(jobID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FolderCopyResponse)->withJobID(...) + * ``` + */ + 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(string $jobID): self + { + $self = new self; + + $self['jobID'] = $jobID; + + return $self; + } + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + */ + public function withJobID(string $jobID): self + { + $self = clone $this; + $self['jobID'] = $jobID; + + return $self; + } +} diff --git a/src/Folders/FolderCreateParams.php b/src/Folders/FolderCreateParams.php new file mode 100644 index 00000000..74d396f8 --- /dev/null +++ b/src/Folders/FolderCreateParams.php @@ -0,0 +1,104 @@ + */ + use SdkModel; + use SdkParams; + + /** + * The folder will be created with this name. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) will be replaced by an underscore i.e. `_`. + */ + #[Required] + public string $folderName; + + /** + * The folder where the new folder should be created, for root use `/` else the path e.g. `containing/folder/`. + * + * Note: If any folder(s) is not present in the parentFolderPath parameter, it will be automatically created. For example, if you pass `/product/images/summer`, then `product`, `images`, and `summer` folders will be created if they don't already exist. + */ + #[Required] + public string $parentFolderPath; + + /** + * `new FolderCreateParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FolderCreateParams::with(folderName: ..., parentFolderPath: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FolderCreateParams)->withFolderName(...)->withParentFolderPath(...) + * ``` + */ + 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( + string $folderName, + string $parentFolderPath + ): self { + $self = new self; + + $self['folderName'] = $folderName; + $self['parentFolderPath'] = $parentFolderPath; + + return $self; + } + + /** + * The folder will be created with this name. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) will be replaced by an underscore i.e. `_`. + */ + public function withFolderName(string $folderName): self + { + $self = clone $this; + $self['folderName'] = $folderName; + + return $self; + } + + /** + * The folder where the new folder should be created, for root use `/` else the path e.g. `containing/folder/`. + * + * Note: If any folder(s) is not present in the parentFolderPath parameter, it will be automatically created. For example, if you pass `/product/images/summer`, then `product`, `images`, and `summer` folders will be created if they don't already exist. + */ + public function withParentFolderPath(string $parentFolderPath): self + { + $self = clone $this; + $self['parentFolderPath'] = $parentFolderPath; + + return $self; + } +} diff --git a/src/Folders/FolderDeleteParams.php b/src/Folders/FolderDeleteParams.php new file mode 100644 index 00000000..aa11b23a --- /dev/null +++ b/src/Folders/FolderDeleteParams.php @@ -0,0 +1,74 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Full path to the folder you want to delete. For example `/folder/to/delete/`. + */ + #[Required] + public string $folderPath; + + /** + * `new FolderDeleteParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FolderDeleteParams::with(folderPath: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FolderDeleteParams)->withFolderPath(...) + * ``` + */ + 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(string $folderPath): self + { + $self = new self; + + $self['folderPath'] = $folderPath; + + return $self; + } + + /** + * Full path to the folder you want to delete. For example `/folder/to/delete/`. + */ + public function withFolderPath(string $folderPath): self + { + $self = clone $this; + $self['folderPath'] = $folderPath; + + return $self; + } +} diff --git a/src/Folders/FolderDeleteResponse.php b/src/Folders/FolderDeleteResponse.php new file mode 100644 index 00000000..ebb739ca --- /dev/null +++ b/src/Folders/FolderDeleteResponse.php @@ -0,0 +1,32 @@ + + */ +final class FolderDeleteResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + 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(): self + { + return new self; + } +} diff --git a/src/Folders/FolderMoveParams.php b/src/Folders/FolderMoveParams.php new file mode 100644 index 00000000..e0e66484 --- /dev/null +++ b/src/Folders/FolderMoveParams.php @@ -0,0 +1,96 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Full path to the destination folder where you want to move the source folder into. + */ + #[Required] + public string $destinationPath; + + /** + * The full path to the source folder you want to move. + */ + #[Required] + public string $sourceFolderPath; + + /** + * `new FolderMoveParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FolderMoveParams::with(destinationPath: ..., sourceFolderPath: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FolderMoveParams)->withDestinationPath(...)->withSourceFolderPath(...) + * ``` + */ + 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( + string $destinationPath, + string $sourceFolderPath + ): self { + $self = new self; + + $self['destinationPath'] = $destinationPath; + $self['sourceFolderPath'] = $sourceFolderPath; + + return $self; + } + + /** + * Full path to the destination folder where you want to move the source folder into. + */ + public function withDestinationPath(string $destinationPath): self + { + $self = clone $this; + $self['destinationPath'] = $destinationPath; + + return $self; + } + + /** + * The full path to the source folder you want to move. + */ + public function withSourceFolderPath(string $sourceFolderPath): self + { + $self = clone $this; + $self['sourceFolderPath'] = $sourceFolderPath; + + return $self; + } +} diff --git a/src/Folders/FolderMoveResponse.php b/src/Folders/FolderMoveResponse.php new file mode 100644 index 00000000..57937c45 --- /dev/null +++ b/src/Folders/FolderMoveResponse.php @@ -0,0 +1,70 @@ + */ + use SdkModel; + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + */ + #[Required('jobId')] + public string $jobID; + + /** + * `new FolderMoveResponse()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FolderMoveResponse::with(jobID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FolderMoveResponse)->withJobID(...) + * ``` + */ + 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(string $jobID): self + { + $self = new self; + + $self['jobID'] = $jobID; + + return $self; + } + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + */ + public function withJobID(string $jobID): self + { + $self = clone $this; + $self['jobID'] = $jobID; + + return $self; + } +} diff --git a/src/Folders/FolderNewResponse.php b/src/Folders/FolderNewResponse.php new file mode 100644 index 00000000..6ac9d782 --- /dev/null +++ b/src/Folders/FolderNewResponse.php @@ -0,0 +1,32 @@ + + */ +final class FolderNewResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + 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(): self + { + return new self; + } +} diff --git a/src/Folders/FolderRenameParams.php b/src/Folders/FolderRenameParams.php new file mode 100644 index 00000000..8b87c509 --- /dev/null +++ b/src/Folders/FolderRenameParams.php @@ -0,0 +1,133 @@ + */ + use SdkModel; + use SdkParams; + + /** + * The full path to the folder you want to rename. + */ + #[Required] + public string $folderPath; + + /** + * The new name for the folder. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) and `-` will be replaced by an underscore i.e. `_`. + */ + #[Required] + public string $newFolderName; + + /** + * Option to purge cache for the old nested files and their versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove the cached content of the old nested files and their versions. There will only be one purge request for all the nested files, which will be counted against your monthly purge quota. + * + * Note: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove all nested files, their versions' URLs, and any transformations made using query parameters on these files or their versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation. + * + * Default value - `false` + */ + #[Optional] + public ?bool $purgeCache; + + /** + * `new FolderRenameParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FolderRenameParams::with(folderPath: ..., newFolderName: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FolderRenameParams)->withFolderPath(...)->withNewFolderName(...) + * ``` + */ + 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( + string $folderPath, + string $newFolderName, + ?bool $purgeCache = null + ): self { + $self = new self; + + $self['folderPath'] = $folderPath; + $self['newFolderName'] = $newFolderName; + + null !== $purgeCache && $self['purgeCache'] = $purgeCache; + + return $self; + } + + /** + * The full path to the folder you want to rename. + */ + public function withFolderPath(string $folderPath): self + { + $self = clone $this; + $self['folderPath'] = $folderPath; + + return $self; + } + + /** + * The new name for the folder. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) and `-` will be replaced by an underscore i.e. `_`. + */ + public function withNewFolderName(string $newFolderName): self + { + $self = clone $this; + $self['newFolderName'] = $newFolderName; + + return $self; + } + + /** + * Option to purge cache for the old nested files and their versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove the cached content of the old nested files and their versions. There will only be one purge request for all the nested files, which will be counted against your monthly purge quota. + * + * Note: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove all nested files, their versions' URLs, and any transformations made using query parameters on these files or their versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation. + * + * Default value - `false` + */ + public function withPurgeCache(bool $purgeCache): self + { + $self = clone $this; + $self['purgeCache'] = $purgeCache; + + return $self; + } +} diff --git a/src/Folders/FolderRenameResponse.php b/src/Folders/FolderRenameResponse.php new file mode 100644 index 00000000..9a7fecf1 --- /dev/null +++ b/src/Folders/FolderRenameResponse.php @@ -0,0 +1,70 @@ + */ + use SdkModel; + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + */ + #[Required('jobId')] + public string $jobID; + + /** + * `new FolderRenameResponse()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FolderRenameResponse::with(jobID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FolderRenameResponse)->withJobID(...) + * ``` + */ + 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(string $jobID): self + { + $self = new self; + + $self['jobID'] = $jobID; + + return $self; + } + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + */ + public function withJobID(string $jobID): self + { + $self = clone $this; + $self['jobID'] = $jobID; + + return $self; + } +} diff --git a/src/Folders/Job/JobGetResponse.php b/src/Folders/Job/JobGetResponse.php new file mode 100644 index 00000000..96fe6826 --- /dev/null +++ b/src/Folders/Job/JobGetResponse.php @@ -0,0 +1,130 @@ +, + * type?: null|Type|value-of, + * } + */ +final class JobGetResponse implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Unique identifier of the bulk job. + */ + #[Optional('jobId')] + public ?string $jobID; + + /** + * Unique identifier of the purge request. This will be present only if `purgeCache` is set to `true` in the rename folder API request. + */ + #[Optional('purgeRequestId')] + public ?string $purgeRequestID; + + /** + * Status of the bulk job. + * + * @var value-of|null $status + */ + #[Optional(enum: Status::class)] + public ?string $status; + + /** + * Type of the bulk job. + * + * @var value-of|null $type + */ + #[Optional(enum: Type::class)] + public ?string $type; + + 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 Status|value-of|null $status + * @param Type|value-of|null $type + */ + public static function with( + ?string $jobID = null, + ?string $purgeRequestID = null, + Status|string|null $status = null, + Type|string|null $type = null, + ): self { + $self = new self; + + null !== $jobID && $self['jobID'] = $jobID; + null !== $purgeRequestID && $self['purgeRequestID'] = $purgeRequestID; + null !== $status && $self['status'] = $status; + null !== $type && $self['type'] = $type; + + return $self; + } + + /** + * Unique identifier of the bulk job. + */ + public function withJobID(string $jobID): self + { + $self = clone $this; + $self['jobID'] = $jobID; + + return $self; + } + + /** + * Unique identifier of the purge request. This will be present only if `purgeCache` is set to `true` in the rename folder API request. + */ + public function withPurgeRequestID(string $purgeRequestID): self + { + $self = clone $this; + $self['purgeRequestID'] = $purgeRequestID; + + return $self; + } + + /** + * Status of the bulk job. + * + * @param Status|value-of $status + */ + public function withStatus(Status|string $status): self + { + $self = clone $this; + $self['status'] = $status; + + return $self; + } + + /** + * Type of the bulk job. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Folders/Job/JobGetResponse/Status.php b/src/Folders/Job/JobGetResponse/Status.php new file mode 100644 index 00000000..0d3bad1f --- /dev/null +++ b/src/Folders/Job/JobGetResponse/Status.php @@ -0,0 +1,15 @@ +` elements. + * This schema extends `SrcOptions` to add support for responsive image generation with breakpoints. + * + * @phpstan-type GetImageAttributesOptionsShape = array{ + * src: string, + * urlEndpoint: string, + * expiresIn?: float|null, + * queryParameters?: array|null, + * signed?: bool|null, + * transformation?: list|null, + * transformationPosition?: null|TransformationPosition|value-of, + * deviceBreakpoints?: list|null, + * imageBreakpoints?: list|null, + * sizes?: string|null, + * width?: float|null, + * } + */ +final class GetImageAttributesOptions implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Accepts a relative or absolute path of the resource. If a relative path is provided, it is appended to the `urlEndpoint`. + * If an absolute path is provided, `urlEndpoint` is ignored. + */ + #[Required] + public string $src; + + /** + * Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + */ + #[Required] + public string $urlEndpoint; + + /** + * When you want the signed URL to expire, specified in seconds. If `expiresIn` is anything above 0, + * the URL will always be signed even if `signed` is set to false. If not specified and `signed` is `true`, + * the signed URL will not expire (valid indefinitely). + * + * Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation time. After the expiry time, the signed URL will no longer be valid and ImageKit will return + * a 401 Unauthorized status code. + * + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + #[Optional] + public ?float $expiresIn; + + /** + * These are additional query parameters that you want to add to the final URL. + * They can be any query parameters and not necessarily related to ImageKit. + * This is especially useful if you want to add a versioning parameter to your URLs. + * + * @var array|null $queryParameters + */ + #[Optional(map: 'string')] + public ?array $queryParameters; + + /** + * Whether to sign the URL or not. Set this to `true` if you want to generate a signed URL. + * If `signed` is `true` and `expiresIn` is not specified, the signed URL will not expire (valid indefinitely). + * Note: If `expiresIn` is set to any value above 0, the URL will always be signed regardless of this setting. + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + #[Optional] + public ?bool $signed; + + /** + * An array of objects specifying the transformations to be applied in the URL. If more than one transformation is specified, they are applied in the order they are specified as chained transformations. + * See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + * + * @var list|null $transformation + */ + #[Optional(list: Transformation::class)] + public ?array $transformation; + + /** + * By default, the transformation string is added as a query parameter in the URL, e.g., `?tr=w-100,h-100`. + * If you want to add the transformation string in the path of the URL, set this to `path`. + * Learn more in the [Transformations guide](https://imagekit.io/docs/transformations). + * + * @var value-of|null $transformationPosition + */ + #[Optional(enum: TransformationPosition::class)] + public ?string $transformationPosition; + + /** + * Custom list of **device-width breakpoints** in pixels. + * These define common screen widths for responsive image generation. + * + * Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. + * Sorted automatically. + * + * @var list|null $deviceBreakpoints + */ + #[Optional(list: 'float')] + public ?array $deviceBreakpoints; + + /** + * Custom list of **image-specific breakpoints** in pixels. + * Useful for generating small variants (e.g., placeholders or thumbnails). + * + * Merged with `deviceBreakpoints` before calculating `srcSet`. + * Defaults to `[16, 32, 48, 64, 96, 128, 256, 384]`. + * Sorted automatically. + * + * @var list|null $imageBreakpoints + */ + #[Optional(list: 'float')] + public ?array $imageBreakpoints; + + /** + * The value for the HTML `sizes` attribute + * (e.g., `"100vw"` or `"(min-width:768px) 50vw, 100vw"`). + * + * - If it includes one or more `vw` units, breakpoints smaller than the corresponding percentage of the smallest device width are excluded. + * - If it contains no `vw` units, the full breakpoint list is used. + * + * Enables a width-based strategy and generates `w` descriptors in `srcSet`. + */ + #[Optional] + public ?string $sizes; + + /** + * The intended display width of the image in pixels, + * used **only when the `sizes` attribute is not provided**. + * + * Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors in `srcSet`. + * + * Ignored if `sizes` is present. + */ + #[Optional] + public ?float $width; + + /** + * `new GetImageAttributesOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * GetImageAttributesOptions::with(src: ..., urlEndpoint: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new GetImageAttributesOptions)->withSrc(...)->withURLEndpoint(...) + * ``` + */ + 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 array|null $queryParameters + * @param list|null $transformation + * @param TransformationPosition|value-of|null $transformationPosition + * @param list|null $deviceBreakpoints + * @param list|null $imageBreakpoints + */ + public static function with( + string $src, + string $urlEndpoint, + ?float $expiresIn = null, + ?array $queryParameters = null, + ?bool $signed = null, + ?array $transformation = null, + TransformationPosition|string|null $transformationPosition = null, + ?array $deviceBreakpoints = null, + ?array $imageBreakpoints = null, + ?string $sizes = null, + ?float $width = null, + ): self { + $self = new self; + + $self['src'] = $src; + $self['urlEndpoint'] = $urlEndpoint; + + null !== $expiresIn && $self['expiresIn'] = $expiresIn; + null !== $queryParameters && $self['queryParameters'] = $queryParameters; + null !== $signed && $self['signed'] = $signed; + null !== $transformation && $self['transformation'] = $transformation; + null !== $transformationPosition && $self['transformationPosition'] = $transformationPosition; + null !== $deviceBreakpoints && $self['deviceBreakpoints'] = $deviceBreakpoints; + null !== $imageBreakpoints && $self['imageBreakpoints'] = $imageBreakpoints; + null !== $sizes && $self['sizes'] = $sizes; + null !== $width && $self['width'] = $width; + + return $self; + } + + /** + * Accepts a relative or absolute path of the resource. If a relative path is provided, it is appended to the `urlEndpoint`. + * If an absolute path is provided, `urlEndpoint` is ignored. + */ + public function withSrc(string $src): self + { + $self = clone $this; + $self['src'] = $src; + + return $self; + } + + /** + * Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + */ + public function withURLEndpoint(string $urlEndpoint): self + { + $self = clone $this; + $self['urlEndpoint'] = $urlEndpoint; + + return $self; + } + + /** + * When you want the signed URL to expire, specified in seconds. If `expiresIn` is anything above 0, + * the URL will always be signed even if `signed` is set to false. If not specified and `signed` is `true`, + * the signed URL will not expire (valid indefinitely). + * + * Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation time. After the expiry time, the signed URL will no longer be valid and ImageKit will return + * a 401 Unauthorized status code. + * + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + public function withExpiresIn(float $expiresIn): self + { + $self = clone $this; + $self['expiresIn'] = $expiresIn; + + return $self; + } + + /** + * These are additional query parameters that you want to add to the final URL. + * They can be any query parameters and not necessarily related to ImageKit. + * This is especially useful if you want to add a versioning parameter to your URLs. + * + * @param array $queryParameters + */ + public function withQueryParameters(array $queryParameters): self + { + $self = clone $this; + $self['queryParameters'] = $queryParameters; + + return $self; + } + + /** + * Whether to sign the URL or not. Set this to `true` if you want to generate a signed URL. + * If `signed` is `true` and `expiresIn` is not specified, the signed URL will not expire (valid indefinitely). + * Note: If `expiresIn` is set to any value above 0, the URL will always be signed regardless of this setting. + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + public function withSigned(bool $signed): self + { + $self = clone $this; + $self['signed'] = $signed; + + return $self; + } + + /** + * An array of objects specifying the transformations to be applied in the URL. If more than one transformation is specified, they are applied in the order they are specified as chained transformations. + * See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + * + * @param list $transformation + */ + public function withTransformation(array $transformation): self + { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * By default, the transformation string is added as a query parameter in the URL, e.g., `?tr=w-100,h-100`. + * If you want to add the transformation string in the path of the URL, set this to `path`. + * Learn more in the [Transformations guide](https://imagekit.io/docs/transformations). + * + * @param TransformationPosition|value-of $transformationPosition + */ + public function withTransformationPosition( + TransformationPosition|string $transformationPosition + ): self { + $self = clone $this; + $self['transformationPosition'] = $transformationPosition; + + return $self; + } + + /** + * Custom list of **device-width breakpoints** in pixels. + * These define common screen widths for responsive image generation. + * + * Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. + * Sorted automatically. + * + * @param list $deviceBreakpoints + */ + public function withDeviceBreakpoints(array $deviceBreakpoints): self + { + $self = clone $this; + $self['deviceBreakpoints'] = $deviceBreakpoints; + + return $self; + } + + /** + * Custom list of **image-specific breakpoints** in pixels. + * Useful for generating small variants (e.g., placeholders or thumbnails). + * + * Merged with `deviceBreakpoints` before calculating `srcSet`. + * Defaults to `[16, 32, 48, 64, 96, 128, 256, 384]`. + * Sorted automatically. + * + * @param list $imageBreakpoints + */ + public function withImageBreakpoints(array $imageBreakpoints): self + { + $self = clone $this; + $self['imageBreakpoints'] = $imageBreakpoints; + + return $self; + } + + /** + * The value for the HTML `sizes` attribute + * (e.g., `"100vw"` or `"(min-width:768px) 50vw, 100vw"`). + * + * - If it includes one or more `vw` units, breakpoints smaller than the corresponding percentage of the smallest device width are excluded. + * - If it contains no `vw` units, the full breakpoint list is used. + * + * Enables a width-based strategy and generates `w` descriptors in `srcSet`. + */ + public function withSizes(string $sizes): self + { + $self = clone $this; + $self['sizes'] = $sizes; + + return $self; + } + + /** + * The intended display width of the image in pixels, + * used **only when the `sizes` attribute is not provided**. + * + * Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors in `srcSet`. + * + * Ignored if `sizes` is present. + */ + public function withWidth(float $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/ImageKit/Configuration/Configuration.php b/src/ImageKit/Configuration/Configuration.php deleted file mode 100644 index c0126318..00000000 --- a/src/ImageKit/Configuration/Configuration.php +++ /dev/null @@ -1,30 +0,0 @@ - 'Invalid Request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $INVALID_UPLOAD_OPTIONS = ['message' => 'Invalid Upload Options ImageKit initialization', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $INVALID_LIST_FILES_OPTIONS = ['message' => 'Invalid List Files Options ImageKit initialization', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MANDATORY_INITIALIZATION_MISSING = ['message' => 'Missing publicKey or privateKey or urlEndpoint during ImageKit initialization', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $INVALID_TRANSFORMATION_POSITION = ['message' => 'Invalid transformationPosition parameter', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $INVALID_FILE_OPTIONS = ['message' => 'Invalid File Options ImageKit initialization', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $LIST_FILES_OPTIONS_NON_ARRAY = ['message' => 'List File Options accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $CACHE_PURGE_URL_MISSING = ['message' => 'Missing URL parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $CACHE_PURGE_URL_INVALID = ['message' => 'Invalid URL provided for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $CACHE_PURGE_STATUS_ID_MISSING = ['message' => 'Missing Request ID parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $fileId_MISSING = ['message' => 'Missing File ID parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $versionId_MISSING = ['message' => 'Missing Version ID parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $JOBID_MISSING = ['message' => 'Missing Job ID parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPDATE_DATA_MISSING = ['message' => 'Missing file update data for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $BULK_TAGS_DATA_MISSING = ['message' => 'Missing bulk tag update data for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $BULK_TAGS_FILEIDS_MISSING = ['message' => 'Missing FileIds for Bulk Tags API', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $BULK_TAGS_FILEIDS_NON_ARRAY = ['message' => 'Bulk Tags API accepts FileIds as an array, non array passed', 'help' => 'For support kindly contact us at support@imagekit.io .' ]; - public static $BULK_TAGS_FILEIDS_EMPTY_ARRAY = ['message' => 'Bulk Tags API accepts FileIds as an array of ids, empty array passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $BULK_TAGS_TAGS_MISSING = ['message' => 'Missing Tags for Bulk Tags API', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $BULK_TAGS_TAGS_NON_ARRAY = ['message' => 'Bulk Tags API accepts Tags as an array, non array passed', 'help' => 'For support kindly contact us at support@imagekit.io .' ]; - public static $BULK_TAGS_TAGS_EMPTY_ARRAY = ['message' => 'Bulk Tags API accepts Tags as an array of tags, empty array passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $UPDATE_DATA_TAGS_INVALID = ['message' => 'Invalid tags parameter for this request', 'help' => "tags should be passed as null or an array like ['tag1', 'tag2']"]; - public static $UPDATE_DATA_COORDS_INVALID = ['message' => 'Invalid customCoordinates parameter for this request', 'help' => "customCoordinates should be passed as null or a string like 'x,y,width,height'"]; - public static $LIST_FILES_INPUT_MISSING = ['message' => 'Missing options for list files', 'help' => 'if you do not want to pass any parameter for listing, pass an empty object']; - public static $UPLOAD_FILE_PARAMETER_MISSING = ['message' => 'Upload API accepts an array of parameters, null passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_NON_ARRAY = ['message' => 'Upload API accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_EMPTY_ARRAY = ['message' => 'Upload API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_NON_ARRAY = ['message' => 'Upload API parameter "options" accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_USEUNIQUEFILENAME_INVALID = ['message' => 'useUniqueFileName must be boolean', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_ISPRIVATEFILE_INVALID = ['message' => 'isPrivateFile must be boolean', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_OVERWRITEFILE_INVALID = ['message' => 'overwriteFile must be boolean', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_OVERWRITEAITAGS_INVALID = ['message' => 'overwriteAITags must be boolean', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_OVERWRITETAGS_INVALID = ['message' => 'overwriteTags must be boolean', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_OVERWRITECUSTOMMETADATA_INVALID = ['message' => 'overwriteCustomMetadata must be boolean', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_EXTENSIONS_INVALID = ['message' => 'extensions must be an array', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_CUSTOMMETADATA_INVALID = ['message' => 'customMetadata must be an array', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_TRANSFORMATION = [ "message" => "Invalid transformation parameter. Please include at least pre, post, or both.", "help" => "For support kindly contact us at support@imagekit.io ."]; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_PRE_TRANSFORMATION = [ "message" => "Invalid pre transformation parameter.", "help" => "For support kindly contact us at support@imagekit.io ."]; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_POST_TRANSFORMATION = [ "message" => "Invalid post transformation parameter.", "help" => "For support kindly contact us at support@imagekit.io ."]; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_CHECKS = [ "message" => "The value provided for the checks parameter is invalid.", "help" => "For support kindly contact us at support@imagekit.io ."]; - public static $UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_PUBLISH_STATUS = [ "message" => "isPublished must be boolean.", "help" => "For support kindly contact us at support@imagekit.io ."]; - public static $MISSING_UPLOAD_DATA = ['message' => 'Missing data for upload', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MISSING_UPLOAD_FILE_PARAMETER = ['message' => 'Missing file parameter for upload', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MISSING_UPLOAD_FILENAME_PARAMETER = ['message' => 'Missing fileName parameter for upload', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $INVALID_PHASH_VALUE = ['message' => 'Invalid pHash value', 'help' => 'Both pHash strings must be valid hexadecimal numbers']; - public static $MISSING_PHASH_VALUE = ['message' => 'Missing pHash value', 'help' => 'Both pHash strings must be valid hexadecimal numbers']; - public static $UNEQUAL_STRING_LENGTH = ['message' => 'Unequal pHash string length', 'help' => 'For distance calucation, the two pHash strings must have equal length']; - public static $fileIdS_MISSING = ['message' => 'Missing Parameter FileIds', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $fileIdS_NON_ARRAY = ['message' => 'File ids should be passed in an array', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $fileIdS_EMPTY_ARRAY = ['message' => 'File ids should be passed as an array of file ids, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MISSING_URL_PARAMETER = ['message' => 'Your request is missing the url query paramater', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $INVALID_URL_PARAMETER = ['message' => 'Invalid URL provided for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_PARAMETER_MISSING = ['message' => 'URL Generation Method accepts an array, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_PARAMETER_NON_ARRAY = ['message' => 'URL Generation API accepts an array of parameters, non array value passed.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_PARAMETER_EMPTY_ARRAY = ['message' => 'URL Generation API accepts an array of parameters, empty array passed.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_SRC_INVALID = ['message' => 'src is not a valid URL', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_URL_INVALID = ['message' => 'Invalid urlEndpoint value', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_TRANSFORMATION_PARAMETER_INVALID = ['message' => 'Transformation Parameter accepts an array, not array or null provided.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_IF_CONDITION_MISSING = ['message' => 'Missing Parameter "condition" in if statement.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_IF_CONDITION_NON_ARRAY = ['message' => 'Invalid Parameter. "condition" accepts an array of parameters, non array value passed.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_IF_CONDITION_EMPTY_ARRAY = ['message' => '"condition" accepts an array of parameters, empty array passed.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_IF_CONDITION_INVALID_PROPERTY = ['message' => 'Invalid property applied in the condition. Refer to SDK docs for allowed properties.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_IF_CONDITION_INVALID_OPERAND = ['message' => 'Invalid operator applied. Allowed operators are "==","!=",">",">=","<","<="', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_IF_TRUE_MISSING = ['message' => 'Missing Parameter "true" in if statement.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_IF_TRUE_NON_ARRAY = ['message' => 'Invalid Parameter. "true" accepts an array of parameters, non array value passed.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_IF_TRUE_EMPTY_ARRAY = ['message' => '"true" accepts an array of parameters, empty array passed.', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_TRANSFORMATION_QUERY_INVALID = ['message' => 'Invalid value provided for "transformationPosition". Supported values are "path" and "query"', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $COPY_FILE_PARAMETER_MISSING = ['message' => 'Copy File API accepts an array, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $COPY_FILE_PARAMETER_NON_ARRAY = ['message' => 'Copy File API accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $COPY_FILE_PARAMETER_EMPTY_ARRAY = ['message' => 'Copy File API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $COPY_FILE_DATA_INVALID = ['message' => 'Missing parameter sourceFilePath and/or destinationPath for Copy File API', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $MOVE_FILE_PARAMETER_MISSING = ['message' => 'Move File API accepts an array, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $MOVE_FILE_PARAMETER_NON_ARRAY = ['message' => 'Move File API accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MOVE_FILE_PARAMETER_EMPTY_ARRAY = ['message' => 'Move File API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MOVE_FILE_DATA_INVALID = ['message' => 'Missing parameter sourceFilePath and/or destinationPath for Move File API', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $RENAME_FILE_PARAMETER_MISSING = ['message' => 'Rename File API accepts an array, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $RENAME_FILE_PARAMETER_NON_ARRAY = ['message' => 'Rename File API accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $RENAME_FILE_PARAMETER_EMPTY_ARRAY = ['message' => 'Rename File API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $RENAME_FILE_DATA_INVALID = ['message' => 'Missing parameter filePath and/or newFileName for Rename File API', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $RENAME_FILE_DATA_INVALID_PURGE_CACHE = ['message' => 'purgeCache parameter must be boolean', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $RESTORE_FILE_VERSION_PARAMETER_MISSING = ['message' => 'Restore File Version API accepts an array, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $RESTORE_FILE_VERSION_PARAMETER_NON_ARRAY = ['message' => 'Restore File Version API accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $RESTORE_FILE_VERSION_PARAMETER_EMPTY_ARRAY = ['message' => 'Restore File Version API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $RESTORE_FILE_VERSION_DATA_INVALID = ['message' => 'Missing parameter fileId and/or versionId for Restore File Version API', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $CREATE_FOLDER_PARAMETER_MISSING = ['message' => 'Create Folder API accepts an array, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $CREATE_FOLDER_PARAMETER_NON_ARRAY = ['message' => 'Create Folder API accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $CREATE_FOLDER_PARAMETER_EMPTY_ARRAY = ['message' => 'Create Folder API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $CREATE_FOLDER_DATA_INVALID = ['message' => 'Missing parameter folderName and/or parentFolderPath for Create Folder API', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $DELETE_FOLDER_PARAMETER_MISSING = ['message' => 'Missing folderPath for Delete Folder API', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $COPY_FOLDER_PARAMETER_MISSING = ['message' => 'Copy Folder API accepts an array, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $COPY_FOLDER_PARAMETER_NON_ARRAY = ['message' => 'Copy Folder API accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $COPY_FOLDER_PARAMETER_EMPTY_ARRAY = ['message' => 'Copy Folder API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $COPY_FOLDER_DATA_INVALID = ['message' => 'Missing parameter sourceFolderPath and/or destinationPath for Copy Folder API', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $MOVE_FOLDER_PARAMETER_MISSING = ['message' => 'Move Folder API accepts an array, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $MOVE_FOLDER_PARAMETER_NON_ARRAY = ['message' => 'Move Folder API accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MOVE_FOLDER_PARAMETER_EMPTY_ARRAY = ['message' => 'Move Folder API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MOVE_FOLDER_DATA_INVALID = ['message' => 'Missing parameter sourceFolderPath and/or destinationPath for Move Folder API', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $MISSING_CREATE_FOLDER_OPTIONS = ['message' => 'Missing data for creation of folder', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MISSING_DELETE_FOLDER_OPTIONS = ['message' => 'Missing data for deletion of folder', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MISSING_COPY_FOLDER_OPTIONS = ['message' => 'Missing data for copying folder', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $MISSING_MOVE_FOLDER_OPTIONS = ['message' => 'Missing data for moving folder', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $CREATE_CUSTOM_METADATA_PARAMETER_MISSING = ['message' => 'Create Custom Metadata API accepts an array, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $CREATE_CUSTOM_METADATA_PARAMETER_NON_ARRAY = ['message' => 'Create Custom Metadata API accepts an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $CREATE_CUSTOM_METADATA_PARAMETER_EMPTY_ARRAY = ['message' => 'Create Custom Metadata API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $CREATE_CUSTOM_METADATA_DATA_INVALID = ['message' => 'Missing parameter name and/or label and/or schema for this request', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $CREATE_CUSTOM_METADATA_DATA_INVALID_SCHEMA_OBJECT = ['message' => 'Invalid parameter schema', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $GET_CUSTOM_METADATA_INVALID_PARAMETER = ['message' => 'Invalid parameter includeDeleted', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $UPDATE_CUSTOM_METADATA_PARAMETER_MISSING = ['message' => 'Update Custom Metadata API accepts an id and requestBody, null passed', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $UPDATE_CUSTOM_METADATA_PARAMETER_NON_ARRAY = ['message' => 'Update Custom Metadata API accepts requestBody as an array of parameters, non array value passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPDATE_CUSTOM_METADATA_PARAMETER_EMPTY_ARRAY = ['message' => 'Update Custom Metadata API accepts an array of parameters, empty array passed', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPDATE_CUSTOM_METADATA_DATA_INVALID = ['message' => 'Missing parameter label and/or schema for this request', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $UPDATE_CUSTOM_METADATA_DATA_INVALID_SCHEMA_OBJECT = ['message' => 'Invalid parameter schema', 'help' => - 'For support kindly contact us at support@imagekit.io .']; - public static $UPDATE_CUSTOM_METADATA_ID_MISSING = ['message' => 'Missing Custom Metadata Field ID parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $UPDATE_CUSTOM_METADATA_BODY_MISSING = ['message' => 'Missing body parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $DELETE_CUSTOM_METADATA_ID_MISSING = ['message' => 'Missing Custom Metadata Field ID parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $PHASH_DISTANCE_FIRST_PHASH_MISSING = ['message' => 'Missing First pHash parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $PHASH_DISTANCE_SECOND_PHASH_MISSING = ['message' => 'Missing Second pHash parameter for this request', 'help' => 'For support kindly contact us at support@imagekit.io .']; - public static $URL_GENERATION_EXPIRESECONDS_PARAMETER_INVALID = ['message' => 'expireSeconds accepts an integer value, non integer value provided.', 'help' => 'For support kindly contact us at support@imagekit.io .']; -} diff --git a/src/ImageKit/Constants/SupportedTransforms.php b/src/ImageKit/Constants/SupportedTransforms.php deleted file mode 100644 index c31aa4de..00000000 --- a/src/ImageKit/Constants/SupportedTransforms.php +++ /dev/null @@ -1,51 +0,0 @@ - 'h', - 'width' => 'w', - 'aspectRatio' => 'ar', - 'quality' => 'q', - 'crop' => 'c', - 'cropMode' => 'cm', - 'x' => 'x', - 'y' => 'y', - 'focus' => 'fo', - 'format' => 'f', - 'radius' => 'r', - 'background' => 'bg', - 'border' => 'b', - 'rotation' => 'rt', - 'blur' => 'bl', - 'named' => 'n', - 'progressive' => 'pr', - 'lossless' => 'lo', - 'trim' => 't', - 'metadata' => 'md', - 'colorProfile' => 'cp', - 'defaultImage' => 'di', - 'dpr' => 'dpr', - 'effectSharpen' => 'e-sharpen', - 'effectUSM' => 'e-usm', - 'effectContrast' => 'e-contrast', - 'effectGray' => 'e-grayscale', - 'effectShadow' => 'e-shadow', - 'effectGradient' => 'e-gradient', - 'original' => 'orig', - 'rotate' => 'rt', - ]; - - /** - * @return array - */ - public static function get() - { - return self::$transforms; - } -} diff --git a/src/ImageKit/ImageKit.php b/src/ImageKit/ImageKit.php deleted file mode 100644 index 33089341..00000000 --- a/src/ImageKit/ImageKit.php +++ /dev/null @@ -1,1205 +0,0 @@ -configuration = new Configuration(); - if ($publicKey == null || empty($publicKey)) { - $msg = 'Missing publicKey during ImageKit initialization'; - throw new InvalidArgumentException($msg); - } - $this->configuration->publicKey = $publicKey; - - if ($privateKey == null || empty($privateKey)) { - $msg = 'Missing privateKey during ImageKit initialization'; - throw new InvalidArgumentException($msg); - } - $this->configuration->privateKey = $privateKey; - - if ($urlEndpoint == null || empty($urlEndpoint)) { - $msg = 'Missing urlEndpoint during ImageKit initialization'; - throw new InvalidArgumentException($msg); - } - - if (!filter_var($urlEndpoint, FILTER_VALIDATE_URL)) { - throw new InvalidArgumentException('urlEndpoint should be a valid URL'); - } - $this->configuration->urlEndpoint = $urlEndpoint; - - if ($transformationPosition !== 'path' && $transformationPosition !== 'query') { - $msg = 'Invalid transformationPosition during ImageKit initialization. Can be one of path or query'; - throw new InvalidArgumentException($msg); - } - $this->configuration->transformationPosition = $transformationPosition; - - $client = new Client(Authorization::addAuthorization($this->configuration,$handlerStack)); - $this->httpClient = new GuzzleHttpWrapper($client); - } - - /** - * You can add multiple origins in the same ImageKit.io account. - * URL endpoints allow you to configure which origins are accessible through your account and set their preference - * order as well. - * - * @link https://docs.imagekit.io/integration/url-endpoints Url Endpoint Documentation - * @link https://github.com/imagekit-developer/imagekit-php#url-generation Url Generation Documentation - * - * @param array $options - * @return string - */ - public function url($options=null) - { - if(!isset($options)){ - return json_encode(Response::respond(true, ((object)ErrorMessages::$URL_GENERATION_PARAMETER_MISSING))); - } - if(!is_array($options)){ - return json_encode(Response::respond(true, ((object)ErrorMessages::$URL_GENERATION_PARAMETER_NON_ARRAY))); - } - if(sizeof($options)==0){ - return json_encode(Response::respond(true, ((object)ErrorMessages::$URL_GENERATION_PARAMETER_EMPTY_ARRAY))); - } - if (isset($options['src']) && !filter_var($options['src'], FILTER_VALIDATE_URL)) { - return json_encode(Response::respond(true, ((object)ErrorMessages::$URL_GENERATION_SRC_INVALID))); - } - if (isset($options['urlEndpoint']) && !filter_var($options['urlEndpoint'], FILTER_VALIDATE_URL)) { - return json_encode(Response::respond(true, ((object)ErrorMessages::$URL_GENERATION_URL_INVALID))); - } - - if (isset($options['transformation']) && !is_array($options['transformation'])) { - return json_encode(Response::respond(true, ((object)ErrorMessages::$URL_GENERATION_TRANSFORMATION_PARAMETER_INVALID))); - } - - if (isset($options['signed']) && $options['signed'] === true){ - if(isset($options['expireSeconds']) && $options['expireSeconds'] !== '' && !is_numeric($options['expireSeconds'])){ - return json_encode(Response::respond(true, ((object)ErrorMessages::$URL_GENERATION_EXPIRESECONDS_PARAMETER_INVALID))); - } - } - - $urlInstance = new Url(); - return $urlInstance->buildURL(array_merge((array)$this->configuration, $options)); - } - - /** - * You can upload files to ImageKit.io media library from your server-side using private API key authentication. - * - * - * @link https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload API Reference - * - * @param array $options - * @return object - * - */ - public function upload($options=null) - { - return $this->uploadFile($options); - } - - /** - * You can upload files to ImageKit.io media library from your server-side using private API key authentication. - * - * - * @link https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload API Reference - * - * @param array $options - * @return Response - */ - public function uploadFile($options=null) - { - - if(!isset($options)){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_MISSING)); - } - if(!is_array($options)){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_NON_ARRAY)); - } - if(sizeof($options)==0){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_EMPTY_ARRAY)); - } - if (empty($options['file'])) { - return Response::respond(true, ((object)ErrorMessages::$MISSING_UPLOAD_FILE_PARAMETER)); - } - if (empty($options['fileName'])) { - return Response::respond(true, ((object)ErrorMessages::$MISSING_UPLOAD_FILENAME_PARAMETER)); - } - if(isset($options['useUniqueFileName']) && !is_bool($options['useUniqueFileName'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_USEUNIQUEFILENAME_INVALID)); - } - if(isset($options['isPrivateFile']) && !is_bool($options['isPrivateFile'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_ISPRIVATEFILE_INVALID)); - } - if(isset($options['overwriteFile']) && !is_bool($options['overwriteFile'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_OVERWRITEFILE_INVALID)); - } - if(isset($options['overwriteAITags']) && !is_bool($options['overwriteAITags'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_OVERWRITEAITAGS_INVALID)); - } - if(isset($options['overwriteTags']) && !is_bool($options['overwriteTags'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_OVERWRITETAGS_INVALID)); - } - if(isset($options['overwriteCustomMetadata']) && !is_bool($options['overwriteCustomMetadata'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_OVERWRITECUSTOMMETADATA_INVALID)); - } - if(isset($options['extensions']) && !is_array($options['extensions'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_EXTENSIONS_INVALID)); - } - if(isset($options['customMetadata']) && !is_array($options['customMetadata'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_CUSTOMMETADATA_INVALID)); - } - if (isset($options['transformation'])) { - if (!isset($options['transformation']['pre']) && !isset($options['transformation']['post'])) { - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_TRANSFORMATION)); - } - if (isset($options['transformation']['pre']) && empty($options['transformation']['pre'])) { - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_PRE_TRANSFORMATION)); - } - if (isset($options['transformation']['post'])) { - if (is_array($options['transformation']['post'])) { - foreach ($options['transformation']['post'] as $transformation) { - if ($transformation['type'] === "abs" && (!isset($transformation['protocol']) || !isset($transformation['value']))) { - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_POST_TRANSFORMATION)); - } else if ($transformation['type'] === "transformation" && empty($transformation['value'])) { - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_POST_TRANSFORMATION)); - } - } - } else { - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_POST_TRANSFORMATION)); - } - } - } - if(isset($options['checks']) && !is_string($options['checks'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_CHECKS)); - } - if(isset($options['isPublished']) && !is_bool($options['isPublished'])){ - return Response::respond(true, ((object)ErrorMessages::$UPLOAD_FILE_PARAMETER_OPTIONS_INVALID_PUBLISH_STATUS)); - } - $this->httpClient->setUri(Endpoints::getUploadFileEndpoint()); - return Upload::upload($options, $this->httpClient); - } - - /** - * You can upload files to ImageKit.io media library from your server-side using private API key authentication. - * - * - * @link https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload API Reference - * - * @param array $options - * @return Response - * - * @deprecated since 2.0.0, use uploadFile; uploadFiles was misleading as it supports only singular - * - * file upload - */ - public function uploadFiles($options=null) - { - return $this->uploadFile($options); - } - - /** - * This API can list all the uploaded files in your ImageKit.io media library. - * For searching and filtering, you can use query parameters as described below. - * - * @link https://docs.imagekit.io/api-reference/media-api/list-and-search-files API Reference - * - * @param array $parameters - * @return Response - */ - public function listFiles($parameters = null) - { - if($parameters){ - if(!is_array($parameters)){ - return Response::respond(true, ((object)ErrorMessages::$LIST_FILES_OPTIONS_NON_ARRAY)); - } - } - - $this->httpClient->setUri(Endpoints::getListFilesEndpoint()); - return Manage\File::listFile($this->httpClient, $parameters); - } - - /** - * Get the file details such as tags, customCoordinates, and isPrivate properties using get file detail API. - * - * @link https://docs.imagekit.io/api-reference/media-api/get-file-details API Reference - * - * @param string $fileId - * - * @return Response - * - * @deprecated since 2.0.0, use getFileDetails - */ - public function getDetails($fileId=null) - { - return $this->getFileDetails($fileId); - } - - /** - * Get the file details such as tags, customCoordinates, and isPrivate properties using get file detail API. - * - * @link https://docs.imagekit.io/api-reference/media-api/get-file-details API Reference - * - * @param string $fileId - * @return Response - * - */ - public function getFileDetails($fileId=null) - { - if (empty($fileId)) { - return Response::respond(true, ((object)ErrorMessages::$fileId_MISSING)); - } - $this->httpClient->setUri(Endpoints::getDetailsEndpoint($fileId)); - return Manage\File::getDetails($fileId, $this->httpClient); - } - - /** - * Get the file version details such as tags, customCoordinates, and isPrivate properties using get file version details API. - * - * @link https://docs.imagekit.io/api-reference/media-api/get-file-version-details API Reference - * - * @param string $fileId - * @param string $versionId - * @return Response - * - */ - public function getFileVersionDetails($fileId=null, $versionId=null) - { - if (empty($fileId)) { - return Response::respond(true, ((object)ErrorMessages::$fileId_MISSING)); - } - - if (empty($versionId)) { - return Response::respond(true, ((object)ErrorMessages::$versionId_MISSING)); - } - - $this->httpClient->setUri(Endpoints::getVersionDetailsEndpoint($fileId, $versionId)); - return Manage\File::getVersionDetails($fileId, $versionId, $this->httpClient); - } - - /** - * Get all the versions of a file using get file versions API. - * - * @link https://docs.imagekit.io/api-reference/media-api/get-file-versions API Reference - * - * @param string $fileId - * @return Response - * - */ - public function getFileVersions($fileId=null) - { - if (empty($fileId)) { - return Response::respond(true, ((object)ErrorMessages::$fileId_MISSING)); - } - - $this->httpClient->setUri(Endpoints::getFileVersionsEndpoint($fileId)); - return Manage\File::getFileVersions($fileId, $this->httpClient); - } - - /** - * Get image exif, pHash and other metadata for uploaded files in ImageKit.io media library using this API. - * - * @link https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files - * - * @param string $fileId The unique fileId of the uploaded file. fileId is returned in list files API and upload API - * - * @return Response - * @deprecated since 2.0.0, use getFileMetaData - */ - public function getMetaData($fileId=null) - { - return $this->getFileMetaData($fileId); - } - - /** - * Get image exif, pHash and other metadata for uploaded files in ImageKit.io media library using this API. - * - * @link https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files - * - * @param string $fileId The unique fileId of the uploaded file. fileId is returned in list files API and upload API - * - * @return Response - */ - public function getFileMetaData($fileId=null) - { - if (empty($fileId)) { - return Response::respond(true, ((object)ErrorMessages::$fileId_MISSING)); - } - $this->httpClient->setUri(Endpoints::getListMetaDataFilesEndpoint($fileId)); - return Manage\CustomMetadataFields::get($fileId, $this->httpClient); - } - - /** - * Update file details such as tags and customCoordinates attribute using update file detail API. - * - * @link https://docs.imagekit.io/api-reference/media-api/update-file-details - * - * @param string $fileId The unique fileId of the uploaded file. fileId is returned in list files API and upload API - * @param array $updateData - * - * @return Response - * @deprecated since 2.0.0, use updateFileDetails - */ - public function updateDetails($fileId=null, $updateData=null) - { - return $this->updateFileDetails($fileId, $updateData); - } - - /** - * Update file details such as tags and customCoordinates attribute using update file detail API. - * - * @link https://docs.imagekit.io/api-reference/media-api/update-file-details - * - * @param string $fileId The unique fileId of the uploaded file. fileId is returned in list files API and upload API - * @param array $updateData - * @return Response - */ - public function updateFileDetails($fileId=null, $updateData=null) - { - if (empty($fileId)) { - return Response::respond(true, ((object)ErrorMessages::$fileId_MISSING)); - } - - if (!is_array($updateData) || sizeof($updateData)==0) { - return Response::respond(true, ((object)ErrorMessages::$UPDATE_DATA_MISSING)); - } - - $this->httpClient->setUri(Endpoints::getUpdateFileDetailsEndpoint($fileId)); - return Manage\File::updateDetails($fileId, $updateData, $this->httpClient); - } - - /** - * Add tags to multiple files in a single request. The method accepts an array of fileIDs of the files and an - * array of tags that have to be added to those files. - * - * @link https://docs.imagekit.io/api-reference/media-api/add-tags-bulk - * - * @param array $fileIds - * @param array $tags - * - * @return Response - */ - public function bulkAddTags($fileIds=null, $tags=null) - { - if(!isset($fileIds)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_FILEIDS_MISSING)); - } - if(!is_array($fileIds)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_FILEIDS_NON_ARRAY)); - } - if(sizeof($fileIds)==0){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_FILEIDS_EMPTY_ARRAY)); - } - if(!isset($tags)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_TAGS_MISSING)); - } - if(!is_array($tags)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_TAGS_NON_ARRAY)); - } - if(sizeof($tags)==0){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_TAGS_EMPTY_ARRAY)); - } - - $this->httpClient->setUri(Endpoints::getBulkAddTagsEndpoint()); - return Manage\File::bulkAddTags($fileIds, $tags, $this->httpClient); - } - - /** - * Remove tags to multiple files in a single request. The method accepts an array of fileIDs of the files and an - * array of tags that have to be removed to those files. - * - * @link https://docs.imagekit.io/api-reference/media-api/remove-tags-bulk - * - * @param array $fileIds - * @param array $tags - * - * @return Response - */ - public function bulkRemoveTags($fileIds=null, $tags=null) - { - if(!isset($fileIds)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_FILEIDS_MISSING)); - } - if(!is_array($fileIds)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_FILEIDS_NON_ARRAY)); - } - if(sizeof($fileIds)==0){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_FILEIDS_EMPTY_ARRAY)); - } - if(!isset($tags)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_TAGS_MISSING)); - } - if(!is_array($tags)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_TAGS_NON_ARRAY)); - } - if(sizeof($tags)==0){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_TAGS_EMPTY_ARRAY)); - } - - $this->httpClient->setUri(Endpoints::getBulkRemoveTagsEndpoint()); - return Manage\File::bulkRemoveTags($fileIds, $tags, $this->httpClient); - } - - /** - * Remove AI tags from multiple files in a single request. The method accepts an array of fileIDs of the files and an array of tags that have to be removed to those files. - * - * @link https://docs.imagekit.io/api-reference/media-api/remove-aitags-bulk - * - * @param array $fileIds - * @param array $AITags - * - * @return Response - */ - public function bulkRemoveAITags($fileIds=null, $AITags=null) - { - if(!isset($fileIds)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_FILEIDS_MISSING)); - } - if(!is_array($fileIds)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_FILEIDS_NON_ARRAY)); - } - if(sizeof($fileIds)==0){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_FILEIDS_EMPTY_ARRAY)); - } - if(!isset($AITags)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_TAGS_MISSING)); - } - if(!is_array($AITags)){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_TAGS_NON_ARRAY)); - } - if(sizeof($AITags)==0){ - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_TAGS_EMPTY_ARRAY)); - } - $this->httpClient->setUri(Endpoints::getBulkRemoveAITagsEndpoint()); - return Manage\File::bulkRemoveAITags($fileIds, $AITags, $this->httpClient); - } - - /** - * You can programmatically delete uploaded files in media library using delete file API. - * - * @link https://docs.imagekit.io/api-reference/media-api/delete-file - * - * @param $fileId - * @return Response - * - */ - public function deleteFile($fileId=null) - { - if (!isset($fileId) || empty($fileId)) { - return Response::respond(true, ((object)ErrorMessages::$fileId_MISSING)); - } - - $this->httpClient->setUri(Endpoints::getDeleteFilesEndpoint($fileId)); - return Manage\File::delete($fileId, $this->httpClient); - } - - - /** - * You can programmatically delete uploaded file version in media library using delete file version API. - * - * @link https://docs.imagekit.io/api-reference/media-api/delete-file-version - * - * @param $fileId - * @param $versionId - * @return Response - * - */ - public function deleteFileVersion($fileId=null, $versionId=null) - { - if (!isset($fileId) || empty($fileId)) { - return Response::respond(true, ((object)ErrorMessages::$fileId_MISSING)); - } - - if (!isset($versionId) || empty($versionId)) { - return Response::respond(true, ((object)ErrorMessages::$versionId_MISSING)); - } - - $this->httpClient->setUri(Endpoints::getDeleteFileVersionEndpoint($fileId,$versionId)); - return Manage\File::deleteVersion($fileId, $versionId, $this->httpClient); - } - - /** - * This will purge CDN and ImageKit.io internal cache. - * - * @link https://docs.imagekit.io/api-reference/media-api/purge-cache - * - * @param $options - * @return Response - * - * @deprecated since 2.0.0, use purgeCache - */ - public function purgeFileCacheApi($options=null) - { - return $this->purgeCache($options); - } - - /** - * This will purge CDN and ImageKit.io internal cache. - * - * @link https://docs.imagekit.io/api-reference/media-api/purge-cache - * - * @param $options - * @return Response - * - * @deprecated since 2.0.0, use purgeCache - */ - public function purgeCacheApi($options=null) - { - return $this->purgeCache($options); - } - - /** - * This will purge CDN and ImageKit.io internal cache. - * - * @link https://docs.imagekit.io/api-reference/media-api/purge-cache - * - * @param $options - * @return Response - */ - public function purgeCache($options=null) - { - if (empty($options)) { - return Response::respond(true, ((object)ErrorMessages::$CACHE_PURGE_URL_MISSING)); - } - - if (!filter_var($options, FILTER_VALIDATE_URL)) { - return Response::respond(true, ((object)ErrorMessages::$CACHE_PURGE_URL_INVALID)); - } - - $this->httpClient->setUri(Endpoints::getPurgeCacheEndpoint()); - return Manage\Cache::purgeFileCache($options, $this->httpClient); - } - - /** - * Get the status of submitted purge request. - * - * @link https://docs.imagekit.io/api-reference/media-api/purge-cache-status - * - * @param $requestId - * @return Response - * - * @deprecated since 2.0.0, use getPurgeCacheStatus - */ - public function purgeCacheStatus($requestId=null) - { - return $this->getPurgeCacheStatus($requestId); - } - - /** - * Get the status of submitted purge request. - * - * @link https://docs.imagekit.io/api-reference/media-api/purge-cache-status - * - * @param $requestId - * @return Response - * - * @deprecated since 2.0.0, use getPurgeCacheStatus - */ - public function purgeFileCacheApiStatus($requestId=null) - { - return $this->getPurgeCacheStatus($requestId); - } - - /** - * Get the status of submitted purge request. - * - * @link https://docs.imagekit.io/api-reference/media-api/purge-cache-status - * - * @param $requestId - * @return Response - */ - public function getPurgeCacheStatus($requestId=null) - { - if (empty($requestId)) { - return Response::respond(true, ((object)ErrorMessages::$CACHE_PURGE_STATUS_ID_MISSING)); - } - - $this->httpClient->setUri(Endpoints::getPurgeCacheApiStatusEndpoint($requestId)); - return Manage\Cache::purgeFileCacheStatus($requestId, $this->httpClient); - } - - /** - * Delete multiple files. The method accepts an array of file IDs of the files that have to be deleted. - * - * @link https://docs.imagekit.io/api-reference/media-api/delete-files-bulk - * - * @param $options - * @return Response - * - * @deprecated since 2.0.0, use bulkDeleteFiles - */ - public function bulkFileDeleteByIds($fileIds=null) - { - return $this->bulkDeleteFiles($fileIds); - } - - /** - * Delete multiple files. The method accepts an array of file IDs of the files that have to be deleted. - * - * @link https://docs.imagekit.io/api-reference/media-api/delete-files-bulk - * - * @param $fileIds - * @return Response - * - */ - public function bulkDeleteFiles($fileIds=null) - { - if (!isset($fileIds)) { - return Response::respond(true, ((object)ErrorMessages::$fileIdS_MISSING)); - } - if (!is_array($fileIds)) { - return Response::respond(true, ((object)ErrorMessages::$fileIdS_NON_ARRAY)); - } - if (sizeof($fileIds)==0) { - return Response::respond(true, ((object)ErrorMessages::$fileIdS_EMPTY_ARRAY)); - } - - $this->httpClient->setUri(Endpoints::getDeleteByFileIdsEndpoint()); - return Manage\File::bulkDeleteByFileIds($fileIds, $this->httpClient); - } - - /** - * This will copy a file from one location to another. This method accepts an array of source file's path, destination path and boolean to include versions or not - * folder path. - * - * @link https://docs.imagekit.io/api-reference/media-api/copy-file - * - * @param $parameter['sourceFilePath','destinationPath','includeFileVersions'] - * @return Response - * - */ - public function copy($parameter=null) - { - if(!isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$COPY_FILE_PARAMETER_MISSING)); - } - if(!is_array($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$COPY_FILE_PARAMETER_NON_ARRAY)); - } - if(sizeof($parameter)==0){ - return Response::respond(true, ((object)ErrorMessages::$COPY_FILE_PARAMETER_EMPTY_ARRAY)); - } - if (empty($parameter['sourceFilePath']) || empty($parameter['destinationPath'])) { - return Response::respond(true, ((object)ErrorMessages::$COPY_FILE_DATA_INVALID)); - } - - $this->httpClient->setUri(Endpoints::getCopyFileEndpoint()); - return Manage\File::copy($parameter['sourceFilePath'], $parameter['destinationPath'], isset($parameter['includeFileVersions']) ? $parameter['includeFileVersions'] : false, $this->httpClient); - } - - - /** - * This will copy a file from one location to another. This method accepts an array of source file's path, destination path and boolean to include versions or not - * folder path. - * - * @link https://docs.imagekit.io/api-reference/media-api/copy-file - * - * @param $sourceFilePath - * @param $destinationPath - * @param $includeFileVersions - * @return Response - * - * @deprecated since 3.0.0, use copy - * - */ - public function copyFile($sourceFilePath=null, $destinationPath=null, $includeFileVersions=null) - { - - if (empty($sourceFilePath) || empty($destinationPath)) { - return Response::respond(true, ((object)ErrorMessages::$COPY_FILE_DATA_INVALID)); - } - - $this->httpClient->setUri(Endpoints::getCopyFileEndpoint()); - return Manage\File::copy($sourceFilePath, $destinationPath, $includeFileVersions, $this->httpClient); - } - - /** - * This will move a file from one location to another. This method accepts an array containing source file's path and destination path - * folder path. - * - * @link https://docs.imagekit.io/api-reference/media-api/move-file - * - * @param $parameter['sourceFilePath','destinationPath'] - * @return Response - * - */ - public function move($parameter=null) - { - if(!isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$MOVE_FILE_PARAMETER_MISSING)); - } - if(!is_array($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$MOVE_FILE_PARAMETER_NON_ARRAY)); - } - if(sizeof($parameter)==0){ - return Response::respond(true, ((object)ErrorMessages::$MOVE_FILE_PARAMETER_EMPTY_ARRAY)); - } - if (empty($parameter['sourceFilePath']) || empty($parameter['destinationPath'])) { - return Response::respond(true, ((object)ErrorMessages::$MOVE_FILE_DATA_INVALID)); - } - $this->httpClient->setUri(Endpoints::getMoveFileEndpoint()); - return Manage\File::move($parameter['sourceFilePath'], $parameter['destinationPath'], $this->httpClient); - } - - /** - * This will move a file from one location to another. This method accepts an array containing source file's path and destination path - * folder path. - * - * @link https://docs.imagekit.io/api-reference/media-api/move-file - * - * @param $sourceFilePath - * @param $destinationPath - * @param $includeVersions - * @return Response - * - * @deprecated since 3.0.0, use move - */ - public function moveFile($sourceFilePath=null, $destinationPath=null) - { - if (empty($sourceFilePath) || empty($destinationPath)) { - return Response::respond(true, ((object)ErrorMessages::$MOVE_FILE_DATA_INVALID)); - } - $this->httpClient->setUri(Endpoints::getMoveFileEndpoint()); - return Manage\File::move($sourceFilePath, $destinationPath, $this->httpClient); - } - - /** - * This will rename a file. This method accepts the source file's path, new file name and an optional parameter - * boolean to purge cache - * - * - * @link https://docs.imagekit.io/api-reference/media-api/rename-file - * - * @param $parameter[$filePath, $newFileNamem, $purgeCache] - * - * @return Response - */ - public function rename($parameter=null) - { - if(!isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$RENAME_FILE_PARAMETER_MISSING)); - } - if(!is_array($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$RENAME_FILE_PARAMETER_NON_ARRAY)); - } - if(sizeof($parameter)==0){ - return Response::respond(true, ((object)ErrorMessages::$RENAME_FILE_PARAMETER_EMPTY_ARRAY)); - } - if (empty($parameter['filePath']) || empty($parameter['newFileName'])) { - return Response::respond(true, ((object)ErrorMessages::$RENAME_FILE_DATA_INVALID)); - } - $purgeCache= false; - if(isset($parameter['purgeCache'])){ - if(!is_bool($parameter['purgeCache'])){ - return Response::respond(true, ((object)ErrorMessages::$RENAME_FILE_DATA_INVALID_PURGE_CACHE)); - } - else{ - $purgeCache = $parameter['purgeCache']; - } - } - - $this->httpClient->setUri(Endpoints::getRenameFileEndpoint()); - return Manage\File::rename($parameter['filePath'], $parameter['newFileName'], $purgeCache, $this->httpClient); - } - - /** - * This will rename a file. This method accepts the source file's path, new file name and an optional parameter - * boolean to purge cache - * - * - * @link https://docs.imagekit.io/api-reference/media-api/rename-file - * - * @param $filePath - * @param $newFileName - * @param $purgeCache - * @return Response - * - * @deprecated since 3.0.0, use rename - */ - public function renameFile($filePath, $newFileName, $purgeCache = false) - { - if (empty($filePath) || empty($newFileName)) { - return Response::respond(true, ((object)ErrorMessages::$RENAME_FILE_DATA_INVALID)); - } - - $this->httpClient->setUri(Endpoints::getRenameFileEndpoint()); - return Manage\File::rename($filePath, $newFileName, $purgeCache, $this->httpClient); - } - - /** - * This will Restore file version to a different version of a file. This method accepts the fileId and versionId - * - * - * @link https://docs.imagekit.io/api-reference/media-api/restore-file-version - * - * @param $parameter[$fileId, $versionId] - * @return Response - */ - public function restoreFileVersion($parameter=null) - { - if(!isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$RESTORE_FILE_VERSION_PARAMETER_MISSING)); - } - if(!is_array($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$RESTORE_FILE_VERSION_PARAMETER_NON_ARRAY)); - } - if(sizeof($parameter)==0){ - return Response::respond(true, ((object)ErrorMessages::$RESTORE_FILE_VERSION_PARAMETER_EMPTY_ARRAY)); - } - if (empty($parameter['fileId']) || empty($parameter['versionId'])) { - return Response::respond(true, ((object)ErrorMessages::$RESTORE_FILE_VERSION_DATA_INVALID)); - } - $this->httpClient->setUri(Endpoints::getRestoreFileVersionEndpoint($parameter['fileId'], $parameter['versionId'])); - return Manage\File::restoreVersion($this->httpClient); - } - - - /** - * This will create a new folder. This method accepts folder name and parent folder path in an array. - * - * @link https://docs.imagekit.io/api-reference/media-api/create-folder - * - * @param $parameter[$folderName, $parentFolderPath] - * - * @return Response - */ - public function createFolder($parameter=null) - { - if(!isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$CREATE_FOLDER_PARAMETER_MISSING)); - } - if(!is_array($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$CREATE_FOLDER_PARAMETER_NON_ARRAY)); - } - if(sizeof($parameter)==0){ - return Response::respond(true, ((object)ErrorMessages::$CREATE_FOLDER_PARAMETER_EMPTY_ARRAY)); - } - if (empty($parameter['folderName']) || empty($parameter['parentFolderPath'])) { - return Response::respond(true, ((object)ErrorMessages::$CREATE_FOLDER_DATA_INVALID)); - } - $this->httpClient->setUri(Endpoints::getCreateFolderEndpoint()); - return Manage\Folder::create($parameter['folderName'], $parameter['parentFolderPath'], $this->httpClient); - } - - /** - * This will delete the specified folder and all nested files & folders. - * This method accepts the full path of the folder that is to be deleted. - * - * @link https://docs.imagekit.io/api-reference/media-api/delete-folder - * - * @param $folderPath - * - * @return Response - */ - public function deleteFolder($folderPath=null) - { - if(!isset($folderPath) || empty($folderPath)){ - return Response::respond(true, ((object)ErrorMessages::$DELETE_FOLDER_PARAMETER_MISSING)); - } - $this->httpClient->setUri(Endpoints::getDeleteFolderEndpoint()); - return Manage\Folder::delete($folderPath, $this->httpClient); - } - - /** - * This will copy a folder from one location to another. This method accepts an array of source folder's path, destination path and boolean to include versions or not. - * - * @link https://docs.imagekit.io/api-reference/media-api/copy-folder - * - * @param $parameter[$sourceFolderPath, $destinationPath, includeFileVersions] - * - * @return Response - */ - public function copyFolder($parameter=null) - { - if(!isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$COPY_FOLDER_PARAMETER_MISSING)); - } - if(!is_array($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$COPY_FOLDER_PARAMETER_NON_ARRAY)); - } - if(sizeof($parameter)==0){ - return Response::respond(true, ((object)ErrorMessages::$COPY_FOLDER_PARAMETER_EMPTY_ARRAY)); - } - if (empty($parameter['sourceFolderPath']) || empty($parameter['destinationPath'])) { - return Response::respond(true, ((object)ErrorMessages::$COPY_FOLDER_DATA_INVALID)); - } - - $this->httpClient->setUri(Endpoints::getCopyFolderEndpoint()); - return Manage\Folder::copy($parameter['sourceFolderPath'], $parameter['destinationPath'], isset($parameter['includeFileVersions']) ? $parameter['includeFileVersions'] : false, $this->httpClient); - } - - /** - * This will move a folder from one location to another. This method accepts the source folder's path - * and destination folder path in an array. - * - * @link https://docs.imagekit.io/api-reference/media-api/move-folder - * - * @param $parameter[$sourceFolderPath, $destinationPath] - * - * @return Response - */ - public function moveFolder($parameter=null) - { - if(!isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$MOVE_FOLDER_PARAMETER_MISSING)); - } - if(!is_array($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$MOVE_FOLDER_PARAMETER_NON_ARRAY)); - } - if(sizeof($parameter)==0){ - return Response::respond(true, ((object)ErrorMessages::$MOVE_FOLDER_PARAMETER_EMPTY_ARRAY)); - } - if (empty($parameter['sourceFolderPath']) || empty($parameter['destinationPath'])) { - return Response::respond(true, ((object)ErrorMessages::$MOVE_FOLDER_DATA_INVALID)); - } - - $this->httpClient->setUri(Endpoints::getMoveFolderEndpoint()); - return Manage\Folder::move($parameter['sourceFolderPath'], $parameter['destinationPath'], $this->httpClient); - } - - /** - * @param string $token - * @param int $expire - * @return object { token: string, expire: int, signature: string} - */ - public function getAuthenticationParameters($token = '', $expire = 0) - { - return Signature::getAuthenticationParameters($token, $expire, $this->configuration); - } - - /** - * This endpoint allows you to get the status of a bulk operation e.g. copy or move folder API. - * - * @link https://docs.imagekit.io/api-reference/media-api/copy-move-folder-status - * - * @param $jobId - * @return Response - */ - public function getBulkJobStatus($jobId=null) - { - - if (empty($jobId)) { - return Response::respond(true, ((object)ErrorMessages::$JOBID_MISSING)); - } - $this->httpClient->setUri(Endpoints::getBulkJobStatusEndpoint($jobId)); - - try { - $res = $this->httpClient->get(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * Get image exif, pHash and other metadata for uploaded files in ImageKit.io powered remote URL using this API. - * - * @link https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-from-remote-url - * - * @param $url - * @return Response - */ - public function getFileMetadataFromRemoteURL($url=null) - { - if (empty($url)) { - return Response::respond(true, ((object)ErrorMessages::$MISSING_URL_PARAMETER)); - } - - if (!filter_var($url, FILTER_VALIDATE_URL)) { - return Response::respond(true, ((object)ErrorMessages::$INVALID_URL_PARAMETER)); - } - - $this->httpClient->setUri(Endpoints::getFileMetadataFromRemoteURLEndpoint()); - return Manage\CustomMetadataFields::getFileMetadataFromRemoteURL($url, $this->httpClient); - } - /** - * Using pHash to find similar or duplicate images - * The hamming distance between two pHash values determines how similar or different the images are. - * - * The pHash value returned by ImageKit.io metadata API is a hexadecimal string of 64bit pHash. The distance - * between two hash can be between 0 and 64. A lower distance means similar images. If the distance is 0, - * that means two images are identical. - * - * @param string $firstPHash - * @param string $secondPHash - * @return int - */ - public function pHashDistance($firstPHash=null, $secondPHash=null) - { - if(!isset($firstPHash) || empty($firstPHash)){ - return Response::respond(true, ((object)ErrorMessages::$PHASH_DISTANCE_FIRST_PHASH_MISSING)); - } - if(!isset($secondPHash) || empty($secondPHash)){ - return Response::respond(true, ((object)ErrorMessages::$PHASH_DISTANCE_SECOND_PHASH_MISSING)); - } - return Phash::pHashDistance($firstPHash, $secondPHash); - } - - - /** - * Create custom metadata field using this API. - * - * @link https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field - * - * @param $parameter[$name,$label,$schema] - * @return Response - */ - public function createCustomMetadataField($parameter=null) - { - if(!isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$CREATE_CUSTOM_METADATA_PARAMETER_MISSING)); - } - if(!is_array($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$CREATE_CUSTOM_METADATA_PARAMETER_NON_ARRAY)); - } - if(sizeof($parameter)==0){ - return Response::respond(true, ((object)ErrorMessages::$CREATE_CUSTOM_METADATA_PARAMETER_EMPTY_ARRAY)); - } - if (empty($parameter['name']) || empty($parameter['label']) || !isset($parameter['schema'])) { - return Response::respond(true, ((object)ErrorMessages::$CREATE_CUSTOM_METADATA_DATA_INVALID)); - } - if(!isset($parameter['schema']['type']) || empty($parameter['schema']['type'])){ - return Response::respond(true, ((object)ErrorMessages::$CREATE_CUSTOM_METADATA_DATA_INVALID_SCHEMA_OBJECT)); - } - - $this->httpClient->setUri(Endpoints::createCustomMetadataField()); - return Manage\CustomMetadataFields::createCustomMetadataField($parameter['name'], $parameter['label'], $parameter['schema'], $this->httpClient); - } - - /** - * Get custom metadata field using this API. - * - * @link https://docs.imagekit.io/api-reference/custom-metadata-fields-api/get-custom-metadata-field - * - * @param $includeDeleted - * @return Response - */ - public function getCustomMetadataFields($includeDeleted=false) - { - if(!is_bool($includeDeleted)){ - return Response::respond(true, ((object)ErrorMessages::$GET_CUSTOM_METADATA_INVALID_PARAMETER)); - } - $this->httpClient->setUri(Endpoints::getCustomMetadataField()); - return Manage\CustomMetadataFields::getCustomMetadataField($includeDeleted, $this->httpClient); - } - - /** - * Update custom metadata field using this API. - * - * @link https://docs.imagekit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field - * - * @param $id - * @param $parameter[$name,$label,$schema] - * @return Response - */ - public function updateCustomMetadataField($id=null,$parameter=null) - { - if(!isset($id) && !isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$UPDATE_CUSTOM_METADATA_PARAMETER_MISSING)); - } - if(!isset($id) || empty($id)){ - return Response::respond(true, ((object)ErrorMessages::$UPDATE_CUSTOM_METADATA_ID_MISSING)); - } - if(!isset($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$UPDATE_CUSTOM_METADATA_BODY_MISSING)); - } - if(!is_array($parameter)){ - return Response::respond(true, ((object)ErrorMessages::$UPDATE_CUSTOM_METADATA_PARAMETER_NON_ARRAY)); - } - if(sizeof($parameter)==0){ - return Response::respond(true, ((object)ErrorMessages::$UPDATE_CUSTOM_METADATA_PARAMETER_EMPTY_ARRAY)); - } - if (empty($parameter['label']) || !isset($parameter['schema'])) { - return Response::respond(true, ((object)ErrorMessages::$UPDATE_CUSTOM_METADATA_DATA_INVALID)); - } - if(!isset($parameter['schema']['type']) || empty($parameter['schema']['type'])){ - return Response::respond(true, ((object)ErrorMessages::$UPDATE_CUSTOM_METADATA_DATA_INVALID_SCHEMA_OBJECT)); - } - - $this->httpClient->setUri(Endpoints::updateCustomMetadataField($id)); - return Manage\CustomMetadataFields::updateCustomMetadataField($parameter['label'], $parameter['schema'], $this->httpClient); - } - - /** - * Delete custom metadata field using this API. - * - * @link https://docs.imagekit.io/api-reference/custom-metadata-fields-api/delete-custom-metadata-field - * - * @param $id - * @return Response - */ - public function deleteCustomMetadataField($id=null) - { - if(!isset($id) || empty($id)){ - return Response::respond(true, ((object)ErrorMessages::$DELETE_CUSTOM_METADATA_ID_MISSING)); - } - - $this->httpClient->setUri(Endpoints::deleteCustomMetadataField($id)); - return Manage\CustomMetadataFields::deleteCustomMetadataField($this->httpClient); - } - -} diff --git a/src/ImageKit/Manage/Cache.php b/src/ImageKit/Manage/Cache.php deleted file mode 100644 index 16c4f0db..00000000 --- a/src/ImageKit/Manage/Cache.php +++ /dev/null @@ -1,89 +0,0 @@ - $urlParam - ]; - - $resource->setDatas($urlParamArray); - try { - $res = $resource->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * purgeCacheStatus File API - * - * @param $requestId - * @param GuzzleHttpWrapper $resource - * @return Response - */ - public static function purgeFileCacheStatus($requestId, GuzzleHttpWrapper $resource) - { - try { - $res = $resource->get(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - -} diff --git a/src/ImageKit/Manage/CustomMetadataFields.php b/src/ImageKit/Manage/CustomMetadataFields.php deleted file mode 100644 index 4770fd37..00000000 --- a/src/ImageKit/Manage/CustomMetadataFields.php +++ /dev/null @@ -1,242 +0,0 @@ -get(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Get file metadata from remote URL - * - * @param $url - * @param $resource - * @return Response - */ - public static function getFileMetadataFromRemoteURL($url, $resource) - { - if (empty($url)) { - return Response::respond(true, ((object)ErrorMessages::$MISSING_URL_PARAMETER)); - } - - $resource->setDatas([ - 'url' => $url - ]); - try { - $res = $resource->get(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Create custom metadata field - * - * @param $name - * @param $label - * @param $schema - * @param $resource - * @return Response - */ - public static function createCustomMetadataField($name, $label, $schema, $resource) - { - $resource->setDatas([ - 'name' => $name, - 'label' => $label, - 'schema' => $schema - ]); - try { - $res = $resource->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * Get custom metadata field - * - * @param $includeDeleted - * @param $resource - * @return Response - */ - public static function getCustomMetadataField($includeDeleted, $resource) - { - $resource->setDatas([ - 'includeDeleted' => $includeDeleted - ]); - - try { - $res = $resource->get(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, $content); - } - - return Response::respond(false, $content); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * Update custom metadata field - * - * @param $label - * @param $schema - * @param $resource - * @return Response - */ - public static function updateCustomMetadataField($label, $schema, $resource) - { - $resource->setDatas([ - 'label' => $label, - 'schema' => $schema - ]); - try { - $res = $resource->patch(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * Update custom metadata field - * - * @param $resource - * @return Response - */ - public static function deleteCustomMetadataField($resource) - { - try { - $res = $resource->delete(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } -} diff --git a/src/ImageKit/Manage/File.php b/src/ImageKit/Manage/File.php deleted file mode 100644 index 4995837d..00000000 --- a/src/ImageKit/Manage/File.php +++ /dev/null @@ -1,592 +0,0 @@ -setDatas($parameters); - } - try { - $res = $resource->get(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - - - } - - /** - * Get Details Of file - * - * @param string $fileId - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function getDetails($fileId, GuzzleHttpWrapper $resource) - { - try { - $res = $resource->get(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * Get Version Details Of file - * - * @param string $fileId - * @param string $versionId - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function getVersionDetails($fileId, $versionId, GuzzleHttpWrapper $resource) - { - try { - $res = $resource->get(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * Get All Versions Of file - * - * @param string $fileId - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function getFileVersions($fileId, GuzzleHttpWrapper $resource) - { - try { - $res = $resource->get(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Delete File API - * - * @param $fileId - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function delete($fileId, GuzzleHttpWrapper $resource) - { - - $resource->setDatas((array)$fileId); - try { - $res = $resource->delete(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Delete File Version API - * - * @param $fileId - * @param $versionId - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function deleteVersion($fileId, $versionId, GuzzleHttpWrapper $resource) - { - $resource->setDatas([$fileId,$versionId]); - try { - $res = $resource->delete(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * Delete Bulk Files by File ID API - * - * @param $fileIds - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function bulkDeleteByFileIds($fileIds, GuzzleHttpWrapper $resource) - { - $resource->setDatas(['fileIds' => $fileIds]); - - try { - $res = $resource->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Copy File API - * - * @param $sourceFilePath - * @param $destinationPath - * @param $includeVersions - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function copy($sourceFilePath, $destinationPath, $includeFileVersions, GuzzleHttpWrapper $resource) - { - $resource->setDatas(['sourceFilePath' => $sourceFilePath, 'destinationPath' => $destinationPath, 'includeFileVersions' => $includeFileVersions]); - try { - $res = $resource->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * Move File API - * - * @param $sourceFilePath - * @param $destinationPath - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function move($sourceFilePath, $destinationPath, GuzzleHttpWrapper $resource) - { - $resource->setDatas(['sourceFilePath' => $sourceFilePath, 'destinationPath' => $destinationPath]); - try { - $res = $resource->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Rename File API - * - * @param $filePath - * @param $newFileName - * @param $purgeCache - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function rename($filePath, $newFileName, $purgeCache, GuzzleHttpWrapper $resource) - { - $resource->setDatas(['filePath' => $filePath, 'newFileName' => $newFileName, 'purgeCache' => $purgeCache]); - try { - $res = $resource->put(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Restore File Version API - * - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function restoreVersion(GuzzleHttpWrapper $resource) - { - try { - $res = $resource->put(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Bulk Add Tags - * - * @param array $fileIds - * @param array $tags - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function bulkAddTags($fileIds, $tags, GuzzleHttpWrapper $resource) - { - - $resource->setDatas(['fileIds' => $fileIds, 'tags' => $tags]); - try { - $res = $resource->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * Bulk Remove Tags - * - * @param array $fileIds - * @param array $tags - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function bulkRemoveTags(array $fileIds, array $tags, GuzzleHttpWrapper $resource) - { - - - if (!is_array($fileIds) || empty($fileIds) || !is_array($tags) || empty($tags)) { - return Response::respond(true, ((object)ErrorMessages::$BULK_TAGS_DATA_MISSING)); - } - - $resource->setDatas(['fileIds' => $fileIds, 'tags' => $tags]); - try { - $res = $resource->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Bulk Remove AI Tags - * - * @param array $fileIds - * @param array $AITags - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function bulkRemoveAITags(array $fileIds, array $AITags, GuzzleHttpWrapper $resource) - { - $resource->setDatas(['fileIds' => $fileIds, 'AITags' => $AITags]); - try { - $res = $resource->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - - /** - * Update File Details - * - * @param $fileId - * @param $updateData - * @param GuzzleHttpWrapper $resource - * - * @return Response - */ - public static function updateDetails($fileId, $updateData, GuzzleHttpWrapper $resource) - { - $obj = (object)$updateData; - - if (isset($obj->tags) && ($obj->tags !== null) && ($obj->tags !== 'undefined') && !is_array($obj->tags)) { - return Response::respond(true, ((object)ErrorMessages::$UPDATE_DATA_TAGS_INVALID)); - } - - if (isset($obj->customCoordinates) && ($obj->customCoordinates !== 'undefined') && is_array($obj->customCoordinates)) { - return Response::respond(true, ((object)ErrorMessages::$UPDATE_DATA_COORDS_INVALID)); - } - - $resource->setDatas($updateData); - try { - $res = $resource->patch(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } -} diff --git a/src/ImageKit/Manage/Folder.php b/src/ImageKit/Manage/Folder.php deleted file mode 100644 index da840a81..00000000 --- a/src/ImageKit/Manage/Folder.php +++ /dev/null @@ -1,157 +0,0 @@ -setDatas(['parentFolderPath' => $parentFolderPath, 'folderName' => $folderName]); - try { - $res = $httpClient->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * @param $folderPath - * @param GuzzleHttpWrapper $httpClient - * - * @return Response - */ - public static function delete($folderPath, GuzzleHttpWrapper $httpClient) - { - if (empty($folderPath)) { - return Response::respond(true, ((object)ErrorMessages::$MISSING_DELETE_FOLDER_OPTIONS)); - } - - $httpClient->setDatas(['folderPath' => $folderPath]); - try { - $res = $httpClient->delete(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * @param $sourceFolderPath - * @param $destinationPath - * @param $includeVersions - * @param GuzzleHttpWrapper $httpClient - * - * @return Response - */ - public static function copy($sourceFolderPath, $destinationPath, $includeFileVersions, GuzzleHttpWrapper $httpClient) - { - $httpClient->setDatas(['sourceFolderPath' => $sourceFolderPath, 'destinationPath' => $destinationPath, 'includeFileVersions' => $includeFileVersions]); - try { - $res = $httpClient->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } - - /** - * @param $sourceFolderPath - * @param $destinationPath - * @param GuzzleHttpWrapper $httpClient - * - * @return Response - */ - public static function move($sourceFolderPath, $destinationPath, GuzzleHttpWrapper $httpClient) - { - $httpClient->setDatas(['sourceFolderPath' => $sourceFolderPath, 'destinationPath' => $destinationPath]); - try { - $res = $httpClient->post(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - } -} diff --git a/src/ImageKit/Phash/Phash.php b/src/ImageKit/Phash/Phash.php deleted file mode 100644 index 64052895..00000000 --- a/src/ImageKit/Phash/Phash.php +++ /dev/null @@ -1,52 +0,0 @@ -client = $client; - $this->serviceId = self::gen_uuid(); - } - - - - /** - * @return string - */ - public static function gen_uuid() - { - return sprintf( - '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', - // 32 bits for "time_low" - mt_rand(0, 0xffff), - mt_rand(0, 0xffff), - - // 16 bits for "time_mid" - mt_rand(0, 0xffff), - - // 16 bits for "time_hi_and_version", - // four most significant bits holds version number 4 - mt_rand(0, 0x0fff) | 0x4000, - - // 16 bits, 8 bits for "clk_seq_hi_res", - // 8 bits for "clk_seq_low", - // two most significant bits holds zero and one for variant DCE1.1 - mt_rand(0, 0x3fff) | 0x8000, - - // 48 bits for "node" - mt_rand(0, 0xffff), - mt_rand(0, 0xffff), - mt_rand(0, 0xffff) - ); - } - - /** - * @return array - */ - public function getDatas() - { - return $this->datas; - } - - /** - * @param array $datas - * @return void - */ - public function setDatas(array $datas) - { - $this->datas = array_filter($datas, function ($var) { - if ($var === '' || $var === null || is_array($var) && count($var) === 0) { - return false; - } - - return true; - }); - } - /** - * @param array $headers - * @return void - */ - public function setHeaders(array $headers) - { - $this->headers = $headers; - } - /** - * @return Response - */ - public function get() - { - try { - return $this->client->request('GET', $this->getUri(), $this->getOptions('query')); - } catch (RequestException $e) { - return $this->handleRequestException($e); - } catch (Exception $e) { - return $this->handleException($e); - } - } - - /** - * @return mixed - */ - protected function getUri() - { - return $this->uri; - } - - - /** - * @param $uri - */ - public function setUri($uri) - { - $this->uri = $uri; - } - - /** - * @param $dataType - * @return array - */ - protected function getOptions($dataType) - { - return [ - $dataType => $this->datas, - 'headers' => $this->headers, - ]; - } - - /** - * @param RequestException $e - * @return Response - */ - protected function handleRequestException(RequestException $e) - { - $status = $e->getCode(); - $headers = []; - $body = ''; - if ($e->hasResponse()) { - $body = (string)$e->getResponse()->getBody(); - $headers = $e->getResponse()->getHeaders(); - $statusCode = $e->getResponse()->getStatusCode(); - } - - return new Response($status, $headers, $body); - } - - /** - * @param Exception $e - * @return Response - */ - protected function handleException(Exception $e) - { - if(!$sock = @fsockopen('api.imagekit.io', 443)) - { - throw new Exception('Network Error'); - } - else - { - throw $e; - } - } - - /** - * @return Response - */ - public function delete() - { - try { - return $this->client->request('DELETE', $this->getUri(), $this->getOptions('json')); - } catch (RequestException $e) { - return $this->handleRequestException($e); - } catch (Exception $e) { - return $this->handleException($e); - } - } - - /** - * @return Response - */ - public function postMultipart() - { - try { - $options = [ - 'headers' => $this->headers, - 'multipart' => self::getMultipartData($this->datas) - ]; - - return $this->client->request('POST', $this->getUri(), $options); - } catch (RequestException $e) { - return $this->handleRequestException($e); - } catch (Exception $e) { - return $this->handleException($e); - } - } - - - /** - * @param $data - * @return array - */ - public static function getMultipartData($data) - { - $multipartData = []; - - foreach ($data as $key => $value) { - if (is_bool($value)) { - $data[$key] = json_encode($value); - } - } - - foreach ($data as $key => $value) { - if (!is_array($value)) { - $multipartData[] = ['name' => $key, 'contents' => $value]; - continue; - } - - foreach ($value as $multiKey => $multiValue) { - $multiName = $key . '[' . $multiKey . ']' . (is_array($multiValue) ? '[' . key($multiValue) . ']' : '') . ''; - $multipartData[] = ['name' => $multiName, 'contents' => (is_array($multiValue) ? reset($multiValue) : $multiValue)]; - } - } - - return $multipartData; - } - - /** - * @return Response - */ - public function post() - { - try { - $options = [ - 'headers' => $this->headers, - 'json' => $this->datas - ]; - - return $this->client->request('POST', $this->getUri(), $options); - } catch (RequestException $e) { - return $this->handleRequestException($e); - } catch (Exception $e) { - return $this->handleException($e); - } - } - - /** - * @return Response - */ - public function rawPost() - { - try { - $options = [ - 'body' => json_encode($this->datas), - 'headers' => ['Content-Type' => 'application/json'] - ]; - - return $this->client->request('POST', $this->getUri(), $options); - } catch (RequestException $e) { - return $this->handleRequestException($e); - } catch (Exception $e) { - return $this->handleException($e); - } - } - - /** - * @return Response - */ - public function patch() - { - try { - $options = [ - 'headers' => $this->headers, - 'json' => $this->datas - ]; - return $this->client->request('PATCH', $this->getUri(), $options); - } catch (RequestException $e) { - return $this->handleRequestException($e); - } catch (Exception $e) { - return $this->handleException($e); - } - } - - /** - * @return Response - */ - public function put() - { - try { - $options = [ - 'headers' => $this->headers, - 'json' => $this->datas - ]; - return $this->client->request('PUT', $this->getUri(), $options); - } catch (RequestException $e) { - return $this->handleRequestException($e); - } catch (Exception $e) { - return $this->handleException($e); - } - } - - -} diff --git a/src/ImageKit/Resource/HttpRequest.php b/src/ImageKit/Resource/HttpRequest.php deleted file mode 100644 index 63c72000..00000000 --- a/src/ImageKit/Resource/HttpRequest.php +++ /dev/null @@ -1,41 +0,0 @@ - isset($token) ? $token : '', - 'expire' => isset($expire) ? $expire : 0, - 'signature' => '' - ]; - - $obj = (object)($configuration); - - if (!empty($obj->privateKey) and !empty($defaultExpire)) { - - $tok = isset($token) && strlen($token) > 0 ? $token : GuzzleHttpWrapper::gen_uuid(); - $exp = isset($expire) && $expire > 0 ? $expire : $defaultExpire; - $data = $tok . $exp; - $signature = hash_hmac('sha1', $data, $obj->privateKey); - - $authParameters['token'] = $tok; - $authParameters['expire'] = $exp; - $authParameters['signature'] = $signature; - - } - - return (object)$authParameters; - - } - -} diff --git a/src/ImageKit/Upload/Upload.php b/src/ImageKit/Upload/Upload.php deleted file mode 100644 index 4f397d0b..00000000 --- a/src/ImageKit/Upload/Upload.php +++ /dev/null @@ -1,87 +0,0 @@ -file; - $fileName = $opts->fileName; - - $payload = []; - if (isset($opts->options) && is_array($opts->options)) { - $payload = $opts->options; - } - else{ - $payload = (array)$opts; - } - $payload['file'] = $file; - $payload['fileName'] = $fileName; - - if (isset($payload['tags']) && is_array($payload['tags'])) { - $payload['tags'] = implode(',', $payload['tags']); - } - - if (isset($payload['customCoordinates']) && is_array($payload['customCoordinates'])) { - $payload['customCoordinates'] = implode(',', $payload['customCoordinates']); - } - - if (isset($payload['responseFields']) && is_array($payload['responseFields'])) { - $payload['responseFields'] = implode(',', $payload['responseFields']); - } - - if (isset($payload['extensions']) && is_array($payload['extensions'])) { - $payload['extensions'] = json_encode($payload['extensions']); - } - - if (isset($payload['customMetadata']) && is_array($payload['customMetadata'])) { - $payload['customMetadata'] = json_encode($payload['customMetadata']); - } - - if (isset($payload['transformation'])) { - $payload['transformation'] = json_encode($payload['transformation']); - } - - $resource->setDatas((array)$payload); - try { - $res = $resource->postMultipart(); - } catch (\Throwable $th) { - return Response::respond(true, $th->getMessage()); - } - if($res && $res->getBody() && $res->getHeaders() && $res->getStatusCode()){ - $stream = $res->getBody(); - $content = []; - $content['body'] = json_decode($stream->getContents()); - $headers = $res->getHeaders(); - $content['headers'] = $headers; - $content['statusCode'] = (int)$res->getStatusCode(); - - if ($res->getStatusCode() && ($res->getStatusCode() < 200 || $res->getStatusCode() > 300)) { - return Response::respond(true, ($content)); - } - - return Response::respond(false, ($content)); - } - else{ - $errorObject = (object) ErrorMessages::$INVALID_REQUEST; - return Response::respond(true, $errorObject->message); - } - - - } -} diff --git a/src/ImageKit/Url/Url.php b/src/ImageKit/Url/Url.php deleted file mode 100644 index 4bc8a70a..00000000 --- a/src/ImageKit/Url/Url.php +++ /dev/null @@ -1,420 +0,0 @@ -removeTrailingSlash($obj->urlEndpoint); - $transformation = null; - $signed = false; - $expireSeconds = null; - - if (isset($obj->signed)) { - $signed = $obj->signed; - } - - if (isset($obj->expireSeconds)) { - $expireSeconds = $obj->expireSeconds; - } - - if (isset($obj->path)) { - $path = ltrim($obj->path, '/'); - $path = $this->addLeadingSlash($path); - } - - if (isset($obj->src)) { - $src = $obj->src; - } - - if (isset($obj->transformation)) { - $transformation = $obj->transformation; - } - - if ($path == null && $src == null) { - return ''; - } - - // Create Correct query parameter - $parsedHost = ''; - - if (!empty($path)) { - $parsedURL = [parse_url($path)]; - $parsedHost = [parse_url($urlEndpoint)]; - $isSrcParameterUsedForURL = false; - } else { - $parsedURL = [parse_url($src)]; - $isSrcParameterUsedForURL = true; - } - - //Initial URL Construction Object - $urlArray = [ - 'host' => '', - 'pathname' => '', - 'search' => [], - 'queryParameters' => [], - ]; - $urlObject = (object)($urlArray); - if (!empty($path)) { - $urlObject->scheme = $parsedHost[0]['scheme']; - $urlObject->host = $parsedHost[0]['host']; - if (isset($parsedHost[0]['path'])) { - $urlObject->pathname = $parsedHost[0]['path']; - } - } else { - $urlObject->scheme = $parsedURL[0]['scheme']; - $urlObject->host = $parsedURL[0]['host']; - $urlObject->pathname = $parsedURL[0]['path']; - } - if (isset($parsedURL[0]['query'])) { - parse_str($parsedURL[0]['query'], $urlObject->search); - } - if(isset($obj->transformationPosition)){ - if($obj->transformationPosition=='query'){ - if (isset($obj->queryParameters)) { - $urlObject->search = array_merge($urlObject->search, $obj->queryParameters); - } - } - else if($obj->transformationPosition=='path'){ - if (isset($obj->queryParameters)) { - $urlObject->queryParameters = $obj->queryParameters; - } - } - else{ - throw new \InvalidArgumentException(ErrorMessages::$URL_GENERATION_TRANSFORMATION_QUERY_INVALID['message']); - } - - } - else{ - if (isset($obj->queryParameters)) { - $urlObject->queryParameters = $obj->queryParameters; - } - } - - - ksort($urlObject->search); - - // Create Transformation String - $transformationString = $this->constructTransformationString($transformation); - if ($transformationString) { - if (Transformation::addAsQueryParameter($urlOptions) || $isSrcParameterUsedForURL) { - $transformationQueryParam = [self::TRANSFORMATION_PARAMETER => $transformationString]; - $urlObject->search = array_merge($transformationQueryParam, $urlObject->search); - } else { - $originalPath = $this->removeTrailingSlash($urlObject->pathname); - $transformationQuery = self::TRANSFORMATION_PARAMETER; - $transformationQuery .= Transformation::getChainTransformDelimiter(); - $transformationQuery .= $transformationString; - if (!$this->startsWithSlash($originalPath)) { - $urlObject->pathname .= '/'; - } - $urlObject->pathname = $originalPath; - $urlObject->pathname .= '/'; - $urlObject->pathname .= $transformationQuery; - } - } - $urlObject->pathname .= $this->addLeadingSlash($path); - $urlObject->host = $this->removeTrailingSlash($urlObject->host); - $urlObject->pathname = $this->addLeadingSlash($urlObject->pathname); - - // Build Search Params here - $urlObject->search = urldecode(http_build_query($urlObject->search)); - - // Build queryParameters here - $urlObject->queryParameters = urldecode(http_build_query($urlObject->queryParameters)); - - // transformationPosition - $urlObject->transformationPosition = $obj->transformationPosition; - // Signature String and Timestamp - // We can do this only for URLs that are created using urlEndpoint and path parameter - // because we need to know the endpoint to be able to remove it from the URL to create a signature - // for the remaining. With the src parameter, we would not know the "pattern" in the URL - if ($signed === true) { - $expiryTimestamp = $this->getSignatureTimestamp($expireSeconds); - $myArray = json_decode(json_encode($urlObject), true); - $intermediateURL = $this->unparsed_url($myArray); - $urlSignatureArray = [ - 'privateKey' => $urlOptions['privateKey'], - 'url' => $intermediateURL, - 'urlEndpoint' => $urlOptions['urlEndpoint'], - 'expiryTimestamp' => $expiryTimestamp, - ]; - - $urlSignature = $this->getSignature($urlSignatureArray); - if ($expiryTimestamp && $expiryTimestamp != self::DEFAULT_TIMESTAMP) { - $timestampParameter = [ - self::TIMESTAMP_PARAMETER => $expiryTimestamp - ]; - $timestampParameterString = http_build_query($timestampParameter); - $urlObject->timestampParameterString = $timestampParameterString; - } - $signatureParameter = [ - self::SIGNATURE_PARAMETER => $urlSignature - ]; - $signatureParameterString = http_build_query($signatureParameter); - - $urlObject->signatureParameterString = $signatureParameterString; - } - $urlObjectArray = json_decode(json_encode($urlObject), true); - - return $this->unparsed_url($urlObjectArray); - } - - /** - * @param $str - * @return false|mixed|string - */ - private function removeTrailingSlash($str) - { - if (is_string($str) and strlen($str) > 0 and substr($str, -1) == '/') { - $str = substr($str, 0, -1); - } - return $str; - } - - /** - * @param $str - * @return mixed|string - */ - private function addLeadingSlash($str) - { - if (is_string($str) and strlen($str) > 0 and $str[0] != '/') { - $str = '/' . $str; - } - return $str; - } - - /** - * @param $transformation - * @return string - */ - private function constructTransformationString($transformation) - { - if (!is_array($transformation)) { - return ''; - } - $parsedTransforms = []; - for ($i = 0; $i < count($transformation); $i++) { - $parsedTransformStep = []; - foreach ($transformation[$i] as $key => $value) { - if($key=='raw'){ - array_push($parsedTransformStep, $value); - } - else if($key!=''){ - $transform_block = $this->buildingTransformationBlocks($key,$value); - array_push($parsedTransformStep, $transform_block); - } - - } - $delimiter = Transformation::getTransformDelimiter(); - $List = implode($delimiter, $parsedTransformStep); - array_push($parsedTransforms, $List); - } - $setChainDelimiter = Transformation::getChainTransformDelimiter(); - return implode($setChainDelimiter, $parsedTransforms); - } - - /** - * @param $key - * @param $value - * @return array - */ - private function buildingTransformationBlocks($key, $value){ - if (is_bool($value)) { - $value = $value ? 'true' : 'false'; - } - - $value = (string)$value; - $transformKey = Transformation::getTransformKey($key); - if (empty($transformKey)) { - return []; - } - if ((empty($value) && $value !== '0') || $value === '-') { - return $transformKey; - } else { - $transformationUtils = Transformation::getTransformKeyValueDelimiter(); - $finalTransformation = $transformKey . $transformationUtils; - if (strpos($value, '/') !== false) { - $finalTransformation .= str_replace('/', '@@', rtrim(ltrim($value, '/'), '/')); - } else { - $finalTransformation .= $value; - } - - return $finalTransformation; - } - } - - /** - * @param $string - * @return bool - */ - private function startsWithSlash($string) - { - $len = strlen('/'); - return (substr($string, 0, $len) === '/'); - } - - /** - * @param $expireSeconds - * @return string - */ - private function getSignatureTimestamp($expireSeconds) - { - if (empty($expireSeconds)) { - return self::DEFAULT_TIMESTAMP; - } - $sec = intval($expireSeconds); - if (empty($sec)) { - return self::DEFAULT_TIMESTAMP; - } - $currentTimestamp = time(); - return (string)($currentTimestamp + $sec); - } - - /** - * @param array $parsed - * @return string - */ - public function unparsed_url(array $parsed) - { - - $get = function ($key) use ($parsed) { - return isset($parsed[$key]) ? $parsed[$key] : null; - }; - $scheme = $get('scheme'); - $host = $get('host'); - - $pathname = $get('pathname'); - $last_slash_index = strripos($pathname,'/'); - $file_name = substr($pathname,$last_slash_index+1); - $pathname = str_replace('/'.$file_name,'',$pathname); - $pathname = $pathname.'/'; - $search = $get('search'); - $queryParameters = $get('queryParameters'); - $transformationPosition = $get('transformationPosition'); - - $signatureParameterString = $get('signatureParameterString'); - - $timestampParameterString = $get('timestampParameterString'); - - if($transformationPosition=='query'){ - return (strlen($scheme) > 0 ? "$scheme:" : '') . - (strlen($host) > 0 ? "//$host" : '') . - (strlen($pathname) > 0 ? "$pathname" : '') . - $file_name . - (strlen($search) > 0 ? '?' .$search : '') . - (strlen($timestampParameterString) > 0 ? ((strlen($search)?'&':'?') . $timestampParameterString): '') . - (strlen($signatureParameterString) > 0 ? ('&' . $signatureParameterString): ''); - } - else{ - - return (strlen($scheme) > 0 ? "$scheme:" : '') . - (strlen($host) > 0 ? "//$host" : '') . - (strlen($pathname) > 0 ? "$pathname" : '') . - (strlen($search) > 0 ? str_replace('=',':',$search).'/' : '') . - $file_name . - (strlen($queryParameters) > 0 ? ( '?' . $queryParameters): '') . - ((!empty($timestampParameterString) && strlen($timestampParameterString) > 0) ? (((!empty($queryParameters) && strlen($queryParameters)>0)?'&':'?') . $timestampParameterString): '') . - ((!empty($signatureParameterString) && strlen($signatureParameterString) > 0) ? (((!empty($queryParameters) && strlen($queryParameters)>0)?'&': - ((!empty($timestampParameterString) && strlen($timestampParameterString) > 0)?'&':'?') - ) . $signatureParameterString): ''); - - } - } - - /** - * @param $options - * @return false|string - */ - public function getSignature($options) - { - if (empty($options['privateKey']) or empty($options['url']) or empty($options['urlEndpoint'])) { - return ''; - } else { - $data = (str_replace($this->addTrailingSlash($options['urlEndpoint']), '', $options['url']) . $options['expiryTimestamp']); - $data = $this->encodeStringIfRequired($data); - return hash_hmac('sha1', $data, $options['privateKey']); - } - } - - /** - * @param $str - * @return string - */ - private function addTrailingSlash($str) - { - if (is_string($str) and strlen($str) > 0 and substr($str, -1) != '/') { - $str = $str . '/'; - } - return $str; - } - - // Used to check if special char is present in string (you'll need to encode it to utf-8 if it does) - private function hasMoreThanAscii($str) - { - $chars = str_split($str); - foreach ($chars as $char) { - if (ord($char) > 127) { - return true; - } - } - return false; - } - - function encodeURI($str) - { - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI - $encoded_str = rawurlencode($str); - $encoded_str = - str_replace( - array('%21', '%2A', '%27', '%28', '%29', '%3B', '%2F', '%3F', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%23'), - array('!', '*', "'", '(', ')', ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '#'), - $encoded_str - ); - return $encoded_str; - } - - function custom_encodeURIComponent($url_str) { - $parsed_url = parse_url($url_str); - $encoded_url = ""; - if (isset($parsed_url['query'])) { - $encoded_url .= $this->encodeURI(explode("?", $url_str)[0]).'?' . $this->encodeURI($parsed_url['query']); - } - else - $encoded_url = $this->encodeURI($url_str); - return $encoded_url; - } - - /** - * @param $str - * @return string - */ - public function encodeStringIfRequired($str) - { - return $this->hasMoreThanAscii($str) ? $this->custom_encodeURIComponent($str) : $str; - } -} \ No newline at end of file diff --git a/src/ImageKit/Utils/Authorization.php b/src/ImageKit/Utils/Authorization.php deleted file mode 100644 index e3cfe832..00000000 --- a/src/ImageKit/Utils/Authorization.php +++ /dev/null @@ -1,26 +0,0 @@ - [ - $configuration->privateKey, '' - ], - 'handler'=>$handlerStack - ]; - } -} - diff --git a/src/ImageKit/Utils/Response.php b/src/ImageKit/Utils/Response.php deleted file mode 100644 index 1ecb73db..00000000 --- a/src/ImageKit/Utils/Response.php +++ /dev/null @@ -1,71 +0,0 @@ -null, - 'raw'=>null, - 'statusCode'=>null - ]; - - /** - * @param $isError - * @param $response - * @return Response - */ - public static function respond($isError, $response) - { - $responseObject = new Response(); - if($response && is_array($response)){ - if ($isError) { - $responseObject->error = $response['body']; - } else { - $responseObject->result = $response['body']; - } - $headers = []; - foreach ($response['headers'] as $key => $value) { - if(is_array($value)){ - $headers[$key] = implode(',',$value); - } - else{ - $headers[$key] = $value; - } - } - - $responseObject->responseMetadata['headers'] = $headers; - $responseObject->responseMetadata['raw'] = $response['body']; - $responseObject->responseMetadata['statusCode'] = $response['statusCode']; - - } - else{ - $responseObject->error = $response; - $responseObject->responseMetadata = null; - } - - return $responseObject; - } -} diff --git a/src/ImageKit/Utils/Transformation.php b/src/ImageKit/Utils/Transformation.php deleted file mode 100644 index 3d6a6c3e..00000000 --- a/src/ImageKit/Utils/Transformation.php +++ /dev/null @@ -1,72 +0,0 @@ -transformationPosition)) { - return $optionsObject->transformationPosition === self::QUERY_TRANSFORMATION_POSITION; - } - return false; - } - -} diff --git a/src/ImageOverlay.php b/src/ImageOverlay.php new file mode 100644 index 00000000..959e33bd --- /dev/null +++ b/src/ImageOverlay.php @@ -0,0 +1,234 @@ +, + * position?: null|OverlayPosition|OverlayPositionShape, + * timing?: null|OverlayTiming|OverlayTimingShape, + * input: string, + * type: 'image', + * encoding?: null|Encoding|value-of, + * transformation?: list|null, + * } + */ +final class ImageOverlay implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var 'image' $type */ + #[Required] + public string $type = 'image'; + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @var value-of|null $layerMode + */ + #[Optional(enum: LayerMode::class)] + public ?string $layerMode; + + #[Optional] + public ?OverlayPosition $position; + + #[Optional] + public ?OverlayTiming $timing; + + /** + * Specifies the relative path to the image used as an overlay. + */ + #[Required] + public string $input; + + /** + * The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + * By default, the SDK determines the appropriate format automatically. + * To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. + * + * @var value-of|null $encoding + */ + #[Optional(enum: Encoding::class)] + public ?string $encoding; + + /** + * Array of transformations to be applied to the overlay image. Supported transformations depends on the base/parent asset. + * See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) and [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + * + * @var list|null $transformation + */ + #[Optional(list: Transformation::class)] + public ?array $transformation; + + /** + * `new ImageOverlay()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ImageOverlay::with(input: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ImageOverlay)->withInput(...) + * ``` + */ + 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 LayerMode|value-of|null $layerMode + * @param OverlayPosition|OverlayPositionShape|null $position + * @param OverlayTiming|OverlayTimingShape|null $timing + * @param Encoding|value-of|null $encoding + * @param list|null $transformation + */ + public static function with( + string $input, + LayerMode|string|null $layerMode = null, + OverlayPosition|array|null $position = null, + OverlayTiming|array|null $timing = null, + Encoding|string|null $encoding = null, + ?array $transformation = null, + ): self { + $self = new self; + + $self['input'] = $input; + + null !== $layerMode && $self['layerMode'] = $layerMode; + null !== $position && $self['position'] = $position; + null !== $timing && $self['timing'] = $timing; + null !== $encoding && $self['encoding'] = $encoding; + null !== $transformation && $self['transformation'] = $transformation; + + return $self; + } + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @param LayerMode|value-of $layerMode + */ + public function withLayerMode(LayerMode|string $layerMode): self + { + $self = clone $this; + $self['layerMode'] = $layerMode; + + return $self; + } + + /** + * @param OverlayPosition|OverlayPositionShape $position + */ + public function withPosition(OverlayPosition|array $position): self + { + $self = clone $this; + $self['position'] = $position; + + return $self; + } + + /** + * @param OverlayTiming|OverlayTimingShape $timing + */ + public function withTiming(OverlayTiming|array $timing): self + { + $self = clone $this; + $self['timing'] = $timing; + + return $self; + } + + /** + * Specifies the relative path to the image used as an overlay. + */ + public function withInput(string $input): self + { + $self = clone $this; + $self['input'] = $input; + + return $self; + } + + /** + * @param 'image' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + * By default, the SDK determines the appropriate format automatically. + * To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. + * + * @param Encoding|value-of $encoding + */ + public function withEncoding(Encoding|string $encoding): self + { + $self = clone $this; + $self['encoding'] = $encoding; + + return $self; + } + + /** + * Array of transformations to be applied to the overlay image. Supported transformations depends on the base/parent asset. + * See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) and [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + * + * @param list $transformation + */ + public function withTransformation(array $transformation): self + { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } +} diff --git a/src/ImageOverlay/Encoding.php b/src/ImageOverlay/Encoding.php new file mode 100644 index 00000000..9dba58a7 --- /dev/null +++ b/src/ImageOverlay/Encoding.php @@ -0,0 +1,24 @@ +|array + */ + public static function variants(): array + { + return [ + 'text' => TextOverlay::class, + 'image' => ImageOverlay::class, + 'video' => VideoOverlay::class, + 'subtitle' => SubtitleOverlay::class, + 'solidColor' => SolidColorOverlay::class, + ]; + } +} diff --git a/src/OverlayPosition.php b/src/OverlayPosition.php new file mode 100644 index 00000000..b3e88c24 --- /dev/null +++ b/src/OverlayPosition.php @@ -0,0 +1,237 @@ +, + * focus?: null|Focus|value-of, + * x?: XShape|null, + * xCenter?: XCenterShape|null, + * y?: YShape|null, + * yCenter?: YCenterShape|null, + * } + */ +final class OverlayPosition implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Sets the anchor point on the base asset from which the overlay offset is calculated. + * The default value is `top_left`. + * Maps to `lap` in the URL. + * Can only be used with one or more of `x`, `y`, `xCenter`, or `yCenter`. + * + * @var value-of|null $anchorPoint + */ + #[Optional(enum: AnchorPoint::class)] + public ?string $anchorPoint; + + /** + * Specifies the position of the overlay relative to the parent image or video. + * If one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is ignored. + * Maps to `lfo` in the URL. + * + * @var value-of|null $focus + */ + #[Optional(enum: Focus::class)] + public ?string $focus; + + /** + * Specifies the x-coordinate of the top-left corner of the base asset where the overlay's top-left corner will be positioned. + * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. + * Maps to `lx` in the URL. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @var XVariants|null $x + */ + #[Optional] + public float|string|null $x; + + /** + * Specifies the x-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. + * Maps to `lxc` in the URL. + * Cannot be used together with `x`, but can be used with `y`. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @var XCenterVariants|null $xCenter + */ + #[Optional] + public float|string|null $xCenter; + + /** + * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's top-left corner will be positioned. + * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. + * Maps to `ly` in the URL. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @var YVariants|null $y + */ + #[Optional] + public float|string|null $y; + + /** + * Specifies the y-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. + * Maps to `lyc` in the URL. + * Cannot be used together with `y`, but can be used with `x`. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @var YCenterVariants|null $yCenter + */ + #[Optional] + public float|string|null $yCenter; + + 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 AnchorPoint|value-of|null $anchorPoint + * @param Focus|value-of|null $focus + * @param XShape|null $x + * @param XCenterShape|null $xCenter + * @param YShape|null $y + * @param YCenterShape|null $yCenter + */ + public static function with( + AnchorPoint|string|null $anchorPoint = null, + Focus|string|null $focus = null, + float|string|null $x = null, + float|string|null $xCenter = null, + float|string|null $y = null, + float|string|null $yCenter = null, + ): self { + $self = new self; + + null !== $anchorPoint && $self['anchorPoint'] = $anchorPoint; + null !== $focus && $self['focus'] = $focus; + null !== $x && $self['x'] = $x; + null !== $xCenter && $self['xCenter'] = $xCenter; + null !== $y && $self['y'] = $y; + null !== $yCenter && $self['yCenter'] = $yCenter; + + return $self; + } + + /** + * Sets the anchor point on the base asset from which the overlay offset is calculated. + * The default value is `top_left`. + * Maps to `lap` in the URL. + * Can only be used with one or more of `x`, `y`, `xCenter`, or `yCenter`. + * + * @param AnchorPoint|value-of $anchorPoint + */ + public function withAnchorPoint(AnchorPoint|string $anchorPoint): self + { + $self = clone $this; + $self['anchorPoint'] = $anchorPoint; + + return $self; + } + + /** + * Specifies the position of the overlay relative to the parent image or video. + * If one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is ignored. + * Maps to `lfo` in the URL. + * + * @param Focus|value-of $focus + */ + public function withFocus(Focus|string $focus): self + { + $self = clone $this; + $self['focus'] = $focus; + + return $self; + } + + /** + * Specifies the x-coordinate of the top-left corner of the base asset where the overlay's top-left corner will be positioned. + * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. + * Maps to `lx` in the URL. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @param XShape $x + */ + public function withX(float|string $x): self + { + $self = clone $this; + $self['x'] = $x; + + return $self; + } + + /** + * Specifies the x-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. + * Maps to `lxc` in the URL. + * Cannot be used together with `x`, but can be used with `y`. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @param XCenterShape $xCenter + */ + public function withXCenter(float|string $xCenter): self + { + $self = clone $this; + $self['xCenter'] = $xCenter; + + return $self; + } + + /** + * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's top-left corner will be positioned. + * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. + * Maps to `ly` in the URL. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @param YShape $y + */ + public function withY(float|string $y): self + { + $self = clone $this; + $self['y'] = $y; + + return $self; + } + + /** + * Specifies the y-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. + * Maps to `lyc` in the URL. + * Cannot be used together with `y`, but can be used with `x`. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @param YCenterShape $yCenter + */ + public function withYCenter(float|string $yCenter): self + { + $self = clone $this; + $self['yCenter'] = $yCenter; + + return $self; + } +} diff --git a/src/OverlayPosition/AnchorPoint.php b/src/OverlayPosition/AnchorPoint.php new file mode 100644 index 00000000..54b11ef2 --- /dev/null +++ b/src/OverlayPosition/AnchorPoint.php @@ -0,0 +1,32 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/OverlayPosition/XCenter.php b/src/OverlayPosition/XCenter.php new file mode 100644 index 00000000..8269ae11 --- /dev/null +++ b/src/OverlayPosition/XCenter.php @@ -0,0 +1,32 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/OverlayPosition/Y.php b/src/OverlayPosition/Y.php new file mode 100644 index 00000000..6147c122 --- /dev/null +++ b/src/OverlayPosition/Y.php @@ -0,0 +1,31 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/OverlayPosition/YCenter.php b/src/OverlayPosition/YCenter.php new file mode 100644 index 00000000..7266a870 --- /dev/null +++ b/src/OverlayPosition/YCenter.php @@ -0,0 +1,32 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/OverlayTiming.php b/src/OverlayTiming.php new file mode 100644 index 00000000..ae7fcdb4 --- /dev/null +++ b/src/OverlayTiming.php @@ -0,0 +1,138 @@ + */ + use SdkModel; + + /** + * Specifies the duration (in seconds) during which the overlay should appear on the base video. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + * Applies only if the base asset is a video. + * Maps to `ldu` in the URL. + * + * @var DurationVariants|null $duration + */ + #[Optional] + public float|string|null $duration; + + /** + * Specifies the end time (in seconds) for when the overlay should disappear from the base video. + * If both end and duration are provided, duration is ignored. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + * Applies only if the base asset is a video. + * Maps to `leo` in the URL. + * + * @var EndVariants|null $end + */ + #[Optional] + public float|string|null $end; + + /** + * Specifies the start time (in seconds) for when the overlay should appear on the base video. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + * Applies only if the base asset is a video. + * Maps to `lso` in the URL. + * + * @var StartVariants|null $start + */ + #[Optional] + public float|string|null $start; + + 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 DurationShape|null $duration + * @param EndShape|null $end + * @param StartShape|null $start + */ + public static function with( + float|string|null $duration = null, + float|string|null $end = null, + float|string|null $start = null, + ): self { + $self = new self; + + null !== $duration && $self['duration'] = $duration; + null !== $end && $self['end'] = $end; + null !== $start && $self['start'] = $start; + + return $self; + } + + /** + * Specifies the duration (in seconds) during which the overlay should appear on the base video. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + * Applies only if the base asset is a video. + * Maps to `ldu` in the URL. + * + * @param DurationShape $duration + */ + public function withDuration(float|string $duration): self + { + $self = clone $this; + $self['duration'] = $duration; + + return $self; + } + + /** + * Specifies the end time (in seconds) for when the overlay should disappear from the base video. + * If both end and duration are provided, duration is ignored. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + * Applies only if the base asset is a video. + * Maps to `leo` in the URL. + * + * @param EndShape $end + */ + public function withEnd(float|string $end): self + { + $self = clone $this; + $self['end'] = $end; + + return $self; + } + + /** + * Specifies the start time (in seconds) for when the overlay should appear on the base video. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. + * Applies only if the base asset is a video. + * Maps to `lso` in the URL. + * + * @param StartShape $start + */ + public function withStart(float|string $start): self + { + $self = clone $this; + $self['start'] = $start; + + return $self; + } +} diff --git a/src/OverlayTiming/Duration.php b/src/OverlayTiming/Duration.php new file mode 100644 index 00000000..49e167ff --- /dev/null +++ b/src/OverlayTiming/Duration.php @@ -0,0 +1,31 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/OverlayTiming/End.php b/src/OverlayTiming/End.php new file mode 100644 index 00000000..1a3cd453 --- /dev/null +++ b/src/OverlayTiming/End.php @@ -0,0 +1,32 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/OverlayTiming/Start.php b/src/OverlayTiming/Start.php new file mode 100644 index 00000000..099c5969 --- /dev/null +++ b/src/OverlayTiming/Start.php @@ -0,0 +1,31 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/RequestOptions.php b/src/RequestOptions.php new file mode 100644 index 00000000..07135340 --- /dev/null +++ b/src/RequestOptions.php @@ -0,0 +1,236 @@ +>|null, + * extraQueryParams?: array|null, + * extraBodyParams?: mixed, + * transporter?: ClientInterface|null, + * streamingTransporter?: ClientInterface|null, + * uriFactory?: UriFactoryInterface|null, + * streamFactory?: StreamFactoryInterface|null, + * requestFactory?: RequestFactoryInterface|null, + * } + * @phpstan-type RequestOpts = null|RequestOptions|RequestOptionShape + */ +final class RequestOptions implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + #[Property] + public float $timeout = 60; + + #[Property] + public int $maxRetries = 2; + + #[Property] + public float $initialRetryDelay = 0.5; + + #[Property] + public float $maxRetryDelay = 8.0; + + /** @var array|null>|null $extraHeaders */ + #[Optional] + public ?array $extraHeaders; + + /** @var array|null $extraQueryParams */ + #[Optional] + public ?array $extraQueryParams; + + #[Optional] + public mixed $extraBodyParams; + + #[Optional] + public ?ClientInterface $transporter; + + #[Optional] + public ?ClientInterface $streamingTransporter; + + #[Optional] + public ?UriFactoryInterface $uriFactory; + + #[Optional] + public ?StreamFactoryInterface $streamFactory; + + #[Optional] + public ?RequestFactoryInterface $requestFactory; + + public function __construct() + { + $this->initialize(); + } + + /** + * @param RequestOpts|null $options + */ + public static function parse(RequestOptions|array|null ...$options): self + { + $parsed = array_map(static fn ($o) => $o instanceof self ? $o->toProperties() : $o ?? [], array: $options); + + // @phpstan-ignore-next-line argument.type + return self::with(...array_merge(...$parsed)); + } + + /** + * @param array|null>|null $extraHeaders + * @param array|null $extraQueryParams + */ + public static function with( + ?float $timeout = null, + ?int $maxRetries = null, + ?float $initialRetryDelay = null, + ?float $maxRetryDelay = null, + ?array $extraHeaders = null, + ?array $extraQueryParams = null, + mixed $extraBodyParams = null, + ?ClientInterface $transporter = null, + ?ClientInterface $streamingTransporter = null, + ?UriFactoryInterface $uriFactory = null, + ?StreamFactoryInterface $streamFactory = null, + ?RequestFactoryInterface $requestFactory = null, + ): self { + $self = new self; + + null !== $timeout && $self->timeout = $timeout; + null !== $maxRetries && $self->maxRetries = $maxRetries; + null !== $initialRetryDelay && $self + ->initialRetryDelay = $initialRetryDelay + ; + null !== $maxRetryDelay && $self->maxRetryDelay = $maxRetryDelay; + null !== $extraHeaders && $self->extraHeaders = $extraHeaders; + null !== $extraQueryParams && $self->extraQueryParams = $extraQueryParams; + null !== $extraBodyParams && $self->extraBodyParams = $extraBodyParams; + null !== $transporter && $self->transporter = $transporter; + null !== $streamingTransporter && $self + ->streamingTransporter = $streamingTransporter + ; + null !== $uriFactory && $self->uriFactory = $uriFactory; + null !== $streamFactory && $self->streamFactory = $streamFactory; + null !== $requestFactory && $self->requestFactory = $requestFactory; + + return $self; + } + + public function withTimeout(float $timeout): self + { + $self = clone $this; + $self->timeout = $timeout; + + return $self; + } + + public function withMaxRetries(int $maxRetries): self + { + $self = clone $this; + $self->maxRetries = $maxRetries; + + return $self; + } + + public function withInitialRetryDelay(float $initialRetryDelay): self + { + $self = clone $this; + $self->initialRetryDelay = $initialRetryDelay; + + return $self; + } + + public function withMaxRetryDelay(float $maxRetryDelay): self + { + $self = clone $this; + $self->maxRetryDelay = $maxRetryDelay; + + return $self; + } + + /** + * @param array|null> $extraHeaders + */ + public function withExtraHeaders(array $extraHeaders): self + { + $self = clone $this; + $self->extraHeaders = $extraHeaders; + + return $self; + } + + /** + * @param array $extraQueryParams + */ + public function withExtraQueryParams(array $extraQueryParams): self + { + $self = clone $this; + $self->extraQueryParams = $extraQueryParams; + + return $self; + } + + public function withExtraBodyParams(mixed $extraBodyParams): self + { + $self = clone $this; + $self->extraBodyParams = $extraBodyParams; + + return $self; + } + + public function withTransporter(ClientInterface $transporter): self + { + $self = clone $this; + $self->transporter = $transporter; + + return $self; + } + + public function withStreamingTransporter( + ClientInterface $streamingTransporter + ): self { + $self = clone $this; + $self->streamingTransporter = $streamingTransporter; + + return $self; + } + + public function withUriFactory(UriFactoryInterface $uriFactory): self + { + $self = clone $this; + $self->uriFactory = $uriFactory; + + return $self; + } + + public function withStreamFactory( + StreamFactoryInterface $streamFactory + ): self { + $self = clone $this; + $self->streamFactory = $streamFactory; + + return $self; + } + + public function withRequestFactory( + RequestFactoryInterface $requestFactory + ): self { + $self = clone $this; + $self->requestFactory = $requestFactory; + + return $self; + } +} diff --git a/src/ResponsiveImageAttributes.php b/src/ResponsiveImageAttributes.php new file mode 100644 index 00000000..3d7c6912 --- /dev/null +++ b/src/ResponsiveImageAttributes.php @@ -0,0 +1,137 @@ +` element. + * Useful for enabling responsive image loading with `srcSet` and `sizes`. + * + * @phpstan-type ResponsiveImageAttributesShape = array{ + * src: string, sizes?: string|null, srcSet?: string|null, width?: float|null + * } + */ +final class ResponsiveImageAttributes implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * URL for the *largest* candidate (assigned to plain `src`). + */ + #[Required] + public string $src; + + /** + * `sizes` returned (or synthesised as `100vw`). + * The value for the HTML `sizes` attribute. + */ + #[Optional] + public ?string $sizes; + + /** + * Candidate set with `w` or `x` descriptors. + * Multiple image URLs separated by commas, each with a descriptor. + */ + #[Optional] + public ?string $srcSet; + + /** + * Width as a number (if `width` was provided in the input options). + */ + #[Optional] + public ?float $width; + + /** + * `new ResponsiveImageAttributes()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ResponsiveImageAttributes::with(src: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ResponsiveImageAttributes)->withSrc(...) + * ``` + */ + 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( + string $src, + ?string $sizes = null, + ?string $srcSet = null, + ?float $width = null, + ): self { + $self = new self; + + $self['src'] = $src; + + null !== $sizes && $self['sizes'] = $sizes; + null !== $srcSet && $self['srcSet'] = $srcSet; + null !== $width && $self['width'] = $width; + + return $self; + } + + /** + * URL for the *largest* candidate (assigned to plain `src`). + */ + public function withSrc(string $src): self + { + $self = clone $this; + $self['src'] = $src; + + return $self; + } + + /** + * `sizes` returned (or synthesised as `100vw`). + * The value for the HTML `sizes` attribute. + */ + public function withSizes(string $sizes): self + { + $self = clone $this; + $self['sizes'] = $sizes; + + return $self; + } + + /** + * Candidate set with `w` or `x` descriptors. + * Multiple image URLs separated by commas, each with a descriptor. + */ + public function withSrcSet(string $srcSet): self + { + $self = clone $this; + $self['srcSet'] = $srcSet; + + return $self; + } + + /** + * Width as a number (if `width` was provided in the input options). + */ + public function withWidth(float $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/SavedExtension.php b/src/SavedExtension.php new file mode 100644 index 00000000..f38114b1 --- /dev/null +++ b/src/SavedExtension.php @@ -0,0 +1,173 @@ + */ + use SdkModel; + + /** + * Unique identifier of the saved extension. + */ + #[Optional] + public ?string $id; + + /** + * Configuration object for an extension (base extensions only, not saved extension references). + * + * @var ExtensionConfigVariants|null $config + */ + #[Optional(union: ExtensionConfig::class)] + public RemovedotBgExtension|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension|null $config; + + /** + * Timestamp when the saved extension was created. + */ + #[Optional] + public ?\DateTimeInterface $createdAt; + + /** + * Description of the saved extension. + */ + #[Optional] + public ?string $description; + + /** + * Name of the saved extension. + */ + #[Optional] + public ?string $name; + + /** + * Timestamp when the saved extension was last updated. + */ + #[Optional] + public ?\DateTimeInterface $updatedAt; + + 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 ExtensionConfigShape|null $config + */ + public static function with( + ?string $id = null, + RemovedotBgExtension|array|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension|null $config = null, + ?\DateTimeInterface $createdAt = null, + ?string $description = null, + ?string $name = null, + ?\DateTimeInterface $updatedAt = null, + ): self { + $self = new self; + + null !== $id && $self['id'] = $id; + null !== $config && $self['config'] = $config; + null !== $createdAt && $self['createdAt'] = $createdAt; + null !== $description && $self['description'] = $description; + null !== $name && $self['name'] = $name; + null !== $updatedAt && $self['updatedAt'] = $updatedAt; + + return $self; + } + + /** + * Unique identifier of the saved extension. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Configuration object for an extension (base extensions only, not saved extension references). + * + * @param ExtensionConfigShape $config + */ + public function withConfig( + RemovedotBgExtension|array|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension $config, + ): self { + $self = clone $this; + $self['config'] = $config; + + return $self; + } + + /** + * Timestamp when the saved extension was created. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * Description of the saved extension. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Name of the saved extension. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Timestamp when the saved extension was last updated. + */ + public function withUpdatedAt(\DateTimeInterface $updatedAt): self + { + $self = clone $this; + $self['updatedAt'] = $updatedAt; + + return $self; + } +} diff --git a/src/SavedExtensions/SavedExtensionCreateParams.php b/src/SavedExtensions/SavedExtensionCreateParams.php new file mode 100644 index 00000000..c7a2b0e8 --- /dev/null +++ b/src/SavedExtensions/SavedExtensionCreateParams.php @@ -0,0 +1,136 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Configuration object for an extension (base extensions only, not saved extension references). + * + * @var ExtensionConfigVariants $config + */ + #[Required(union: ExtensionConfig::class)] + public RemovedotBgExtension|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension $config; + + /** + * Description of what the saved extension does. + */ + #[Required] + public string $description; + + /** + * Name of the saved extension. + */ + #[Required] + public string $name; + + /** + * `new SavedExtensionCreateParams()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SavedExtensionCreateParams::with(config: ..., description: ..., name: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SavedExtensionCreateParams) + * ->withConfig(...) + * ->withDescription(...) + * ->withName(...) + * ``` + */ + 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 ExtensionConfigShape $config + */ + public static function with( + RemovedotBgExtension|array|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension $config, + string $description, + string $name, + ): self { + $self = new self; + + $self['config'] = $config; + $self['description'] = $description; + $self['name'] = $name; + + return $self; + } + + /** + * Configuration object for an extension (base extensions only, not saved extension references). + * + * @param ExtensionConfigShape $config + */ + public function withConfig( + RemovedotBgExtension|array|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension $config, + ): self { + $self = clone $this; + $self['config'] = $config; + + return $self; + } + + /** + * Description of what the saved extension does. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Name of the saved extension. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/SavedExtensions/SavedExtensionUpdateParams.php b/src/SavedExtensions/SavedExtensionUpdateParams.php new file mode 100644 index 00000000..2107a7f5 --- /dev/null +++ b/src/SavedExtensions/SavedExtensionUpdateParams.php @@ -0,0 +1,118 @@ + */ + use SdkModel; + use SdkParams; + + /** + * Configuration object for an extension (base extensions only, not saved extension references). + * + * @var ExtensionConfigVariants|null $config + */ + #[Optional(union: ExtensionConfig::class)] + public RemovedotBgExtension|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension|null $config; + + /** + * Updated description of the saved extension. + */ + #[Optional] + public ?string $description; + + /** + * Updated name of the saved extension. + */ + #[Optional] + public ?string $name; + + 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 ExtensionConfigShape|null $config + */ + public static function with( + RemovedotBgExtension|array|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension|null $config = null, + ?string $description = null, + ?string $name = null, + ): self { + $self = new self; + + null !== $config && $self['config'] = $config; + null !== $description && $self['description'] = $description; + null !== $name && $self['name'] = $name; + + return $self; + } + + /** + * Configuration object for an extension (base extensions only, not saved extension references). + * + * @param ExtensionConfigShape $config + */ + public function withConfig( + RemovedotBgExtension|array|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension $config, + ): self { + $self = clone $this; + $self['config'] = $config; + + return $self; + } + + /** + * Updated description of the saved extension. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * Updated name of the saved extension. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/ServiceContracts/Accounts/OriginsContract.php b/src/ServiceContracts/Accounts/OriginsContract.php new file mode 100644 index 00000000..075de491 --- /dev/null +++ b/src/ServiceContracts/Accounts/OriginsContract.php @@ -0,0 +1,155 @@ + + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): array; + + /** + * @api + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): mixed; + + /** + * @api + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): S3|S3Compatible|CloudinaryBackup|WebFolder|WebProxy|GoogleCloudStorageGcs|AzureBlobStorage|AkeneoPim; +} diff --git a/src/ServiceContracts/Accounts/OriginsRawContract.php b/src/ServiceContracts/Accounts/OriginsRawContract.php new file mode 100644 index 00000000..e3cb0579 --- /dev/null +++ b/src/ServiceContracts/Accounts/OriginsRawContract.php @@ -0,0 +1,100 @@ +|OriginCreateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|OriginCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param array|OriginUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $id, + array|OriginUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse,> + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; +} diff --git a/src/ServiceContracts/Accounts/URLEndpointsContract.php b/src/ServiceContracts/Accounts/URLEndpointsContract.php new file mode 100644 index 00000000..44b69db0 --- /dev/null +++ b/src/ServiceContracts/Accounts/URLEndpointsContract.php @@ -0,0 +1,99 @@ + $origins Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * @param string $urlPrefix path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint) + * @param URLRewriterShape $urlRewriter configuration for third-party URL rewriting + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function create( + string $description, + array $origins = [], + string $urlPrefix = '', + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter = null, + RequestOptions|array|null $requestOptions = null, + ): URLEndpointResponse; + + /** + * @api + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param string $description description of the URL endpoint + * @param list $origins Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * @param string $urlPrefix path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint) + * @param URLRewriterShape1 $urlRewriter configuration for third-party URL rewriting + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function update( + string $id, + string $description, + array $origins = [], + string $urlPrefix = '', + \ImageKit\Accounts\URLEndpoints\URLEndpointUpdateParams\URLRewriter\CloudinaryURLRewriter|array|\ImageKit\Accounts\URLEndpoints\URLEndpointUpdateParams\URLRewriter\ImgixURLRewriter|\ImageKit\Accounts\URLEndpoints\URLEndpointUpdateParams\URLRewriter\AkamaiURLRewriter|null $urlRewriter = null, + RequestOptions|array|null $requestOptions = null, + ): URLEndpointResponse; + + /** + * @api + * + * @param RequestOpts|null $requestOptions + * + * @return list + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): array; + + /** + * @api + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): mixed; + + /** + * @api + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): URLEndpointResponse; +} diff --git a/src/ServiceContracts/Accounts/URLEndpointsRawContract.php b/src/ServiceContracts/Accounts/URLEndpointsRawContract.php new file mode 100644 index 00000000..bbf30517 --- /dev/null +++ b/src/ServiceContracts/Accounts/URLEndpointsRawContract.php @@ -0,0 +1,93 @@ +|URLEndpointCreateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|URLEndpointCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param array|URLEndpointUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $id, + array|URLEndpointUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; +} diff --git a/src/ServiceContracts/Accounts/UsageContract.php b/src/ServiceContracts/Accounts/UsageContract.php new file mode 100644 index 00000000..f316b17d --- /dev/null +++ b/src/ServiceContracts/Accounts/UsageContract.php @@ -0,0 +1,30 @@ +|UsageGetParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + array|UsageGetParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/AccountsContract.php b/src/ServiceContracts/AccountsContract.php new file mode 100644 index 00000000..593d29a6 --- /dev/null +++ b/src/ServiceContracts/AccountsContract.php @@ -0,0 +1,7 @@ + $fileType Filter results by file type. + * + * - `all` — include all file types + * - `image` — include only image files + * - `non-image` — include only non-image files (e.g., JS, CSS, video) + * @param int $limit the maximum number of results to return in response + * @param string $path Folder path if you want to limit the search within a specific folder. For example, `/sales-banner/` will only search in folder sales-banner. + * + * Note : If your use case involves searching within a folder as well as its subfolders, you can use `path` parameter in `searchQuery` with appropriate operator. + * Checkout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) for more information. + * @param string $searchQuery Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + * + * Note : When the searchQuery parameter is present, the following query parameters will have no effect on the result: + * + * 1. `tags` + * 2. `type` + * 3. `name` + * + * [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) from examples. + * @param int $skip the number of results to skip before returning results + * @param Sort|value-of $sort sort the results by one of the supported fields in ascending or descending order + * @param Type|value-of $type Filter results by asset type. + * + * - `file` — returns only files + * - `file-version` — returns specific file versions + * - `folder` — returns only folders + * - `all` — returns both files and folders (excludes `file-version`) + * @param RequestOpts|null $requestOptions + * + * @return list + * + * @throws APIException + */ + public function list( + FileType|string $fileType = 'all', + int $limit = 1000, + ?string $path = null, + ?string $searchQuery = null, + int $skip = 0, + Sort|string $sort = 'ASC_CREATED', + Type|string $type = 'file', + RequestOptions|array|null $requestOptions = null, + ): array; +} diff --git a/src/ServiceContracts/AssetsRawContract.php b/src/ServiceContracts/AssetsRawContract.php new file mode 100644 index 00000000..824bfd3e --- /dev/null +++ b/src/ServiceContracts/AssetsRawContract.php @@ -0,0 +1,33 @@ +|AssetListParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + array|AssetListParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/Beta/V2/FilesContract.php b/src/ServiceContracts/Beta/V2/FilesContract.php new file mode 100644 index 00000000..0a864d25 --- /dev/null +++ b/src/ServiceContracts/Beta/V2/FilesContract.php @@ -0,0 +1,102 @@ + $customMetadata JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values. + * @param string $description optional text to describe the contents of the file + * @param list $extensions Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * @param string $folder The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. Using multiple `/` creates a nested folder. + * @param bool $isPrivateFile Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or signed URL. + * @param bool $isPublished Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * @param bool $overwriteAITags If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags. + * @param bool $overwriteCustomMetadata if the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed + * @param bool $overwriteFile if `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately + * @param bool $overwriteTags if the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed + * @param list> $responseFields array of response field keys to include in the API response body + * @param list $tags Set the tags while uploading the file. + * Provide an array of tag strings (e.g. `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed. + * If this field is not specified and the file is overwritten, the existing tags will be removed. + * @param Transformation|TransformationShape $transformation Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * + * - `pre` — applied before the file is uploaded to the Media Library. + * Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + * + * - `post` — applied immediately after upload. + * Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * @param bool $useUniqueFileName Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced. + * @param string $webhookURL The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function upload( + string|FileParam $file, + string $fileName, + ?string $token = null, + ?string $checks = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?array $extensions = null, + string $folder = '/', + bool $isPrivateFile = false, + bool $isPublished = true, + bool $overwriteAITags = true, + bool $overwriteCustomMetadata = true, + bool $overwriteFile = true, + bool $overwriteTags = true, + ?array $responseFields = null, + ?array $tags = null, + Transformation|array|null $transformation = null, + bool $useUniqueFileName = true, + ?string $webhookURL = null, + RequestOptions|array|null $requestOptions = null, + ): FileUploadResponse; +} diff --git a/src/ServiceContracts/Beta/V2/FilesRawContract.php b/src/ServiceContracts/Beta/V2/FilesRawContract.php new file mode 100644 index 00000000..f66987e1 --- /dev/null +++ b/src/ServiceContracts/Beta/V2/FilesRawContract.php @@ -0,0 +1,32 @@ +|FileUploadParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function upload( + array|FileUploadParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/Beta/V2Contract.php b/src/ServiceContracts/Beta/V2Contract.php new file mode 100644 index 00000000..c3c8cd8c --- /dev/null +++ b/src/ServiceContracts/Beta/V2Contract.php @@ -0,0 +1,7 @@ +|InvalidationCreateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|InvalidationCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $requestID should be a valid requestId + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $requestID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; +} diff --git a/src/ServiceContracts/CacheContract.php b/src/ServiceContracts/CacheContract.php new file mode 100644 index 00000000..aa3c07b6 --- /dev/null +++ b/src/ServiceContracts/CacheContract.php @@ -0,0 +1,7 @@ + + * + * @throws APIException + */ + public function list( + ?string $folderPath = null, + bool $includeDeleted = false, + RequestOptions|array|null $requestOptions = null, + ): array; + + /** + * @api + * + * @param string $id should be a valid custom metadata field id + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): CustomMetadataFieldDeleteResponse; +} diff --git a/src/ServiceContracts/CustomMetadataFieldsRawContract.php b/src/ServiceContracts/CustomMetadataFieldsRawContract.php new file mode 100644 index 00000000..25b7b107 --- /dev/null +++ b/src/ServiceContracts/CustomMetadataFieldsRawContract.php @@ -0,0 +1,82 @@ +|CustomMetadataFieldCreateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|CustomMetadataFieldCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $id should be a valid custom metadata field id + * @param array|CustomMetadataFieldUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $id, + array|CustomMetadataFieldUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|CustomMetadataFieldListParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + array|CustomMetadataFieldListParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $id should be a valid custom metadata field id + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; +} diff --git a/src/ServiceContracts/Files/BulkContract.php b/src/ServiceContracts/Files/BulkContract.php new file mode 100644 index 00000000..4ec1adf3 --- /dev/null +++ b/src/ServiceContracts/Files/BulkContract.php @@ -0,0 +1,76 @@ + $fileIDs an array of fileIds which you want to delete + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + array $fileIDs, + RequestOptions|array|null $requestOptions = null + ): BulkDeleteResponse; + + /** + * @api + * + * @param list $fileIDs an array of fileIds to which you want to add tags + * @param list $tags an array of tags that you want to add to the files + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function addTags( + array $fileIDs, + array $tags, + RequestOptions|array|null $requestOptions = null, + ): BulkAddTagsResponse; + + /** + * @api + * + * @param list $aiTags an array of AITags that you want to remove from the files + * @param list $fileIDs an array of fileIds from which you want to remove AITags + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function removeAITags( + array $aiTags, + array $fileIDs, + RequestOptions|array|null $requestOptions = null, + ): BulkRemoveAITagsResponse; + + /** + * @api + * + * @param list $fileIDs an array of fileIds from which you want to remove tags + * @param list $tags an array of tags that you want to remove from the files + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function removeTags( + array $fileIDs, + array $tags, + RequestOptions|array|null $requestOptions = null, + ): BulkRemoveTagsResponse; +} diff --git a/src/ServiceContracts/Files/BulkRawContract.php b/src/ServiceContracts/Files/BulkRawContract.php new file mode 100644 index 00000000..6062f309 --- /dev/null +++ b/src/ServiceContracts/Files/BulkRawContract.php @@ -0,0 +1,83 @@ +|BulkDeleteParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + array|BulkDeleteParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|BulkAddTagsParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function addTags( + array|BulkAddTagsParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|BulkRemoveAITagsParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function removeAITags( + array|BulkRemoveAITagsParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|BulkRemoveTagsParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function removeTags( + array|BulkRemoveTagsParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/Files/MetadataContract.php b/src/ServiceContracts/Files/MetadataContract.php new file mode 100644 index 00000000..bac8b5c5 --- /dev/null +++ b/src/ServiceContracts/Files/MetadataContract.php @@ -0,0 +1,41 @@ + + * + * @throws APIException + */ + public function get( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|MetadataGetFromURLParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function getFromURL( + array|MetadataGetFromURLParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/Files/VersionsContract.php b/src/ServiceContracts/Files/VersionsContract.php new file mode 100644 index 00000000..cd697185 --- /dev/null +++ b/src/ServiceContracts/Files/VersionsContract.php @@ -0,0 +1,76 @@ + + * + * @throws APIException + */ + public function list( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): array; + + /** + * @api + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $versionID, + string $fileID, + RequestOptions|array|null $requestOptions = null, + ): VersionDeleteResponse; + + /** + * @api + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $versionID, + string $fileID, + RequestOptions|array|null $requestOptions = null, + ): File; + + /** + * @api + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function restore( + string $versionID, + string $fileID, + RequestOptions|array|null $requestOptions = null, + ): File; +} diff --git a/src/ServiceContracts/Files/VersionsRawContract.php b/src/ServiceContracts/Files/VersionsRawContract.php new file mode 100644 index 00000000..746d3baa --- /dev/null +++ b/src/ServiceContracts/Files/VersionsRawContract.php @@ -0,0 +1,86 @@ +> + * + * @throws APIException + */ + public function list( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param array|VersionDeleteParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $versionID, + array|VersionDeleteParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param array|VersionGetParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $versionID, + array|VersionGetParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param array|VersionRestoreParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function restore( + string $versionID, + array|VersionRestoreParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/FilesContract.php b/src/ServiceContracts/FilesContract.php new file mode 100644 index 00000000..06f120ee --- /dev/null +++ b/src/ServiceContracts/FilesContract.php @@ -0,0 +1,250 @@ + $customMetadata A key-value data to be associated with the asset. To unset a key, send `null` value for that key. Before setting any custom metadata on an asset you have to create the field using custom metadata fields API. + * @param string $description optional text to describe the contents of the file + * @param list $extensions Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * @param RemoveAITagsShape $removeAITags An array of AITags associated with the file that you want to remove, e.g. `["car", "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are processed. + * @param list|null $tags An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to unset all tags associated with the file. + * @param string $webhookURL The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + * @param Publish|PublishShape $publish configure the publication status of a file and its versions + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function update( + string $fileID, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?array $extensions = null, + string|array|null $removeAITags = null, + ?array $tags = null, + ?string $webhookURL = null, + Publish|array|null $publish = null, + RequestOptions|array|null $requestOptions = null, + ): FileUpdateResponse; + + /** + * @api + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): mixed; + + /** + * @api + * + * @param string $destinationPath full path to the folder you want to copy the above file into + * @param string $sourceFilePath the full path of the file you want to copy + * @param bool $includeFileVersions Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied. Default value - `false`. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function copy( + string $destinationPath, + string $sourceFilePath, + ?bool $includeFileVersions = null, + RequestOptions|array|null $requestOptions = null, + ): FileCopyResponse; + + /** + * @api + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in the list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): File; + + /** + * @api + * + * @param string $destinationPath full path to the folder you want to move the above file into + * @param string $sourceFilePath the full path of the file you want to move + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function move( + string $destinationPath, + string $sourceFilePath, + RequestOptions|array|null $requestOptions = null, + ): FileMoveResponse; + + /** + * @api + * + * @param string $filePath the full path of the file you want to rename + * @param string $newFileName The new name of the file. A filename can contain: + * + * Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals in other languages). + * Special Characters: `.`, `_`, and `-`. + * + * Any other character, including space, will be replaced by `_`. + * @param bool $purgeCache Option to purge cache for the old file and its versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove cached content of old file and its versions. This purge request is counted against your monthly purge quota. + * + * Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will remove the file and its versions' URLs and any transformations made using query parameters on this file or its versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function rename( + string $filePath, + string $newFileName, + ?bool $purgeCache = null, + RequestOptions|array|null $requestOptions = null, + ): FileRenameResponse; + + /** + * @api + * + * @param string|FileParam $file The API accepts any of the following: + * + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request. + * @param string $fileName The name with which the file has to be uploaded. + * The file name can contain: + * + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * @param string $token A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field. + * @param string $checks Server-side checks to run on the asset. + * Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * @param string $customCoordinates Define an important area in the image. This is only relevant for image type files. + * + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be removed. + * @param array $customMetadata JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values. + * @param string $description optional text to describe the contents of the file + * @param int $expire The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side. + * @param list $extensions Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * @param string $folder The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. + * + * The folder name can contain: + * + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * @param bool $isPrivateFile Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or signed URL. + * @param bool $isPublished Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * @param bool $overwriteAITags If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags. + * @param bool $overwriteCustomMetadata if the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed + * @param bool $overwriteFile if `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately + * @param bool $overwriteTags if the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed + * @param string $publicKey Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side. + * @param list> $responseFields array of response field keys to include in the API response body + * @param string $signature HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side. + * @param list $tags Set the tags while uploading the file. + * Provide an array of tag strings (e.g. `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed. + * If this field is not specified and the file is overwritten, the existing tags will be removed. + * @param Transformation|TransformationShape $transformation Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * + * - `pre` — applied before the file is uploaded to the Media Library. + * Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + * + * - `post` — applied immediately after upload. + * Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * @param bool $useUniqueFileName Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced. + * @param string $webhookURL The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function upload( + string|FileParam $file, + string $fileName, + ?string $token = null, + ?string $checks = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?int $expire = null, + ?array $extensions = null, + string $folder = '/', + bool $isPrivateFile = false, + bool $isPublished = true, + bool $overwriteAITags = true, + bool $overwriteCustomMetadata = true, + bool $overwriteFile = true, + bool $overwriteTags = true, + ?string $publicKey = null, + ?array $responseFields = null, + ?string $signature = null, + ?array $tags = null, + Transformation|array|null $transformation = null, + bool $useUniqueFileName = true, + ?string $webhookURL = null, + RequestOptions|array|null $requestOptions = null, + ): FileUploadResponse; +} diff --git a/src/ServiceContracts/FilesRawContract.php b/src/ServiceContracts/FilesRawContract.php new file mode 100644 index 00000000..54a96cd0 --- /dev/null +++ b/src/ServiceContracts/FilesRawContract.php @@ -0,0 +1,133 @@ +|FileUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $fileID, + array|FileUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|FileCopyParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function copy( + array|FileCopyParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in the list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param array|FileMoveParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function move( + array|FileMoveParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|FileRenameParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function rename( + array|FileRenameParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|FileUploadParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function upload( + array|FileUploadParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/Folders/JobContract.php b/src/ServiceContracts/Folders/JobContract.php new file mode 100644 index 00000000..e111bc22 --- /dev/null +++ b/src/ServiceContracts/Folders/JobContract.php @@ -0,0 +1,28 @@ + + * + * @throws APIException + */ + public function get( + string $jobID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; +} diff --git a/src/ServiceContracts/FoldersContract.php b/src/ServiceContracts/FoldersContract.php new file mode 100644 index 00000000..45ad8fdd --- /dev/null +++ b/src/ServiceContracts/FoldersContract.php @@ -0,0 +1,108 @@ +|FolderCreateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|FolderCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|FolderDeleteParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + array|FolderDeleteParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|FolderCopyParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function copy( + array|FolderCopyParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|FolderMoveParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function move( + array|FolderMoveParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param array|FolderRenameParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function rename( + array|FolderRenameParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; +} diff --git a/src/ServiceContracts/SavedExtensionsContract.php b/src/ServiceContracts/SavedExtensionsContract.php new file mode 100644 index 00000000..4104f9e1 --- /dev/null +++ b/src/ServiceContracts/SavedExtensionsContract.php @@ -0,0 +1,95 @@ + + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): array; + + /** + * @api + * + * @param string $id the unique ID of the saved extension + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): mixed; + + /** + * @api + * + * @param string $id the unique ID of the saved extension + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): SavedExtension; +} diff --git a/src/ServiceContracts/SavedExtensionsRawContract.php b/src/ServiceContracts/SavedExtensionsRawContract.php new file mode 100644 index 00000000..95f1d0e9 --- /dev/null +++ b/src/ServiceContracts/SavedExtensionsRawContract.php @@ -0,0 +1,93 @@ +|SavedExtensionCreateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|SavedExtensionCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param string $id the unique ID of the saved extension + * @param array|SavedExtensionUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $id, + array|SavedExtensionUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse; + + /** + * @api + * + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param string $id the unique ID of the saved extension + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; + + /** + * @api + * + * @param string $id the unique ID of the saved extension + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse; +} diff --git a/src/ServiceContracts/WebhooksContract.php b/src/ServiceContracts/WebhooksContract.php new file mode 100644 index 00000000..4cc93acb --- /dev/null +++ b/src/ServiceContracts/WebhooksContract.php @@ -0,0 +1,48 @@ +>|null $headers + * + * @throws WebhookException + */ + public function unwrap( + string $body, + ?array $headers = null, + ?string $secret = null + ): VideoTransformationAcceptedEvent|VideoTransformationReadyEvent|VideoTransformationErrorEvent|UploadPreTransformSuccessEvent|UploadPreTransformErrorEvent|UploadPostTransformSuccessEvent|UploadPostTransformErrorEvent|FileCreateEvent|FileUpdateEvent|FileDeleteEvent|FileVersionCreateEvent|FileVersionDeleteEvent; +} diff --git a/src/ServiceContracts/WebhooksRawContract.php b/src/ServiceContracts/WebhooksRawContract.php new file mode 100644 index 00000000..80aa9694 --- /dev/null +++ b/src/ServiceContracts/WebhooksRawContract.php @@ -0,0 +1,7 @@ + + * + * @throws APIException + */ + public function create( + array|OriginCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = OriginCreateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/accounts/origins', + body: (object) $parsed, + options: $options, + convert: OriginResponse::class, + ); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Updates the origin identified by `id` and returns the updated origin object. + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param array{ + * accessKey: string, + * bucket: string, + * name: string, + * secretKey: string, + * type?: 'AKENEO_PIM', + * baseURLForCanonicalHeader?: string, + * includeCanonicalHeader?: bool, + * prefix?: string, + * endpoint: string, + * s3ForcePathStyle?: bool, + * baseURL: string, + * forwardHostHeaderToOrigin?: bool, + * clientEmail: string, + * privateKey: string, + * accountName: string, + * container: string, + * sasToken: string, + * clientID: string, + * clientSecret: string, + * password: string, + * username: string, + * }|OriginUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $id, + array|OriginUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = OriginUpdateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'put', + path: ['v1/accounts/origins/%1$s', $id], + body: (object) $parsed, + options: $options, + convert: OriginResponse::class, + ); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Returns an array of all configured origins for the current account. + * + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse,> + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'v1/accounts/origins', + options: $requestOptions, + convert: new ListOf(OriginResponse::class), + ); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Permanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error. + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['v1/accounts/origins/%1$s', $id], + options: $requestOptions, + convert: null, + ); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Retrieves the origin identified by `id`. + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v1/accounts/origins/%1$s', $id], + options: $requestOptions, + convert: OriginResponse::class, + ); + } +} diff --git a/src/Services/Accounts/OriginsService.php b/src/Services/Accounts/OriginsService.php new file mode 100644 index 00000000..41e60fbb --- /dev/null +++ b/src/Services/Accounts/OriginsService.php @@ -0,0 +1,263 @@ +raw = new OriginsRawService($client); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Creates a new origin and returns the origin object. + * + * @param string $accessKey access key for the bucket + * @param string $name display name of the origin + * @param string $secretKey secret key for the bucket + * @param string $endpoint custom S3-compatible endpoint + * @param string $baseURL akeneo instance base URL + * @param string $clientID akeneo API client ID + * @param string $clientSecret akeneo API client secret + * @param string $password akeneo API password + * @param string $username akeneo API username + * @param 'AKENEO_PIM' $type + * @param string $baseURLForCanonicalHeader URL used in the Canonical header (if enabled) + * @param bool $includeCanonicalHeader whether to send a Canonical header + * @param bool $s3ForcePathStyle Use path-style S3 URLs? + * @param bool $forwardHostHeaderToOrigin Forward the Host header to origin? + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function create( + string $accessKey, + string $bucket, + string $name, + string $secretKey, + string $endpoint, + string $baseURL, + string $clientEmail, + string $privateKey, + string $accountName, + string $container, + string $sasToken, + string $clientID, + string $clientSecret, + string $password, + string $username, + string $type = 'AKENEO_PIM', + ?string $baseURLForCanonicalHeader = null, + bool $includeCanonicalHeader = false, + string $prefix = '', + bool $s3ForcePathStyle = false, + bool $forwardHostHeaderToOrigin = false, + RequestOptions|array|null $requestOptions = null, + ): S3|S3Compatible|CloudinaryBackup|WebFolder|WebProxy|GoogleCloudStorageGcs|AzureBlobStorage|AkeneoPim { + $params = Util::removeNulls( + [ + 'accessKey' => $accessKey, + 'bucket' => $bucket, + 'name' => $name, + 'secretKey' => $secretKey, + 'type' => $type, + 'baseURLForCanonicalHeader' => $baseURLForCanonicalHeader, + 'includeCanonicalHeader' => $includeCanonicalHeader, + 'prefix' => $prefix, + 'endpoint' => $endpoint, + 's3ForcePathStyle' => $s3ForcePathStyle, + 'baseURL' => $baseURL, + 'forwardHostHeaderToOrigin' => $forwardHostHeaderToOrigin, + 'clientEmail' => $clientEmail, + 'privateKey' => $privateKey, + 'accountName' => $accountName, + 'container' => $container, + 'sasToken' => $sasToken, + 'clientID' => $clientID, + 'clientSecret' => $clientSecret, + 'password' => $password, + 'username' => $username, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->create(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Updates the origin identified by `id` and returns the updated origin object. + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param string $accessKey access key for the bucket + * @param string $name display name of the origin + * @param string $secretKey secret key for the bucket + * @param string $endpoint custom S3-compatible endpoint + * @param string $baseURL akeneo instance base URL + * @param string $clientID akeneo API client ID + * @param string $clientSecret akeneo API client secret + * @param string $password akeneo API password + * @param string $username akeneo API username + * @param 'AKENEO_PIM' $type + * @param string $baseURLForCanonicalHeader URL used in the Canonical header (if enabled) + * @param bool $includeCanonicalHeader whether to send a Canonical header + * @param bool $s3ForcePathStyle Use path-style S3 URLs? + * @param bool $forwardHostHeaderToOrigin Forward the Host header to origin? + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function update( + string $id, + string $accessKey, + string $bucket, + string $name, + string $secretKey, + string $endpoint, + string $baseURL, + string $clientEmail, + string $privateKey, + string $accountName, + string $container, + string $sasToken, + string $clientID, + string $clientSecret, + string $password, + string $username, + string $type = 'AKENEO_PIM', + ?string $baseURLForCanonicalHeader = null, + bool $includeCanonicalHeader = false, + string $prefix = '', + bool $s3ForcePathStyle = false, + bool $forwardHostHeaderToOrigin = false, + RequestOptions|array|null $requestOptions = null, + ): S3|S3Compatible|CloudinaryBackup|WebFolder|WebProxy|GoogleCloudStorageGcs|AzureBlobStorage|AkeneoPim { + $params = Util::removeNulls( + [ + 'accessKey' => $accessKey, + 'bucket' => $bucket, + 'name' => $name, + 'secretKey' => $secretKey, + 'type' => $type, + 'baseURLForCanonicalHeader' => $baseURLForCanonicalHeader, + 'includeCanonicalHeader' => $includeCanonicalHeader, + 'prefix' => $prefix, + 'endpoint' => $endpoint, + 's3ForcePathStyle' => $s3ForcePathStyle, + 'baseURL' => $baseURL, + 'forwardHostHeaderToOrigin' => $forwardHostHeaderToOrigin, + 'clientEmail' => $clientEmail, + 'privateKey' => $privateKey, + 'accountName' => $accountName, + 'container' => $container, + 'sasToken' => $sasToken, + 'clientID' => $clientID, + 'clientSecret' => $clientSecret, + 'password' => $password, + 'username' => $username, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->update($id, params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Returns an array of all configured origins for the current account. + * + * @param RequestOpts|null $requestOptions + * + * @return list + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): array { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list(requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Permanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error. + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): mixed { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($id, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Retrieves the origin identified by `id`. + * + * @param string $id Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): S3|S3Compatible|CloudinaryBackup|WebFolder|WebProxy|GoogleCloudStorageGcs|AzureBlobStorage|AkeneoPim { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get($id, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/Accounts/URLEndpointsRawService.php b/src/Services/Accounts/URLEndpointsRawService.php new file mode 100644 index 00000000..7dac59d1 --- /dev/null +++ b/src/Services/Accounts/URLEndpointsRawService.php @@ -0,0 +1,181 @@ +, + * urlPrefix?: string, + * urlRewriter?: URLRewriterShape, + * }|URLEndpointCreateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function create( + array|URLEndpointCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = URLEndpointCreateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/accounts/url-endpoints', + body: (object) $parsed, + options: $options, + convert: URLEndpointResponse::class, + ); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Updates the URL‑endpoint identified by `id` and returns the updated object. + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param array{ + * description: string, + * origins?: list, + * urlPrefix?: string, + * urlRewriter?: URLRewriterShape1, + * }|URLEndpointUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $id, + array|URLEndpointUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = URLEndpointUpdateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'put', + path: ['v1/accounts/url-endpoints/%1$s', $id], + body: (object) $parsed, + options: $options, + convert: URLEndpointResponse::class, + ); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Returns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation. + * + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'v1/accounts/url-endpoints', + options: $requestOptions, + convert: new ListOf(URLEndpointResponse::class), + ); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Deletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation. + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['v1/accounts/url-endpoints/%1$s', $id], + options: $requestOptions, + convert: null, + ); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Retrieves the URL‑endpoint identified by `id`. + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v1/accounts/url-endpoints/%1$s', $id], + options: $requestOptions, + convert: URLEndpointResponse::class, + ); + } +} diff --git a/src/Services/Accounts/URLEndpointsService.php b/src/Services/Accounts/URLEndpointsService.php new file mode 100644 index 00000000..0740c4f5 --- /dev/null +++ b/src/Services/Accounts/URLEndpointsService.php @@ -0,0 +1,173 @@ +raw = new URLEndpointsRawService($client); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Creates a new URL‑endpoint and returns the resulting object. + * + * @param string $description description of the URL endpoint + * @param list $origins Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * @param string $urlPrefix path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint) + * @param URLRewriterShape $urlRewriter configuration for third-party URL rewriting + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function create( + string $description, + array $origins = [], + string $urlPrefix = '', + CloudinaryURLRewriter|array|ImgixURLRewriter|AkamaiURLRewriter|null $urlRewriter = null, + RequestOptions|array|null $requestOptions = null, + ): URLEndpointResponse { + $params = Util::removeNulls( + [ + 'description' => $description, + 'origins' => $origins, + 'urlPrefix' => $urlPrefix, + 'urlRewriter' => $urlRewriter, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->create(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Updates the URL‑endpoint identified by `id` and returns the updated object. + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param string $description description of the URL endpoint + * @param list $origins Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint. + * @param string $urlPrefix path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint) + * @param URLRewriterShape1 $urlRewriter configuration for third-party URL rewriting + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function update( + string $id, + string $description, + array $origins = [], + string $urlPrefix = '', + \ImageKit\Accounts\URLEndpoints\URLEndpointUpdateParams\URLRewriter\CloudinaryURLRewriter|array|\ImageKit\Accounts\URLEndpoints\URLEndpointUpdateParams\URLRewriter\ImgixURLRewriter|\ImageKit\Accounts\URLEndpoints\URLEndpointUpdateParams\URLRewriter\AkamaiURLRewriter|null $urlRewriter = null, + RequestOptions|array|null $requestOptions = null, + ): URLEndpointResponse { + $params = Util::removeNulls( + [ + 'description' => $description, + 'origins' => $origins, + 'urlPrefix' => $urlPrefix, + 'urlRewriter' => $urlRewriter, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->update($id, params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Returns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation. + * + * @param RequestOpts|null $requestOptions + * + * @return list + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): array { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list(requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Deletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation. + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): mixed { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($id, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * **Note:** This API is currently in beta. + * Retrieves the URL‑endpoint identified by `id`. + * + * @param string $id Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): URLEndpointResponse { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get($id, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/Accounts/UsageRawService.php b/src/Services/Accounts/UsageRawService.php new file mode 100644 index 00000000..0de038f8 --- /dev/null +++ b/src/Services/Accounts/UsageRawService.php @@ -0,0 +1,56 @@ + + * + * @throws APIException + */ + public function get( + array|UsageGetParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = UsageGetParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'v1/accounts/usage', + query: $parsed, + options: $options, + convert: UsageGetResponse::class, + ); + } +} diff --git a/src/Services/Accounts/UsageService.php b/src/Services/Accounts/UsageService.php new file mode 100644 index 00000000..a49773b4 --- /dev/null +++ b/src/Services/Accounts/UsageService.php @@ -0,0 +1,57 @@ +raw = new UsageRawService($client); + } + + /** + * @api + * + * Get the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date. + * + * @param string $endDate Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days. + * @param string $startDate Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $endDate, + string $startDate, + RequestOptions|array|null $requestOptions = null, + ): UsageGetResponse { + $params = Util::removeNulls( + ['endDate' => $endDate, 'startDate' => $startDate] + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/AccountsRawService.php b/src/Services/AccountsRawService.php new file mode 100644 index 00000000..fa3fca54 --- /dev/null +++ b/src/Services/AccountsRawService.php @@ -0,0 +1,17 @@ +raw = new AccountsRawService($client); + $this->usage = new UsageService($client); + $this->origins = new OriginsService($client); + $this->urlEndpoints = new URLEndpointsService($client); + } +} diff --git a/src/Services/AssetsRawService.php b/src/Services/AssetsRawService.php new file mode 100644 index 00000000..bd20f60e --- /dev/null +++ b/src/Services/AssetsRawService.php @@ -0,0 +1,70 @@ +, + * limit?: int, + * path?: string, + * searchQuery?: string, + * skip?: int, + * sort?: value-of, + * type?: Type|value-of, + * }|AssetListParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + array|AssetListParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = AssetListParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'v1/files', + query: $parsed, + options: $options, + convert: new ListOf(AssetListResponseItem::class), + ); + } +} diff --git a/src/Services/AssetsService.php b/src/Services/AssetsService.php new file mode 100644 index 00000000..dcfd4933 --- /dev/null +++ b/src/Services/AssetsService.php @@ -0,0 +1,101 @@ +raw = new AssetsRawService($client); + } + + /** + * @api + * + * This API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`. + * + * @param FileType|value-of $fileType Filter results by file type. + * + * - `all` — include all file types + * - `image` — include only image files + * - `non-image` — include only non-image files (e.g., JS, CSS, video) + * @param int $limit the maximum number of results to return in response + * @param string $path Folder path if you want to limit the search within a specific folder. For example, `/sales-banner/` will only search in folder sales-banner. + * + * Note : If your use case involves searching within a folder as well as its subfolders, you can use `path` parameter in `searchQuery` with appropriate operator. + * Checkout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) for more information. + * @param string $searchQuery Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + * + * Note : When the searchQuery parameter is present, the following query parameters will have no effect on the result: + * + * 1. `tags` + * 2. `type` + * 3. `name` + * + * [Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) from examples. + * @param int $skip the number of results to skip before returning results + * @param Sort|value-of $sort sort the results by one of the supported fields in ascending or descending order + * @param Type|value-of $type Filter results by asset type. + * + * - `file` — returns only files + * - `file-version` — returns specific file versions + * - `folder` — returns only folders + * - `all` — returns both files and folders (excludes `file-version`) + * @param RequestOpts|null $requestOptions + * + * @return list + * + * @throws APIException + */ + public function list( + FileType|string $fileType = 'all', + int $limit = 1000, + ?string $path = null, + ?string $searchQuery = null, + int $skip = 0, + Sort|string $sort = 'ASC_CREATED', + Type|string $type = 'file', + RequestOptions|array|null $requestOptions = null, + ): array { + $params = Util::removeNulls( + [ + 'fileType' => $fileType, + 'limit' => $limit, + 'path' => $path, + 'searchQuery' => $searchQuery, + 'skip' => $skip, + 'sort' => $sort, + 'type' => $type, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/Beta/V2/FilesRawService.php b/src/Services/Beta/V2/FilesRawService.php new file mode 100644 index 00000000..f9dc045e --- /dev/null +++ b/src/Services/Beta/V2/FilesRawService.php @@ -0,0 +1,99 @@ +, + * description?: string, + * extensions?: list, + * folder?: string, + * isPrivateFile?: bool, + * isPublished?: bool, + * overwriteAITags?: bool, + * overwriteCustomMetadata?: bool, + * overwriteFile?: bool, + * overwriteTags?: bool, + * responseFields?: list>, + * tags?: list, + * transformation?: Transformation|TransformationShape, + * useUniqueFileName?: bool, + * webhookURL?: string, + * }|FileUploadParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function upload( + array|FileUploadParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FileUploadParams::parseRequest( + $params, + $requestOptions, + ); + $path = $this + ->client + ->baseUrlOverridden ? 'api/v2/files/upload' : 'https://upload.imagekit.io/api/v2/files/upload'; + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: $path, + headers: ['Content-Type' => 'multipart/form-data'], + body: (object) $parsed, + options: $options, + convert: FileUploadResponse::class, + ); + } +} diff --git a/src/Services/Beta/V2/FilesService.php b/src/Services/Beta/V2/FilesService.php new file mode 100644 index 00000000..425e3147 --- /dev/null +++ b/src/Services/Beta/V2/FilesService.php @@ -0,0 +1,163 @@ +raw = new FilesRawService($client); + } + + /** + * @api + * + * The V2 API enhances security by verifying the entire payload using JWT. This API is in beta. + * + * ImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload. + * + * **File size limit** \ + * On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans. + * + * **Version limit** \ + * A file can have a maximum of 100 versions. + * + * **Demo applications** + * + * - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. + * + * @param string|FileParam $file The API accepts any of the following: + * + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request. + * @param string $fileName the name with which the file has to be uploaded + * @param string $token This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to authenticate and check that the upload request parameters have not been tampered with after the token has been generated. Learn how to create the token on the page below. This field is only required for authentication when uploading a file from the client side. + * @param string $checks Server-side checks to run on the asset. + * Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + * @param string $customCoordinates Define an important area in the image. This is only relevant for image type files. + * + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be removed. + * @param array $customMetadata JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values. + * @param string $description optional text to describe the contents of the file + * @param list $extensions Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * @param string $folder The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. Using multiple `/` creates a nested folder. + * @param bool $isPrivateFile Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or signed URL. + * @param bool $isPublished Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * @param bool $overwriteAITags If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags. + * @param bool $overwriteCustomMetadata if the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed + * @param bool $overwriteFile if `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately + * @param bool $overwriteTags if the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed + * @param list> $responseFields array of response field keys to include in the API response body + * @param list $tags Set the tags while uploading the file. + * Provide an array of tag strings (e.g. `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed. + * If this field is not specified and the file is overwritten, the existing tags will be removed. + * @param Transformation|TransformationShape $transformation Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * + * - `pre` — applied before the file is uploaded to the Media Library. + * Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + * + * - `post` — applied immediately after upload. + * Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * @param bool $useUniqueFileName Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced. + * @param string $webhookURL The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function upload( + string|FileParam $file, + string $fileName, + ?string $token = null, + ?string $checks = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?array $extensions = null, + string $folder = '/', + bool $isPrivateFile = false, + bool $isPublished = true, + bool $overwriteAITags = true, + bool $overwriteCustomMetadata = true, + bool $overwriteFile = true, + bool $overwriteTags = true, + ?array $responseFields = null, + ?array $tags = null, + Transformation|array|null $transformation = null, + bool $useUniqueFileName = true, + ?string $webhookURL = null, + RequestOptions|array|null $requestOptions = null, + ): FileUploadResponse { + $params = Util::removeNulls( + [ + 'file' => $file, + 'fileName' => $fileName, + 'token' => $token, + 'checks' => $checks, + 'customCoordinates' => $customCoordinates, + 'customMetadata' => $customMetadata, + 'description' => $description, + 'extensions' => $extensions, + 'folder' => $folder, + 'isPrivateFile' => $isPrivateFile, + 'isPublished' => $isPublished, + 'overwriteAITags' => $overwriteAITags, + 'overwriteCustomMetadata' => $overwriteCustomMetadata, + 'overwriteFile' => $overwriteFile, + 'overwriteTags' => $overwriteTags, + 'responseFields' => $responseFields, + 'tags' => $tags, + 'transformation' => $transformation, + 'useUniqueFileName' => $useUniqueFileName, + 'webhookURL' => $webhookURL, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->upload(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/Beta/V2RawService.php b/src/Services/Beta/V2RawService.php new file mode 100644 index 00000000..2b0b996e --- /dev/null +++ b/src/Services/Beta/V2RawService.php @@ -0,0 +1,17 @@ +raw = new V2RawService($client); + $this->files = new FilesService($client); + } +} diff --git a/src/Services/BetaRawService.php b/src/Services/BetaRawService.php new file mode 100644 index 00000000..e5ef3afa --- /dev/null +++ b/src/Services/BetaRawService.php @@ -0,0 +1,17 @@ +raw = new BetaRawService($client); + $this->v2 = new V2Service($client); + } +} diff --git a/src/Services/Cache/InvalidationRawService.php b/src/Services/Cache/InvalidationRawService.php new file mode 100644 index 00000000..1d9daaef --- /dev/null +++ b/src/Services/Cache/InvalidationRawService.php @@ -0,0 +1,82 @@ + + * + * @throws APIException + */ + public function create( + array|InvalidationCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = InvalidationCreateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/files/purge', + body: (object) $parsed, + options: $options, + convert: InvalidationNewResponse::class, + ); + } + + /** + * @api + * + * This API returns the status of a purge cache request. + * + * @param string $requestID should be a valid requestId + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $requestID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v1/files/purge/%1$s', $requestID], + options: $requestOptions, + convert: InvalidationGetResponse::class, + ); + } +} diff --git a/src/Services/Cache/InvalidationService.php b/src/Services/Cache/InvalidationService.php new file mode 100644 index 00000000..cfc001e2 --- /dev/null +++ b/src/Services/Cache/InvalidationService.php @@ -0,0 +1,74 @@ +raw = new InvalidationRawService($client); + } + + /** + * @api + * + * This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes. + * + * @param string $url the full URL of the file to be purged + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function create( + string $url, + RequestOptions|array|null $requestOptions = null + ): InvalidationNewResponse { + $params = Util::removeNulls(['url' => $url]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->create(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API returns the status of a purge cache request. + * + * @param string $requestID should be a valid requestId + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $requestID, + RequestOptions|array|null $requestOptions = null + ): InvalidationGetResponse { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get($requestID, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/CacheRawService.php b/src/Services/CacheRawService.php new file mode 100644 index 00000000..096ab979 --- /dev/null +++ b/src/Services/CacheRawService.php @@ -0,0 +1,17 @@ +raw = new CacheRawService($client); + $this->invalidation = new InvalidationService($client); + } +} diff --git a/src/Services/CustomMetadataFieldsRawService.php b/src/Services/CustomMetadataFieldsRawService.php new file mode 100644 index 00000000..8d3f5877 --- /dev/null +++ b/src/Services/CustomMetadataFieldsRawService.php @@ -0,0 +1,161 @@ + + * + * @throws APIException + */ + public function create( + array|CustomMetadataFieldCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = CustomMetadataFieldCreateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/customMetadataFields', + body: (object) $parsed, + options: $options, + convert: CustomMetadataField::class, + ); + } + + /** + * @api + * + * This API updates the label or schema of an existing custom metadata field. + * + * @param string $id should be a valid custom metadata field id + * @param array{ + * label?: string, + * schema?: CustomMetadataFieldUpdateParams\Schema|SchemaShape1, + * }|CustomMetadataFieldUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $id, + array|CustomMetadataFieldUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = CustomMetadataFieldUpdateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'patch', + path: ['v1/customMetadataFields/%1$s', $id], + body: (object) $parsed, + options: $options, + convert: CustomMetadataField::class, + ); + } + + /** + * @api + * + * This API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response. + * + * You can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path. + * + * @param array{ + * folderPath?: string, includeDeleted?: bool + * }|CustomMetadataFieldListParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + array|CustomMetadataFieldListParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = CustomMetadataFieldListParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'v1/customMetadataFields', + query: $parsed, + options: $options, + convert: new ListOf(CustomMetadataField::class), + ); + } + + /** + * @api + * + * This API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name. + * + * @param string $id should be a valid custom metadata field id + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['v1/customMetadataFields/%1$s', $id], + options: $requestOptions, + convert: CustomMetadataFieldDeleteResponse::class, + ); + } +} diff --git a/src/Services/CustomMetadataFieldsService.php b/src/Services/CustomMetadataFieldsService.php new file mode 100644 index 00000000..62c848bd --- /dev/null +++ b/src/Services/CustomMetadataFieldsService.php @@ -0,0 +1,139 @@ +raw = new CustomMetadataFieldsRawService($client); + } + + /** + * @api + * + * This API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API. + * + * @param string $label Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. + * @param string $name API name of the custom metadata field. This should be unique across all (including deleted) custom metadata fields. + * @param Schema|SchemaShape $schema + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function create( + string $label, + string $name, + Schema|array $schema, + RequestOptions|array|null $requestOptions = null, + ): CustomMetadataField { + $params = Util::removeNulls( + ['label' => $label, 'name' => $name, 'schema' => $schema] + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->create(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API updates the label or schema of an existing custom metadata field. + * + * @param string $id should be a valid custom metadata field id + * @param string $label Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. This parameter is required if `schema` is not provided. + * @param \ImageKit\CustomMetadataFields\CustomMetadataFieldUpdateParams\Schema|SchemaShape1 $schema An object that describes the rules for the custom metadata key. This parameter is required if `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the `schema`. The schema will be validated as per the existing `type`. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function update( + string $id, + ?string $label = null, + \ImageKit\CustomMetadataFields\CustomMetadataFieldUpdateParams\Schema|array|null $schema = null, + RequestOptions|array|null $requestOptions = null, + ): CustomMetadataField { + $params = Util::removeNulls(['label' => $label, 'schema' => $schema]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->update($id, params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response. + * + * You can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path. + * + * @param string $folderPath The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata fields. Useful for determining path-specific field selections when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use. + * @param bool $includeDeleted set it to `true` to include deleted field objects in the API response + * @param RequestOpts|null $requestOptions + * + * @return list + * + * @throws APIException + */ + public function list( + ?string $folderPath = null, + bool $includeDeleted = false, + RequestOptions|array|null $requestOptions = null, + ): array { + $params = Util::removeNulls( + ['folderPath' => $folderPath, 'includeDeleted' => $includeDeleted] + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name. + * + * @param string $id should be a valid custom metadata field id + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): CustomMetadataFieldDeleteResponse { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($id, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/Files/BulkRawService.php b/src/Services/Files/BulkRawService.php new file mode 100644 index 00000000..97aba6e4 --- /dev/null +++ b/src/Services/Files/BulkRawService.php @@ -0,0 +1,165 @@ +}|BulkDeleteParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + array|BulkDeleteParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = BulkDeleteParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/files/batch/deleteByFileIds', + body: (object) $parsed, + options: $options, + convert: BulkDeleteResponse::class, + ); + } + + /** + * @api + * + * This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time. + * + * @param array{ + * fileIDs: list, tags: list + * }|BulkAddTagsParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function addTags( + array|BulkAddTagsParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = BulkAddTagsParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/files/addTags', + body: (object) $parsed, + options: $options, + convert: BulkAddTagsResponse::class, + ); + } + + /** + * @api + * + * This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time. + * + * @param array{ + * aiTags: list, fileIDs: list + * }|BulkRemoveAITagsParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function removeAITags( + array|BulkRemoveAITagsParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = BulkRemoveAITagsParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/files/removeAITags', + body: (object) $parsed, + options: $options, + convert: BulkRemoveAITagsResponse::class, + ); + } + + /** + * @api + * + * This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time. + * + * @param array{ + * fileIDs: list, tags: list + * }|BulkRemoveTagsParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function removeTags( + array|BulkRemoveTagsParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = BulkRemoveTagsParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/files/removeTags', + body: (object) $parsed, + options: $options, + convert: BulkRemoveTagsResponse::class, + ); + } +} diff --git a/src/Services/Files/BulkService.php b/src/Services/Files/BulkService.php new file mode 100644 index 00000000..89fb681f --- /dev/null +++ b/src/Services/Files/BulkService.php @@ -0,0 +1,132 @@ +raw = new BulkRawService($client); + } + + /** + * @api + * + * This API deletes multiple files and all their file versions permanently. + * + * Note: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API. + * + * A maximum of 100 files can be deleted at a time. + * + * @param list $fileIDs an array of fileIds which you want to delete + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + array $fileIDs, + RequestOptions|array|null $requestOptions = null + ): BulkDeleteResponse { + $params = Util::removeNulls(['fileIDs' => $fileIDs]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time. + * + * @param list $fileIDs an array of fileIds to which you want to add tags + * @param list $tags an array of tags that you want to add to the files + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function addTags( + array $fileIDs, + array $tags, + RequestOptions|array|null $requestOptions = null, + ): BulkAddTagsResponse { + $params = Util::removeNulls(['fileIDs' => $fileIDs, 'tags' => $tags]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->addTags(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time. + * + * @param list $aiTags an array of AITags that you want to remove from the files + * @param list $fileIDs an array of fileIds from which you want to remove AITags + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function removeAITags( + array $aiTags, + array $fileIDs, + RequestOptions|array|null $requestOptions = null, + ): BulkRemoveAITagsResponse { + $params = Util::removeNulls(['aiTags' => $aiTags, 'fileIDs' => $fileIDs]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->removeAITags(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time. + * + * @param list $fileIDs an array of fileIds from which you want to remove tags + * @param list $tags an array of tags that you want to remove from the files + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function removeTags( + array $fileIDs, + array $tags, + RequestOptions|array|null $requestOptions = null, + ): BulkRemoveTagsResponse { + $params = Util::removeNulls(['fileIDs' => $fileIDs, 'tags' => $tags]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->removeTags(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/Files/MetadataRawService.php b/src/Services/Files/MetadataRawService.php new file mode 100644 index 00000000..db981b5c --- /dev/null +++ b/src/Services/Files/MetadataRawService.php @@ -0,0 +1,83 @@ + + * + * @throws APIException + */ + public function get( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v1/files/%1$s/metadata', $fileID], + options: $requestOptions, + convert: Metadata::class, + ); + } + + /** + * @api + * + * Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. + * + * @param array{url: string}|MetadataGetFromURLParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function getFromURL( + array|MetadataGetFromURLParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = MetadataGetFromURLParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'v1/metadata', + query: $parsed, + options: $options, + convert: Metadata::class, + ); + } +} diff --git a/src/Services/Files/MetadataService.php b/src/Services/Files/MetadataService.php new file mode 100644 index 00000000..bfffa68c --- /dev/null +++ b/src/Services/Files/MetadataService.php @@ -0,0 +1,75 @@ +raw = new MetadataRawService($client); + } + + /** + * @api + * + * You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API. + * + * You can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter. + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in the list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): Metadata { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get($fileID, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. + * + * @param string $url Should be a valid file URL. It should be accessible using your ImageKit.io account. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function getFromURL( + string $url, + RequestOptions|array|null $requestOptions = null + ): Metadata { + $params = Util::removeNulls(['url' => $url]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->getFromURL(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/Files/VersionsRawService.php b/src/Services/Files/VersionsRawService.php new file mode 100644 index 00000000..10c58a31 --- /dev/null +++ b/src/Services/Files/VersionsRawService.php @@ -0,0 +1,158 @@ +> + * + * @throws APIException + */ + public function list( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v1/files/%1$s/versions', $fileID], + options: $requestOptions, + convert: new ListOf(File::class), + ); + } + + /** + * @api + * + * This API deletes a non-current file version permanently. The API returns an empty response. + * + * Note: If you want to delete all versions of a file, use the delete file API. + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param array{fileID: string}|VersionDeleteParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $versionID, + array|VersionDeleteParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = VersionDeleteParams::parseRequest( + $params, + $requestOptions, + ); + $fileID = $parsed['fileID']; + unset($parsed['fileID']); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['v1/files/%1$s/versions/%2$s', $fileID, $versionID], + options: $options, + convert: VersionDeleteResponse::class, + ); + } + + /** + * @api + * + * This API returns an object with details or attributes of a file version. + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param array{fileID: string}|VersionGetParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $versionID, + array|VersionGetParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = VersionGetParams::parseRequest( + $params, + $requestOptions, + ); + $fileID = $parsed['fileID']; + unset($parsed['fileID']); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v1/files/%1$s/versions/%2$s', $fileID, $versionID], + options: $options, + convert: File::class, + ); + } + + /** + * @api + * + * This API restores a file version as the current file version. + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param array{fileID: string}|VersionRestoreParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function restore( + string $versionID, + array|VersionRestoreParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = VersionRestoreParams::parseRequest( + $params, + $requestOptions, + ); + $fileID = $parsed['fileID']; + unset($parsed['fileID']); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'put', + path: ['v1/files/%1$s/versions/%2$s/restore', $fileID, $versionID], + options: $options, + convert: File::class, + ); + } +} diff --git a/src/Services/Files/VersionsService.php b/src/Services/Files/VersionsService.php new file mode 100644 index 00000000..527eadfe --- /dev/null +++ b/src/Services/Files/VersionsService.php @@ -0,0 +1,128 @@ +raw = new VersionsRawService($client); + } + + /** + * @api + * + * This API returns details of all versions of a file. + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @return list + * + * @throws APIException + */ + public function list( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): array { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list($fileID, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API deletes a non-current file version permanently. The API returns an empty response. + * + * Note: If you want to delete all versions of a file, use the delete file API. + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $versionID, + string $fileID, + RequestOptions|array|null $requestOptions = null, + ): VersionDeleteResponse { + $params = Util::removeNulls(['fileID' => $fileID]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($versionID, params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API returns an object with details or attributes of a file version. + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $versionID, + string $fileID, + RequestOptions|array|null $requestOptions = null, + ): File { + $params = Util::removeNulls(['fileID' => $fileID]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get($versionID, params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API restores a file version as the current file version. + * + * @param string $versionID The unique `versionId` of the uploaded file. `versionId` is returned in list and search assets API and upload API. + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function restore( + string $versionID, + string $fileID, + RequestOptions|array|null $requestOptions = null, + ): File { + $params = Util::removeNulls(['fileID' => $fileID]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->restore($versionID, params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/FilesRawService.php b/src/Services/FilesRawService.php new file mode 100644 index 00000000..19c71ac6 --- /dev/null +++ b/src/Services/FilesRawService.php @@ -0,0 +1,313 @@ +, + * description?: string, + * extensions?: list, + * removeAITags?: RemoveAITagsShape, + * tags?: list|null, + * webhookURL?: string, + * publish?: Publish|PublishShape, + * }|FileUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $fileID, + array|FileUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FileUpdateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'patch', + path: ['v1/files/%1$s/details', $fileID], + body: (object) $parsed, + options: $options, + convert: FileUpdateResponse::class, + ); + } + + /** + * @api + * + * This API deletes the file and all its file versions permanently. + * + * Note: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API. + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['v1/files/%1$s', $fileID], + options: $requestOptions, + convert: null, + ); + } + + /** + * @api + * + * This will copy a file from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history. + * + * @param array{ + * destinationPath: string, sourceFilePath: string, includeFileVersions?: bool + * }|FileCopyParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function copy( + array|FileCopyParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FileCopyParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/files/copy', + body: (object) $parsed, + options: $options, + convert: FileCopyResponse::class, + ); + } + + /** + * @api + * + * This API returns an object with details or attributes about the current version of the file. + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in the list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v1/files/%1$s/details', $fileID], + options: $requestOptions, + convert: File::class, + ); + } + + /** + * @api + * + * This will move a file and all its versions from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file. + * + * @param array{ + * destinationPath: string, sourceFilePath: string + * }|FileMoveParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function move( + array|FileMoveParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FileMoveParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/files/move', + body: (object) $parsed, + options: $options, + convert: FileMoveResponse::class, + ); + } + + /** + * @api + * + * You can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. + * + * Note: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested. + * + * @param array{ + * filePath: string, newFileName: string, purgeCache?: bool + * }|FileRenameParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function rename( + array|FileRenameParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FileRenameParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'put', + path: 'v1/files/rename', + body: (object) $parsed, + options: $options, + convert: FileRenameResponse::class, + ); + } + + /** + * @api + * + * ImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload. + * + * The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT. + * + * **File size limit** \ + * On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans. + * + * **Version limit** \ + * A file can have a maximum of 100 versions. + * + * **Demo applications** + * + * - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. + * + * @param array{ + * file: string|FileParam, + * fileName: string, + * token?: string, + * checks?: string, + * customCoordinates?: string, + * customMetadata?: array, + * description?: string, + * expire?: int, + * extensions?: list, + * folder?: string, + * isPrivateFile?: bool, + * isPublished?: bool, + * overwriteAITags?: bool, + * overwriteCustomMetadata?: bool, + * overwriteFile?: bool, + * overwriteTags?: bool, + * publicKey?: string, + * responseFields?: list>, + * signature?: string, + * tags?: list, + * transformation?: Transformation|TransformationShape, + * useUniqueFileName?: bool, + * webhookURL?: string, + * }|FileUploadParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function upload( + array|FileUploadParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FileUploadParams::parseRequest( + $params, + $requestOptions, + ); + $path = $this + ->client + ->baseUrlOverridden ? 'api/v1/files/upload' : 'https://upload.imagekit.io/api/v1/files/upload'; + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: $path, + headers: ['Content-Type' => 'multipart/form-data'], + body: (object) $parsed, + options: $options, + convert: FileUploadResponse::class, + ); + } +} diff --git a/src/Services/FilesService.php b/src/Services/FilesService.php new file mode 100644 index 00000000..18a5d76e --- /dev/null +++ b/src/Services/FilesService.php @@ -0,0 +1,421 @@ +raw = new FilesRawService($client); + $this->bulk = new BulkService($client); + $this->versions = new VersionsService($client); + $this->metadata = new MetadataService($client); + } + + /** + * @api + * + * This API updates the details or attributes of the current version of the file. You can update `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` and apply extensions using this API. + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param string|null $customCoordinates Define an important area in the image in the format `x,y,width,height` e.g. `10,10,100,100`. Send `null` to unset this value. + * @param array $customMetadata A key-value data to be associated with the asset. To unset a key, send `null` value for that key. Before setting any custom metadata on an asset you have to create the field using custom metadata fields API. + * @param string $description optional text to describe the contents of the file + * @param list $extensions Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * @param RemoveAITagsShape $removeAITags An array of AITags associated with the file that you want to remove, e.g. `["car", "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are processed. + * @param list|null $tags An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to unset all tags associated with the file. + * @param string $webhookURL The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + * @param Publish|PublishShape $publish configure the publication status of a file and its versions + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function update( + string $fileID, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?array $extensions = null, + string|array|null $removeAITags = null, + ?array $tags = null, + ?string $webhookURL = null, + Publish|array|null $publish = null, + RequestOptions|array|null $requestOptions = null, + ): FileUpdateResponse { + $params = Util::removeNulls( + [ + 'customCoordinates' => $customCoordinates, + 'customMetadata' => $customMetadata, + 'description' => $description, + 'extensions' => $extensions, + 'removeAITags' => $removeAITags, + 'tags' => $tags, + 'webhookURL' => $webhookURL, + 'publish' => $publish, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->update($fileID, params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API deletes the file and all its file versions permanently. + * + * Note: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API. + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): mixed { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($fileID, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This will copy a file from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history. + * + * @param string $destinationPath full path to the folder you want to copy the above file into + * @param string $sourceFilePath the full path of the file you want to copy + * @param bool $includeFileVersions Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied. Default value - `false`. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function copy( + string $destinationPath, + string $sourceFilePath, + ?bool $includeFileVersions = null, + RequestOptions|array|null $requestOptions = null, + ): FileCopyResponse { + $params = Util::removeNulls( + [ + 'destinationPath' => $destinationPath, + 'sourceFilePath' => $sourceFilePath, + 'includeFileVersions' => $includeFileVersions, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->copy(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API returns an object with details or attributes about the current version of the file. + * + * @param string $fileID The unique `fileId` of the uploaded file. `fileId` is returned in the list and search assets API and upload API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $fileID, + RequestOptions|array|null $requestOptions = null + ): File { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get($fileID, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This will move a file and all its versions from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file. + * + * @param string $destinationPath full path to the folder you want to move the above file into + * @param string $sourceFilePath the full path of the file you want to move + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function move( + string $destinationPath, + string $sourceFilePath, + RequestOptions|array|null $requestOptions = null, + ): FileMoveResponse { + $params = Util::removeNulls( + [ + 'destinationPath' => $destinationPath, + 'sourceFilePath' => $sourceFilePath, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->move(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * You can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. + * + * Note: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested. + * + * @param string $filePath the full path of the file you want to rename + * @param string $newFileName The new name of the file. A filename can contain: + * + * Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals in other languages). + * Special Characters: `.`, `_`, and `-`. + * + * Any other character, including space, will be replaced by `_`. + * @param bool $purgeCache Option to purge cache for the old file and its versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove cached content of old file and its versions. This purge request is counted against your monthly purge quota. + * + * Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will remove the file and its versions' URLs and any transformations made using query parameters on this file or its versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function rename( + string $filePath, + string $newFileName, + ?bool $purgeCache = null, + RequestOptions|array|null $requestOptions = null, + ): FileRenameResponse { + $params = Util::removeNulls( + [ + 'filePath' => $filePath, + 'newFileName' => $newFileName, + 'purgeCache' => $purgeCache, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->rename(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * ImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload. + * + * The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT. + * + * **File size limit** \ + * On the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans. + * + * **Version limit** \ + * A file can have a maximum of 100 versions. + * + * **Demo applications** + * + * - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. + * + * @param string|FileParam $file The API accepts any of the following: + * + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request. + * @param string $fileName The name with which the file has to be uploaded. + * The file name can contain: + * + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * @param string $token A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field. + * @param string $checks Server-side checks to run on the asset. + * Read more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * @param string $customCoordinates Define an important area in the image. This is only relevant for image type files. + * + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be removed. + * @param array $customMetadata JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values. + * @param string $description optional text to describe the contents of the file + * @param int $expire The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side. + * @param list $extensions Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type. + * @param string $folder The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. + * + * The folder name can contain: + * + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * @param bool $isPrivateFile Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or signed URL. + * @param bool $isPublished Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * @param bool $overwriteAITags If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags. + * @param bool $overwriteCustomMetadata if the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed + * @param bool $overwriteFile if `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately + * @param bool $overwriteTags if the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed + * @param string $publicKey Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side. + * @param list> $responseFields array of response field keys to include in the API response body + * @param string $signature HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side. + * @param list $tags Set the tags while uploading the file. + * Provide an array of tag strings (e.g. `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed. + * If this field is not specified and the file is overwritten, the existing tags will be removed. + * @param Transformation|TransformationShape $transformation Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * + * - `pre` — applied before the file is uploaded to the Media Library. + * Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress). + * + * - `post` — applied immediately after upload. + * Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * @param bool $useUniqueFileName Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced. + * @param string $webhookURL The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function upload( + string|FileParam $file, + string $fileName, + ?string $token = null, + ?string $checks = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?int $expire = null, + ?array $extensions = null, + string $folder = '/', + bool $isPrivateFile = false, + bool $isPublished = true, + bool $overwriteAITags = true, + bool $overwriteCustomMetadata = true, + bool $overwriteFile = true, + bool $overwriteTags = true, + ?string $publicKey = null, + ?array $responseFields = null, + ?string $signature = null, + ?array $tags = null, + Transformation|array|null $transformation = null, + bool $useUniqueFileName = true, + ?string $webhookURL = null, + RequestOptions|array|null $requestOptions = null, + ): FileUploadResponse { + $params = Util::removeNulls( + [ + 'file' => $file, + 'fileName' => $fileName, + 'token' => $token, + 'checks' => $checks, + 'customCoordinates' => $customCoordinates, + 'customMetadata' => $customMetadata, + 'description' => $description, + 'expire' => $expire, + 'extensions' => $extensions, + 'folder' => $folder, + 'isPrivateFile' => $isPrivateFile, + 'isPublished' => $isPublished, + 'overwriteAITags' => $overwriteAITags, + 'overwriteCustomMetadata' => $overwriteCustomMetadata, + 'overwriteFile' => $overwriteFile, + 'overwriteTags' => $overwriteTags, + 'publicKey' => $publicKey, + 'responseFields' => $responseFields, + 'signature' => $signature, + 'tags' => $tags, + 'transformation' => $transformation, + 'useUniqueFileName' => $useUniqueFileName, + 'webhookURL' => $webhookURL, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->upload(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/Folders/JobRawService.php b/src/Services/Folders/JobRawService.php new file mode 100644 index 00000000..84c93d8e --- /dev/null +++ b/src/Services/Folders/JobRawService.php @@ -0,0 +1,49 @@ + + * + * @throws APIException + */ + public function get( + string $jobID, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v1/bulkJobs/%1$s', $jobID], + options: $requestOptions, + convert: JobGetResponse::class, + ); + } +} diff --git a/src/Services/Folders/JobService.php b/src/Services/Folders/JobService.php new file mode 100644 index 00000000..9197ed41 --- /dev/null +++ b/src/Services/Folders/JobService.php @@ -0,0 +1,50 @@ +raw = new JobRawService($client); + } + + /** + * @api + * + * This API returns the status of a bulk job like copy and move folder operations. + * + * @param string $jobID The `jobId` is returned in the response of bulk job API e.g. copy folder or move folder API. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $jobID, + RequestOptions|array|null $requestOptions = null + ): JobGetResponse { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get($jobID, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/FoldersRawService.php b/src/Services/FoldersRawService.php new file mode 100644 index 00000000..9c1d0dbb --- /dev/null +++ b/src/Services/FoldersRawService.php @@ -0,0 +1,196 @@ + + * + * @throws APIException + */ + public function create( + array|FolderCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FolderCreateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/folder', + body: (object) $parsed, + options: $options, + convert: FolderNewResponse::class, + ); + } + + /** + * @api + * + * This will delete a folder and all its contents permanently. The API returns an empty response. + * + * @param array{folderPath: string}|FolderDeleteParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + array|FolderDeleteParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FolderDeleteParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: 'v1/folder', + body: (object) $parsed, + options: $options, + convert: FolderDeleteResponse::class, + ); + } + + /** + * @api + * + * This will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history. + * + * @param array{ + * destinationPath: string, sourceFolderPath: string, includeVersions?: bool + * }|FolderCopyParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function copy( + array|FolderCopyParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FolderCopyParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/bulkJobs/copyFolder', + body: (object) $parsed, + options: $options, + convert: FolderCopyResponse::class, + ); + } + + /** + * @api + * + * This will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history. + * + * @param array{ + * destinationPath: string, sourceFolderPath: string + * }|FolderMoveParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function move( + array|FolderMoveParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FolderMoveParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/bulkJobs/moveFolder', + body: (object) $parsed, + options: $options, + convert: FolderMoveResponse::class, + ); + } + + /** + * @api + * + * This API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name. + * + * @param array{ + * folderPath: string, newFolderName: string, purgeCache?: bool + * }|FolderRenameParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function rename( + array|FolderRenameParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = FolderRenameParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/bulkJobs/renameFolder', + body: (object) $parsed, + options: $options, + convert: FolderRenameResponse::class, + ); + } +} diff --git a/src/Services/FoldersService.php b/src/Services/FoldersService.php new file mode 100644 index 00000000..8b5d95f4 --- /dev/null +++ b/src/Services/FoldersService.php @@ -0,0 +1,195 @@ +raw = new FoldersRawService($client); + $this->job = new JobService($client); + } + + /** + * @api + * + * This will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created. + * + * @param string $folderName The folder will be created with this name. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) will be replaced by an underscore i.e. `_`. + * @param string $parentFolderPath The folder where the new folder should be created, for root use `/` else the path e.g. `containing/folder/`. + * + * Note: If any folder(s) is not present in the parentFolderPath parameter, it will be automatically created. For example, if you pass `/product/images/summer`, then `product`, `images`, and `summer` folders will be created if they don't already exist. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function create( + string $folderName, + string $parentFolderPath, + RequestOptions|array|null $requestOptions = null, + ): FolderNewResponse { + $params = Util::removeNulls( + ['folderName' => $folderName, 'parentFolderPath' => $parentFolderPath] + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->create(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This will delete a folder and all its contents permanently. The API returns an empty response. + * + * @param string $folderPath Full path to the folder you want to delete. For example `/folder/to/delete/`. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $folderPath, + RequestOptions|array|null $requestOptions = null + ): FolderDeleteResponse { + $params = Util::removeNulls(['folderPath' => $folderPath]); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history. + * + * @param string $destinationPath full path to the destination folder where you want to copy the source folder into + * @param string $sourceFolderPath the full path to the source folder you want to copy + * @param bool $includeVersions Option to copy all versions of files that are nested inside the selected folder. By default, only the current version of each file will be copied. When set to true, all versions of each file will be copied. Default value - `false`. + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function copy( + string $destinationPath, + string $sourceFolderPath, + ?bool $includeVersions = null, + RequestOptions|array|null $requestOptions = null, + ): FolderCopyResponse { + $params = Util::removeNulls( + [ + 'destinationPath' => $destinationPath, + 'sourceFolderPath' => $sourceFolderPath, + 'includeVersions' => $includeVersions, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->copy(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history. + * + * @param string $destinationPath full path to the destination folder where you want to move the source folder into + * @param string $sourceFolderPath the full path to the source folder you want to move + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function move( + string $destinationPath, + string $sourceFolderPath, + RequestOptions|array|null $requestOptions = null, + ): FolderMoveResponse { + $params = Util::removeNulls( + [ + 'destinationPath' => $destinationPath, + 'sourceFolderPath' => $sourceFolderPath, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->move(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name. + * + * @param string $folderPath the full path to the folder you want to rename + * @param string $newFolderName The new name for the folder. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) and `-` will be replaced by an underscore i.e. `_`. + * @param bool $purgeCache Option to purge cache for the old nested files and their versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove the cached content of the old nested files and their versions. There will only be one purge request for all the nested files, which will be counted against your monthly purge quota. + * + * Note: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove all nested files, their versions' URLs, and any transformations made using query parameters on these files or their versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation. + * + * Default value - `false` + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function rename( + string $folderPath, + string $newFolderName, + ?bool $purgeCache = null, + RequestOptions|array|null $requestOptions = null, + ): FolderRenameResponse { + $params = Util::removeNulls( + [ + 'folderPath' => $folderPath, + 'newFolderName' => $newFolderName, + 'purgeCache' => $purgeCache, + ], + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->rename(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/SavedExtensionsRawService.php b/src/Services/SavedExtensionsRawService.php new file mode 100644 index 00000000..17f551b5 --- /dev/null +++ b/src/Services/SavedExtensionsRawService.php @@ -0,0 +1,172 @@ + + * + * @throws APIException + */ + public function create( + array|SavedExtensionCreateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = SavedExtensionCreateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'post', + path: 'v1/saved-extensions', + body: (object) $parsed, + options: $options, + convert: SavedExtension::class, + ); + } + + /** + * @api + * + * This API updates an existing saved extension. You can update the name, description, or config. + * + * @param string $id the unique ID of the saved extension + * @param array{ + * config?: ExtensionConfigShape, description?: string, name?: string + * }|SavedExtensionUpdateParams $params + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function update( + string $id, + array|SavedExtensionUpdateParams $params, + RequestOptions|array|null $requestOptions = null, + ): BaseResponse { + [$parsed, $options] = SavedExtensionUpdateParams::parseRequest( + $params, + $requestOptions, + ); + + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'patch', + path: ['v1/saved-extensions/%1$s', $id], + body: (object) $parsed, + options: $options, + convert: SavedExtension::class, + ); + } + + /** + * @api + * + * This API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs. + * + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse> + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: 'v1/saved-extensions', + options: $requestOptions, + convert: new ListOf(SavedExtension::class), + ); + } + + /** + * @api + * + * This API deletes a saved extension permanently. + * + * @param string $id the unique ID of the saved extension + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'delete', + path: ['v1/saved-extensions/%1$s', $id], + options: $requestOptions, + convert: null, + ); + } + + /** + * @api + * + * This API returns details of a specific saved extension by ID. + * + * @param string $id the unique ID of the saved extension + * @param RequestOpts|null $requestOptions + * + * @return BaseResponse + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): BaseResponse { + // @phpstan-ignore-next-line return.type + return $this->client->request( + method: 'get', + path: ['v1/saved-extensions/%1$s', $id], + options: $requestOptions, + convert: SavedExtension::class, + ); + } +} diff --git a/src/Services/SavedExtensionsService.php b/src/Services/SavedExtensionsService.php new file mode 100644 index 00000000..d296f313 --- /dev/null +++ b/src/Services/SavedExtensionsService.php @@ -0,0 +1,157 @@ +raw = new SavedExtensionsRawService($client); + } + + /** + * @api + * + * This API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs. + * + * **Saved extension limit** \ + * You can create a maximum of 100 saved extensions per account. + * + * @param ExtensionConfigShape $config configuration object for an extension (base extensions only, not saved extension references) + * @param string $description description of what the saved extension does + * @param string $name name of the saved extension + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function create( + RemovedotBgExtension|array|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension $config, + string $description, + string $name, + RequestOptions|array|null $requestOptions = null, + ): SavedExtension { + $params = Util::removeNulls( + ['config' => $config, 'description' => $description, 'name' => $name] + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->create(params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API updates an existing saved extension. You can update the name, description, or config. + * + * @param string $id the unique ID of the saved extension + * @param ExtensionConfigShape $config configuration object for an extension (base extensions only, not saved extension references) + * @param string $description updated description of the saved extension + * @param string $name updated name of the saved extension + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function update( + string $id, + RemovedotBgExtension|array|AutoTaggingExtension|AutoDescriptionExtension|AITasksExtension|null $config = null, + ?string $description = null, + ?string $name = null, + RequestOptions|array|null $requestOptions = null, + ): SavedExtension { + $params = Util::removeNulls( + ['config' => $config, 'description' => $description, 'name' => $name] + ); + + // @phpstan-ignore-next-line argument.type + $response = $this->raw->update($id, params: $params, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs. + * + * @param RequestOpts|null $requestOptions + * + * @return list + * + * @throws APIException + */ + public function list( + RequestOptions|array|null $requestOptions = null + ): array { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->list(requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API deletes a saved extension permanently. + * + * @param string $id the unique ID of the saved extension + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function delete( + string $id, + RequestOptions|array|null $requestOptions = null + ): mixed { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->delete($id, requestOptions: $requestOptions); + + return $response->parse(); + } + + /** + * @api + * + * This API returns details of a specific saved extension by ID. + * + * @param string $id the unique ID of the saved extension + * @param RequestOpts|null $requestOptions + * + * @throws APIException + */ + public function get( + string $id, + RequestOptions|array|null $requestOptions = null + ): SavedExtension { + // @phpstan-ignore-next-line argument.type + $response = $this->raw->get($id, requestOptions: $requestOptions); + + return $response->parse(); + } +} diff --git a/src/Services/WebhooksRawService.php b/src/Services/WebhooksRawService.php new file mode 100644 index 00000000..4802ba05 --- /dev/null +++ b/src/Services/WebhooksRawService.php @@ -0,0 +1,17 @@ +raw = new WebhooksRawService($client); + } + + /** + * @api + * + * Unwraps a webhook event from its JSON representation. + * + * @throws WebhookException + */ + public function unsafeUnwrap( + string $body + ): VideoTransformationAcceptedEvent|VideoTransformationReadyEvent|VideoTransformationErrorEvent|UploadPreTransformSuccessEvent|UploadPreTransformErrorEvent|UploadPostTransformSuccessEvent|UploadPostTransformErrorEvent|FileCreateEvent|FileUpdateEvent|FileDeleteEvent|FileVersionCreateEvent|FileVersionDeleteEvent { + try { + $decoded = Util::decodeJson($body); + + // @phpstan-ignore return.type + return Conversion::coerce(UnsafeUnwrapWebhookEvent::class, value: $decoded); + } catch (\Throwable $e) { + throw new WebhookException('Error parsing webhook body', previous: $e); + } + } + + /** + * @api + * + * Unwraps a webhook event from its JSON representation. + * + * @param array>|null $headers + * + * @throws WebhookException + */ + public function unwrap( + string $body, + ?array $headers = null, + ?string $secret = null + ): VideoTransformationAcceptedEvent|VideoTransformationReadyEvent|VideoTransformationErrorEvent|UploadPreTransformSuccessEvent|UploadPreTransformErrorEvent|UploadPostTransformSuccessEvent|UploadPostTransformErrorEvent|FileCreateEvent|FileUpdateEvent|FileDeleteEvent|FileVersionCreateEvent|FileVersionDeleteEvent { + if (!is_null($headers)) { + $secret = $secret ?? ($this->client->webhookSecret ?: null); + if (is_null($secret)) { + throw new WebhookException('Webhook key must not be null in order to unwrap'); + } + + try { + $flatHeaders = array_map(fn (string|array $v): string => is_array($v) ? $v[0] : $v, $headers); + $webhook = new Webhook($secret); + $webhook->verify($body, $flatHeaders); + } catch (WebhookVerificationException $e) { + throw new WebhookException('Could not verify webhook event signature', previous: $e); + } + } + + try { + $decoded = Util::decodeJson($body); + + // @phpstan-ignore return.type + return Conversion::coerce(UnwrapWebhookEvent::class, value: $decoded); + } catch (\Throwable $e) { + throw new WebhookException('Error parsing webhook body', previous: $e); + } + } +} diff --git a/src/SolidColorOverlay.php b/src/SolidColorOverlay.php new file mode 100644 index 00000000..e341af17 --- /dev/null +++ b/src/SolidColorOverlay.php @@ -0,0 +1,197 @@ +, + * position?: null|OverlayPosition|OverlayPositionShape, + * timing?: null|OverlayTiming|OverlayTimingShape, + * color: string, + * type: 'solidColor', + * transformation?: list|null, + * } + */ +final class SolidColorOverlay implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var 'solidColor' $type */ + #[Required] + public string $type = 'solidColor'; + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @var value-of|null $layerMode + */ + #[Optional(enum: LayerMode::class)] + public ?string $layerMode; + + #[Optional] + public ?OverlayPosition $position; + + #[Optional] + public ?OverlayTiming $timing; + + /** + * Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name (e.g., `red`). + * If an 8-character value is provided, the last two characters represent the opacity level (from `00` for 0.00 to `99` for 0.99). + */ + #[Required] + public string $color; + + /** + * Control width and height of the solid color overlay. Supported transformations depend on the base/parent asset. + * See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) and [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + * + * @var list|null $transformation + */ + #[Optional(list: SolidColorOverlayTransformation::class)] + public ?array $transformation; + + /** + * `new SolidColorOverlay()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SolidColorOverlay::with(color: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SolidColorOverlay)->withColor(...) + * ``` + */ + 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 LayerMode|value-of|null $layerMode + * @param OverlayPosition|OverlayPositionShape|null $position + * @param OverlayTiming|OverlayTimingShape|null $timing + * @param list|null $transformation + */ + public static function with( + string $color, + LayerMode|string|null $layerMode = null, + OverlayPosition|array|null $position = null, + OverlayTiming|array|null $timing = null, + ?array $transformation = null, + ): self { + $self = new self; + + $self['color'] = $color; + + null !== $layerMode && $self['layerMode'] = $layerMode; + null !== $position && $self['position'] = $position; + null !== $timing && $self['timing'] = $timing; + null !== $transformation && $self['transformation'] = $transformation; + + return $self; + } + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @param LayerMode|value-of $layerMode + */ + public function withLayerMode(LayerMode|string $layerMode): self + { + $self = clone $this; + $self['layerMode'] = $layerMode; + + return $self; + } + + /** + * @param OverlayPosition|OverlayPositionShape $position + */ + public function withPosition(OverlayPosition|array $position): self + { + $self = clone $this; + $self['position'] = $position; + + return $self; + } + + /** + * @param OverlayTiming|OverlayTimingShape $timing + */ + public function withTiming(OverlayTiming|array $timing): self + { + $self = clone $this; + $self['timing'] = $timing; + + return $self; + } + + /** + * Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name (e.g., `red`). + * If an 8-character value is provided, the last two characters represent the opacity level (from `00` for 0.00 to `99` for 0.99). + */ + public function withColor(string $color): self + { + $self = clone $this; + $self['color'] = $color; + + return $self; + } + + /** + * @param 'solidColor' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Control width and height of the solid color overlay. Supported transformations depend on the base/parent asset. + * See overlays on [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) and [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + * + * @param list $transformation + */ + public function withTransformation(array $transformation): self + { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } +} diff --git a/src/SolidColorOverlayTransformation.php b/src/SolidColorOverlayTransformation.php new file mode 100644 index 00000000..52e5149b --- /dev/null +++ b/src/SolidColorOverlayTransformation.php @@ -0,0 +1,201 @@ + */ + use SdkModel; + + /** + * Specifies the transparency level of the overlaid solid color layer. Supports integers from `1` to `9`. + */ + #[Optional] + public ?float $alpha; + + /** + * Specifies the background color of the solid color overlay. Accepts an RGB hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + */ + #[Optional] + public ?string $background; + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a string for a custom gradient. + * Only works if the base asset is an image. See [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + * + * @var GradientVariants|null $gradient + */ + #[Optional] + public string|bool|null $gradient; + + /** + * Controls the height of the solid color overlay. Accepts a numeric value or an arithmetic expression. + * Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @var HeightVariants|null $height + */ + #[Optional] + public float|string|null $height; + + /** + * Specifies the corner radius of the solid color overlay. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + * See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * + * @var RadiusVariants|null $radius + */ + #[Optional] + public float|string|null $radius; + + /** + * Controls the width of the solid color overlay. Accepts a numeric value or an arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). + * Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @var WidthVariants|null $width + */ + #[Optional] + public float|string|null $width; + + 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 GradientShape|null $gradient + * @param HeightShape|null $height + * @param RadiusShape|null $radius + * @param WidthShape|null $width + */ + public static function with( + ?float $alpha = null, + ?string $background = null, + string|bool|null $gradient = null, + float|string|null $height = null, + float|string|null $radius = null, + float|string|null $width = null, + ): self { + $self = new self; + + null !== $alpha && $self['alpha'] = $alpha; + null !== $background && $self['background'] = $background; + null !== $gradient && $self['gradient'] = $gradient; + null !== $height && $self['height'] = $height; + null !== $radius && $self['radius'] = $radius; + null !== $width && $self['width'] = $width; + + return $self; + } + + /** + * Specifies the transparency level of the overlaid solid color layer. Supports integers from `1` to `9`. + */ + public function withAlpha(float $alpha): self + { + $self = clone $this; + $self['alpha'] = $alpha; + + return $self; + } + + /** + * Specifies the background color of the solid color overlay. Accepts an RGB hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + */ + public function withBackground(string $background): self + { + $self = clone $this; + $self['background'] = $background; + + return $self; + } + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a string for a custom gradient. + * Only works if the base asset is an image. See [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + * + * @param GradientShape $gradient + */ + public function withGradient(string|bool $gradient): self + { + $self = clone $this; + $self['gradient'] = $gradient; + + return $self; + } + + /** + * Controls the height of the solid color overlay. Accepts a numeric value or an arithmetic expression. + * Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @param HeightShape $height + */ + public function withHeight(float|string $height): self + { + $self = clone $this; + $self['height'] = $height; + + return $self; + } + + /** + * Specifies the corner radius of the solid color overlay. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + * See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * + * @param RadiusShape $radius + */ + public function withRadius(float|string $radius): self + { + $self = clone $this; + $self['radius'] = $radius; + + return $self; + } + + /** + * Controls the width of the solid color overlay. Accepts a numeric value or an arithmetic expression (e.g., `bw_mul_0.2` or `bh_div_2`). + * Learn about [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @param WidthShape $width + */ + public function withWidth(float|string $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/SolidColorOverlayTransformation/Gradient.php b/src/SolidColorOverlayTransformation/Gradient.php new file mode 100644 index 00000000..cb98110e --- /dev/null +++ b/src/SolidColorOverlayTransformation/Gradient.php @@ -0,0 +1,29 @@ +|array + */ + public static function variants(): array + { + return ['bool', 'string']; + } +} diff --git a/src/SolidColorOverlayTransformation/Height.php b/src/SolidColorOverlayTransformation/Height.php new file mode 100644 index 00000000..eab71847 --- /dev/null +++ b/src/SolidColorOverlayTransformation/Height.php @@ -0,0 +1,29 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/SolidColorOverlayTransformation/Radius.php b/src/SolidColorOverlayTransformation/Radius.php new file mode 100644 index 00000000..a181fec0 --- /dev/null +++ b/src/SolidColorOverlayTransformation/Radius.php @@ -0,0 +1,32 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string', 'string']; + } +} diff --git a/src/SolidColorOverlayTransformation/Width.php b/src/SolidColorOverlayTransformation/Width.php new file mode 100644 index 00000000..0eaf990e --- /dev/null +++ b/src/SolidColorOverlayTransformation/Width.php @@ -0,0 +1,29 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/SrcOptions.php b/src/SrcOptions.php new file mode 100644 index 00000000..6363bf6a --- /dev/null +++ b/src/SrcOptions.php @@ -0,0 +1,244 @@ +|null, + * signed?: bool|null, + * transformation?: list|null, + * transformationPosition?: null|TransformationPosition|value-of, + * } + */ +final class SrcOptions implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Accepts a relative or absolute path of the resource. If a relative path is provided, it is appended to the `urlEndpoint`. + * If an absolute path is provided, `urlEndpoint` is ignored. + */ + #[Required] + public string $src; + + /** + * Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + */ + #[Required] + public string $urlEndpoint; + + /** + * When you want the signed URL to expire, specified in seconds. If `expiresIn` is anything above 0, + * the URL will always be signed even if `signed` is set to false. If not specified and `signed` is `true`, + * the signed URL will not expire (valid indefinitely). + * + * Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation time. After the expiry time, the signed URL will no longer be valid and ImageKit will return + * a 401 Unauthorized status code. + * + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + #[Optional] + public ?float $expiresIn; + + /** + * These are additional query parameters that you want to add to the final URL. + * They can be any query parameters and not necessarily related to ImageKit. + * This is especially useful if you want to add a versioning parameter to your URLs. + * + * @var array|null $queryParameters + */ + #[Optional(map: 'string')] + public ?array $queryParameters; + + /** + * Whether to sign the URL or not. Set this to `true` if you want to generate a signed URL. + * If `signed` is `true` and `expiresIn` is not specified, the signed URL will not expire (valid indefinitely). + * Note: If `expiresIn` is set to any value above 0, the URL will always be signed regardless of this setting. + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + #[Optional] + public ?bool $signed; + + /** + * An array of objects specifying the transformations to be applied in the URL. If more than one transformation is specified, they are applied in the order they are specified as chained transformations. + * See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + * + * @var list|null $transformation + */ + #[Optional(list: Transformation::class)] + public ?array $transformation; + + /** + * By default, the transformation string is added as a query parameter in the URL, e.g., `?tr=w-100,h-100`. + * If you want to add the transformation string in the path of the URL, set this to `path`. + * Learn more in the [Transformations guide](https://imagekit.io/docs/transformations). + * + * @var value-of|null $transformationPosition + */ + #[Optional(enum: TransformationPosition::class)] + public ?string $transformationPosition; + + /** + * `new SrcOptions()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SrcOptions::with(src: ..., urlEndpoint: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SrcOptions)->withSrc(...)->withURLEndpoint(...) + * ``` + */ + 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 array|null $queryParameters + * @param list|null $transformation + * @param TransformationPosition|value-of|null $transformationPosition + */ + public static function with( + string $src, + string $urlEndpoint, + ?float $expiresIn = null, + ?array $queryParameters = null, + ?bool $signed = null, + ?array $transformation = null, + TransformationPosition|string|null $transformationPosition = null, + ): self { + $self = new self; + + $self['src'] = $src; + $self['urlEndpoint'] = $urlEndpoint; + + null !== $expiresIn && $self['expiresIn'] = $expiresIn; + null !== $queryParameters && $self['queryParameters'] = $queryParameters; + null !== $signed && $self['signed'] = $signed; + null !== $transformation && $self['transformation'] = $transformation; + null !== $transformationPosition && $self['transformationPosition'] = $transformationPosition; + + return $self; + } + + /** + * Accepts a relative or absolute path of the resource. If a relative path is provided, it is appended to the `urlEndpoint`. + * If an absolute path is provided, `urlEndpoint` is ignored. + */ + public function withSrc(string $src): self + { + $self = clone $this; + $self['src'] = $src; + + return $self; + } + + /** + * Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + */ + public function withURLEndpoint(string $urlEndpoint): self + { + $self = clone $this; + $self['urlEndpoint'] = $urlEndpoint; + + return $self; + } + + /** + * When you want the signed URL to expire, specified in seconds. If `expiresIn` is anything above 0, + * the URL will always be signed even if `signed` is set to false. If not specified and `signed` is `true`, + * the signed URL will not expire (valid indefinitely). + * + * Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation time. After the expiry time, the signed URL will no longer be valid and ImageKit will return + * a 401 Unauthorized status code. + * + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + public function withExpiresIn(float $expiresIn): self + { + $self = clone $this; + $self['expiresIn'] = $expiresIn; + + return $self; + } + + /** + * These are additional query parameters that you want to add to the final URL. + * They can be any query parameters and not necessarily related to ImageKit. + * This is especially useful if you want to add a versioning parameter to your URLs. + * + * @param array $queryParameters + */ + public function withQueryParameters(array $queryParameters): self + { + $self = clone $this; + $self['queryParameters'] = $queryParameters; + + return $self; + } + + /** + * Whether to sign the URL or not. Set this to `true` if you want to generate a signed URL. + * If `signed` is `true` and `expiresIn` is not specified, the signed URL will not expire (valid indefinitely). + * Note: If `expiresIn` is set to any value above 0, the URL will always be signed regardless of this setting. + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + public function withSigned(bool $signed): self + { + $self = clone $this; + $self['signed'] = $signed; + + return $self; + } + + /** + * An array of objects specifying the transformations to be applied in the URL. If more than one transformation is specified, they are applied in the order they are specified as chained transformations. + * See [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + * + * @param list $transformation + */ + public function withTransformation(array $transformation): self + { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * By default, the transformation string is added as a query parameter in the URL, e.g., `?tr=w-100,h-100`. + * If you want to add the transformation string in the path of the URL, set this to `path`. + * Learn more in the [Transformations guide](https://imagekit.io/docs/transformations). + * + * @param TransformationPosition|value-of $transformationPosition + */ + public function withTransformationPosition( + TransformationPosition|string $transformationPosition + ): self { + $self = clone $this; + $self['transformationPosition'] = $transformationPosition; + + return $self; + } +} diff --git a/src/StreamingResolution.php b/src/StreamingResolution.php new file mode 100644 index 00000000..350f8215 --- /dev/null +++ b/src/StreamingResolution.php @@ -0,0 +1,25 @@ +, + * position?: null|OverlayPosition|OverlayPositionShape, + * timing?: null|OverlayTiming|OverlayTimingShape, + * input: string, + * type: 'subtitle', + * encoding?: null|Encoding|value-of, + * transformation?: list|null, + * } + */ +final class SubtitleOverlay implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var 'subtitle' $type */ + #[Required] + public string $type = 'subtitle'; + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @var value-of|null $layerMode + */ + #[Optional(enum: LayerMode::class)] + public ?string $layerMode; + + #[Optional] + public ?OverlayPosition $position; + + #[Optional] + public ?OverlayTiming $timing; + + /** + * Specifies the relative path to the subtitle file used as an overlay. + */ + #[Required] + public string $input; + + /** + * The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + * By default, the SDK determines the appropriate format automatically. + * To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. + * + * @var value-of|null $encoding + */ + #[Optional(enum: Encoding::class)] + public ?string $encoding; + + /** + * Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + * + * @var list|null $transformation + */ + #[Optional(list: SubtitleOverlayTransformation::class)] + public ?array $transformation; + + /** + * `new SubtitleOverlay()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SubtitleOverlay::with(input: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SubtitleOverlay)->withInput(...) + * ``` + */ + 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 LayerMode|value-of|null $layerMode + * @param OverlayPosition|OverlayPositionShape|null $position + * @param OverlayTiming|OverlayTimingShape|null $timing + * @param Encoding|value-of|null $encoding + * @param list|null $transformation + */ + public static function with( + string $input, + LayerMode|string|null $layerMode = null, + OverlayPosition|array|null $position = null, + OverlayTiming|array|null $timing = null, + Encoding|string|null $encoding = null, + ?array $transformation = null, + ): self { + $self = new self; + + $self['input'] = $input; + + null !== $layerMode && $self['layerMode'] = $layerMode; + null !== $position && $self['position'] = $position; + null !== $timing && $self['timing'] = $timing; + null !== $encoding && $self['encoding'] = $encoding; + null !== $transformation && $self['transformation'] = $transformation; + + return $self; + } + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @param LayerMode|value-of $layerMode + */ + public function withLayerMode(LayerMode|string $layerMode): self + { + $self = clone $this; + $self['layerMode'] = $layerMode; + + return $self; + } + + /** + * @param OverlayPosition|OverlayPositionShape $position + */ + public function withPosition(OverlayPosition|array $position): self + { + $self = clone $this; + $self['position'] = $position; + + return $self; + } + + /** + * @param OverlayTiming|OverlayTimingShape $timing + */ + public function withTiming(OverlayTiming|array $timing): self + { + $self = clone $this; + $self['timing'] = $timing; + + return $self; + } + + /** + * Specifies the relative path to the subtitle file used as an overlay. + */ + public function withInput(string $input): self + { + $self = clone $this; + $self['input'] = $input; + + return $self; + } + + /** + * @param 'subtitle' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + * By default, the SDK determines the appropriate format automatically. + * To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. + * + * @param Encoding|value-of $encoding + */ + public function withEncoding(Encoding|string $encoding): self + { + $self = clone $this; + $self['encoding'] = $encoding; + + return $self; + } + + /** + * Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + * + * @param list $transformation + */ + public function withTransformation(array $transformation): self + { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } +} diff --git a/src/SubtitleOverlay/Encoding.php b/src/SubtitleOverlay/Encoding.php new file mode 100644 index 00000000..d234a9ff --- /dev/null +++ b/src/SubtitleOverlay/Encoding.php @@ -0,0 +1,24 @@ +, + * } + */ +final class SubtitleOverlayTransformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Specifies the subtitle background color using a standard color name, an RGB color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + #[Optional] + public ?string $background; + + /** + * Sets the font color of the subtitle text using a standard color name, an RGB color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + #[Optional] + public ?string $color; + + /** + * Sets the font family of subtitle text. + * Refer to the [supported fonts documented](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) in the ImageKit transformations guide. + */ + #[Optional] + public ?string $fontFamily; + + /** + * Sets the font outline of the subtitle text. + * Requires the outline width (an integer) and the outline color (as an RGB color code, RGBA color code, or standard web color name) separated by an underscore. + * Example: `fol-2_blue` (outline width of 2px and outline color blue), `fol-2_A1CCDD` (outline width of 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` (outline width of 2px and outline color `#A1CCDD` at 50% opacity). + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + #[Optional] + public ?string $fontOutline; + + /** + * Sets the font shadow for the subtitle text. + * Requires the shadow color (as an RGB color code, RGBA color code, or standard web color name) and shadow indent (an integer) separated by an underscore. + * Example: `fsh-blue_2` (shadow color blue, indent of 2px), `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent of 3px), `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, indent of 3px). + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + #[Optional] + public ?string $fontShadow; + + /** + * Sets the font size of subtitle text. + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + #[Optional] + public ?float $fontSize; + + /** + * Sets the typography style of the subtitle text. Supports values are `b` for bold, `i` for italics, and `b_i` for bold with italics. + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + * + * @var value-of|null $typography + */ + #[Optional(enum: Typography::class)] + public ?string $typography; + + 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 Typography|value-of|null $typography + */ + public static function with( + ?string $background = null, + ?string $color = null, + ?string $fontFamily = null, + ?string $fontOutline = null, + ?string $fontShadow = null, + ?float $fontSize = null, + Typography|string|null $typography = null, + ): self { + $self = new self; + + null !== $background && $self['background'] = $background; + null !== $color && $self['color'] = $color; + null !== $fontFamily && $self['fontFamily'] = $fontFamily; + null !== $fontOutline && $self['fontOutline'] = $fontOutline; + null !== $fontShadow && $self['fontShadow'] = $fontShadow; + null !== $fontSize && $self['fontSize'] = $fontSize; + null !== $typography && $self['typography'] = $typography; + + return $self; + } + + /** + * Specifies the subtitle background color using a standard color name, an RGB color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + public function withBackground(string $background): self + { + $self = clone $this; + $self['background'] = $background; + + return $self; + } + + /** + * Sets the font color of the subtitle text using a standard color name, an RGB color code (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + public function withColor(string $color): self + { + $self = clone $this; + $self['color'] = $color; + + return $self; + } + + /** + * Sets the font family of subtitle text. + * Refer to the [supported fonts documented](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) in the ImageKit transformations guide. + */ + public function withFontFamily(string $fontFamily): self + { + $self = clone $this; + $self['fontFamily'] = $fontFamily; + + return $self; + } + + /** + * Sets the font outline of the subtitle text. + * Requires the outline width (an integer) and the outline color (as an RGB color code, RGBA color code, or standard web color name) separated by an underscore. + * Example: `fol-2_blue` (outline width of 2px and outline color blue), `fol-2_A1CCDD` (outline width of 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` (outline width of 2px and outline color `#A1CCDD` at 50% opacity). + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + public function withFontOutline(string $fontOutline): self + { + $self = clone $this; + $self['fontOutline'] = $fontOutline; + + return $self; + } + + /** + * Sets the font shadow for the subtitle text. + * Requires the shadow color (as an RGB color code, RGBA color code, or standard web color name) and shadow indent (an integer) separated by an underscore. + * Example: `fsh-blue_2` (shadow color blue, indent of 2px), `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent of 3px), `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, indent of 3px). + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + public function withFontShadow(string $fontShadow): self + { + $self = clone $this; + $self['fontShadow'] = $fontShadow; + + return $self; + } + + /** + * Sets the font size of subtitle text. + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + public function withFontSize(float $fontSize): self + { + $self = clone $this; + $self['fontSize'] = $fontSize; + + return $self; + } + + /** + * Sets the typography style of the subtitle text. Supports values are `b` for bold, `i` for italics, and `b_i` for bold with italics. + * + * [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + * + * @param Typography|value-of $typography + */ + public function withTypography(Typography|string $typography): self + { + $self = clone $this; + $self['typography'] = $typography; + + return $self; + } +} diff --git a/src/SubtitleOverlayTransformation/Typography.php b/src/SubtitleOverlayTransformation/Typography.php new file mode 100644 index 00000000..da7d956d --- /dev/null +++ b/src/SubtitleOverlayTransformation/Typography.php @@ -0,0 +1,19 @@ +, + * position?: null|OverlayPosition|OverlayPositionShape, + * timing?: null|OverlayTiming|OverlayTimingShape, + * text: string, + * type: 'text', + * encoding?: null|Encoding|value-of, + * transformation?: list|null, + * } + */ +final class TextOverlay implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var 'text' $type */ + #[Required] + public string $type = 'text'; + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @var value-of|null $layerMode + */ + #[Optional(enum: LayerMode::class)] + public ?string $layerMode; + + #[Optional] + public ?OverlayPosition $position; + + #[Optional] + public ?OverlayTiming $timing; + + /** + * Specifies the text to be displayed in the overlay. The SDK automatically handles special characters and encoding. + */ + #[Required] + public string $text; + + /** + * Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` (base64). + * By default, the SDK selects the appropriate format based on the input text. + * To always use base64 (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method, the input text is always percent-encoded to ensure it is URL-safe. + * + * @var value-of|null $encoding + */ + #[Optional(enum: Encoding::class)] + public ?string $encoding; + + /** + * Control styling of the text overlay. See [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + * + * @var list|null $transformation + */ + #[Optional(list: TextOverlayTransformation::class)] + public ?array $transformation; + + /** + * `new TextOverlay()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * TextOverlay::with(text: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new TextOverlay)->withText(...) + * ``` + */ + 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 LayerMode|value-of|null $layerMode + * @param OverlayPosition|OverlayPositionShape|null $position + * @param OverlayTiming|OverlayTimingShape|null $timing + * @param Encoding|value-of|null $encoding + * @param list|null $transformation + */ + public static function with( + string $text, + LayerMode|string|null $layerMode = null, + OverlayPosition|array|null $position = null, + OverlayTiming|array|null $timing = null, + Encoding|string|null $encoding = null, + ?array $transformation = null, + ): self { + $self = new self; + + $self['text'] = $text; + + null !== $layerMode && $self['layerMode'] = $layerMode; + null !== $position && $self['position'] = $position; + null !== $timing && $self['timing'] = $timing; + null !== $encoding && $self['encoding'] = $encoding; + null !== $transformation && $self['transformation'] = $transformation; + + return $self; + } + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @param LayerMode|value-of $layerMode + */ + public function withLayerMode(LayerMode|string $layerMode): self + { + $self = clone $this; + $self['layerMode'] = $layerMode; + + return $self; + } + + /** + * @param OverlayPosition|OverlayPositionShape $position + */ + public function withPosition(OverlayPosition|array $position): self + { + $self = clone $this; + $self['position'] = $position; + + return $self; + } + + /** + * @param OverlayTiming|OverlayTimingShape $timing + */ + public function withTiming(OverlayTiming|array $timing): self + { + $self = clone $this; + $self['timing'] = $timing; + + return $self; + } + + /** + * Specifies the text to be displayed in the overlay. The SDK automatically handles special characters and encoding. + */ + public function withText(string $text): self + { + $self = clone $this; + $self['text'] = $text; + + return $self; + } + + /** + * @param 'text' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Text can be included in the layer as either `i-{input}` (plain text) or `ie-{base64_encoded_input}` (base64). + * By default, the SDK selects the appropriate format based on the input text. + * To always use base64 (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method, the input text is always percent-encoded to ensure it is URL-safe. + * + * @param Encoding|value-of $encoding + */ + public function withEncoding(Encoding|string $encoding): self + { + $self = clone $this; + $self['encoding'] = $encoding; + + return $self; + } + + /** + * Control styling of the text overlay. See [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + * + * @param list $transformation + */ + public function withTransformation(array $transformation): self + { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } +} diff --git a/src/TextOverlay/Encoding.php b/src/TextOverlay/Encoding.php new file mode 100644 index 00000000..ad8dbcf2 --- /dev/null +++ b/src/TextOverlay/Encoding.php @@ -0,0 +1,22 @@ +, + * fontColor?: string|null, + * fontFamily?: string|null, + * fontSize?: FontSizeShape|null, + * innerAlignment?: null|InnerAlignment|value-of, + * lineHeight?: LineHeightShape|null, + * padding?: PaddingShape|null, + * radius?: RadiusShape|null, + * rotation?: RotationShape|null, + * typography?: string|null, + * width?: WidthShape|null, + * } + */ +final class TextOverlayTransformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Specifies the transparency level of the text overlay. Accepts integers from `1` to `9`. + */ + #[Optional] + public ?float $alpha; + + /** + * Specifies the background color of the text overlay. + * Accepts an RGB hex code, an RGBA code, or a color name. + */ + #[Optional] + public ?string $background; + + /** + * Flip/mirror the text horizontally, vertically, or in both directions. + * Acceptable values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. + * + * @var value-of|null $flip + */ + #[Optional(enum: Flip::class)] + public ?string $flip; + + /** + * Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + */ + #[Optional] + public ?string $fontColor; + + /** + * Specifies the font family of the overlaid text. Choose from the supported fonts list or use a custom font. + * See [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) and [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). + */ + #[Optional] + public ?string $fontFamily; + + /** + * Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic expression. + * + * @var FontSizeVariants|null $fontSize + */ + #[Optional] + public float|string|null $fontSize; + + /** + * Specifies the inner alignment of the text when width is more than the text length. + * + * @var value-of|null $innerAlignment + */ + #[Optional(enum: InnerAlignment::class)] + public ?string $innerAlignment; + + /** + * Specifies the line height for multi-line text overlays. It will come into effect only if the text wraps over multiple lines. + * Accepts either an integer value or an arithmetic expression. + * + * @var LineHeightVariants|null $lineHeight + */ + #[Optional] + public float|string|null $lineHeight; + + /** + * Specifies the padding around the overlaid text. + * Can be provided as a single positive integer or multiple values separated by underscores (following CSS shorthand order). + * Arithmetic expressions are also accepted. + * + * @var PaddingVariants|null $padding + */ + #[Optional] + public float|string|null $padding; + + /** + * Specifies the corner radius: + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + * See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * + * @var RadiusVariants|null $radius + */ + #[Optional] + public float|string|null $radius; + + /** + * Specifies the rotation angle of the text overlay. + * Accepts a numeric value for clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. + * + * @var RotationVariants|null $rotation + */ + #[Optional] + public float|string|null $rotation; + + /** + * Specifies the typography style of the text. + * Supported values: + * - Single styles: `b` (bold), `i` (italic), `strikethrough`. + * - Combinations: Any combination separated by underscores, e.g., `b_i`, `b_i_strikethrough`. + */ + #[Optional] + public ?string $typography; + + /** + * Specifies the maximum width (in pixels) of the overlaid text. The text wraps automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are supported. Useful when used in conjunction with the `background`. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @var WidthVariants|null $width + */ + #[Optional] + public float|string|null $width; + + 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 Flip|value-of|null $flip + * @param FontSizeShape|null $fontSize + * @param InnerAlignment|value-of|null $innerAlignment + * @param LineHeightShape|null $lineHeight + * @param PaddingShape|null $padding + * @param RadiusShape|null $radius + * @param RotationShape|null $rotation + * @param WidthShape|null $width + */ + public static function with( + ?float $alpha = null, + ?string $background = null, + Flip|string|null $flip = null, + ?string $fontColor = null, + ?string $fontFamily = null, + float|string|null $fontSize = null, + InnerAlignment|string|null $innerAlignment = null, + float|string|null $lineHeight = null, + float|string|null $padding = null, + float|string|null $radius = null, + float|string|null $rotation = null, + ?string $typography = null, + float|string|null $width = null, + ): self { + $self = new self; + + null !== $alpha && $self['alpha'] = $alpha; + null !== $background && $self['background'] = $background; + null !== $flip && $self['flip'] = $flip; + null !== $fontColor && $self['fontColor'] = $fontColor; + null !== $fontFamily && $self['fontFamily'] = $fontFamily; + null !== $fontSize && $self['fontSize'] = $fontSize; + null !== $innerAlignment && $self['innerAlignment'] = $innerAlignment; + null !== $lineHeight && $self['lineHeight'] = $lineHeight; + null !== $padding && $self['padding'] = $padding; + null !== $radius && $self['radius'] = $radius; + null !== $rotation && $self['rotation'] = $rotation; + null !== $typography && $self['typography'] = $typography; + null !== $width && $self['width'] = $width; + + return $self; + } + + /** + * Specifies the transparency level of the text overlay. Accepts integers from `1` to `9`. + */ + public function withAlpha(float $alpha): self + { + $self = clone $this; + $self['alpha'] = $alpha; + + return $self; + } + + /** + * Specifies the background color of the text overlay. + * Accepts an RGB hex code, an RGBA code, or a color name. + */ + public function withBackground(string $background): self + { + $self = clone $this; + $self['background'] = $background; + + return $self; + } + + /** + * Flip/mirror the text horizontally, vertically, or in both directions. + * Acceptable values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. + * + * @param Flip|value-of $flip + */ + public function withFlip(Flip|string $flip): self + { + $self = clone $this; + $self['flip'] = $flip; + + return $self; + } + + /** + * Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + */ + public function withFontColor(string $fontColor): self + { + $self = clone $this; + $self['fontColor'] = $fontColor; + + return $self; + } + + /** + * Specifies the font family of the overlaid text. Choose from the supported fonts list or use a custom font. + * See [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) and [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). + */ + public function withFontFamily(string $fontFamily): self + { + $self = clone $this; + $self['fontFamily'] = $fontFamily; + + return $self; + } + + /** + * Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic expression. + * + * @param FontSizeShape $fontSize + */ + public function withFontSize(float|string $fontSize): self + { + $self = clone $this; + $self['fontSize'] = $fontSize; + + return $self; + } + + /** + * Specifies the inner alignment of the text when width is more than the text length. + * + * @param InnerAlignment|value-of $innerAlignment + */ + public function withInnerAlignment( + InnerAlignment|string $innerAlignment + ): self { + $self = clone $this; + $self['innerAlignment'] = $innerAlignment; + + return $self; + } + + /** + * Specifies the line height for multi-line text overlays. It will come into effect only if the text wraps over multiple lines. + * Accepts either an integer value or an arithmetic expression. + * + * @param LineHeightShape $lineHeight + */ + public function withLineHeight(float|string $lineHeight): self + { + $self = clone $this; + $self['lineHeight'] = $lineHeight; + + return $self; + } + + /** + * Specifies the padding around the overlaid text. + * Can be provided as a single positive integer or multiple values separated by underscores (following CSS shorthand order). + * Arithmetic expressions are also accepted. + * + * @param PaddingShape $padding + */ + public function withPadding(float|string $padding): self + { + $self = clone $this; + $self['padding'] = $padding; + + return $self; + } + + /** + * Specifies the corner radius: + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + * See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * + * @param RadiusShape $radius + */ + public function withRadius(float|string $radius): self + { + $self = clone $this; + $self['radius'] = $radius; + + return $self; + } + + /** + * Specifies the rotation angle of the text overlay. + * Accepts a numeric value for clockwise rotation or a string prefixed with "N" for counter-clockwise rotation. + * + * @param RotationShape $rotation + */ + public function withRotation(float|string $rotation): self + { + $self = clone $this; + $self['rotation'] = $rotation; + + return $self; + } + + /** + * Specifies the typography style of the text. + * Supported values: + * - Single styles: `b` (bold), `i` (italic), `strikethrough`. + * - Combinations: Any combination separated by underscores, e.g., `b_i`, `b_i_strikethrough`. + */ + public function withTypography(string $typography): self + { + $self = clone $this; + $self['typography'] = $typography; + + return $self; + } + + /** + * Specifies the maximum width (in pixels) of the overlaid text. The text wraps automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are supported. Useful when used in conjunction with the `background`. + * Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @param WidthShape $width + */ + public function withWidth(float|string $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/TextOverlayTransformation/Flip.php b/src/TextOverlayTransformation/Flip.php new file mode 100644 index 00000000..6214d8f2 --- /dev/null +++ b/src/TextOverlayTransformation/Flip.php @@ -0,0 +1,20 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/TextOverlayTransformation/InnerAlignment.php b/src/TextOverlayTransformation/InnerAlignment.php new file mode 100644 index 00000000..e38cc502 --- /dev/null +++ b/src/TextOverlayTransformation/InnerAlignment.php @@ -0,0 +1,17 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/TextOverlayTransformation/Padding.php b/src/TextOverlayTransformation/Padding.php new file mode 100644 index 00000000..65838ff6 --- /dev/null +++ b/src/TextOverlayTransformation/Padding.php @@ -0,0 +1,30 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/TextOverlayTransformation/Radius.php b/src/TextOverlayTransformation/Radius.php new file mode 100644 index 00000000..42e84e72 --- /dev/null +++ b/src/TextOverlayTransformation/Radius.php @@ -0,0 +1,32 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string', 'string']; + } +} diff --git a/src/TextOverlayTransformation/Rotation.php b/src/TextOverlayTransformation/Rotation.php new file mode 100644 index 00000000..3bb977b9 --- /dev/null +++ b/src/TextOverlayTransformation/Rotation.php @@ -0,0 +1,29 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/TextOverlayTransformation/Width.php b/src/TextOverlayTransformation/Width.php new file mode 100644 index 00000000..4a8e1ec7 --- /dev/null +++ b/src/TextOverlayTransformation/Width.php @@ -0,0 +1,29 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation.php b/src/Transformation.php new file mode 100644 index 00000000..8ed80b36 --- /dev/null +++ b/src/Transformation.php @@ -0,0 +1,1519 @@ +, + * background?: string|null, + * blur?: float|null, + * border?: string|null, + * colorize?: string|null, + * colorProfile?: bool|null, + * colorReplace?: string|null, + * contrastStretch?: bool|null, + * crop?: null|Crop|value-of, + * cropMode?: null|CropMode|value-of, + * defaultImage?: string|null, + * distort?: string|null, + * dpr?: float|null, + * duration?: DurationShape|null, + * endOffset?: EndOffsetShape|null, + * flip?: null|Flip|value-of, + * focus?: string|null, + * format?: null|Format|value-of, + * gradient?: GradientShape|null, + * grayscale?: bool|null, + * height?: HeightShape|null, + * lossless?: bool|null, + * metadata?: bool|null, + * named?: string|null, + * opacity?: float|null, + * original?: bool|null, + * overlay?: mixed, + * page?: PageShape|null, + * progressive?: bool|null, + * quality?: float|null, + * radius?: RadiusShape|null, + * raw?: string|null, + * rotation?: RotationShape|null, + * shadow?: ShadowShape|null, + * sharpen?: SharpenShape|null, + * startOffset?: StartOffsetShape|null, + * streamingResolutions?: list>|null, + * trim?: TrimShape|null, + * unsharpMask?: UnsharpMaskShape|null, + * videoCodec?: null|VideoCodec|value-of, + * width?: WidthShape|null, + * x?: XShape|null, + * xCenter?: XCenterShape|null, + * y?: YShape|null, + * yCenter?: YCenterShape|null, + * zoom?: float|null, + * } + */ +final class Transformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Uses AI to change the background. Provide a text prompt or a base64-encoded prompt, + * e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + * Not supported inside overlay. + * See [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). + */ + #[Optional] + public ?string $aiChangeBackground; + + /** + * Adds an AI-based drop shadow around a foreground object on a transparent or removed background. + * Optionally, control the direction, elevation, and saturation of the light source (e.g., `az-45` to change light direction). + * Pass `true` for the default drop shadow, or provide a string for a custom drop shadow. + * Supported inside overlay. + * See [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + * + * @var AIDropShadowVariants|null $aiDropShadow + */ + #[Optional] + public string|bool|null $aiDropShadow; + + /** + * Uses AI to edit images based on a text prompt. Provide a text prompt or a base64-encoded prompt, + * e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + * Not supported inside overlay. + * See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). + */ + #[Optional] + public ?string $aiEdit; + + /** + * Applies ImageKit's in-house background removal. + * Supported inside overlay. + * See [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + */ + #[Optional] + public ?bool $aiRemoveBackground; + + /** + * Uses third-party background removal. + * Note: It is recommended to use aiRemoveBackground, ImageKit's in-house solution, which is more cost-effective. + * Supported inside overlay. + * See [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + */ + #[Optional] + public ?bool $aiRemoveBackgroundExternal; + + /** + * Performs AI-based retouching to improve faces or product shots. Not supported inside overlay. + * See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + */ + #[Optional] + public ?bool $aiRetouch; + + /** + * Upscales images beyond their original dimensions using AI. Not supported inside overlay. + * See [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + */ + #[Optional] + public ?bool $aiUpscale; + + /** + * Generates a variation of an image using AI. This produces a new image with slight variations from the original, + * such as changes in color, texture, and other visual elements, while preserving the structure and essence of the original image. Not supported inside overlay. + * See [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + */ + #[Optional] + public ?bool $aiVariation; + + /** + * Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with either width or height (but not both). + * For example: aspectRatio = `4:3`, `4_3`, or an expression like `iar_div_2`. + * See [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + * + * @var AspectRatioVariants|null $aspectRatio + */ + #[Optional] + public float|string|null $aspectRatio; + + /** + * Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + * + * @var value-of|null $audioCodec + */ + #[Optional(enum: AudioCodec::class)] + public ?string $audioCodec; + + /** + * Specifies the background to be used in conjunction with certain cropping strategies when resizing an image. + * - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + * - Dominant color: `dominant` extracts the dominant color from the image. See [Dominant color background](https://imagekit.io/docs/effects-and-enhancements#dominant-color-background). + * - Gradient: `gradient_dominant` or `gradient_dominant_2` creates a gradient using the dominant colors. Optionally specify palette size (2 or 4), e.g., `gradient_dominant_4`. See [Gradient background](https://imagekit.io/docs/effects-and-enhancements#gradient-background). + * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). + * - Expand the image boundaries using generative fill: `genfill`. Not supported inside overlay. Optionally, control the background scene by passing a text prompt: + * `genfill[:-prompt-${text}]` or `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. See [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). + */ + #[Optional] + public ?string $background; + + /** + * Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, or an expression like `bl-10`. + * See [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). + */ + #[Optional] + public ?float $blur; + + /** + * Adds a border to the output media. Accepts a string in the format `_` + * (e.g., `5_FFF000` for a 5px yellow border), or an expression like `ih_div_20_FF00FF`. + * See [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). + */ + #[Optional] + public ?string $border; + + /** + * Applies a color tint to the image. Accepts color and intensity as optional parameters. + * - `co-color` - Color to apply (e.g., `red`, `blue`, `FF0022`). Default is gray color. + * - `in-intensity` - Intensity of the color (0-100). Default is 35. + * See [Colorize](https://imagekit.io/docs/effects-and-enhancements#colorize---e-colorize). + */ + #[Optional] + public ?string $colorize; + + /** + * Indicates whether the output image should retain the original color profile. + * See [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + */ + #[Optional] + public ?bool $colorProfile; + + /** + * Replaces colors in the image. Supports three formats: + * - `toColor` - Replace dominant color with the specified color. + * - `toColor_tolerance` - Replace dominant color with specified tolerance (0-100). + * - `toColor_tolerance_fromColor` - Replace a specific color with another within tolerance range. + * Colors can be hex codes (e.g., `FF0022`) or names (e.g., `red`, `blue`). + * See [Color replacement](https://imagekit.io/docs/effects-and-enhancements#color-replace---cr). + */ + #[Optional] + public ?string $colorReplace; + + /** + * Automatically enhances the contrast of an image (contrast stretch). + * See [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + */ + #[Optional] + public ?bool $contrastStretch; + + /** + * Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + * + * @var value-of|null $crop + */ + #[Optional(enum: Crop::class)] + public ?string $crop; + + /** + * Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + * + * @var value-of|null $cropMode + */ + #[Optional(enum: CropMode::class)] + public ?string $cropMode; + + /** + * Specifies a fallback image if the resource is not found, e.g., a URL or file path. + * See [Default image](https://imagekit.io/docs/image-transformation#default-image---di). + */ + #[Optional] + public ?string $defaultImage; + + /** + * Distorts the shape of an image. Supports two modes: + * - Perspective distortion: `p-x1_y1_x2_y2_x3_y3_x4_y4` changes the position of the four corners starting clockwise from top-left. + * - Arc distortion: `a-degrees` curves the image upwards (positive values) or downwards (negative values). + * See [Distort effect](https://imagekit.io/docs/effects-and-enhancements#distort---e-distort). + */ + #[Optional] + public ?string $distort; + + /** + * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) calculation. Also accepts arithmetic expressions. + * - Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + */ + #[Optional] + public ?float $dpr; + + /** + * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. + * Typically used with startOffset to indicate the length from the start offset. Arithmetic expressions are supported. + * See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + * + * @var DurationVariants|null $duration + */ + #[Optional] + public float|string|null $duration; + + /** + * Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + * Typically used with startOffset to define a time window. Arithmetic expressions are supported. + * See [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + * + * @var EndOffsetVariants|null $endOffset + */ + #[Optional] + public float|string|null $endOffset; + + /** + * Flips or mirrors an image either horizontally, vertically, or both. + * Acceptable values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. + * See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + * + * @var value-of|null $flip + */ + #[Optional(enum: Flip::class)] + public ?string $flip; + + /** + * Refines padding and cropping behavior for pad resize, maintain ratio, and extract crop modes. + * Supports manual positions and coordinate-based focus. With AI-based cropping, you can automatically + * keep key subjects in frame—such as faces or detected objects (e.g., `fo-face`, `fo-person`, `fo-car`)— + * while resizing. + * - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). + * - [Object aware cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name). + */ + #[Optional] + public ?string $focus; + + /** + * Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, `mp4`, or `auto`. + * You can also pass `orig` for images to return the original format. + * ImageKit automatically delivers images and videos in the optimal format based on device support unless overridden by the dashboard settings or the format parameter. + * See [Image format](https://imagekit.io/docs/image-optimization#format---f) and [Video format](https://imagekit.io/docs/video-optimization#format---f). + * + * @var value-of|null $format + */ + #[Optional(enum: Format::class)] + public ?string $format; + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a string for a custom gradient. + * See [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + * + * @var GradientVariants|null $gradient + */ + #[Optional] + public string|bool|null $gradient; + + /** + * Enables a grayscale effect for images. See [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + */ + #[Optional] + public ?bool $grayscale; + + /** + * Specifies the height of the output. If a value between 0 and 1 is provided, it is treated as a percentage (e.g., `0.5` represents 50% of the original height). + * You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). + * Height transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h). + * + * @var HeightVariants|null $height + */ + #[Optional] + public float|string|null $height; + + /** + * Specifies whether the output image (in JPEG or PNG) should be compressed losslessly. + * See [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). + */ + #[Optional] + public ?bool $lossless; + + /** + * By default, ImageKit removes all metadata during automatic image compression. + * Set this to true to preserve metadata. + * See [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). + */ + #[Optional] + public ?bool $metadata; + + /** + * Named transformation reference. See [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + */ + #[Optional] + public ?string $named; + + /** + * Specifies the opacity level of the output image. See [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + */ + #[Optional] + public ?float $opacity; + + /** + * If set to true, serves the original file without applying any transformations. + * See [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). + */ + #[Optional] + public ?bool $original; + + /** + * Specifies an overlay to be applied on the parent image or video. + * ImageKit supports overlays including images, text, videos, subtitles, and solid colors. + * See [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + */ + #[Optional(union: Overlay::class)] + public mixed $overlay; + + /** + * Extracts a specific page or frame from multi-page or layered files (PDF, PSD, AI). + * For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the 2nd and 3rd layers), + * or by name (e.g., `name-layer-4` for a PSD layer). + * See [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + * + * @var PageVariants|null $page + */ + #[Optional] + public float|string|null $page; + + /** + * Specifies whether the output JPEG image should be rendered progressively. Progressive loading begins with a low-quality, + * pixelated version of the full image, which gradually improves to provide a faster perceived load time. + * See [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). + */ + #[Optional] + public ?bool $progressive; + + /** + * Specifies the quality of the output image for lossy formats such as JPEG, WebP, and AVIF. + * A higher quality value results in a larger file size with better quality, while a lower value produces a smaller file size with reduced quality. + * See [Quality](https://imagekit.io/docs/image-optimization#quality---q). + */ + #[Optional] + public ?float $quality; + + /** + * Specifies the corner radius for rounded corners. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + * See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * + * @var RadiusVariants|null $radius + */ + #[Optional] + public float|string|null $radius; + + /** + * Pass any transformation not directly supported by the SDK. + * This transformation string is appended to the URL as provided. + */ + #[Optional] + public ?string $raw; + + /** + * Specifies the rotation angle in degrees. Positive values rotate the image clockwise; you can also use, for example, `N40` for counterclockwise rotation + * or `auto` to use the orientation specified in the image's EXIF data. + * For videos, only the following values are supported: 0, 90, 180, 270, or 360. + * See [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + * + * @var RotationVariants|null $rotation + */ + #[Optional] + public float|string|null $rotation; + + /** + * Adds a shadow beneath solid objects in an image with a transparent background. + * For AI-based drop shadows, refer to aiDropShadow. + * Pass `true` for a default shadow, or provide a string for a custom shadow. + * See [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + * + * @var ShadowVariants|null $shadow + */ + #[Optional] + public string|bool|null $shadow; + + /** + * Sharpens the input image, highlighting edges and finer details. + * Pass `true` for default sharpening, or provide a numeric value for custom sharpening. + * See [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + * + * @var SharpenVariants|null $sharpen + */ + #[Optional] + public float|bool|null $sharpen; + + /** + * Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + * Arithmetic expressions are also supported. + * See [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + * + * @var StartOffsetVariants|null $startOffset + */ + #[Optional] + public float|string|null $startOffset; + + /** + * An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, `480`, `720`, `1080`]. + * See [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). + * + * @var list>|null $streamingResolutions + */ + #[Optional(list: StreamingResolution::class)] + public ?array $streamingResolutions; + + /** + * Useful for images with a solid or nearly solid background and a central object. This parameter trims the background, + * leaving only the central object in the output image. + * See [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + * + * @var TrimVariants|null $trim + */ + #[Optional] + public float|bool|null $trim; + + /** + * Applies Unsharp Masking (USM), an image sharpening technique. + * Pass `true` for a default unsharp mask, or provide a string for a custom unsharp mask. + * See [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + * + * @var UnsharpMaskVariants|null $unsharpMask + */ + #[Optional] + public string|bool|null $unsharpMask; + + /** + * Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + * + * @var value-of|null $videoCodec + */ + #[Optional(enum: VideoCodec::class)] + public ?string $videoCodec; + + /** + * Specifies the width of the output. If a value between 0 and 1 is provided, it is treated as a percentage (e.g., `0.4` represents 40% of the original width). + * You can also supply arithmetic expressions (e.g., `iw_div_2`). + * Width transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w). + * + * @var WidthVariants|null $width + */ + #[Optional] + public float|string|null $width; + + /** + * Focus using cropped image coordinates - X coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @var XVariants|null $x + */ + #[Optional] + public float|string|null $x; + + /** + * Focus using cropped image coordinates - X center coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @var XCenterVariants|null $xCenter + */ + #[Optional] + public float|string|null $xCenter; + + /** + * Focus using cropped image coordinates - Y coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @var YVariants|null $y + */ + #[Optional] + public float|string|null $y; + + /** + * Focus using cropped image coordinates - Y center coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @var YCenterVariants|null $yCenter + */ + #[Optional] + public float|string|null $yCenter; + + /** + * Accepts a numeric value that determines how much to zoom in or out of the cropped area. + * It should be used in conjunction with fo-face or fo-. + * See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). + */ + #[Optional] + public ?float $zoom; + + 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 AIDropShadowShape|null $aiDropShadow + * @param AspectRatioShape|null $aspectRatio + * @param AudioCodec|value-of|null $audioCodec + * @param Crop|value-of|null $crop + * @param CropMode|value-of|null $cropMode + * @param DurationShape|null $duration + * @param EndOffsetShape|null $endOffset + * @param Flip|value-of|null $flip + * @param Format|value-of|null $format + * @param GradientShape|null $gradient + * @param HeightShape|null $height + * @param PageShape|null $page + * @param RadiusShape|null $radius + * @param RotationShape|null $rotation + * @param ShadowShape|null $shadow + * @param SharpenShape|null $sharpen + * @param StartOffsetShape|null $startOffset + * @param list>|null $streamingResolutions + * @param TrimShape|null $trim + * @param UnsharpMaskShape|null $unsharpMask + * @param VideoCodec|value-of|null $videoCodec + * @param WidthShape|null $width + * @param XShape|null $x + * @param XCenterShape|null $xCenter + * @param YShape|null $y + * @param YCenterShape|null $yCenter + */ + public static function with( + ?string $aiChangeBackground = null, + string|bool|null $aiDropShadow = null, + ?string $aiEdit = null, + ?bool $aiRemoveBackground = null, + ?bool $aiRemoveBackgroundExternal = null, + ?bool $aiRetouch = null, + ?bool $aiUpscale = null, + ?bool $aiVariation = null, + float|string|null $aspectRatio = null, + AudioCodec|string|null $audioCodec = null, + ?string $background = null, + ?float $blur = null, + ?string $border = null, + ?string $colorize = null, + ?bool $colorProfile = null, + ?string $colorReplace = null, + ?bool $contrastStretch = null, + Crop|string|null $crop = null, + CropMode|string|null $cropMode = null, + ?string $defaultImage = null, + ?string $distort = null, + ?float $dpr = null, + float|string|null $duration = null, + float|string|null $endOffset = null, + Flip|string|null $flip = null, + ?string $focus = null, + Format|string|null $format = null, + string|bool|null $gradient = null, + ?bool $grayscale = null, + float|string|null $height = null, + ?bool $lossless = null, + ?bool $metadata = null, + ?string $named = null, + ?float $opacity = null, + ?bool $original = null, + mixed $overlay = null, + float|string|null $page = null, + ?bool $progressive = null, + ?float $quality = null, + float|string|null $radius = null, + ?string $raw = null, + float|string|null $rotation = null, + string|bool|null $shadow = null, + float|bool|null $sharpen = null, + float|string|null $startOffset = null, + ?array $streamingResolutions = null, + float|bool|null $trim = null, + string|bool|null $unsharpMask = null, + VideoCodec|string|null $videoCodec = null, + float|string|null $width = null, + float|string|null $x = null, + float|string|null $xCenter = null, + float|string|null $y = null, + float|string|null $yCenter = null, + ?float $zoom = null, + ): self { + $self = new self; + + null !== $aiChangeBackground && $self['aiChangeBackground'] = $aiChangeBackground; + null !== $aiDropShadow && $self['aiDropShadow'] = $aiDropShadow; + null !== $aiEdit && $self['aiEdit'] = $aiEdit; + null !== $aiRemoveBackground && $self['aiRemoveBackground'] = $aiRemoveBackground; + null !== $aiRemoveBackgroundExternal && $self['aiRemoveBackgroundExternal'] = $aiRemoveBackgroundExternal; + null !== $aiRetouch && $self['aiRetouch'] = $aiRetouch; + null !== $aiUpscale && $self['aiUpscale'] = $aiUpscale; + null !== $aiVariation && $self['aiVariation'] = $aiVariation; + null !== $aspectRatio && $self['aspectRatio'] = $aspectRatio; + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $background && $self['background'] = $background; + null !== $blur && $self['blur'] = $blur; + null !== $border && $self['border'] = $border; + null !== $colorize && $self['colorize'] = $colorize; + null !== $colorProfile && $self['colorProfile'] = $colorProfile; + null !== $colorReplace && $self['colorReplace'] = $colorReplace; + null !== $contrastStretch && $self['contrastStretch'] = $contrastStretch; + null !== $crop && $self['crop'] = $crop; + null !== $cropMode && $self['cropMode'] = $cropMode; + null !== $defaultImage && $self['defaultImage'] = $defaultImage; + null !== $distort && $self['distort'] = $distort; + null !== $dpr && $self['dpr'] = $dpr; + null !== $duration && $self['duration'] = $duration; + null !== $endOffset && $self['endOffset'] = $endOffset; + null !== $flip && $self['flip'] = $flip; + null !== $focus && $self['focus'] = $focus; + null !== $format && $self['format'] = $format; + null !== $gradient && $self['gradient'] = $gradient; + null !== $grayscale && $self['grayscale'] = $grayscale; + null !== $height && $self['height'] = $height; + null !== $lossless && $self['lossless'] = $lossless; + null !== $metadata && $self['metadata'] = $metadata; + null !== $named && $self['named'] = $named; + null !== $opacity && $self['opacity'] = $opacity; + null !== $original && $self['original'] = $original; + null !== $overlay && $self['overlay'] = $overlay; + null !== $page && $self['page'] = $page; + null !== $progressive && $self['progressive'] = $progressive; + null !== $quality && $self['quality'] = $quality; + null !== $radius && $self['radius'] = $radius; + null !== $raw && $self['raw'] = $raw; + null !== $rotation && $self['rotation'] = $rotation; + null !== $shadow && $self['shadow'] = $shadow; + null !== $sharpen && $self['sharpen'] = $sharpen; + null !== $startOffset && $self['startOffset'] = $startOffset; + null !== $streamingResolutions && $self['streamingResolutions'] = $streamingResolutions; + null !== $trim && $self['trim'] = $trim; + null !== $unsharpMask && $self['unsharpMask'] = $unsharpMask; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + null !== $width && $self['width'] = $width; + null !== $x && $self['x'] = $x; + null !== $xCenter && $self['xCenter'] = $xCenter; + null !== $y && $self['y'] = $y; + null !== $yCenter && $self['yCenter'] = $yCenter; + null !== $zoom && $self['zoom'] = $zoom; + + return $self; + } + + /** + * Uses AI to change the background. Provide a text prompt or a base64-encoded prompt, + * e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + * Not supported inside overlay. + * See [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). + */ + public function withAIChangeBackground(string $aiChangeBackground): self + { + $self = clone $this; + $self['aiChangeBackground'] = $aiChangeBackground; + + return $self; + } + + /** + * Adds an AI-based drop shadow around a foreground object on a transparent or removed background. + * Optionally, control the direction, elevation, and saturation of the light source (e.g., `az-45` to change light direction). + * Pass `true` for the default drop shadow, or provide a string for a custom drop shadow. + * Supported inside overlay. + * See [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + * + * @param AIDropShadowShape $aiDropShadow + */ + public function withAIDropShadow(string|bool $aiDropShadow): self + { + $self = clone $this; + $self['aiDropShadow'] = $aiDropShadow; + + return $self; + } + + /** + * Uses AI to edit images based on a text prompt. Provide a text prompt or a base64-encoded prompt, + * e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. + * Not supported inside overlay. + * See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). + */ + public function withAIEdit(string $aiEdit): self + { + $self = clone $this; + $self['aiEdit'] = $aiEdit; + + return $self; + } + + /** + * Applies ImageKit's in-house background removal. + * Supported inside overlay. + * See [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + */ + public function withAIRemoveBackground(bool $aiRemoveBackground): self + { + $self = clone $this; + $self['aiRemoveBackground'] = $aiRemoveBackground; + + return $self; + } + + /** + * Uses third-party background removal. + * Note: It is recommended to use aiRemoveBackground, ImageKit's in-house solution, which is more cost-effective. + * Supported inside overlay. + * See [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + */ + public function withAIRemoveBackgroundExternal( + bool $aiRemoveBackgroundExternal + ): self { + $self = clone $this; + $self['aiRemoveBackgroundExternal'] = $aiRemoveBackgroundExternal; + + return $self; + } + + /** + * Performs AI-based retouching to improve faces or product shots. Not supported inside overlay. + * See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + */ + public function withAIRetouch(bool $aiRetouch): self + { + $self = clone $this; + $self['aiRetouch'] = $aiRetouch; + + return $self; + } + + /** + * Upscales images beyond their original dimensions using AI. Not supported inside overlay. + * See [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + */ + public function withAIUpscale(bool $aiUpscale): self + { + $self = clone $this; + $self['aiUpscale'] = $aiUpscale; + + return $self; + } + + /** + * Generates a variation of an image using AI. This produces a new image with slight variations from the original, + * such as changes in color, texture, and other visual elements, while preserving the structure and essence of the original image. Not supported inside overlay. + * See [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + */ + public function withAIVariation(bool $aiVariation): self + { + $self = clone $this; + $self['aiVariation'] = $aiVariation; + + return $self; + } + + /** + * Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with either width or height (but not both). + * For example: aspectRatio = `4:3`, `4_3`, or an expression like `iar_div_2`. + * See [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + * + * @param AspectRatioShape $aspectRatio + */ + public function withAspectRatio(float|string $aspectRatio): self + { + $self = clone $this; + $self['aspectRatio'] = $aspectRatio; + + return $self; + } + + /** + * Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + * + * @param AudioCodec|value-of $audioCodec + */ + public function withAudioCodec(AudioCodec|string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * Specifies the background to be used in conjunction with certain cropping strategies when resizing an image. + * - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + * - Dominant color: `dominant` extracts the dominant color from the image. See [Dominant color background](https://imagekit.io/docs/effects-and-enhancements#dominant-color-background). + * - Gradient: `gradient_dominant` or `gradient_dominant_2` creates a gradient using the dominant colors. Optionally specify palette size (2 or 4), e.g., `gradient_dominant_4`. See [Gradient background](https://imagekit.io/docs/effects-and-enhancements#gradient-background). + * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). + * - Expand the image boundaries using generative fill: `genfill`. Not supported inside overlay. Optionally, control the background scene by passing a text prompt: + * `genfill[:-prompt-${text}]` or `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. See [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). + */ + public function withBackground(string $background): self + { + $self = clone $this; + $self['background'] = $background; + + return $self; + } + + /** + * Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, or an expression like `bl-10`. + * See [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). + */ + public function withBlur(float $blur): self + { + $self = clone $this; + $self['blur'] = $blur; + + return $self; + } + + /** + * Adds a border to the output media. Accepts a string in the format `_` + * (e.g., `5_FFF000` for a 5px yellow border), or an expression like `ih_div_20_FF00FF`. + * See [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). + */ + public function withBorder(string $border): self + { + $self = clone $this; + $self['border'] = $border; + + return $self; + } + + /** + * Applies a color tint to the image. Accepts color and intensity as optional parameters. + * - `co-color` - Color to apply (e.g., `red`, `blue`, `FF0022`). Default is gray color. + * - `in-intensity` - Intensity of the color (0-100). Default is 35. + * See [Colorize](https://imagekit.io/docs/effects-and-enhancements#colorize---e-colorize). + */ + public function withColorize(string $colorize): self + { + $self = clone $this; + $self['colorize'] = $colorize; + + return $self; + } + + /** + * Indicates whether the output image should retain the original color profile. + * See [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + */ + public function withColorProfile(bool $colorProfile): self + { + $self = clone $this; + $self['colorProfile'] = $colorProfile; + + return $self; + } + + /** + * Replaces colors in the image. Supports three formats: + * - `toColor` - Replace dominant color with the specified color. + * - `toColor_tolerance` - Replace dominant color with specified tolerance (0-100). + * - `toColor_tolerance_fromColor` - Replace a specific color with another within tolerance range. + * Colors can be hex codes (e.g., `FF0022`) or names (e.g., `red`, `blue`). + * See [Color replacement](https://imagekit.io/docs/effects-and-enhancements#color-replace---cr). + */ + public function withColorReplace(string $colorReplace): self + { + $self = clone $this; + $self['colorReplace'] = $colorReplace; + + return $self; + } + + /** + * Automatically enhances the contrast of an image (contrast stretch). + * See [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + */ + public function withContrastStretch(bool $contrastStretch): self + { + $self = clone $this; + $self['contrastStretch'] = $contrastStretch; + + return $self; + } + + /** + * Crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + * + * @param Crop|value-of $crop + */ + public function withCrop(Crop|string $crop): self + { + $self = clone $this; + $self['crop'] = $crop; + + return $self; + } + + /** + * Additional crop modes for image resizing. See [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + * + * @param CropMode|value-of $cropMode + */ + public function withCropMode(CropMode|string $cropMode): self + { + $self = clone $this; + $self['cropMode'] = $cropMode; + + return $self; + } + + /** + * Specifies a fallback image if the resource is not found, e.g., a URL or file path. + * See [Default image](https://imagekit.io/docs/image-transformation#default-image---di). + */ + public function withDefaultImage(string $defaultImage): self + { + $self = clone $this; + $self['defaultImage'] = $defaultImage; + + return $self; + } + + /** + * Distorts the shape of an image. Supports two modes: + * - Perspective distortion: `p-x1_y1_x2_y2_x3_y3_x4_y4` changes the position of the four corners starting clockwise from top-left. + * - Arc distortion: `a-degrees` curves the image upwards (positive values) or downwards (negative values). + * See [Distort effect](https://imagekit.io/docs/effects-and-enhancements#distort---e-distort). + */ + public function withDistort(string $distort): self + { + $self = clone $this; + $self['distort'] = $distort; + + return $self; + } + + /** + * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) calculation. Also accepts arithmetic expressions. + * - Learn about [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + */ + public function withDpr(float $dpr): self + { + $self = clone $this; + $self['dpr'] = $dpr; + + return $self; + } + + /** + * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. + * Typically used with startOffset to indicate the length from the start offset. Arithmetic expressions are supported. + * See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + * + * @param DurationShape $duration + */ + public function withDuration(float|string $duration): self + { + $self = clone $this; + $self['duration'] = $duration; + + return $self; + } + + /** + * Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + * Typically used with startOffset to define a time window. Arithmetic expressions are supported. + * See [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + * + * @param EndOffsetShape $endOffset + */ + public function withEndOffset(float|string $endOffset): self + { + $self = clone $this; + $self['endOffset'] = $endOffset; + + return $self; + } + + /** + * Flips or mirrors an image either horizontally, vertically, or both. + * Acceptable values: `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. + * See [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + * + * @param Flip|value-of $flip + */ + public function withFlip(Flip|string $flip): self + { + $self = clone $this; + $self['flip'] = $flip; + + return $self; + } + + /** + * Refines padding and cropping behavior for pad resize, maintain ratio, and extract crop modes. + * Supports manual positions and coordinate-based focus. With AI-based cropping, you can automatically + * keep key subjects in frame—such as faces or detected objects (e.g., `fo-face`, `fo-person`, `fo-car`)— + * while resizing. + * - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). + * - [Object aware cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name). + */ + public function withFocus(string $focus): self + { + $self = clone $this; + $self['focus'] = $focus; + + return $self; + } + + /** + * Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, `mp4`, or `auto`. + * You can also pass `orig` for images to return the original format. + * ImageKit automatically delivers images and videos in the optimal format based on device support unless overridden by the dashboard settings or the format parameter. + * See [Image format](https://imagekit.io/docs/image-optimization#format---f) and [Video format](https://imagekit.io/docs/video-optimization#format---f). + * + * @param Format|value-of $format + */ + public function withFormat(Format|string $format): self + { + $self = clone $this; + $self['format'] = $format; + + return $self; + } + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a string for a custom gradient. + * See [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + * + * @param GradientShape $gradient + */ + public function withGradient(string|bool $gradient): self + { + $self = clone $this; + $self['gradient'] = $gradient; + + return $self; + } + + /** + * Enables a grayscale effect for images. See [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + */ + public function withGrayscale(bool $grayscale): self + { + $self = clone $this; + $self['grayscale'] = $grayscale; + + return $self; + } + + /** + * Specifies the height of the output. If a value between 0 and 1 is provided, it is treated as a percentage (e.g., `0.5` represents 50% of the original height). + * You can also supply arithmetic expressions (e.g., `ih_mul_0.5`). + * Height transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h). + * + * @param HeightShape $height + */ + public function withHeight(float|string $height): self + { + $self = clone $this; + $self['height'] = $height; + + return $self; + } + + /** + * Specifies whether the output image (in JPEG or PNG) should be compressed losslessly. + * See [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). + */ + public function withLossless(bool $lossless): self + { + $self = clone $this; + $self['lossless'] = $lossless; + + return $self; + } + + /** + * By default, ImageKit removes all metadata during automatic image compression. + * Set this to true to preserve metadata. + * See [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). + */ + public function withMetadata(bool $metadata): self + { + $self = clone $this; + $self['metadata'] = $metadata; + + return $self; + } + + /** + * Named transformation reference. See [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + */ + public function withNamed(string $named): self + { + $self = clone $this; + $self['named'] = $named; + + return $self; + } + + /** + * Specifies the opacity level of the output image. See [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + */ + public function withOpacity(float $opacity): self + { + $self = clone $this; + $self['opacity'] = $opacity; + + return $self; + } + + /** + * If set to true, serves the original file without applying any transformations. + * See [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). + */ + public function withOriginal(bool $original): self + { + $self = clone $this; + $self['original'] = $original; + + return $self; + } + + /** + * Specifies an overlay to be applied on the parent image or video. + * ImageKit supports overlays including images, text, videos, subtitles, and solid colors. + * See [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + */ + public function withOverlay(mixed $overlay): self + { + $self = clone $this; + $self['overlay'] = $overlay; + + return $self; + } + + /** + * Extracts a specific page or frame from multi-page or layered files (PDF, PSD, AI). + * For example, specify by number (e.g., `2`), a range (e.g., `3-4` for the 2nd and 3rd layers), + * or by name (e.g., `name-layer-4` for a PSD layer). + * See [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + * + * @param PageShape $page + */ + public function withPage(float|string $page): self + { + $self = clone $this; + $self['page'] = $page; + + return $self; + } + + /** + * Specifies whether the output JPEG image should be rendered progressively. Progressive loading begins with a low-quality, + * pixelated version of the full image, which gradually improves to provide a faster perceived load time. + * See [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). + */ + public function withProgressive(bool $progressive): self + { + $self = clone $this; + $self['progressive'] = $progressive; + + return $self; + } + + /** + * Specifies the quality of the output image for lossy formats such as JPEG, WebP, and AVIF. + * A higher quality value results in a larger file size with better quality, while a lower value produces a smaller file size with reduced quality. + * See [Quality](https://imagekit.io/docs/image-optimization#quality---q). + */ + public function withQuality(float $quality): self + { + $self = clone $this; + $self['quality'] = $quality; + + return $self; + } + + /** + * Specifies the corner radius for rounded corners. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + * See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * + * @param RadiusShape $radius + */ + public function withRadius(float|string $radius): self + { + $self = clone $this; + $self['radius'] = $radius; + + return $self; + } + + /** + * Pass any transformation not directly supported by the SDK. + * This transformation string is appended to the URL as provided. + */ + public function withRaw(string $raw): self + { + $self = clone $this; + $self['raw'] = $raw; + + return $self; + } + + /** + * Specifies the rotation angle in degrees. Positive values rotate the image clockwise; you can also use, for example, `N40` for counterclockwise rotation + * or `auto` to use the orientation specified in the image's EXIF data. + * For videos, only the following values are supported: 0, 90, 180, 270, or 360. + * See [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + * + * @param RotationShape $rotation + */ + public function withRotation(float|string $rotation): self + { + $self = clone $this; + $self['rotation'] = $rotation; + + return $self; + } + + /** + * Adds a shadow beneath solid objects in an image with a transparent background. + * For AI-based drop shadows, refer to aiDropShadow. + * Pass `true` for a default shadow, or provide a string for a custom shadow. + * See [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + * + * @param ShadowShape $shadow + */ + public function withShadow(string|bool $shadow): self + { + $self = clone $this; + $self['shadow'] = $shadow; + + return $self; + } + + /** + * Sharpens the input image, highlighting edges and finer details. + * Pass `true` for default sharpening, or provide a numeric value for custom sharpening. + * See [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + * + * @param SharpenShape $sharpen + */ + public function withSharpen(float|bool $sharpen): self + { + $self = clone $this; + $self['sharpen'] = $sharpen; + + return $self; + } + + /** + * Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + * Arithmetic expressions are also supported. + * See [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + * + * @param StartOffsetShape $startOffset + */ + public function withStartOffset(float|string $startOffset): self + { + $self = clone $this; + $self['startOffset'] = $startOffset; + + return $self; + } + + /** + * An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, `480`, `720`, `1080`]. + * See [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). + * + * @param list> $streamingResolutions + */ + public function withStreamingResolutions(array $streamingResolutions): self + { + $self = clone $this; + $self['streamingResolutions'] = $streamingResolutions; + + return $self; + } + + /** + * Useful for images with a solid or nearly solid background and a central object. This parameter trims the background, + * leaving only the central object in the output image. + * See [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + * + * @param TrimShape $trim + */ + public function withTrim(float|bool $trim): self + { + $self = clone $this; + $self['trim'] = $trim; + + return $self; + } + + /** + * Applies Unsharp Masking (USM), an image sharpening technique. + * Pass `true` for a default unsharp mask, or provide a string for a custom unsharp mask. + * See [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + * + * @param UnsharpMaskShape $unsharpMask + */ + public function withUnsharpMask(string|bool $unsharpMask): self + { + $self = clone $this; + $self['unsharpMask'] = $unsharpMask; + + return $self; + } + + /** + * Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + * + * @param VideoCodec|value-of $videoCodec + */ + public function withVideoCodec(VideoCodec|string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * Specifies the width of the output. If a value between 0 and 1 is provided, it is treated as a percentage (e.g., `0.4` represents 40% of the original width). + * You can also supply arithmetic expressions (e.g., `iw_div_2`). + * Width transformation – [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w). + * + * @param WidthShape $width + */ + public function withWidth(float|string $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } + + /** + * Focus using cropped image coordinates - X coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @param XShape $x + */ + public function withX(float|string $x): self + { + $self = clone $this; + $self['x'] = $x; + + return $self; + } + + /** + * Focus using cropped image coordinates - X center coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @param XCenterShape $xCenter + */ + public function withXCenter(float|string $xCenter): self + { + $self = clone $this; + $self['xCenter'] = $xCenter; + + return $self; + } + + /** + * Focus using cropped image coordinates - Y coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @param YShape $y + */ + public function withY(float|string $y): self + { + $self = clone $this; + $self['y'] = $y; + + return $self; + } + + /** + * Focus using cropped image coordinates - Y center coordinate. See [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @param YCenterShape $yCenter + */ + public function withYCenter(float|string $yCenter): self + { + $self = clone $this; + $self['yCenter'] = $yCenter; + + return $self; + } + + /** + * Accepts a numeric value that determines how much to zoom in or out of the cropped area. + * It should be used in conjunction with fo-face or fo-. + * See [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). + */ + public function withZoom(float $zoom): self + { + $self = clone $this; + $self['zoom'] = $zoom; + + return $self; + } +} diff --git a/src/Transformation/AIDropShadow.php b/src/Transformation/AIDropShadow.php new file mode 100644 index 00000000..8e83ba88 --- /dev/null +++ b/src/Transformation/AIDropShadow.php @@ -0,0 +1,32 @@ +|array + */ + public static function variants(): array + { + return ['bool', 'string']; + } +} diff --git a/src/Transformation/AspectRatio.php b/src/Transformation/AspectRatio.php new file mode 100644 index 00000000..6efa4212 --- /dev/null +++ b/src/Transformation/AspectRatio.php @@ -0,0 +1,30 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/AudioCodec.php b/src/Transformation/AudioCodec.php new file mode 100644 index 00000000..e50f6a34 --- /dev/null +++ b/src/Transformation/AudioCodec.php @@ -0,0 +1,17 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/EndOffset.php b/src/Transformation/EndOffset.php new file mode 100644 index 00000000..a0ea4d3a --- /dev/null +++ b/src/Transformation/EndOffset.php @@ -0,0 +1,30 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/Flip.php b/src/Transformation/Flip.php new file mode 100644 index 00000000..cf787781 --- /dev/null +++ b/src/Transformation/Flip.php @@ -0,0 +1,21 @@ +|array + */ + public static function variants(): array + { + return ['bool', 'string']; + } +} diff --git a/src/Transformation/Height.php b/src/Transformation/Height.php new file mode 100644 index 00000000..a71522ac --- /dev/null +++ b/src/Transformation/Height.php @@ -0,0 +1,30 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/Page.php b/src/Transformation/Page.php new file mode 100644 index 00000000..39c7d7b8 --- /dev/null +++ b/src/Transformation/Page.php @@ -0,0 +1,31 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/Radius.php b/src/Transformation/Radius.php new file mode 100644 index 00000000..e8557099 --- /dev/null +++ b/src/Transformation/Radius.php @@ -0,0 +1,32 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string', 'string']; + } +} diff --git a/src/Transformation/Rotation.php b/src/Transformation/Rotation.php new file mode 100644 index 00000000..98feb837 --- /dev/null +++ b/src/Transformation/Rotation.php @@ -0,0 +1,31 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/Shadow.php b/src/Transformation/Shadow.php new file mode 100644 index 00000000..964b6aa4 --- /dev/null +++ b/src/Transformation/Shadow.php @@ -0,0 +1,31 @@ +|array + */ + public static function variants(): array + { + return ['bool', 'string']; + } +} diff --git a/src/Transformation/Sharpen.php b/src/Transformation/Sharpen.php new file mode 100644 index 00000000..57c395fd --- /dev/null +++ b/src/Transformation/Sharpen.php @@ -0,0 +1,30 @@ +|array + */ + public static function variants(): array + { + return ['bool', 'float']; + } +} diff --git a/src/Transformation/StartOffset.php b/src/Transformation/StartOffset.php new file mode 100644 index 00000000..117c4c36 --- /dev/null +++ b/src/Transformation/StartOffset.php @@ -0,0 +1,30 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/Trim.php b/src/Transformation/Trim.php new file mode 100644 index 00000000..549f23a9 --- /dev/null +++ b/src/Transformation/Trim.php @@ -0,0 +1,30 @@ +|array + */ + public static function variants(): array + { + return ['bool', 'float']; + } +} diff --git a/src/Transformation/UnsharpMask.php b/src/Transformation/UnsharpMask.php new file mode 100644 index 00000000..d41f04c1 --- /dev/null +++ b/src/Transformation/UnsharpMask.php @@ -0,0 +1,30 @@ +|array + */ + public static function variants(): array + { + return ['bool', 'string']; + } +} diff --git a/src/Transformation/VideoCodec.php b/src/Transformation/VideoCodec.php new file mode 100644 index 00000000..787a91fc --- /dev/null +++ b/src/Transformation/VideoCodec.php @@ -0,0 +1,19 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/X.php b/src/Transformation/X.php new file mode 100644 index 00000000..451916da --- /dev/null +++ b/src/Transformation/X.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/XCenter.php b/src/Transformation/XCenter.php new file mode 100644 index 00000000..c4bead03 --- /dev/null +++ b/src/Transformation/XCenter.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/Y.php b/src/Transformation/Y.php new file mode 100644 index 00000000..cef68ed2 --- /dev/null +++ b/src/Transformation/Y.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/Transformation/YCenter.php b/src/Transformation/YCenter.php new file mode 100644 index 00000000..8467dca4 --- /dev/null +++ b/src/Transformation/YCenter.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['float', 'string']; + } +} diff --git a/src/TransformationPosition.php b/src/TransformationPosition.php new file mode 100644 index 00000000..8e3ee23f --- /dev/null +++ b/src/TransformationPosition.php @@ -0,0 +1,17 @@ +, + * position?: null|OverlayPosition|OverlayPositionShape, + * timing?: null|OverlayTiming|OverlayTimingShape, + * input: string, + * type: 'video', + * encoding?: null|Encoding|value-of, + * transformation?: list|null, + * } + */ +final class VideoOverlay implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var 'video' $type */ + #[Required] + public string $type = 'video'; + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @var value-of|null $layerMode + */ + #[Optional(enum: LayerMode::class)] + public ?string $layerMode; + + #[Optional] + public ?OverlayPosition $position; + + #[Optional] + public ?OverlayTiming $timing; + + /** + * Specifies the relative path to the video used as an overlay. + */ + #[Required] + public string $input; + + /** + * The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + * By default, the SDK determines the appropriate format automatically. + * To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. + * + * @var value-of|null $encoding + */ + #[Optional(enum: Encoding::class)] + public ?string $encoding; + + /** + * Array of transformation to be applied to the overlay video. Except `streamingResolutions`, all other video transformations are supported. + * See [Video transformations](https://imagekit.io/docs/video-transformation). + * + * @var list|null $transformation + */ + #[Optional(list: Transformation::class)] + public ?array $transformation; + + /** + * `new VideoOverlay()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * VideoOverlay::with(input: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new VideoOverlay)->withInput(...) + * ``` + */ + 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 LayerMode|value-of|null $layerMode + * @param OverlayPosition|OverlayPositionShape|null $position + * @param OverlayTiming|OverlayTimingShape|null $timing + * @param Encoding|value-of|null $encoding + * @param list|null $transformation + */ + public static function with( + string $input, + LayerMode|string|null $layerMode = null, + OverlayPosition|array|null $position = null, + OverlayTiming|array|null $timing = null, + Encoding|string|null $encoding = null, + ?array $transformation = null, + ): self { + $self = new self; + + $self['input'] = $input; + + null !== $layerMode && $self['layerMode'] = $layerMode; + null !== $position && $self['position'] = $position; + null !== $timing && $self['timing'] = $timing; + null !== $encoding && $self['encoding'] = $encoding; + null !== $transformation && $self['transformation'] = $transformation; + + return $self; + } + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the URL. + * By default, layers completely cover the base image beneath them. Layer modes change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The red channel controls horizontal displacement, and the green channel controls vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image transparent, while transparent areas leave the base image unchanged. This mode functions like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming the base image to match the specific dimensions and shape of the layer. + * See [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @param LayerMode|value-of $layerMode + */ + public function withLayerMode(LayerMode|string $layerMode): self + { + $self = clone $this; + $self['layerMode'] = $layerMode; + + return $self; + } + + /** + * @param OverlayPosition|OverlayPositionShape $position + */ + public function withPosition(OverlayPosition|array $position): self + { + $self = clone $this; + $self['position'] = $position; + + return $self; + } + + /** + * @param OverlayTiming|OverlayTimingShape $timing + */ + public function withTiming(OverlayTiming|array $timing): self + { + $self = clone $this; + $self['timing'] = $timing; + + return $self; + } + + /** + * Specifies the relative path to the video used as an overlay. + */ + public function withInput(string $input): self + { + $self = clone $this; + $self['input'] = $input; + + return $self; + } + + /** + * @param 'video' $type + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * The input path can be included in the layer as either `i-{input}` or `ie-{base64_encoded_input}`. + * By default, the SDK determines the appropriate format automatically. + * To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. + * + * @param Encoding|value-of $encoding + */ + public function withEncoding(Encoding|string $encoding): self + { + $self = clone $this; + $self['encoding'] = $encoding; + + return $self; + } + + /** + * Array of transformation to be applied to the overlay video. Except `streamingResolutions`, all other video transformations are supported. + * See [Video transformations](https://imagekit.io/docs/video-transformation). + * + * @param list $transformation + */ + public function withTransformation(array $transformation): self + { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } +} diff --git a/src/VideoOverlay/Encoding.php b/src/VideoOverlay/Encoding.php new file mode 100644 index 00000000..a78e3f8f --- /dev/null +++ b/src/VideoOverlay/Encoding.php @@ -0,0 +1,24 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * `new BaseWebhookEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * BaseWebhookEvent::with(id: ..., type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new BaseWebhookEvent)->withID(...)->withType(...) + * ``` + */ + 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(string $id, string $type): self + { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } +} diff --git a/src/Webhooks/FileCreateEvent.php b/src/Webhooks/FileCreateEvent.php new file mode 100644 index 00000000..fb6e1d8e --- /dev/null +++ b/src/Webhooks/FileCreateEvent.php @@ -0,0 +1,141 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + /** + * Object containing details of a file or file version. + */ + #[Required] + public File $data; + + /** + * `new FileCreateEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileCreateEvent::with(id: ..., type: ..., createdAt: ..., data: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileCreateEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->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 File|FileShape $data + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + File|array $data + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * Object containing details of a file or file version. + * + * @param File|FileShape $data + */ + public function withData(File|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } +} diff --git a/src/Webhooks/FileDeleteEvent.php b/src/Webhooks/FileDeleteEvent.php new file mode 100644 index 00000000..736af9fd --- /dev/null +++ b/src/Webhooks/FileDeleteEvent.php @@ -0,0 +1,136 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + #[Required] + public Data $data; + + /** + * `new FileDeleteEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileDeleteEvent::with(id: ..., type: ..., createdAt: ..., data: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileDeleteEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->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, + string $type, + \DateTimeInterface $createdAt, + Data|array $data + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * @param Data|DataShape $data + */ + public function withData(Data|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } +} diff --git a/src/Webhooks/FileDeleteEvent/Data.php b/src/Webhooks/FileDeleteEvent/Data.php new file mode 100644 index 00000000..dd5b0d28 --- /dev/null +++ b/src/Webhooks/FileDeleteEvent/Data.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * The unique `fileId` of the deleted file. + */ + #[Required('fileId')] + public string $fileID; + + /** + * `new Data()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Data::with(fileID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Data)->withFileID(...) + * ``` + */ + 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(string $fileID): self + { + $self = new self; + + $self['fileID'] = $fileID; + + return $self; + } + + /** + * The unique `fileId` of the deleted file. + */ + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } +} diff --git a/src/Webhooks/FileUpdateEvent.php b/src/Webhooks/FileUpdateEvent.php new file mode 100644 index 00000000..5bb1195a --- /dev/null +++ b/src/Webhooks/FileUpdateEvent.php @@ -0,0 +1,141 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + /** + * Object containing details of a file or file version. + */ + #[Required] + public File $data; + + /** + * `new FileUpdateEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileUpdateEvent::with(id: ..., type: ..., createdAt: ..., data: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileUpdateEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->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 File|FileShape $data + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + File|array $data + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * Object containing details of a file or file version. + * + * @param File|FileShape $data + */ + public function withData(File|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } +} diff --git a/src/Webhooks/FileVersionCreateEvent.php b/src/Webhooks/FileVersionCreateEvent.php new file mode 100644 index 00000000..6e1aa478 --- /dev/null +++ b/src/Webhooks/FileVersionCreateEvent.php @@ -0,0 +1,141 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + /** + * Object containing details of a file or file version. + */ + #[Required] + public File $data; + + /** + * `new FileVersionCreateEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileVersionCreateEvent::with(id: ..., type: ..., createdAt: ..., data: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileVersionCreateEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->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 File|FileShape $data + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + File|array $data + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * Object containing details of a file or file version. + * + * @param File|FileShape $data + */ + public function withData(File|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } +} diff --git a/src/Webhooks/FileVersionDeleteEvent.php b/src/Webhooks/FileVersionDeleteEvent.php new file mode 100644 index 00000000..92b2d709 --- /dev/null +++ b/src/Webhooks/FileVersionDeleteEvent.php @@ -0,0 +1,136 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + #[Required] + public Data $data; + + /** + * `new FileVersionDeleteEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * FileVersionDeleteEvent::with(id: ..., type: ..., createdAt: ..., data: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new FileVersionDeleteEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->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, + string $type, + \DateTimeInterface $createdAt, + Data|array $data + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * @param Data|DataShape $data + */ + public function withData(Data|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } +} diff --git a/src/Webhooks/FileVersionDeleteEvent/Data.php b/src/Webhooks/FileVersionDeleteEvent/Data.php new file mode 100644 index 00000000..2ae74e04 --- /dev/null +++ b/src/Webhooks/FileVersionDeleteEvent/Data.php @@ -0,0 +1,86 @@ + */ + use SdkModel; + + /** + * The unique `fileId` of the deleted file. + */ + #[Required('fileId')] + public string $fileID; + + /** + * The unique `versionId` of the deleted file version. + */ + #[Required('versionId')] + public string $versionID; + + /** + * `new Data()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Data::with(fileID: ..., versionID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Data)->withFileID(...)->withVersionID(...) + * ``` + */ + 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(string $fileID, string $versionID): self + { + $self = new self; + + $self['fileID'] = $fileID; + $self['versionID'] = $versionID; + + return $self; + } + + /** + * The unique `fileId` of the deleted file. + */ + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } + + /** + * The unique `versionId` of the deleted file version. + */ + public function withVersionID(string $versionID): self + { + $self = clone $this; + $self['versionID'] = $versionID; + + return $self; + } +} diff --git a/src/Webhooks/UnsafeUnwrapWebhookEvent.php b/src/Webhooks/UnsafeUnwrapWebhookEvent.php new file mode 100644 index 00000000..666bdb61 --- /dev/null +++ b/src/Webhooks/UnsafeUnwrapWebhookEvent.php @@ -0,0 +1,54 @@ +|array + */ + public static function variants(): array + { + return [ + VideoTransformationAcceptedEvent::class, + VideoTransformationReadyEvent::class, + VideoTransformationErrorEvent::class, + UploadPreTransformSuccessEvent::class, + UploadPreTransformErrorEvent::class, + UploadPostTransformSuccessEvent::class, + UploadPostTransformErrorEvent::class, + FileCreateEvent::class, + FileUpdateEvent::class, + FileDeleteEvent::class, + FileVersionCreateEvent::class, + FileVersionDeleteEvent::class, + ]; + } +} diff --git a/src/Webhooks/UnwrapWebhookEvent.php b/src/Webhooks/UnwrapWebhookEvent.php new file mode 100644 index 00000000..a7ad2b52 --- /dev/null +++ b/src/Webhooks/UnwrapWebhookEvent.php @@ -0,0 +1,54 @@ +|array + */ + public static function variants(): array + { + return [ + VideoTransformationAcceptedEvent::class, + VideoTransformationReadyEvent::class, + VideoTransformationErrorEvent::class, + UploadPreTransformSuccessEvent::class, + UploadPreTransformErrorEvent::class, + UploadPostTransformSuccessEvent::class, + UploadPostTransformErrorEvent::class, + FileCreateEvent::class, + FileUpdateEvent::class, + FileDeleteEvent::class, + FileVersionCreateEvent::class, + FileVersionDeleteEvent::class, + ]; + } +} diff --git a/src/Webhooks/UploadPostTransformErrorEvent.php b/src/Webhooks/UploadPostTransformErrorEvent.php new file mode 100644 index 00000000..2fb26668 --- /dev/null +++ b/src/Webhooks/UploadPostTransformErrorEvent.php @@ -0,0 +1,162 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + #[Required] + public Data $data; + + #[Required] + public Request $request; + + /** + * `new UploadPostTransformErrorEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UploadPostTransformErrorEvent::with( + * id: ..., type: ..., createdAt: ..., data: ..., request: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UploadPostTransformErrorEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->withData(...) + * ->withRequest(...) + * ``` + */ + 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 + * @param Request|RequestShape $request + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + Data|array $data, + Request|array $request, + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + $self['request'] = $request; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * @param Data|DataShape $data + */ + public function withData(Data|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } + + /** + * @param Request|RequestShape $request + */ + public function withRequest(Request|array $request): self + { + $self = clone $this; + $self['request'] = $request; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformErrorEvent/Data.php b/src/Webhooks/UploadPostTransformErrorEvent/Data.php new file mode 100644 index 00000000..c223ce04 --- /dev/null +++ b/src/Webhooks/UploadPostTransformErrorEvent/Data.php @@ -0,0 +1,159 @@ + */ + use SdkModel; + + /** + * Unique identifier of the originally uploaded file. + */ + #[Required('fileId')] + public string $fileID; + + /** + * Name of the file. + */ + #[Required] + public string $name; + + /** + * Path of the file. + */ + #[Required] + public string $path; + + #[Required] + public Transformation $transformation; + + /** + * URL of the attempted post-transformation. + */ + #[Required] + public string $url; + + /** + * `new Data()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Data::with(fileID: ..., name: ..., path: ..., transformation: ..., url: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Data) + * ->withFileID(...) + * ->withName(...) + * ->withPath(...) + * ->withTransformation(...) + * ->withURL(...) + * ``` + */ + 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 Transformation|TransformationShape $transformation + */ + public static function with( + string $fileID, + string $name, + string $path, + Transformation|array $transformation, + string $url, + ): self { + $self = new self; + + $self['fileID'] = $fileID; + $self['name'] = $name; + $self['path'] = $path; + $self['transformation'] = $transformation; + $self['url'] = $url; + + return $self; + } + + /** + * Unique identifier of the originally uploaded file. + */ + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } + + /** + * Name of the file. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Path of the file. + */ + public function withPath(string $path): self + { + $self = clone $this; + $self['path'] = $path; + + return $self; + } + + /** + * @param Transformation|TransformationShape $transformation + */ + public function withTransformation( + Transformation|array $transformation + ): self { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * URL of the attempted post-transformation. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformErrorEvent/Data/Transformation.php b/src/Webhooks/UploadPostTransformErrorEvent/Data/Transformation.php new file mode 100644 index 00000000..cfd37551 --- /dev/null +++ b/src/Webhooks/UploadPostTransformErrorEvent/Data/Transformation.php @@ -0,0 +1,70 @@ + */ + use SdkModel; + + #[Required] + public Error $error; + + /** + * `new Transformation()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Transformation::with(error: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Transformation)->withError(...) + * ``` + */ + 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 Error|ErrorShape $error + */ + public static function with(Error|array $error): self + { + $self = new self; + + $self['error'] = $error; + + return $self; + } + + /** + * @param Error|ErrorShape $error + */ + public function withError(Error|array $error): self + { + $self = clone $this; + $self['error'] = $error; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformErrorEvent/Data/Transformation/Error.php b/src/Webhooks/UploadPostTransformErrorEvent/Data/Transformation/Error.php new file mode 100644 index 00000000..130de60e --- /dev/null +++ b/src/Webhooks/UploadPostTransformErrorEvent/Data/Transformation/Error.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * Reason for the post-transformation failure. + */ + #[Required] + public string $reason; + + /** + * `new Error()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Error::with(reason: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Error)->withReason(...) + * ``` + */ + 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(string $reason): self + { + $self = new self; + + $self['reason'] = $reason; + + return $self; + } + + /** + * Reason for the post-transformation failure. + */ + public function withReason(string $reason): self + { + $self = clone $this; + $self['reason'] = $reason; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformErrorEvent/Request.php b/src/Webhooks/UploadPostTransformErrorEvent/Request.php new file mode 100644 index 00000000..9b42fa05 --- /dev/null +++ b/src/Webhooks/UploadPostTransformErrorEvent/Request.php @@ -0,0 +1,93 @@ + */ + use SdkModel; + + #[Required] + public Transformation $transformation; + + /** + * Unique identifier for the originating request. + */ + #[Required('x_request_id')] + public string $xRequestID; + + /** + * `new Request()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Request::with(transformation: ..., xRequestID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Request)->withTransformation(...)->withXRequestID(...) + * ``` + */ + 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 Transformation|TransformationShape $transformation + */ + public static function with( + Transformation|array $transformation, + string $xRequestID + ): self { + $self = new self; + + $self['transformation'] = $transformation; + $self['xRequestID'] = $xRequestID; + + return $self; + } + + /** + * @param Transformation|TransformationShape $transformation + */ + public function withTransformation( + Transformation|array $transformation + ): self { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Unique identifier for the originating request. + */ + public function withXRequestID(string $xRequestID): self + { + $self = clone $this; + $self['xRequestID'] = $xRequestID; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformErrorEvent/Request/Transformation.php b/src/Webhooks/UploadPostTransformErrorEvent/Request/Transformation.php new file mode 100644 index 00000000..a02d4598 --- /dev/null +++ b/src/Webhooks/UploadPostTransformErrorEvent/Request/Transformation.php @@ -0,0 +1,126 @@ +, + * protocol?: null|Protocol|value-of, + * value?: string|null, + * } + */ +final class Transformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of the requested post-transformation. + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * Only applicable if transformation type is 'abs'. Streaming protocol used. + * + * @var value-of|null $protocol + */ + #[Optional(enum: Protocol::class)] + public ?string $protocol; + + /** + * Value for the requested transformation type. + */ + #[Optional] + public ?string $value; + + /** + * `new Transformation()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Transformation::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Transformation)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param Protocol|value-of|null $protocol + */ + public static function with( + Type|string $type, + Protocol|string|null $protocol = null, + ?string $value = null + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $protocol && $self['protocol'] = $protocol; + null !== $value && $self['value'] = $value; + + return $self; + } + + /** + * Type of the requested post-transformation. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Only applicable if transformation type is 'abs'. Streaming protocol used. + * + * @param Protocol|value-of $protocol + */ + public function withProtocol(Protocol|string $protocol): self + { + $self = clone $this; + $self['protocol'] = $protocol; + + return $self; + } + + /** + * Value for the requested transformation type. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformErrorEvent/Request/Transformation/Protocol.php b/src/Webhooks/UploadPostTransformErrorEvent/Request/Transformation/Protocol.php new file mode 100644 index 00000000..f6f399cc --- /dev/null +++ b/src/Webhooks/UploadPostTransformErrorEvent/Request/Transformation/Protocol.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + #[Required] + public Data $data; + + #[Required] + public Request $request; + + /** + * `new UploadPostTransformSuccessEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UploadPostTransformSuccessEvent::with( + * id: ..., type: ..., createdAt: ..., data: ..., request: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UploadPostTransformSuccessEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->withData(...) + * ->withRequest(...) + * ``` + */ + 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 + * @param Request|RequestShape $request + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + Data|array $data, + Request|array $request, + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + $self['request'] = $request; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * @param Data|DataShape $data + */ + public function withData(Data|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } + + /** + * @param Request|RequestShape $request + */ + public function withRequest(Request|array $request): self + { + $self = clone $this; + $self['request'] = $request; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformSuccessEvent/Data.php b/src/Webhooks/UploadPostTransformSuccessEvent/Data.php new file mode 100644 index 00000000..966e7d9e --- /dev/null +++ b/src/Webhooks/UploadPostTransformSuccessEvent/Data.php @@ -0,0 +1,104 @@ + */ + use SdkModel; + + /** + * Unique identifier of the originally uploaded file. + */ + #[Required('fileId')] + public string $fileID; + + /** + * Name of the file. + */ + #[Required] + public string $name; + + /** + * URL of the generated post-transformation. + */ + #[Required] + public string $url; + + /** + * `new Data()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Data::with(fileID: ..., name: ..., url: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Data)->withFileID(...)->withName(...)->withURL(...) + * ``` + */ + 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(string $fileID, string $name, string $url): self + { + $self = new self; + + $self['fileID'] = $fileID; + $self['name'] = $name; + $self['url'] = $url; + + return $self; + } + + /** + * Unique identifier of the originally uploaded file. + */ + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } + + /** + * Name of the file. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * URL of the generated post-transformation. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformSuccessEvent/Request.php b/src/Webhooks/UploadPostTransformSuccessEvent/Request.php new file mode 100644 index 00000000..5a7e25ad --- /dev/null +++ b/src/Webhooks/UploadPostTransformSuccessEvent/Request.php @@ -0,0 +1,93 @@ + */ + use SdkModel; + + #[Required] + public Transformation $transformation; + + /** + * Unique identifier for the originating request. + */ + #[Required('x_request_id')] + public string $xRequestID; + + /** + * `new Request()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Request::with(transformation: ..., xRequestID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Request)->withTransformation(...)->withXRequestID(...) + * ``` + */ + 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 Transformation|TransformationShape $transformation + */ + public static function with( + Transformation|array $transformation, + string $xRequestID + ): self { + $self = new self; + + $self['transformation'] = $transformation; + $self['xRequestID'] = $xRequestID; + + return $self; + } + + /** + * @param Transformation|TransformationShape $transformation + */ + public function withTransformation( + Transformation|array $transformation + ): self { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Unique identifier for the originating request. + */ + public function withXRequestID(string $xRequestID): self + { + $self = clone $this; + $self['xRequestID'] = $xRequestID; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformSuccessEvent/Request/Transformation.php b/src/Webhooks/UploadPostTransformSuccessEvent/Request/Transformation.php new file mode 100644 index 00000000..594940bb --- /dev/null +++ b/src/Webhooks/UploadPostTransformSuccessEvent/Request/Transformation.php @@ -0,0 +1,126 @@ +, + * protocol?: null|Protocol|value-of, + * value?: string|null, + * } + */ +final class Transformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of the requested post-transformation. + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * Only applicable if transformation type is 'abs'. Streaming protocol used. + * + * @var value-of|null $protocol + */ + #[Optional(enum: Protocol::class)] + public ?string $protocol; + + /** + * Value for the requested transformation type. + */ + #[Optional] + public ?string $value; + + /** + * `new Transformation()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Transformation::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Transformation)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param Protocol|value-of|null $protocol + */ + public static function with( + Type|string $type, + Protocol|string|null $protocol = null, + ?string $value = null + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $protocol && $self['protocol'] = $protocol; + null !== $value && $self['value'] = $value; + + return $self; + } + + /** + * Type of the requested post-transformation. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Only applicable if transformation type is 'abs'. Streaming protocol used. + * + * @param Protocol|value-of $protocol + */ + public function withProtocol(Protocol|string $protocol): self + { + $self = clone $this; + $self['protocol'] = $protocol; + + return $self; + } + + /** + * Value for the requested transformation type. + */ + public function withValue(string $value): self + { + $self = clone $this; + $self['value'] = $value; + + return $self; + } +} diff --git a/src/Webhooks/UploadPostTransformSuccessEvent/Request/Transformation/Protocol.php b/src/Webhooks/UploadPostTransformSuccessEvent/Request/Transformation/Protocol.php new file mode 100644 index 00000000..e9a8d491 --- /dev/null +++ b/src/Webhooks/UploadPostTransformSuccessEvent/Request/Transformation/Protocol.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + #[Required] + public Data $data; + + #[Required] + public Request $request; + + /** + * `new UploadPreTransformErrorEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UploadPreTransformErrorEvent::with( + * id: ..., type: ..., createdAt: ..., data: ..., request: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UploadPreTransformErrorEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->withData(...) + * ->withRequest(...) + * ``` + */ + 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 + * @param Request|RequestShape $request + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + Data|array $data, + Request|array $request, + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + $self['request'] = $request; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * @param Data|DataShape $data + */ + public function withData(Data|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } + + /** + * @param Request|RequestShape $request + */ + public function withRequest(Request|array $request): self + { + $self = clone $this; + $self['request'] = $request; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformErrorEvent/Data.php b/src/Webhooks/UploadPreTransformErrorEvent/Data.php new file mode 100644 index 00000000..5b17752d --- /dev/null +++ b/src/Webhooks/UploadPreTransformErrorEvent/Data.php @@ -0,0 +1,112 @@ + */ + use SdkModel; + + /** + * Name of the file. + */ + #[Required] + public string $name; + + /** + * Path of the file. + */ + #[Required] + public string $path; + + #[Required] + public Transformation $transformation; + + /** + * `new Data()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Data::with(name: ..., path: ..., transformation: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Data)->withName(...)->withPath(...)->withTransformation(...) + * ``` + */ + 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 Transformation|TransformationShape $transformation + */ + public static function with( + string $name, + string $path, + Transformation|array $transformation + ): self { + $self = new self; + + $self['name'] = $name; + $self['path'] = $path; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Name of the file. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Path of the file. + */ + public function withPath(string $path): self + { + $self = clone $this; + $self['path'] = $path; + + return $self; + } + + /** + * @param Transformation|TransformationShape $transformation + */ + public function withTransformation( + Transformation|array $transformation + ): self { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformErrorEvent/Data/Transformation.php b/src/Webhooks/UploadPreTransformErrorEvent/Data/Transformation.php new file mode 100644 index 00000000..95c2165e --- /dev/null +++ b/src/Webhooks/UploadPreTransformErrorEvent/Data/Transformation.php @@ -0,0 +1,70 @@ + */ + use SdkModel; + + #[Required] + public Error $error; + + /** + * `new Transformation()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Transformation::with(error: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Transformation)->withError(...) + * ``` + */ + 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 Error|ErrorShape $error + */ + public static function with(Error|array $error): self + { + $self = new self; + + $self['error'] = $error; + + return $self; + } + + /** + * @param Error|ErrorShape $error + */ + public function withError(Error|array $error): self + { + $self = clone $this; + $self['error'] = $error; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformErrorEvent/Data/Transformation/Error.php b/src/Webhooks/UploadPreTransformErrorEvent/Data/Transformation/Error.php new file mode 100644 index 00000000..e3e2c31b --- /dev/null +++ b/src/Webhooks/UploadPreTransformErrorEvent/Data/Transformation/Error.php @@ -0,0 +1,68 @@ + */ + use SdkModel; + + /** + * Reason for the pre-transformation failure. + */ + #[Required] + public string $reason; + + /** + * `new Error()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Error::with(reason: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Error)->withReason(...) + * ``` + */ + 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(string $reason): self + { + $self = new self; + + $self['reason'] = $reason; + + return $self; + } + + /** + * Reason for the pre-transformation failure. + */ + public function withReason(string $reason): self + { + $self = clone $this; + $self['reason'] = $reason; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformErrorEvent/Request.php b/src/Webhooks/UploadPreTransformErrorEvent/Request.php new file mode 100644 index 00000000..3c641161 --- /dev/null +++ b/src/Webhooks/UploadPreTransformErrorEvent/Request.php @@ -0,0 +1,88 @@ + */ + use SdkModel; + + /** + * The requested pre-transformation string. + */ + #[Required] + public string $transformation; + + /** + * Unique identifier for the originating request. + */ + #[Required('x_request_id')] + public string $xRequestID; + + /** + * `new Request()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Request::with(transformation: ..., xRequestID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Request)->withTransformation(...)->withXRequestID(...) + * ``` + */ + 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( + string $transformation, + string $xRequestID + ): self { + $self = new self; + + $self['transformation'] = $transformation; + $self['xRequestID'] = $xRequestID; + + return $self; + } + + /** + * The requested pre-transformation string. + */ + public function withTransformation(string $transformation): self + { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Unique identifier for the originating request. + */ + public function withXRequestID(string $xRequestID): self + { + $self = clone $this; + $self['xRequestID'] = $xRequestID; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent.php b/src/Webhooks/UploadPreTransformSuccessEvent.php new file mode 100644 index 00000000..b4c57508 --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent.php @@ -0,0 +1,167 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + /** + * Object containing details of a successful upload. + */ + #[Required] + public Data $data; + + #[Required] + public Request $request; + + /** + * `new UploadPreTransformSuccessEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * UploadPreTransformSuccessEvent::with( + * id: ..., type: ..., createdAt: ..., data: ..., request: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new UploadPreTransformSuccessEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->withData(...) + * ->withRequest(...) + * ``` + */ + 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 + * @param Request|RequestShape $request + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + Data|array $data, + Request|array $request, + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + $self['request'] = $request; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp of when the event occurred in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * Object containing details of a successful upload. + * + * @param Data|DataShape $data + */ + public function withData(Data|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } + + /** + * @param Request|RequestShape $request + */ + public function withRequest(Request|array $request): self + { + $self = clone $this; + $self['request'] = $request; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data.php new file mode 100644 index 00000000..2b5d0279 --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data.php @@ -0,0 +1,606 @@ +|null, + * audioCodec?: string|null, + * bitRate?: int|null, + * customCoordinates?: string|null, + * customMetadata?: array|null, + * description?: string|null, + * duration?: int|null, + * embeddedMetadata?: array|null, + * extensionStatus?: null|ExtensionStatus|ExtensionStatusShape, + * fileID?: string|null, + * filePath?: string|null, + * fileType?: string|null, + * height?: float|null, + * isPrivateFile?: bool|null, + * isPublished?: bool|null, + * metadata?: null|Metadata|MetadataShape, + * name?: string|null, + * selectedFieldsSchema?: array|null, + * size?: float|null, + * tags?: list|null, + * thumbnailURL?: string|null, + * url?: string|null, + * versionInfo?: null|VersionInfo|VersionInfoShape, + * videoCodec?: string|null, + * width?: float|null, + * } + */ +final class Data implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * An array of tags assigned to the uploaded file by auto tagging. + * + * @var list|null $aiTags + */ + #[Optional('AITags', list: AITag::class, nullable: true)] + public ?array $aiTags; + + /** + * The audio codec used in the video (only for video). + */ + #[Optional] + public ?string $audioCodec; + + /** + * The bit rate of the video in kbps (only for video). + */ + #[Optional] + public ?int $bitRate; + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in `responseFields` in API request to get the value of this field. + */ + #[Optional(nullable: true)] + public ?string $customCoordinates; + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get `customMetadata` in the upload API response. Before setting any custom metadata on an asset, you have to create the field using custom metadata fields API. Send `customMetadata` in `responseFields` in API request to get the value of this field. + * + * @var array|null $customMetadata + */ + #[Optional(map: 'mixed')] + public ?array $customMetadata; + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + #[Optional] + public ?string $description; + + /** + * The duration of the video in seconds (only for video). + */ + #[Optional] + public ?int $duration; + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in the upload API response. + * + * @var array|null $embeddedMetadata + */ + #[Optional(map: 'mixed')] + public ?array $embeddedMetadata; + + /** + * Extension names with their processing status at the time of completion of the request. It could have one of the following status values: + * + * `success`: The extension has been successfully applied. + * `failed`: The extension has failed and will not be retried. + * `pending`: The extension will finish processing in some time. On completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + */ + #[Optional] + public ?ExtensionStatus $extensionStatus; + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update action on this file. + */ + #[Optional('fileId')] + public ?string $fileID; + + /** + * The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + */ + #[Optional] + public ?string $filePath; + + /** + * Type of the uploaded file. Possible values are `image`, `non-image`. + */ + #[Optional] + public ?string $fileType; + + /** + * Height of the image in pixels (Only for images). + */ + #[Optional] + public ?float $height; + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` in `responseFields` in API request to get the value of this field. + */ + #[Optional] + public ?bool $isPrivateFile; + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send `isPublished` in `responseFields` in API request to get the value of this field. + */ + #[Optional] + public ?bool $isPublished; + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the upload API response. + */ + #[Optional] + public ?Metadata $metadata; + + /** + * Name of the asset. + */ + #[Optional] + public ?string $name; + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @var array|null $selectedFieldsSchema + */ + #[Optional(map: SelectedFieldsSchema::class)] + public ?array $selectedFieldsSchema; + + /** + * Size of the image file in Bytes. + */ + #[Optional] + public ?float $size; + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send `tags` in `responseFields` in API request to get the value of this field. + * + * @var list|null $tags + */ + #[Optional(list: 'string', nullable: true)] + public ?array $tags; + + /** + * In the case of an image, a small thumbnail URL. + */ + #[Optional('thumbnailUrl')] + public ?string $thumbnailURL; + + /** + * A publicly accessible URL of the file. + */ + #[Optional] + public ?string $url; + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + */ + #[Optional] + public ?VersionInfo $versionInfo; + + /** + * The video codec used in the video (only for video). + */ + #[Optional] + public ?string $videoCodec; + + /** + * Width of the image in pixels (Only for Images). + */ + #[Optional] + public ?float $width; + + 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 list|null $aiTags + * @param array|null $customMetadata + * @param array|null $embeddedMetadata + * @param ExtensionStatus|ExtensionStatusShape|null $extensionStatus + * @param Metadata|MetadataShape|null $metadata + * @param array|null $selectedFieldsSchema + * @param list|null $tags + * @param VersionInfo|VersionInfoShape|null $versionInfo + */ + public static function with( + ?array $aiTags = null, + ?string $audioCodec = null, + ?int $bitRate = null, + ?string $customCoordinates = null, + ?array $customMetadata = null, + ?string $description = null, + ?int $duration = null, + ?array $embeddedMetadata = null, + ExtensionStatus|array|null $extensionStatus = null, + ?string $fileID = null, + ?string $filePath = null, + ?string $fileType = null, + ?float $height = null, + ?bool $isPrivateFile = null, + ?bool $isPublished = null, + Metadata|array|null $metadata = null, + ?string $name = null, + ?array $selectedFieldsSchema = null, + ?float $size = null, + ?array $tags = null, + ?string $thumbnailURL = null, + ?string $url = null, + VersionInfo|array|null $versionInfo = null, + ?string $videoCodec = null, + ?float $width = null, + ): self { + $self = new self; + + null !== $aiTags && $self['aiTags'] = $aiTags; + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $bitRate && $self['bitRate'] = $bitRate; + null !== $customCoordinates && $self['customCoordinates'] = $customCoordinates; + null !== $customMetadata && $self['customMetadata'] = $customMetadata; + null !== $description && $self['description'] = $description; + null !== $duration && $self['duration'] = $duration; + null !== $embeddedMetadata && $self['embeddedMetadata'] = $embeddedMetadata; + null !== $extensionStatus && $self['extensionStatus'] = $extensionStatus; + null !== $fileID && $self['fileID'] = $fileID; + null !== $filePath && $self['filePath'] = $filePath; + null !== $fileType && $self['fileType'] = $fileType; + null !== $height && $self['height'] = $height; + null !== $isPrivateFile && $self['isPrivateFile'] = $isPrivateFile; + null !== $isPublished && $self['isPublished'] = $isPublished; + null !== $metadata && $self['metadata'] = $metadata; + null !== $name && $self['name'] = $name; + null !== $selectedFieldsSchema && $self['selectedFieldsSchema'] = $selectedFieldsSchema; + null !== $size && $self['size'] = $size; + null !== $tags && $self['tags'] = $tags; + null !== $thumbnailURL && $self['thumbnailURL'] = $thumbnailURL; + null !== $url && $self['url'] = $url; + null !== $versionInfo && $self['versionInfo'] = $versionInfo; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + null !== $width && $self['width'] = $width; + + return $self; + } + + /** + * An array of tags assigned to the uploaded file by auto tagging. + * + * @param list|null $aiTags + */ + public function withAITags(?array $aiTags): self + { + $self = clone $this; + $self['aiTags'] = $aiTags; + + return $self; + } + + /** + * The audio codec used in the video (only for video). + */ + public function withAudioCodec(string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * The bit rate of the video in kbps (only for video). + */ + public function withBitRate(int $bitRate): self + { + $self = clone $this; + $self['bitRate'] = $bitRate; + + return $self; + } + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in `responseFields` in API request to get the value of this field. + */ + public function withCustomCoordinates(?string $customCoordinates): self + { + $self = clone $this; + $self['customCoordinates'] = $customCoordinates; + + return $self; + } + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get `customMetadata` in the upload API response. Before setting any custom metadata on an asset, you have to create the field using custom metadata fields API. Send `customMetadata` in `responseFields` in API request to get the value of this field. + * + * @param array $customMetadata + */ + public function withCustomMetadata(array $customMetadata): self + { + $self = clone $this; + $self['customMetadata'] = $customMetadata; + + return $self; + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the ai-auto-description extension. + */ + public function withDescription(string $description): self + { + $self = clone $this; + $self['description'] = $description; + + return $self; + } + + /** + * The duration of the video in seconds (only for video). + */ + public function withDuration(int $duration): self + { + $self = clone $this; + $self['duration'] = $duration; + + return $self; + } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in the upload API response. + * + * @param array $embeddedMetadata + */ + public function withEmbeddedMetadata(array $embeddedMetadata): self + { + $self = clone $this; + $self['embeddedMetadata'] = $embeddedMetadata; + + return $self; + } + + /** + * Extension names with their processing status at the time of completion of the request. It could have one of the following status values: + * + * `success`: The extension has been successfully applied. + * `failed`: The extension has failed and will not be retried. + * `pending`: The extension will finish processing in some time. On completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + * + * @param ExtensionStatus|ExtensionStatusShape $extensionStatus + */ + public function withExtensionStatus( + ExtensionStatus|array $extensionStatus + ): self { + $self = clone $this; + $self['extensionStatus'] = $extensionStatus; + + return $self; + } + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update action on this file. + */ + public function withFileID(string $fileID): self + { + $self = clone $this; + $self['fileID'] = $fileID; + + return $self; + } + + /** + * The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + */ + public function withFilePath(string $filePath): self + { + $self = clone $this; + $self['filePath'] = $filePath; + + return $self; + } + + /** + * Type of the uploaded file. Possible values are `image`, `non-image`. + */ + public function withFileType(string $fileType): self + { + $self = clone $this; + $self['fileType'] = $fileType; + + return $self; + } + + /** + * Height of the image in pixels (Only for images). + */ + public function withHeight(float $height): self + { + $self = clone $this; + $self['height'] = $height; + + return $self; + } + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` in `responseFields` in API request to get the value of this field. + */ + public function withIsPrivateFile(bool $isPrivateFile): self + { + $self = clone $this; + $self['isPrivateFile'] = $isPrivateFile; + + return $self; + } + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send `isPublished` in `responseFields` in API request to get the value of this field. + */ + public function withIsPublished(bool $isPublished): self + { + $self = clone $this; + $self['isPublished'] = $isPublished; + + return $self; + } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the upload API response. + * + * @param Metadata|MetadataShape $metadata + */ + public function withMetadata(Metadata|array $metadata): self + { + $self = clone $this; + $self['metadata'] = $metadata; + + return $self; + } + + /** + * Name of the asset. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file path. + * Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom metadata schema. + * + * @param array $selectedFieldsSchema + */ + public function withSelectedFieldsSchema(array $selectedFieldsSchema): self + { + $self = clone $this; + $self['selectedFieldsSchema'] = $selectedFieldsSchema; + + return $self; + } + + /** + * Size of the image file in Bytes. + */ + public function withSize(float $size): self + { + $self = clone $this; + $self['size'] = $size; + + return $self; + } + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send `tags` in `responseFields` in API request to get the value of this field. + * + * @param list|null $tags + */ + public function withTags(?array $tags): self + { + $self = clone $this; + $self['tags'] = $tags; + + return $self; + } + + /** + * In the case of an image, a small thumbnail URL. + */ + public function withThumbnailURL(string $thumbnailURL): self + { + $self = clone $this; + $self['thumbnailURL'] = $thumbnailURL; + + return $self; + } + + /** + * A publicly accessible URL of the file. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + * + * @param VersionInfo|VersionInfoShape $versionInfo + */ + public function withVersionInfo(VersionInfo|array $versionInfo): self + { + $self = clone $this; + $self['versionInfo'] = $versionInfo; + + return $self; + } + + /** + * The video codec used in the video (only for video). + */ + public function withVideoCodec(string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * Width of the image in pixels (Only for Images). + */ + public function withWidth(float $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data/AITag.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data/AITag.php new file mode 100644 index 00000000..f32e6d15 --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data/AITag.php @@ -0,0 +1,97 @@ + */ + use SdkModel; + + /** + * Confidence score of the tag. + */ + #[Optional] + public ?float $confidence; + + /** + * Name of the tag. + */ + #[Optional] + public ?string $name; + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + */ + #[Optional] + public ?string $source; + + 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( + ?float $confidence = null, + ?string $name = null, + ?string $source = null + ): self { + $self = new self; + + null !== $confidence && $self['confidence'] = $confidence; + null !== $name && $self['name'] = $name; + null !== $source && $self['source'] = $source; + + return $self; + } + + /** + * Confidence score of the tag. + */ + public function withConfidence(float $confidence): self + { + $self = clone $this; + $self['confidence'] = $confidence; + + return $self; + } + + /** + * Name of the tag. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + */ + public function withSource(string $source): self + { + $self = clone $this; + $self['source'] = $source; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data/ExtensionStatus.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data/ExtensionStatus.php new file mode 100644 index 00000000..5c0cf5ab --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data/ExtensionStatus.php @@ -0,0 +1,149 @@ +, + * aiTasks?: null|AITasks|value-of, + * awsAutoTagging?: null|AwsAutoTagging|value-of, + * googleAutoTagging?: null|GoogleAutoTagging|value-of, + * removeBg?: null|RemoveBg|value-of, + * } + */ +final class ExtensionStatus implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** @var value-of|null $aiAutoDescription */ + #[Optional('ai-auto-description', enum: AIAutoDescription::class)] + public ?string $aiAutoDescription; + + /** @var value-of|null $aiTasks */ + #[Optional('ai-tasks', enum: AITasks::class)] + public ?string $aiTasks; + + /** @var value-of|null $awsAutoTagging */ + #[Optional('aws-auto-tagging', enum: AwsAutoTagging::class)] + public ?string $awsAutoTagging; + + /** @var value-of|null $googleAutoTagging */ + #[Optional('google-auto-tagging', enum: GoogleAutoTagging::class)] + public ?string $googleAutoTagging; + + /** @var value-of|null $removeBg */ + #[Optional('remove-bg', enum: RemoveBg::class)] + public ?string $removeBg; + + 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 AIAutoDescription|value-of|null $aiAutoDescription + * @param AITasks|value-of|null $aiTasks + * @param AwsAutoTagging|value-of|null $awsAutoTagging + * @param GoogleAutoTagging|value-of|null $googleAutoTagging + * @param RemoveBg|value-of|null $removeBg + */ + public static function with( + AIAutoDescription|string|null $aiAutoDescription = null, + AITasks|string|null $aiTasks = null, + AwsAutoTagging|string|null $awsAutoTagging = null, + GoogleAutoTagging|string|null $googleAutoTagging = null, + RemoveBg|string|null $removeBg = null, + ): self { + $self = new self; + + null !== $aiAutoDescription && $self['aiAutoDescription'] = $aiAutoDescription; + null !== $aiTasks && $self['aiTasks'] = $aiTasks; + null !== $awsAutoTagging && $self['awsAutoTagging'] = $awsAutoTagging; + null !== $googleAutoTagging && $self['googleAutoTagging'] = $googleAutoTagging; + null !== $removeBg && $self['removeBg'] = $removeBg; + + return $self; + } + + /** + * @param AIAutoDescription|value-of $aiAutoDescription + */ + public function withAIAutoDescription( + AIAutoDescription|string $aiAutoDescription + ): self { + $self = clone $this; + $self['aiAutoDescription'] = $aiAutoDescription; + + return $self; + } + + /** + * @param AITasks|value-of $aiTasks + */ + public function withAITasks(AITasks|string $aiTasks): self + { + $self = clone $this; + $self['aiTasks'] = $aiTasks; + + return $self; + } + + /** + * @param AwsAutoTagging|value-of $awsAutoTagging + */ + public function withAwsAutoTagging( + AwsAutoTagging|string $awsAutoTagging + ): self { + $self = clone $this; + $self['awsAutoTagging'] = $awsAutoTagging; + + return $self; + } + + /** + * @param GoogleAutoTagging|value-of $googleAutoTagging + */ + public function withGoogleAutoTagging( + GoogleAutoTagging|string $googleAutoTagging + ): self { + $self = clone $this; + $self['googleAutoTagging'] = $googleAutoTagging; + + return $self; + } + + /** + * @param RemoveBg|value-of $removeBg + */ + public function withRemoveBg(RemoveBg|string $removeBg): self + { + $self = clone $this; + $self['removeBg'] = $removeBg; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data/ExtensionStatus/AIAutoDescription.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data/ExtensionStatus/AIAutoDescription.php new file mode 100644 index 00000000..a9cc5f07 --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data/ExtensionStatus/AIAutoDescription.php @@ -0,0 +1,14 @@ +, + * defaultValue?: DefaultValueShape|null, + * isValueRequired?: bool|null, + * maxLength?: float|null, + * maxValue?: MaxValueShape|null, + * minLength?: float|null, + * minValue?: MinValueShape|null, + * readOnly?: bool|null, + * selectOptions?: list|null, + * selectOptionsTruncated?: bool|null, + * } + */ +final class SelectedFieldsSchema implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of the custom metadata field. + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * The default value for this custom metadata field. The value should match the `type` of custom metadata field. + * + * @var DefaultValueVariants|null $defaultValue + */ + #[Optional(union: DefaultValue::class)] + public string|float|bool|array|null $defaultValue; + + /** + * Specifies if the custom metadata field is required or not. + */ + #[Optional] + public ?bool $isValueRequired; + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $maxLength; + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MaxValueVariants|null $maxValue + */ + #[Optional] + public string|float|null $maxValue; + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + #[Optional] + public ?float $minLength; + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @var MinValueVariants|null $minValue + */ + #[Optional] + public string|float|null $minValue; + + /** + * Indicates whether the custom metadata field is read only. A read only field cannot be modified after being set. This field is configurable only via the **Path policy** feature. + */ + #[Optional] + public ?bool $readOnly; + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @var list|null $selectOptions + */ + #[Optional(list: SelectOption::class)] + public ?array $selectOptions; + + /** + * Specifies if the selectOptions array is truncated. It is truncated when number of options are > 100. + */ + #[Optional] + public ?bool $selectOptionsTruncated; + + /** + * `new SelectedFieldsSchema()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * SelectedFieldsSchema::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new SelectedFieldsSchema)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param DefaultValueShape|null $defaultValue + * @param MaxValueShape|null $maxValue + * @param MinValueShape|null $minValue + * @param list|null $selectOptions + */ + public static function with( + Type|string $type, + string|float|bool|array|null $defaultValue = null, + ?bool $isValueRequired = null, + ?float $maxLength = null, + string|float|null $maxValue = null, + ?float $minLength = null, + string|float|null $minValue = null, + ?bool $readOnly = null, + ?array $selectOptions = null, + ?bool $selectOptionsTruncated = null, + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $defaultValue && $self['defaultValue'] = $defaultValue; + null !== $isValueRequired && $self['isValueRequired'] = $isValueRequired; + null !== $maxLength && $self['maxLength'] = $maxLength; + null !== $maxValue && $self['maxValue'] = $maxValue; + null !== $minLength && $self['minLength'] = $minLength; + null !== $minValue && $self['minValue'] = $minValue; + null !== $readOnly && $self['readOnly'] = $readOnly; + null !== $selectOptions && $self['selectOptions'] = $selectOptions; + null !== $selectOptionsTruncated && $self['selectOptionsTruncated'] = $selectOptionsTruncated; + + return $self; + } + + /** + * Type of the custom metadata field. + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * The default value for this custom metadata field. The value should match the `type` of custom metadata field. + * + * @param DefaultValueShape $defaultValue + */ + public function withDefaultValue( + string|float|bool|array $defaultValue + ): self { + $self = clone $this; + $self['defaultValue'] = $defaultValue; + + return $self; + } + + /** + * Specifies if the custom metadata field is required or not. + */ + public function withIsValueRequired(bool $isValueRequired): self + { + $self = clone $this; + $self['isValueRequired'] = $isValueRequired; + + return $self; + } + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMaxLength(float $maxLength): self + { + $self = clone $this; + $self['maxLength'] = $maxLength; + + return $self; + } + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MaxValueShape $maxValue + */ + public function withMaxValue(string|float $maxValue): self + { + $self = clone $this; + $self['maxValue'] = $maxValue; + + return $self; + } + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + */ + public function withMinLength(float $minLength): self + { + $self = clone $this; + $self['minLength'] = $minLength; + + return $self; + } + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value. + * + * @param MinValueShape $minValue + */ + public function withMinValue(string|float $minValue): self + { + $self = clone $this; + $self['minValue'] = $minValue; + + return $self; + } + + /** + * Indicates whether the custom metadata field is read only. A read only field cannot be modified after being set. This field is configurable only via the **Path policy** feature. + */ + public function withReadOnly(bool $readOnly): self + { + $self = clone $this; + $self['readOnly'] = $readOnly; + + return $self; + } + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @param list $selectOptions + */ + public function withSelectOptions(array $selectOptions): self + { + $self = clone $this; + $self['selectOptions'] = $selectOptions; + + return $self; + } + + /** + * Specifies if the selectOptions array is truncated. It is truncated when number of options are > 100. + */ + public function withSelectOptionsTruncated( + bool $selectOptionsTruncated + ): self { + $self = clone $this; + $self['selectOptionsTruncated'] = $selectOptionsTruncated; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/DefaultValue.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/DefaultValue.php new file mode 100644 index 00000000..8adaf3a1 --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/DefaultValue.php @@ -0,0 +1,32 @@ + + * @phpstan-type DefaultValueShape = DefaultValueVariants|list + */ +final class DefaultValue implements ConverterSource +{ + use SdkUnion; + + /** + * @return list|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool', new ListOf(Mixed_::class)]; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/DefaultValue/Mixed_.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/DefaultValue/Mixed_.php new file mode 100644 index 00000000..60f3a6e5 --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/DefaultValue/Mixed_.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/MaxValue.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/MaxValue.php new file mode 100644 index 00000000..07daa097 --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/MaxValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/MinValue.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/MinValue.php new file mode 100644 index 00000000..c1dd20ae --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/MinValue.php @@ -0,0 +1,28 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float']; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/SelectOption.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/SelectOption.php new file mode 100644 index 00000000..db28a90f --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/SelectOption.php @@ -0,0 +1,26 @@ +|array + */ + public static function variants(): array + { + return ['string', 'float', 'bool']; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/Type.php b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/Type.php new file mode 100644 index 00000000..3f000dee --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Data/SelectedFieldsSchema/Type.php @@ -0,0 +1,25 @@ + */ + use SdkModel; + + /** + * Unique identifier of the file version. + */ + #[Optional] + public ?string $id; + + /** + * Name of the file version. + */ + #[Optional] + public ?string $name; + + 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(?string $id = null, ?string $name = null): self + { + $self = new self; + + null !== $id && $self['id'] = $id; + null !== $name && $self['name'] = $name; + + return $self; + } + + /** + * Unique identifier of the file version. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * Name of the file version. + */ + public function withName(string $name): self + { + $self = clone $this; + $self['name'] = $name; + + return $self; + } +} diff --git a/src/Webhooks/UploadPreTransformSuccessEvent/Request.php b/src/Webhooks/UploadPreTransformSuccessEvent/Request.php new file mode 100644 index 00000000..caa7f2c5 --- /dev/null +++ b/src/Webhooks/UploadPreTransformSuccessEvent/Request.php @@ -0,0 +1,88 @@ + */ + use SdkModel; + + /** + * The requested pre-transformation string. + */ + #[Required] + public string $transformation; + + /** + * Unique identifier for the originating request. + */ + #[Required('x_request_id')] + public string $xRequestID; + + /** + * `new Request()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Request::with(transformation: ..., xRequestID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Request)->withTransformation(...)->withXRequestID(...) + * ``` + */ + 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( + string $transformation, + string $xRequestID + ): self { + $self = new self; + + $self['transformation'] = $transformation; + $self['xRequestID'] = $xRequestID; + + return $self; + } + + /** + * The requested pre-transformation string. + */ + public function withTransformation(string $transformation): self + { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Unique identifier for the originating request. + */ + public function withXRequestID(string $xRequestID): self + { + $self = clone $this; + $self['xRequestID'] = $xRequestID; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationAcceptedEvent.php b/src/Webhooks/VideoTransformationAcceptedEvent.php new file mode 100644 index 00000000..1b03f04f --- /dev/null +++ b/src/Webhooks/VideoTransformationAcceptedEvent.php @@ -0,0 +1,167 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp when the event was created in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + #[Required] + public Data $data; + + /** + * Information about the original request that triggered the video transformation. + */ + #[Required] + public Request $request; + + /** + * `new VideoTransformationAcceptedEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * VideoTransformationAcceptedEvent::with( + * id: ..., type: ..., createdAt: ..., data: ..., request: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new VideoTransformationAcceptedEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->withData(...) + * ->withRequest(...) + * ``` + */ + 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 + * @param Request|RequestShape $request + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + Data|array $data, + Request|array $request, + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + $self['request'] = $request; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp when the event was created in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * @param Data|DataShape $data + */ + public function withData(Data|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } + + /** + * Information about the original request that triggered the video transformation. + * + * @param Request|RequestShape $request + */ + public function withRequest(Request|array $request): self + { + $self = clone $this; + $self['request'] = $request; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationAcceptedEvent/Data.php b/src/Webhooks/VideoTransformationAcceptedEvent/Data.php new file mode 100644 index 00000000..2183b326 --- /dev/null +++ b/src/Webhooks/VideoTransformationAcceptedEvent/Data.php @@ -0,0 +1,103 @@ + */ + use SdkModel; + + /** + * Information about the source video asset being transformed. + */ + #[Required] + public Asset $asset; + + /** + * Base information about a video transformation request. + */ + #[Required] + public Transformation $transformation; + + /** + * `new Data()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Data::with(asset: ..., transformation: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Data)->withAsset(...)->withTransformation(...) + * ``` + */ + 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 Asset|AssetShape $asset + * @param Transformation|TransformationShape $transformation + */ + public static function with( + Asset|array $asset, + Transformation|array $transformation + ): self { + $self = new self; + + $self['asset'] = $asset; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Information about the source video asset being transformed. + * + * @param Asset|AssetShape $asset + */ + public function withAsset(Asset|array $asset): self + { + $self = clone $this; + $self['asset'] = $asset; + + return $self; + } + + /** + * Base information about a video transformation request. + * + * @param Transformation|TransformationShape $transformation + */ + public function withTransformation( + Transformation|array $transformation + ): self { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationAcceptedEvent/Data/Asset.php b/src/Webhooks/VideoTransformationAcceptedEvent/Data/Asset.php new file mode 100644 index 00000000..817c9c2c --- /dev/null +++ b/src/Webhooks/VideoTransformationAcceptedEvent/Data/Asset.php @@ -0,0 +1,70 @@ + */ + use SdkModel; + + /** + * URL to download or access the source video file. + */ + #[Required] + public string $url; + + /** + * `new Asset()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Asset::with(url: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Asset)->withURL(...) + * ``` + */ + 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(string $url): self + { + $self = new self; + + $self['url'] = $url; + + return $self; + } + + /** + * URL to download or access the source video file. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationAcceptedEvent/Data/Transformation.php b/src/Webhooks/VideoTransformationAcceptedEvent/Data/Transformation.php new file mode 100644 index 00000000..15c532d4 --- /dev/null +++ b/src/Webhooks/VideoTransformationAcceptedEvent/Data/Transformation.php @@ -0,0 +1,113 @@ +, options?: null|Options|OptionsShape + * } + */ +final class Transformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * Configuration options for video transformations. + */ + #[Optional] + public ?Options $options; + + /** + * `new Transformation()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Transformation::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Transformation)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param Options|OptionsShape|null $options + */ + public static function with( + Type|string $type, + Options|array|null $options = null + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $options && $self['options'] = $options; + + return $self; + } + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Configuration options for video transformations. + * + * @param Options|OptionsShape $options + */ + public function withOptions(Options|array $options): self + { + $self = clone $this; + $self['options'] = $options; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationAcceptedEvent/Data/Transformation/Options.php b/src/Webhooks/VideoTransformationAcceptedEvent/Data/Transformation/Options.php new file mode 100644 index 00000000..e2c3d608 --- /dev/null +++ b/src/Webhooks/VideoTransformationAcceptedEvent/Data/Transformation/Options.php @@ -0,0 +1,210 @@ +, + * autoRotate?: bool|null, + * format?: null|Format|value-of, + * quality?: int|null, + * streamProtocol?: null|StreamProtocol|value-of, + * variants?: list|null, + * videoCodec?: null|VideoCodec|value-of, + * } + */ +final class Options implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Audio codec used for encoding (aac or opus). + * + * @var value-of|null $audioCodec + */ + #[Optional('audio_codec', enum: AudioCodec::class)] + public ?string $audioCodec; + + /** + * Whether to automatically rotate the video based on metadata. + */ + #[Optional('auto_rotate')] + public ?bool $autoRotate; + + /** + * Output format for the transformed video or thumbnail. + * + * @var value-of|null $format + */ + #[Optional(enum: Format::class)] + public ?string $format; + + /** + * Quality setting for the output video. + */ + #[Optional] + public ?int $quality; + + /** + * Streaming protocol for adaptive bitrate streaming. + * + * @var value-of|null $streamProtocol + */ + #[Optional('stream_protocol', enum: StreamProtocol::class)] + public ?string $streamProtocol; + + /** + * Array of quality representations for adaptive bitrate streaming. + * + * @var list|null $variants + */ + #[Optional(list: 'string')] + public ?array $variants; + + /** + * Video codec used for encoding (h264, vp9, or av1). + * + * @var value-of|null $videoCodec + */ + #[Optional('video_codec', enum: VideoCodec::class)] + public ?string $videoCodec; + + 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 AudioCodec|value-of|null $audioCodec + * @param Format|value-of|null $format + * @param StreamProtocol|value-of|null $streamProtocol + * @param list|null $variants + * @param VideoCodec|value-of|null $videoCodec + */ + public static function with( + AudioCodec|string|null $audioCodec = null, + ?bool $autoRotate = null, + Format|string|null $format = null, + ?int $quality = null, + StreamProtocol|string|null $streamProtocol = null, + ?array $variants = null, + VideoCodec|string|null $videoCodec = null, + ): self { + $self = new self; + + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $autoRotate && $self['autoRotate'] = $autoRotate; + null !== $format && $self['format'] = $format; + null !== $quality && $self['quality'] = $quality; + null !== $streamProtocol && $self['streamProtocol'] = $streamProtocol; + null !== $variants && $self['variants'] = $variants; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * Audio codec used for encoding (aac or opus). + * + * @param AudioCodec|value-of $audioCodec + */ + public function withAudioCodec(AudioCodec|string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * Whether to automatically rotate the video based on metadata. + */ + public function withAutoRotate(bool $autoRotate): self + { + $self = clone $this; + $self['autoRotate'] = $autoRotate; + + return $self; + } + + /** + * Output format for the transformed video or thumbnail. + * + * @param Format|value-of $format + */ + public function withFormat(Format|string $format): self + { + $self = clone $this; + $self['format'] = $format; + + return $self; + } + + /** + * Quality setting for the output video. + */ + public function withQuality(int $quality): self + { + $self = clone $this; + $self['quality'] = $quality; + + return $self; + } + + /** + * Streaming protocol for adaptive bitrate streaming. + * + * @param StreamProtocol|value-of $streamProtocol + */ + public function withStreamProtocol( + StreamProtocol|string $streamProtocol + ): self { + $self = clone $this; + $self['streamProtocol'] = $streamProtocol; + + return $self; + } + + /** + * Array of quality representations for adaptive bitrate streaming. + * + * @param list $variants + */ + public function withVariants(array $variants): self + { + $self = clone $this; + $self['variants'] = $variants; + + return $self; + } + + /** + * Video codec used for encoding (h264, vp9, or av1). + * + * @param VideoCodec|value-of $videoCodec + */ + public function withVideoCodec(VideoCodec|string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationAcceptedEvent/Data/Transformation/Options/AudioCodec.php b/src/Webhooks/VideoTransformationAcceptedEvent/Data/Transformation/Options/AudioCodec.php new file mode 100644 index 00000000..e9034932 --- /dev/null +++ b/src/Webhooks/VideoTransformationAcceptedEvent/Data/Transformation/Options/AudioCodec.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * Full URL of the transformation request that was submitted. + */ + #[Required] + public string $url; + + /** + * Unique identifier for the originating transformation request. + */ + #[Required('x_request_id')] + public string $xRequestID; + + /** + * User-Agent header from the original request that triggered the transformation. + */ + #[Optional('user_agent')] + public ?string $userAgent; + + /** + * `new Request()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Request::with(url: ..., xRequestID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Request)->withURL(...)->withXRequestID(...) + * ``` + */ + 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( + string $url, + string $xRequestID, + ?string $userAgent = null + ): self { + $self = new self; + + $self['url'] = $url; + $self['xRequestID'] = $xRequestID; + + null !== $userAgent && $self['userAgent'] = $userAgent; + + return $self; + } + + /** + * Full URL of the transformation request that was submitted. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } + + /** + * Unique identifier for the originating transformation request. + */ + public function withXRequestID(string $xRequestID): self + { + $self = clone $this; + $self['xRequestID'] = $xRequestID; + + return $self; + } + + /** + * User-Agent header from the original request that triggered the transformation. + */ + public function withUserAgent(string $userAgent): self + { + $self = clone $this; + $self['userAgent'] = $userAgent; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationErrorEvent.php b/src/Webhooks/VideoTransformationErrorEvent.php new file mode 100644 index 00000000..c289d758 --- /dev/null +++ b/src/Webhooks/VideoTransformationErrorEvent.php @@ -0,0 +1,167 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp when the event was created in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + #[Required] + public Data $data; + + /** + * Information about the original request that triggered the video transformation. + */ + #[Required] + public Request $request; + + /** + * `new VideoTransformationErrorEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * VideoTransformationErrorEvent::with( + * id: ..., type: ..., createdAt: ..., data: ..., request: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new VideoTransformationErrorEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->withData(...) + * ->withRequest(...) + * ``` + */ + 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 + * @param Request|RequestShape $request + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + Data|array $data, + Request|array $request, + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + $self['request'] = $request; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp when the event was created in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * @param Data|DataShape $data + */ + public function withData(Data|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } + + /** + * Information about the original request that triggered the video transformation. + * + * @param Request|RequestShape $request + */ + public function withRequest(Request|array $request): self + { + $self = clone $this; + $self['request'] = $request; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationErrorEvent/Data.php b/src/Webhooks/VideoTransformationErrorEvent/Data.php new file mode 100644 index 00000000..0df6009c --- /dev/null +++ b/src/Webhooks/VideoTransformationErrorEvent/Data.php @@ -0,0 +1,98 @@ + */ + use SdkModel; + + /** + * Information about the source video asset being transformed. + */ + #[Required] + public Asset $asset; + + #[Required] + public Transformation $transformation; + + /** + * `new Data()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Data::with(asset: ..., transformation: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Data)->withAsset(...)->withTransformation(...) + * ``` + */ + 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 Asset|AssetShape $asset + * @param Transformation|TransformationShape $transformation + */ + public static function with( + Asset|array $asset, + Transformation|array $transformation + ): self { + $self = new self; + + $self['asset'] = $asset; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Information about the source video asset being transformed. + * + * @param Asset|AssetShape $asset + */ + public function withAsset(Asset|array $asset): self + { + $self = clone $this; + $self['asset'] = $asset; + + return $self; + } + + /** + * @param Transformation|TransformationShape $transformation + */ + public function withTransformation( + Transformation|array $transformation + ): self { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationErrorEvent/Data/Asset.php b/src/Webhooks/VideoTransformationErrorEvent/Data/Asset.php new file mode 100644 index 00000000..a41c76d1 --- /dev/null +++ b/src/Webhooks/VideoTransformationErrorEvent/Data/Asset.php @@ -0,0 +1,70 @@ + */ + use SdkModel; + + /** + * URL to download or access the source video file. + */ + #[Required] + public string $url; + + /** + * `new Asset()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Asset::with(url: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Asset)->withURL(...) + * ``` + */ + 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(string $url): self + { + $self = new self; + + $self['url'] = $url; + + return $self; + } + + /** + * URL to download or access the source video file. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation.php b/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation.php new file mode 100644 index 00000000..16efca63 --- /dev/null +++ b/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation.php @@ -0,0 +1,137 @@ +, + * error?: null|Error|ErrorShape, + * options?: null|Options|OptionsShape, + * } + */ +final class Transformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * Details about the transformation error. + */ + #[Optional] + public ?Error $error; + + /** + * Configuration options for video transformations. + */ + #[Optional] + public ?Options $options; + + /** + * `new Transformation()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Transformation::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Transformation)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param Error|ErrorShape|null $error + * @param Options|OptionsShape|null $options + */ + public static function with( + Type|string $type, + Error|array|null $error = null, + Options|array|null $options = null + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $error && $self['error'] = $error; + null !== $options && $self['options'] = $options; + + return $self; + } + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Details about the transformation error. + * + * @param Error|ErrorShape $error + */ + public function withError(Error|array $error): self + { + $self = clone $this; + $self['error'] = $error; + + return $self; + } + + /** + * Configuration options for video transformations. + * + * @param Options|OptionsShape $options + */ + public function withOptions(Options|array $options): self + { + $self = clone $this; + $self['options'] = $options; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation/Error.php b/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation/Error.php new file mode 100644 index 00000000..06c1d0b1 --- /dev/null +++ b/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation/Error.php @@ -0,0 +1,83 @@ +} + */ +final class Error implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Specific reason for the transformation failure: + * - `encoding_failed`: Error during video encoding process + * - `download_failed`: Could not download source video + * - `internal_server_error`: Unexpected server error + * + * @var value-of $reason + */ + #[Required(enum: Reason::class)] + public string $reason; + + /** + * `new Error()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Error::with(reason: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Error)->withReason(...) + * ``` + */ + 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 Reason|value-of $reason + */ + public static function with(Reason|string $reason): self + { + $self = new self; + + $self['reason'] = $reason; + + return $self; + } + + /** + * Specific reason for the transformation failure: + * - `encoding_failed`: Error during video encoding process + * - `download_failed`: Could not download source video + * - `internal_server_error`: Unexpected server error + * + * @param Reason|value-of $reason + */ + public function withReason(Reason|string $reason): self + { + $self = clone $this; + $self['reason'] = $reason; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation/Error/Reason.php b/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation/Error/Reason.php new file mode 100644 index 00000000..751baa9f --- /dev/null +++ b/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation/Error/Reason.php @@ -0,0 +1,20 @@ +, + * autoRotate?: bool|null, + * format?: null|Format|value-of, + * quality?: int|null, + * streamProtocol?: null|StreamProtocol|value-of, + * variants?: list|null, + * videoCodec?: null|VideoCodec|value-of, + * } + */ +final class Options implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Audio codec used for encoding (aac or opus). + * + * @var value-of|null $audioCodec + */ + #[Optional('audio_codec', enum: AudioCodec::class)] + public ?string $audioCodec; + + /** + * Whether to automatically rotate the video based on metadata. + */ + #[Optional('auto_rotate')] + public ?bool $autoRotate; + + /** + * Output format for the transformed video or thumbnail. + * + * @var value-of|null $format + */ + #[Optional(enum: Format::class)] + public ?string $format; + + /** + * Quality setting for the output video. + */ + #[Optional] + public ?int $quality; + + /** + * Streaming protocol for adaptive bitrate streaming. + * + * @var value-of|null $streamProtocol + */ + #[Optional('stream_protocol', enum: StreamProtocol::class)] + public ?string $streamProtocol; + + /** + * Array of quality representations for adaptive bitrate streaming. + * + * @var list|null $variants + */ + #[Optional(list: 'string')] + public ?array $variants; + + /** + * Video codec used for encoding (h264, vp9, or av1). + * + * @var value-of|null $videoCodec + */ + #[Optional('video_codec', enum: VideoCodec::class)] + public ?string $videoCodec; + + 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 AudioCodec|value-of|null $audioCodec + * @param Format|value-of|null $format + * @param StreamProtocol|value-of|null $streamProtocol + * @param list|null $variants + * @param VideoCodec|value-of|null $videoCodec + */ + public static function with( + AudioCodec|string|null $audioCodec = null, + ?bool $autoRotate = null, + Format|string|null $format = null, + ?int $quality = null, + StreamProtocol|string|null $streamProtocol = null, + ?array $variants = null, + VideoCodec|string|null $videoCodec = null, + ): self { + $self = new self; + + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $autoRotate && $self['autoRotate'] = $autoRotate; + null !== $format && $self['format'] = $format; + null !== $quality && $self['quality'] = $quality; + null !== $streamProtocol && $self['streamProtocol'] = $streamProtocol; + null !== $variants && $self['variants'] = $variants; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * Audio codec used for encoding (aac or opus). + * + * @param AudioCodec|value-of $audioCodec + */ + public function withAudioCodec(AudioCodec|string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * Whether to automatically rotate the video based on metadata. + */ + public function withAutoRotate(bool $autoRotate): self + { + $self = clone $this; + $self['autoRotate'] = $autoRotate; + + return $self; + } + + /** + * Output format for the transformed video or thumbnail. + * + * @param Format|value-of $format + */ + public function withFormat(Format|string $format): self + { + $self = clone $this; + $self['format'] = $format; + + return $self; + } + + /** + * Quality setting for the output video. + */ + public function withQuality(int $quality): self + { + $self = clone $this; + $self['quality'] = $quality; + + return $self; + } + + /** + * Streaming protocol for adaptive bitrate streaming. + * + * @param StreamProtocol|value-of $streamProtocol + */ + public function withStreamProtocol( + StreamProtocol|string $streamProtocol + ): self { + $self = clone $this; + $self['streamProtocol'] = $streamProtocol; + + return $self; + } + + /** + * Array of quality representations for adaptive bitrate streaming. + * + * @param list $variants + */ + public function withVariants(array $variants): self + { + $self = clone $this; + $self['variants'] = $variants; + + return $self; + } + + /** + * Video codec used for encoding (h264, vp9, or av1). + * + * @param VideoCodec|value-of $videoCodec + */ + public function withVideoCodec(VideoCodec|string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation/Options/AudioCodec.php b/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation/Options/AudioCodec.php new file mode 100644 index 00000000..c33c2fef --- /dev/null +++ b/src/Webhooks/VideoTransformationErrorEvent/Data/Transformation/Options/AudioCodec.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * Full URL of the transformation request that was submitted. + */ + #[Required] + public string $url; + + /** + * Unique identifier for the originating transformation request. + */ + #[Required('x_request_id')] + public string $xRequestID; + + /** + * User-Agent header from the original request that triggered the transformation. + */ + #[Optional('user_agent')] + public ?string $userAgent; + + /** + * `new Request()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Request::with(url: ..., xRequestID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Request)->withURL(...)->withXRequestID(...) + * ``` + */ + 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( + string $url, + string $xRequestID, + ?string $userAgent = null + ): self { + $self = new self; + + $self['url'] = $url; + $self['xRequestID'] = $xRequestID; + + null !== $userAgent && $self['userAgent'] = $userAgent; + + return $self; + } + + /** + * Full URL of the transformation request that was submitted. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } + + /** + * Unique identifier for the originating transformation request. + */ + public function withXRequestID(string $xRequestID): self + { + $self = clone $this; + $self['xRequestID'] = $xRequestID; + + return $self; + } + + /** + * User-Agent header from the original request that triggered the transformation. + */ + public function withUserAgent(string $userAgent): self + { + $self = clone $this; + $self['userAgent'] = $userAgent; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationReadyEvent.php b/src/Webhooks/VideoTransformationReadyEvent.php new file mode 100644 index 00000000..7d08c1ef --- /dev/null +++ b/src/Webhooks/VideoTransformationReadyEvent.php @@ -0,0 +1,194 @@ + */ + use SdkModel; + + /** + * Unique identifier for the event. + */ + #[Required] + public string $id; + + /** + * The type of webhook event. + */ + #[Required] + public string $type; + + /** + * Timestamp when the event was created in ISO8601 format. + */ + #[Required('created_at')] + public \DateTimeInterface $createdAt; + + #[Required] + public Data $data; + + /** + * Information about the original request that triggered the video transformation. + */ + #[Required] + public Request $request; + + /** + * Performance metrics for the transformation process. + */ + #[Optional] + public ?Timings $timings; + + /** + * `new VideoTransformationReadyEvent()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * VideoTransformationReadyEvent::with( + * id: ..., type: ..., createdAt: ..., data: ..., request: ... + * ) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new VideoTransformationReadyEvent) + * ->withID(...) + * ->withType(...) + * ->withCreatedAt(...) + * ->withData(...) + * ->withRequest(...) + * ``` + */ + 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 + * @param Request|RequestShape $request + * @param Timings|TimingsShape|null $timings + */ + public static function with( + string $id, + string $type, + \DateTimeInterface $createdAt, + Data|array $data, + Request|array $request, + Timings|array|null $timings = null, + ): self { + $self = new self; + + $self['id'] = $id; + $self['type'] = $type; + $self['createdAt'] = $createdAt; + $self['data'] = $data; + $self['request'] = $request; + + null !== $timings && $self['timings'] = $timings; + + return $self; + } + + /** + * Unique identifier for the event. + */ + public function withID(string $id): self + { + $self = clone $this; + $self['id'] = $id; + + return $self; + } + + /** + * The type of webhook event. + */ + public function withType(string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Timestamp when the event was created in ISO8601 format. + */ + public function withCreatedAt(\DateTimeInterface $createdAt): self + { + $self = clone $this; + $self['createdAt'] = $createdAt; + + return $self; + } + + /** + * @param Data|DataShape $data + */ + public function withData(Data|array $data): self + { + $self = clone $this; + $self['data'] = $data; + + return $self; + } + + /** + * Information about the original request that triggered the video transformation. + * + * @param Request|RequestShape $request + */ + public function withRequest(Request|array $request): self + { + $self = clone $this; + $self['request'] = $request; + + return $self; + } + + /** + * Performance metrics for the transformation process. + * + * @param Timings|TimingsShape $timings + */ + public function withTimings(Timings|array $timings): self + { + $self = clone $this; + $self['timings'] = $timings; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationReadyEvent/Data.php b/src/Webhooks/VideoTransformationReadyEvent/Data.php new file mode 100644 index 00000000..aee25cf4 --- /dev/null +++ b/src/Webhooks/VideoTransformationReadyEvent/Data.php @@ -0,0 +1,98 @@ + */ + use SdkModel; + + /** + * Information about the source video asset being transformed. + */ + #[Required] + public Asset $asset; + + #[Required] + public Transformation $transformation; + + /** + * `new Data()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Data::with(asset: ..., transformation: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Data)->withAsset(...)->withTransformation(...) + * ``` + */ + 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 Asset|AssetShape $asset + * @param Transformation|TransformationShape $transformation + */ + public static function with( + Asset|array $asset, + Transformation|array $transformation + ): self { + $self = new self; + + $self['asset'] = $asset; + $self['transformation'] = $transformation; + + return $self; + } + + /** + * Information about the source video asset being transformed. + * + * @param Asset|AssetShape $asset + */ + public function withAsset(Asset|array $asset): self + { + $self = clone $this; + $self['asset'] = $asset; + + return $self; + } + + /** + * @param Transformation|TransformationShape $transformation + */ + public function withTransformation( + Transformation|array $transformation + ): self { + $self = clone $this; + $self['transformation'] = $transformation; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationReadyEvent/Data/Asset.php b/src/Webhooks/VideoTransformationReadyEvent/Data/Asset.php new file mode 100644 index 00000000..73388521 --- /dev/null +++ b/src/Webhooks/VideoTransformationReadyEvent/Data/Asset.php @@ -0,0 +1,70 @@ + */ + use SdkModel; + + /** + * URL to download or access the source video file. + */ + #[Required] + public string $url; + + /** + * `new Asset()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Asset::with(url: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Asset)->withURL(...) + * ``` + */ + 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(string $url): self + { + $self = new self; + + $self['url'] = $url; + + return $self; + } + + /** + * URL to download or access the source video file. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation.php b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation.php new file mode 100644 index 00000000..169eec3c --- /dev/null +++ b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation.php @@ -0,0 +1,137 @@ +, + * options?: null|Options|OptionsShape, + * output?: null|Output|OutputShape, + * } + */ +final class Transformation implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + * + * @var value-of $type + */ + #[Required(enum: Type::class)] + public string $type; + + /** + * Configuration options for video transformations. + */ + #[Optional] + public ?Options $options; + + /** + * Information about the transformed output video. + */ + #[Optional] + public ?Output $output; + + /** + * `new Transformation()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Transformation::with(type: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Transformation)->withType(...) + * ``` + */ + 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 Type|value-of $type + * @param Options|OptionsShape|null $options + * @param Output|OutputShape|null $output + */ + public static function with( + Type|string $type, + Options|array|null $options = null, + Output|array|null $output = null, + ): self { + $self = new self; + + $self['type'] = $type; + + null !== $options && $self['options'] = $options; + null !== $output && $self['output'] = $output; + + return $self; + } + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + * + * @param Type|value-of $type + */ + public function withType(Type|string $type): self + { + $self = clone $this; + $self['type'] = $type; + + return $self; + } + + /** + * Configuration options for video transformations. + * + * @param Options|OptionsShape $options + */ + public function withOptions(Options|array $options): self + { + $self = clone $this; + $self['options'] = $options; + + return $self; + } + + /** + * Information about the transformed output video. + * + * @param Output|OutputShape $output + */ + public function withOutput(Output|array $output): self + { + $self = clone $this; + $self['output'] = $output; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Options.php b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Options.php new file mode 100644 index 00000000..c121c59c --- /dev/null +++ b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Options.php @@ -0,0 +1,210 @@ +, + * autoRotate?: bool|null, + * format?: null|Format|value-of, + * quality?: int|null, + * streamProtocol?: null|StreamProtocol|value-of, + * variants?: list|null, + * videoCodec?: null|VideoCodec|value-of, + * } + */ +final class Options implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + /** + * Audio codec used for encoding (aac or opus). + * + * @var value-of|null $audioCodec + */ + #[Optional('audio_codec', enum: AudioCodec::class)] + public ?string $audioCodec; + + /** + * Whether to automatically rotate the video based on metadata. + */ + #[Optional('auto_rotate')] + public ?bool $autoRotate; + + /** + * Output format for the transformed video or thumbnail. + * + * @var value-of|null $format + */ + #[Optional(enum: Format::class)] + public ?string $format; + + /** + * Quality setting for the output video. + */ + #[Optional] + public ?int $quality; + + /** + * Streaming protocol for adaptive bitrate streaming. + * + * @var value-of|null $streamProtocol + */ + #[Optional('stream_protocol', enum: StreamProtocol::class)] + public ?string $streamProtocol; + + /** + * Array of quality representations for adaptive bitrate streaming. + * + * @var list|null $variants + */ + #[Optional(list: 'string')] + public ?array $variants; + + /** + * Video codec used for encoding (h264, vp9, or av1). + * + * @var value-of|null $videoCodec + */ + #[Optional('video_codec', enum: VideoCodec::class)] + public ?string $videoCodec; + + 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 AudioCodec|value-of|null $audioCodec + * @param Format|value-of|null $format + * @param StreamProtocol|value-of|null $streamProtocol + * @param list|null $variants + * @param VideoCodec|value-of|null $videoCodec + */ + public static function with( + AudioCodec|string|null $audioCodec = null, + ?bool $autoRotate = null, + Format|string|null $format = null, + ?int $quality = null, + StreamProtocol|string|null $streamProtocol = null, + ?array $variants = null, + VideoCodec|string|null $videoCodec = null, + ): self { + $self = new self; + + null !== $audioCodec && $self['audioCodec'] = $audioCodec; + null !== $autoRotate && $self['autoRotate'] = $autoRotate; + null !== $format && $self['format'] = $format; + null !== $quality && $self['quality'] = $quality; + null !== $streamProtocol && $self['streamProtocol'] = $streamProtocol; + null !== $variants && $self['variants'] = $variants; + null !== $videoCodec && $self['videoCodec'] = $videoCodec; + + return $self; + } + + /** + * Audio codec used for encoding (aac or opus). + * + * @param AudioCodec|value-of $audioCodec + */ + public function withAudioCodec(AudioCodec|string $audioCodec): self + { + $self = clone $this; + $self['audioCodec'] = $audioCodec; + + return $self; + } + + /** + * Whether to automatically rotate the video based on metadata. + */ + public function withAutoRotate(bool $autoRotate): self + { + $self = clone $this; + $self['autoRotate'] = $autoRotate; + + return $self; + } + + /** + * Output format for the transformed video or thumbnail. + * + * @param Format|value-of $format + */ + public function withFormat(Format|string $format): self + { + $self = clone $this; + $self['format'] = $format; + + return $self; + } + + /** + * Quality setting for the output video. + */ + public function withQuality(int $quality): self + { + $self = clone $this; + $self['quality'] = $quality; + + return $self; + } + + /** + * Streaming protocol for adaptive bitrate streaming. + * + * @param StreamProtocol|value-of $streamProtocol + */ + public function withStreamProtocol( + StreamProtocol|string $streamProtocol + ): self { + $self = clone $this; + $self['streamProtocol'] = $streamProtocol; + + return $self; + } + + /** + * Array of quality representations for adaptive bitrate streaming. + * + * @param list $variants + */ + public function withVariants(array $variants): self + { + $self = clone $this; + $self['variants'] = $variants; + + return $self; + } + + /** + * Video codec used for encoding (h264, vp9, or av1). + * + * @param VideoCodec|value-of $videoCodec + */ + public function withVideoCodec(VideoCodec|string $videoCodec): self + { + $self = clone $this; + $self['videoCodec'] = $videoCodec; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Options/AudioCodec.php b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Options/AudioCodec.php new file mode 100644 index 00000000..28919565 --- /dev/null +++ b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Options/AudioCodec.php @@ -0,0 +1,15 @@ + */ + use SdkModel; + + /** + * URL to access the transformed video. + */ + #[Required] + public string $url; + + /** + * Metadata of the output video file. + */ + #[Optional('video_metadata')] + public ?VideoMetadata $videoMetadata; + + /** + * `new Output()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Output::with(url: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Output)->withURL(...) + * ``` + */ + 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 VideoMetadata|VideoMetadataShape|null $videoMetadata + */ + public static function with( + string $url, + VideoMetadata|array|null $videoMetadata = null + ): self { + $self = new self; + + $self['url'] = $url; + + null !== $videoMetadata && $self['videoMetadata'] = $videoMetadata; + + return $self; + } + + /** + * URL to access the transformed video. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } + + /** + * Metadata of the output video file. + * + * @param VideoMetadata|VideoMetadataShape $videoMetadata + */ + public function withVideoMetadata(VideoMetadata|array $videoMetadata): self + { + $self = clone $this; + $self['videoMetadata'] = $videoMetadata; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Output/VideoMetadata.php b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Output/VideoMetadata.php new file mode 100644 index 00000000..c1903388 --- /dev/null +++ b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Output/VideoMetadata.php @@ -0,0 +1,134 @@ + */ + use SdkModel; + + /** + * Bitrate of the output video in bits per second. + */ + #[Required] + public int $bitrate; + + /** + * Duration of the output video in seconds. + */ + #[Required] + public float $duration; + + /** + * Height of the output video in pixels. + */ + #[Required] + public int $height; + + /** + * Width of the output video in pixels. + */ + #[Required] + public int $width; + + /** + * `new VideoMetadata()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * VideoMetadata::with(bitrate: ..., duration: ..., height: ..., width: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new VideoMetadata) + * ->withBitrate(...) + * ->withDuration(...) + * ->withHeight(...) + * ->withWidth(...) + * ``` + */ + 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( + int $bitrate, + float $duration, + int $height, + int $width + ): self { + $self = new self; + + $self['bitrate'] = $bitrate; + $self['duration'] = $duration; + $self['height'] = $height; + $self['width'] = $width; + + return $self; + } + + /** + * Bitrate of the output video in bits per second. + */ + public function withBitrate(int $bitrate): self + { + $self = clone $this; + $self['bitrate'] = $bitrate; + + return $self; + } + + /** + * Duration of the output video in seconds. + */ + public function withDuration(float $duration): self + { + $self = clone $this; + $self['duration'] = $duration; + + return $self; + } + + /** + * Height of the output video in pixels. + */ + public function withHeight(int $height): self + { + $self = clone $this; + $self['height'] = $height; + + return $self; + } + + /** + * Width of the output video in pixels. + */ + public function withWidth(int $width): self + { + $self = clone $this; + $self['width'] = $width; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Type.php b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Type.php new file mode 100644 index 00000000..0dfcbeae --- /dev/null +++ b/src/Webhooks/VideoTransformationReadyEvent/Data/Transformation/Type.php @@ -0,0 +1,20 @@ + */ + use SdkModel; + + /** + * Full URL of the transformation request that was submitted. + */ + #[Required] + public string $url; + + /** + * Unique identifier for the originating transformation request. + */ + #[Required('x_request_id')] + public string $xRequestID; + + /** + * User-Agent header from the original request that triggered the transformation. + */ + #[Optional('user_agent')] + public ?string $userAgent; + + /** + * `new Request()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Request::with(url: ..., xRequestID: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Request)->withURL(...)->withXRequestID(...) + * ``` + */ + 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( + string $url, + string $xRequestID, + ?string $userAgent = null + ): self { + $self = new self; + + $self['url'] = $url; + $self['xRequestID'] = $xRequestID; + + null !== $userAgent && $self['userAgent'] = $userAgent; + + return $self; + } + + /** + * Full URL of the transformation request that was submitted. + */ + public function withURL(string $url): self + { + $self = clone $this; + $self['url'] = $url; + + return $self; + } + + /** + * Unique identifier for the originating transformation request. + */ + public function withXRequestID(string $xRequestID): self + { + $self = clone $this; + $self['xRequestID'] = $xRequestID; + + return $self; + } + + /** + * User-Agent header from the original request that triggered the transformation. + */ + public function withUserAgent(string $userAgent): self + { + $self = clone $this; + $self['userAgent'] = $userAgent; + + return $self; + } +} diff --git a/src/Webhooks/VideoTransformationReadyEvent/Timings.php b/src/Webhooks/VideoTransformationReadyEvent/Timings.php new file mode 100644 index 00000000..f147e9bf --- /dev/null +++ b/src/Webhooks/VideoTransformationReadyEvent/Timings.php @@ -0,0 +1,78 @@ + */ + use SdkModel; + + /** + * Time spent downloading the source video from your origin or media library, in milliseconds. + */ + #[Optional('download_duration')] + public ?int $downloadDuration; + + /** + * Time spent encoding the video, in milliseconds. + */ + #[Optional('encoding_duration')] + public ?int $encodingDuration; + + 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( + ?int $downloadDuration = null, + ?int $encodingDuration = null + ): self { + $self = new self; + + null !== $downloadDuration && $self['downloadDuration'] = $downloadDuration; + null !== $encodingDuration && $self['encodingDuration'] = $encodingDuration; + + return $self; + } + + /** + * Time spent downloading the source video from your origin or media library, in milliseconds. + */ + public function withDownloadDuration(int $downloadDuration): self + { + $self = clone $this; + $self['downloadDuration'] = $downloadDuration; + + return $self; + } + + /** + * Time spent encoding the video, in milliseconds. + */ + public function withEncodingDuration(int $encodingDuration): self + { + $self = clone $this; + $self['encodingDuration'] = $encodingDuration; + + return $self; + } +} diff --git a/tests/ClientTest.php b/tests/ClientTest.php new file mode 100644 index 00000000..a3ca6694 --- /dev/null +++ b/tests/ClientTest.php @@ -0,0 +1,49 @@ +createResponse() + ->withStatus(200) + ->withHeader('Content-Type', 'application/json') + ->withBody(Psr17FactoryDiscovery::findStreamFactory()->createStream(json_encode([], flags: Util::JSON_ENCODE_FLAGS) ?: '')) + ; + + $transporter->setDefaultResponse($mockRsp); + + $client = new \ImageKit\Client( + baseUrl: 'http://localhost', + privateKey: 'My Private Key', + password: 'My Password', + requestOptions: ['transporter' => $transporter], + ); + + $client->files->upload( + file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)), + fileName: 'fileName', + ); + + $this->assertNotFalse($requested = $transporter->getRequests()[0] ?? false); + + foreach (['accept', 'content-type'] as $header) { + $sent = $requested->getHeaderLine($header); + $this->assertNotEmpty($sent); + } + } +} diff --git a/tests/Core/ModelTest.php b/tests/Core/ModelTest.php new file mode 100644 index 00000000..bd4682ab --- /dev/null +++ b/tests/Core/ModelTest.php @@ -0,0 +1,144 @@ +> */ + use SdkModel; + + #[Required] + public string $name; + + #[Required('age_years')] + public int $ageYears; + + /** @var list|null */ + #[Optional] + public ?array $friends; + + #[Required] + public ?string $owner; + + /** + * @param list|null $friends + */ + public function __construct( + string $name, + int $ageYears, + ?string $owner, + ?array $friends = null, + ) { + $this->initialize(); + + $this->name = $name; + $this->ageYears = $ageYears; + $this->owner = $owner; + + null !== $friends && $this['friends'] = $friends; + } +} + +/** + * @internal + * + * @coversNothing + */ +#[CoversNothing] +class ModelTest extends TestCase +{ + #[Test] + public function testBasicGetAndSet(): void + { + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); + $this->assertEquals(12, $model->ageYears); + + ++$model->ageYears; + $this->assertEquals(13, $model->ageYears); + } + + #[Test] + public function testNullAccess(): void + { + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); + $this->assertNull($model->owner); + $this->assertNull($model->friends); + } + + #[Test] + public function testArrayGetAndSet(): void + { + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); + $model->friends ??= []; + $this->assertEquals([], $model->friends); + $model->friends[] = 'Alice'; + $this->assertEquals(['Alice'], $model->friends); + } + + #[Test] + public function testDiscernsBetweenNullAndUnset(): void + { + $modelUnsetFriends = new Dog(name: 'Bob', ageYears: 12, owner: null); + $modelNullFriends = new Dog(name: 'bob', ageYears: 12, owner: null); + $modelNullFriends->friends = null; + + $this->assertEquals(12, $modelUnsetFriends->ageYears); + $this->assertEquals(12, $modelNullFriends->ageYears); + + $this->assertTrue($modelUnsetFriends->offsetExists('ageYears')); + $this->assertTrue($modelNullFriends->offsetExists('ageYears')); + + $this->assertNull($modelUnsetFriends->friends); + $this->assertNull($modelNullFriends->friends); + + $this->assertFalse($modelUnsetFriends->offsetExists('friends')); + $this->assertTrue($modelNullFriends->offsetExists('friends')); + } + + #[Test] + public function testIssetOnOmittedProperties(): void + { + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); + $this->assertFalse(isset($model->owner)); + $this->assertFalse(isset($model->friends)); + } + + #[Test] + public function testSerializeBasicModel(): void + { + $model = new Dog(name: 'Bob', ageYears: 12, owner: 'Eve', friends: ['Alice', 'Charlie']); + $this->assertEquals( + '{"name":"Bob","age_years":12,"friends":["Alice","Charlie"],"owner":"Eve"}', + json_encode($model) + ); + } + + #[Test] + public function testSerializeModelWithOmittedProperties(): void + { + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); + $this->assertEquals( + '{"name":"Bob","age_years":12,"owner":null}', + json_encode($model) + ); + } + + #[Test] + public function testSerializeModelWithExplicitNull(): void + { + $model = new Dog(name: 'Bob', ageYears: 12, owner: null); + $model->friends = null; + $this->assertEquals( + '{"name":"Bob","age_years":12,"friends":null,"owner":null}', + json_encode($model) + ); + } +} diff --git a/tests/Core/StreamingTransportTest.php b/tests/Core/StreamingTransportTest.php new file mode 100644 index 00000000..1014a6c5 --- /dev/null +++ b/tests/Core/StreamingTransportTest.php @@ -0,0 +1,122 @@ + true, + 'application/x-ndjson' => true, + 'application/x-ldjson' => true, + 'application/jsonl' => true, + 'application/x-jsonl' => true, + 'text/event-stream; charset=utf-8' => true, + 'application/json' => false, + 'text/plain' => false, + '' => false, + ]; + + foreach ($cases as $accept => $expected) { + $req = $factory->createRequest('GET', 'http://localhost'); + if ('' !== $accept) { + $req = $req->withHeader('Accept', $accept); + } + $this->assertSame( + $expected, + Util::isStreamingRequest($req), + "Accept: '{$accept}'", + ); + } + } + + #[Test] + public function testRoutesNonStreamingRequestToTransporter(): void + { + [$client, $plain, $streaming] = $this->buildClient(); + + $client->request('GET', '/'); + + $this->assertCount(1, $plain->getRequests()); + $this->assertCount(0, $streaming->getRequests()); + } + + #[Test] + public function testRoutesStreamingRequestToStreamingTransporter(): void + { + [$client, $plain, $streaming] = $this->buildClient(); + + $client->request('GET', '/', headers: ['Accept' => 'text/event-stream']); + + $this->assertCount(0, $plain->getRequests()); + $this->assertCount(1, $streaming->getRequests()); + + $sent = $streaming->getRequests()[0]; + $this->assertStringContainsString('text/event-stream', $sent->getHeaderLine('Accept')); + } + + /** + * @return array{BaseClient, MockClient, MockClient} + */ + private function buildClient(): array + { + $plain = new MockClient; + $plain->setDefaultResponse($this->jsonResponse()); + + $streaming = new MockClient; + $streaming->setDefaultResponse($this->sseResponse()); + + $options = RequestOptions::with( + transporter: $plain, + streamingTransporter: $streaming, + uriFactory: Psr17FactoryDiscovery::findUriFactory(), + requestFactory: Psr17FactoryDiscovery::findRequestFactory(), + streamFactory: Psr17FactoryDiscovery::findStreamFactory(), + ); + + $client = new class(headers: [], baseUrl: 'http://localhost', options: $options) extends BaseClient {}; + + return [$client, $plain, $streaming]; + } + + private function jsonResponse(): ResponseInterface + { + $responseFactory = Psr17FactoryDiscovery::findResponseFactory(); + $streamFactory = Psr17FactoryDiscovery::findStreamFactory(); + + return $responseFactory->createResponse(200) + ->withHeader('Content-Type', 'application/json') + ->withBody($streamFactory->createStream('{}')) + ; + } + + private function sseResponse(): ResponseInterface + { + $responseFactory = Psr17FactoryDiscovery::findResponseFactory(); + $streamFactory = Psr17FactoryDiscovery::findStreamFactory(); + + return $responseFactory->createResponse(200) + ->withHeader('Content-Type', 'text/event-stream') + ->withBody($streamFactory->createStream('')) + ; + } +} diff --git a/tests/Core/UtilTest.php b/tests/Core/UtilTest.php new file mode 100644 index 00000000..acce0587 --- /dev/null +++ b/tests/Core/UtilTest.php @@ -0,0 +1,90 @@ + $v, + ], + [ + ['a' => null, 'b' => [null, null], 'c' => ['d' => null, 'e' => 0], 'f' => ['g' => null]], + ['b' => [null, null], 'c' => ['e' => 0], 'f' => []], + static fn ($vs) => is_array($vs) && !array_is_list($vs) ? array_filter($vs, callback: static fn ($v) => !is_null($v)) : $vs, + ], + [ + ['a' => null, 'b' => 2, 'c' => true, 'd' => [1, 2]], + ['a' => null, 'b' => '2', 'c' => true, 'd' => ['1', '2']], + static fn ($v) => is_bool($v) || is_numeric($v) ? Util::strVal($v) : $v, + ], + ]; + + foreach ($cases as [$input, $expected, $xform]) { + $actual = Util::mapRecursive($xform, value: $input); + $this->assertEquals($expected, $actual); + } + } + + #[Test] + public function testJoinUri(): void + { + $factory = Psr17FactoryDiscovery::findUriFactory(); + $base = $factory->createUri('http://localhost'); + $cases = [ + [ + '', + [], + 'http://localhost', + ], + [ + 'dog', + [], + 'http://localhost/dog', + ], + [ + '', + ['dog' => 'dog'], + 'http://localhost?dog=dog', + ], + [ + '', + ['dog' => ['dog']], + 'http://localhost?dog[0]=dog', + ], + [ + '', + ['dog' => [true, false]], + 'http://localhost?dog[0]=true&dog[1]=false', + ], + [ + '', + ['dog' => ['dog' => ['dog']]], + 'http://localhost?dog[dog][0]=dog', + ], + ]; + + foreach ($cases as [$path, $query, $output]) { + $expected = $factory->createUri($output); + $actual = Util::joinUri($base, path: $path, query: $query); + $this->assertEquals($expected, $actual); + } + } +} diff --git a/tests/ImageKit/ImageKitTest.php b/tests/ImageKit/ImageKitTest.php deleted file mode 100644 index 666330ac..00000000 --- a/tests/ImageKit/ImageKitTest.php +++ /dev/null @@ -1,337 +0,0 @@ -configuration, "\$configuration should be an instance of Configuration"); - Assert::assertEquals('testing_public_key', $this->configuration->publicKey, 'Public Key should be equal to testing_public_key'); - Assert::assertEquals('testing_private_key', $this->configuration->privateKey, 'Private Key should be equal to testing_private_key'); - Assert::assertEquals('https://ik.imagekit.io/testing', $this->configuration->urlEndpoint, 'Url Endpoint should be equal to https://ik.imagekit.io/testing'); - Assert::assertEquals('path', $this->configuration->transformationPosition, 'Transformation Position should be equal to path'); - }; - $doAssertClosure = $assertionClosure->bindTo($imagekit, ImageKit::class); - $doAssertClosure(); - } - - /** - * Successful initialization with TransformationPosition as Path - */ - public function test__constructSuccessfulWithTransformationPositionPath() - { - $imagekit = new ImageKit('testing_public_key', 'testing_private_key', 'https://ik.imagekit.io/testing', 'path'); - $assertionClosure = function () { - Assert::assertInstanceOf(Configuration::class, $this->configuration, "\$configuration should be an instance of Configuration"); - Assert::assertEquals('testing_public_key', $this->configuration->publicKey, 'Public Key should be equal to testing_public_key'); - Assert::assertEquals('testing_private_key', $this->configuration->privateKey, 'Private Key should be equal to testing_private_key'); - Assert::assertEquals('https://ik.imagekit.io/testing', $this->configuration->urlEndpoint, 'Url Endpoint should be equal to https://ik.imagekit.io/testing'); - Assert::assertEquals('path', $this->configuration->transformationPosition, 'Transformation Position should be equal to path'); - }; - $doAssertClosure = $assertionClosure->bindTo($imagekit, ImageKit::class); - $doAssertClosure(); - } - - /** - * Successful initialization with TransformationPosition as Query - */ - public function test__constructSuccessfulWithTransformationPositionQuery() - { - $imagekit = new ImageKit('testing_public_key', 'testing_private_key', 'https://ik.imagekit.io/testing', 'query'); - $assertionClosure = function () { - Assert::assertInstanceOf(Configuration::class, $this->configuration, "\$configuration should be an instance of Configuration"); - Assert::assertEquals('testing_public_key', $this->configuration->publicKey, 'Public Key should be equal to testing_public_key'); - Assert::assertEquals('testing_private_key', $this->configuration->privateKey, 'Private Key should be equal to testing_private_key'); - Assert::assertEquals('https://ik.imagekit.io/testing', $this->configuration->urlEndpoint, 'Url Endpoint should be equal to https://ik.imagekit.io/testing'); - Assert::assertEquals('query', $this->configuration->transformationPosition, 'Transformation Position should be equal to path'); - }; - $doAssertClosure = $assertionClosure->bindTo($imagekit, ImageKit::class); - $doAssertClosure(); - } - - /** - * Failed initialization Missing Public Key - */ - public function test__constructFailedEmptyPublicKey() - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Missing publicKey during ImageKit initialization'); - new ImageKit('', '', '', ''); - } - - /** - * Failed initialization Missing Private Key - */ - public function test__constructFailedEmptyPrivateKey() - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Missing privateKey during ImageKit initialization'); - new ImageKit('testing_public_key', '', '', ''); - } - - /** - * Failed initialization Missing Url Endpoint - */ - public function test__constructFailedEmptyUrlEndpoint() - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Missing urlEndpoint during ImageKit initialization'); - new ImageKit('testing_public_key', 'testing_private_key', '', ''); - } - - /** - * Failed initialization Missing Transformation Position - */ - public function test__constructFailedEmptyTransformationPosition() - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid transformationPosition during ImageKit initialization. Can be one of path or query'); - new ImageKit('testing_public_key', 'testing_private_key', 'https://ik.imagekit.io/testing', ''); - } - - /** - * Failed initialization Invalid Transformation Position - */ - public function test__constructFailedInvalidTransformationPosition() - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid transformationPosition during ImageKit initialization. Can be one of path or query'); - new ImageKit('testing_public_key', 'testing_private_key', 'https://ik.imagekit.io/testing', 'testing'); - } - - - /** - * Failed initialization Invalid URL Endpoint - */ - public function test__constructFailedInvalidURLEndpoint() - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('urlEndpoint should be a valid URL'); - new ImageKit('testing_public_key', 'testing_private_key', 'wrong_url', 'path'); - } - - /** - * Generate Authentication Parameters With Token - */ - public function testGetAuthenticationParametersWithToken() - { - $token = 'your_token'; - $expire = 1582269249; - $signature = 'e71bcd6031016b060d349d212e23e85c791decdd'; - - $imagekit = new ImageKit('public_key_test', 'private_key_test', 'https://ik.imagekit.io/testing'); - $response = $imagekit->getAuthenticationParameters('your_token', 1582269249); - - - Assert::assertEquals(json_encode([ - 'token' => $token, - 'expire' => $expire, - 'signature' => $signature, - ]), json_encode($response)); - } - - /** - * Test Phash Distance - */ - public function testPHashDistance() - { - $imagekit = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - $phash1 = '63433b3ccf8e1ebe'; - $phash2 = 'f5d2226cd9d32b16'; - - $distance = $imagekit->pHashDistance($phash1, $phash2); - - Assert::assertEquals(27, $distance); - } - - /** - * Test Phash Distance - */ - public function testPHashDistanceEmptyPhash1() - { - $imagekit = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - $phash1 = ''; - $phash2 = 'f5d2226cd9d32b16'; - - $response = $imagekit->pHashDistance($phash1, $phash2); - - ImageKitTest::assertEquals('Missing First pHash parameter for this request',$response->error->message); - } - - /** - * Test Phash Distance - */ - public function testPHashDistanceEmptyPhash2() - { - $imagekit = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - $phash1 = 'f5d2226cd9d32b16'; - $phash2 = ''; - - - $response = $imagekit->pHashDistance($phash1, $phash2); - - ImageKitTest::assertEquals('Missing Second pHash parameter for this request',$response->error->message); - } - - /** - * Test Phash Distance - */ - public function testPHashDistanceInvalidPhash1() - { - $imagekit = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - $phash1 = 'asdadasda'; - $phash2 = 'f5d2226cd9d32b16'; - - $this->expectException(Exception::class); - $this->expectExceptionMessage('Invalid pHash value'); - - $imagekit->pHashDistance($phash1, $phash2); - } - - /** - * Test Phash Distance - */ - public function testPHashDistanceInvalidPhash2() - { - $imagekit = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - $phash1 = 'f5d2226cd9d32b16'; - $phash2 = 'asjdkajlkda'; - - $this->expectException(Exception::class); - $this->expectExceptionMessage('Invalid pHash value'); - - $imagekit->pHashDistance($phash1, $phash2); - } - - /** - * Test Phash Distance - */ - public function testPHashDistancePhashesLengthNotEqual() - { - $imagekit = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - $phash1 = 'f5d2226cd9d32b16'; - $phash2 = 'f5d2226cd9d32b16f5d2226cd9d32b16'; - - $this->expectException(Exception::class); - $this->expectExceptionMessage('Invalid pHash value'); - - $imagekit->pHashDistance($phash1, $phash2); - } - - - /** - * - */ - public function testGetBulkJobStatus() - { - $jobId = '598821f949c0a938d57563bd'; - - $responseBody = [ - "jobId" => "598821f949c0a938d57563bd", - "type" => "COPY_FOLDER", - "status" => "Completed" - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $this->stubHttpClient('get', new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse)); - - $response = $this->client->getBulkJobStatus($jobId); - - ImageKitTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - } - - /** - * - */ - public function testGetBulkJobStatusMissingJobId() - { - $jobId = ''; - - $response = $this->client->getBulkJobStatus($jobId); - - ImageKitTest::assertEquals('Missing Job ID parameter for this request',$response->error->message); - } - - /** - * - */ - private function stubHttpClient($methodName, $response) - { - $stub = $this->createMock(GuzzleHttpWrapper::class); - $stub->method('setDatas'); - $stub->method($methodName)->willReturn($response); - - $closure = function () use ($stub) { - $this->httpClient = $stub; - }; - $doClosure = $closure->bindTo($this->client, ImageKit::class); - $doClosure(); - } - - protected function setUp() - { - $this->client = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - } - - protected function tearDown() - { - $this->client = null; - } -} diff --git a/tests/ImageKit/Manage/CacheTest.php b/tests/ImageKit/Manage/CacheTest.php deleted file mode 100644 index cf3a5711..00000000 --- a/tests/ImageKit/Manage/CacheTest.php +++ /dev/null @@ -1,192 +0,0 @@ - "598821f949c0a938d57563bd" - ]; - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->purgeCache($image_url); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - - // Request Check - CacheTest::assertEquals("/v1/files/purge",$requestPath); - CacheTest::assertEquals($stream['url'],$image_url); - - // Response Check - CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testPurgeCacheWithMissingImageURL() - { - $image_url = ''; - - $response = $this->client->purgeCache($image_url); - - CacheTest::assertEquals('Missing URL parameter for this request', $response->error->message); - } - - /** - * - */ - public function testPurgeCacheWithInvalidImageURL() - { - $image_url = 'image_url'; - - $response = $this->client->purgeCache($image_url); - - CacheTest::assertEquals('Invalid URL provided for this request', $response->error->message); - } - - /** - * - */ - public function testPurgeCacheStatus() - { - $cacheRequestId = '598821f949c0a938d57563bd'; - - $responseBody = [ - "status" => "Pending" - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->purgeCacheStatus($cacheRequestId); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - - // Request Check - CacheTest::assertEquals("/v1/files/purge/{$cacheRequestId}",$requestPath); - CacheTest::assertEmpty($stream); - - // Response Check - CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - /** - * - */ - public function testPurgeCacheStatusWithMissingCacheRequestId() - { - $cacheRequestId = ''; - - $response = $this->client->purgeCacheStatus($cacheRequestId); - - CacheTest::assertEquals('Missing Request ID parameter for this request', $response->error->message); - } - - - - private function stubHttpClient($methodName, $response) - { - $stub = $this->createMock(GuzzleHttpWrapper::class); - $stub->method('setDatas'); - $stub->method($methodName)->willReturn($response); - - $closure = function () use ($stub) { - $this->httpClient = $stub; - }; - $doClosure = $closure->bindTo($this->client, ImageKit::class); - $doClosure(); - } - - protected function setUp() - { - $this->client = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - } - - /** - * - */ - private function createMockClient($handler){ - $this->mockClient = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo', - Transformation::DEFAULT_TRANSFORMATION_POSITION, - $handler - ); - } - - - protected function tearDown() - { - $this->client = null; - } -} diff --git a/tests/ImageKit/Manage/CustomMetadataTest.php b/tests/ImageKit/Manage/CustomMetadataTest.php deleted file mode 100644 index a3fb06ae..00000000 --- a/tests/ImageKit/Manage/CustomMetadataTest.php +++ /dev/null @@ -1,627 +0,0 @@ - "price", - "label" => "Unit Price", - "schema" => [ - "type" => 'Number', - "minValue" => 1000, - "maxValue" => 5000, - ], - ]; - - $responseBody = [ - "id" => "598821f949c0a938d57563dd", - "name" => "price", - "label" => "Unit Price", - "schema" => [ - "type" => "Number", - "minValue" => 1000, - "maxValue" => 5000 - ] - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->createCustomMetadataField($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - - // Request Check - CacheTest::assertEquals("/v1/customMetadataFields",$requestPath); - CacheTest::assertEquals($stream['name'],$requestBody['name']); - CacheTest::assertEquals($stream['label'],$requestBody['label']); - CacheTest::assertEquals($stream['schema'],$requestBody['schema']); - CacheTest::assertEquals($stream['schema']['type'],$requestBody['schema']['type']); - CacheTest::assertEquals($stream['schema']['minValue'],$requestBody['schema']['minValue']); - CacheTest::assertEquals($stream['schema']['maxValue'],$requestBody['schema']['maxValue']); - - // Response Check - CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testCreateFieldsInvalidRequest() - { - - $response = $this->client->createCustomMetadataField(); - - CacheTest::assertEquals('Create Custom Metadata API accepts an array, null passed', $response->error->message); - - } - - /** - * - */ - public function testCreateFieldsWithNonArrayParameter() - { - $requestBody = 'field_name'; - - $response = $this->client->createCustomMetadataField($requestBody); - - CacheTest::assertEquals('Create Custom Metadata API accepts an array of parameters, non array value passed', $response->error->message); - - } - - /** - * - */ - public function testCreateFieldsWithEmptyArrayParameter() - { - $requestBody = []; - - $response = $this->client->createCustomMetadataField($requestBody); - - CacheTest::assertEquals('Create Custom Metadata API accepts an array of parameters, empty array passed', $response->error->message); - } - - /** - * - */ - public function testCreateFieldsWithMissingName() - { - $requestBody = [ - "name" => "", - "label" => "Unit Price", - "schema" => [ - "type" => 'Number', - "minValue" => 1000, - "maxValue" => 5000, - ], - ]; - - $response = $this->client->createCustomMetadataField($requestBody); - - CacheTest::assertEquals('Missing parameter name and/or label and/or schema for this request', $response->error->message); - } - - /** - * - */ - public function testCreateFieldsWithMissingLabel() - { - $requestBody = [ - "name" => "price", - "label" => "", - "schema" => [ - "type" => 'Number', - "minValue" => 1000, - "maxValue" => 5000, - ], - ]; - - $response = $this->client->createCustomMetadataField($requestBody); - - CacheTest::assertEquals('Missing parameter name and/or label and/or schema for this request', $response->error->message); - } - - /** - * - */ - public function testCreateFieldsWithMissingSchema() - { - $requestBody = [ - "name" => "price", - "label" => "Unit Price", - ]; - - $response = $this->client->createCustomMetadataField($requestBody); - - CacheTest::assertEquals('Missing parameter name and/or label and/or schema for this request', $response->error->message); - } - - - /** - * - */ - public function testCreateFieldsWithMissingSchemaType() - { - $requestBody = [ - "name" => "price", - "label" => "Unit Price", - "schema" => [ - ], - ]; - - $response = $this->client->createCustomMetadataField($requestBody); - - CacheTest::assertEquals('Invalid parameter schema', $response->error->message); - } - - - /** - * - */ - public function testGetFields() - { - $includeDeleted = false; - - $responseBody = [ - [ - "id" => "598821f949c0a938d57563dd", - "name" => "brand", - "label" => "brand", - "schema" => [ - "type" => "Text", - "defaultValue" => "Nike" - ] - ], - [ - "id" => "865421f949c0a835d57563dd", - "name" => "price", - "label" => "price", - "schema" => [ - "type" => "Number", - "minValue" => 1000, - "maxValue" => 3000 - ] - ] - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->getCustomMetadataFields($includeDeleted); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $queryString = $request->getUri()->getQuery(); - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - - // Request Check - CacheTest::assertEquals("/v1/customMetadataFields",$requestPath); - CacheTest::assertEquals($queryString,http_build_query(['includeDeleted'=>$includeDeleted])); - - // Response Check - CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - - /** - * - */ - public function testGetFieldsWithoutIncludeDeleted() - { - - $responseBody = [ - [ - "id" => "598821f949c0a938d57563dd", - "name" => "brand", - "label" => "brand", - "schema" => [ - "type" => "Text", - "defaultValue" => "Nike" - ] - ], - [ - "id" => "865421f949c0a835d57563dd", - "name" => "price", - "label" => "price", - "schema" => [ - "type" => "Number", - "minValue" => 1000, - "maxValue" => 3000 - ] - ] - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->getCustomMetadataFields(); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $queryString = $request->getUri()->getQuery(); - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - - // Request Check - CacheTest::assertEquals("/v1/customMetadataFields",$requestPath); - CacheTest::assertEquals($queryString,http_build_query(['includeDeleted'=>false])); - - // Response Check - CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - /** - * - */ - public function testGetFieldsWithInvalidIncludeDeleted() - { - $includeDeleted = 'includeDeleted'; - - $response = $this->client->getCustomMetadataFields($includeDeleted); - - CacheTest::assertEquals('Invalid parameter includeDeleted', $response->error->message); - } - - /** - * - */ - public function testUpdateFields() - { - $customMetadataFieldId = '598821f949c0a938d57563dd'; - - $requestBody = [ - "label" => "Net Price", - "schema" => [ - "type"=>'Number' - ], - ]; - - $responseBody = [ - "id" => "598821f949c0a938d57563dd", - "name" => "price", - "label" => "Net Price", - "schema" => [ - "type" => "Number" - ] - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->updateCustomMetadataField($customMetadataFieldId, $requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - - // Request Check - CacheTest::assertEquals("/v1/customMetadataFields/" . $customMetadataFieldId,$requestPath); - CacheTest::assertEquals($stream['label'],$requestBody['label']); - CacheTest::assertEquals($stream['schema'],$requestBody['schema']);CacheTest::assertEquals($stream['schema']['type'],$requestBody['schema']['type']); - - // Response Check - CacheTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'PATCH'); - } - - /** - * - */ - public function testUpdateFieldsInvalidRequest() - { - - $response = $this->client->updateCustomMetadataField(); - - CacheTest::assertEquals('Update Custom Metadata API accepts an id and requestBody, null passed', $response->error->message); - - } - - - /** - * - */ - public function testUpdateFieldsWithMissingCustomMetadataFieldId() - { - $customMetadataFieldId = ''; - - $requestBody = [ - "label" => "Net Price", - "schema" => [ - "type"=>'Number' - ], - ]; - - $response = $this->client->updateCustomMetadataField($customMetadataFieldId, $requestBody); - - CacheTest::assertEquals('Missing Custom Metadata Field ID parameter for this request', $response->error->message); - - } - - - /** - * - */ - public function testUpdateFieldsWithMissingBody() - { - $customMetadataFieldId = '598821f949c0a938d57563dd'; - - $response = $this->client->updateCustomMetadataField($customMetadataFieldId); - - CacheTest::assertEquals('Missing body parameter for this request', $response->error->message); - - } - - /** - * - */ - public function testUpdateFieldsWithNonArrayBodyParameter() - { - $customMetadataFieldId = '598821f949c0a938d57563dd'; - - $requestBody = "Net Price"; - - $response = $this->client->updateCustomMetadataField($customMetadataFieldId, $requestBody); - - CacheTest::assertEquals('Update Custom Metadata API accepts requestBody as an array of parameters, non array value passed', $response->error->message); - - } - - /** - * - */ - public function testUpdateFieldsWithEmptyArrayBodyParameter() - { - $customMetadataFieldId = '598821f949c0a938d57563dd'; - - $requestBody = []; - - $response = $this->client->updateCustomMetadataField($customMetadataFieldId, $requestBody); - - CacheTest::assertEquals('Update Custom Metadata API accepts an array of parameters, empty array passed', $response->error->message); - - } - - /** - * - */ - public function testUpdateFieldsWithMissingLabel() - { - $customMetadataFieldId = '598821f949c0a938d57563dd'; - - $requestBody = [ - "label" => "", - "schema" => [ - "type"=>'Number' - ], - ]; - - $response = $this->client->updateCustomMetadataField($customMetadataFieldId, $requestBody); - - CacheTest::assertEquals('Missing parameter label and/or schema for this request', $response->error->message); - - } - - /** - * - */ - public function testUpdateFieldsWithMissingSchema() - { - $customMetadataFieldId = '598821f949c0a938d57563dd'; - - $requestBody = [ - "label" => "Net Price", - ]; - - $response = $this->client->updateCustomMetadataField($customMetadataFieldId, $requestBody); - - CacheTest::assertEquals('Missing parameter label and/or schema for this request', $response->error->message); - - } - - /** - * - */ - public function testUpdateFieldsWithMissingSchemaType() - { - $customMetadataFieldId = '598821f949c0a938d57563dd'; - - $requestBody = [ - "label" => "Net Price", - "schema" => [ - "type"=>'' - ], - ]; - - $response = $this->client->updateCustomMetadataField($customMetadataFieldId, $requestBody); - - CacheTest::assertEquals('Invalid parameter schema', $response->error->message); - - } - - /** - * - */ - public function testDeleteFields() - { - $customMetadataFieldId = '598821f949c0a938d57563dd'; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->deleteCustomMetadataField($customMetadataFieldId); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - - // Request Check - CacheTest::assertEquals("/v1/customMetadataFields/" . $customMetadataFieldId,$requestPath); - CacheTest::assertEmpty($stream); - - // Response Check - CacheTest::assertNull($response->result); - CacheTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'DELETE'); - } - - /** - * - */ - public function testDeleteFieldsWithMissingCustomMetadataFieldId() - { - $customMetadataFieldId = ''; - - $response = $this->client->deleteCustomMetadataField($customMetadataFieldId); - - CacheTest::assertEquals('Missing Custom Metadata Field ID parameter for this request',$response->error->message); - } - - - private function stubHttpClient($methodName, $response) - { - $stub = $this->createMock(GuzzleHttpWrapper::class); - $stub->method('setDatas'); - $stub->method($methodName)->willReturn($response); - - $closure = function () use ($stub) { - $this->httpClient = $stub; - }; - $doClosure = $closure->bindTo($this->client, ImageKit::class); - $doClosure(); - } - - protected function setUp() - { - $this->client = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - } - - /** - * - */ - private function createMockClient($handler){ - $this->mockClient = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo', - Transformation::DEFAULT_TRANSFORMATION_POSITION, - $handler - ); - } - - - protected function tearDown() - { - $this->client = null; - } -} diff --git a/tests/ImageKit/Manage/FileTest.php b/tests/ImageKit/Manage/FileTest.php deleted file mode 100644 index d53ecfd0..00000000 --- a/tests/ImageKit/Manage/FileTest.php +++ /dev/null @@ -1,2035 +0,0 @@ - "help", - "message" => "message" - ]; - - /** - * - */ - public function testListFiles() - { - $responseBody = [ - [ - 'type' => 'file', - 'name' => 'default-image.jpg', - 'fileId' => '5de4fb65c851e55df73abe8d', - 'tags' => ["tag1","tag2"], - 'customCoordinates' => null, - 'isPrivateFile' => false, - 'url' => 'https://ik.imagekit.io/ot2cky3ujwa/default-image.jpg', - 'thumbnail' => 'https://ik.imagekit.io/ot2cky3ujwa/tr:n-media_library_thumbnail/default-image.jpg', - 'fileType' => 'image', - 'filePath' => '/default-image.jpg', - ], - ]; - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $this->stubHttpClient('get', new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse)); - - $response = $this->client->listFiles(); - - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - } - - /** - * - */ - public function testListFilesWithOptions() - { - $listOptions = [ - "type" => "file", - "sort" => "ASC_CREATED", - "path" => "/sample-folder", - "fileType" => "all", - "limit" => 10, - "skip" => 0, - "tags" => ["tag3","tag4"], - ]; - - $responseBody = [ - [ - 'type' => 'file', - 'name' => 'default-image.jpg', - 'fileId' => '5de4fb65c851e55df73abe8d', - 'tags' => null, - 'customCoordinates' => null, - 'isPrivateFile' => false, - 'url' => 'https://ik.imagekit.io/ot2cky3ujwa/default-image.jpg', - 'thumbnail' => 'https://ik.imagekit.io/ot2cky3ujwa/tr:n-media_library_thumbnail/default-image.jpg', - 'fileType' => 'image', - 'filePath' => '/default-image.jpg', - ], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->listFiles($listOptions); - - $request = $container[0]['request']; - $queryString = $request->getUri()->getQuery(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - - FileTest::assertEmpty($stream); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - - - /** - * - */ - public function testListFilesWithEmptyOptions() - { - $listOptions = []; - - $responseBody = [ - [ - 'type' => 'file', - 'name' => 'default-image.jpg', - 'fileId' => '5de4fb65c851e55df73abe8d', - 'tags' => null, - 'customCoordinates' => null, - 'isPrivateFile' => false, - 'url' => 'https://ik.imagekit.io/ot2cky3ujwa/default-image.jpg', - 'thumbnail' => 'https://ik.imagekit.io/ot2cky3ujwa/tr:n-media_library_thumbnail/default-image.jpg', - 'fileType' => 'image', - 'filePath' => '/default-image.jpg', - ], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->listFiles($listOptions); - - $request = $container[0]['request']; - $queryString = $request->getUri()->getQuery(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - - FileTest::assertEmpty($queryString); - FileTest::assertEmpty($stream); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - /** - * - */ - public function testListFilesWithInvalidOptions() - { - $listOptions = 'invalid'; - - $response = $this->client->listFiles($listOptions); - - FileTest::assertEquals('List File Options accepts an array of parameters, non array value passed', $response->error->message); - } - - /** - * - */ - public function testGetFileDetails() - { - $fileId = '23902390239203923'; - - $responseBody = [ - 'type' => 'file', - 'name' => 'default-image.jpg', - 'fileId' => '5de4fb65c851e55df73abe8d', - 'tags' => null, - 'customCoordinates' => null, - 'isPrivateFile' => false, - 'url' => 'https://ik.imagekit.io/ot2cky3ujwa/default-image.jpg', - 'thumbnail' => 'https://ik.imagekit.io/ot2cky3ujwa/tr:n-media_library_thumbnail/default-image.jpg', - 'fileType' => 'image', - 'filePath' => '/default-image.jpg', - ]; - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->getFileDetails($fileId); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - - // Request Check - FileTest::assertEquals("/v1/files/{$fileId}/details",$requestPath); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - /** - * - */ - public function testGetFileDetailsWithMissingFileId() - { - $fileId = ''; - - $mockBodyResponse = Utils::streamFor(); - - $this->stubHttpClient('get', new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse)); - - $response = $this->client->getFileDetails($fileId); - - FileTest::assertEquals('Missing File ID parameter for this request',$response->error->message); - } - - /** - * - */ - public function testGetFileDetailsWithError() - { - $fileId = '23902390239203923'; - - $this->stubHttpClient('get', new Response(500, ['X-Foo' => 'Bar'], json_encode($this->dummyAPIErrorResponse))); - - $response = $this->client->getFileDetails($fileId); - - FileTest::assertEquals(json_encode($this->dummyAPIErrorResponse),json_encode($response->error)); - } - - /** - * - */ - public function testGetFileVersionDetails() - { - $fileId = '23902390239203923'; - $versionId = '23902390239203923'; - - $responseBody = [ - 'type' => 'file', - 'name' => 'default-image.jpg', - 'fileId' => '5de4fb65c851e55df73abe8d', - 'tags' => null, - 'customCoordinates' => null, - 'isPrivateFile' => false, - 'url' => 'https://ik.imagekit.io/ot2cky3ujwa/default-image.jpg', - 'thumbnail' => 'https://ik.imagekit.io/ot2cky3ujwa/tr:n-media_library_thumbnail/default-image.jpg', - 'fileType' => 'image', - 'filePath' => '/default-image.jpg', - "versionInfo" => [ - "id" => "598821f949c0a938d57563bd", - "name" => "Version 1" - ], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->getFileVersionDetails($fileId, $versionId); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - - - // Request Check - FileTest::assertEquals("/v1/files/{$fileId}/versions/{$versionId}",$requestPath); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - /** - * - */ - public function testGetFileVersionDetailsWithMissingFileId() - { - $fileId = ''; - $versionId = '23902390239203923'; - - $response = $this->client->getFileVersionDetails($fileId, $versionId); - - FileTest::assertEquals('Missing File ID parameter for this request', $response->error->message); - } - - /** - * - */ - public function testGetFileVersionDetailsWithMissingVersionId() - { - $fileId = '23902390239203923'; - $versionId = ''; - - $response = $this->client->getFileVersionDetails($fileId, $versionId); - - FileTest::assertEquals('Missing Version ID parameter for this request', $response->error->message); - } - - /** - * - */ - public function testGetFileVersions() - { - $fileId = '23902390239203923'; - - $responseBody = [ - [ - 'type' => 'file', - 'name' => 'default-image.jpg', - 'fileId' => '5de4fb65c851e55df73abe8d', - 'tags' => null, - 'customCoordinates' => null, - 'isPrivateFile' => false, - 'url' => 'https://ik.imagekit.io/ot2cky3ujwa/default-image.jpg', - 'thumbnail' => 'https://ik.imagekit.io/ot2cky3ujwa/tr:n-media_library_thumbnail/default-image.jpg', - 'fileType' => 'image', - 'filePath' => '/default-image.jpg', - "versionInfo" => [ - "id" => "598821f949c0a938d57563bd", - "name" => "Version 1" - ] - ], - [ - 'type' => 'file', - 'name' => 'default-image.jpg', - 'fileId' => '5de4fb65c851e55df73abe8d', - 'tags' => null, - 'customCoordinates' => null, - 'isPrivateFile' => false, - 'url' => 'https://ik.imagekit.io/ot2cky3ujwa/default-image.jpg', - 'thumbnail' => 'https://ik.imagekit.io/ot2cky3ujwa/tr:n-media_library_thumbnail/default-image.jpg', - 'fileType' => 'image', - 'filePath' => '/default-image.jpg', - "versionInfo" => [ - "id" => "330a81i1f949c0a938d57563bd", - "name" => "Version 2" - ] - ], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->getFileVersions($fileId); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - - // Request Check - FileTest::assertEquals("/v1/files/{$fileId}/versions",$requestPath); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - - /** - * - */ - public function testGetFileVersionsWithMissingFileId() - { - $fileId = ''; - - $response = $this->client->getFileVersions($fileId); - - FileTest::assertEquals('Missing File ID parameter for this request', $response->error->message); - } - - - /** - * - */ - public function testUpdateFileDetails() - { - $fileId = '5df36759adf3f523d81dd94f'; - - $updateData = [ - 'customCoordinates' => '10,10,100,100', - 'tags' => ['tag1', 'tag2'], - 'removeAITags'=>['car','vehicle','motorsports'], - 'extensions'=>[ - [ - "name" => "google-auto-tagging", - "maxTags" => 5, - "minConfidence" => 95 - ] - ], - "customMetadata" => [ - "SKU" => "VS882HJ2JD", - "price" => 599.99, - ] - ]; - - $responseBody = [ - 'fileId' => '598821f949c0a938d57563bd', - 'type' => 'file', - 'name' => 'file1.jpg', - 'filePath' => '/images/products/file1.jpg', - 'tags' => ['t-shirt', 'round-neck', 'sale2019'], - 'isPrivateFile' => false, - 'customCoordinates' => null, - 'url' => 'https://ik.imagekit.io/your_imagekit_id/images/products/file1.jpg', - 'thumbnail' => 'https://ik.imagekit.io/your_imagekit_id/tr:n-media_library_thumbnail/images/products/file1.jpg', - 'fileType' => 'image' - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->updateFileDetails($fileId, $updateData); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - - // Request Check - FileTest::assertEquals("/v1/files/{$fileId}/details",$requestPath); - FileTest::assertEquals($stream,json_encode($updateData)); - - // Response Check - FileTest::assertNull($response->error); - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'PATCH'); - } - - /** - * - */ - public function testUpdateFilePublishStatus() - { - $fileId = '5df36759adf3f523d81dd94f'; - - $updateData = [ - "publish" => [ - "isPublished" => true, - "includeFileVersions" => true - ] - ]; - - $responseBody = [ - 'fileId' => '598821f949c0a938d57563bd', - 'type' => 'file', - 'name' => 'file1.jpg', - 'filePath' => '/images/products/file1.jpg', - 'tags' => ['t-shirt', 'round-neck', 'sale2019'], - 'isPrivateFile' => false, - 'isPublished' => true, - 'customCoordinates' => null, - 'url' => 'https://ik.imagekit.io/your_imagekit_id/images/products/file1.jpg', - 'thumbnail' => 'https://ik.imagekit.io/your_imagekit_id/tr:n-media_library_thumbnail/images/products/file1.jpg', - 'fileType' => 'image' - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->updateFileDetails($fileId, $updateData); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - - // Request Check - FileTest::assertEquals("/v1/files/{$fileId}/details",$requestPath); - FileTest::assertEquals($stream,json_encode($updateData)); - - // Response Check - FileTest::assertNull($response->error); - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'PATCH'); - } - - public function testUpdateFileDetailsWithInvalidTags() - { - $fileId = '5df36759adf3f523d81dd94f'; - - $updateData = [ - 'customCoordinates' => '10,10,100,100', - 'tags' => 'tag1,tag2', - 'removeAITags'=>['car','vehicle','motorsports'], - 'extensions'=>[ - [ - "name" => "google-auto-tagging", - "maxTags" => 5, - "minConfidence" => 95 - ] - ], - "customMetadata" => [ - "SKU" => "VS882HJ2JD", - "price" => 599.99, - ] - ]; - - $response = $this->client->updateFileDetails($fileId, $updateData); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Invalid tags parameter for this request', $response->error->message); - } - - /** - * - */ - public function testUpdateFileDetailsWithMissingFileId() - { - $fileId = ''; - - $updateData = [ - 'customCoordinates' => '10,10,100,100', - 'tags' => ['tag1', 'tag2'] - ]; - - $response = $this->client->updateFileDetails($fileId, $updateData); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Missing File ID parameter for this request', $response->error->message); - } - - - /** - * - */ - public function testUpdateFileDetailsWithInvalidUpdateData() - { - $fileId = '5df36759adf3f523d81dd94f'; - - $updateData = []; - - $response = $this->client->updateFileDetails($fileId, $updateData); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Missing file update data for this request', $response->error->message); - } - - - /** - * - */ - public function testUpdateFileDetailsWithError() - { - $fileId = '5df36759adf3f523d81dd94f'; - - $updateData = [ - 'customCoordinates' => '10,10,100,100', - 'tags' => ['tag1', 'tag2'] - ]; - - $this->stubHttpClient('patch', new Response(500, ['X-Foo' => 'Bar'], json_encode($this->dummyAPIErrorResponse))); - - $response = $this->client->updateFileDetails($fileId, $updateData); - - FileTest::assertEquals(json_encode($this->dummyAPIErrorResponse),json_encode($response->error)); - } - - - /** - * - */ - public function testBulkAddTags() - { - $fileIds = ['5e21880d5efe355febd4bccd','5e1c13c1c55ec3437c451403']; - $tags = ['testing_tag1']; - - $responseBody = [ - "successfullyUpdatedFileIds" => [ - "5e21880d5efe355febd4bccd", - "5e1c13c1c55ec3437c451403" - ] - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->bulkAddTags($fileIds, $tags); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals($stream['fileIds'],$fileIds); - FileTest::assertEquals($stream['tags'],$tags); - FileTest::assertEquals("/v1/files/addTags",$requestPath); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - - /** - * - */ - public function testBulkAddTagsMissingFileIds() - { - $fileIds = []; - $tags = ['testing_tag1']; - - $response = $this->client->bulkAddTags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts FileIds as an array of ids, empty array passed', $response->error->message); - } - - - /** - * - */ - public function testBulkAddTagsMissingTags() - { - $fileIds = ['23902390239203923']; - $tags = []; - - $response = $this->client->bulkAddTags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts Tags as an array of tags, empty array passed', $response->error->message); - } - - /** - * - */ - public function testBulkAddTagsNonArrayFileId() - { - $fileIds = '23902390239203923'; - $tags = ['testing_tag1']; - - $response = $this->client->bulkAddTags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts FileIds as an array, non array passed', $response->error->message); - } - - /** - * - */ - public function testBulkAddTagsNonArrayTags() - { - $fileIds = ['23902390239203923']; - $tags = 'testing_tag1'; - - $response = $this->client->bulkAddTags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts Tags as an array, non array passed', $response->error->message); - } - - /** - * - */ - public function testBulkRemoveTags() - { - $fileIds = ['23902390239203923']; - $tags = ['testing_tag1']; - - $responseBody = [ - "successfullyUpdatedFileIds" => [ - "23902390239203923", - ] - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->bulkRemoveTags($fileIds, $tags); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals($stream['fileIds'],$fileIds); - FileTest::assertEquals($stream['tags'],$tags); - FileTest::assertEquals("/v1/files/removeTags",$requestPath); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testBulkRemoveTagsMissingFileIds() - { - $fileIds = []; - $tags = ['testing_tag1']; - - $response = $this->client->bulkRemoveTags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts FileIds as an array of ids, empty array passed', $response->error->message); - } - - /** - * - */ - public function testBulkRemoveTagsMissingTags() - { - $fileIds = ['23902390239203923']; - $tags = []; - - $response = $this->client->bulkRemoveTags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts Tags as an array of tags, empty array passed', $response->error->message); - } - - - /** - * - */ - public function testBulkRemoveTagsNonArrayFileId() - { - $fileIds = '23902390239203923'; - $tags = ['testing_tag1']; - - $response = $this->client->bulkRemoveTags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts FileIds as an array, non array passed', $response->error->message); - } - - /** - * - */ - public function testBulkRemoveTagsNonArrayTags() - { - $fileIds = ['23902390239203923']; - $tags = 'testing_tag1'; - - $response = $this->client->bulkRemoveTags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts Tags as an array, non array passed', $response->error->message); - } - - /** - * - */ - public function testBulkRemoveAITags() - { - $fileIds = ['5e21880d5efe355febd4bccd','5e1c13c1c55ec3437c451403']; - $AItags = ['image_AITag_1','image_AITag_2']; - - $responseBody = [ - "successfullyUpdatedFileIds" => [ - "5e21880d5efe355febd4bccd", - "5e1c13c1c55ec3437c451403" - ] - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->bulkRemoveAITags($fileIds, $AItags); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals($stream['fileIds'],$fileIds); - FileTest::assertEquals($stream['AITags'],$AItags); - FileTest::assertEquals("/v1/files/removeAITags",$requestPath); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testBulkRemoveAITagsMissingFileIds() - { - $fileIds = []; - $tags = ['image_AITag_1']; - - $response = $this->client->bulkRemoveAITags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts FileIds as an array of ids, empty array passed', $response->error->message); - } - - /** - * - */ - public function testBulkRemoveAITagsMissingTags() - { - $fileIds = ['23902390239203923']; - $tags = []; - - $response = $this->client->bulkRemoveAITags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts Tags as an array of tags, empty array passed', $response->error->message); - } - - - /** - * - */ - public function testBulkRemoveAITagsNonArrayFileId() - { - $fileIds = '23902390239203923'; - $tags = ['testing_tag1']; - - $response = $this->client->bulkRemoveAITags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts FileIds as an array, non array passed', $response->error->message); - } - - /** - * - */ - public function testBulkRemoveAITagsNonArrayTags() - { - $fileIds = ['23902390239203923']; - $tags = 'testing_tag1'; - - $response = $this->client->bulkRemoveAITags($fileIds, $tags); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Bulk Tags API accepts Tags as an array, non array passed', $response->error->message); - } - - /** - * - */ - public function testDeleteSingleFile() - { - $fileId = "23902390239203923"; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->deleteFile($fileId); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals("/v1/files/".$fileId,$requestPath); - FileTest::assertEquals($stream[0],$fileId); - - // Response Check - FolderTest::assertNull($response->result); - FolderTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'DELETE'); - } - - /** - * - */ - public function testDeleteSingleFileMissingFileId() - { - $fileId = ""; - - $response = $this->client->deleteFile($fileId); - - FileTest::assertEquals('Missing File ID parameter for this request',$response->error->message); - } - - /** - * - */ - public function testDeleteFileVersion() - { - $fileId = '23902390239203923'; - $versionId = "123213239023902392"; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->deleteFileVersion($fileId, $versionId); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals("/v1/files/{$fileId}/versions/{$versionId}",$requestPath); - FileTest::assertEquals($stream[0],$fileId); - FileTest::assertEquals($stream[1],$versionId); - - // Response Check - FolderTest::assertNull($response->result); - FolderTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'DELETE'); - } - - /** - * - */ - public function testDeleteFileVersionWithMissingFileId() - { - $fileId = ""; - $versionId = "version_id"; - - $response = $this->client->deleteFileVersion($fileId, $versionId); - - FileTest::assertEquals('Missing File ID parameter for this request',$response->error->message); - } - - /** - * - */ - public function testDeleteFileVersionWithMissingVisionId() - { - $fileId = "file_id"; - $versionId = ""; - - $response = $this->client->deleteFileVersion($fileId, $versionId); - - FileTest::assertEquals('Missing Version ID parameter for this request',$response->error->message); - } - - /** - * - */ - public function testBulkDeleteFiles() - { - $fileIds = ['file_id1','file_id2']; - - $responseBody = [ - "successfullyDeletedFileIds" => [ - "5e21880d5efe355febd4bccd", - "5e1c13c1c55ec3437c451403" - ] - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->bulkDeleteFiles($fileIds); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $requestBody = $request->getBody(); - $stream = Utils::streamFor($requestBody)->getContents(); - $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals("/v1/files/batch/deleteByFileIds",$requestPath); - FileTest::assertEquals($stream['fileIds'],$fileIds); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testBulkDeleteFilesInvalidRequest() - { - $response = $this->client->bulkDeleteFiles(); - - FileTest::assertEquals('Missing Parameter FileIds', $response->error->message); - } - - /** - * - */ - public function testBulkDeleteFilesMissingFileIds() - { - $fileIds = []; - $response = $this->client->bulkDeleteFiles($fileIds); - - FileTest::assertEquals('File ids should be passed as an array of file ids, empty array passed', $response->error->message); - } - - /** - * - */ - public function testBulkDeleteFilesNonArrayFileIds() - { - $fileIds = 'file_id'; - $response = $this->client->bulkDeleteFiles($fileIds); - - FileTest::assertEquals('File ids should be passed in an array', $response->error->message); - } - - /** - * - */ - public function testCopyFile() - { - $sourceFilePath = '/file.jpg'; - $destinationPath = '/'; - $includeFileVersions = true; - - $requestBody = [ - 'sourceFilePath' => $sourceFilePath, - 'destinationPath' => $destinationPath, - 'includeFileVersions' => $includeFileVersions - ]; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->copy($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - // $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals("/v1/files/copy",$requestPath); - FileTest::assertEquals($stream,json_encode($requestBody)); - - // Response Check - FolderTest::assertNull($response->result); - FolderTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - - /** - * - */ - public function testCopyFileWithoutIncludeFileVersions() - { - $sourceFilePath = '/file.jpg'; - $destinationPath = '/'; - $includeFileVersions = true; - - $requestBody = [ - 'sourceFilePath' => $sourceFilePath, - 'destinationPath' => $destinationPath, - ]; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->copy($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - // $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals("/v1/files/copy",$requestPath); - FileTest::assertEquals($stream,json_encode([ - 'sourceFilePath' => '/file.jpg', - 'destinationPath' => '/', - 'includeFileVersions' => false - ])); - - // Response Check - FolderTest::assertNull($response->result); - FolderTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testCopyFileInvalidParameter() - { - $sourceFilePath = '/file.jpg'; - $destinationPath = '/'; - $includeVersions = true; - - $requestBody = []; - - $response = $this->client->copy($requestBody); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Copy File API accepts an array of parameters, empty array passed',$response->error->message); - - } - - - /** - * - */ - public function testCopyFileMissingSourceFilePath() - { - $sourceFilePath = '/file.jpg'; - $destinationPath = '/'; - $includeVersions = true; - - $requestBody = [ - 'destinationPath' => $destinationPath, - 'includeVersions' => $includeVersions - ]; - - $response = $this->client->copy($requestBody); - - - FileTest::assertNull($response->result); - FileTest::assertEquals('Missing parameter sourceFilePath and/or destinationPath for Copy File API',$response->error->message); - } - - /** - * - */ - public function testCopyFileMissingDestinationPath() - { - $sourceFilePath = '/file.jpg'; - $destinationPath = '/'; - $includeVersions = true; - - $requestBody = [ - 'sourceFilePath' => $sourceFilePath, - 'includeVersions' => $includeVersions - ]; - - $response = $this->client->copy($requestBody); - - - FileTest::assertNull($response->result); - FileTest::assertEquals('Missing parameter sourceFilePath and/or destinationPath for Copy File API',$response->error->message); - - } - - /** - * - */ - public function testMoveFile() - { - $sourceFilePath = '/file.jpg'; - $destinationPath = '/'; - - $requestBody = [ - 'sourceFilePath' => $sourceFilePath, - 'destinationPath' => $destinationPath - ]; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->move($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - - // Request Check - FileTest::assertEquals("/v1/files/move",$requestPath); - FileTest::assertEquals($stream,json_encode($requestBody)); - - // Response Check - FolderTest::assertNull($response->result); - FolderTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testMoveFileInvalidParameter() - { - $sourceFilePath = '/file.jpg'; - $destinationPath = '/'; - - $requestBody = []; - - $response = $this->client->move($requestBody); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Move File API accepts an array of parameters, empty array passed',$response->error->message); - } - - /** - * - */ - public function testMoveFileMissingSourceFilePath() - { - $sourceFilePath = '/file.jpg'; - $destinationPath = '/'; - - $requestBody = [ - 'destinationPath' => $destinationPath, - ]; - - $response = $this->client->move($requestBody); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Missing parameter sourceFilePath and/or destinationPath for Move File API',$response->error->message); - } - - /** - * - */ - public function testMoveFileMissingDestinationPath() - { - $sourceFilePath = '/file.jpg'; - $destinationPath = '/'; - - $requestBody = [ - 'sourceFilePath' => $sourceFilePath, - ]; - - $response = $this->client->move($requestBody); - - FileTest::assertNull($response->result); - FileTest::assertEquals('Missing parameter sourceFilePath and/or destinationPath for Move File API',$response->error->message); - - } - - /** - * - */ - public function testRenameFile() - { - $filePath = '/sample-folder/sample-file.jpg'; - $newFileName = 'sample-file2.jpg'; - - $requestBody = [ - 'filePath' => $filePath, - 'newFileName' => $newFileName, - 'purgeCache' => true - ]; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->rename($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - - // Request Check - FileTest::assertEquals("/v1/files/rename",$requestPath); - FileTest::assertEquals($stream,json_encode($requestBody)); - - // Response Check - FolderTest::assertNull($response->result); - FolderTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'PUT'); - } - - - /** - * - */ - public function testRenameFileWithoutPurgeCache() - { - $filePath = '/sample-folder/sample-file.jpg'; - $newFileName = 'sample-file2.jpg'; - - $requestBody = [ - 'filePath' => $filePath, - 'newFileName' => $newFileName, - ]; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->rename($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - - // Request Check - FileTest::assertEquals("/v1/files/rename",$requestPath); - FileTest::assertEquals($stream,json_encode([ - 'filePath' => '/sample-folder/sample-file.jpg', - 'newFileName' => 'sample-file2.jpg', - 'purgeCache' => false - ])); - - // Response Check - FolderTest::assertNull($response->result); - FolderTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'PUT'); - } - - /** - * - */ - public function testRenameFileWithInvalidRequest() - { - $response = $this->client->rename(); - - FileTest::assertEquals('Rename File API accepts an array, null passed',$response->error->message); - } - - /** - * - */ - public function testRenameFileWithNonArrayParameter() - { - $filePath = '/sample-folder/sample-file.jpg'; - $newFileName = 'sample-file2.jpg'; - - $requestBody = $filePath; - - $response = $this->client->rename($requestBody); - - FileTest::assertEquals('Rename File API accepts an array of parameters, non array value passed',$response->error->message); - } - - /** - * - */ - public function testRenameFileWithEmptyArrayParameter() - { - $requestBody = []; - - $response = $this->client->rename($requestBody); - - FileTest::assertEquals('Rename File API accepts an array of parameters, empty array passed',$response->error->message); - } - - /** - * - */ - public function testRenameFileWithMissingFilePath() - { - $filePath = ''; - $newFileName = 'sample-file2.jpg'; - - $requestBody = [ - 'filePath' => $filePath, - 'newFileName' => $newFileName, - ]; - - $response = $this->client->rename($requestBody); - - FileTest::assertEquals('Missing parameter filePath and/or newFileName for Rename File API',$response->error->message); - } - - /** - * - */ - public function testRenameFileWithMissingNewFileName() - { - $filePath = '/sample-folder/sample-file.jpg'; - $newFileName = ''; - - $requestBody = [ - 'filePath' => $filePath, - 'newFileName' => $newFileName, - ]; - - $response = $this->client->rename($requestBody); - - FileTest::assertEquals('Missing parameter filePath and/or newFileName for Rename File API',$response->error->message); - } - - /** - * - */ - public function testRestoreFileVersion() - { - $fileId = 'fileId'; - $versionId = 'versionId'; - - $requestBody = [ - 'fileId' => $fileId, - 'versionId' => $versionId, - ]; - - $responseBody = [ - 'type' => 'file', - 'name' => 'default-image.jpg', - 'fileId' => '5de4fb65c851e55df73abe8d', - 'tags' => null, - 'customCoordinates' => null, - 'isPrivateFile' => false, - 'url' => 'https://ik.imagekit.io/ot2cky3ujwa/default-image.jpg', - 'thumbnail' => 'https://ik.imagekit.io/ot2cky3ujwa/tr:n-media_library_thumbnail/default-image.jpg', - 'fileType' => 'image', - 'filePath' => '/default-image.jpg', - "versionInfo" => [ - "id" => "598821f949c0a938d57563bd", - "name" => "Version 1" - ], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->restoreFileVersion($requestBody); - - $request = $container[0]['request']; - $queryString = $request->getUri()->getQuery(); - $requestPath = $request->getUri()->getPath(); - - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - // Request Check - FileTest::assertEquals("/v1/files/{$fileId}/versions/{$versionId}/restore",$requestPath); - FileTest::assertEmpty($stream); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'PUT'); - } - - /** - * - */ - public function testRestoreFileVersionWithInvalidRequest() - { - $response = $this->client->restoreFileVersion(); - - FileTest::assertEquals('Restore File Version API accepts an array, null passed',$response->error->message); - } - - /** - * - */ - public function testRestoreFileVersionWithNonArrayParameter() - { - $fileId = 'fileId'; - $versionId = 'versionId'; - - $requestBody = $fileId; - - $response = $this->client->restoreFileVersion($requestBody); - - FileTest::assertEquals('Restore File Version API accepts an array of parameters, non array value passed',$response->error->message); - } - - /** - * - */ - public function testRestoreFileVersionWithEmptyArrayParameter() - { - $requestBody = []; - - $response = $this->client->restoreFileVersion($requestBody); - - FileTest::assertEquals('Restore File Version API accepts an array of parameters, empty array passed',$response->error->message); - } - - /** - * - */ - public function testRestoreFileVersionWithMissingFileId() - { - $fileId = ''; - $versionId = 'versionId'; - - $requestBody = [ - 'fileId' => $fileId, - 'versionId' => $versionId, - ]; - - $response = $this->client->restoreFileVersion($requestBody); - - FileTest::assertEquals('Missing parameter fileId and/or versionId for Restore File Version API',$response->error->message); - } - - /** - * - */ - public function testRestoreFileVersionWithMissingVersionId() - { - $fileId = 'fileId'; - $versionId = ''; - - $requestBody = [ - 'fileId' => $fileId, - 'versionId' => $versionId, - ]; - - $response = $this->client->restoreFileVersion($requestBody); - - FileTest::assertEquals('Missing parameter fileId and/or versionId for Restore File Version API',$response->error->message); - } - - - - /** - * - */ - public function testGetFileMetadataUsingFileId() - { - $fileId = '5de4fb65c851e55df73abe8d'; - - $responseBody = [ - 'height' => 3214, - 'width' => 3948, - 'size' => 207097, - 'format' => 'jpg', - 'hasColorProfile' => true, - 'quality' => 90, - 'density' => 300, - 'hasTransparency' => false, - 'exif' => [ - 'image' => [ - 'ImageWidth' => 4584, - 'ImageHeight' => 3334, - 'BitsPerSample' => [8, 8, 8], - 'PhotometricInterpretation' => 2, - 'ImageDescription' => 'Character illustration of people holding creative ideas icons', - 'Orientation' => 1, - 'SamplesPerPixel' => 3, - 'XResolution' => 300, - 'YResolution' => 300, - 'ResolutionUnit' => 2, - 'Software' => 'Adobe Photoshop CC 2019 (Windows)', - 'ModifyDate' => '2019=>05=>25 10=>16=>49', - 'Artist' => 'busbus', - 'Copyright' => 'Rawpixel Ltd.', - 'ExifOffset' => 356 - ], - 'thumbnail' => [ - 'Compression' => 6, - 'XResolution' => 72, - 'YResolution' => 72, - 'ResolutionUnit' => 2, - 'ThumbnailOffset' => 506, - 'ThumbnailLength' => 6230, - ], - 'exif' => [ - 'ExifVersion' => '0221', - 'ColorSpace' => 65535, - 'ExifImageWidth' => 3948, - 'ExifImageHeight' => 3214 - ], - 'gps' => [], - 'interoperability' => [], - 'makernote' => [], - ], - 'pHash' => 'd1813e2fc22c7b2f', - ]; - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->getFileMetaData($fileId); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $queryString = $request->getUri()->getQuery(); - $stream = Utils::streamFor($request->getBody())->getContents(); - // $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals("/v1/files/{$fileId}/metadata",$requestPath); - FileTest::assertEmpty($stream); - - // Response Check - FileTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - - /** - * - */ - public function testGetFileMetadataUsingFileIdWithMissingFileId() - { - $fileId = ''; - - $response = $this->client->getFileMetaData($fileId); - - FileTest::assertEquals('Missing File ID parameter for this request', $response->error->message); - } - - /** - * - */ - public function testGetFileMetadataUsingRemoteURL() - { - $remoteURL = 'https://ik.imagekit.io/demo/sample-folder/default-image.jpg'; - - $requestBody = [ - 'height' => 3214, - 'width' => 3948, - 'size' => 207097, - 'format' => 'jpg', - 'hasColorProfile' => true, - 'quality' => 90, - 'density' => 300, - 'hasTransparency' => false, - 'exif' => [ - 'image' => [ - 'ImageWidth' => 4584, - 'ImageHeight' => 3334, - 'BitsPerSample' => [8, 8, 8], - 'PhotometricInterpretation' => 2, - 'ImageDescription' => 'Character illustration of people holding creative ideas icons', - 'Orientation' => 1, - 'SamplesPerPixel' => 3, - 'XResolution' => 300, - 'YResolution' => 300, - 'ResolutionUnit' => 2, - 'Software' => 'Adobe Photoshop CC 2019 (Windows)', - 'ModifyDate' => '2019=>05=>25 10=>16=>49', - 'Artist' => 'busbus', - 'Copyright' => 'Rawpixel Ltd.', - 'ExifOffset' => 356 - ], - 'thumbnail' => [ - 'Compression' => 6, - 'XResolution' => 72, - 'YResolution' => 72, - 'ResolutionUnit' => 2, - 'ThumbnailOffset' => 506, - 'ThumbnailLength' => 6230, - ], - 'exif' => [ - 'ExifVersion' => '0221', - 'ColorSpace' => 65535, - 'ExifImageWidth' => 3948, - 'ExifImageHeight' => 3214 - ], - 'gps' => [], - 'interoperability' => [], - 'makernote' => [], - ], - 'pHash' => 'd1813e2fc22c7b2f', - ]; - $mockBodyResponse = Utils::streamFor(json_encode($requestBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->getFileMetadataFromRemoteURL($remoteURL); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $queryString = $request->getUri()->getQuery(); - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals("/v1/metadata",$requestPath); - FileTest::assertEquals($queryString,http_build_query(['url'=>$remoteURL])); - - // Response Check - FileTest::assertEquals(json_encode($requestBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'GET'); - } - - - - /** - * - */ - public function testGetFileMetadataUsingRemoteURLMissingURL() - { - $remoteURL = ''; - - $response = $this->client->getFileMetadataFromRemoteURL($remoteURL); - - FileTest::assertEquals('Your request is missing the url query paramater', $response->error->message); - } - - /** - * - */ - public function testGetFileMetadataUsingRemoteURLInvalidURL() - { - $remoteURL = 'invalid_url'; - - $response = $this->client->getFileMetadataFromRemoteURL($remoteURL); - - FileTest::assertEquals('Invalid URL provided for this request', $response->error->message); - } - - /** - * - */ - private function stubHttpClient($methodName, $response) - { - $stub = $this->createMock(GuzzleHttpWrapper::class); - $stub->method('setDatas'); - $stub->method($methodName)->willReturn($response); - - $closure = function () use ($stub) { - $this->httpClient = $stub; - }; - $doClosure = $closure->bindTo($this->client, ImageKit::class); - $doClosure(); - } - - /** - * - */ - private function createMockClient($handler){ - $this->mockClient = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo', - Transformation::DEFAULT_TRANSFORMATION_POSITION, - $handler - ); - } - - protected function setUp() - { - $this->client = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - } - - protected function tearDown() - { - $this->client = null; - } -} diff --git a/tests/ImageKit/Manage/FolderTest.php b/tests/ImageKit/Manage/FolderTest.php deleted file mode 100644 index e0fa83a2..00000000 --- a/tests/ImageKit/Manage/FolderTest.php +++ /dev/null @@ -1,565 +0,0 @@ - $parentFolderPath, - 'folderName' => $folderName, - ]; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->createFolder($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - - // Request Check - FileTest::assertEquals("/v1/folder/",$requestPath); - FileTest::assertEquals($stream,json_encode($requestBody)); - - // Response Check - FolderTest::assertNull($response->result); - FolderTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testCreateFolderInvalidRequest() - { - $response = $this->client->createFolder(); - - FolderTest::assertEquals('Create Folder API accepts an array, null passed',$response->error->message); - } - - /** - * - */ - public function testCreateFolderWithNonArrayParameter() - { - $folderName = 'new-folder'; - $parentFolderPath = '/'; - - $requestBody = $folderName; - - $response = $this->client->createFolder($requestBody); - - FolderTest::assertEquals('Create Folder API accepts an array of parameters, non array value passed',$response->error->message); - } - - /** - * - */ - public function testCreateFolderWithEmptyArrayParameter() - { - $requestBody = []; - - $response = $this->client->createFolder($requestBody); - - FolderTest::assertEquals('Create Folder API accepts an array of parameters, empty array passed',$response->error->message); - } - - - public function testCreateFolderWithMissingFolderName() - { - $folderName = ''; - $parentFolderPath = '/'; - - $requestBody = [ - 'folderName' => $folderName, - 'parentFolderPath' => $parentFolderPath, - ]; - - $response = $this->client->createFolder($requestBody); - - FolderTest::assertEquals('Missing parameter folderName and/or parentFolderPath for Create Folder API', $response->error->message); - } - - public function testCreateFolderWithMissingParentFolderPath() - { - $folderName = 'new-folder'; - $parentFolderPath = ''; - - $requestBody = [ - 'folderName' => $folderName, - 'parentFolderPath' => $parentFolderPath, - ]; - - $response = $this->client->createFolder($requestBody); - - FolderTest::assertEquals('Missing parameter folderName and/or parentFolderPath for Create Folder API', $response->error->message); - } - - /** - * - */ - public function testDeleteFolder() - { - $folderPath = '/new-folder'; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->deleteFolder($folderPath); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - $stream = json_decode($stream,true); - - // Request Check - FileTest::assertEquals("/v1/folder/",$requestPath); - FileTest::assertEquals($stream['folderPath'],$folderPath); - - // Response Check - FolderTest::assertNull($response->result); - FolderTest::assertNull($response->error); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'DELETE'); - } - - /** - * - */ - public function testDeleteFolderMissingFolderPath() - { - $folderPath = ''; - - $response = $this->client->deleteFolder($folderPath); - - FolderTest::assertEquals('Missing folderPath for Delete Folder API',$response->error->message); - } - - public function testCopyFolder(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = "/destination-folder/"; - $includeFileVersions = false; - - $requestBody = [ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - 'includeFileVersions' => $includeFileVersions - ]; - - $responseBody = [ - "jobId" => "598821f949c0a938d57563bd" - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->copyFolder($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - - // Request Check - FileTest::assertEquals("/v1/bulkJobs/copyFolder",$requestPath); - FileTest::assertEquals($stream,json_encode($requestBody)); - - // Response Check - FolderTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - - public function testCopyFolderWithoutIncludeFileVersions(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = "/destination-folder/"; - - $requestBody = [ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - ]; - - $responseBody = [ - "jobId" => "598821f949c0a938d57563bd" - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->copyFolder($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - - // Request Check - FileTest::assertEquals("/v1/bulkJobs/copyFolder",$requestPath); - FileTest::assertEquals($stream,json_encode([ - 'sourceFolderPath' => '/source-folder/', - 'destinationPath' => '/destination-folder/', - 'includeFileVersions' => false - ])); - - // Response Check - FolderTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - - public function testCopyFolderInvalidRequest(){ - - $response = $this->client->copyFolder(); - - FolderTest::assertEquals("Copy Folder API accepts an array, null passed", $response->error->message); - - } - - public function testCopyFolderNonArray(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = "/destination-folder/"; - $includeVersions = false; - - $requestBody = $sourceFolderPath; - $response = $this->client->copyFolder($requestBody); - - FolderTest::assertEquals("Copy Folder API accepts an array of parameters, non array value passed", $response->error->message); - - } - - public function testCopyFolderEmptyArray(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = "/destination-folder/"; - $includeVersions = false; - - $requestBody = []; - $response = $this->client->copyFolder($requestBody); - - FolderTest::assertEquals("Copy Folder API accepts an array of parameters, empty array passed", $response->error->message); - - } - - public function testCopyFolderWithMissingSourceFolderPath(){ - - $sourceFolderPath = ""; - $destinationPath = "/destination-folder/"; - $includeVersions = false; - - $requestBody = [ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - 'includeVersions' => $includeVersions - ]; - - $response = $this->client->copyFolder($requestBody); - - FolderTest::assertEquals("Missing parameter sourceFolderPath and/or destinationPath for Copy Folder API", $response->error->message); - - } - - public function testCopyFolderWithMissingDestinationPath(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = ""; - $includeVersions = false; - - $requestBody = [ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - 'includeVersions' => $includeVersions - ]; - - $response = $this->client->copyFolder($requestBody); - - FolderTest::assertEquals("Missing parameter sourceFolderPath and/or destinationPath for Copy Folder API", $response->error->message); - - } - - public function testCopyFolderWithNullIncludeVersions(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = "/destination-folder/"; - $includeVersions = null; - - $requestBody = [ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - 'includeVersions' => $includeVersions - ]; - - $mockBodyResponse = Utils::streamFor(); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->copyFolder($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - - // Request Check - FileTest::assertEquals("/v1/bulkJobs/copyFolder",$requestPath); - FileTest::assertEquals($stream,json_encode([ - 'sourceFolderPath' => '/source-folder/', - 'destinationPath' => '/destination-folder/', - 'includeFileVersions' => false - ])); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - - public function testMoveFolder(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = "/destination-folder/"; - - $requestBody = [ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - ]; - - $responseBody = [ - "jobId" => "598821f949c0a938d57563bd" - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($responseBody)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->moveFolder($requestBody); - - $request = $container[0]['request']; - $requestPath = $request->getUri()->getPath(); - $stream = Utils::streamFor($request->getBody())->getContents(); - - // Request Check - FileTest::assertEquals("/v1/bulkJobs/moveFolder",$requestPath); - FileTest::assertEquals($stream,json_encode($requestBody)); - - // Response Check - FolderTest::assertEquals(json_encode($responseBody), json_encode($response->result)); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - FileTest::assertEquals($requestMethod,'POST'); - } - - - public function testMoveFolderInvalidRequest(){ - - $response = $this->client->moveFolder(); - - FolderTest::assertEquals("Move Folder API accepts an array, null passed", $response->error->message); - - } - - public function testMoveFolderNonArray(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = "/destination-folder/"; - - $requestBody = $sourceFolderPath; - $response = $this->client->moveFolder($requestBody); - - FolderTest::assertEquals("Move Folder API accepts an array of parameters, non array value passed", $response->error->message); - - } - - public function testMoveFolderEmptyArray(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = "/destination-folder/"; - - $requestBody = []; - $response = $this->client->moveFolder($requestBody); - - FolderTest::assertEquals("Move Folder API accepts an array of parameters, empty array passed", $response->error->message); - - } - - public function testMoveFolderWithMissingSourceFolderPath(){ - - $sourceFolderPath = ""; - $destinationPath = "/destination-folder/"; - - $requestBody = [ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - ]; - - $response = $this->client->moveFolder($requestBody); - - FolderTest::assertEquals("Missing parameter sourceFolderPath and/or destinationPath for Move Folder API", $response->error->message); - - } - - public function testMoveFolderWithMissingDestinationPath(){ - - $sourceFolderPath = "/source-folder/"; - $destinationPath = ""; - - $requestBody = [ - 'sourceFolderPath' => $sourceFolderPath, - 'destinationPath' => $destinationPath, - ]; - - $response = $this->client->moveFolder($requestBody); - - FolderTest::assertEquals("Missing parameter sourceFolderPath and/or destinationPath for Move Folder API", $response->error->message); - - } - - - private function stubHttpClient($methodName, $response) - { - $stub = $this->createMock(GuzzleHttpWrapper::class); - $stub->method('setDatas'); - $stub->method($methodName)->willReturn($response); - - $closure = function () use ($stub) { - $this->httpClient = $stub; - }; - $doClosure = $closure->bindTo($this->client, ImageKit::class); - $doClosure(); - } - - protected function setUp() - { - $this->client = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - } - - /** - * - */ - private function createMockClient($handler){ - $this->mockClient = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo', - Transformation::DEFAULT_TRANSFORMATION_POSITION, - $handler - ); - } - - protected function tearDown() - { - $this->client = null; - } -} diff --git a/tests/ImageKit/Phash/PhashTest.php b/tests/ImageKit/Phash/PhashTest.php deleted file mode 100644 index 0578e0c3..00000000 --- a/tests/ImageKit/Phash/PhashTest.php +++ /dev/null @@ -1,55 +0,0 @@ -pHashDistance($firstHash, $secondHash); - PhashTest::assertEquals(0, $response); - } - - /** - * - */ - public function testPHashDistanceForSimilarImages() - { - $firstHash = '2d5ad3936d2e015b'; - $secondHash = '2d6ed293db36a4fb'; - - $pHash = new Phash(); - $response = $pHash->pHashDistance($firstHash, $secondHash); - PhashTest::assertEquals(17, $response); - } - - /** - * - */ - public function testPHashDistanceForDissimilarImages() - { - $firstHash = '33699c96619cc69e'; - $secondHash = '968e978414fe04ea'; - - $pHash = new Phash(); - $response = $pHash->pHashDistance($firstHash, $secondHash); - PhashTest::assertEquals(30, $response); - } -} diff --git a/tests/ImageKit/Resource/GuzzleHttpWrapperTest.php b/tests/ImageKit/Resource/GuzzleHttpWrapperTest.php deleted file mode 100644 index 72e29efb..00000000 --- a/tests/ImageKit/Resource/GuzzleHttpWrapperTest.php +++ /dev/null @@ -1,41 +0,0 @@ - 'Test', - 'param2' => '', - 'param3' => null, - 'param4' => [], - 'param5' => [], - 'param6' => true, - 'param7' => false, - 'param8' => 0 - ]; - - $stub = $this->createMock(Client::class); - - $resource = new GuzzleHttpWrapper($stub); - $resource->setDatas($data); - - GuzzleHttpWrapperTest::assertEquals(['param1' => 'Test', 'param6' => true, 'param7' => false, 'param8' => 0], $resource->getDatas()); - } -} diff --git a/tests/ImageKit/Upload/UploadTest.php b/tests/ImageKit/Upload/UploadTest.php deleted file mode 100644 index 8c8b1df9..00000000 --- a/tests/ImageKit/Upload/UploadTest.php +++ /dev/null @@ -1,856 +0,0 @@ - "598821f949c0a938d57563bd", - "name"=> "file1.jpg", - "url"=> "https://ik.imagekit.io/your_imagekit_id/images/products/file1.jpg", - "thumbnailUrl"=> "https://ik.imagekit.io/your_imagekit_id/tr:n-media_library_thumbnail/images/products/file1.jpg", - "height"=> 300, - "width"=> 200, - "size"=> 83622, - "filePath"=> "/images/products/file1.jpg", - "tags"=> ["t-shirt", "round-neck", "sale2019"], - "isPrivateFile"=> false, - "customCoordinates"=> null, - "fileType"=> "image", - "AITags"=>[["name"=>"Face","confidence"=>99.95,"source"=>"aws-auto-tagging"]], - "extensionStatus"=>["aws-auto-tagging"=>"success"] - ]; - - /** - * - */ - private function stubHttpClient($response) - { - $stub = $this->createMock(GuzzleHttpWrapper::class); - $stub->method('setDatas'); - $stub->method('postMultipart')->willReturn($response); - - $closure = function () use ($stub) { - $this->httpClient = $stub; - }; - $doClosure = $closure->bindTo($this->client, ImageKit::class); - $doClosure(); - } - - /** - * - */ - private function createMockClient($handler){ - $this->mockClient = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo', - Transformation::DEFAULT_TRANSFORMATION_POSITION, - $handler - ); - } - - private function checkFormData($requestBody, $boundary, $fieldName, $fieldValue) { - - $string = '--'.$boundary.' Content-Disposition: form-data; name="'.$fieldName.'" Content-Length: '.strlen($fieldValue).' '.$fieldValue; - $string = substr(json_encode($string),1,-1); - - UploadTest::assertContains($string,$requestBody); - } - - /** - * - */ - public function testFileUploadIfInvalidUploadParams() - { - - $mockBodyResponse = Utils::streamFor(); - - $response = $this->client->uploadFile(null); - - UploadTest::assertNull($response->result); - UploadTest::assertEquals('Upload API accepts an array of parameters, null passed', $response->error->message); - } - - /** - * - */ - public function testFileUploadIfMissingFileName() - { - - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - ]; - - $response = $this->client->uploadFile($fileOptions); - - UploadTest::assertNull($response->result); - UploadTest::assertEquals('Missing fileName parameter for upload', $response->error->message); - } - - /** - * - */ - public function testFileUploadIfMissingFile() - { - $fileOptions = [ - 'fileName' => 'default-image.png', - ]; - - $response = $this->client->uploadFile($fileOptions); - - UploadTest::assertNull($response->result); - UploadTest::assertEquals('Missing file parameter for upload', $response->error->message); - } - - - /** - * - */ - public function testFileUploadIfSuccessful() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "useUniqueFileName" => false, // true|false - "tags" => implode(',',["abd", "def"]), // Comma Separated, Max length: 500 chars - "folder" => "/sample-folder", // Using multiple forward slash (/) creates a nested folder - "isPrivateFile" => true, // true|false - "customCoordinates" => implode(",", ["10", "10", "100", "100"]), // Comma Separated, Max length: 500 chars - "responseFields" => implode(",", ["tags", "customMetadata"]), // Comma Separated, check docs for more responseFields - "extensions" => [ // An array of extensions, for more extensions refer to docs - [ - "name" => "remove-bg", - "options" => [ // all parameters inside this object are sent directly to the third-party service - "add_shadow" => true - ] - ] - ], - "webhookUrl" => "https://example.com/webhook", // Notification URL to receive the final status of pending extensions - "overwriteFile" => true, // true|false, in case of false useUniqueFileName should be true - "overwriteAITags" => false, // true|false, set to false in order to preserve overwriteAITags - "overwriteTags" => false, // true|false - "overwriteCustomMetadata" => true, // true|false - "customMetadata" => [ // An array of created custom fields, for more details refer to docs - "SKU" => "VS882HJ2JD", - "price" => 599.99, - ], - 'transformation' => [ - 'pre' => 'l-text,i-Imagekit,fs-50,l-end', - 'post' => [ - [ - 'type' => 'transformation', - 'value' => 'h-100' - ] - ] - ], - 'checks' => "'request.folder' : '/sample-folder'", - 'isPublished' => true - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($this->uploadSuccessResponseObj)); - - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->uploadFile($fileOptions); - - $requestBody = $container[0]['request']->getBody(); - $requestHeaders = $container[0]['request']->getHeaders(); - $boundary = str_replace("multipart/form-data; boundary=","",$requestHeaders["Content-Type"][0]); - - UploadTest::assertArrayHasKey("Content-Type",$requestHeaders); - UploadTest::assertStringStartsWith("multipart/form-data; boundary=",$requestHeaders['Content-Type'][0]); - - $stream = Utils::streamFor($requestBody); - $stream = str_replace('\r\n',' ',json_encode($stream->getContents())); - - $this->checkFormData($stream,$boundary,"file",$fileOptions['file']); - $this->checkFormData($stream,$boundary,"fileName",$fileOptions['fileName']); - $this->checkFormData($stream,$boundary,"tags",implode(',',["abd", "def"])); - $this->checkFormData($stream,$boundary,"isPrivateFile","true"); - $this->checkFormData($stream,$boundary,"useUniqueFileName","false"); - $this->checkFormData($stream,$boundary,"responseFields",implode(",", ["tags", "customMetadata"])); - $this->checkFormData($stream,$boundary,"extensions",json_encode($fileOptions['extensions'])); - $this->checkFormData($stream,$boundary,"webhookUrl","https://example.com/webhook"); - $this->checkFormData($stream,$boundary,"overwriteFile","true"); - $this->checkFormData($stream,$boundary,"overwriteAITags","false"); - $this->checkFormData($stream,$boundary,"overwriteCustomMetadata","true"); - $this->checkFormData($stream,$boundary,"customMetadata",json_encode($fileOptions['customMetadata'])); - $this->checkFormData($stream,$boundary,"transformation",json_encode($fileOptions['transformation'])); - $this->checkFormData($stream,$boundary,"checks",$fileOptions['checks']); - $this->checkFormData($stream,$boundary,"isPublished","true"); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - UploadTest::assertEquals($requestMethod,'POST'); - - // Response Check - UploadTest::assertEquals(json_encode($this->uploadSuccessResponseObj), json_encode($response->result)); - } - - /** - * - */ - public function testFileUploadWithOnlyPreTransformationIfSuccessful() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "useUniqueFileName" => true, // true|false - "responseFields" => implode(",", ["tags", "customMetadata"]), // Comma Separated, check docs for more responseFields - 'transformation' => [ - 'pre' => 'l-text,i-Imagekit,fs-50,l-end', - ], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($this->uploadSuccessResponseObj)); - - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->uploadFile($fileOptions); - - $requestBody = $container[0]['request']->getBody(); - $requestHeaders = $container[0]['request']->getHeaders(); - $boundary = str_replace("multipart/form-data; boundary=","",$requestHeaders["Content-Type"][0]); - - UploadTest::assertArrayHasKey("Content-Type",$requestHeaders); - UploadTest::assertStringStartsWith("multipart/form-data; boundary=",$requestHeaders['Content-Type'][0]); - - $stream = Utils::streamFor($requestBody); - $stream = str_replace('\r\n',' ',json_encode($stream->getContents())); - - $this->checkFormData($stream,$boundary,"file",$fileOptions['file']); - $this->checkFormData($stream,$boundary,"fileName",$fileOptions['fileName']); - $this->checkFormData($stream,$boundary,"useUniqueFileName","true"); - $this->checkFormData($stream,$boundary,"responseFields",implode(",", ["tags", "customMetadata"])); - $this->checkFormData($stream,$boundary,"transformation",json_encode($fileOptions['transformation'])); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - UploadTest::assertEquals($requestMethod,'POST'); - - // Response Check - UploadTest::assertEquals(json_encode($this->uploadSuccessResponseObj), json_encode($response->result)); - } - - /** - * - */ - public function testFileUploadWithOnlyPostTransformationIfSuccessful() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "useUniqueFileName" => true, // true|false - "responseFields" => implode(",", ["tags", "customMetadata"]), // Comma Separated, check docs for more responseFields - 'transformation' => [ - 'post' => [ - [ - 'type' => 'transformation', - 'value' => 'h-100' - ] - ] - ], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($this->uploadSuccessResponseObj)); - - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->uploadFile($fileOptions); - - $requestBody = $container[0]['request']->getBody(); - $requestHeaders = $container[0]['request']->getHeaders(); - $boundary = str_replace("multipart/form-data; boundary=","",$requestHeaders["Content-Type"][0]); - - UploadTest::assertArrayHasKey("Content-Type",$requestHeaders); - UploadTest::assertStringStartsWith("multipart/form-data; boundary=",$requestHeaders['Content-Type'][0]); - - $stream = Utils::streamFor($requestBody); - $stream = str_replace('\r\n',' ',json_encode($stream->getContents())); - - $this->checkFormData($stream,$boundary,"file",$fileOptions['file']); - $this->checkFormData($stream,$boundary,"fileName",$fileOptions['fileName']); - $this->checkFormData($stream,$boundary,"useUniqueFileName","true"); - $this->checkFormData($stream,$boundary,"responseFields",implode(",", ["tags", "customMetadata"])); - $this->checkFormData($stream,$boundary,"transformation",json_encode($fileOptions['transformation'])); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - UploadTest::assertEquals($requestMethod,'POST'); - - // Response Check - UploadTest::assertEquals(json_encode($this->uploadSuccessResponseObj), json_encode($response->result)); - } - - /** - * - */ - public function testFileUploadMissingUseUniqueFileName() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - 'isPrivateFile' => true - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->uploadFile($fileOptions); - - $requestBody = $container[0]['request']->getBody(); - $requestHeaders = $container[0]['request']->getHeaders(); - $boundary = str_replace("multipart/form-data; boundary=","",$requestHeaders["Content-Type"][0]); - - UploadTest::assertArrayHasKey("Content-Type",$requestHeaders); - UploadTest::assertStringStartsWith("multipart/form-data; boundary=",$requestHeaders['Content-Type'][0]); - - $stream = Utils::streamFor($requestBody); - $stream = str_replace('\r\n',' ',json_encode($stream->getContents())); - - $this->checkFormData($stream,$boundary,"file",$fileOptions['file']); - $this->checkFormData($stream,$boundary,"fileName",$fileOptions['fileName']); - $this->checkFormData($stream,$boundary,"isPrivateFile","true"); - UploadTest::assertNotContains("useUniqueFileName",$stream); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - UploadTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testFileUploadMissingIsPrivateFileUseUniqueFileName() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "tags" => implode(",",["abd", "def"]), - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->uploadFile($fileOptions); - - $requestBody = $container[0]['request']->getBody(); - $requestHeaders = $container[0]['request']->getHeaders(); - $boundary = str_replace("multipart/form-data; boundary=","",$requestHeaders["Content-Type"][0]); - - UploadTest::assertArrayHasKey("Content-Type",$requestHeaders); - UploadTest::assertStringStartsWith("multipart/form-data; boundary=",$requestHeaders['Content-Type'][0]); - - $stream = Utils::streamFor($requestBody); - $stream = str_replace('\r\n',' ',json_encode($stream->getContents())); - - $this->checkFormData($stream,$boundary,"file",$fileOptions['file']); - $this->checkFormData($stream,$boundary,"fileName",$fileOptions['fileName']); - $this->checkFormData($stream,$boundary,"tags","abd,def"); - UploadTest::assertNotContains("isPrivateFile",$stream); - UploadTest::assertNotContains("useUniqueFileName",$stream); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - UploadTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testFileUploadTagsAsArray() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "tags" => ["abd", "def"], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->uploadFile($fileOptions); - - $requestBody = $container[0]['request']->getBody(); - $requestHeaders = $container[0]['request']->getHeaders(); - $boundary = str_replace("multipart/form-data; boundary=","",$requestHeaders["Content-Type"][0]); - - UploadTest::assertArrayHasKey("Content-Type",$requestHeaders); - UploadTest::assertStringStartsWith("multipart/form-data; boundary=",$requestHeaders['Content-Type'][0]); - - $stream = Utils::streamFor($requestBody); - $stream = str_replace('\r\n',' ',json_encode($stream->getContents())); - - $this->checkFormData($stream,$boundary,"file",$fileOptions['file']); - $this->checkFormData($stream,$boundary,"fileName",$fileOptions['fileName']); - $this->checkFormData($stream,$boundary,"tags","abd,def"); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - UploadTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testFileUploadCustomCoordinatesAsArray() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "customCoordinates" => ["10", "10", "100", "100"], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->uploadFile($fileOptions); - - $requestBody = $container[0]['request']->getBody(); - $requestHeaders = $container[0]['request']->getHeaders(); - $boundary = str_replace("multipart/form-data; boundary=","",$requestHeaders["Content-Type"][0]); - - UploadTest::assertArrayHasKey("Content-Type",$requestHeaders); - UploadTest::assertStringStartsWith("multipart/form-data; boundary=",$requestHeaders['Content-Type'][0]); - - $stream = Utils::streamFor($requestBody); - $stream = str_replace('\r\n',' ',json_encode($stream->getContents())); - - $this->checkFormData($stream,$boundary,"file",$fileOptions['file']); - $this->checkFormData($stream,$boundary,"fileName",$fileOptions['fileName']); - $this->checkFormData($stream,$boundary,"customCoordinates","10,10,100,100"); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - UploadTest::assertEquals($requestMethod,'POST'); - } - - - /** - * - */ - public function testFileUploadResponseFieldsAsArray() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "responseFields" => ["tags", "customMetadata"], - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->uploadFile($fileOptions); - - $requestBody = $container[0]['request']->getBody(); - $requestHeaders = $container[0]['request']->getHeaders(); - $boundary = str_replace("multipart/form-data; boundary=","",$requestHeaders["Content-Type"][0]); - - UploadTest::assertArrayHasKey("Content-Type",$requestHeaders); - UploadTest::assertStringStartsWith("multipart/form-data; boundary=",$requestHeaders['Content-Type'][0]); - - $stream = Utils::streamFor($requestBody); - $stream = str_replace('\r\n',' ',json_encode($stream->getContents())); - - $this->checkFormData($stream,$boundary,"file",$fileOptions['file']); - $this->checkFormData($stream,$boundary,"fileName",$fileOptions['fileName']); - $this->checkFormData($stream,$boundary,"responseFields","tags,customMetadata"); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - UploadTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testFileUploadBareMinimumRequest() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $mock = new MockHandler([ - new Response(200, ['X-Foo' => 'Bar'], $mockBodyResponse) - ]); - - $handlerStack = HandlerStack::create($mock); - - $container = []; - $history = Middleware::history($container); - - $handlerStack->push($history); - - $this->createMockClient($handlerStack); - - $response = $this->mockClient->uploadFile($fileOptions); - - $requestBody = $container[0]['request']->getBody(); - $requestHeaders = $container[0]['request']->getHeaders(); - $boundary = str_replace("multipart/form-data; boundary=","",$requestHeaders["Content-Type"][0]); - - UploadTest::assertArrayHasKey("Content-Type",$requestHeaders); - UploadTest::assertStringStartsWith("multipart/form-data; boundary=",$requestHeaders['Content-Type'][0]); - - $stream = Utils::streamFor($requestBody); - $stream = str_replace('\r\n',' ',json_encode($stream->getContents())); - - $this->checkFormData($stream,$boundary,"file",$fileOptions['file']); - $this->checkFormData($stream,$boundary,"fileName",$fileOptions['fileName']); - UploadTest::assertNotContains("tags",$stream); - UploadTest::assertNotContains("isPrivateFile",$stream); - UploadTest::assertNotContains("useUniqueFileName",$stream); - UploadTest::assertNotContains("customCoordinates",$stream); - UploadTest::assertNotContains("responseFields",$stream); - - // Assert Method - $requestMethod = $container[0]['request']->getMethod(); - UploadTest::assertEquals($requestMethod,'POST'); - } - - /** - * - */ - public function testServerSideError() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - ]; - - $error = [ - "help" => "For support kindly contact us at support@imagekit.io .", - "message" => "Your account cannot be authenticated." - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $this->stubHttpClient(new Response(403, ['X-Foo' => 'Bar'], json_encode($error))); - - $response = $this->client->uploadFile($fileOptions); - - // Request Body Check - UploadTest::assertEquals(json_encode($error),json_encode($response->error)); - } - - /** - * - */ - public function testFileUploadWithInvalidTransformation() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "useUniqueFileName" => true, // true|false - "responseFields" => implode(",", ["tags", "customMetadata"]), // Comma Separated, check docs for more responseFields - 'transformation' => [], - ]; - - $error = [ - "message" => "Invalid transformation parameter. Please include at least pre, post, or both.", - "help" => "For support kindly contact us at support@imagekit.io ." - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $this->stubHttpClient(new Response(403, ['X-Foo' => 'Bar'], json_encode($error))); - - $response = $this->client->uploadFile($fileOptions); - - // Request Body Check - UploadTest::assertEquals(json_encode($error),json_encode($response->error)); - } - - /** - * - */ - public function testFileUploadWithInvalidPreTransformation() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "useUniqueFileName" => true, // true|false - "responseFields" => implode(",", ["tags", "customMetadata"]), // Comma Separated, check docs for more responseFields - 'transformation' => [ - 'pre' => '', - ], - ]; - - $error = [ - "message" => "Invalid pre transformation parameter.", - "help" => "For support kindly contact us at support@imagekit.io ." - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $this->stubHttpClient(new Response(403, ['X-Foo' => 'Bar'], json_encode($error))); - - $response = $this->client->uploadFile($fileOptions); - - // Request Body Check - UploadTest::assertEquals(json_encode($error),json_encode($response->error)); - } - - /** - * - */ - public function testFileUploadWithInvalidAbsTypePostTransformation() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "useUniqueFileName" => true, // true|false - "responseFields" => implode(",", ["tags", "customMetadata"]), // Comma Separated, check docs for more responseFields - 'transformation' => [ - 'post' => [ - [ - 'type' => 'abs', - 'value' => '' - ] - ] - ], - ]; - - $error = [ - "message" => "Invalid post transformation parameter.", - "help" => "For support kindly contact us at support@imagekit.io ." - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $this->stubHttpClient(new Response(403, ['X-Foo' => 'Bar'], json_encode($error))); - - $response = $this->client->uploadFile($fileOptions); - - // Request Body Check - UploadTest::assertEquals(json_encode($error),json_encode($response->error)); - } - - /** - * - */ - public function testFileUploadWithInvalidTransformationTypePostTransformation() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "useUniqueFileName" => true, // true|false - "responseFields" => implode(",", ["tags", "customMetadata"]), // Comma Separated, check docs for more responseFields - 'transformation' => [ - 'post' => [ - [ - 'type' => 'transformation', - 'value' => '' - ] - ] - ], - ]; - - $error = [ - "message" => "Invalid post transformation parameter.", - "help" => "For support kindly contact us at support@imagekit.io ." - ]; - - $mockBodyResponse = Utils::streamFor(json_encode($fileOptions)); - - $this->stubHttpClient(new Response(403, ['X-Foo' => 'Bar'], json_encode($error))); - - $response = $this->client->uploadFile($fileOptions); - - // Request Body Check - UploadTest::assertEquals(json_encode($error),json_encode($response->error)); - } - - - /** - * - */ - public function testFileUploadWithInvalidChecks() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "useUniqueFileName" => true, // true|false - "responseFields" => implode(",", ["tags", "customMetadata"]), // Comma Separated, check docs for more responseFields - 'checks' => true - ]; - - $error = [ - "message" => "The value provided for the checks parameter is invalid.", - "help" => "For support kindly contact us at support@imagekit.io ." - ]; - - $this->stubHttpClient(new Response(403, ['X-Foo' => 'Bar'], json_encode($error))); - - $response = $this->client->uploadFile($fileOptions); - - // Request Body Check - UploadTest::assertEquals(json_encode($error),json_encode($response->error)); - } - - public function testFileUploadWithInvalidPublishStatus() - { - $fileOptions = [ - 'file' => 'http://lorempixel.com/640/480/', - 'fileName' => 'test_file_name', - "useUniqueFileName" => true, // true|false - "responseFields" => implode(",", ["tags", "customMetadata"]), // Comma Separated, check docs for more responseFields - 'isPublished' => '' - ]; - - $error = [ - "message" => "isPublished must be boolean.", - "help" => "For support kindly contact us at support@imagekit.io ." - ]; - - $this->stubHttpClient(new Response(403, ['X-Foo' => 'Bar'], json_encode($error))); - - $response = $this->client->uploadFile($fileOptions); - - // Request Body Check - UploadTest::assertEquals(json_encode($error),json_encode($response->error)); - } - - protected function setUp() - { - $this->client = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - - } - - protected function tearDown() - { - $this->client = null; - } -} diff --git a/tests/ImageKit/Url/UrlTest.php b/tests/ImageKit/Url/UrlTest.php deleted file mode 100644 index 29f87739..00000000 --- a/tests/ImageKit/Url/UrlTest.php +++ /dev/null @@ -1,1283 +0,0 @@ -client = new ImageKit( - 'testing_public_key', - 'testing_private_key', - 'https://ik.imagekit.io/demo' - ); - } - - /** - * - */ - public function testUrlNoPathNoSrc() - { - $url = $this->client->url(); - UrlTest::assertEquals('URL Generation Method accepts an array, null passed', json_decode($url)->error->message); - } - - /** - * - */ - public function testUrlNoTransformationPath() - { - $url = $this->client->url(['path' => '/default-image.jpg']); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlNoTransformationSrc() - { - $url = $this->client->url(['src' => 'https://ik.imagekit.io/demo/default-image.jpg']); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlNullParametersWithPath() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => null, - 'transformationPosition' => null, - 'src' => null - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlSignedUrl() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'signed' => true - ]); - UrlTest::assertContains( - 'ik-s=', - $url - ); - } - - /** - * - */ - public function testUrlSignedUrlWithEmptyExpiryString() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'signed' => true, - 'expireSeconds' => '' - ]); - - UrlTest::assertContains( - 'ik-s=', - $url - ); - } - - /** - * - */ - public function testUrlSignedUrlWithInvalidExpiryString() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'signed' => true, - 'expireSeconds' => 'asdad' - ]); - UrlTest::assertEquals('expireSeconds accepts an integer value, non integer value provided.',json_decode($url)->error->message); - } - - /** - * - */ - public function testUrlSignedUrlWithoutExpiry() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'signed' => true - ]); - UrlTest::assertContains( - '?ik-s=', - $url - ); - } - - /** - * - */ - public function testUrlSignedUrlWithExpiryWithTransformation() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - "transformation" => [ - [ - "height" => "300", - ] - ], - 'signed' => true, - 'expireSeconds' => 300 - ]); - UrlTest::assertContains( - '?ik-t=', - $url - ); - UrlTest::assertContains( - '&ik-s=', - $url - ); - } - - /** - * - */ - public function testUrlSignedUrlWithExpiryWithQueryParameters() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - "queryParameters" => - [ - "key" => "value" - ], - 'signed' => true, - 'expireSeconds' => 300 - ]); - UrlTest::assertContains( - '&ik-t=', - $url - ); - UrlTest::assertContains( - '&ik-s=', - $url - ); - } - - /** - * - */ - public function testUrlSignedUrlWithExpiryWithTransformationWithQueryParameters() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - "queryParameters" => - [ - "key" => "value" - ], - "transformation" => [ - [ - "height" => "300", - ] - ], - 'signed' => true, - 'expireSeconds' => 300 - ]); - UrlTest::assertContains( - '&ik-t=', - $url - ); - UrlTest::assertContains( - '&ik-s=', - $url - ); - } - - /** - * - */ - public function testUrlSignedUrlWithoutExpiryWithTransformationWithQueryParameters() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - "queryParameters" => - [ - "key" => "value" - ], - "transformation" => [ - [ - "height" => "300", - ] - ], - 'signed' => true - ]); - UrlTest::assertNotContains( - '&ik-t=', - $url - ); - UrlTest::assertContains( - '&ik-s=', - $url - ); - } - - /** - * - */ - public function testUrlSignedUrlWithExpiry() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'signed' => true, - 'expireSeconds' => 100 - ]); - UrlTest::assertStringStartsWith( - 'https://ik.imagekit.io/demo/default-image.jpg', - $url - ); - UrlTest::assertContains( - 'ik-s=', - $url - ); - UrlTest::assertContains( - 'ik-t=', - $url - ); - } - - /** - * - */ - public function testUrlSignedWithDiacriticInFilename() - { - $url = 'https://ik.imagekit.io/demo/test_é_path_alt.jpg'; - $urlInstance = new Url(); - $encodedUrl = $urlInstance->encodeStringIfRequired($url); - UrlTest::assertEquals('https://ik.imagekit.io/demo/test_%C3%A9_path_alt.jpg', $encodedUrl); - - $opts = [ - 'privateKey' => 'testing_private_key', - 'url' => $url, - 'urlEndpoint' => 'https://ik.imagekit.io/demo', - 'expiryTimestamp' => '9999999999' - ]; - $signature = $urlInstance->getSignature($opts); - $url = $this->client->url([ - 'path' => '/test_é_path_alt.jpg', - 'signed' => true, - 'expireSeconds' => '' - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/test_é_path_alt.jpg?ik-s='. $signature, - $url - ); - } - - /** - * - */ - public function testUrlSignedWithDiacriticInFilenameAndPath() - { - $url = 'https://ik.imagekit.io/demo/aéb/test_é_path_alt.jpg'; - $urlInstance = new Url(); - $encodedUrl = $urlInstance->encodeStringIfRequired($url); - UrlTest::assertEquals('https://ik.imagekit.io/demo/a%C3%A9b/test_%C3%A9_path_alt.jpg', $encodedUrl); - - $opts = [ - 'privateKey' => 'testing_private_key', - 'url' => $url, - 'urlEndpoint' => 'https://ik.imagekit.io/demo', - 'expiryTimestamp' => '9999999999' - ]; - $signature = $urlInstance->getSignature($opts); - $url = $this->client->url([ - 'path' => '/aéb/test_é_path_alt.jpg', - 'signed' => true, - 'expireSeconds' => '' - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/aéb/test_é_path_alt.jpg?ik-s='. $signature, - $url - ); - } - - /** - * - */ - public function testUrlSignedWithDiacriticInFilenamePathTransforamtionInPath() - { - $url = 'https://ik.imagekit.io/demo/tr:l-text,i-Imagekité,fs-50,l-end/aéb/test_é_path_alt.jpg'; - $urlInstance = new Url(); - $encodedUrl = $urlInstance->encodeStringIfRequired($url); - UrlTest::assertEquals('https://ik.imagekit.io/demo/tr:l-text,i-Imagekit%C3%A9,fs-50,l-end/a%C3%A9b/test_%C3%A9_path_alt.jpg', $encodedUrl); - - $opts = [ - 'privateKey' => 'testing_private_key', - 'url' => $url, - 'urlEndpoint' => 'https://ik.imagekit.io/demo', - 'expiryTimestamp' => '9999999999' - ]; - $signature = $urlInstance->getSignature($opts); - $url = $this->client->url([ - 'path' => '/aéb/test_é_path_alt.jpg', - 'signed' => true, - "transformation" => [ - [ - "raw" => "l-text,i-Imagekité,fs-50,l-end" - ] - ], - "transformationPosition" => "path", - 'expireSeconds' => '' - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:l-text,i-Imagekité,fs-50,l-end/aéb/test_é_path_alt.jpg?ik-s='. $signature, - $url - ); - } - - /** - * - */ - public function testUrlSignedWithDiacriticInFilenamePathTransforamtionInQuery() - { - $url = 'https://ik.imagekit.io/demo/aéb/test_é_path_alt.jpg?tr=l-text,i-Imagekité,fs-50,l-end'; - $urlInstance = new Url(); - $encodedUrl = $urlInstance->encodeStringIfRequired($url); - UrlTest::assertEquals('https://ik.imagekit.io/demo/a%C3%A9b/test_%C3%A9_path_alt.jpg?tr=l-text,i-Imagekit%C3%A9,fs-50,l-end', $encodedUrl); - - $opts = [ - 'privateKey' => 'testing_private_key', - 'url' => $url, - 'urlEndpoint' => 'https://ik.imagekit.io/demo', - 'expiryTimestamp' => '9999999999' - ]; - $signature = $urlInstance->getSignature($opts); - $url = $this->client->url([ - 'path' => '/aéb/test_é_path_alt.jpg', - 'signed' => true, - "transformation" => [ - [ - "raw" => "l-text,i-Imagekité,fs-50,l-end" - ] - ], - "transformationPosition" => "query", - 'expireSeconds' => '' - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/aéb/test_é_path_alt.jpg?tr=l-text,i-Imagekité,fs-50,l-end&ik-s='. $signature, - $url - ); - } - - /** - * - */ - public function testUrlURLWithPath() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ] - ] - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlURLWithPathNoLeadingSlash() - { - $url = $this->client->url([ - 'path' => 'default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400/default-image.jpg', - $url - ); - } - - - /** - * - */ - public function testUrlURLWithPathMultipleLeadingSlash() - { - $url = $this->client->url([ - 'path' => '////default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ] - ] - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlURLOverrideUrlEndpoint() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/test/', - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ] - ] - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/test/tr:h-300,w-400/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlPathTransformationQuery() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformationPosition' => 'query', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/default-image.jpg?tr=h-300,w-400', - $url - ); - } - - /** - * - */ - public function testUrlSrcTransformation() - { - $url = $this->client->url([ - 'src' => 'https://ik.imagekit.io/demo/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlSrcTransformationQuery() - { - $url = $this->client->url([ - 'src' => 'https://ik.imagekit.io/demo/default-image.jpg', - 'transformationPosition' => 'query', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/default-image.jpg?tr=h-300,w-400', - $url - ); - } - - /** - * - */ - public function testUrlSrcMergeQueryParams() - { - $url = $this->client->url([ - 'src' => 'https://ik.imagekit.io/demo/default-image.jpg?t1=v1&t3=v3', - 'queryParameters' => ['t2' => 'v2'], - 'transformationPosition' => 'query', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/default-image.jpg?tr=h-300,w-400&t1=v1&t2=v2&t3=v3', - $url - ); - } - - /** - * - */ - public function testUrlPathMergeQueryParams() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'queryParameters' => ['t1' => 'v1', 't2' => 'v2', 't3' => 'v3'], - 'transformationPosition' => 'query', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/default-image.jpg?tr=h-300,w-400&t1=v1&t2=v2&t3=v3', - $url - ); - } - - /** - * - */ - public function testUrlChainedTransformation() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ], [ - 'rotate' => 90 - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400:rt-90/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlUndocumentedTransformation() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'undocumented' => 'param' - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:undocumented-param/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlChainedTransformationUndocumentedTransformation() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400 - ], [ - 'undocumented' => 'param' - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400:undocumented-param/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlOverLayImage() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400, - 'raw' => "l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end" - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlOverLayImageWithPath() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400, - 'raw' => "l-image,i-/path/to/overlay.jpg,w-100,b-10_CDDC39,l-end" - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400,l-image,i-/path/to/overlay.jpg,w-100,b-10_CDDC39,l-end/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlBorder() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400, - 'border' => '20_FF0000' - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400,b-20_FF0000/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlESharpen() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400, - 'e-sharpen' => '-', - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400,e-sharpen/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlRaw() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'raw' => 'h-300,w-400' - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400/default-image.jpg', - $url - ); - } - - - /** - * - */ - public function testUrlAllCombined() - { - $url = $this->client->url([ - 'path' => '/default-image.jpg', - 'transformation' => [ - [ - 'height' => 300, - 'width' => 400, - 'aspectRatio' => '4-3', - 'quality' => 40, - 'crop' => 'force', - 'cropMode' => 'extract', - 'focus' => 'left', - 'format' => 'jpeg', - 'radius' => 50, - 'bg' => 'A94D34', - 'border' => '5-A94D34', - 'rotation' => 90, - 'blur' => 10, - 'named' => 'some_name', - 'progressive' => true, - 'lossless' => true, - 'trim' => 5, - 'metadata' => true, - 'colorProfile' => true, - 'defaultImage' => 'folder/file.jpg/', //trailing slash case - 'dpr' => 3, - 'effectSharpen' => 10, - 'effectUSM' => '2-2-0.8-0.024', - 'effectContrast' => true, - 'effectGray' => true, - 'effectShadow' => 'bl-15_st-40_x-10_y-N5', - 'effectGradient' => 'from-red_to-white', - 'original' => true, - 'raw' => 'h-500,w-450' - ] - ] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,e-shadow-bl-15_st-40_x-10_y-N5,e-gradient-from-red_to-white,orig-true,h-500,w-450/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testUrlGenerationIfTransformationPositionIsPath() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'queryParameters' => ['v' => '123123'] - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:w-200,h-300:rt-90/path/to/my/image.jpg?v=123123', - $url - ); - } - - /** - * - */ - public function testUrlGenerationCustomDomain() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://images.example.com', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'queryParameters' => ['v' => '123123'] - ]); - - UrlTest::assertEquals( - 'https://images.example.com/tr:w-200,h-300:rt-90/path/to/my/image.jpg?v=123123', - $url - ); - } - - /** - * - */ - public function testUrlGenerationIfTransformationPositionIsQuery() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300']], - 'queryParameters' => ['v' => '123123'], - 'transformationPosition' => 'query', - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/path/to/my/image.jpg?tr=w-200,h-300&v=123123', - $url - ); - } - - /** - * - */ - public function testUrlGenerationIfPathAndSrcEmpty() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => '', - 'src' => '', - 'transformationPosition' => 'path', - 'transformation' => [['width' => '200', 'height' => '300']], - 'queryParameters' => ['v' => '123123'], - 'signed' => true, - 'expireSeconds' => 300, - ]); - - UrlTest::assertEquals('src is not a valid URL', json_decode($url)->error->message); - - } - - /** - * - */ - public function testUrlGenerationIfUrlEmptyEmpty() - { - $url = $this->client->url([ - 'urlEndpoint' => '', - 'transformationPosition' => 'path', - 'transformation' => [['width' => '200', 'height' => '300']], - 'queryParameters' => ['v' => '123123'], - 'signed' => true, - 'expireSeconds' => 300, - ]); - - UrlTest::assertEquals('Invalid urlEndpoint value', json_decode($url)->error->message); - - } - - /** - * - */ - public function testUrlGenerationUsingFullImageUrlWhenPassedSrc() - { - $url = $this->client->url([ - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'src' => 'https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg', - 'queryParameters' => ['v' => '123123'], - 'expireSeconds' => 300, - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/your_imagekit_id/endpoint/tr:w-200,h-300:rt-90/default-image.jpg?v=123123', - $url - ); - } - - /** - * - */ - public function testUrlGenerationUsingFullImageUrlWhenPassedSrcWithQueryParameters() - { - - $url = $this->client->url([ - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'src' => 'https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg', - 'queryParameters' => ['test' => 'params', 'test2' => 'param2'], - 'expireSeconds' => 300, - ]); - - // UrlTest::assertNotRegExp('/??/', $url); - // UrlTest::assertNotRegExp('/&&/', $url); - UrlTest::assertEquals( - 'https://ik.imagekit.io/your_imagekit_id/endpoint/tr:w-200,h-300:rt-90/default-image.jpg?test=params&test2=param2', - $url - ); - } - - /** - * - */ - public function testUrlGenerationUsingFullImageUrlWhenPassedSrcWithQueryParametersAndTransforamtionPositionIsPath() - { - $url = $this->client->url([ - 'src' => 'https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg', - 'transformationPosition' => 'path', - 'expireSeconds' => 300, - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg', - $url - ); - } - - /** - * - */ - public function testSignedUrlGeneration() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'transformationPosition' => 'path', - 'queryParameters' => ['v' => '123123'], - 'signed' => true, - 'expireSeconds' => 300, - ]); - - $url_components = parse_url($url); - parse_str($url_components['query'], $params); - - UrlTest::assertNotEmpty($params['ik-s']); - UrlTest::assertNotEmpty($params['ik-t']); - } - - /** - * - */ - public function testUrlGenerationIfInitializationUrlEndpointIsOverriddenByNewUrlEndpoint() - { - - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'transformationPosition' => 'path', - 'queryParameters' => ['v' => '123123'], - 'expireSeconds' => 300, - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:w-200,h-300:rt-90/path/to/my/image.jpg?v=123123', - $url - ); - } - - /** - * - */ - public function testUrlGenerationIfPresenceOfTrailingSlashInUrlEndpointWillGenerateValidUrl() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern/', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'transformationPosition' => 'path', - 'queryParameters' => ['v' => '123123'], - 'expireSeconds' => 300, - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:w-200,h-300:rt-90/path/to/my/image.jpg?v=123123', - $url - ); - } - - /** - * - */ - public function testUrlGenerationIfPresenceOfLeadingSlashInPathWillGenerateValidUrl() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => '/path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'transformationPosition' => 'path', - 'queryParameters' => ['v' => '123123'], - 'expireSeconds' => 300, - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:w-200,h-300:rt-90/path/to/my/image.jpg?v=123123', - $url - ); - } - - /** - * - */ - public function testUrlGenerationIfNewTransformationParameterIsPassedWillBePresentInGeneratedUrl() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90'], ['test' => 'param']], - 'transformationPosition' => 'path', - 'queryParameters' => ['v' => '123123'], - 'expireSeconds' => 300, - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:w-200,h-300:rt-90:test-param/path/to/my/image.jpg?v=123123', - $url - ); - } - - // /** - // * - // */ - // public function testUrlGenerationIfGeneratedUrlContainsSDKVersion() - // { - // $url = $this->client->url([ - // 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - // 'transformation' => [['width' => '200', 'height' => '300']], - // 'path' => 'path/to/my/image.jpg', - // 'transformationPosition' => 'query', - // 'queryParameters' => ['v' => '123123'], - // 'expireSeconds' => 300, - // ]); - - // $url_components = parse_url($url); - // parse_str($url_components['query'], $params); - - // UrlTest::assertNotEmpty($params['ik-sdk-version']); - // UrlTest::assertEquals('php-', $params['ik-sdk-version']); - // } - - /** - * - */ - public function testUrlGenerationIfTransformationPositionIsQueryAndTransformationArePresentInUrlAsQueryParams() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'transformation' => [['width' => '200', 'height' => '300']], - 'path' => 'path/to/my/image.jpg', - 'transformationPosition' => 'query', - 'queryParameters' => ['v' => '123123'], - 'expireSeconds' => 300, - ]); - - $url_components = parse_url($url); - parse_str($url_components['query'], $params); - - UrlTest::assertNotEmpty($params['tr']); - UrlTest::assertEquals('w-200,h-300', $params['tr']); - } - - /** - * - */ - public function testUrlGenerationWithChainedTransformationIfTransformationPositionIsPath() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'transformationPosition' => 'path', - 'queryParameters' => ['v' => '123123'], - 'expireSeconds' => 300, - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:w-200,h-300:rt-90/path/to/my/image.jpg?v=123123', - $url - ); - } - - /** - * - */ - public function testUrlGenerationWithChainedTransformationIfTransformationPositionIsQuery() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'transformationPosition' => 'query', - 'queryParameters' => ['v' => '123123'], - 'expireSeconds' => 300, - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/path/to/my/image.jpg?tr=w-200,h-300:rt-90&v=123123', - $url - ); - } - - /** - * - */ - public function testUrlGenerationWithQueryParametersIfTransformationPositionIsPath() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'transformationPosition' => 'path', - 'queryParameters' => ['test' => 'param'], - 'expireSeconds' => 300, - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:w-200,h-300:rt-90/path/to/my/image.jpg?test=param', - $url - ); - } - - /** - * - */ - public function testUrlGenerationWithQueryParametersIfTransformationPositionIsQuery() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['width' => '200', 'height' => '300'], ['rotation' => '90']], - 'transformationPosition' => 'query', - 'queryParameters' => ['test' => 'param'], - 'expireSeconds' => 300, - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/path/to/my/image.jpg?tr=w-200,h-300:rt-90&test=param', - $url - ); - } - - // /** - // * - // */ - // public function testUrlGenerationWithDefaultExpiredSeconds() - // { - // $url = $this->client->url([ - // 'path' => '/test-signed-url.png', - // 'transformation' => [['width' => '100']], - // 'signed' => true, - // ]); - - // $url_components = parse_url($url); - // parse_str($url_components['query'], $params); - - // UrlTest::assertStringNotContainsString('?&', $url); - // UrlTest::assertNotEmpty($params['ik-s']); - // } - - /** - * - */ - public function testUrlGenerationWithCustomExpiredSeconds() - { - $url = $this->client->url([ - 'path' => '/test-signed-url.png', - 'transformation' => [['width' => '100']], - 'signed' => true, - 'expireSeconds' => 300 - ]); - - $url_components = parse_url($url); - parse_str($url_components['query'], $params); - - // UrlTest::assertNotRegExp('/?&/', $url); - UrlTest::assertNotEmpty($params['ik-t']); - } - - /** - * - */ - public function testTransformationWithoutValueShouldNotHaveHypen() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['orig' => '']], - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:orig/path/to/my/image.jpg', - $url - ); - } - - /** - * - */ - public function testTransformationValueShouldBeConvertedToString() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['rt' => 90, 'orig' => true]], - ]); - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:rt-90,orig-true/path/to/my/image.jpg', - $url - ); - } - - /** - * - */ - public function testTransformationNonMappedSupportedTransform() - { - $url = $this->client->url([ - 'urlEndpoint' => 'https://ik.imagekit.io/demo/pattern', - 'path' => 'path/to/my/image.jpg', - 'transformation' => [['not_mapped' => 'value', '' => '']], - ]); - - UrlTest::assertEquals( - 'https://ik.imagekit.io/demo/pattern/tr:not_mapped-value/path/to/my/image.jpg', - $url - ); - } - - /** - * - */ - public function testUnitTestGeneratedSignature() - { - $opts = [ - 'privateKey' => 'private_key_test', - 'url' => 'https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png', - 'urlEndpoint' => 'https://test-domain.com/test-endpoint', - 'expiryTimestamp' => '9999999999' - ]; - - $urlInstance = new Url(); - $signature = $urlInstance->getSignature($opts); - - UrlTest::assertEquals('41b3075c40bc84147eb71b8b49ae7fbf349d0f00', $signature); - } - -} diff --git a/tests/Services/Accounts/OriginsTest.php b/tests/Services/Accounts/OriginsTest.php new file mode 100644 index 00000000..6f927c36 --- /dev/null +++ b/tests/Services/Accounts/OriginsTest.php @@ -0,0 +1,202 @@ +client = $client; + } + + #[Test] + public function testCreate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->origins->create( + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'gcs-media', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + endpoint: 'https://s3.eu-central-1.wasabisys.com', + baseURL: 'https://akeneo.company.com', + clientEmail: 'service-account@project.iam.gserviceaccount.com', + privateKey: '-----BEGIN PRIVATE KEY-----\nMIIEv...', + accountName: 'account123', + container: 'images', + sasToken: '?sv=2023-01-03&sr=c&sig=abc123', + clientID: 'akeneo-client-id', + clientSecret: 'akeneo-client-secret', + password: 'strongpassword123', + username: 'integration-user', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertNotNull($result); + } + + #[Test] + public function testCreateWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->origins->create( + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'gcs-media', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'AKENEO_PIM', + baseURLForCanonicalHeader: 'https://cdn.example.com', + includeCanonicalHeader: false, + prefix: 'uploads', + endpoint: 'https://s3.eu-central-1.wasabisys.com', + s3ForcePathStyle: true, + baseURL: 'https://akeneo.company.com', + forwardHostHeaderToOrigin: false, + clientEmail: 'service-account@project.iam.gserviceaccount.com', + privateKey: '-----BEGIN PRIVATE KEY-----\nMIIEv...', + accountName: 'account123', + container: 'images', + sasToken: '?sv=2023-01-03&sr=c&sig=abc123', + clientID: 'akeneo-client-id', + clientSecret: 'akeneo-client-secret', + password: 'strongpassword123', + username: 'integration-user', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertNotNull($result); + } + + #[Test] + public function testUpdate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->origins->update( + 'id', + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'gcs-media', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + endpoint: 'https://s3.eu-central-1.wasabisys.com', + baseURL: 'https://akeneo.company.com', + clientEmail: 'service-account@project.iam.gserviceaccount.com', + privateKey: '-----BEGIN PRIVATE KEY-----\nMIIEv...', + accountName: 'account123', + container: 'images', + sasToken: '?sv=2023-01-03&sr=c&sig=abc123', + clientID: 'akeneo-client-id', + clientSecret: 'akeneo-client-secret', + password: 'strongpassword123', + username: 'integration-user', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertNotNull($result); + } + + #[Test] + public function testUpdateWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->origins->update( + 'id', + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'gcs-media', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'AKENEO_PIM', + baseURLForCanonicalHeader: 'https://cdn.example.com', + includeCanonicalHeader: false, + prefix: 'uploads', + endpoint: 'https://s3.eu-central-1.wasabisys.com', + s3ForcePathStyle: true, + baseURL: 'https://akeneo.company.com', + forwardHostHeaderToOrigin: false, + clientEmail: 'service-account@project.iam.gserviceaccount.com', + privateKey: '-----BEGIN PRIVATE KEY-----\nMIIEv...', + accountName: 'account123', + container: 'images', + sasToken: '?sv=2023-01-03&sr=c&sig=abc123', + clientID: 'akeneo-client-id', + clientSecret: 'akeneo-client-secret', + password: 'strongpassword123', + username: 'integration-user', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertNotNull($result); + } + + #[Test] + public function testList(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->origins->list(); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertIsList($result); + } + + #[Test] + public function testDelete(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->origins->delete('id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertNull($result); + } + + #[Test] + public function testGet(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->origins->get('id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertNotNull($result); + } +} diff --git a/tests/Services/Accounts/URLEndpointsTest.php b/tests/Services/Accounts/URLEndpointsTest.php new file mode 100644 index 00000000..fff8bc16 --- /dev/null +++ b/tests/Services/Accounts/URLEndpointsTest.php @@ -0,0 +1,145 @@ +client = $client; + } + + #[Test] + public function testCreate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->urlEndpoints->create( + description: 'My custom URL endpoint' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(URLEndpointResponse::class, $result); + } + + #[Test] + public function testCreateWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->urlEndpoints->create( + description: 'My custom URL endpoint', + origins: ['origin-id-1'], + urlPrefix: 'product-images', + urlRewriter: [ + 'type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true, + ], + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(URLEndpointResponse::class, $result); + } + + #[Test] + public function testUpdate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->urlEndpoints->update( + 'id', + description: 'My custom URL endpoint' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(URLEndpointResponse::class, $result); + } + + #[Test] + public function testUpdateWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->urlEndpoints->update( + 'id', + description: 'My custom URL endpoint', + origins: ['origin-id-1'], + urlPrefix: 'product-images', + urlRewriter: [ + 'type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true, + ], + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(URLEndpointResponse::class, $result); + } + + #[Test] + public function testList(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->urlEndpoints->list(); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertIsList($result); + } + + #[Test] + public function testDelete(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->urlEndpoints->delete('id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertNull($result); + } + + #[Test] + public function testGet(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->urlEndpoints->get('id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(URLEndpointResponse::class, $result); + } +} diff --git a/tests/Services/Accounts/UsageTest.php b/tests/Services/Accounts/UsageTest.php new file mode 100644 index 00000000..a1bd0096 --- /dev/null +++ b/tests/Services/Accounts/UsageTest.php @@ -0,0 +1,66 @@ +client = $client; + } + + #[Test] + public function testGet(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->usage->get( + endDate: '2019-12-27', + startDate: '2019-12-27' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(UsageGetResponse::class, $result); + } + + #[Test] + public function testGetWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->accounts->usage->get( + endDate: '2019-12-27', + startDate: '2019-12-27' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(UsageGetResponse::class, $result); + } +} diff --git a/tests/Services/AssetsTest.php b/tests/Services/AssetsTest.php new file mode 100644 index 00000000..f3e729d3 --- /dev/null +++ b/tests/Services/AssetsTest.php @@ -0,0 +1,46 @@ +client = $client; + } + + #[Test] + public function testList(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->assets->list(); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertIsList($result); + } +} diff --git a/tests/Services/Beta/V2/FilesTest.php b/tests/Services/Beta/V2/FilesTest.php new file mode 100644 index 00000000..a5da04d6 --- /dev/null +++ b/tests/Services/Beta/V2/FilesTest.php @@ -0,0 +1,152 @@ +client = $client; + } + + #[Test] + public function testUpload(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->beta->v2->files->upload( + file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)), + fileName: 'fileName', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileUploadResponse::class, $result); + } + + #[Test] + public function testUploadWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->beta->v2->files->upload( + file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)), + fileName: 'fileName', + token: 'token', + checks: "\"request.folder\" : \"marketing/\"\n", + customCoordinates: 'customCoordinates', + customMetadata: ['brand' => 'bar', 'color' => 'bar'], + description: 'Running shoes', + extensions: [ + [ + 'name' => 'remove-bg', + 'options' => [ + 'addShadow' => true, + 'bgColor' => 'bg_color', + 'bgImageURL' => 'bg_image_url', + 'semitransparency' => true, + ], + ], + [ + 'maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging', + ], + ['name' => 'ai-auto-description'], + [ + 'name' => 'ai-tasks', + 'tasks' => [ + [ + 'instruction' => 'What types of clothing items are visible in this image?', + 'type' => 'select_tags', + 'maxSelections' => 1, + 'minSelections' => 0, + 'vocabulary' => [ + 'shirt', 'tshirt', 'dress', 'trousers', 'jacket', + ], + ], + [ + 'instruction' => 'Is this a luxury or high-end fashion item?', + 'type' => 'yes_no', + 'onNo' => [ + 'addTags' => ['luxury', 'premium'], + 'removeTags' => ['budget', 'affordable'], + 'setMetadata' => [ + ['field' => 'price_range', 'value' => 'premium'], + ], + 'unsetMetadata' => [['field' => 'price_range']], + ], + 'onUnknown' => [ + 'addTags' => ['luxury', 'premium'], + 'removeTags' => ['budget', 'affordable'], + 'setMetadata' => [ + ['field' => 'price_range', 'value' => 'premium'], + ], + 'unsetMetadata' => [['field' => 'price_range']], + ], + 'onYes' => [ + 'addTags' => ['luxury', 'premium'], + 'removeTags' => ['budget', 'affordable'], + 'setMetadata' => [ + ['field' => 'price_range', 'value' => 'premium'], + ], + 'unsetMetadata' => [['field' => 'price_range']], + ], + ], + ], + ], + ['id' => 'ext_abc123', 'name' => 'saved-extension'], + ], + folder: 'folder', + isPrivateFile: true, + isPublished: true, + overwriteAITags: true, + overwriteCustomMetadata: true, + overwriteFile: true, + overwriteTags: true, + responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], + tags: ['t-shirt', 'round-neck', 'men'], + transformation: [ + 'post' => [ + ['type' => 'thumbnail', 'value' => 'w-150,h-150'], + [ + 'protocol' => 'dash', + 'type' => 'abs', + 'value' => 'sr-240_360_480_720_1080', + ], + ], + 'pre' => 'w-300,h-300,q-80', + ], + useUniqueFileName: true, + webhookURL: 'https://example.com', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileUploadResponse::class, $result); + } +} diff --git a/tests/Services/Cache/InvalidationTest.php b/tests/Services/Cache/InvalidationTest.php new file mode 100644 index 00000000..9744391a --- /dev/null +++ b/tests/Services/Cache/InvalidationTest.php @@ -0,0 +1,78 @@ +client = $client; + } + + #[Test] + public function testCreate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->cache->invalidation->create( + url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(InvalidationNewResponse::class, $result); + } + + #[Test] + public function testCreateWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->cache->invalidation->create( + url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(InvalidationNewResponse::class, $result); + } + + #[Test] + public function testGet(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->cache->invalidation->get('requestId'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(InvalidationGetResponse::class, $result); + } +} diff --git a/tests/Services/CustomMetadataFieldsTest.php b/tests/Services/CustomMetadataFieldsTest.php new file mode 100644 index 00000000..fe677646 --- /dev/null +++ b/tests/Services/CustomMetadataFieldsTest.php @@ -0,0 +1,117 @@ +client = $client; + } + + #[Test] + public function testCreate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->customMetadataFields->create( + label: 'price', + name: 'price', + schema: ['type' => 'Number'] + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(CustomMetadataField::class, $result); + } + + #[Test] + public function testCreateWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->customMetadataFields->create( + label: 'price', + name: 'price', + schema: [ + 'type' => 'Number', + 'defaultValue' => [true, 10, 'Hello'], + 'isValueRequired' => true, + 'maxLength' => 0, + 'maxValue' => 3000, + 'minLength' => 0, + 'minValue' => 1000, + 'selectOptions' => ['small', 'medium', 'large', 30, 40, true], + ], + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(CustomMetadataField::class, $result); + } + + #[Test] + public function testUpdate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->customMetadataFields->update('id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(CustomMetadataField::class, $result); + } + + #[Test] + public function testList(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->customMetadataFields->list(); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertIsList($result); + } + + #[Test] + public function testDelete(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->customMetadataFields->delete('id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(CustomMetadataFieldDeleteResponse::class, $result); + } +} diff --git a/tests/Services/Files/BulkTest.php b/tests/Services/Files/BulkTest.php new file mode 100644 index 00000000..e20e6c31 --- /dev/null +++ b/tests/Services/Files/BulkTest.php @@ -0,0 +1,163 @@ +client = $client; + } + + #[Test] + public function testDelete(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->bulk->delete( + fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(BulkDeleteResponse::class, $result); + } + + #[Test] + public function testDeleteWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->bulk->delete( + fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(BulkDeleteResponse::class, $result); + } + + #[Test] + public function testAddTags(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->bulk->addTags( + fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + tags: ['t-shirt', 'round-neck', 'sale2019'], + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(BulkAddTagsResponse::class, $result); + } + + #[Test] + public function testAddTagsWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->bulk->addTags( + fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + tags: ['t-shirt', 'round-neck', 'sale2019'], + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(BulkAddTagsResponse::class, $result); + } + + #[Test] + public function testRemoveAITags(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->bulk->removeAITags( + aiTags: ['t-shirt', 'round-neck', 'sale2019'], + fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(BulkRemoveAITagsResponse::class, $result); + } + + #[Test] + public function testRemoveAITagsWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->bulk->removeAITags( + aiTags: ['t-shirt', 'round-neck', 'sale2019'], + fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(BulkRemoveAITagsResponse::class, $result); + } + + #[Test] + public function testRemoveTags(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->bulk->removeTags( + fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + tags: ['t-shirt', 'round-neck', 'sale2019'], + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(BulkRemoveTagsResponse::class, $result); + } + + #[Test] + public function testRemoveTagsWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->bulk->removeTags( + fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + tags: ['t-shirt', 'round-neck', 'sale2019'], + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(BulkRemoveTagsResponse::class, $result); + } +} diff --git a/tests/Services/Files/MetadataTest.php b/tests/Services/Files/MetadataTest.php new file mode 100644 index 00000000..5216a3ca --- /dev/null +++ b/tests/Services/Files/MetadataTest.php @@ -0,0 +1,77 @@ +client = $client; + } + + #[Test] + public function testGet(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->metadata->get('fileId'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(Metadata::class, $result); + } + + #[Test] + public function testGetFromURL(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->metadata->getFromURL( + url: 'https://example.com' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(Metadata::class, $result); + } + + #[Test] + public function testGetFromURLWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->metadata->getFromURL( + url: 'https://example.com' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(Metadata::class, $result); + } +} diff --git a/tests/Services/Files/VersionsTest.php b/tests/Services/Files/VersionsTest.php new file mode 100644 index 00000000..7f5ffd52 --- /dev/null +++ b/tests/Services/Files/VersionsTest.php @@ -0,0 +1,144 @@ +client = $client; + } + + #[Test] + public function testList(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->versions->list('fileId'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertIsList($result); + } + + #[Test] + public function testDelete(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->versions->delete( + 'versionId', + fileID: 'fileId' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(VersionDeleteResponse::class, $result); + } + + #[Test] + public function testDeleteWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->versions->delete( + 'versionId', + fileID: 'fileId' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(VersionDeleteResponse::class, $result); + } + + #[Test] + public function testGet(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->versions->get( + 'versionId', + fileID: 'fileId' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(File::class, $result); + } + + #[Test] + public function testGetWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->versions->get( + 'versionId', + fileID: 'fileId' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(File::class, $result); + } + + #[Test] + public function testRestore(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->versions->restore( + 'versionId', + fileID: 'fileId' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(File::class, $result); + } + + #[Test] + public function testRestoreWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->versions->restore( + 'versionId', + fileID: 'fileId' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(File::class, $result); + } +} diff --git a/tests/Services/FilesTest.php b/tests/Services/FilesTest.php new file mode 100644 index 00000000..e1c920d2 --- /dev/null +++ b/tests/Services/FilesTest.php @@ -0,0 +1,297 @@ +client = $client; + } + + #[Test] + public function testUpdate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->update('fileId'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileUpdateResponse::class, $result); + } + + #[Test] + public function testDelete(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->delete('fileId'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertNull($result); + } + + #[Test] + public function testCopy(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->copy( + destinationPath: '/folder/to/copy/into/', + sourceFilePath: '/path/to/file.jpg', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileCopyResponse::class, $result); + } + + #[Test] + public function testCopyWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->copy( + destinationPath: '/folder/to/copy/into/', + sourceFilePath: '/path/to/file.jpg', + includeFileVersions: false, + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileCopyResponse::class, $result); + } + + #[Test] + public function testGet(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->get('fileId'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(File::class, $result); + } + + #[Test] + public function testMove(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->move( + destinationPath: '/folder/to/move/into/', + sourceFilePath: '/path/to/file.jpg', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileMoveResponse::class, $result); + } + + #[Test] + public function testMoveWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->move( + destinationPath: '/folder/to/move/into/', + sourceFilePath: '/path/to/file.jpg', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileMoveResponse::class, $result); + } + + #[Test] + public function testRename(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->rename( + filePath: '/path/to/file.jpg', + newFileName: 'newFileName.jpg' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileRenameResponse::class, $result); + } + + #[Test] + public function testRenameWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->rename( + filePath: '/path/to/file.jpg', + newFileName: 'newFileName.jpg', + purgeCache: true, + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileRenameResponse::class, $result); + } + + #[Test] + public function testUpload(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->upload( + file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)), + fileName: 'fileName', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileUploadResponse::class, $result); + } + + #[Test] + public function testUploadWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->files->upload( + file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)), + fileName: 'fileName', + token: 'token', + checks: "\"request.folder\" : \"marketing/\"\n", + customCoordinates: 'customCoordinates', + customMetadata: ['brand' => 'bar', 'color' => 'bar'], + description: 'Running shoes', + expire: 0, + extensions: [ + [ + 'name' => 'remove-bg', + 'options' => [ + 'addShadow' => true, + 'bgColor' => 'bg_color', + 'bgImageURL' => 'bg_image_url', + 'semitransparency' => true, + ], + ], + [ + 'maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging', + ], + ['name' => 'ai-auto-description'], + [ + 'name' => 'ai-tasks', + 'tasks' => [ + [ + 'instruction' => 'What types of clothing items are visible in this image?', + 'type' => 'select_tags', + 'maxSelections' => 1, + 'minSelections' => 0, + 'vocabulary' => [ + 'shirt', 'tshirt', 'dress', 'trousers', 'jacket', + ], + ], + [ + 'instruction' => 'Is this a luxury or high-end fashion item?', + 'type' => 'yes_no', + 'onNo' => [ + 'addTags' => ['luxury', 'premium'], + 'removeTags' => ['budget', 'affordable'], + 'setMetadata' => [ + ['field' => 'price_range', 'value' => 'premium'], + ], + 'unsetMetadata' => [['field' => 'price_range']], + ], + 'onUnknown' => [ + 'addTags' => ['luxury', 'premium'], + 'removeTags' => ['budget', 'affordable'], + 'setMetadata' => [ + ['field' => 'price_range', 'value' => 'premium'], + ], + 'unsetMetadata' => [['field' => 'price_range']], + ], + 'onYes' => [ + 'addTags' => ['luxury', 'premium'], + 'removeTags' => ['budget', 'affordable'], + 'setMetadata' => [ + ['field' => 'price_range', 'value' => 'premium'], + ], + 'unsetMetadata' => [['field' => 'price_range']], + ], + ], + ], + ], + ['id' => 'ext_abc123', 'name' => 'saved-extension'], + ], + folder: 'folder', + isPrivateFile: true, + isPublished: true, + overwriteAITags: true, + overwriteCustomMetadata: true, + overwriteFile: true, + overwriteTags: true, + publicKey: 'publicKey', + responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], + signature: 'signature', + tags: ['t-shirt', 'round-neck', 'men'], + transformation: [ + 'post' => [ + ['type' => 'thumbnail', 'value' => 'w-150,h-150'], + [ + 'protocol' => 'dash', + 'type' => 'abs', + 'value' => 'sr-240_360_480_720_1080', + ], + ], + 'pre' => 'w-300,h-300,q-80', + ], + useUniqueFileName: true, + webhookURL: 'https://example.com', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FileUploadResponse::class, $result); + } +} diff --git a/tests/Services/Folders/JobTest.php b/tests/Services/Folders/JobTest.php new file mode 100644 index 00000000..7a1a5870 --- /dev/null +++ b/tests/Services/Folders/JobTest.php @@ -0,0 +1,47 @@ +client = $client; + } + + #[Test] + public function testGet(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->job->get('jobId'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(JobGetResponse::class, $result); + } +} diff --git a/tests/Services/FoldersTest.php b/tests/Services/FoldersTest.php new file mode 100644 index 00000000..2aa44b02 --- /dev/null +++ b/tests/Services/FoldersTest.php @@ -0,0 +1,194 @@ +client = $client; + } + + #[Test] + public function testCreate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->create( + folderName: 'summer', + parentFolderPath: '/product/images/' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderNewResponse::class, $result); + } + + #[Test] + public function testCreateWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->create( + folderName: 'summer', + parentFolderPath: '/product/images/' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderNewResponse::class, $result); + } + + #[Test] + public function testDelete(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->delete(folderPath: '/folder/to/delete/'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderDeleteResponse::class, $result); + } + + #[Test] + public function testDeleteWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->delete(folderPath: '/folder/to/delete/'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderDeleteResponse::class, $result); + } + + #[Test] + public function testCopy(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->copy( + destinationPath: '/path/of/destination/folder', + sourceFolderPath: '/path/of/source/folder', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderCopyResponse::class, $result); + } + + #[Test] + public function testCopyWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->copy( + destinationPath: '/path/of/destination/folder', + sourceFolderPath: '/path/of/source/folder', + includeVersions: true, + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderCopyResponse::class, $result); + } + + #[Test] + public function testMove(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->move( + destinationPath: '/path/of/destination/folder', + sourceFolderPath: '/path/of/source/folder', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderMoveResponse::class, $result); + } + + #[Test] + public function testMoveWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->move( + destinationPath: '/path/of/destination/folder', + sourceFolderPath: '/path/of/source/folder', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderMoveResponse::class, $result); + } + + #[Test] + public function testRename(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->rename( + folderPath: '/path/of/folder', + newFolderName: 'new-folder-name' + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderRenameResponse::class, $result); + } + + #[Test] + public function testRenameWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->folders->rename( + folderPath: '/path/of/folder', + newFolderName: 'new-folder-name', + purgeCache: true, + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(FolderRenameResponse::class, $result); + } +} diff --git a/tests/Services/SavedExtensionsTest.php b/tests/Services/SavedExtensionsTest.php new file mode 100644 index 00000000..f3cf8d70 --- /dev/null +++ b/tests/Services/SavedExtensionsTest.php @@ -0,0 +1,128 @@ +client = $client; + } + + #[Test] + public function testCreate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->savedExtensions->create( + config: ['name' => 'remove-bg'], + description: 'Analyzes vehicle images for type, condition, and quality assessment', + name: 'Car Quality Analysis', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(SavedExtension::class, $result); + } + + #[Test] + public function testCreateWithOptionalParams(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->savedExtensions->create( + config: [ + 'name' => 'remove-bg', + 'options' => [ + 'addShadow' => true, + 'bgColor' => 'bg_color', + 'bgImageURL' => 'bg_image_url', + 'semitransparency' => true, + ], + ], + description: 'Analyzes vehicle images for type, condition, and quality assessment', + name: 'Car Quality Analysis', + ); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(SavedExtension::class, $result); + } + + #[Test] + public function testUpdate(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->savedExtensions->update('id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(SavedExtension::class, $result); + } + + #[Test] + public function testList(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->savedExtensions->list(); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertIsList($result); + } + + #[Test] + public function testDelete(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->savedExtensions->delete('id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertNull($result); + } + + #[Test] + public function testGet(): void + { + if (UnsupportedMockTests::$skip) { + $this->markTestSkipped('Mock server tests are disabled'); + } + + $result = $this->client->savedExtensions->get('id'); + + // @phpstan-ignore-next-line method.alreadyNarrowedType + $this->assertInstanceOf(SavedExtension::class, $result); + } +} diff --git a/tests/Services/WebhooksTest.php b/tests/Services/WebhooksTest.php new file mode 100644 index 00000000..d9458597 --- /dev/null +++ b/tests/Services/WebhooksTest.php @@ -0,0 +1,176 @@ +client = $client; + } + + #[Test] + public function testUnsafeUnwrap(): void + { + $payload = '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; + $this->client->webhooks->unsafeUnwrap($payload); + // unwrap successful if not error thrown, increment assertion count to avoid risky test warning + $this->addToAssertionCount(1); + } + + #[Test] + public function testUnsafeUnwrapBadJson(): void + { + $this->expectException(WebhookException::class); + + $badPayload = 'not a json string'; + $this->client->webhooks->unsafeUnwrap($badPayload); + } + + #[Test] + public function testUnwrap(): void + { + $payload = '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; + $this->client->webhooks->unwrap($payload); + // unwrap successful if not error thrown, increment assertion count to avoid risky test warning + $this->addToAssertionCount(1); + } + + #[Test] + public function testUnwrapBadJson(): void + { + $this->expectException(WebhookException::class); + + $badPayload = 'not a json string'; + $this->client->webhooks->unwrap($badPayload); + } + + #[Test] + public function testUnwrapWithVerification(): void + { + $payload = '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; + $secret = 'whsec_c2VjcmV0Cg=='; + $webhook = new Webhook($secret); + $messageId = '1'; + $timestamp = time(); + $signature = $webhook->sign($messageId, $timestamp, $payload); + + /** @var array> $headers */ + $headers = [ + 'webhook-signature' => [$signature], + 'webhook-id' => [$messageId], + 'webhook-timestamp' => [(string) $timestamp], + ]; + $this->client->webhooks->unwrap($payload, $headers, $secret); + // unwrap successful if not error thrown, increment assertion count to avoid risky test warning + $this->addToAssertionCount(1); + } + + #[Test] + public function testUnwrapWrongKey(): void + { + $this->expectException(WebhookException::class); + + $payload = '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; + $secret = 'whsec_c2VjcmV0Cg=='; + $webhook = new Webhook($secret); + $messageId = '1'; + $timestamp = time(); + $signature = $webhook->sign($messageId, $timestamp, $payload); + + /** @var array> $headers */ + $headers = [ + 'webhook-signature' => [$signature], + 'webhook-id' => [$messageId], + 'webhook-timestamp' => [(string) $timestamp], + ]; + $wrongKey = 'whsec_aaaaaaaaaa'; + $this->client->webhooks->unwrap($payload, $headers, $wrongKey); + } + + #[Test] + public function testUnwrapBadSignature(): void + { + $this->expectException(WebhookException::class); + + $payload = '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; + $secret = 'whsec_c2VjcmV0Cg=='; + $webhook = new Webhook($secret); + $messageId = '1'; + $timestamp = time(); + $badSig = $webhook->sign($messageId, $timestamp, 'some other payload'); + + /** @var array> $headers */ + $headers = [ + 'webhook-signature' => [$badSig], + 'webhook-id' => [$messageId], + 'webhook-timestamp' => [(string) $timestamp], + ]; + $this->client->webhooks->unwrap($payload, $headers, $secret); + } + + #[Test] + public function testUnwrapOldTimestamp(): void + { + $this->expectException(WebhookException::class); + + $payload = '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; + $secret = 'whsec_c2VjcmV0Cg=='; + $webhook = new Webhook($secret); + $messageId = '1'; + $timestamp = time(); + $signature = $webhook->sign($messageId, $timestamp, $payload); + + /** @var array> $headers */ + $headers = [ + 'webhook-signature' => [$signature], + 'webhook-id' => [$messageId], + 'webhook-timestamp' => ['5'], + ]; + $this->client->webhooks->unwrap($payload, $headers, $secret); + } + + #[Test] + public function testUnwrapWrongMessageID(): void + { + $this->expectException(WebhookException::class); + + $payload = '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; + $secret = 'whsec_c2VjcmV0Cg=='; + $webhook = new Webhook($secret); + $messageId = '1'; + $timestamp = time(); + $signature = $webhook->sign($messageId, $timestamp, $payload); + + /** @var array> $headers */ + $headers = [ + 'webhook-signature' => [$signature], + 'webhook-id' => ['wrong'], + 'webhook-timestamp' => [(string) $timestamp], + ]; + $this->client->webhooks->unwrap($payload, $headers, $secret); + } +} diff --git a/tests/UnsupportedMockTests.php b/tests/UnsupportedMockTests.php new file mode 100644 index 00000000..f57ac900 --- /dev/null +++ b/tests/UnsupportedMockTests.php @@ -0,0 +1,8 @@ +