diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..adb71c87 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI +on: + push: + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' + +jobs: + lint: + timeout-minutes: 10 + name: lint + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: false + - run: |- + bundle install + + - name: Run lints + run: ./scripts/lint + test: + timeout-minutes: 10 + name: test + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: false + - run: |- + bundle install + + - name: Run tests + run: ./scripts/test diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml deleted file mode 100644 index 6a3223fd..00000000 --- a/.github/workflows/gempush.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Ruby Gem -on: - release: - types: [published] - -jobs: - build: - name: Build + Publish - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Ruby 2.6 - uses: ruby/setup-ruby@v1.126.0 - with: - ruby-version: 2.6.5 - bundler: 2.4.22 - - name: Run Test Cases - run: | - gem install bundler -v 2.4.22 - bundle install --jobs 4 --retry 3 - bundle exec rake - - - name: Publish to RubyGems - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials - gem build *.gemspec - gem push *.gem - env: - GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}} diff --git a/.github/workflows/publish-gem.yml b/.github/workflows/publish-gem.yml new file mode 100644 index 00000000..a3de9dee --- /dev/null +++ b/.github/workflows/publish-gem.yml @@ -0,0 +1,31 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to rubygems.org in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/imagekit-developer/imagekit-ruby/actions/workflows/publish-gem.yml +name: Publish Gem +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: false + - run: |- + bundle install + + - name: Publish to RubyGems.org + run: | + bash ./bin/publish-gem + env: + # `RUBYGEMS_HOST` is only required for private gem repositories, not https://rubygems.org + RUBYGEMS_HOST: ${{ secrets.IMAGE_KIT_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }} + GEM_HOST_API_KEY: ${{ secrets.IMAGE_KIT_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }} diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 00000000..9d9c1e66 --- /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-ruby' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v4 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + RUBYGEMS_HOST: ${{ secrets.IMAGE_KIT_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }} + GEM_HOST_API_KEY: ${{ secrets.IMAGE_KIT_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 8c68db1a..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Ruby Test - -on: [ push, pull_request ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Ruby 2.6 - uses: ruby/setup-ruby@v1.126.0 - with: - ruby-version: 2.6.5 - bundler: 2.4.22 - - name: Build and test with Rake - run: | - gem install bundler -v 2.4.22 - bundle install --jobs 4 --retry 3 - bundle exec rake - # - name: Upload code coverage reports to codecov - # uses: codecov/codecov-action@v1 - # with: - # token: 58fd7bff-e88e-4f23-b940-811b12f20dcf # not required for public repos - # # file: ./coverage.xml # optional - # # files: ./coverage1.xml,./coverage2.xml # optional - # # flags: unittests # optional - # # name: codecov-umbrella # optional - # # fail_ci_if_error: true # optional (default = false) diff --git a/.gitignore b/.gitignore index 7500a4aa..3f5f2c5d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,11 @@ -.bundle/ -log/*.log -pkg/ -coverage/ -test/dummy/db/*.sqlite3 -test/dummy/db/*.sqlite3-journal -test/dummy/db/*.sqlite3-* -test/dummy/log/*.log -test/dummy/storage/ -test/dummy/tmp/ -.vscode -public/uploads/ -config/master.key -.DS_Store -Gemfile.lock -**/Gemfile.lock -.idea/* -.rakeTasks -.idea/.gitignore -.idea/imagekit-ruby.iml -.idea/misc.xml -.idea/modules.xml -.idea/vcs.xml +*.gem +.idea/ +.ignore +.prism.log +.ruby-lsp/ +.yardoc/ +bin/tapioca +Brewfile.lock.json +doc/ +sorbet/tapioca/* +examples/temp* \ No newline at end of file diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..127ac87b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "4.0.0" +} \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..65ce11cc --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,296 @@ +# yaml-language-server: $schema=https://www.rubyschema.org/rubocop.json +--- +# Explicitly disable pending cops for now. This is the default behaviour but +# this avoids a large warning every time we run it. +# Stop RuboCop nagging about rubocop-rake. +# Ensure that RuboCop validates according to the lowest version of Ruby that we support. +AllCops: + Exclude: + - "bin/*" + NewCops: enable + SuggestExtensions: false + TargetRubyVersion: 3.2 + +# Whether MFA is required or not should be left to the token configuration. +Gemspec/RequireMFA: + Enabled: false + +# Don't require this extra line break, it can be excessive. +Layout/EmptyLineAfterGuardClause: + Enabled: false + +# Don't leave complex assignment values hanging off to the right. +Layout/EndAlignment: + EnforcedStyleAlignWith: variable + +Layout/FirstArrayElementLineBreak: + Enabled: true + +Layout/FirstHashElementLineBreak: + Enabled: true + +Layout/FirstMethodArgumentLineBreak: + Enabled: true + +Layout/FirstMethodParameterLineBreak: + Enabled: true + +# Set a reasonable line length; rely on other cops to correct long lines. +Layout/LineLength: + AllowedPatterns: + - "^\\s*#.*$" + - ^require(_relative)? + - "Imagekitio::Internal::Type::BaseModel$" + - "^\\s*[A-Z0-9_]+ = :" + - "Imagekitio::(Models|Resources|Test)::" + Max: 110 + +Layout/MultilineArrayLineBreaks: + Enabled: true + +# Start the assignment on the same line variable is mentioned. +Layout/MultilineAssignmentLayout: + EnforcedStyle: same_line + +Layout/MultilineHashKeyLineBreaks: + Enabled: true + +Layout/MultilineMethodArgumentLineBreaks: + Enabled: true + +Layout/MultilineMethodParameterLineBreaks: + Enabled: true + +# Prefer compact hash literals. +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: no_space + Exclude: + - "**/*.rbi" + +Lint/BooleanSymbol: + Enabled: false + +# This option occasionally mangles identifier names +Lint/DeprecatedConstants: + Exclude: + - "**/*.rbi" + +# We use pattern assertion in tests to ensure correctness. +Lint/DuplicateMatchPattern: + Exclude: + - "test/**/*" + +# Fairly useful in tests for pattern assertions. +Lint/EmptyInPattern: + Exclude: + - "test/**/*" + +Lint/MissingCopEnableDirective: + Exclude: + - "examples/**/*.rb" + +Lint/MissingSuper: + Exclude: + - "**/*.rbi" + +Lint/SymbolConversion: + Exclude: + - "**/*.rbi" + +# Disabled for safety reasons, this option changes code semantics. +Lint/UnusedMethodArgument: + AutoCorrect: false + +# This option is prone to causing accidental bugs. +Lint/UselessAssignment: + AutoCorrect: false + Exclude: + - "examples/**/*.rb" + +Metrics/AbcSize: + Enabled: false + +Metrics/BlockLength: + AllowedPatterns: + - assert_pattern + - type_alias + - define_sorbet_constant! + Exclude: + - "**/*.rbi" + +Metrics/ClassLength: + Enabled: false + +Metrics/CollectionLiteralLength: + Exclude: + - "test/**/*" + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Metrics/ParameterLists: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false + +Naming/AccessorMethodName: + Enabled: false + +# Need to preserve block identifier for documentation. +Naming/BlockForwarding: + Enabled: false + +# Underscores are generally useful for disambiguation. +Naming/ClassAndModuleCamelCase: + Enabled: false + +Naming/MethodParameterName: + Enabled: false + +Naming/PredicatePrefix: + Exclude: + - "**/*.rbi" + +Naming/VariableNumber: + Enabled: false + +# Nothing wrong with inline private methods. +Style/AccessModifierDeclarations: + Enabled: false + +Style/AccessorGrouping: + Exclude: + - "**/*.rbi" + +# Behaviour of alias_method is more predictable. +Style/Alias: + EnforcedStyle: prefer_alias_method + +# And/or have confusing precedence, avoid them. +Style/AndOr: + EnforcedStyle: always + +Style/ArgumentsForwarding: + Enabled: false + +Style/BisectedAttrAccessor: + Exclude: + - "**/*.rbi" + +# We prefer nested modules in lib/, but are currently using compact style for tests. +Style/ClassAndModuleChildren: + Exclude: + - "test/**/*" + +Style/CommentAnnotation: + Enabled: false + +# We should go back and add these docs, but ignore for now. +Style/Documentation: + Enabled: false + +# Allow explicit empty elses, for clarity. +Style/EmptyElse: + Enabled: false + +Style/EmptyMethod: + Exclude: + - "**/*.rbi" + +# We commonly use ENV['KEY'], it's OK. +Style/FetchEnvVar: + Enabled: false + +# Just to be safe, ensure nobody is mutating our internal strings. +Style/FrozenStringLiteralComment: + EnforcedStyle: always + Exclude: + - "**/*.rbi" + +# Nothing wrong with clear if statements. +Style/IfUnlessModifier: + Enabled: false + +# Rubocop is pretty bad about mangling single line lambdas. +Style/Lambda: + Enabled: false + +# Prefer consistency in method calling syntax. +Style/MethodCallWithArgsParentheses: + AllowedMethods: + - raise + Enabled: true + Exclude: + - "**/*.gemspec" + +Style/MultilineBlockChain: + Enabled: false + +# Perfectly fine. +Style/MultipleComparison: + Enabled: false + +Style/MutableConstant: + Exclude: + - "**/*.rbi" + +# Not all parameters should be named. +Style/NumberedParameters: + Enabled: false + +Style/NumberedParametersLimit: + Max: 2 + +# Reasonable to use brackets for errors with long messages. +Style/RaiseArgs: + Enabled: false + +# Be explicit about `RuntimeError`s. +Style/RedundantException: + Enabled: false + +Style/RedundantInitialize: + Exclude: + - "**/*.rbi" + +Style/RedundantParentheses: + Exclude: + - "**/*.rbi" + +# Prefer slashes for regex literals. +Style/RegexpLiteral: + EnforcedStyle: slashes + +# Allow explicit ifs, especially for imperative use. +Style/SafeNavigation: + Enabled: false + +Style/SignalException: + Exclude: + - Rakefile + - "**/*.rake" + +# We use these sparingly, where we anticipate future branches for the +# inner conditional. +Style/SoleNestedConditional: + Enabled: false + +# Prefer double quotes so that interpolation can be easily added. +Style/StringLiterals: + EnforcedStyle: double_quotes + +# Prefer explicit symbols for clarity; you can search for `:the_symbol`. +Style/SymbolArray: + EnforcedStyle: brackets + +# This option makes examples harder to read for ruby novices. +Style/SymbolProc: + Exclude: + - "examples/**/*.rb" diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..944880fa --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.2.0 diff --git a/.solargraph.yml b/.solargraph.yml new file mode 100644 index 00000000..6110683d --- /dev/null +++ b/.solargraph.yml @@ -0,0 +1,11 @@ +--- +max_files: 0 +include: + - '*.gemspec' + - 'Rakefile' + - 'examples/**/*.rb' + - 'lib/**/*.rb' + - 'test/imagekitio/resource_namespaces.rb' + - 'test/imagekitio/test_helper.rb' +exclude: + - 'rbi/**/*' diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 00000000..ae3aead6 --- /dev/null +++ b/.stats.yml @@ -0,0 +1,4 @@ +configured_endpoints: 42 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml +openapi_spec_hash: a9aa620376fce66532c84f9364209b0b +config_hash: eb4cf65a4c6b26a2901076eff5810d5d diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..f2cb4f63 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,14 @@ +{ + "recommendations": [ + "shopify.ruby-lsp", + "sorbet.sorbet-vscode-extension", + "soutaro.rbs-syntax", + "bradlc.vscode-tailwindcss", + "github.copilot", + "github.copilot-chat" + ], + "unwantedRecommendations": [ + "rebornix.ruby", + "castwide.solargraph" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..f52f0aeb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,37 @@ +{ + "ruby.interpreter": "ruby", + "ruby.pathToBundler": "bundle", + "ruby.useLanguageServer": true, + "ruby.lint": { + "rubocop": true, + "ruby": true + }, + "ruby.format": "rubocop", + "sorbet.enabled": true, + "sorbet.typeCheckingMode": "strict", + "sorbet.watchmanPath": "watchman", + "files.associations": { + "*.rb": "ruby", + "*.rbi": "ruby", + "*.rbs": "rbs", + "Gemfile": "ruby", + "Rakefile": "ruby" + }, + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.rubocop": "explicit" + }, + "[ruby]": { + "editor.defaultFormatter": "Shopify.ruby-lsp", + "editor.formatOnSave": true, + "editor.tabSize": 2, + "editor.insertSpaces": true, + "editor.semanticHighlighting.enabled": true, + "editor.suggest.insertMode": "replace" + }, + "[rbs]": { + "editor.defaultFormatter": "soutaro.rbs-syntax", + "editor.tabSize": 2, + "editor.insertSpaces": true + } +} diff --git a/.yardopts b/.yardopts new file mode 100644 index 00000000..84c12f2a --- /dev/null +++ b/.yardopts @@ -0,0 +1,6 @@ +--type-name-tag generic:Generic +--default-return void +--markup markdown +--markup-provider redcarpet +--exclude /rbi +--exclude /sig diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..19c75791 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,116 @@ +# Changelog + +## 4.0.0 (2025-11-03) + +Full Changelog: [v0.0.1...v4.0.0](https://github.com/imagekit-developer/imagekit-ruby/compare/v0.0.1...v4.0.0) + +### Features + +* add get_responsive_image_attributes method with options parameter ([766ded9](https://github.com/imagekit-developer/imagekit-ruby/commit/766ded9f6644cdc0f4638980ca78b51a877fe309)) +* add responsive image attributes generation for HTML <img> tags ([13edc3d](https://github.com/imagekit-developer/imagekit-ruby/commit/13edc3d82f92d19869f672bd955a9045a13e0a16)) +* **api:** add BaseWebhookEvent ([b4c2a83](https://github.com/imagekit-developer/imagekit-ruby/commit/b4c2a8398c1b8bfa1df7da222ede418b047fe0b1)) +* **api:** add GetImageAttributesOptions and ResponsiveImageAttributes schemas; update resource references in main.yaml; remove dummy endpoint ([08560d4](https://github.com/imagekit-developer/imagekit-ruby/commit/08560d45c6390460f14c8b76ce42292ed3303047)) +* **api:** add path policy related non-breaking changes ([b24e025](https://github.com/imagekit-developer/imagekit-ruby/commit/b24e025ed565cd1a0f3906838c24d1fc5588f3fd)) +* **api:** add selectedFieldsSchema in upload and list API response ([557f058](https://github.com/imagekit-developer/imagekit-ruby/commit/557f0588a6352568ca0b7be28fe1759717c59aa5)) +* **api:** extract UpdateFileDetailsRequest to model ([9aaa659](https://github.com/imagekit-developer/imagekit-ruby/commit/9aaa6599d67f4d077d34d0afec3c08baef271b9b)) +* **api:** fix go sdk breaking changes ([525a5aa](https://github.com/imagekit-developer/imagekit-ruby/commit/525a5aa25dba80a109fc5d53535cf2f8fa2250dd)) +* **api:** fix upload API request params ([0ac922a](https://github.com/imagekit-developer/imagekit-ruby/commit/0ac922a79db6de564a0ec9dc5405a5171c1d7109)) +* **api:** manual updates ([eaa294e](https://github.com/imagekit-developer/imagekit-ruby/commit/eaa294e74f32dea948ceaec8a5e44223075dabf8)) +* **api:** manual updates ([9604a8e](https://github.com/imagekit-developer/imagekit-ruby/commit/9604a8eb40f6e4947075d6ff80bf919062a1556f)) +* **api:** manual updates ([0682128](https://github.com/imagekit-developer/imagekit-ruby/commit/0682128a78d935ba01979783050d66aac099504a)) +* **api:** manual updates ([f9bee87](https://github.com/imagekit-developer/imagekit-ruby/commit/f9bee8789b20c3ae42a177e8e7adc086fd6b734a)) +* **api:** manual updates ([2f5a40a](https://github.com/imagekit-developer/imagekit-ruby/commit/2f5a40ab9e7c3ffc0755c8c8cbf26bcfe69ab5b0)) +* **api:** manual updates ([428829b](https://github.com/imagekit-developer/imagekit-ruby/commit/428829bb7d7a3e01621dcb6d9901a1b440481f7c)) +* **api:** manual updates ([54e5bdf](https://github.com/imagekit-developer/imagekit-ruby/commit/54e5bdf49a3a67eb494e7aecfd4f5300f8c07772)) +* **api:** manual updates ([8c970ed](https://github.com/imagekit-developer/imagekit-ruby/commit/8c970ed1b42cfb40e05cedf4f643096918097f67)) +* **api:** manual updates ([e33d6ed](https://github.com/imagekit-developer/imagekit-ruby/commit/e33d6ed379d8d298f049edcf5b5b4d2ecfdd82bd)) +* **api:** manual updates ([4c04de9](https://github.com/imagekit-developer/imagekit-ruby/commit/4c04de93766bb15aad1784f5a4a594036fdce827)) +* **api:** manual updates ([e9bad22](https://github.com/imagekit-developer/imagekit-ruby/commit/e9bad2213d947539b07f4c71622c6bee2e826274)) +* **api:** manual updates ([c0417fb](https://github.com/imagekit-developer/imagekit-ruby/commit/c0417fbd4286fb47cbdfc154a696fcd2d34b1b5d)) +* **api:** manual updates ([bddb2fa](https://github.com/imagekit-developer/imagekit-ruby/commit/bddb2faecc78b22888d44aeda6896bdeff0f7cf8)) +* **api:** manual updates ([24f9f11](https://github.com/imagekit-developer/imagekit-ruby/commit/24f9f11ca39e3611c621a1d5383d763a4acd87b4)) +* **api:** manual updates ([8ac0ad3](https://github.com/imagekit-developer/imagekit-ruby/commit/8ac0ad3ff00d4036d52ec31777d74cb19f8d4379)) +* **api:** manual updates ([c64d558](https://github.com/imagekit-developer/imagekit-ruby/commit/c64d558fc172b4c1768d59731dc2a0e2c71de2fb)) +* **api:** manual updates ([453e942](https://github.com/imagekit-developer/imagekit-ruby/commit/453e942ec2c25f3720305dcd564ca22b85815336)) +* **api:** modify upload options serialization for backend API compatibility ([2d9cda5](https://github.com/imagekit-developer/imagekit-ruby/commit/2d9cda5fd408c5359f455c989585a8a8e3528676)) +* **api:** remove Stainless attribution from readme ([45e7793](https://github.com/imagekit-developer/imagekit-ruby/commit/45e7793eae012f4fcd05a30aa1ff4ef695793792)) +* **api:** update api docs link ([03ecbdf](https://github.com/imagekit-developer/imagekit-ruby/commit/03ecbdffb5dddc16aeace01e5b86a7e525263d7b)) +* **api:** Update env var name ([db61f60](https://github.com/imagekit-developer/imagekit-ruby/commit/db61f6089520c631dccbc618453d018634e53e63)) +* **api:** update gem name ([a966137](https://github.com/imagekit-developer/imagekit-ruby/commit/a966137abb937faa25451baafcd41e32c0d16b7e)) +* **api:** updated docs ([c2d983e](https://github.com/imagekit-developer/imagekit-ruby/commit/c2d983ed07adab3c0031f18174b0dcf95a5ba26d)) +* expose response headers for both streams and errors ([72c02c3](https://github.com/imagekit-developer/imagekit-ruby/commit/72c02c37a42bddc4e191b43145a562fab9e01dc7)) +* handle thread interrupts in the core HTTP client ([4d258e9](https://github.com/imagekit-developer/imagekit-ruby/commit/4d258e9d5fc3cb2d2e74e26d605e87b7852736a4)) +* pass all test cases ([1cfd9cb](https://github.com/imagekit-developer/imagekit-ruby/commit/1cfd9cb2229352e8d2ba4a005fc214fbfd73c1ba)) +* **tests:** add support for plain hashes in various helper methods and tests ([f7a8f2d](https://github.com/imagekit-developer/imagekit-ruby/commit/f7a8f2d0cdb258abbc04d73eb7458d371948f2d8)) +* **tests:** add test for generating signed URLs in responsive image attributes ([41b17ab](https://github.com/imagekit-developer/imagekit-ruby/commit/41b17abff1fdd1dc63e7b5cb1b3eff765f8955f4)) +* **tests:** add tests to ensure integer descriptors in srcset for responsive image attributes ([fab9156](https://github.com/imagekit-developer/imagekit-ruby/commit/fab915681615569c608439025992325210391e61)) + + +### Bug Fixes + +* absolutely qualified uris should always override the default ([eebaf5e](https://github.com/imagekit-developer/imagekit-ruby/commit/eebaf5ef3d7b60eb051d4e1a146dee8e0eae66ec)) +* add examples/temp* to .gitignore ([2e76262](https://github.com/imagekit-developer/imagekit-ruby/commit/2e762620a6e8179d3f873306596ea623bd6e539d)) +* always send `filename=...` for multipart requests where a file is expected ([9cf2e92](https://github.com/imagekit-developer/imagekit-ruby/commit/9cf2e92f6bd271a6ffa538176d836786f9ae72bc)) +* carrierwave bump to rm mimemagic dep ([ab4c2cf](https://github.com/imagekit-developer/imagekit-ruby/commit/ab4c2cf5856de50a9cb9deb7fb2168d67258083d)) +* change to dev dep ([22b98f8](https://github.com/imagekit-developer/imagekit-ruby/commit/22b98f8a9f482f11c0e6c3cfe9650a75e62d7f17)) +* coroutine leaks from connection pool ([62e54e5](https://github.com/imagekit-developer/imagekit-ruby/commit/62e54e54eaa2201beeedbacd41452e7eb7d6b1d7)) +* **deps:** update gem dependencies to latest versions in Gemfile.lock ([0cfea18](https://github.com/imagekit-developer/imagekit-ruby/commit/0cfea1897d6c71f8a24bf4795b46553d5d937693)) +* **docs:** enhance README to clarify features and integration with Ruby on Rails ([22c2cec](https://github.com/imagekit-developer/imagekit-ruby/commit/22c2cec88e2c6a37f10dce061eb555e70fe7715d)) +* **docs:** remove unnecessary Bundler setup requirement from usage example in README ([b3355da](https://github.com/imagekit-developer/imagekit-ruby/commit/b3355dad701bb557b5f93281330cc68b6b49011c)) +* **docs:** streamline documentation for Ruby on Rails integration and remove redundant sections ([855c7f9](https://github.com/imagekit-developer/imagekit-ruby/commit/855c7f95644f493d5d670a76c571b9c245493e73)) +* **docs:** update README examples for file uploads and remove obsolete parameters ([17a776a](https://github.com/imagekit-developer/imagekit-ruby/commit/17a776a445401889f0624bf05de2317408f9c1e1)) +* **docs:** update README examples to use File.read instead of StringIO for file uploads ([ca62b83](https://github.com/imagekit-developer/imagekit-ruby/commit/ca62b8326f92b584d805bbe22f133b46f3f84423)) +* **docs:** update README to enhance clarity on Ruby documentation and Rails integration ([e5f64f1](https://github.com/imagekit-developer/imagekit-ruby/commit/e5f64f1a20cb2fb02f23378636053bc0e1bf4957)) +* **docs:** update README to enhance documentation for Ruby on Rails integration and remove outdated sections ([d1760a3](https://github.com/imagekit-developer/imagekit-ruby/commit/d1760a31d0cde39067114c1d913d4c0d0ce8d1c1)) +* **docs:** update README to reflect gem name change from imagekit to imagekitio ([6beb35d](https://github.com/imagekit-developer/imagekit-ruby/commit/6beb35d38eb07ae157a000b953380f948a550c5f)) +* README.md linking sections ([9101ca2](https://github.com/imagekit-developer/imagekit-ruby/commit/9101ca2f3676a28d92c84c3b1b2c1c78ab5d027d)) +* shorten multipart boundary sep to less than RFC specificed max length ([b2ffa6a](https://github.com/imagekit-developer/imagekit-ruby/commit/b2ffa6a8b489b151c50f76f56ad79376aabbcbcb)) +* should not reuse buffers for `IO.copy_stream` interop ([80dcda6](https://github.com/imagekit-developer/imagekit-ruby/commit/80dcda667c50f379514018fbf9db84b1a624fc2e)) +* spelling typo ([8debe83](https://github.com/imagekit-developer/imagekit-ruby/commit/8debe8379dbebdc7aad334acd1d8ac69283b0f94)) +* standardize naming from "Image Kit" to "ImageKit" across documentation and gemspec ([c427415](https://github.com/imagekit-developer/imagekit-ruby/commit/c427415b3424b544bd0b61188d95b1fa90846a38)) +* update namespace for coerce_hash! method in file upload parameters ([f3e7216](https://github.com/imagekit-developer/imagekit-ruby/commit/f3e72163a0000d8f526ad67f1183c1d185772cf4)) + + +### Performance Improvements + +* faster code formatting ([8005df1](https://github.com/imagekit-developer/imagekit-ruby/commit/8005df172660b8610889bd2a478774c38b26cb7d)) + + +### Chores + +* allow fast-format to use bsd sed as well ([81093a0](https://github.com/imagekit-developer/imagekit-ruby/commit/81093a0420de0f10a331fb8d878cc2d9322ca1ec)) +* do not install brew dependencies in ./scripts/bootstrap by default ([14104e2](https://github.com/imagekit-developer/imagekit-ruby/commit/14104e2b691d586fe0e978a6c6e4232d2e6db650)) +* ignore linter error for tests having large collections ([86d5b43](https://github.com/imagekit-developer/imagekit-ruby/commit/86d5b4308f574b456e7f4fd8f094cf02fba39114)) +* **internal:** codegen related update ([d13a1d7](https://github.com/imagekit-developer/imagekit-ruby/commit/d13a1d73432f2ed5a54a7ad624cdc8237b15eb81)) +* remove example upload script ([efe2092](https://github.com/imagekit-developer/imagekit-ruby/commit/efe2092315ca68b4d9b7ede16ba4e624ec1f3adc)) +* sync repo ([0200fb8](https://github.com/imagekit-developer/imagekit-ruby/commit/0200fb885ff82f4960f401169d728b48c9d900cf)) +* update SDK settings ([15d893e](https://github.com/imagekit-developer/imagekit-ruby/commit/15d893e96bc5ae52e5e0cefe24818c248a047d3e)) +* update SDK settings ([5ce5d1f](https://github.com/imagekit-developer/imagekit-ruby/commit/5ce5d1f2370b6b31c1d2927856bfeac5eb592a23)) + + +### Documentation + +* correct typo in default value description for custom metadata field ([c16e257](https://github.com/imagekit-developer/imagekit-ruby/commit/c16e257b541f1fd5063f8feeac74ba7b214d0507)) +* update README to enhance URL generation section with detailed examples and new features ([f1687c0](https://github.com/imagekit-developer/imagekit-ruby/commit/f1687c0784b4633a3e55165f62f14ef7d8bbd5c8)) + + +### Refactors + +* consolidate handling of tags and responseFields for improved clarity ([2b7d54e](https://github.com/imagekit-developer/imagekit-ruby/commit/2b7d54e8592d36f8db8eaebffdae65aa4f1527e7)) +* format and fix all lint issues ([091e6d2](https://github.com/imagekit-developer/imagekit-ruby/commit/091e6d29618ee8337f4fe4ea6d82c77748520b65)) +* remove unnecessary require statements for improved clarity ([75820cd](https://github.com/imagekit-developer/imagekit-ruby/commit/75820cdc78cae2383c7e6061f359b1cc40a93d52)) +* rename generateTransformationString to buildTransformationString for consistency ([028871e](https://github.com/imagekit-developer/imagekit-ruby/commit/028871e9aa23e61b7ba1432874ed99943aec4c0f)) +* simplify overlay processing and enhance safe property access ([f35d7eb](https://github.com/imagekit-developer/imagekit-ruby/commit/f35d7eb50bd2eafd74f355d9a6edd992ae9b995c)) +* standardize method naming for URL and transformation string generation ([f736fef](https://github.com/imagekit-developer/imagekit-ruby/commit/f736fefcd85bf65204fce105969671608551ee89)) +* streamline model object handling and enhance safe property access ([ebf5887](https://github.com/imagekit-developer/imagekit-ruby/commit/ebf5887fb945ae99807327e2361263612a734c00)) +* **tests:** remove password parameter from client setup in URL generation tests ([3cf2616](https://github.com/imagekit-developer/imagekit-ruby/commit/3cf26166baf9369b3e32203c202b3d44f68d177b)) +* unify helper attribute naming across client and test files ([67d2ecb](https://github.com/imagekit-developer/imagekit-ruby/commit/67d2ecb8de8f2889c7473d2635a172b5346bcfde)) +* update method calls to use fully qualified names for clarity ([a45cc83](https://github.com/imagekit-developer/imagekit-ruby/commit/a45cc83d04301758db54a1cfa96364ddb7002959)) +* update parameter naming for build_url method to use options ([cd3618c](https://github.com/imagekit-developer/imagekit-ruby/commit/cd3618c5bb747640da0b255d46206bdd6ee0d300)) + + +### Build System + +* **deps:** bump addressable from 2.7.0 to 2.8.0 in /samples/rails_app ([db074cc](https://github.com/imagekit-developer/imagekit-ruby/commit/db074cc81e5aa59fa962b5e26c25d327bb4cac87)) +* **deps:** bump carrierwave from 2.1.0 to 2.1.1 in /samples/rails_app ([c109b9b](https://github.com/imagekit-developer/imagekit-ruby/commit/c109b9bd0effff643b8062dbe9d1157dad0210d8)) +* **deps:** bump nokogiri from 1.10.10 to 1.11.4 in /samples/rails_app ([9497849](https://github.com/imagekit-developer/imagekit-ruby/commit/9497849e1caa72bc5bbc582da3fc5f6575f2b455)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..a225d784 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,125 @@ +## Setting up the environment + +This repository contains a `.ruby-version` file, which should work with either [rbenv](https://github.com/rbenv/rbenv) or [asdf](https://github.com/asdf-vm/asdf) with the [ruby plugin](https://github.com/asdf-vm/asdf-ruby). + +Please follow the instructions for your preferred version manager to install the Ruby version specified in the `.ruby-version` file. + +To set up the repository, run: + +```bash +$ ./scripts/bootstrap +``` + +This will install all the required dependencies. + +## Modifying/Adding code + +Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents of `lib/imagekitio/helpers/` and `examples/` directory. + +## Adding and running examples + +All files in the `examples/` directory are not modified by the generator and can be freely edited or added to. + +```ruby +#!/usr/bin/env ruby +# frozen_string_literal: true + +require_relative "../lib/imagekitio" + +# ... +``` + +```bash +$ chmod +x './examples/.rb' + +# run the example against your api +$ ruby './examples/.rb' +``` + +## Using the repository from source + +If you’d like to use the repository from source, you can either install from git or reference a cloned repository: + +To install via git in your `Gemfile`: + +```ruby +gem "imagekitio", git: "https://www.github.com/imagekit-developer/imagekit-ruby" +``` + +Alternatively, reference local copy of the repo: + +```bash +$ git clone -- 'https://www.github.com/imagekit-developer/imagekit-ruby' '' +``` + +```ruby +gem "imagekitio", path: "" +``` + +## Running commands + +Running `rake` by itself will show all runnable commands. + +```bash +$ bundle exec rake +``` + +## Running tests + +Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. + +```bash +$ npx prism mock path/to/your/openapi.yml +``` + +```bash +$ bundle exec rake test +``` + +## Linting and formatting + +This repository uses [rubocop](https://github.com/rubocop/rubocop) for linting and formatting of `*.rb` files; And [syntax_tree](https://github.com/ruby-syntax-tree/syntax_tree) is used for formatting of both `*.rbi` and `*.rbs` files. + +There are two separate type checkers supported by this library: [sorbet](https://github.com/sorbet/sorbet) and [steep](https://github.com/soutaro/steep) are used for verifying `*.rbi` and `*.rbs` files respectively. + +To lint and typecheck: + +```bash +$ bundle exec rake lint +``` + +To format and fix all lint issues automatically: + +```bash +$ bundle exec rake format +``` + +## Editor Support + +### Ruby LSP + +[Ruby LSP](https://github.com/Shopify/ruby-lsp) has quite good support for go to definition, but not auto-completion. + +This can be installed along side Solargraph. + +### Solargraph + +[Solargraph](https://solargraph.org) has quite good support for auto-completion, but not go to definition. + +This can be installed along side Ruby LSP. + +### Sorbet + +[Sorbet](https://sorbet.org) should mostly work out of the box when editing this library directly. However, there are a some caveats due to the colocation of `*.rb` and `*.rbi` files in the same project. These issues should not otherwise manifest when this library is used as a dependency. + +1. For go to definition usages, sorbet might get confused and may not always navigate to the correct location. + +2. For each generic type in `*.rbi` files, a spurious "Duplicate type member" error is present. + +## Documentation Preview + +To preview the documentation, run: + +```bash +$ bundle exec rake docs:preview [PORT=8808] +``` diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md deleted file mode 100644 index 47e24cd9..00000000 --- a/DEVELOPMENT.md +++ /dev/null @@ -1,20 +0,0 @@ -# Development Guide - - -**1. To modify version open `lib/imagekit/sdk/version.rb` and change value of `VERSION`.** - -**2. Setup dependency for projects** -```shell -gem install bundler -bundle install -``` - -**2. Run test cases** -```shell -bundle exec rake -``` - -**3. To build gem** -```shell -gem build imagekitio.gemspec -``` diff --git a/Gemfile b/Gemfile index c5777000..0d76364b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,27 +1,33 @@ -source 'https://rubygems.org' -git_source(:github) { |repo| "https://github.com/#{repo}.git" } +# frozen_string_literal: true + +source "https://rubygems.org" -# Declare your gem's dependencies in imagekit-sdk.gemspec. -# Bundler will treat runtime dependencies like base dependencies, and -# development dependencies will be added by default to the :development group. gemspec -# Declare any dependencies that are still in development here instead of in -# your gemspec. These might include edge Rails or gems from your path or -# Git. Remember to move these dependencies to your gemspec before releasing -# your gem to rubygems.org. +group :development do + gem "rake" + gem "rbs" + gem "rubocop" + gem "sorbet" + gem "steep" + gem "syntax_tree" + # TODO: using a fork for now, the prettier below has a bug + gem "syntax_tree-rbs", github: "stainless-api/syntax_tree-rbs", branch: "main" + gem "tapioca" +end -# To use a debugger -# gem 'byebug', group: [:development, :test] -# gem 'carrierwave', '~> 2.0' -# gem "rake", "~> 12.0" -# gem "rest-client", "~>2.1" +group :development, :test do + gem "async" + gem "minitest" + gem "minitest-focus" + gem "minitest-hooks" + gem "minitest-proveit" + gem "minitest-rg" + gem "webmock" +end -group :test do - gem "minitest", "~> 5.0" - gem "rspec" - gem 'simplecov' - # gem 'codecov' - gem 'webmock' - gem 'byebug' +group :development, :docs do + gem "redcarpet" + gem "webrick" + gem "yard" end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..5831c83d --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,227 @@ +GIT + remote: https://github.com/stainless-api/syntax_tree-rbs.git + revision: c30b50219918be7cfe3ef803a00b59d1e77fcada + branch: main + specs: + syntax_tree-rbs (1.0.0) + prettier_print + rbs + syntax_tree (>= 2.0.1) + +PATH + remote: . + specs: + imagekitio (4.0.0) + connection_pool + +GEM + remote: https://rubygems.org/ + specs: + activesupport (8.1.1) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + json + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.3) + async (2.34.0) + console (~> 1.29) + fiber-annotation + io-event (~> 1.11) + metrics (~> 0.12) + traces (~> 0.18) + base64 (0.3.0) + benchmark (0.5.0) + bigdecimal (3.3.1) + concurrent-ruby (1.3.5) + connection_pool (2.5.4) + console (1.34.2) + fiber-annotation + fiber-local (~> 1.1) + json + crack (1.0.1) + bigdecimal + rexml + csv (3.3.5) + drb (2.2.3) + erubi (1.13.1) + ffi (1.17.2-aarch64-linux-gnu) + ffi (1.17.2-aarch64-linux-musl) + ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86_64-darwin) + ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.2-x86_64-linux-musl) + fiber-annotation (0.2.0) + fiber-local (1.1.0) + fiber-storage + fiber-storage (1.0.1) + fileutils (1.8.0) + hashdiff (1.2.1) + i18n (1.14.7) + concurrent-ruby (~> 1.0) + io-event (1.11.2) + json (2.15.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + logger (1.7.0) + metrics (0.15.0) + minitest (5.26.0) + minitest-focus (1.4.0) + minitest (>= 4, < 6) + minitest-hooks (1.5.2) + minitest (> 5.3) + minitest-proveit (1.0.0) + minitest (> 5, < 7) + minitest-rg (5.3.0) + minitest (~> 5.0) + mutex_m (0.3.0) + netrc (0.11.0) + parallel (1.27.0) + parser (3.3.10.0) + ast (~> 2.4.1) + racc + prettier_print (1.2.1) + prism (1.6.0) + public_suffix (6.0.2) + racc (1.8.1) + rainbow (3.1.1) + rake (13.3.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rbi (0.3.7) + prism (~> 1.0) + rbs (>= 3.4.4) + rbs (3.9.5) + logger + redcarpet (3.6.1) + regexp_parser (2.11.3) + rexml (3.4.4) + rubocop (1.81.7) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.47.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.47.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + ruby-progressbar (1.13.0) + securerandom (0.4.1) + sorbet (0.6.12690) + sorbet-static (= 0.6.12690) + sorbet-runtime (0.6.12690) + sorbet-static (0.6.12690-aarch64-linux) + sorbet-static (0.6.12690-universal-darwin) + sorbet-static (0.6.12690-x86_64-linux) + sorbet-static-and-runtime (0.6.12690) + sorbet (= 0.6.12690) + sorbet-runtime (= 0.6.12690) + spoom (1.6.3) + erubi (>= 1.10.0) + prism (>= 0.28.0) + rbi (>= 0.3.3) + rexml (>= 3.2.6) + sorbet-static-and-runtime (>= 0.5.10187) + thor (>= 0.19.2) + steep (1.10.0) + activesupport (>= 5.1) + concurrent-ruby (>= 1.1.10) + csv (>= 3.0.9) + fileutils (>= 1.1.0) + json (>= 2.1.0) + language_server-protocol (>= 3.17.0.4, < 4.0) + listen (~> 3.0) + logger (>= 1.3.0) + mutex_m (>= 0.3.0) + parser (>= 3.1) + rainbow (>= 2.2.2, < 4.0) + rbs (~> 3.9) + securerandom (>= 0.1) + strscan (>= 1.0.0) + terminal-table (>= 2, < 5) + uri (>= 0.12.0) + strscan (3.1.5) + syntax_tree (6.3.0) + prettier_print (>= 1.2.0) + tapioca (0.16.11) + benchmark + bundler (>= 2.2.25) + netrc (>= 0.11.0) + parallel (>= 1.21.0) + rbi (~> 0.2) + sorbet-static-and-runtime (>= 0.5.11087) + spoom (>= 1.2.0) + thor (>= 1.2.0) + yard-sorbet + terminal-table (4.0.0) + unicode-display_width (>= 1.1.1, < 4) + thor (1.4.0) + traces (0.18.2) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) + uri (1.1.0) + webmock (3.26.1) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.1) + yard (0.9.37) + yard-sorbet (0.9.0) + sorbet-runtime + yard + +PLATFORMS + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm64-darwin + universal-darwin + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + async + imagekitio! + minitest + minitest-focus + minitest-hooks + minitest-proveit + minitest-rg + rake + rbs + redcarpet + rubocop + sorbet + steep + syntax_tree + syntax_tree-rbs! + tapioca + webmock + webrick + yard + +BUNDLED WITH + 2.7.1 diff --git a/LICENSE b/LICENSE index b767e540..6c276897 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +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 -SOFTWARE. \ No newline at end of file + 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 2025 ImageKit + + 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 20a7791d..17f80414 100644 --- a/README.md +++ b/README.md @@ -1,915 +1,744 @@ -[ImageKit.io](https://imagekit.io) - -# Imagekit Ruby and Rails SDK - -[![Ruby Test](https://github.com/imagekit-developer/imagekit-ruby/workflows/Ruby%20Test/badge.svg)](https://github.com/imagekit-developer/imagekit-ruby) -[![Gem Version](https://badge.fury.io/rb/imagekitio.svg)](https://badge.fury.io/rb/imagekitio) -[![codecov](https://codecov.io/gh/imagekit-developer/imagekit-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/imagekit-developer/imagekit-ruby) -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow&style=social)](https://twitter.com/ImagekitIo) - -Ruby on Rails gem for [ImageKit](https://imagekit.io/) implements the new APIs and interface for different file operations. - -ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/features/imagekit-infrastructure). 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. - -Table of contents - - * [Changelog](#changelog) - * [Installation](#installation) - * [Initialization](#initialization) - - [CarrierWave](#carrierwave) - - [ActiveStorage](#activestorage) - * [URL Generation](#url-generation) - * [File Upload](#file-upload) - * [File Management](#file-management) - * [Utility Functions](#utility-functions) - * [Sample applications](#sample-application) - * [Upgrade to 2.x](#upgrade-to-2x) - * [Support](#support) - * [Links](#links) - - -# Quick start guide -Get started with [official quick start guide](https://docs.imagekit.io/getting-started/quickstart-guides/ruby-guides) for integrating ImageKit in Ruby on Rails. - -## Changelog -### SDK Version 3.0.0 -#### Breaking changes -**1. Overlay syntax update** -* In version 3.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. +# ImageKit.io Ruby SDK + +The ImageKit Ruby library provides convenient access to the ImageKit REST API from any Ruby 3.2.0+ application. The library supports building and transforming URLs, generating signed URLs for secure content delivery, and handling file uploads. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem. + +## Documentation + +The official [ImageKit Ruby documentation](https://imagekit.io/docs/integration/ruby) provides complete integration guides and examples. + +If you're using Ruby on Rails, the [ImageKit Rails gem](https://github.com/imagekit-developer/imagekit-rails) builds on top of this SDK to provide [Rails-specific integrations](https://imagekit.io/docs/integration/ruby/ruby-on-rails) including Active Storage and view helpers. + +## Table of Contents + +- [Documentation](#documentation) +- [Installation](#installation) +- [Usage](#usage) + - [File uploads](#file-uploads) +- [URL Generation](#url-generation) + - [Basic URL generation](#basic-url-generation) + - [URL generation with transformations](#url-generation-with-transformations) + - [URL generation with image overlay](#url-generation-with-image-overlay) + - [URL generation with text overlay](#url-generation-with-text-overlay) + - [Signed URLs for secure delivery](#signed-urls-for-secure-delivery) + - [Chained transformations](#chained-transformations) + - [Using raw parameter for custom transformations](#using-raw-parameter-for-custom-transformations) +- [Helper Methods](#helper-methods) + - [Authentication parameters for client-side uploads](#authentication-parameters-for-client-side-uploads) + - [Responsive image attributes](#responsive-image-attributes) +- [Handling errors](#handling-errors) + - [Retries](#retries) + - [Timeouts](#timeouts) +- [Advanced concepts](#advanced-concepts) + - [BaseModel](#basemodel) + - [Making custom or undocumented requests](#making-custom-or-undocumented-requests) + - [Concurrency & connection pooling](#concurrency--connection-pooling) +- [Sorbet](#sorbet) + - [Enums](#enums) +- [Versioning](#versioning) +- [Requirements](#requirements) +- [Contributing](#contributing) ## Installation -Add `imagekitio` dependency to your application's Gemfile: +To use this gem, install via Bundler by adding the following to your application's `Gemfile`: -```ruby -gem 'imagekitio' -``` - -And then execute: -``` -$ bundle install -``` - -Or install it yourself: -``` -$ gem install imagekitio -``` - -## Initialization - -Create a new file `config/initializers/imagekitio.rb` then add the configuration. -```ruby -ImageKitIo.configure do |config| - if Rails.env.development? - config.public_key = 'your_public_api_key' - config.private_key = 'your_private_api_key' - config.url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/' - end - config.service = :carrierwave - #config.service = :active_storage - #config.constants.MISSING_PRIVATE_KEY = 'custom error message' -end -``` -#### CarrierWave -You can create a CarrierWave uploader to attach pictures to your database objects as their attributes. Skip to [this section](https://github.com/imagekit-developer/imagekit-ruby#file-upload) to upload images without designating them as database attributes. Make sure to add service `:carrierwave` as shown in [initialization section](#initialization). - -```bash -rails g uploader -# For example, if you want to create an uploader for Avatar attribute, then use -rails g uploader Avatar -# Generated uploader's path will be app/uploaders/avatar_uploader.rb -``` + -After that, you need to edit your generated uploader and make the following changes: ```ruby -# include this module inside the top of the uploader class -include ImageKitIo::CarrierWave - -# If you want to add uploading options, then create this method inside the uploader file as an example - -def options - options={ - response_fields: 'isPrivateFile, tags', - tags: %w[abc def], - use_unique_file_name: false, - folder: "your_directory/" - } -end - -# If you want to set upload dir, then you can use the following method, or you can also use the options method. -# This method should return a string -def store_dir - "your_directory/" -end +gem "imagekitio", "~> 4.0.0" ``` -Then you need to modify your model. for example- if your model name is employee, then do these changes. + -```ruby -class Employee < ApplicationRecord - attr_accessor :avatar - mount_uploader :avatar, AvatarUploader -end -``` +## Usage -Get image url: ```ruby -# If @employee is an object of your model that has data. - -# To get the original image url, use -@employee.avatar.url +require "imagekitio" -# To get the file metadata -@employee.avatar.metadata +image_kit = Imagekitio::Client.new( + private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted +) +response = image_kit.files.upload( + file: Pathname("/path/to/file"), + file_name: "file-name.jpg" +) -# And to get transformed url use -# options is a transformation options -@employee.avatar.url_with(options) +puts(response.file_id) ``` -#### ActiveStorage +### File uploads -Once you [install](https://guides.rubyonrails.org/active_storage_overview.html#setup) the active_storage gem, then any model can have the attachment using `has_one_attached` or `has_many_attached` like below: +Request parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, or an `IO` stream. ```ruby -class Employee < ApplicationRecord - has_one_attached :avatar -end -``` +require "pathname" -Get image url: -```ruby -# If @employee is an object of your model that has data. +# Use `Pathname` to stream from disk (memory efficient, supports retries): +response = image_kit.files.upload(file: Pathname("/path/to/file")) -# To get the original image url, use -@employee.avatar.url -``` - -Now, let's configure active_storage as a service for the imagekitio. +# Or pass file contents directly +response = image_kit.files.upload(file: File.read("/path/to/file")) -First add `:active_storage` in initializer file. +# Or, to control the filename and/or content type: +file = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…") +response = image_kit.files.upload(file: file) -```ruby -config.service = :active_storage -``` - -Then add the imagekitio service in the `storage.yml` file: - -```ruby -imagekitio: - service: ImageKitIo +puts(response.file_id) ``` +Note that you can also pass a raw `IO` descriptor, but this disables retries, as the library can't be sure if the descriptor is a file or pipe (which cannot be rewound). -## Usage +## URL Generation -You can use this Ruby SDK for three different methods - URL generation, file upload, and media management operations. The usage of the SDK has been explained below. +The ImageKit SDK provides a powerful `helper.build_url()` method for generating optimized image and video URLs with transformations. Here are examples ranging from simple URLs to complex transformations with overlays and signed URLs. -* `URL Generation` -* `File Upload` -* `File Management` +### Basic URL generation -## URL generation +Generate a simple URL without any transformations: -**1. Using Image path and image hostname or endpoint** +```ruby +require "imagekitio" -This method allows you to create an URL to access a file using the relative file path and the ImageKit URL endpoint (`urlEndpoint`). The file can be an image, video or any other static file supported by ImageKit. +image_kit = Imagekitio::Client.new( + private_key: ENV["IMAGEKIT_PRIVATE_KEY"] +) -```ruby -imagekitio = ImageKitIo.client -image_url = imagekitio.url({ - path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{height: "300", width: "400", raw: "ar-4-3,q-40"}] +# Basic URL without transformations +url = image_kit.helper.build_url({ + src: "/default-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id" }) -``` -The result in a URL like -``` -https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400,ar-4-3,q-40/default-image.jpg +puts url +# Output: https://ik.imagekit.io/your_imagekit_id/default-image.jpg ``` -**2.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. - +You can also use absolute URLs: ```ruby -image_url = imagekitio.url({ - src: "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg", - transformation: [{height: "300", width: "400"}], +url = image_kit.helper.build_url({ + src: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id" }) ``` -The results in a URL like - -``` -https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300%2Cw-400 -``` - - -The `.url()` method accepts the following parameters +### URL generation with transformations -| Option | Description | -| :---------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| url_endpoint | 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 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. | -| transformation_position | Optional. The default value is `path` that 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. If you use `src` parameter to create the URL, then the transformation string is always added as a query parameter. | -| query_parameters | Optional. These are the other query parameters that you want to add to the final URL. These can be any query parameters and not necessarily related to ImageKit. Especially useful if you want to add some versioning parameters to your URLs. | -| signed | Optional. Boolean. Default is `false`. If set to `true`, the SDK generates a signed image URL adding the image signature to the image URL. This can only be used if you are creating the URL with the `url_endpoint` and `path` parameters and not with the `src` parameter. | -| expire_seconds | Optional. Integer. Meant to be used along with the `signed` parameter to specify the time in seconds from now when the URL should expire. If specified, the URL contains the expiry timestamp in the URL, and the image signature is modified accordingly. | - - -## Examples of generating URLs -**1. Chained Transformations as a query parameter** +Apply common transformations like resizing, cropping, and format conversion: ```ruby -image_url = imagekitio.url({ - path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - height: "300", - width: "400" - },{ - rotation: 90 - }], - transformation_position: "query" +# URL with basic transformations +url = image_kit.helper.build_url({ + src: "/path/to/image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + width: 400, + height: 300, + crop: :maintain_ratio, + quality: 80, + format_: :webp + } + ] }) +# Output: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300,c-maintain_ratio,q-80,f-webp ``` -Sample Result URL - -``` -https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300%2Cw-400%3Art-90 -``` - -**2. Sharpening and contrast transforms and a progressive JPG image** - -There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation) -that 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. +More transformation examples: ```ruby -image_url = imagekitio.url({ - src: "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg", - transformation: [{ - format: "jpg", - progressive: "true", - effect_sharpen: "-", - effect_contrast: "1" - }] +# Image resizing and cropping +url = image_kit.helper.build_url({ + src: "/product.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + width: 800, + height: 600, + crop: :at_max, + focus: "auto" + } + ] }) -``` -``` -//Note that because `src` parameter was used, the transformation string gets added as a query parameter `tr` -https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=f-jpg%2Cpr-true%2Ce-sharpen%2Ce-contrast-1 -``` +# Image effects +url = image_kit.helper.build_url({ + src: "/photo.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + blur: 10, + grayscale: true, + radius: 20 + } + ] +}) -**3. Signed URL that expires in 300 seconds with the default URL endpoint and other query parameters** +# Format and quality optimization +url = image_kit.helper.build_url({ + src: "/image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + format_: :auto, + quality: 85, + progressive: true + } + ] +}) +``` -```ruby -image_url = imagekit.url({ - path: "/default-image", - query_parameters: { - "v": "123" +### URL generation with image overlay + +Add image overlays to your base image: + +```ruby +# URL with image overlay +url = image_kit.helper.build_url({ + src: "/path/to/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + width: 500, + height: 400, + overlay: { + type: :image, + input: "/path/to/overlay-logo.png", + position: { + x: 10, + y_: 10 + }, + transformation: [ + { + width: 100, + height: 50 + } + ] + } + } + ] +}) +# Output: URL with image overlay positioned at x:10, y:10 +``` + +### URL generation with text overlay + +Add customized text overlays: + +```ruby +# URL with text overlay +url = image_kit.helper.build_url({ + src: "/path/to/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + width: 600, + height: 400, + overlay: { + type: :text, + text: "Sample Text Overlay", + position: { + x: 50, + y_: 50, + focus: :center + }, + transformation: [ + { + font_size: 40, + font_family: "Arial", + font_color: "FFFFFF", + typography: "b" # bold + } + ] + } + } + ] +}) +# Output: URL with bold white Arial text overlay at center position +``` + +You can combine multiple overlays for complex compositions: + +```ruby +# URL with multiple overlays (text + image) +url = image_kit.helper.build_url({ + src: "/path/to/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + width: 800, + height: 600, + overlay: { + type: :text, + text: "Header Text", + position: { x: 20, y_: 20 }, + transformation: [{ font_size: 30, font_color: "000000" }] + } }, - transformation: [{ - height: "300", - width: "400" - }], - signed: True, - expire_seconds: 300 + { + overlay: { + type: :image, + input: "/watermark.png", + position: { focus: :bottom_right }, + transformation: [{ width: 100, opacity: 70 }] + } + } + ] }) +# Output: URL with text overlay at top-left and semi-transparent watermark at bottom-right ``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg?v=123&ik-t=1567358667&ik-s=f2c7cdacbe7707b71a83d49cf1c6110e3d701054 -``` - -**4. 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** +### Signed URLs for secure delivery -You can add any text string over a base video or image using a text layer (l-text). - -For example: +Generate signed URLs that expire after a specified time for secure content delivery: ```ruby -image_url = imagekit.url({ - path: "/default-image", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - height: "300", - width: "400", - raw: "l-text,i-Imagekit,fs-50,l-end" - }], +# Generate a signed URL that expires in 1 hour (3600 seconds) +url = image_kit.helper.build_url({ + src: "/private/secure-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + width: 400, + height: 300, + quality: 90 + } + ], + signed: true, + expires_in: 3600 # URL expires in 1 hour }) +# Output: URL with signature parameters (?ik-t=timestamp&ik-s=signature) + +# Generate a signed URL that doesn't expire +url = image_kit.helper.build_url({ + src: "/private/secure-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + signed: true + # No expires_in means the URL won't expire +}) +# Output: URL with signature parameter (?ik-s=signature) ``` -**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 -``` - -**Image as overlays** -You can add an image over a base video or image using an image layer (l-image). +### Chained transformations -For example: +Apply multiple transformation steps by passing multiple transformation objects. Each transformation is applied sequentially: ```ruby -image_url = imagekit.url({ - path: "/default-image", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - height: "300", - width: "400", - raw: "l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end" - }], +# First resize, then apply effects +url = image_kit.helper.build_url({ + src: "/default-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + width: 400, + height: 300 + }, + { + rotation: 90, + blur: 5 + } + ] }) -``` -**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 +# Output: https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-400,h-300:rt-90,bl-5 ``` -**Solid color blocks as overlays** +### Using raw parameter for custom transformations -You can add solid color blocks over a base video or image using an image layer (l-image). - -For example: +ImageKit frequently adds new transformation parameters that might not yet be documented in the SDK. You can use the `raw` parameter to access these features or create custom transformation strings: ```ruby -image_url = imagekit.url({ - path: "/img/sample-video", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - height: "300", - width: "400", - raw: "l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end" - }], +# Using raw parameter for custom transformations +url = image_kit.helper.build_url({ + src: "/path/to/image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation: [ + { + width: 400, + height: 300, + raw: "something-new" + } + ] }) +# Output: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300,something-new ``` -**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 -``` - -**5. 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: +You can control where transformations appear in the URL: ```ruby -image_url = imagekit.url({ - path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ - width: "iw_div_4", - height: "ih_div_2", - 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 +# Add transformations to the URL path instead of query parameters +url = image_kit.helper.build_url({ + src: "/default-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + transformation_position: :path, + transformation: [ + { + width: 400, + height: 300 + } + ] +}) +# Output: https://ik.imagekit.io/your_imagekit_id/tr:w-400,h-300/default-image.jpg ``` -**List of transformations** - -The complete list of transformations supported and their usage in ImageKit can be found [here](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations). 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 | -| aspect_ratio | ar | -| quality | q | -| crop | c | -| crop_mode | 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 | -| color_profile | cp | -| default_image | di | -| dpr | dpr | -| effect_sharpen | e-sharpen | -| effect_usm | e-usm | -| effect_contrast | e-contrast | -| effect_gray | e-grayscale | -| effect_shadow | e-shadow | -| effect_gradient | e-gradient | -| original | orig | -| raw | `replaced by the parameter value` | - -## File Upload -This method can be used to directly upload images to your ImageKit Media Library without giving it the designation of an attribute of any database object. - -The SDK provides a simple interface using the `.upload()` method to upload files to the ImageKit Media library. It -accepts all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload). - -The `upload()` method requires at least the `file` and the `file_name` parameter to upload a file and returns -a callback with the `error` and `result` as arguments. You can pass other parameters supported by the -ImageKit upload API using the same parameter name as specified in the upload API documentation. For example, to specify tags for a file at the time of upload, use the `tags` parameter as specified in the [documentation here](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload). - -Simple usage +Add custom query parameters: ```ruby -imagekitio.upload_file( - file: "", # required - file_name: "my_file_name.jpg", # required - response_fields: 'isPrivateFile, tags', - tags: %w[abc def], - use_unique_file_name: true, - transformation: { - pre: 'l-text,i-Imagekit,fs-50,l-end', - post: [ - { - type: 'transformation', - value: 'w-100' - } - ] - }, - checks: "'request.folder' : '/'" # To run server side checks before uploading files. Notice the quotes around file.size and 1mb. - is_published: true -) - +url = image_kit.helper.build_url({ + src: "/default-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + query_parameters: { + version: "1", + cache: "max" + } +}) ``` -If the upload is succeeded, `error` will be `None`, and the result will be the same as what is received from ImageKit's -servers. If the upload fails, `error` will be the same as what is received from ImageKit's servers, and the result will -be `None`. - -## File Management +## Helper Methods -The SDK provides a simple interface for all the [media APIs mentioned here](https://docs.imagekit.io/api-reference/media-api) -to manage your files. This also returns `error` and `result`. The `error` will be `None` if API succeeds. +The SDK provides several helper methods for common ImageKit operations. -**List & Search Files** +### Authentication parameters for client-side uploads -Accepts an object specifying the parameters to be used to list and search files. All parameters specified -in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#list-and-search-file-api) can be passed with the -correct values to get the results. +Generate authentication parameters for secure client-side file uploads. These parameters allow you to securely upload files directly from the browser without exposing your private API key: ```ruby -imagekitio.list_files( - skip: 0, - limit: 5 -) -``` -**Get File Details** +require "imagekitio" -Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details) - -```ruby -imagekitio.get_file_details( - file_id: '598821f949c0a938d57563bd' +image_kit = Imagekitio::Client.new( + private_key: ENV["IMAGEKIT_PRIVATE_KEY"] ) -``` -**Get File Metadata** +# Generate authentication parameters with default expiry (30 minutes) +auth_params = image_kit.helper.get_authentication_parameters -Accepts the file ID and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files) -```ruby -imagekit.get_file_metadata( - file_id: '598821f949c0a938d57563bd' -) +puts auth_params +# Output: { token: "unique-token", expire: 1234567890, signature: "signature-hash" } ``` -**Get File Metadata from remote url** - -Accepts the remote file url and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-from-remote-url) +Customize the token and expiration: ```ruby -imagekit.get_remote_file_url_metadata( - remote_file_url: "https://ik.imagekit.io/demo/tr:w-100/default-image.jpg" +# Custom token and expiry (1 hour from now) +auth_params = image_kit.helper.get_authentication_parameters( + token: "my-custom-token", + expire: Time.now.to_i + 3600 ) +# Output: { token: "my-custom-token", expire: 1234567890, signature: "generated-signature" } ``` -**Update File Details** +These authentication parameters can be used in client-side upload forms to securely upload files without exposing your private API key. -Update parameters associated with the file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/update-file-details). -The first argument to the `update_field_details` method is the file ID, and a second argument is an object with the -parameters to be updated. +### Responsive image attributes -```ruby -imagekitio.update_file_details( - file_id: '598821f949c0a938d57563bd', - tags: ["image_tag"], - custom_coordinates: "10,10,100, 100" -) -``` - - -**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`. +Generate responsive image attributes for HTML `` tags. This creates optimized `srcset` and `sizes` attributes for responsive images: ```ruby -imagekitio.update_file_details( - file_id: '598821f949c0a938d57563bd', - publish:{ - isPublished: true, - includeFileVersions: true +# Width-based responsive images (generates w descriptors) +attrs = image_kit.helper.get_responsive_image_attributes({ + src: "/default-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + sizes: "(min-width: 768px) 50vw, 100vw", + transformation: [ + { + quality: 80, + format_: :auto } -) -``` + ] +}) -**Copy File** +puts attrs.src +# Largest candidate URL -Copy file from one path to another path using the source file path and the destination path as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-file) +puts attrs.src_set +# URL1 640w, URL2 750w, URL3 1080w, ... -```ruby -imagekitio.copy_file( - source_file_path: '/path/to/file.jpg', - destination_path: '/folder/to/copy/into', - include_file_versions: true #default false -) +puts attrs.sizes +# (min-width: 768px) 50vw, 100vw ``` -**Move File** - -Move file from one folder to another folder using the source file path and destination path as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/move-file) +DPR-based responsive images (generates x descriptors): ```ruby -imagekitio.move_file( - source_file_path: '/path/to/file.jpg', - destination_path: '/folder/to/move/into/' -) -``` - -**Rename File** +# When width is provided without sizes, generates 1x and 2x variants +attrs = image_kit.helper.get_responsive_image_attributes({ + src: "/profile.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + width: 400, + transformation: [ + { + quality: 85 + } + ] +}) -Rename file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/rename-file) +puts attrs.src_set +# URL1 1x, URL2 2x -```ruby -imagekitio.rename_file( - file_path: '/path/to/old-file-name.jpg', - new_file_name: 'new-file-name.jpg', - purge_cache: true #optional -) +puts attrs.width +# 400 ``` -**Delete File** - -Delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file). The method accepts the file ID of the file that has to be deleted. +Custom breakpoints for device widths: ```ruby -imagekitio.delete_file( - file_id: '598821f949c0a938d57563bd' -) +attrs = image_kit.helper.get_responsive_image_attributes({ + src: "/default-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + sizes: "100vw", + device_breakpoints: [320, 640, 1024, 1920], + image_breakpoints: [16, 32, 64], + transformation: [ + { + crop: :at_max + } + ] +}) ``` -**File versions** -Get all file versions as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-versions). The method accepts the file ID of the file. +The returned attributes can be directly used in your HTML: -```ruby -imagekitio.file_versions( - file_id: '598821f949c0a938d57563bd' -) +```erb +Responsive image ``` -**File version details** -Get all file version detail as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-version-details). The method accepts the file ID and version ID of the file. +Generate signed responsive image URLs: ```ruby -imagekitio.file_version_detail( - file_id: '598821f949c0a938d57563bd', - version_id: '846321f949c0a938d57567ty' -) +# Generate signed responsive image URLs +attrs = image_kit.helper.get_responsive_image_attributes({ + src: "/default-image.jpg", + url_endpoint: "https://ik.imagekit.io/your_imagekit_id", + sizes: "100vw", + signed: true, + expires_in: 3600, + transformation: [ + { + quality: 80 + } + ] +}) ``` -**Delete file version** +### Handling errors -Delete file version as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file-version). The method accepts the file ID and version ID of the file. +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 `Imagekitio::Errors::APIError` will be thrown: ```ruby -imagekitio.delete_file_version( - file_id: '598821f949c0a938d57563bd', - version_id: '846321f949c0a938d57567ty' -) +begin + file = image_kit.files.upload( + file: File.read("/path/to/file.jpg"), + file_name: "file-name.jpg" + ) +rescue Imagekitio::Errors::APIConnectionError => e + puts("The server could not be reached") + puts(e.cause) # an underlying Exception, likely raised within `net/http` +rescue Imagekitio::Errors::RateLimitError => e + puts("A 429 status code was received; we should back off a bit.") +rescue Imagekitio::Errors::APIStatusError => e + puts("Another non-200-range status code was received") + puts(e.status) +end ``` -**Restore file version** - -Restore deleted file version as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/restore-file-version). The method accepts the file ID and version ID of the file. +Error codes are as follows: -```ruby -imagekitio.restore_file_version( - file_id: '598821f949c0a938d57563bd', - version_id: '846321f949c0a938d57567ty' -) -``` +| Cause | Error Type | +| ---------------- | -------------------------- | +| HTTP 400 | `BadRequestError` | +| HTTP 401 | `AuthenticationError` | +| HTTP 403 | `PermissionDeniedError` | +| HTTP 404 | `NotFoundError` | +| HTTP 409 | `ConflictError` | +| HTTP 422 | `UnprocessableEntityError` | +| HTTP 429 | `RateLimitError` | +| HTTP >= 500 | `InternalServerError` | +| Other HTTP error | `APIStatusError` | +| Timeout | `APITimeoutError` | +| Network error | `APIConnectionError` | -**Bulk File Delete by IDs** +### Retries -Delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-files-bulk). The method accepts a list of file IDs of files that has to be -deleted. +Certain errors will be automatically retried 2 times by default, with a short exponential backoff. -```ruby -imagekitio.delete_bulk_files( - file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57543bd"] -) -``` +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. -**Purge Cache** -Programmatically issue a clear cache request as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache). -Accepts the full URL of the file for which the cache has to be cleared. +You can use the `max_retries` option to configure or disable this: ```ruby -imagekitio.purge_file_cache( - file_url: 'https://ik.imagekit.io/demo/logo-white_SJwqB4Nfe.png' +# Configure the default for all requests: +image_kit = Imagekitio::Client.new( + max_retries: 0 # default is 2 ) -``` -**Purge Cache Status** - -Get the purge cache request status using the request ID returned when a purge cache request gets submitted as per the -[API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache-status) -```ruby -imagekitio.purge_file_cache_status( - request_id: '598821f949c0a938d57543bd' +# Or, configure per-request: +image_kit.files.upload( + file: File.read("/path/to/file.jpg"), + file_name: "file-name.jpg", + request_options: {max_retries: 5} ) ``` -**Add Bulk Tags** +### Timeouts -Add multiple tags on multiple files using an array of file ids and an array of tags as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/add-tags-bulk) +By default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this: ```ruby -imagekitio.add_bulk_tags( - file_ids: ['598821f949c0a938d57543bd', '598921f949c0a938d57543bd'], - tags: ['custom_tags', 'image', 'favourite'] +# Configure the default for all requests: +image_kit = Imagekitio::Client.new( + timeout: nil # default is 60 ) -``` -**Delete Bulk Tags** - -Remove multiple tags from multiple files using an array of file ids and an array of tags as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/remove-tags-bulk) - -```ruby -imagekitio.delete_bulk_tags( - file_ids: ['598821f949c0a938d57543bd', '598921f949c0a938d57543bd'], - tags: ['custom_tags', 'image'] +# Or, configure per-request: +image_kit.files.upload( + file: File.read("/path/to/file.jpg"), + file_name: "file-name.jpg", + request_options: {timeout: 5} ) ``` -**Delete Bulk AI Tags** +On timeout, `Imagekitio::Errors::APITimeoutError` is raised. -Delete bulk ai tags as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/remove-aitags-bulk) +Note that requests that time out are retried by default. -```ruby -imagekitio.delete_bulk_ai_tags( - file_ids: ['598821f949c0a938d57543bd', '598921f949c0a938d57543bd'], - ai_tags: ['custom_ai_tags'] -) -``` +## Advanced concepts -**Create Folder** +### BaseModel -Create folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/create-folder) +All parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including: -```ruby -imagekitio.create_folder( - folder_name: 'new_folder', - parent_folder_path: 'source/folder/path' #optional -) -``` +1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax. +2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true. -**Copy Folder** +3. Both instances and the classes themselves can be pretty-printed. -Copy folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-folder) +4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`. -```ruby -imagekitio.copy_folder( - source_folder_path: '/folder/to/copy', - destination_path: '/folder/to/copy/into', - include_file_versions: true #default false -) -``` +### Making custom or undocumented requests + +#### Undocumented properties -**Move Folder** +You can send undocumented parameters to any endpoint, and read undocumented response properties, like so: -Move folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/move-folder) +Note: the `extra_` parameters of the same name overrides the documented parameters. ```ruby -imagekitio.move_folder( - source_folder_path: '/folder/to/move', - destination_path: '/folder/to/move/into/' -) -``` +response = + image_kit.files.upload( + file: File.read("/path/to/file.jpg"), + file_name: "file-name.jpg", + request_options: { + extra_query: {my_query_parameter: value}, + extra_body: {my_body_parameter: value}, + extra_headers: {"my-header": value} + } + ) -**Delete Folder** +puts(response[:my_undocumented_property]) +``` -Delete folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-folder) +#### Undocumented request params -```ruby -imagekitio.delete_folder( - folder_path: 'folder/to/delete' -) -``` +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. -**Bulk Job Status** +#### Undocumented endpoints -Get the bulk job status as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-move-folder-status) +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: ```ruby -imagekitio.bulk_job_status( - job_id: '5e21880d5efe355febd4cccd' +response = client.request( + method: :post, + path: '/undocumented/endpoint', + query: {"dog": "woof"}, + headers: {"useful-header": "interesting-value"}, + body: {"hello": "world"} ) ``` -**Create a custom metadata field** - -Create custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field) +### Concurrency & connection pooling -```ruby +The `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests. -imagekitio.create_custom_metadata_field( - name: 'price', - label: 'price_label', - schema: { - 'type': 'Number', - 'minValue': 100, - 'maxValue': 300 - } -) -``` +Each instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings. -**Get Custom Metadata Fields** +When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout. -Get the custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/get-custom-metadata-field) +Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure. -```ruby -imagekitio.get_custom_metadata_fields( - include_deleted: true #optional -) -``` +## Sorbet -**Update Custom Metadata Fields** +This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime. -Update custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field) +You can provide typesafe request parameters like so: ```ruby -imagekitio.update_custom_metadata_field( - id: '5e21880d5efe355febd4bccd', #field_id - label: 'custom-price', #Either label or schema or both should be given - schema: nil +image_kit.files.upload( + file: File.read("/path/to/file.jpg"), + file_name: "file-name.jpg" ) ``` -**Delete Custom Metadata Fields** - -Delete custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/delete-custom-metadata-field) +Or, equivalently: ```ruby -imagekitio.delete_custom_metadata_field( - id: '5e21880d5efe355febd4bccd' #field_id +# Hashes work, but are not typesafe: +image_kit.files.upload( + file: File.read("/path/to/file.jpg"), + file_name: "file-name.jpg" ) -``` - -## Access request-id, other response headers and HTTP status code - -Each media management function returns a hash with `response`, `error`, `status_code`, `headers`, `raw_body` keys with respective values. -```ruby -upload = imagekitio.upload_file( - file: file, - file_name: "default.jpg", - folder: '/test', - response_fields: 'tags,customCoordinates,isPrivateFile,metadata', - tags: %w[abc def], - use_unique_file_name: false, - is_private_file: true +# You can also splat a full Params class: +params = Imagekitio::FileUploadParams.new( + file: File.read("/path/to/file.jpg"), + file_name: "file-name.jpg" ) -puts upload[:status_code] # 200 -puts upload[:headers] - -# { -# "access-control-allow-origin"=>["*"], -# "x-ik-requestid"=>["6963194e-014f-8945-b05a-bdb0e088f1bd"], -# "content-type"=>["application/json; charset=utf-8"], -# "content-length"=>["611"], -# "etag"=>["W/\"859-GOeZiRFGOZERjHBgRUhG0EGcODs\""], -# "date"=>["Wed, 29 Jun 2022 07:04:33 GMT"], -# "x-request-id"=>["6963194e-014f-8945-b05a-bdb0e088f1bd"], -# "connection"=>["close"] -# } - - -puts upload[:raw_body] -# "{\"fileId\":\"62bjf980rb886bd691b86760\",\"name\":\"default.jpg\",\"size\":102117,\"versionInfo\":{\"id\":\"62bjf980rb886bd691b86760\",\"name\":\"Version 1\"},\"filePath\":\"/test/default.jpg\",\"url\":\"https://ik.imagekit.io/46865sdf6sdf/test/default.jpg\",\"fileType\":\"image\",\"height\":700,\"width\":1050,\"thumbnailUrl\":\"https://ik.imagekit.io/46865sdf6sdf/tr:n-ik_ml_thumbnail/test/default.jpg\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"isPrivateFile\":true,\"customCoordinates\":null,\"metadata\":{\"height\":700,\"width\":1050,\"size\":102117,\"format\":\"jpg\",\"hasColorProfile\":true,\"quality\":0,\"density\":72,\"hasTransparency\":false,\"exif\":{},\"pHash\":\"90249d9b1fc74367\"}}" +image_kit.files.upload(**params) ``` -## Utility functions - -We have included the following commonly used utility functions in this package. - -**Authentication parameter generation** - -If you are looking 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 that you can use in your code to generate these authentication parameters for you. - -_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_ - -`authentication_parameters = imagekit.get_authentication_parameters(token, expire)` +### Enums -Returns +Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime: ```ruby -{ - "token": "unique_token", - "expire": "valid_expiry_timestamp", - "signature": "generated_signature" -} -``` - -Both the `token` and `expire` parameters are optional. If not specified, the SDK uses the uuid to generate a random token and also generates a valid expiry timestamp internally. The value of the `token` and `expire` used to generate the signature is always returned in the response, no matter if they are provided as an input to this method 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 near the duplicate(similar) image by calculating -the distance between the two images. - - -This SDK exposes the `phash_distance` 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. +# :all +puts(Imagekitio::AssetListParams::FileType::ALL) -```ruby -def calculate_distance(): - # fetch metadata of two uploaded image files - ... - # extract pHash strings from both: say 'first_hash' and 'second_hash.' - ... - # calculate the distance between them: - - distance = imagekitio.phash_distance(first_hash, second_hash) - return distance +# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)` +T.reveal_type(Imagekitio::AssetListParams::FileType::ALL) ``` -**Distance calculation examples** +Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value: ```ruby -imagekitio.phash_distance('f06830ca9f1e3e90', 'f06830ca9f1e3e90') -# output: 0 (ame image) - -imagekitio.phash_distance('2d5ad3936d2e015b', '2d6ed293db36a4fb') -# output: 17 (similar images) +# Using the enum constants preserves the tagged type information: +image_kit.assets.list( + file_type: Imagekitio::AssetListParams::FileType::ALL, + # … +) -imagekitio.phash_distance('a4a65595ac94518b', '7838873e791f8400') -# output: 37 (dissimilar images) +# Literal values are also permissible: +image_kit.assets.list( + file_type: :all, + # … +) ``` -## Sample Application -There are three sample apps: - -* Rails application using Carrierwave -* Rails application using ActiveStorage -* Plain ruby application - -Please see the sample applications in [here](https://github.com/imagekit-samples/quickstart). +## Versioning -## Upgrade to 2.x +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. -If you are upgrading to 2.x from version 1.x, make the following changes in your application: +This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes. -- Remove config from environment file to initializer file as described [here](#Initialization). -- Include `ImageKitIo::CarrierWave` in uploader class(for Carrierwave). -- Remove `storage :imagekit_store` config from uploader. -- Rename class `ImageKit::ImageKitClient` to `ImageKitIo::Client` -- Rename class `ImageKitIo::ImageKitRequest` to `ImageKitIo::Request` +## Requirements -## Support -For any feedback or to report any issues or general implementation support, please reach out to [support@imagekit.io](mailto:support@imagekit.io) +Ruby 3.2.0 or higher. -## Links -- [Documentation](https://docs.imagekit.io) -- [Main website](https://imagekit.io) +## Contributing -## License -Released under the MIT license. +See [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md). diff --git a/Rakefile b/Rakefile index 7457939a..a0c9e54e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,27 +1,172 @@ -begin - require 'bundler/setup' -rescue LoadError - puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +# frozen_string_literal: true + +require "pathname" +require "securerandom" +require "shellwords" + +require "minitest/test_task" +require "rake/clean" +require "rubocop/rake_task" + +tapioca = "sorbet/tapioca" +examples = "examples" +ignore_file = ".ignore" + +FILES_ENV = "FORMAT_FILE" + +CLEAN.push(*%w[.idea/ .ruby-lsp/ .yardoc/ doc/], *FileList["*.gem"], ignore_file) + +CLOBBER.push(*%w[sorbet/rbi/annotations/ sorbet/rbi/gems/], tapioca) + +multitask(:default) do + sh(*%w[rake --tasks]) +end + +desc("Preview docs; use `PORT=` to change the port") +multitask(:"docs:preview") do + sh(*%w[yard server --reload --quiet --bind [::] --port], ENV.fetch("PORT", "8808")) +end + +desc("Run test suites; use `TEST=path/to/test.rb` to run a specific test file") +multitask(:test) do + rb = + FileList[ENV.fetch("TEST", "./test/**/*_test.rb")] + .map { "require_relative(#{_1.dump});" } + .join + + ruby(*%w[-w -e], rb, verbose: false) { fail unless _1 } +end + +xargs = %w[xargs --no-run-if-empty --null --max-procs=0 --max-args=300 --] +ruby_opt = {"RUBYOPT" => [ENV["RUBYOPT"], "--encoding=UTF-8"].compact.join(" ")} + +filtered = ->(ext, dirs) do + if ENV.key?(FILES_ENV) + %w[sed -E -n -e] << "/\\.#{ext}$/p" << "--" << ENV.fetch(FILES_ENV) + else + (%w[find] + dirs + %w[-type f -and -name]) << "*.#{ext}" << "-print0" + end +end + +desc("Lint `*.rb(i)`") +multitask(:"lint:rubocop") do + find = %w[find ./lib ./test ./rbi ./examples -type f -and ( -name *.rb -or -name *.rbi ) -print0] + + rubocop = %w[rubocop] + rubocop += %w[--format github] if ENV.key?("CI") + + # some lines cannot be shortened + rubocop += %w[--except Lint/RedundantCopDisableDirective,Layout/LineLength] + + lint = xargs + rubocop + sh("#{find.shelljoin} | #{lint.shelljoin}") +end + +norm_lines = %w[tr -- \n \0].shelljoin + +desc("Format `*.rb`") +multitask(:"format:rb") do + # while `syntax_tree` is much faster than `rubocop`, `rubocop` is the only formatter with full syntax support + files = filtered["rb", %w[./lib ./test ./examples]] + fmt = xargs + %w[rubocop --fail-level F --autocorrect --format simple --] + sh("#{files.shelljoin} | #{norm_lines} | #{fmt.shelljoin}") +end + +desc("Format `*.rbi`") +multitask(:"format:rbi") do + files = filtered["rbi", %w[./rbi]] + fmt = xargs + %w[stree write --] + sh(ruby_opt, "#{files.shelljoin} | #{norm_lines} | #{fmt.shelljoin}") end -require 'rdoc/task' +desc("Format `*.rbs`") +multitask(:"format:rbs") do + files = filtered["rbs", %w[./sig]] + inplace = /darwin|bsd/ =~ RUBY_PLATFORM ? ["-i", ""] : %w[-i] + uuid = SecureRandom.uuid + + # `syntax_tree` has trouble with `rbs`'s class & module aliases + + sed_bin = /darwin/ =~ RUBY_PLATFORM ? "/usr/bin/sed" : "sed" + sed = xargs + [sed_bin, "-E", *inplace, "-e"] + # annotate unprocessable aliases with a unique comment + pre = sed + ["s/(class|module) ([^ ]+) = (.+$)/# \\1 #{uuid}\\n\\2: \\3/", "--"] + fmt = xargs + %w[stree write --plugin=rbs --] + # remove the unique comment and unprocessable aliases to type aliases + subst = <<~SED + s/# (class|module) #{uuid}/\\1/ + t l1 + b -RDoc::Task.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'ImageKitIo::Sdk' - rdoc.options << '--line-numbers' - rdoc.rdoc_files.include('README.md') - rdoc.rdoc_files.include('lib/**/*.rb') + : l1 + N + s/\\n *([^:]+): (.+)$/ \\1 = \\2/ + SED + # for each line: + # 1. try transform the unique comment into `class | module`, if successful, branch to label `l1`. + # 2. at label `l1`, join previously annotated line with `class | module` information. + pst = sed + [subst, "--"] + + success = false + + # transform class aliases to type aliases, which syntax tree has no trouble with + sh("#{files.shelljoin} | #{norm_lines} | #{pre.shelljoin}") + # run syntax tree to format `*.rbs` files + sh(ruby_opt, "#{files.shelljoin} | #{norm_lines} | #{fmt.shelljoin}") do + success = _1 + end + # transform type aliases back to class aliases + sh("#{files.shelljoin} | #{norm_lines} | #{pst.shelljoin}") + + # always run post-processing to remove comment marker + fail unless success end -require 'bundler/gem_tasks' +desc("Format everything") +multitask(format: [:"format:rb", :"format:rbi", :"format:rbs"]) + +desc("Typecheck `*.rbs`") +multitask(:"typecheck:steep") do + sh(*%w[steep check]) +end -require 'rake/testtask' +directory(examples) -Rake::TestTask.new(:test) do |t| - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.verbose = false +desc("Typecheck `*.rbi`") +multitask("typecheck:sorbet": examples) do + sh(*%w[srb typecheck --dir], examples) end -task default: :test +directory(tapioca) do + sh(*%w[tapioca init]) +end + +desc("Typecheck everything") +multitask(typecheck: [:"typecheck:steep", :"typecheck:sorbet"]) + +desc("Lint and typecheck") +multitask(lint: [:"lint:rubocop", :typecheck]) + +desc("Build yard docs") +multitask(:"build:docs") do + sh(*%w[yard]) +end + +desc("Build ruby gem") +multitask(:"build:gem") do + # optimizing for grepping through the gem bundle: many tools honour `.ignore` files, including VSCode + # + # both `rbi` and `sig` directories are navigable by their respective tool chains and therefore can be ignored by tools such as `rg` + Pathname(ignore_file).write(<<~GLOB) + rbi/* + sig/* + GLOB + + sh(*%w[gem build -- imagekitio.gemspec]) + rm_rf(ignore_file) +end + +desc("Release ruby gem") +multitask(release: [:"build:gem"]) do + sh(*%w[gem push], *FileList["*.gem"]) +end diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..2ed9bbbf --- /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 ImageKit, please follow the respective company's security reporting guidelines. + +### ImageKit 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/Steepfile b/Steepfile new file mode 100644 index 00000000..528b48c3 --- /dev/null +++ b/Steepfile @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "yaml" + +target(:lib) do + configure_code_diagnostics(Steep::Diagnostic::Ruby.strict) + + signature("sig") + + YAML.safe_load_file("./manifest.yaml", symbolize_names: true) => {dependencies:} + # currently these libraries lack the `*.rbs` annotations required by `steep` + stdlibs = dependencies - %w[English etc net/http rbconfig set stringio] + + stdlibs.each { library(_1) } +end diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 00000000..c05436e8 --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${GEM_HOST_API_KEY}" ]; then + errors+=("The GEM_HOST_API_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/bin/publish-gem b/bin/publish-gem new file mode 100644 index 00000000..8444af20 --- /dev/null +++ b/bin/publish-gem @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail + +cd -- "$(dirname -- "$0")/.." + +bundle +find . -maxdepth 1 -type f -name "*.gem" -delete +rake release \ No newline at end of file diff --git a/bin/test b/bin/test deleted file mode 100755 index 5516a12b..00000000 --- a/bin/test +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby -$: << File.expand_path("../test", __dir__) - -require "bundler/setup" -require "rails/plugin/test" diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 6e19fffc..00000000 --- a/codecov.yml +++ /dev/null @@ -1,22 +0,0 @@ -codecov: - require_ci_to_pass: yes - -coverage: - status: - patch: off - precision: 2 - round: down - range: "70...100" - -parsers: - gcov: - branch_detection: - conditional: yes - loop: yes - method: no - macro: no - -comment: - layout: "reach,diff,flags,tree" - behavior: default - require_changes: no diff --git a/examples/.keep b/examples/.keep new file mode 100644 index 00000000..d8c73e93 --- /dev/null +++ b/examples/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store example files demonstrating usage of this SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/imagekitio.gemspec b/imagekitio.gemspec index e44548d9..c5fb4d76 100644 --- a/imagekitio.gemspec +++ b/imagekitio.gemspec @@ -1,34 +1,28 @@ -$:.push File.expand_path("lib", __dir__) +# frozen_string_literal: true -# Maintain your gem's version: -require "imagekitio/sdk/version" +require_relative "lib/imagekitio/version" -# Describe your gem and declare its dependencies: -Gem::Specification.new do |spec| - spec.name = "imagekitio" - spec.version = ImageKitIo::Sdk::VERSION - spec.authors = ["ImageKit.io team"] - spec.email = ["developer@imagekit.io"] - spec.homepage = "https://imagekit.io" - spec.summary = "Automate image optimization on rails platforms." - spec.description = "Automate image optimization on rails platforms." - spec.license = "MIT" +Gem::Specification.new do |s| + s.name = "imagekitio" + s.version = Imagekitio::VERSION + s.summary = "Ruby library to access the ImageKit API" + s.authors = ["ImageKit"] + s.email = "developer@imagekit.io" + s.homepage = "https://gemdocs.org/gems/imagekitio" + s.metadata["homepage_uri"] = s.homepage + s.metadata["source_code_uri"] = "https://github.com/imagekit-developer/imagekit-ruby" + s.metadata["rubygems_mfa_required"] = false.to_s + s.required_ruby_version = ">= 3.2.0" - # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' - # to allow pushing to a single host or delete this section to allow pushing to any host. - if spec.respond_to?(:metadata) - spec.metadata["allowed_push_host"] = "https://rubygems.org" - else - raise "RubyGems 2.0 or newer is required to protect against " \ - "public gem pushes." - end - - spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] - - spec.add_dependency "addressable", "~> 2.8" - spec.add_dependency "multipart-post", ">= 2.1.0" - spec.add_dependency "rest-client", "~> 2.1", ">=2.1" - spec.add_development_dependency "activestorage", ">= 5.2.0" - spec.add_development_dependency "carrierwave", ">= 0.7", "<= 2.2.1" - spec.add_development_dependency "rails", "~> 5.2.0", ">= 5.2.0" + s.files = Dir[ + "lib/**/*.rb", + "rbi/**/*.rbi", + "sig/**/*.rbs", + "manifest.yaml", + "SECURITY.md", + "CHANGELOG.md", + ".ignore" + ] + s.extra_rdoc_files = ["README.md"] + s.add_dependency "connection_pool" end diff --git a/lib/active_storage/active_storage.rb b/lib/active_storage/active_storage.rb deleted file mode 100644 index 67565d12..00000000 --- a/lib/active_storage/active_storage.rb +++ /dev/null @@ -1,7 +0,0 @@ -begin - require 'active_storage' - rescue LoadError - puts "Add gem 'activestorage' to use this service" - end - require_relative './service/ik_file' - require_relative './service/image_kit_io_service' diff --git a/lib/active_storage/service/ik_file.rb b/lib/active_storage/service/ik_file.rb deleted file mode 100644 index 9b2b8f08..00000000 --- a/lib/active_storage/service/ik_file.rb +++ /dev/null @@ -1,115 +0,0 @@ -module ImageKiIo - module ActiveStorage - class IKFile - attr_accessor :identifier - - def initialize(identifier) - @identifier = identifier - @imagekit = ImageKitIo.client - end - - def url - identifier['url'] - end - - def delete - begin - @imagekit.delete_file(file_id: file_id) - rescue - file_id - end - end - - def file_type - identifier['fileType'] - end - - def thumbnail_url - identifier['thumbnail'] - end - - def filename - identifier['name'] - end - - def size - identifier['size'] - end - - def path - identifier['filePath'] - end - - def height - identifier['height'] - end - - def width - identifier['width'] - end - - def file_id - identifier['fileId'] - end - - def exist? - details = @imagekit.get_file_details(file_id: file_id) - return false if details[:error].present? - - true - end - - def type - identifier['type'] - end - - def tags - identifier['tags'] - end - - def ai_tags - identifier['AITags'] - end - - def is_private? - identifier['isPrivateFile'] - end - - def custom_coordinates - identifier['customCoordinates'] - end - - def mime - identifier['mime'] - end - - def alpha? - identifier['hasAlpha'] - end - - def custom_metadata - identifier['customMetadata'] - end - - def embedded_metadata - identifier['embeddedMetadata'] - end - - def created_at - identifier['createdAt'] - end - - def updated_at - identifier['updatedAt'] - end - - def extension_status - identifier['extensionStatus'] - end - - def transformation - identifier['transformation'] - end - end - end -end diff --git a/lib/active_storage/service/image_kit_io_service.rb b/lib/active_storage/service/image_kit_io_service.rb deleted file mode 100644 index 41a6390b..00000000 --- a/lib/active_storage/service/image_kit_io_service.rb +++ /dev/null @@ -1,188 +0,0 @@ -require_relative './ik_file' - -if defined? Rails - # Overwrite the ActiveStorage::Downloader's open method and remove the file integrity check constraint method verify_integrity_of - class DownloaderExtension < ::ActiveStorage::Downloader - def open(key, checksum:, name: "ActiveStorage-", tmpdir: nil, **options) - open_tempfile(name, tmpdir) do |file| - download key, file - # verify_integrity_of file, checksum: checksum - yield file - end - end - end - - module ActiveStorageBlobExtension - def self.included(base) - base.class_eval do - before_update :check_metadata - before_destroy :remove_imagekit_file - # ActiveRecord::Blob class first destroy the record data and then calls the service.delete method with key - # as an argument. But the imagekit.io needs fileId to destroy the file which can be get from the metadata. - # So first destroy the remote file and then destroy the local blob record. - def remove_imagekit_file - service.class.delete_ik_file(self) - end - - def remote_file_exist? - service.exist?(self.key) - end - - def remote_file - return false unless remote_file_exist? - - service.class.remote_file(self) - end - - # Needs to reload the record to reflect updated remote meta data. - def check_metadata - self.reload - end - end - end - end - - Rails.application.config.to_prepare do - ActiveStorage::Blob.send :include, ::ActiveStorageBlobExtension - end - - module ActiveStorage - class Service::ImageKitIoService < Service - include ImageKitIo::Constantable - - class << self - def delete_ik_file(blob) - ik_file(blob).delete - end - - def remote_file(blob) - ik_file(blob) - end - - def ik_file(blob) - self.new.send(:ik_file).new(blob.metadata) - end - end - - def initialize(**options) - @options = options - end - - def upload(key, io, checksum: nil, **options) - instrument :upload, key: key, checksum: checksum do - blob = storage_blob(key) - response = client.upload_file(file: io, file_name: blob.filename.to_s, content_type: blob.content_type) - if response[:error].nil? - blob.update_columns(metadata: response[:response].transform_keys(&:to_sym)) - else - raise Exception.new response[:error] - end - end - end - - def download(key, &block) - if block_given? - instrument :stream_file, key: key do - stream_file(key, &block) - end - else - instrument :download, key: key do - image_kit_file(key) - end - end - end - - def download_chunk(key, range) - puts 'Not implemented download_chunk' - end - - def delete(key) - instrument :delete, key: key do - # image kit file is already deleted on before blob destroy callback - key - end - end - - def delete_prefixed(prefix) - # delete the variants files - puts 'Not implemented delete_prefixed' - end - - def exist?(key) - image_kit_file(key).exist? - end - - def url_for_direct_upload(key, **options) - instrument :url, key: key do |payload| - options.delete(:content_length) - options.delete(:checksum) - url = "#{constants.BASE_URL}#{constants.UPLOAD}" - generated_url = client.url(src: url) - payload[:url] = generated_url - generated_url - end - end - - def headers_for_direct_upload(key, content_type:, checksum:, **options) - { - 'Content-Type' => content_type - } - end - - def path_for(key) - image_kit_file(key).path - end - - def url(key, filename: nil, content_type: '', **options) - generate_url(key, filename: filename, content_type: content_type, path: image_kit_file(key).path, **options) - end - - def open(*args, **options, &block) - DownloaderExtension.new(self).open(*args, **options, &block) - end - - private - - def private_url(key, expires_in:, filename:, disposition:, content_type:, **options) - generate_url(key, expires_in: expires_in, filename: filename, disposition: disposition, content_type: content_type, path: image_kit_file(key).path, **options) - end - - def generate_url(key, expires_in:, filename:, content_type:, disposition:, **options) - # filename = filename.to_s if filename.is_a? ActiveStorage::Filename - # options[:filename] = filename if filename - client.url(url_endpoint: config.url_endpoint, **options) - end - - def client - ImageKitIo.client - end - - def config - ImageKitIo.config - end - - def storage_blob(key) - ActiveStorage::Blob.find_by_key(key) - end - - def image_kit_file(key) - blob = storage_blob(key) - ik_file.new(blob.metadata) - end - - def ik_file - ImageKiIo::ActiveStorage::IKFile - end - - def stream_file(key, &download_block) - file_obj = image_kit_file(key) - block = proc { |response| - response.read_body do |chunk| - download_block.call(chunk) if download_block.present? - end - } - client.stream_file(file_url: file_obj.url, &block) - end - end - end -end diff --git a/lib/carrierwave/carrierwave.rb b/lib/carrierwave/carrierwave.rb deleted file mode 100644 index 1c589da4..00000000 --- a/lib/carrierwave/carrierwave.rb +++ /dev/null @@ -1,83 +0,0 @@ -begin - require 'carrierwave' -rescue LoadError - puts "Add gem 'carrierwave' to use this service" -end -require_relative './storage/imagekit_store' -require_relative './storage/ik_file' -require_relative './support/uri_filename' - -module ImageKitIo - module CarrierWave - def self.included(base) - base.include InstanceMethods - base.class_eval do - configure do |config| - config.storage_engines[:imagekit_store] = 'ImageKitIo::CarrierWave::Storage::ImageKitStore' - end - end - base.storage :imagekit_store - end - - module InstanceMethods - def initialize(*) - @imagekit = ImageKitIo.client - @options = {} - end - - def filename - if options != nil - @options = options - end - folder = nil - begin - folder = store_dir - rescue - end - - if folder != nil - @options[:folder] = folder - end - - if self.file != nil - resp = @imagekit.upload_file(file: open(self.file.file, 'rb'), file_name: self.file.filename, **@options) - # ::File.delete(self.file.file) - res = resp[:response].to_json - if res != "null" - res - else - "{\"filePath\":\"\",\"url\":\"\",\"name\":\"\"}" - end - else - "{\"filePath\":\"\",\"url\":\"\",\"name\":\"\"}" - end - end - - def fileId - JSON.parse(self.identifier)['fileId'] - end - - def blob - JSON.parse(self.identifier) - end - - def url_with(opt) - path = JSON.parse(self.identifier)['filePath'] - opt[:path] = path - url = @imagekit.url(opt) - end - - def url - JSON.parse(self.identifier)['url'] - end - - def options - options = {} - end - - def store_dir - store_dir = nil - end - end - end -end diff --git a/lib/carrierwave/storage/ik_file.rb b/lib/carrierwave/storage/ik_file.rb deleted file mode 100644 index f76811bf..00000000 --- a/lib/carrierwave/storage/ik_file.rb +++ /dev/null @@ -1,51 +0,0 @@ -module ImageKitIo - module CarrierWave - module Storage - class IKFile - # Initialize as required. - - def initialize(identifier) - @identifier=JSON.parse(identifier) - @imagekit = ImageKitIo.client - end - - # Duck-type methods for CarrierWave::SanitizedFile. - def content_type - "image/jpg" - end - def public_url - @identifier['url'] - end - def url(options = {}) - @identifier['url'] - end - - def fileId - @identifier['fileId'] - end - def filename(options = {}) - @identifier['name'] - end - def read - end - def size - end - def delete - # file_id=@identifier['fileId'] - begin - @imagekit.delete_file(file_id: fileId) - rescue - fileId - end - # binding.pry - # return nil - end - def exists? - end - # Others... ? - end - - end - - end -end diff --git a/lib/carrierwave/storage/imagekit_store.rb b/lib/carrierwave/storage/imagekit_store.rb deleted file mode 100644 index 5d00c74b..00000000 --- a/lib/carrierwave/storage/imagekit_store.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'uri' -require 'net/http' -require 'base64' - -module ImageKitIo - module CarrierWave - module Storage - class ImageKitStore < ::CarrierWave::Storage::Abstract - - def initialize(*) - super - @cache_called = nil - end - - def store!(file) - file.delete - end - - def retrieve!(identifier) - - IKFile.new(identifier) - end - - def cache!(new_file) - new_file.move_to(::File.expand_path(uploader.cache_path, uploader.root), uploader.permissions, uploader.directory_permissions, true) - rescue Errno::EMLINK, Errno::ENOSPC => e - raise(e) if @cache_called - @cache_called = true - - # NOTE: Remove cached files older than 10 minutes - clean_cache!(600) - - cache!(new_file) - end - - def retrieve_from_cache!(identifier) - CarrierWave::SanitizedFile.new(::File.expand_path(uploader.cache_path(identifier), uploader.root)) - end - - def delete_dir!(path) - if path - begin - Dir.rmdir(::File.expand_path(path, uploader.root)) - rescue Errno::ENOENT - # Ignore: path does not exist - rescue Errno::ENOTDIR - # Ignore: path is not a dir - rescue Errno::ENOTEMPTY, Errno::EEXIST - # Ignore: dir is not empty - end - end - end - - def clean_cache!(seconds) - Dir.glob(::File.expand_path(::File.join(uploader.cache_dir, '*'), CarrierWave.root)).each do |dir| - # generate_cache_id returns key formated TIMEINT-PID(-COUNTER)-RND - time = dir.scan(/(\d+)-\d+-\d+(?:-\d+)?/).first.map(&:to_i) - time = Time.at(*time) - if time < (Time.now.utc - seconds) - FileUtils.rm_rf(dir) - end - end - end - - end - end - end -end diff --git a/lib/carrierwave/support/uri_filename.rb b/lib/carrierwave/support/uri_filename.rb deleted file mode 100644 index f5d45430..00000000 --- a/lib/carrierwave/support/uri_filename.rb +++ /dev/null @@ -1,12 +0,0 @@ -module ImageKitIo - module CarrierWave - module Support - module UriFilename - def self.filename(url) - path = url.split('?').first - URI.decode(path).gsub(%r{.*/(.*?$)}, '\1') - end - end - end - end -end diff --git a/lib/imagekitio.rb b/lib/imagekitio.rb index 6e15fa8e..317c9b3f 100644 --- a/lib/imagekitio.rb +++ b/lib/imagekitio.rb @@ -1,13 +1,181 @@ -require "imagekitio/railtie" if defined? Rails - -require 'base64' - -require_relative './imagekitio/constant' -require_relative './imagekitio/base' -require_relative './imagekitio/configurable' -require_relative './imagekitio/client' -require_relative "./imagekitio/request" -require_relative "./imagekitio/url" -require_relative './imagekitio/api_service/custom_metadata_field' -require_relative './imagekitio/api_service/file' -require_relative './imagekitio/api_service/folder' +# frozen_string_literal: true + +# Standard libraries. +# rubocop:disable Lint/RedundantRequireStatement +require "English" +require "cgi" +require "date" +require "erb" +require "etc" +require "json" +require "net/http" +require "pathname" +require "rbconfig" +require "securerandom" +require "set" +require "stringio" +require "time" +require "uri" +require "base64" +# rubocop:enable Lint/RedundantRequireStatement + +# We already ship the preferred sorbet manifests in the package itself. +# `tapioca` currently does not offer us a way to opt out of unnecessary compilation. +if Object.const_defined?(:Tapioca) && + caller.chain([$PROGRAM_NAME]).chain(ARGV).any?(/tapioca/) && + ARGV.none?(/dsl/) + return +end + +# Gems. +require "connection_pool" + +# Package files. +require_relative "imagekitio/version" +require_relative "imagekitio/internal/util" +require_relative "imagekitio/internal/type/converter" +require_relative "imagekitio/internal/type/unknown" +require_relative "imagekitio/internal/type/boolean" +require_relative "imagekitio/internal/type/file_input" +require_relative "imagekitio/internal/type/enum" +require_relative "imagekitio/internal/type/union" +require_relative "imagekitio/internal/type/array_of" +require_relative "imagekitio/internal/type/hash_of" +require_relative "imagekitio/internal/type/base_model" +require_relative "imagekitio/internal/type/base_page" +require_relative "imagekitio/internal/type/request_parameters" +require_relative "imagekitio/internal" +require_relative "imagekitio/request_options" +require_relative "imagekitio/file_part" +require_relative "imagekitio/errors" +require_relative "imagekitio/internal/transport/base_client" +require_relative "imagekitio/internal/transport/pooled_net_requester" +require_relative "imagekitio/client" +require_relative "imagekitio/models/accounts/origin_request" +require_relative "imagekitio/models/accounts/url_endpoint_request" +require_relative "imagekitio/models/update_file_request" +require_relative "imagekitio/models/file" +require_relative "imagekitio/models/src_options" +require_relative "imagekitio/models/base_overlay" +require_relative "imagekitio/models/base_webhook_event" +require_relative "imagekitio/models/accounts/origin_create_params" +require_relative "imagekitio/models/accounts/origin_delete_params" +require_relative "imagekitio/models/accounts/origin_get_params" +require_relative "imagekitio/models/accounts/origin_list_params" +require_relative "imagekitio/models/accounts/origin_list_response" +require_relative "imagekitio/models/accounts/origin_response" +require_relative "imagekitio/models/accounts/origin_update_params" +require_relative "imagekitio/models/accounts/url_endpoint_create_params" +require_relative "imagekitio/models/accounts/url_endpoint_delete_params" +require_relative "imagekitio/models/accounts/url_endpoint_get_params" +require_relative "imagekitio/models/accounts/url_endpoint_list_params" +require_relative "imagekitio/models/accounts/url_endpoint_list_response" +require_relative "imagekitio/models/accounts/url_endpoint_response" +require_relative "imagekitio/models/accounts/url_endpoint_update_params" +require_relative "imagekitio/models/accounts/usage_get_params" +require_relative "imagekitio/models/accounts/usage_get_response" +require_relative "imagekitio/models/asset_list_params" +require_relative "imagekitio/models/asset_list_response" +require_relative "imagekitio/models/beta/v2/file_upload_params" +require_relative "imagekitio/models/beta/v2/file_upload_response" +require_relative "imagekitio/models/cache/invalidation_create_params" +require_relative "imagekitio/models/cache/invalidation_create_response" +require_relative "imagekitio/models/cache/invalidation_get_params" +require_relative "imagekitio/models/cache/invalidation_get_response" +require_relative "imagekitio/models/custom_metadata_field" +require_relative "imagekitio/models/custom_metadata_field_create_params" +require_relative "imagekitio/models/custom_metadata_field_delete_params" +require_relative "imagekitio/models/custom_metadata_field_delete_response" +require_relative "imagekitio/models/custom_metadata_field_list_params" +require_relative "imagekitio/models/custom_metadata_field_list_response" +require_relative "imagekitio/models/custom_metadata_field_update_params" +require_relative "imagekitio/models/extensions" +require_relative "imagekitio/models/file_copy_params" +require_relative "imagekitio/models/file_copy_response" +require_relative "imagekitio/models/file_delete_params" +require_relative "imagekitio/models/file_get_params" +require_relative "imagekitio/models/file_move_params" +require_relative "imagekitio/models/file_move_response" +require_relative "imagekitio/models/file_rename_params" +require_relative "imagekitio/models/file_rename_response" +require_relative "imagekitio/models/files/bulk_add_tags_params" +require_relative "imagekitio/models/files/bulk_add_tags_response" +require_relative "imagekitio/models/files/bulk_delete_params" +require_relative "imagekitio/models/files/bulk_delete_response" +require_relative "imagekitio/models/files/bulk_remove_ai_tags_params" +require_relative "imagekitio/models/files/bulk_remove_ai_tags_response" +require_relative "imagekitio/models/files/bulk_remove_tags_params" +require_relative "imagekitio/models/files/bulk_remove_tags_response" +require_relative "imagekitio/models/files/metadata_get_from_url_params" +require_relative "imagekitio/models/files/metadata_get_params" +require_relative "imagekitio/models/files/version_delete_params" +require_relative "imagekitio/models/files/version_delete_response" +require_relative "imagekitio/models/files/version_get_params" +require_relative "imagekitio/models/files/version_list_params" +require_relative "imagekitio/models/files/version_list_response" +require_relative "imagekitio/models/files/version_restore_params" +require_relative "imagekitio/models/file_update_params" +require_relative "imagekitio/models/file_update_response" +require_relative "imagekitio/models/file_upload_params" +require_relative "imagekitio/models/file_upload_response" +require_relative "imagekitio/models/folder" +require_relative "imagekitio/models/folder_copy_params" +require_relative "imagekitio/models/folder_copy_response" +require_relative "imagekitio/models/folder_create_params" +require_relative "imagekitio/models/folder_create_response" +require_relative "imagekitio/models/folder_delete_params" +require_relative "imagekitio/models/folder_delete_response" +require_relative "imagekitio/models/folder_move_params" +require_relative "imagekitio/models/folder_move_response" +require_relative "imagekitio/models/folder_rename_params" +require_relative "imagekitio/models/folder_rename_response" +require_relative "imagekitio/models/folders/job_get_params" +require_relative "imagekitio/models/folders/job_get_response" +require_relative "imagekitio/models/get_image_attributes_options" +require_relative "imagekitio/models/image_overlay" +require_relative "imagekitio/models/metadata" +require_relative "imagekitio/models/overlay" +require_relative "imagekitio/models/overlay_position" +require_relative "imagekitio/models/overlay_timing" +require_relative "imagekitio/models/responsive_image_attributes" +require_relative "imagekitio/models/solid_color_overlay" +require_relative "imagekitio/models/solid_color_overlay_transformation" +require_relative "imagekitio/models/streaming_resolution" +require_relative "imagekitio/models/subtitle_overlay" +require_relative "imagekitio/models/subtitle_overlay_transformation" +require_relative "imagekitio/models/text_overlay" +require_relative "imagekitio/models/text_overlay_transformation" +require_relative "imagekitio/models/transformation" +require_relative "imagekitio/models/transformation_position" +require_relative "imagekitio/models/unsafe_unwrap_webhook_event" +require_relative "imagekitio/models/unwrap_webhook_event" +require_relative "imagekitio/models/upload_post_transform_error_event" +require_relative "imagekitio/models/upload_post_transform_success_event" +require_relative "imagekitio/models/upload_pre_transform_error_event" +require_relative "imagekitio/models/upload_pre_transform_success_event" +require_relative "imagekitio/models/video_overlay" +require_relative "imagekitio/models/video_transformation_accepted_event" +require_relative "imagekitio/models/video_transformation_error_event" +require_relative "imagekitio/models/video_transformation_ready_event" +require_relative "imagekitio/models/webhook_unsafe_unwrap_params" +require_relative "imagekitio/models/webhook_unwrap_params" +require_relative "imagekitio/models" +require_relative "imagekitio/resources/accounts" +require_relative "imagekitio/resources/accounts/origins" +require_relative "imagekitio/resources/accounts/url_endpoints" +require_relative "imagekitio/resources/accounts/usage" +require_relative "imagekitio/resources/assets" +require_relative "imagekitio/resources/beta" +require_relative "imagekitio/resources/beta/v2" +require_relative "imagekitio/resources/beta/v2/files" +require_relative "imagekitio/resources/cache" +require_relative "imagekitio/resources/cache/invalidation" +require_relative "imagekitio/resources/custom_metadata_fields" +require_relative "imagekitio/resources/files" +require_relative "imagekitio/resources/files/bulk" +require_relative "imagekitio/resources/files/metadata" +require_relative "imagekitio/resources/files/versions" +require_relative "imagekitio/resources/folders" +require_relative "imagekitio/resources/folders/job" +require_relative "imagekitio/resources/webhooks" +require_relative "imagekitio/helpers/helper" diff --git a/lib/imagekitio/api_service/bulk.rb b/lib/imagekitio/api_service/bulk.rb deleted file mode 100644 index 2ee35f63..00000000 --- a/lib/imagekitio/api_service/bulk.rb +++ /dev/null @@ -1,58 +0,0 @@ -require_relative '../constant' - -module ImageKitIo - module ApiService - class Bulk - include Constantable - - def initialize(req_obj) - @req_obj = req_obj - end - - def job_status(job_id: nil) - if job_id == '' || job_id.nil? - raise ArgumentError, 'job_id is required' - end - url = "#{constants.BULK_BASE_URL}/#{job_id}" - payload = { 'jobId': job_id } - @req_obj.request('get', url, @req_obj.create_headers, payload) - end - - def add_tags(file_ids: [], tags: []) - if file_ids.empty? || tags.empty? - raise ArgumentError, 'Parameters are required' - end - url = "#{constants.BASE_URL}/addTags" - payload = { 'fileIds': file_ids, 'tags': tags }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def remove_tags(file_ids: [], tags: []) - if file_ids.empty? || tags.empty? - raise ArgumentError, 'Parameters are required' - end - url = "#{constants.BASE_URL}/removeTags" - payload = { 'fileIds': file_ids, 'tags': tags }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def remove_ai_tags(file_ids: [], ai_tags: []) - if file_ids.empty? || ai_tags.empty? - raise ArgumentError, 'Parameters are required' - end - url = "#{constants.BASE_URL}/removeAITags" - payload = { 'fileIds': file_ids, 'AITags': ai_tags }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def remove_files(file_ids: []) - if file_ids.empty? - raise ArgumentError, 'File ids are required' - end - url = "#{constants.BASE_URL}#{constants.BULK_FILE_DELETE}" - payload = {'fileIds': file_ids}.to_json - @req_obj.request("post", url, @req_obj.create_headers, payload) - end - end - end -end diff --git a/lib/imagekitio/api_service/custom_metadata_field.rb b/lib/imagekitio/api_service/custom_metadata_field.rb deleted file mode 100644 index 7bc213ad..00000000 --- a/lib/imagekitio/api_service/custom_metadata_field.rb +++ /dev/null @@ -1,52 +0,0 @@ -require_relative '../utils/option_validator' -require_relative '../constant' - -module ImageKitIo - module ApiService - class CustomMetadataField - include Utils::OptionValidator - include Constantable - - def initialize(req_obj) - @req_obj = req_obj - end - - def create(name: nil, label: nil, schema: nil) - if name == '' || name.nil? || label == '' || label.nil? || schema == '' || schema.nil? - raise ArgumentError, 'Parameters required' - end - unless schema.is_a?(Hash) - raise ArgumentError, 'Schema must be hash object' - end - url = "#{constants.API_BASE_URL}/customMetadataFields" - payload = { 'name': name, 'label': label, 'schema': schema }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def list(**options) - url = "#{constants.API_BASE_URL}/customMetadataFields" - payload = request_formatter(options || {}) - @req_obj.request('get', url, @req_obj.create_headers, payload) - end - - def update(id: nil, label: nil, schema: nil) - if id == '' || id.nil? - raise ArgumentError, 'id is required' - end - url = "#{constants.API_BASE_URL}/customMetadataFields/#{id}" - payload = {} - payload = payload.merge({ 'label': label }) unless label.nil? - payload = payload.merge({ 'schema': label }) unless schema.nil? - @req_obj.request('patch', url, @req_obj.create_headers, payload.to_json) - end - - def delete(id: nil) - if id == '' || id.nil? - raise ArgumentError, 'id is required' - end - url = "#{constants.API_BASE_URL}/customMetadataFields/#{id}" - @req_obj.request('delete', url, @req_obj.create_headers) - end - end - end -end diff --git a/lib/imagekitio/api_service/file.rb b/lib/imagekitio/api_service/file.rb deleted file mode 100644 index 986cd21a..00000000 --- a/lib/imagekitio/api_service/file.rb +++ /dev/null @@ -1,221 +0,0 @@ -# frozen_string_literal: true -require_relative '../constant' -require_relative '../utils/option_validator' -require 'net/http/post/multipart' - -module ImageKitIo - module ApiService - class File - include Utils::OptionValidator - include Constantable - - # This File class holds file related operations like - # upload, list etc - def initialize(req_obj) - @req_obj = req_obj - end - - # uploads files with required arguments, supports bot url and binary - # Options types: - # - `extensions` should be array of hash - # eg: option['extension'] = [ - # { 'name' => 'remove-bg', 'options' => { 'add_shadow' => 'true' } }, - # { 'name' => 'google-auto-tagging', 'minConfidence' => 80 } - # ] - # - `custom_metadata` should be hash - # eg: option['custom_metadata'] = { - # "SKU": "VS882HJ2JD", - # "price": 599.99, - # "brand": "H&M", - # "discount": 30 - # } - def upload(file: nil, file_name: nil, **options) - raise ArgumentError, constants.MISSING_UPLOAD_FILE_PARAMETER unless file - raise ArgumentError, constants.MISSING_UPLOAD_FILE_PARAMETER unless file_name - - content_type = options.delete(:content_type) || '' - options = format_to_json(options, :extensions, Array) - options = format_to_json(options, :custom_metadata, Hash) - options = format_to_json(options, :transformation, Hash) - options = validate_upload_options(options || {}) - if options.is_a?(FalseClass) - raise ArgumentError, "Invalid Upload option" - else - headers = @req_obj.create_headers - payload = { - multipart: true, - file: file.is_a?(String) ? file : ::UploadIO.new(file, content_type, file_name), - fileName: file_name - } - payload.merge!(options) - url = "#{constants.BASE_URL}#{constants.UPLOAD}" - @req_obj.request("post", url, headers, payload) - end - end - - def update_details(file_id: nil, **options) - unless options.fetch(:tags, []).is_a?(Array) - raise ArgumentError, constants.UPDATE_DATA_TAGS_INVALID - end - unless options.fetch(:custom_coordinates, "").is_a?(String) - raise ArgumentError, constants.UPDATE_DATA_COORDS_INVALID - end - url = "#{constants.BASE_URL}/#{file_id}/details/" - headers = @req_obj.create_headers - payload = request_formatter(options || {}) - @req_obj.request("patch", url, headers, payload.to_json) - end - - def list(**options) - # returns list of files on ImageKitIo Server - # :options dictionary of options - formatted_options = request_formatter(options || {}) - raise KeyError(constants.LIST_FILES_INPUT_MISSING) unless formatted_options.is_a?(Hash) - url = constants.BASE_URL - headers = @req_obj.create_headers.update({params: formatted_options}) - @req_obj.request("get", url, headers, formatted_options) - end - - def get_file_versions(file_id: nil) - if file_id == '' || file_id.nil? - raise ArgumentError, 'file_id is required' - end - url = "#{constants.BASE_URL}/#{file_id}/versions" - headers = @req_obj.create_headers - @req_obj.request('get', url, headers) - end - - def get_file_version_detail(file_id: nil, version_id: nil) - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - if version_id == "" || version_id.nil? - raise ArgumentError, "version_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}/versions/#{version_id}" - headers = @req_obj.create_headers - @req_obj.request('get', url, headers) - end - - def delete_file_version(file_id: nil, version_id: nil) - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - if version_id == "" || version_id.nil? - raise ArgumentError, "version_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}/versions/#{version_id}" - headers = @req_obj.create_headers - @req_obj.request('delete', url, headers) - end - - def restore_file_version(file_id: nil, version_id: nil) - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - if version_id == "" || version_id.nil? - raise ArgumentError, "version_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}/versions/#{version_id}/restore" - headers = @req_obj.create_headers - @req_obj.request('put', url, headers) - end - - def details(file_identifier: nil) - # Get detail of file by file_identifier - if file_identifier == "" || file_identifier.nil? - raise ArgumentError, "file_identifier is required" - end - url = "#{constants.BASE_URL}/#{file_identifier}/details/" - headers = @req_obj.create_headers - @req_obj.request("get", url, headers) - end - - def get_metadata(file_id: nil) - # Get metadata of a file by file_id - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}/metadata" - @req_obj.request("get", url, @req_obj.create_headers) - end - - def delete(file_id: nil) - # Delete a file_id by file_id - if file_id == "" || file_id.nil? - raise ArgumentError, "file_id is required" - end - url = "#{constants.BASE_URL}/#{file_id}" - headers = @req_obj.create_headers - @req_obj.request("delete", url, headers) - end - - def purge_cache(file_url: nil) - # purges cache from server by file_url - if file_url == "" || file_url.nil? - raise ArgumentError, "file_url is required" - end - url = "#{constants.BASE_URL}/purge" - payload = {'url': file_url} - @req_obj.request("post", url, @req_obj.create_headers, payload) - end - - def purge_cache_status(request_id: nil) - # This function is to get cache_status - if request_id == "" || request_id.nil? - raise ArgumentError, "remote_file_url is required" - end - url = "#{constants.BASE_URL}/purge/#{request_id}" - @req_obj.request("get", url, @req_obj.create_headers) - end - - def get_metadata_from_remote_url(remote_file_url: nil) - if remote_file_url == "" || remote_file_url.nil? - raise ArgumentError, "remote_file_url is required" - end - url = "#{constants.REMOTE_METADATA_FULL_URL}?url=#{remote_file_url}" - @req_obj.request("get", url, @req_obj.create_headers) - end - - def stream_file(remote_file_url: nil, &block) - if remote_file_url == '' || remote_file_url.nil? - raise ArgumentError, 'remote_file_url is required' - end - @req_obj.request_stream('get', remote_file_url, headers: @req_obj.create_headers, &block) - end - - def copy(source_file_path: nil, destination_path: nil, include_file_versions: false) - if source_file_path == '' || source_file_path.nil? || destination_path == '' || destination_path.nil? - raise ArgumentError, 'parameters required' - end - url = "#{constants.BASE_URL}/copy" - payload = { 'sourceFilePath': source_file_path, 'destinationPath': destination_path, 'includeFileVersions': include_file_versions }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def move(source_file_path: nil, destination_path: nil) - if source_file_path == '' || source_file_path.nil? || destination_path == '' || destination_path.nil? - raise ArgumentError, 'parameters required' - end - url = "#{constants.BASE_URL}/move" - payload = { 'sourceFilePath': source_file_path, 'destinationPath': destination_path } - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def rename(file_path: nil, new_file_name: nil, **options) - if file_path == '' || file_path.nil? || new_file_name == '' || new_file_name.nil? - raise ArgumentError, 'parameters required' - end - url = "#{constants.BASE_URL}/rename" - payload = { 'filePath': file_path, 'newFileName': new_file_name }.merge(request_formatter(options)).to_json - @req_obj.request('put', url, @req_obj.create_headers, payload) - end - - - private - def image_format?(type) - %(image/jpeg image/bmp image/apng image/avif image/gif image/ief image/svg+xml image/tiff image/x-icon image/rgb image/webp).include?(type) - end - end - end -end diff --git a/lib/imagekitio/api_service/folder.rb b/lib/imagekitio/api_service/folder.rb deleted file mode 100644 index 41bdb453..00000000 --- a/lib/imagekitio/api_service/folder.rb +++ /dev/null @@ -1,49 +0,0 @@ -require_relative '../constant' - -module ImageKitIo - module ApiService - class Folder - include Constantable - - def initialize(req_obj) - @req_obj = req_obj - end - - def create(folder_name: nil, parent_folder_path: nil) - if folder_name == '' || folder_name.nil? - raise ArgumentError, 'folder_name is required' - end - url = "#{constants.API_BASE_URL}/folder" - payload = { 'folderName': folder_name, 'parentFolderPath': parent_folder_path }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def delete(folder_path: nil) - if folder_path == '' || folder_path.nil? - raise ArgumentError, 'folder_path is required' - end - url = "#{constants.API_BASE_URL}/folder" - payload = { 'folderPath': folder_path } - @req_obj.request('delete', url, @req_obj.create_headers, payload) - end - - def copy(source_folder_path: nil, destination_path: nil, include_file_versions: false) - if source_folder_path == '' || source_folder_path.nil? || destination_path == '' || destination_path.nil? - raise ArgumentError, 'Parameters required' - end - url = "#{constants.BULK_BASE_URL}/copyFolder" - payload = { 'sourceFolderPath': source_folder_path, 'destinationPath': destination_path, 'includeFileVersions': include_file_versions }.to_json - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - - def move(source_folder_path: nil, destination_path: nil) - if source_folder_path == '' || source_folder_path.nil? || destination_path == '' || destination_path.nil? - raise ArgumentError, 'Parameters required' - end - url = "#{constants.BULK_BASE_URL}/moveFolder" - payload = { 'sourceFolderPath': source_folder_path, 'destinationPath': destination_path } - @req_obj.request('post', url, @req_obj.create_headers, payload) - end - end - end -end diff --git a/lib/imagekitio/base.rb b/lib/imagekitio/base.rb deleted file mode 100644 index 162e89ef..00000000 --- a/lib/imagekitio/base.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative './configurable' - -module ImageKitIo - include ImageKitIo::Configurable - - class << self - def client - ik_config = config - @client ||= ImageKitIo::Client.new(ik_config.private_key, ik_config.public_key, ik_config.url_endpoint) - end - end -end diff --git a/lib/imagekitio/client.rb b/lib/imagekitio/client.rb index 3c2b7851..3f5b787b 100644 --- a/lib/imagekitio/client.rb +++ b/lib/imagekitio/client.rb @@ -1,202 +1,129 @@ # frozen_string_literal: true -$VERBOSE = nil - -require_relative "./request" -require_relative "./url" -require_relative "./utils/calculation" -require_relative './constant' -require_relative './configurable' -require_relative './api_service/custom_metadata_field' -require_relative './api_service/folder' -require_relative './api_service/file' -require_relative './api_service/bulk' - -module ImageKitIo - # ImageKitIo class holds each method will be used by user - class Client - include Utils::Calculation - include Constantable - - attr_reader :file_service, :custom_metadata_field_service, :folder_service, :bulk_service - - def initialize(private_key, public_key, url_endpoint, transformation_pos = nil, options = nil) - unless(private_key.is_a?(String) && private_key.to_s.strip.length != 0) - raise ArgumentError, constants.MISSING_PRIVATE_KEY +module Imagekitio + class Client < Imagekitio::Internal::Transport::BaseClient + # Default max number of retries to attempt after a failed retryable request. + DEFAULT_MAX_RETRIES = 2 + + # Default per-request timeout. + DEFAULT_TIMEOUT_IN_SECONDS = 60.0 + + # Default initial retry delay in seconds. + # Overall delay is calculated using exponential backoff + jitter. + DEFAULT_INITIAL_RETRY_DELAY = 0.5 + + # Default max retry delay in seconds. + DEFAULT_MAX_RETRY_DELAY = 8.0 + + # Your ImageKit private API key (starts with `private_`). You can find this in the + # [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + # @return [String] + attr_reader :private_key + + # ImageKit uses your API key as username and ignores the password. The SDK sets a + # dummy value. You can ignore this field. + # @return [String, nil] + attr_reader :password + + # @return [Imagekitio::Resources::CustomMetadataFields] + attr_reader :custom_metadata_fields + + # @return [Imagekitio::Resources::Files] + attr_reader :files + + # @return [Imagekitio::Resources::Assets] + attr_reader :assets + + # @return [Imagekitio::Resources::Cache] + attr_reader :cache + + # @return [Imagekitio::Resources::Folders] + attr_reader :folders + + # @return [Imagekitio::Resources::Accounts] + attr_reader :accounts + + # @return [Imagekitio::Resources::Beta] + attr_reader :beta + + # @return [Imagekitio::Resources::Webhooks] + attr_reader :webhooks + + # @return [Imagekitio::Helper] + attr_reader :helper + + # @api private + # + # @return [Hash{String=>String}] + private def auth_headers + return {} if @private_key.nil? || @password.nil? + + base64_credentials = ["#{@private_key}:#{@password}"].pack("m0") + {"authorization" => "Basic #{base64_credentials}"} + end + + # @api private + # + # @return [Boolean] + def base_url_overridden? = @base_url_overridden + + # Creates and returns a new client for interacting with the API. + # + # @param private_key [String, nil] Your ImageKit private API key (starts with `private_`). You can find this in the + # [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). Defaults + # to `ENV["IMAGEKIT_PRIVATE_KEY"]` + # + # @param password [String, nil] ImageKit uses your API key as username and ignores the password. The SDK sets a + # dummy value. You can ignore this field. Defaults to + # `ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"]` + # + # @param base_url [String, nil] Override the default base URL for the API, e.g., + # `"https://api.example.com/v2/"`. Defaults to `ENV["IMAGE_KIT_BASE_URL"]` + # + # @param max_retries [Integer] Max number of retries to attempt after a failed retryable request. + # + # @param timeout [Float] + # + # @param initial_retry_delay [Float] + # + # @param max_retry_delay [Float] + def initialize( + private_key: ENV["IMAGEKIT_PRIVATE_KEY"], + password: ENV.fetch("OPTIONAL_IMAGEKIT_IGNORES_THIS", "do_not_set"), + base_url: ENV["IMAGE_KIT_BASE_URL"], + max_retries: self.class::DEFAULT_MAX_RETRIES, + timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, + initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, + max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY + ) + @base_url_overridden = !base_url.nil? + + base_url ||= "https://api.imagekit.io" + + if private_key.nil? || private_key.to_s.empty? + raise ArgumentError.new("private_key is required, and can be set via environ: \"IMAGEKIT_PRIVATE_KEY\"") end - unless(public_key.is_a?(String) && public_key.to_s.strip.length != 0) - raise ArgumentError, constants.MISSING_PUBLIC_KEY - end - unless(url_endpoint.is_a?(String) && url_endpoint.to_s.strip.length != 0) - raise ArgumentError, constants.MISSING_URL_ENDPOINT - end - - @private_key = private_key - @public_key = public_key - @url_endpoint = url_endpoint - @transformation_position = transformation_pos - @options = options - - @ik_req = Request.new(private_key, public_key, url_endpoint) - @url_obj = Url.new(@ik_req) - @file_service = ApiService::File.new(@ik_req) - @custom_metadata_field_service = ApiService::CustomMetadataField.new(@ik_req) - @folder_service = ApiService::Folder.new(@ik_req) - @bulk_service = ApiService::Bulk.new(@ik_req) - end - - def set_ik_request(ik_req) - # setter for imagekit request mainly will be used for - # test - @ik_req = ik_req - end - - def url(options = {}) - @url_obj.generate_url(options) - end - - def upload_file(file: nil, file_name: nil, **options) - # upload file to imagekit server - @file_service.upload(file: file, file_name: file_name, **options) - end - - def list_files(options = {}) - # list all files - @file_service.list(**options) - end - - def file_versions(file_id: nil) - @file_service.get_file_versions(file_id: file_id) - end - - def file_version_detail(file_id: nil, version_id: nil) - @file_service.get_file_version_detail(file_id: file_id, version_id: version_id) - end - - def delete_file_version(file_id: nil, version_id: nil) - @file_service.delete_file_version(file_id: file_id, version_id: version_id) - end - - def restore_file_version(file_id: nil, version_id: nil) - @file_service.restore_file_version(file_id: file_id, version_id: version_id) - end - - def get_file_details(file_id: nil) - # Get file detail by file-id or file_url - @file_service.details(file_identifier: file_id) - end - - def update_file_details(file_id: nil, **options) - # update file details by file id and other options payload - @file_service.update_details(file_id: file_id, **options) - end - - def delete_file(file_id: nil) - # Delete a file by file-id - @file_service.delete(file_id: file_id) - end - - def get_file_metadata(file_id: nil) - # Get metadata of a file by file-id - @file_service.get_metadata(file_id: file_id) - end - - def purge_file_cache(file_url: nil) - # Purge cache from ImageKitIo server by file_url - @file_service.purge_cache(file_url: file_url) - end - - def purge_file_cache_status(request_id: nil) - @file_service.purge_cache_status(request_id: request_id.to_s) - end - - # Get metadata from remote_file_url - # param remote_file_url: url string of remote file - def get_remote_file_url_metadata(remote_file_url: "") - @file_service.get_metadata_from_remote_url(remote_file_url: remote_file_url) - end - - def stream_file(file_url: nil, &block) - @file_service.stream_file(remote_file_url: file_url, &block) - end - - def copy_file(source_file_path: nil, destination_path: nil, include_file_versions: false) - @file_service.copy(source_file_path: source_file_path, destination_path: destination_path, include_file_versions: include_file_versions) - end - - def move_file(source_file_path: nil, destination_path: nil) - @file_service.move(source_file_path: source_file_path, destination_path: destination_path) - end - - def rename_file(file_path: nil, new_file_name: nil, **options) - @file_service.rename(file_path: file_path, new_file_name: new_file_name, **options) - end - - def add_bulk_tags(file_ids: [], tags: []) - @bulk_service.add_tags(file_ids: file_ids, tags: tags) - end - - def delete_bulk_files(file_ids: []) - # Delete file in bulks by list of file id - @bulk_service.remove_files(file_ids: file_ids) - end - - def delete_bulk_tags(file_ids: [], tags: []) - @bulk_service.remove_tags(file_ids: file_ids, tags: tags) - end - - def delete_bulk_ai_tags(file_ids: [], ai_tags: []) - @bulk_service.remove_ai_tags(file_ids: file_ids, ai_tags: ai_tags) - end - - def bulk_job_status(job_id: nil) - @bulk_service.job_status(job_id: job_id) - end - - def create_folder(folder_name: nil, parent_folder_path: "/") - @folder_service.create(folder_name: folder_name, parent_folder_path: parent_folder_path) - end - - def delete_folder(folder_path: nil) - @folder_service.delete(folder_path: folder_path) - end - - def copy_folder(source_folder_path: nil, destination_path: nil, include_file_versions: false) - @folder_service.copy(source_folder_path: source_folder_path, destination_path: destination_path, include_file_versions: include_file_versions) - end - - def move_folder(source_folder_path: nil, destination_path: nil) - @folder_service.move(source_folder_path: source_folder_path, destination_path: destination_path) - end - - def create_custom_metadata_field(name: nil, label: nil, schema: {}) - @custom_metadata_field_service.create(name: name, label: label, schema: schema) - end - - def get_custom_metadata_fields(options = {}) - @custom_metadata_field_service.list(**options) - end - - def update_custom_metadata_field(id: nil, label: nil, schema: nil) - @custom_metadata_field_service.update(id: id, label: label, schema: schema) - end - - def delete_custom_metadata_field(id: nil) - @custom_metadata_field_service.delete(id: id) - end - - def phash_distance(first, second) - # Get hamming distance between two phash(image hash) to check - # similarity between images - if first.to_s.strip == "" || second.to_s.strip == "" - raise ArgumentError, constants.MISSING_PHASH_VALUE - end - hamming_distance(first, second) - end - def get_authentication_parameters(token = nil, expire = nil) - # Get Authentication params - get_authenticated_params(token, expire, @ik_req.private_key) + @private_key = private_key.to_s + @password = password.to_s + + super( + base_url: base_url, + timeout: timeout, + max_retries: max_retries, + initial_retry_delay: initial_retry_delay, + max_retry_delay: max_retry_delay + ) + + @custom_metadata_fields = Imagekitio::Resources::CustomMetadataFields.new(client: self) + @files = Imagekitio::Resources::Files.new(client: self) + @assets = Imagekitio::Resources::Assets.new(client: self) + @cache = Imagekitio::Resources::Cache.new(client: self) + @folders = Imagekitio::Resources::Folders.new(client: self) + @accounts = Imagekitio::Resources::Accounts.new(client: self) + @beta = Imagekitio::Resources::Beta.new(client: self) + @webhooks = Imagekitio::Resources::Webhooks.new(client: self) + @helper = Imagekitio::Helper.new(client: self) end end end diff --git a/lib/imagekitio/configurable.rb b/lib/imagekitio/configurable.rb deleted file mode 100644 index 98db3414..00000000 --- a/lib/imagekitio/configurable.rb +++ /dev/null @@ -1,43 +0,0 @@ -module ImageKitIo - module Configurable - def self.included(klass) - klass.extend ClassMethods - end - - module ClassMethods - def config - @config ||= Configuration.new - end - - def configure - yield config - initialize_service - end - - def initialize_service - if config.service == :carrierwave - require_relative '../carrierwave/carrierwave' - elsif config.service == :active_storage - require_relative '../active_storage/active_storage' - end - end - - def constants - config.constants - end - end - - class Configuration - AVAILABLE_SERVICE = [:carrierwave, :active_storage] - attr_accessor :public_key, :private_key, :url_endpoint, :service - - def service - @service&.to_sym || :carrierwave - end - - def constants - @constants ||= ImageKitIo::Constant - end - end - end -end diff --git a/lib/imagekitio/constant.rb b/lib/imagekitio/constant.rb deleted file mode 100644 index 21fa44a7..00000000 --- a/lib/imagekitio/constant.rb +++ /dev/null @@ -1,36 +0,0 @@ -require_relative './constants/default' -require_relative './constants/error' -require_relative './constants/file' -require_relative './constants/supported_transformation' -require_relative './constants/url' -require_relative './configurable' - -module ImageKitIo - module Constantable - def self.included(base) - def constants - ImageKitIo.constants - end - end - end - class Constant - include Constants::Default - include Constants::Error - include Constants::File - include Constants::SupportedTransformation - include Constants::URL - - class << self - def method_missing(symbol, *args) - method_name = symbol.to_s.gsub('=', '') - if self.const_defined? method_name - return self.const_get(method_name) if args.empty? - - self.const_set(method_name, args.first) - else - super - end - end - end - end -end diff --git a/lib/imagekitio/constants/default.rb b/lib/imagekitio/constants/default.rb deleted file mode 100644 index 34d9345e..00000000 --- a/lib/imagekitio/constants/default.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# Enum for defaults -module ImageKitIo - module Constants - module Default - TRANSFORMATION_POSITION = "path" - QUERY_TRANSFORMATION_POSITION = "query" - VALID_TRANSFORMATION_POSITION = [TRANSFORMATION_POSITION, - QUERY_TRANSFORMATION_POSITION,].freeze - DEFAULT_TIMESTAMP = "9999999999" - TRANSFORMATION_PARAMETER = "tr" - CHAIN_TRANSFORM_DELIMITER = ":" - TRANSFORM_DELIMITER = "," - TRANSFORM_KEY_VALUE_DELIMITER = "-" - - SIGNATURE_PARAMETER = "ik-s" - TIMESTAMP_PARAMETER = "ik-t" - TIMESTAMP = "9999999999" - end - end -end diff --git a/lib/imagekitio/constants/error.rb b/lib/imagekitio/constants/error.rb deleted file mode 100644 index 49c8f429..00000000 --- a/lib/imagekitio/constants/error.rb +++ /dev/null @@ -1,69 +0,0 @@ -module ImageKitIo - module Constants - module Error - MANDATORY_INIT_MISSING = { - 'message': "Missing public_key or private_key or url_endpoint during ImageKitIo initialization", - help: "", - } - INVALID_TRANSFORMATION_POS = {'message': "Invalid transformationPosition parameter", - help: "",} - INVALID_URL_GENERATION_PARAM = {'message': "Invalid url parameter", help: ""} - INVALID_TRANSFORMATION_OPTIONS = { - 'message': "Invalid transformation parameter options", - help: "", - } - CACHE_PURGE_URL_MISSING = {'message': "Missing URL parameter for this request", - help: "",} - CACHE_PURGE_STATUS_ID_MISSING = {'message': "Missing Request ID parameter for this request", - help: "",} - FILE_ID_MISSING = {'message': "Missing File ID parameter for this request", - help: "",} - UPDATE_DATA_MISSING = {'message': "Missing file update data for this request", - help: "",} - - UPDATE_DATA_TAGS_INVALID = {'message': "Invalid tags parameter for this request", - help: "tags should be passed as null or an array like ['tag1', 'tag2']",}.freeze - - UPDATE_DATA_COORDS_INVALID = - {'message': "Invalid custom_coordinates parameter for this request", - help: "custom_coordinates should be passed as null or a string like 'x,y,width,height'",} - - 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", - } - MISSING_FILE_URL = {'message': "Missing file_url for purge_cache", help: ""} - MISSING_UPLOAD_DATA = {'message': "Missing data for upload", help: ""} - MISSING_UPLOAD_FILE_PARAMETER = { - 'message': "Missing file parameter for upload", - help: "", - } - MISSING_UPLOAD_FILENAME_PARAM = { - 'message': "Missing fileName parameter for upload", - help: "", - } - - INVALID_PHASH_VALUE = - { - 'message': "Invalid pHash value", - help: "Both pHash strings must be valid hexadecimal numbers", - } - - MISSING_PHASH_VALUE = { - 'message': "Missing pHash value", - help: "Please pass two pHash values", - } - UNEQUAL_STRING_LENGTH = { - '': "Unequal pHash string length", - help: "For distance calculation, the two pHash strings must have equal length", - } - - MISSING_PRIVATE_KEY = "ImageKitIo private key missing" - - MISSING_PUBLIC_KEY = "ImageKitIo public key missing" - - MISSING_URL_ENDPOINT = "ImageKitIo URL Endpoint missing. Default URL Endpoint: https://ik.imagekit.io//" - - end - end -end diff --git a/lib/imagekitio/constants/file.rb b/lib/imagekitio/constants/file.rb deleted file mode 100644 index 3af374dc..00000000 --- a/lib/imagekitio/constants/file.rb +++ /dev/null @@ -1,11 +0,0 @@ -module ImageKitIo - module Constants - module File - VALID_FILE_OPTIONS = %w[path fileType tags includeFolder name limit skip] - - VALID_FILE_DETAIL_OPTIONS = ["fileID"] - - VALID_UPLOAD_OPTIONS = %w[file file_name use_unique_file_name tags folder is_private_file custom_coordinates response_fields extensions webhook_url overwrite_file overwrite_AI_tags overwrite_custom_metadata custom_metadata mime overwrite_tags content_type transformation checks is_published] - end - end -end diff --git a/lib/imagekitio/constants/supported_transformation.rb b/lib/imagekitio/constants/supported_transformation.rb deleted file mode 100644 index c8158b6f..00000000 --- a/lib/imagekitio/constants/supported_transformation.rb +++ /dev/null @@ -1,39 +0,0 @@ -module ImageKitIo - module Constants - module SupportedTransformation - SUPPORTED_TRANS = { - 'height': "h", - 'width': "w", - 'aspect_ratio': "ar", - 'quality': "q", - 'crop': "c", - 'crop_mode': "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", - 'color_profile': "cp", - 'default_image': "di", - 'dpr': "dpr", - 'effect_sharpen': "e-sharpen", - 'effect_usm': "e-usm", - 'effect_contrast': "e-contrast", - 'effect_gray': "e-grayscale", - 'effect_shadow': "e-shadow", - 'effect_gradient': "e-gradient", - 'original': "orig", - 'raw': 'raw', - } - end - end -end diff --git a/lib/imagekitio/constants/url.rb b/lib/imagekitio/constants/url.rb deleted file mode 100644 index 5b02252f..00000000 --- a/lib/imagekitio/constants/url.rb +++ /dev/null @@ -1,14 +0,0 @@ -module ImageKitIo - module Constants - module URL - # Default URL Constants - BASE_URL = "https://api.imagekit.io/v1/files" - PURGE_CACHE = "/purge" - BULK_FILE_DELETE = "/batch/deleteByFileIds" - UPLOAD = "/upload" - REMOTE_METADATA_FULL_URL = "https://api.imagekit.io/v1/metadata" - BULK_BASE_URL = 'https://api.imagekit.io/v1/bulkJobs' - API_BASE_URL = 'https://api.imagekit.io/v1' - end - end -end diff --git a/lib/imagekitio/errors.rb b/lib/imagekitio/errors.rb index eeac14de..ae3d200b 100644 --- a/lib/imagekitio/errors.rb +++ b/lib/imagekitio/errors.rb @@ -1,4 +1,228 @@ -module ImageKitIo - class Error < StandardError +# frozen_string_literal: true + +module Imagekitio + module Errors + class Error < StandardError + # @!attribute cause + # + # @return [StandardError, nil] + end + + class ConversionError < Imagekitio::Errors::Error + # @return [StandardError, nil] + def cause = @cause.nil? ? super : @cause + + # @api private + # + # @param on [Class] + # @param method [Symbol] + # @param target [Object] + # @param value [Object] + # @param cause [StandardError, nil] + def initialize(on:, method:, target:, value:, cause: nil) + cls = on.name.split("::").last + + message = [ + "Failed to parse #{cls}.#{method} from #{value.class} to #{target.inspect}.", + "To get the unparsed API response, use #{cls}[#{method.inspect}].", + cause && "Cause: #{cause.message}" + ].filter(&:itself).join(" ") + + @cause = cause + super(message) + end + end + + class APIError < Imagekitio::Errors::Error + # @return [URI::Generic] + attr_accessor :url + + # @return [Integer, nil] + attr_accessor :status + + # @return [Hash{String=>String}, nil] + attr_accessor :headers + + # @return [Object, nil] + attr_accessor :body + + # @api private + # + # @param url [URI::Generic] + # @param status [Integer, nil] + # @param headers [Hash{String=>String}, nil] + # @param body [Object, nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + def initialize(url:, status: nil, headers: nil, body: nil, request: nil, response: nil, message: nil) + @url = url + @status = status + @headers = headers + @body = body + @request = request + @response = response + super(message) + end + end + + class APIConnectionError < Imagekitio::Errors::APIError + # @!attribute status + # + # @return [nil] + + # @!attribute body + # + # @return [nil] + + # @api private + # + # @param url [URI::Generic] + # @param status [nil] + # @param headers [Hash{String=>String}, nil] + # @param body [nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + def initialize( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: "Connection error." + ) + super + end + end + + class APITimeoutError < Imagekitio::Errors::APIConnectionError + # @api private + # + # @param url [URI::Generic] + # @param status [nil] + # @param headers [Hash{String=>String}, nil] + # @param body [nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + def initialize( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: "Request timed out." + ) + super + end + end + + class APIStatusError < Imagekitio::Errors::APIError + # @api private + # + # @param url [URI::Generic] + # @param status [Integer] + # @param headers [Hash{String=>String}, nil] + # @param body [Object, nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + # + # @return [self] + def self.for(url:, status:, headers:, body:, request:, response:, message: nil) + kwargs = + { + url: url, + status: status, + headers: headers, + body: body, + request: request, + response: response, + message: message + } + + case status + in 400 + Imagekitio::Errors::BadRequestError.new(**kwargs) + in 401 + Imagekitio::Errors::AuthenticationError.new(**kwargs) + in 403 + Imagekitio::Errors::PermissionDeniedError.new(**kwargs) + in 404 + Imagekitio::Errors::NotFoundError.new(**kwargs) + in 409 + Imagekitio::Errors::ConflictError.new(**kwargs) + in 422 + Imagekitio::Errors::UnprocessableEntityError.new(**kwargs) + in 429 + Imagekitio::Errors::RateLimitError.new(**kwargs) + in (500..) + Imagekitio::Errors::InternalServerError.new(**kwargs) + else + Imagekitio::Errors::APIStatusError.new(**kwargs) + end + end + + # @!parse + # # @return [Integer] + # attr_accessor :status + + # @api private + # + # @param url [URI::Generic] + # @param status [Integer] + # @param headers [Hash{String=>String}, nil] + # @param body [Object, nil] + # @param request [nil] + # @param response [nil] + # @param message [String, nil] + def initialize(url:, status:, headers:, body:, request:, response:, message: nil) + message ||= {url: url.to_s, status: status, body: body} + super( + url: url, + status: status, + headers: headers, + body: body, + request: request, + response: response, + message: message&.to_s + ) + end + end + + class BadRequestError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 400 + end + + class AuthenticationError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 401 + end + + class PermissionDeniedError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 403 + end + + class NotFoundError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 404 + end + + class ConflictError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 409 + end + + class UnprocessableEntityError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 422 + end + + class RateLimitError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 429 + end + + class InternalServerError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = (500..) + end end end diff --git a/lib/imagekitio/file_part.rb b/lib/imagekitio/file_part.rb new file mode 100644 index 00000000..2856bd88 --- /dev/null +++ b/lib/imagekitio/file_part.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +module Imagekitio + class FilePart + # @return [Pathname, StringIO, IO, String] + attr_reader :content + + # @return [String, nil] + attr_reader :content_type + + # @return [String, nil] + attr_reader :filename + + # @api private + # + # @return [String] + private def read + case content + in Pathname + content.read(binmode: true) + in StringIO + content.string + in IO + content.read + in String + content + end + end + + # @param a [Object] + # + # @return [String] + def to_json(*a) = read.to_json(*a) + + # @param a [Object] + # + # @return [String] + def to_yaml(*a) = read.to_yaml(*a) + + # @param content [Pathname, StringIO, IO, String] + # @param filename [Pathname, String, nil] + # @param content_type [String, nil] + def initialize(content, filename: nil, content_type: nil) + @content_type = content_type + @filename = + case [filename, (@content = content)] + in [String | Pathname, _] + ::File.basename(filename) + in [nil, Pathname] + content.basename.to_path + in [nil, IO] + content.to_path + else + filename + end + end + end +end diff --git a/lib/imagekitio/helpers/crypto_utils.rb b/lib/imagekitio/helpers/crypto_utils.rb new file mode 100644 index 00000000..1d0be449 --- /dev/null +++ b/lib/imagekitio/helpers/crypto_utils.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require "openssl" +require "digest" + +module Imagekitio + # @api private + # Crypto utilities for ImageKit SDK + # Provides HMAC-SHA1 functionality for URL signing and authentication + module CryptoUtils + class << self + # Creates an HMAC-SHA1 hash + # + # @param key [String] The secret key for HMAC generation + # @param data [String] The data to be signed + # @return [String] Hex-encoded HMAC-SHA1 hash + # @raise [StandardError] if HMAC generation fails + def create_hmac_sha1(key, data) + OpenSSL::HMAC.hexdigest("SHA1", key, data) + rescue StandardError => e + raise StandardError, "Failed to generate HMAC-SHA1 signature: #{e.message}" + end + end + end +end diff --git a/lib/imagekitio/helpers/helper.rb b/lib/imagekitio/helpers/helper.rb new file mode 100644 index 00000000..2da2f3c9 --- /dev/null +++ b/lib/imagekitio/helpers/helper.rb @@ -0,0 +1,689 @@ +# frozen_string_literal: true + +require_relative "transformation_utils" +require_relative "crypto_utils" +require_relative "uuid_utils" + +module Imagekitio + class Helper + TRANSFORMATION_PARAMETER = "tr" + SIGNATURE_PARAMETER = "ik-s" + TIMESTAMP_PARAMETER = "ik-t" + DEFAULT_TIMESTAMP = 9_999_999_999 + SIMPLE_OVERLAY_PATH_REGEX = %r{^[a-zA-Z0-9\-._/ ]*$} + SIMPLE_OVERLAY_TEXT_REGEX = /^[a-zA-Z0-9\-._ ]*$/ + + private_constant :TRANSFORMATION_PARAMETER, + :SIGNATURE_PARAMETER, + :TIMESTAMP_PARAMETER, + :DEFAULT_TIMESTAMP, + :SIMPLE_OVERLAY_PATH_REGEX, + :SIMPLE_OVERLAY_TEXT_REGEX + + # Builds a URL with transformations applied + # + # @param options [Imagekitio::Models::SrcOptions] Options for generating ImageKit URLs with transformations + # @return [String] The built URL with transformations + def build_url(options) + # Convert model to hash - all inputs are expected to be BaseModel objects + opts = options.to_h + + # Set defaults + opts[:url_endpoint] ||= "" + opts[:src] ||= "" + opts[:transformation_position] ||= :query + + return "" if opts[:src].nil? || opts[:src].empty? + + src = opts[:src].to_s + is_absolute_url = src.start_with?("http://", "https://") + + begin + if is_absolute_url + url_obj = URI.parse(src) + is_src_parameter_used_for_url = true + else + url_obj = URI.parse(opts[:url_endpoint].to_s) + end + rescue URI::InvalidURIError + return "" + end + + # Add query parameters + query_params = opts[:query_parameters] || {} + existing_params = CGI.parse(url_obj.query || "") + query_params.each do |key, value| + existing_params[key.to_s] = [value.to_s] + end + + # Build transformation string + transformation_string = build_transformation_string(opts[:transformation]) + + add_as_query = Imagekitio::TransformationUtils.add_as_query_parameter?(opts) || + is_src_parameter_used_for_url + transformation_placeholder = "PLEASEREPLACEJUSTBEFORESIGN" + + unless is_absolute_url + # For non-absolute URLs, construct the path + endpoint_path = url_obj.path + path_parts = [] + + # Add endpoint path if it's not empty + if !endpoint_path.empty? && endpoint_path != "/" + path_parts << endpoint_path + end + + if !transformation_string.empty? && !add_as_query + path_parts << "#{TRANSFORMATION_PARAMETER}#{Imagekitio::TransformationUtils.get_chain_transform_delimiter}#{transformation_placeholder}" + end + + path_parts << src + url_obj.path = path_join(path_parts) + end + + # Build query string + unless existing_params.empty? + url_obj.query = existing_params.map { |k, v| "#{CGI.escape(k)}=#{CGI.escape(v.first)}" }.join("&") + end + + # Build final URL + final_url = url_obj.to_s + + # Add transformation parameter manually to avoid URL encoding + if !transformation_string.empty? && add_as_query + separator = url_obj.query && !url_obj.query.empty? ? "&" : "?" + final_url = "#{final_url}#{separator}#{TRANSFORMATION_PARAMETER}=#{transformation_placeholder}" + end + + # Replace placeholder with actual transformation string + unless transformation_string.empty? + final_url = final_url.gsub(transformation_placeholder, transformation_string) + end + + # Sign the URL if needed + if opts[:signed] == true || (opts[:expires_in] && opts[:expires_in].to_i.positive?) + expiry_timestamp = get_signature_timestamp(opts[:expires_in]) + + url_signature = get_signature( + private_key: @client.private_key, + url: final_url, + url_endpoint: opts[:url_endpoint].to_s, + expiry_timestamp: expiry_timestamp + ) + + # Add signature parameters + final_url_uri = URI.parse(final_url) + has_existing_params = final_url_uri.query && !final_url_uri.query.empty? + separator = has_existing_params ? "&" : "?" + + if expiry_timestamp && expiry_timestamp != DEFAULT_TIMESTAMP + final_url = "#{final_url}#{separator}#{TIMESTAMP_PARAMETER}=#{expiry_timestamp}" + final_url = "#{final_url}&#{SIGNATURE_PARAMETER}=#{url_signature}" + else + final_url = "#{final_url}#{separator}#{SIGNATURE_PARAMETER}=#{url_signature}" + end + end + + final_url + end + + # Generates transformation string from transformation objects + # + # @param transformations [Array] Array of transformation objects + # @return [String] The transformation string (e.g., "w-400,h-300") + def build_transformation_string(transformations) + return "" unless transformations.is_a?(Array) + + parsed_transforms = [] + + # rubocop:disable Metrics/BlockLength + transformations.each do |transform| + next unless transform + + # Convert model to hash - all transformation inputs are expected to be BaseModel objects + current_transform = transform.to_h + + parsed_transform_step = [] + + # rubocop:disable Metrics/BlockLength + current_transform.each do |key, value| + next if value.nil? || value.to_s.empty? + + # Handle overlay separately + if key.to_s == "overlay" && value + # Pass model object directly to process_overlay + raw_string = process_overlay(value) + if raw_string && !raw_string.strip.empty? + parsed_transform_step << raw_string + end + next + end + + transform_key = Imagekitio::TransformationUtils.get_transform_key(key) + transform_key = key.to_s if transform_key.empty? + + next if transform_key.empty? + + # Handle special boolean effects + boolean_effects = %w[e-grayscale e-contrast e-removedotbg e-bgremove e-upscale e-retouch e-genvar] + if boolean_effects.include?(transform_key) + if value == true || value == "-" || value == "true" + parsed_transform_step << transform_key + end + next + end + + # Handle effects that can be boolean or have values + value_effects = %w[e-sharpen e-shadow e-gradient e-usm e-dropshadow] + if value_effects.include?(transform_key) && + (value.to_s.strip.empty? || value == true || value == "true") + parsed_transform_step << transform_key + next + end + + # Handle raw parameter + if key.to_s == "raw" + parsed_transform_step << value.to_s + next + end + + # Handle special cases for di and ff (need special encoding) + if %w[di ff].include?(transform_key) + processed_value = remove_leading_slash(remove_trailing_slash(value.to_s)) + processed_value = processed_value.gsub("/", "@@") + value = processed_value + end + + # Handle streaming resolutions array + if transform_key == "sr" && value.is_a?(Array) + value = value.join("_") + end + + # Special case for trim with empty string + if transform_key == "t" && value.to_s.strip.empty? + value = "true" + end + + # Convert numeric values to integers if they're whole numbers + if value.is_a?(Numeric) + value = value.to_i if value == value.to_i + end + + parsed_transform_step << "#{transform_key}#{Imagekitio::TransformationUtils.get_transform_key_value_delimiter}#{value}" + end + # rubocop:enable Metrics/BlockLength + + unless parsed_transform_step.empty? + parsed_transforms << parsed_transform_step.join(Imagekitio::TransformationUtils.get_transform_delimiter) + end + end + # rubocop:enable Metrics/BlockLength + + parsed_transforms.join(Imagekitio::TransformationUtils.get_chain_transform_delimiter) + end + + # Generates authentication parameters for client-side file uploads using ImageKit's Upload API V1. + # + # This method creates the required authentication signature that allows secure file uploads + # directly from the browser or mobile applications without exposing your private API key. + # The generated parameters include a unique token, expiration timestamp, and HMAC signature. + # + # @param token [String, nil] Custom token for the upload session. If not provided, a UUID v4 will be generated automatically. + # @param expire [Integer, nil] Expiration time in seconds from now. If not provided, defaults to 1800 seconds (30 minutes). + # @return [Hash{Symbol => String, Integer}] Authentication parameters object containing: + # - :token (String): Unique identifier for this upload session + # - :expire (Integer): Unix timestamp when these parameters expire + # - :signature (String): HMAC-SHA1 signature for authenticating the upload + def get_authentication_parameters(token: nil, expire: nil) + default_time_diff = 60 * 30 + default_expire = Time.now.to_i + default_time_diff + + # Handle falsy values - empty string and nil should generate new token + final_token = token.nil? || token.to_s.empty? ? generate_token : token + # Handle falsy values - nil and 0 should use default expire + final_expire = expire.nil? || expire.zero? ? default_expire : expire + + get_authentication_parameters_internal(final_token, final_expire, @client.private_key) + end + + # Generates responsive image attributes for use in HTML tags. + # + # This method creates optimized srcset and sizes attributes for responsive images, + # enabling browsers to select the most appropriate image size based on the device's + # screen width and resolution. Supports three strategies: + # - Width-based (w descriptors): When sizes attribute is provided + # - DPR-based (x descriptors): When width is provided without sizes + # - Fallback (w descriptors): Uses device breakpoints when neither is provided + # + # @param options [Imagekitio::Models::GetImageAttributesOptions] Options for generating responsive image attributes + # @return [Imagekitio::Models::ResponsiveImageAttributes] Responsive image attributes suitable for an HTML element + def get_responsive_image_attributes(options) + # Convert model to hash for easier access + opts = options.is_a?(Imagekitio::Internal::Type::BaseModel) ? options.to_h : options + + # Default breakpoint pools + default_device_breakpoints = [640, 750, 828, 1080, 1200, 1920, 2048, 3840] + default_image_breakpoints = [16, 32, 48, 64, 96, 128, 256, 384] + + # Extract options + src = opts[:src] + url_endpoint = opts[:url_endpoint] + width = opts[:width] + sizes = opts[:sizes] + device_breakpoints = opts[:device_breakpoints] || default_device_breakpoints + image_breakpoints = opts[:image_breakpoints] || default_image_breakpoints + transformation = opts[:transformation] || [] + transformation_position = opts[:transformation_position] + query_parameters = opts[:query_parameters] + expires_in = opts[:expires_in] + signed = opts[:signed] + + # Sort and merge breakpoints + sorted_device_breakpoints = device_breakpoints.sort + sorted_image_breakpoints = image_breakpoints.sort + all_breakpoints = (sorted_image_breakpoints + sorted_device_breakpoints).sort.uniq + + # Compute candidate widths and descriptor kind + result = compute_candidate_widths( + all_breakpoints: all_breakpoints, + device_breakpoints: sorted_device_breakpoints, + explicit_width: width, + sizes_attr: sizes + ) + candidates = result[:candidates] + descriptor_kind = result[:descriptor_kind] + + # Helper to build a single ImageKit URL + build_url_fn = lambda do |w| + build_url( + Imagekitio::Models::SrcOptions.new( + src: src, + url_endpoint: url_endpoint, + query_parameters: query_parameters, + transformation_position: transformation_position, + expires_in: expires_in, + signed: signed, + transformation: transformation + [ + Imagekitio::Models::Transformation.new(width: w, crop: "at_max") # never upscale beyond original + ] + ) + ) + end + + # Build srcset + src_set_entries = candidates.map.with_index do |w, i| + # Ensure width is an integer for proper descriptor format (e.g., "640w" not "640.0w") + width_int = w.to_i + descriptor = descriptor_kind == :w ? "#{width_int}w" : "#{i + 1}x" + "#{build_url_fn.call(width_int)} #{descriptor}" + end + src_set = src_set_entries.empty? ? nil : src_set_entries.join(", ") + + final_sizes = sizes || (descriptor_kind == :w ? "100vw" : nil) + + # Build and return ResponsiveImageAttributes model + Imagekitio::Models::ResponsiveImageAttributes.new( + src: build_url_fn.call(candidates.last.to_i), # largest candidate as integer + src_set: src_set, + sizes: final_sizes, + width: width + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + + private + + # Compute candidate widths for responsive images. + # Implements three strategies: + # 1. Width-based srcSet (w) when sizes attribute contains vw units + # 2. Fallback to device breakpoints when no width or sizes provided + # 3. DPR-based srcSet (x) with 1x and 2x variants when width is provided + def compute_candidate_widths( + all_breakpoints:, + device_breakpoints:, + explicit_width: nil, + sizes_attr: nil + ) + # Strategy 1: Width-based srcSet (w) using viewport vw hints + if sizes_attr + vw_tokens = sizes_attr.scan(/(?:^|\s)(1?\d{1,2})vw/).flatten.map(&:to_i) + + if vw_tokens.any? + # Find the smallest vw percentage + smallest_ratio = vw_tokens.min / 100.0 + # Calculate minimum required pixels + min_required_px = device_breakpoints.first * smallest_ratio + # Filter breakpoints >= min_required_px + candidates = all_breakpoints.select { |bp| bp >= min_required_px } + return {candidates: candidates, descriptor_kind: :w} + end + + # No usable vw found: fallback to all breakpoints + return {candidates: all_breakpoints, descriptor_kind: :w} + end + + # Strategy 2: Fallback using device breakpoints if no explicit width + return {candidates: device_breakpoints, descriptor_kind: :w} unless explicit_width + + # Strategy 3: Use 1x and 2x nearest breakpoints for x descriptor + # Find the first breakpoint >= target (or use the largest) + nearest = lambda do |target| + all_breakpoints.find { |bp| bp >= target } || all_breakpoints.last + end + + # Generate unique 1x and 2x variants + unique = [nearest.call(explicit_width), nearest.call(explicit_width * 2)].uniq + + {candidates: unique, descriptor_kind: :x} + end + + # Generate a 32-character hex token + def generate_token + # Generate 16 random bytes and convert to hex (32 characters) + require("securerandom") + SecureRandom.hex(16) + end + + # Internal method to generate authentication parameters + def get_authentication_parameters_internal(token, expire, private_key) + auth_parameters = { + token: token, + expire: expire, + signature: "" + } + + signature = Imagekitio::CryptoUtils.create_hmac_sha1(private_key, token.to_s + expire.to_s) + auth_parameters[:signature] = signature + + auth_parameters + end + + # Remove trailing slash from string + def remove_trailing_slash(str) + return str unless str.is_a?(String) && str.end_with?("/") + str.chomp("/") + end + + # Remove leading slash from string + def remove_leading_slash(str) + return str unless str.is_a?(String) && str.start_with?("/") + str[1..] + end + + # RFC 3986 path encoding - matches Node.js encodeURIPath exactly + # From Node.js: str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent) + def encode_uri_path(str) + # Only encode characters that are NOT in the RFC 3986 path character set + # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" + # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" + # pchar = unreserved / pct-encoded / sub-delims / ":" / "@" + str.gsub(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/) { |match| CGI.escape(match) } + end + + # Join path parts (Node.js pathJoin algorithm without encoding) + def path_join(parts, separator = "/") + return "" if parts.nil? || parts.empty? + + # Clean up parts and join + cleaned_parts = [] + + parts.each do |part| + part = part.to_s.strip + next if part.empty? + + # Remove leading slashes from all parts + part = part[1..] while part.start_with?(separator) + + # Remove trailing slashes from all parts + part = part[0..-2] while part.end_with?(separator) + + cleaned_parts << part unless part.empty? + end + + return "" if cleaned_parts.empty? + + # Join with separator and add leading slash (Node.js style) + result = separator + cleaned_parts.join(separator) + + # Apply encoding to special characters only, preserving path structure + result.gsub(/[^\x00-\x7F]/) { |char| CGI.escape(char) } + end + + # Process overlay transformation (full implementation) + def process_overlay(overlay) + return "" unless overlay + + # Support both BaseModel objects and plain hashes + type = if overlay.is_a?(Hash) + overlay[:type] || overlay["type"] + else + overlay.type + end + return "" unless type + + # Determine overlay type based on explicit type field + case type.to_s + when "text" + process_text_overlay(overlay) + when "image" + process_image_overlay(overlay) + when "video" + process_video_overlay(overlay) + when "subtitle" + process_subtitle_overlay(overlay) + when "solidColor" + process_solid_color_overlay(overlay) + else + "" + end + end + + # Process input path for image/video/subtitle overlays (matching Node.js processInputPath) + def process_input_path(str, encoding) + # Remove leading and trailing slashes + str = remove_trailing_slash(remove_leading_slash(str)) + + case encoding.to_s + when "plain" + "i-#{str.gsub('/', '@@')}" + when "base64" + "ie-#{CGI.escape(Base64.strict_encode64(str))}" + else # auto + if str.match?(SIMPLE_OVERLAY_PATH_REGEX) + "i-#{str.gsub('/', '@@')}" + else + "ie-#{CGI.escape(Base64.strict_encode64(str))}" + end + end + end + + # Process text content for text overlays (matching Node.js processText) + def process_text(str, encoding) + case encoding.to_s + when "plain" + "i-#{uri_encode(str)}" + when "base64" + "ie-#{uri_encode(Base64.strict_encode64(str))}" + else # auto + if str.match?(SIMPLE_OVERLAY_TEXT_REGEX) + "i-#{uri_encode(str)}" + else + "ie-#{uri_encode(Base64.strict_encode64(str))}" + end + end + end + + # URI encode like JavaScript's encodeURIComponent (uses %20 instead of +) + def uri_encode(str) + CGI.escape(str).gsub("+", "%20") + end + + # Process text overlay + def process_text_overlay(overlay) + text = safe_get(overlay, :text) + return "" unless text && !text.to_s.empty? + + parts = ["l-text"] + + # Handle encoding using the processText function + encoding = safe_get(overlay, :encoding) || "auto" + parts << process_text(text, encoding) + + # Add other overlay properties (position, timing, transformations) + add_overlay_properties(parts, overlay) + + parts << "l-end" + parts.join(",") + end + + # Process image overlay + def process_image_overlay(overlay) + input = safe_get(overlay, :input) + return "" unless input && !input.to_s.empty? + + parts = ["l-image"] + + # Handle encoding using the process_input_path function + encoding = safe_get(overlay, :encoding) || "auto" + parts << process_input_path(input, encoding) + + # Add other overlay properties + add_overlay_properties(parts, overlay) + + parts << "l-end" + parts.join(",") + end + + # Process video overlay + def process_video_overlay(overlay) + input = safe_get(overlay, :input) + return "" unless input && !input.to_s.empty? + + parts = ["l-video"] + + # Handle encoding using the process_input_path function + encoding = safe_get(overlay, :encoding) || "auto" + parts << process_input_path(input, encoding) + + # Add other overlay properties + add_overlay_properties(parts, overlay) + + parts << "l-end" + parts.join(",") + end + + # Process subtitle overlay + def process_subtitle_overlay(overlay) + input = safe_get(overlay, :input) + return "" unless input && !input.to_s.empty? + + parts = ["l-subtitle"] + + # Handle encoding using the process_input_path function + encoding = safe_get(overlay, :encoding) || "auto" + parts << process_input_path(input, encoding) + + # Add other overlay properties + add_overlay_properties(parts, overlay) + + parts << "l-end" + parts.join(",") + end + + # Process solid color overlay + def process_solid_color_overlay(overlay) + color = safe_get(overlay, :color) + return "" unless color && !color.to_s.empty? + + parts = ["l-image", "i-ik_canvas", "bg-#{color}"] + + # Add other overlay properties + add_overlay_properties(parts, overlay) + + parts << "l-end" + parts.join(",") + end + + # Safe property access for model objects and hashes + def safe_get(obj, key) + return nil unless obj + + # Support both BaseModel objects and plain hashes + if obj.is_a?(Hash) + obj[key.to_sym] || obj[key.to_s] + elsif obj.respond_to?(key.to_sym) + obj.send(key.to_sym) + else + nil + end + end + + # Add overlay properties like position, timing, transformations (matching Node.js) + def add_overlay_properties(parts, overlay) + # Add position properties + position = safe_get(overlay, :position) + if position + x = safe_get(position, :x) + y = safe_get(position, :y_) + focus = safe_get(position, :focus) + + parts << "lx-#{x}" if x + parts << "ly-#{y}" if y + parts << "lfo-#{focus}" if focus + end + + # Add timing properties + timing = safe_get(overlay, :timing) + if timing + start = safe_get(timing, :start) + end_time = safe_get(timing, :end_) + duration = safe_get(timing, :duration) + + parts << "lso-#{start.to_i}" if start + parts << "leo-#{end_time.to_i}" if end_time + parts << "ldu-#{duration}" if duration + end + + # Add transformation properties + transformations = safe_get(overlay, :transformation) + return unless transformations && transformations.is_a?(Array) + transformation_string = build_transformation_string(transformations) + return unless transformation_string && !transformation_string.strip.empty? + parts << transformation_string + end + + # Calculate expiry timestamp for URL signing + def get_signature_timestamp(seconds) + return DEFAULT_TIMESTAMP unless seconds && seconds.to_i.positive? + + sec = seconds.to_i + return DEFAULT_TIMESTAMP if sec <= 0 + + Time.now.to_i + sec + end + + # Generate HMAC-SHA1 signature for URL signing + def get_signature(private_key:, url:, url_endpoint:, expiry_timestamp:) + return "" if private_key.nil? || private_key.empty? || url.nil? || url.empty? || url_endpoint.nil? + + # Create string to sign: relative path + expiry timestamp + endpoint_with_slash = add_trailing_slash(url_endpoint) + string_to_sign = url.gsub(endpoint_with_slash, "") + expiry_timestamp.to_s + + Imagekitio::CryptoUtils.create_hmac_sha1(private_key, string_to_sign) + end + + # Add trailing slash to string if not present + def add_trailing_slash(str) + return str unless str.is_a?(String) + return str if str.end_with?("/") + "#{str}/" + end + end +end diff --git a/lib/imagekitio/helpers/transformation_utils.rb b/lib/imagekitio/helpers/transformation_utils.rb new file mode 100644 index 00000000..3e7a4316 --- /dev/null +++ b/lib/imagekitio/helpers/transformation_utils.rb @@ -0,0 +1,164 @@ +# frozen_string_literal: true + +module Imagekitio + # @api private + # Transformation utilities for building ImageKit URLs + # Ported from the Node.js SDK + module TransformationUtils + # Constants for transformation parsing + QUERY_TRANSFORMATION_POSITION = :query + PATH_TRANSFORMATION_POSITION = :path + CHAIN_TRANSFORM_DELIMITER = ":" + TRANSFORM_DELIMITER = "," + TRANSFORM_KEY_VALUE_DELIMITER = "-" + + # Supported transformations mapping + # Based on https://imagekit.io/docs/transformations + SUPPORTED_TRANSFORMS = { + # Basic sizing & layout + "width" => "w", + "height" => "h", + "aspect_ratio" => "ar", + "aspectRatio" => "ar", + "background" => "bg", + "border" => "b", + "crop" => "c", + "crop_mode" => "cm", + "cropMode" => "cm", + "dpr" => "dpr", + "focus" => "fo", + "quality" => "q", + "x" => "x", + "x_center" => "xc", + "xCenter" => "xc", + "y" => "y", + "y_" => "y", + "y_center" => "yc", + "yCenter" => "yc", + "format" => "f", + "format_" => "f", + "video_codec" => "vc", + "videoCodec" => "vc", + "audio_codec" => "ac", + "audioCodec" => "ac", + "radius" => "r", + "rotation" => "rt", + "blur" => "bl", + "named" => "n", + "default_image" => "di", + "defaultImage" => "di", + "flip" => "fl", + "original" => "orig", + "start_offset" => "so", + "startOffset" => "so", + "end_offset" => "eo", + "endOffset" => "eo", + "duration" => "du", + "streaming_resolutions" => "sr", + "streamingResolutions" => "sr", + + # AI & advanced effects + "grayscale" => "e-grayscale", + "ai_upscale" => "e-upscale", + "aiUpscale" => "e-upscale", + "ai_retouch" => "e-retouch", + "aiRetouch" => "e-retouch", + "ai_variation" => "e-genvar", + "aiVariation" => "e-genvar", + "ai_drop_shadow" => "e-dropshadow", + "aiDropShadow" => "e-dropshadow", + "ai_change_background" => "e-changebg", + "aiChangeBackground" => "e-changebg", + "ai_remove_background" => "e-bgremove", + "aiRemoveBackground" => "e-bgremove", + "ai_remove_background_external" => "e-removedotbg", + "aiRemoveBackgroundExternal" => "e-removedotbg", + "ai_edit" => "e-edit", + "aiEdit" => "e-edit", + "contrast_stretch" => "e-contrast", + "contrastStretch" => "e-contrast", + "shadow" => "e-shadow", + "sharpen" => "e-sharpen", + "unsharp_mask" => "e-usm", + "unsharpMask" => "e-usm", + "gradient" => "e-gradient", + + # Other flags & finishing + "progressive" => "pr", + "lossless" => "lo", + "color_profile" => "cp", + "colorProfile" => "cp", + "metadata" => "md", + "opacity" => "o", + "trim" => "t", + "zoom" => "z", + "page" => "pg", + + # Text overlay transformations + "font_size" => "fs", + "fontSize" => "fs", + "font_family" => "ff", + "fontFamily" => "ff", + "font_color" => "co", + "fontColor" => "co", + "inner_alignment" => "ia", + "innerAlignment" => "ia", + "padding" => "pa", + "alpha" => "al", + "typography" => "tg", + "line_height" => "lh", + "lineHeight" => "lh", + + # Subtitles transformations + "font_outline" => "fol", + "fontOutline" => "fol", + "font_shadow" => "fsh", + "fontShadow" => "fsh", + "color" => "co", + + # Raw pass-through + "raw" => "raw" + }.freeze + + class << self + # Check if transformations should be added as query parameter + def add_as_query_parameter?(options) + options[:transformation_position] == QUERY_TRANSFORMATION_POSITION || + options["transformation_position"] == QUERY_TRANSFORMATION_POSITION || + options[:transformation_position] == "query" || + options["transformation_position"] == "query" + end + + # Get transformation key from supported transforms + def get_transform_key(transform) + return "" if transform.nil? || transform.to_s.empty? + + transform_str = transform.to_s + SUPPORTED_TRANSFORMS[transform_str] || + SUPPORTED_TRANSFORMS[transform_str.downcase] || + "" + end + + # Get chain transform delimiter + def get_chain_transform_delimiter + CHAIN_TRANSFORM_DELIMITER + end + + # Get transform delimiter + def get_transform_delimiter + TRANSFORM_DELIMITER + end + + # Get transform key-value delimiter + def get_transform_key_value_delimiter + TRANSFORM_KEY_VALUE_DELIMITER + end + + # Safe base64 encoding + def safe_btoa(str) + require("base64") + Base64.strict_encode64(str) + end + end + end +end diff --git a/lib/imagekitio/helpers/uuid_utils.rb b/lib/imagekitio/helpers/uuid_utils.rb new file mode 100644 index 00000000..6840505e --- /dev/null +++ b/lib/imagekitio/helpers/uuid_utils.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require "securerandom" + +module Imagekitio + # @api private + # UUID utilities for ImageKit SDK + module UuidUtils + class << self + # Generates a UUID v4 string + # + # @return [String] A UUID v4 string + def uuid4 + SecureRandom.uuid + end + end + end +end diff --git a/lib/imagekitio/internal.rb b/lib/imagekitio/internal.rb new file mode 100644 index 00000000..129495a2 --- /dev/null +++ b/lib/imagekitio/internal.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + OMIT = + Object.new.tap do + _1.define_singleton_method(:inspect) { "#<#{Imagekitio::Internal}::OMIT>" } + end + .freeze + + define_sorbet_constant!(:AnyHash) do + T.type_alias { T::Hash[Symbol, T.anything] } + end + define_sorbet_constant!(:FileInput) do + T.type_alias { T.any(Pathname, StringIO, IO, String, Imagekitio::FilePart) } + end + end +end diff --git a/lib/imagekitio/internal/transport/base_client.rb b/lib/imagekitio/internal/transport/base_client.rb new file mode 100644 index 00000000..6e613d49 --- /dev/null +++ b/lib/imagekitio/internal/transport/base_client.rb @@ -0,0 +1,567 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Transport + # @api private + # + # @abstract + class BaseClient + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + # from whatwg fetch spec + MAX_REDIRECTS = 20 + + # rubocop:disable Style/MutableConstant + PLATFORM_HEADERS = + { + "x-stainless-arch" => Imagekitio::Internal::Util.arch, + "x-stainless-lang" => "ruby", + "x-stainless-os" => Imagekitio::Internal::Util.os, + "x-stainless-package-version" => Imagekitio::VERSION, + "x-stainless-runtime" => ::RUBY_ENGINE, + "x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION + } + # rubocop:enable Style/MutableConstant + + class << self + # @api private + # + # @param req [Hash{Symbol=>Object}] + # + # @raise [ArgumentError] + def validate!(req) + keys = [:method, :path, :query, :headers, :body, :unwrap, :page, :stream, :model, :options] + case req + in Hash + req.each_key do |k| + unless keys.include?(k) + raise ArgumentError.new("Request `req` keys must be one of #{keys}, got #{k.inspect}") + end + end + else + raise ArgumentError.new("Request `req` must be a Hash or RequestOptions, got #{req.inspect}") + end + end + + # @api private + # + # @param status [Integer] + # @param headers [Hash{String=>String}] + # + # @return [Boolean] + def should_retry?(status, headers:) + coerced = Imagekitio::Internal::Util.coerce_boolean(headers["x-should-retry"]) + case [coerced, status] + in [true | false, _] + coerced + in [_, 408 | 409 | 429 | (500..)] + # retry on: + # 408: timeouts + # 409: locks + # 429: rate limits + # 500+: unknown errors + true + else + false + end + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @option request [Object] :body + # + # @option request [Integer] :max_retries + # + # @option request [Float] :timeout + # + # @param status [Integer] + # + # @param response_headers [Hash{String=>String}] + # + # @return [Hash{Symbol=>Object}] + def follow_redirect(request, status:, response_headers:) + method, url, headers = request.fetch_values(:method, :url, :headers) + location = + Kernel.then do + URI.join(url, response_headers["location"]) + rescue ArgumentError + message = "Server responded with status #{status} but no valid location header." + raise Imagekitio::Errors::APIConnectionError.new( + url: url, + response: response_headers, + message: message + ) + end + + request = {**request, url: location} + + case [url.scheme, location.scheme] + in ["https", "http"] + message = "Tried to redirect to a insecure URL" + raise Imagekitio::Errors::APIConnectionError.new( + url: url, + response: response_headers, + message: message + ) + else + nil + end + + # from whatwg fetch spec + case [status, method] + in [301 | 302, :post] | [303, _] + drop = %w[content-encoding content-language content-length content-location content-type] + request = { + **request, + method: method == :head ? :head : :get, + headers: headers.except(*drop), + body: nil + } + else + end + + # from undici + if Imagekitio::Internal::Util.uri_origin(url) != Imagekitio::Internal::Util.uri_origin(location) + drop = %w[authorization cookie host proxy-authorization] + request = {**request, headers: request.fetch(:headers).except(*drop)} + end + + request + end + + # @api private + # + # @param status [Integer, Imagekitio::Errors::APIConnectionError] + # @param stream [Enumerable, nil] + def reap_connection!(status, stream:) + case status + in (..199) | (300..499) + stream&.each { next } + in Imagekitio::Errors::APIConnectionError | (500..) + Imagekitio::Internal::Util.close_fused!(stream) + else + end + end + end + + # @return [URI::Generic] + attr_reader :base_url + + # @return [Float] + attr_reader :timeout + + # @return [Integer] + attr_reader :max_retries + + # @return [Float] + attr_reader :initial_retry_delay + + # @return [Float] + attr_reader :max_retry_delay + + # @return [Hash{String=>String}] + attr_reader :headers + + # @return [String, nil] + attr_reader :idempotency_header + + # @api private + # @return [Imagekitio::Internal::Transport::PooledNetRequester] + attr_reader :requester + + # @api private + # + # @param base_url [String] + # @param timeout [Float] + # @param max_retries [Integer] + # @param initial_retry_delay [Float] + # @param max_retry_delay [Float] + # @param headers [Hash{String=>String, Integer, Array, nil}] + # @param idempotency_header [String, nil] + def initialize( + base_url:, + timeout: 0.0, + max_retries: 0, + initial_retry_delay: 0.0, + max_retry_delay: 0.0, + headers: {}, + idempotency_header: nil + ) + @requester = Imagekitio::Internal::Transport::PooledNetRequester.new + @headers = Imagekitio::Internal::Util.normalized_headers( + self.class::PLATFORM_HEADERS, + { + "accept" => "application/json", + "content-type" => "application/json" + }, + headers + ) + @base_url_components = Imagekitio::Internal::Util.parse_uri(base_url) + @base_url = Imagekitio::Internal::Util.unparse_uri(@base_url_components) + @idempotency_header = idempotency_header&.to_s&.downcase + @timeout = timeout + @max_retries = max_retries + @initial_retry_delay = initial_retry_delay + @max_retry_delay = max_retry_delay + end + + # @api private + # + # @return [Hash{String=>String}] + private def auth_headers = {} + + # @api private + # + # @return [String] + private def generate_idempotency_key = "stainless-ruby-retry-#{SecureRandom.uuid}" + + # @api private + # + # @param req [Hash{Symbol=>Object}] . + # + # @option req [Symbol] :method + # + # @option req [String, Array] :path + # + # @option req [Hash{String=>Array, String, nil}, nil] :query + # + # @option req [Hash{String=>String, Integer, Array, nil}, nil] :headers + # + # @option req [Object, nil] :body + # + # @option req [Symbol, Integer, Array, Proc, nil] :unwrap + # + # @option req [Class, nil] :page + # + # @option req [Class, nil] :stream + # + # @option req [Imagekitio::Internal::Type::Converter, Class, nil] :model + # + # @param opts [Hash{Symbol=>Object}] . + # + # @option opts [String, nil] :idempotency_key + # + # @option opts [Hash{String=>Array, String, nil}, nil] :extra_query + # + # @option opts [Hash{String=>String, nil}, nil] :extra_headers + # + # @option opts [Object, nil] :extra_body + # + # @option opts [Integer, nil] :max_retries + # + # @option opts [Float, nil] :timeout + # + # @return [Hash{Symbol=>Object}] + private def build_request(req, opts) + method, uninterpolated_path = req.fetch_values(:method, :path) + + path = Imagekitio::Internal::Util.interpolate_path(uninterpolated_path) + + query = Imagekitio::Internal::Util.deep_merge(req[:query].to_h, opts[:extra_query].to_h) + + headers = Imagekitio::Internal::Util.normalized_headers( + @headers, + auth_headers, + req[:headers].to_h, + opts[:extra_headers].to_h + ) + + if @idempotency_header && + !headers.key?(@idempotency_header) && + (!Net::HTTP::IDEMPOTENT_METHODS_.include?(method.to_s.upcase) || opts.key?(:idempotency_key)) + headers[@idempotency_header] = opts.fetch(:idempotency_key) { generate_idempotency_key } + end + + unless headers.key?("x-stainless-retry-count") + headers["x-stainless-retry-count"] = "0" + end + + timeout = opts.fetch(:timeout, @timeout).to_f.clamp(0..) + unless headers.key?("x-stainless-timeout") || timeout.zero? + headers["x-stainless-timeout"] = timeout.to_s + end + + headers.reject! { |_, v| v.to_s.empty? } + + body = + case method + in :get | :head | :options | :trace + nil + else + Imagekitio::Internal::Util.deep_merge(*[req[:body], opts[:extra_body]].compact) + end + + url = Imagekitio::Internal::Util.join_parsed_uri( + @base_url_components, + {**req, path: path, query: query} + ) + headers, encoded = Imagekitio::Internal::Util.encode_content(headers, body) + { + method: method, + url: url, + headers: headers, + body: encoded, + max_retries: opts.fetch(:max_retries, @max_retries), + timeout: timeout + } + end + + # @api private + # + # @param headers [Hash{String=>String}] + # @param retry_count [Integer] + # + # @return [Float] + private def retry_delay(headers, retry_count:) + # Non-standard extension + span = Float(headers["retry-after-ms"], exception: false)&.then { _1 / 1000 } + return span if span + + retry_header = headers["retry-after"] + return span if (span = Float(retry_header, exception: false)) + + span = retry_header&.then do + Time.httpdate(_1) - Time.now + rescue ArgumentError + nil + end + return span if span + + scale = retry_count**2 + jitter = 1 - (0.25 * rand) + (@initial_retry_delay * scale * jitter).clamp(0, @max_retry_delay) + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @option request [Object] :body + # + # @option request [Integer] :max_retries + # + # @option request [Float] :timeout + # + # @param redirect_count [Integer] + # + # @param retry_count [Integer] + # + # @param send_retry_header [Boolean] + # + # @raise [Imagekitio::Errors::APIError] + # @return [Array(Integer, Net::HTTPResponse, Enumerable)] + def send_request(request, redirect_count:, retry_count:, send_retry_header:) + url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout) + input = {**request.except(:timeout), deadline: Imagekitio::Internal::Util.monotonic_secs + timeout} + + if send_retry_header + headers["x-stainless-retry-count"] = retry_count.to_s + end + + begin + status, response, stream = @requester.execute(input) + rescue Imagekitio::Errors::APIConnectionError => e + status = e + end + headers = Imagekitio::Internal::Util.normalized_headers(response&.each_header&.to_h) + + case status + in ..299 + [status, response, stream] + in 300..399 if redirect_count >= self.class::MAX_REDIRECTS + self.class.reap_connection!(status, stream: stream) + + message = "Failed to complete the request within #{self.class::MAX_REDIRECTS} redirects." + raise Imagekitio::Errors::APIConnectionError.new(url: url, response: response, message: message) + in 300..399 + self.class.reap_connection!(status, stream: stream) + + request = self.class.follow_redirect(request, status: status, response_headers: headers) + send_request( + request, + redirect_count: redirect_count + 1, + retry_count: retry_count, + send_retry_header: send_retry_header + ) + in Imagekitio::Errors::APIConnectionError if retry_count >= max_retries + raise status + in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: headers) + decoded = Kernel.then do + Imagekitio::Internal::Util.decode_content(headers, stream: stream, suppress_error: true) + ensure + self.class.reap_connection!(status, stream: stream) + end + + raise Imagekitio::Errors::APIStatusError.for( + url: url, + status: status, + headers: headers, + body: decoded, + request: nil, + response: response + ) + in (400..) | Imagekitio::Errors::APIConnectionError + self.class.reap_connection!(status, stream: stream) + + delay = retry_delay(response || {}, retry_count: retry_count) + sleep(delay) + + send_request( + request, + redirect_count: redirect_count, + retry_count: retry_count + 1, + send_retry_header: send_retry_header + ) + end + end + + # Execute the request specified by `req`. This is the method that all resource + # methods call into. + # + # @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: Imagekitio::Internal::Type::Unknown, options: {}) + # + # @param method [Symbol] + # + # @param path [String, Array] + # + # @param query [Hash{String=>Array, String, nil}, nil] + # + # @param headers [Hash{String=>String, Integer, Array, nil}, nil] + # + # @param body [Object, nil] + # + # @param unwrap [Symbol, Integer, Array, Proc, nil] + # + # @param page [Class, nil] + # + # @param stream [Class, nil] + # + # @param model [Imagekitio::Internal::Type::Converter, Class, nil] + # + # @param options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] . + # + # @option options [String, nil] :idempotency_key + # + # @option options [Hash{String=>Array, String, nil}, nil] :extra_query + # + # @option options [Hash{String=>String, nil}, nil] :extra_headers + # + # @option options [Object, nil] :extra_body + # + # @option options [Integer, nil] :max_retries + # + # @option options [Float, nil] :timeout + # + # @raise [Imagekitio::Errors::APIError] + # @return [Object] + def request(req) + self.class.validate!(req) + model = req.fetch(:model) { Imagekitio::Internal::Type::Unknown } + opts = req[:options].to_h + unwrap = req[:unwrap] + Imagekitio::RequestOptions.validate!(opts) + request = build_request(req.except(:options), opts) + url = request.fetch(:url) + + # Don't send the current retry count in the headers if the caller modified the header defaults. + send_retry_header = request.fetch(:headers)["x-stainless-retry-count"] == "0" + status, response, stream = send_request( + request, + redirect_count: 0, + retry_count: 0, + send_retry_header: send_retry_header + ) + + headers = Imagekitio::Internal::Util.normalized_headers(response.each_header.to_h) + decoded = Imagekitio::Internal::Util.decode_content(headers, stream: stream) + case req + in {stream: Class => st} + st.new( + model: model, + url: url, + status: status, + headers: headers, + response: response, + unwrap: unwrap, + stream: decoded + ) + in {page: Class => page} + page.new(client: self, req: req, headers: headers, page_data: decoded) + else + unwrapped = Imagekitio::Internal::Util.dig(decoded, unwrap) + Imagekitio::Internal::Type::Converter.coerce(model, unwrapped) + end + end + + # @api private + # + # @return [String] + def inspect + # rubocop:disable Layout/LineLength + "#<#{self.class.name}:0x#{object_id.to_s(16)} base_url=#{@base_url} max_retries=#{@max_retries} timeout=#{@timeout}>" + # rubocop:enable Layout/LineLength + end + + define_sorbet_constant!(:RequestComponents) do + T.type_alias do + { + method: Symbol, + path: T.any(String, T::Array[String]), + query: T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]), + headers: T.nilable( + T::Hash[String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + )] + ), + body: T.nilable(T.anything), + unwrap: T.nilable( + T.any( + Symbol, + Integer, + T::Array[T.any(Symbol, Integer)], + T.proc.params(arg0: T.anything).returns(T.anything) + ) + ), + page: T.nilable(T::Class[Imagekitio::Internal::Type::BasePage[Imagekitio::Internal::Type::BaseModel]]), + stream: T.nilable(T::Class[T.anything]), + model: T.nilable(Imagekitio::Internal::Type::Converter::Input), + options: T.nilable(Imagekitio::RequestOptions::OrHash) + } + end + end + define_sorbet_constant!(:RequestInput) do + T.type_alias do + { + method: Symbol, + url: URI::Generic, + headers: T::Hash[String, String], + body: T.anything, + max_retries: Integer, + timeout: Float + } + end + end + end + end + end +end diff --git a/lib/imagekitio/internal/transport/pooled_net_requester.rb b/lib/imagekitio/internal/transport/pooled_net_requester.rb new file mode 100644 index 00000000..41f53196 --- /dev/null +++ b/lib/imagekitio/internal/transport/pooled_net_requester.rb @@ -0,0 +1,217 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Transport + # @api private + class PooledNetRequester + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + # from the golang stdlib + # https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49 + KEEP_ALIVE_TIMEOUT = 30 + + DEFAULT_MAX_CONNECTIONS = [Etc.nprocessors, 99].max + + class << self + # @api private + # + # @param url [URI::Generic] + # + # @return [Net::HTTP] + def connect(url) + port = + case [url.port, url.scheme] + in [Integer, _] + url.port + in [nil, "http" | "ws"] + Net::HTTP.http_default_port + in [nil, "https" | "wss"] + Net::HTTP.https_default_port + end + + Net::HTTP.new(url.host, port).tap do + _1.use_ssl = %w[https wss].include?(url.scheme) + _1.max_retries = 0 + + # Temporary workaround for SSL verification issue on some + # platforms. Similar to: https://github.com/stripe/stripe-ruby/pull/397 + # Without this fix you may see errors like: + # .rbenv/versions/3.2.0/lib/ruby/3.2.0/net/protocol.rb:46:in `connect_nonblock': + # SSL_connect returned=1 errno=0 peeraddr=52.23.130.57:443 state=error: + # certificate verify failed (unable to get certificate CRL) (OpenSSL::SSL::SSLError) + if _1.use_ssl? + cert_store = OpenSSL::X509::Store.new + cert_store.set_default_paths + _1.cert_store = cert_store + _1.verify_mode = OpenSSL::SSL::VERIFY_PEER + end + end + end + + # @api private + # + # @param conn [Net::HTTP] + # @param deadline [Float] + def calibrate_socket_timeout(conn, deadline) + timeout = deadline - Imagekitio::Internal::Util.monotonic_secs + conn.open_timeout = conn.read_timeout = conn.write_timeout = conn.continue_timeout = timeout + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @param blk [Proc] + # + # @yieldparam [String] + # @return [Array(Net::HTTPGenericRequest, Proc)] + def build_request(request, &blk) + method, url, headers, body = request.fetch_values(:method, :url, :headers, :body) + req = Net::HTTPGenericRequest.new( + method.to_s.upcase, + !body.nil?, + method != :head, + URI(url.to_s) # ensure we construct a URI class of the right scheme + ) + + headers.each { req[_1] = _2 } + + case body + in nil + nil + in String + req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"] + req.body_stream = Imagekitio::Internal::Util::ReadIOAdapter.new(body, &blk) + in StringIO + req["content-length"] ||= body.size.to_s unless req["transfer-encoding"] + req.body_stream = Imagekitio::Internal::Util::ReadIOAdapter.new(body, &blk) + in Pathname | IO | Enumerator + req["transfer-encoding"] ||= "chunked" unless req["content-length"] + req.body_stream = Imagekitio::Internal::Util::ReadIOAdapter.new(body, &blk) + end + + [req, req.body_stream&.method(:close)] + end + end + + # @api private + # + # @param url [URI::Generic] + # @param deadline [Float] + # @param blk [Proc] + # + # @raise [Timeout::Error] + # @yieldparam [Net::HTTP] + private def with_pool(url, deadline:, &blk) + origin = Imagekitio::Internal::Util.uri_origin(url) + timeout = deadline - Imagekitio::Internal::Util.monotonic_secs + pool = + @mutex.synchronize do + @pools[origin] ||= ConnectionPool.new(size: @size) do + self.class.connect(url) + end + end + + pool.with(timeout: timeout, &blk) + end + + # @api private + # + # @param request [Hash{Symbol=>Object}] . + # + # @option request [Symbol] :method + # + # @option request [URI::Generic] :url + # + # @option request [Hash{String=>String}] :headers + # + # @option request [Object] :body + # + # @option request [Float] :deadline + # + # @return [Array(Integer, Net::HTTPResponse, Enumerable)] + def execute(request) + url, deadline = request.fetch_values(:url, :deadline) + + req = nil + finished = false + + # rubocop:disable Metrics/BlockLength + enum = Enumerator.new do |y| + next if finished + + with_pool(url, deadline: deadline) do |conn| + eof = false + closing = nil + ::Thread.handle_interrupt(Object => :never) do + ::Thread.handle_interrupt(Object => :immediate) do + req, closing = self.class.build_request(request) do + self.class.calibrate_socket_timeout(conn, deadline) + end + + self.class.calibrate_socket_timeout(conn, deadline) + unless conn.started? + conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT + conn.start + end + + self.class.calibrate_socket_timeout(conn, deadline) + conn.request(req) do |rsp| + y << [req, rsp] + break if finished + + rsp.read_body do |bytes| + y << bytes.force_encoding(Encoding::BINARY) + break if finished + + self.class.calibrate_socket_timeout(conn, deadline) + end + eof = true + end + end + ensure + begin + conn.finish if !eof && conn&.started? + ensure + closing&.call + end + end + end + rescue Timeout::Error + raise Imagekitio::Errors::APITimeoutError.new(url: url, request: req) + rescue StandardError + raise Imagekitio::Errors::APIConnectionError.new(url: url, request: req) + end + # rubocop:enable Metrics/BlockLength + + _, response = enum.next + body = Imagekitio::Internal::Util.fused_enum(enum, external: true) do + finished = true + loop { enum.next } + end + [Integer(response.code), response, body] + end + + # @api private + # + # @param size [Integer] + def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS) + @mutex = Mutex.new + @size = size + @pools = {} + end + + define_sorbet_constant!(:Request) do + T.type_alias { {method: Symbol, url: URI::Generic, headers: T::Hash[String, String], body: T.anything, deadline: Float} } + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/array_of.rb b/lib/imagekitio/internal/type/array_of.rb new file mode 100644 index 00000000..717f4aeb --- /dev/null +++ b/lib/imagekitio/internal/type/array_of.rb @@ -0,0 +1,168 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + # + # @abstract + # + # @generic Elem + # + # Array of items of a given type. + class ArrayOf + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + private_class_method :new + + # @overload [](type_info, spec = {}) + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + # + # @return [self] + def self.[](...) = new(...) + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ===(other) = other.is_a?(Array) && other.all?(item_type) + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + # rubocop:disable Layout/LineLength + other.is_a?(Imagekitio::Internal::Type::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type + # rubocop:enable Layout/LineLength + end + + # @api public + # + # @return [Integer] + def hash = [self.class, item_type].hash + + # @api private + # + # @param value [Array, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Array, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + + unless value.is_a?(Array) + exactness[:no] += 1 + state[:error] = TypeError.new("#{value.class} can't be coerced into #{Array}") + return value + end + + target = item_type + exactness[:yes] += 1 + value + .map do |item| + case [nilable?, item] + in [true, nil] + exactness[:yes] += 1 + nil + else + Imagekitio::Internal::Type::Converter.coerce(target, item, state: state) + end + end + end + + # @api private + # + # @param value [Array, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Array, Object] + def dump(value, state:) + target = item_type + if value.is_a?(Array) + value.map do + Imagekitio::Internal::Type::Converter.dump(target, _1, state: state) + end + else + super + end + end + + # @api private + # + # @return [Object] + def to_sorbet_type + T::Array[Imagekitio::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)] + end + + # @api private + # + # @return [generic] + protected def item_type = @item_type_fn.call + + # @api private + # + # @return [Boolean] + protected def nilable? = @nilable + + # @api private + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def initialize(type_info, spec = {}) + @item_type_fn = Imagekitio::Internal::Type::Converter.type_info(type_info || spec) + @meta = Imagekitio::Internal::Type::Converter.meta_info(type_info, spec) + @nilable = spec.fetch(:nil?, false) + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + items = Imagekitio::Internal::Type::Converter.inspect(item_type, depth: depth.succ) + + "#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]" + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/base_model.rb b/lib/imagekitio/internal/type/base_model.rb new file mode 100644 index 00000000..a7dd52d9 --- /dev/null +++ b/lib/imagekitio/internal/type/base_model.rb @@ -0,0 +1,530 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @abstract + class BaseModel + extend Imagekitio::Internal::Type::Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + class << self + # @api private + # + # Assumes superclass fields are totally defined before fields are accessed / + # defined on subclasses. + # + # @param child [Class] + def inherited(child) + super + child.known_fields.replace(known_fields.dup) + end + + # @api private + # + # @return [Hash{Symbol=>Hash{Symbol=>Object}}] + def known_fields = @known_fields ||= {} + + # @api private + # + # @return [Hash{Symbol=>Hash{Symbol=>Object}}] + def fields + known_fields.transform_values do |field| + {**field.except(:type_fn), type: field.fetch(:type_fn).call} + end + end + + # @api private + # + # @param name_sym [Symbol] + # + # @param required [Boolean] + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + private def add_field(name_sym, required:, type_info:, spec:) + meta = Imagekitio::Internal::Type::Converter.meta_info(type_info, spec) + type_fn, info = + case type_info + in Proc | Imagekitio::Internal::Type::Converter | Class + [Imagekitio::Internal::Type::Converter.type_info({**spec, union: type_info}), spec] + in Hash + [Imagekitio::Internal::Type::Converter.type_info(type_info), type_info] + end + + setter = :"#{name_sym}=" + api_name = info.fetch(:api_name, name_sym) + nilable = info.fetch(:nil?, false) + const = required && !nilable ? info.fetch(:const, Imagekitio::Internal::OMIT) : Imagekitio::Internal::OMIT + + [name_sym, setter].each { undef_method(_1) } if known_fields.key?(name_sym) + + known_fields[name_sym] = + { + mode: @mode, + api_name: api_name, + required: required, + nilable: nilable, + const: const, + type_fn: type_fn, + meta: meta + } + + define_method(setter) do |value| + target = type_fn.call + state = Imagekitio::Internal::Type::Converter.new_coerce_state(translate_names: false) + coerced = Imagekitio::Internal::Type::Converter.coerce(target, value, state: state) + status = @coerced.store(name_sym, state.fetch(:error) || true) + stored = + case [target, status] + in [Imagekitio::Internal::Type::Converter | Symbol, true] + coerced + else + value + end + @data.store(name_sym, stored) + end + + # rubocop:disable Style/CaseEquality + # rubocop:disable Metrics/BlockLength + define_method(name_sym) do + target = type_fn.call + + case @coerced[name_sym] + in true | false if Imagekitio::Internal::Type::Converter === target + @data.fetch(name_sym) + in ::StandardError => e + raise Imagekitio::Errors::ConversionError.new( + on: self.class, + method: __method__, + target: target, + value: @data.fetch(name_sym), + cause: e + ) + else + Kernel.then do + value = @data.fetch(name_sym) { const == Imagekitio::Internal::OMIT ? nil : const } + state = Imagekitio::Internal::Type::Converter.new_coerce_state(translate_names: false) + if (nilable || !required) && value.nil? + nil + else + Imagekitio::Internal::Type::Converter.coerce( + target, value, state: state + ) + end + rescue StandardError => e + raise Imagekitio::Errors::ConversionError.new( + on: self.class, + method: __method__, + target: target, + value: value, + cause: e + ) + end + end + end + # rubocop:enable Metrics/BlockLength + # rubocop:enable Style/CaseEquality + end + + # @api private + # + # @param name_sym [Symbol] + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def required(name_sym, type_info, spec = {}) + add_field(name_sym, required: true, type_info: type_info, spec: spec) + end + + # @api private + # + # @param name_sym [Symbol] + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def optional(name_sym, type_info, spec = {}) + add_field(name_sym, required: false, type_info: type_info, spec: spec) + end + + # @api private + # + # `request_only` attributes not excluded from `.#coerce` when receiving responses + # even if well behaved servers should not send them + # + # @param blk [Proc] + private def request_only(&blk) + @mode = :dump + blk.call + ensure + @mode = nil + end + + # @api private + # + # `response_only` attributes are omitted from `.#dump` when making requests + # + # @param blk [Proc] + private def response_only(&blk) + @mode = :coerce + blk.call + ensure + @mode = nil + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + other.is_a?(Class) && other <= Imagekitio::Internal::Type::BaseModel && other.fields == fields + end + + # @api public + # + # @return [Integer] + def hash = fields.hash + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) = self.class == other.class && @data == other.to_h + + # @api public + # + # @return [Integer] + def hash = [self.class, @data].hash + + class << self + # @api private + # + # @param value [Imagekitio::Internal::Type::BaseModel, Hash{Object=>Object}, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [self, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + + if value.is_a?(self) + exactness[:yes] += 1 + return value + end + + unless (val = Imagekitio::Internal::Util.coerce_hash(value)).is_a?(Hash) + exactness[:no] += 1 + state[:error] = TypeError.new("#{value.class} can't be coerced into #{Hash}") + return value + end + exactness[:yes] += 1 + + keys = val.keys.to_set + instance = new + data = instance.to_h + status = instance.instance_variable_get(:@coerced) + + # rubocop:disable Metrics/BlockLength + fields.each do |name, field| + mode, required, target = field.fetch_values(:mode, :required, :type) + api_name, nilable, const = field.fetch_values(:api_name, :nilable, :const) + src_name = state.fetch(:translate_names) ? api_name : name + + unless val.key?(src_name) + if required && mode != :dump && const == Imagekitio::Internal::OMIT + exactness[nilable ? :maybe : :no] += 1 + else + exactness[:yes] += 1 + end + next + end + + item = val.fetch(src_name) + keys.delete(src_name) + + state[:error] = nil + converted = + if item.nil? && (nilable || !required) + exactness[nilable ? :yes : :maybe] += 1 + nil + else + coerced = Imagekitio::Internal::Type::Converter.coerce(target, item, state: state) + case target + in Imagekitio::Internal::Type::Converter | Symbol + coerced + else + item + end + end + + status.store(name, state.fetch(:error) || true) + data.store(name, converted) + end + # rubocop:enable Metrics/BlockLength + + keys.each { data.store(_1, val.fetch(_1)) } + instance + end + + # @api private + # + # @param value [self, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Hash{Object=>Object}, Object] + def dump(value, state:) + unless (coerced = Imagekitio::Internal::Util.coerce_hash(value)).is_a?(Hash) + return super + end + + acc = {} + + coerced.each do |key, val| + name = key.is_a?(String) ? key.to_sym : key + case (field = known_fields[name]) + in nil + acc.store(name, super(val, state: state)) + else + api_name, mode, type_fn = field.fetch_values(:api_name, :mode, :type_fn) + case mode + in :coerce + next + else + target = type_fn.call + acc.store(api_name, Imagekitio::Internal::Type::Converter.dump(target, val, state: state)) + end + end + end + + known_fields.each_value do |field| + api_name, mode, const = field.fetch_values(:api_name, :mode, :const) + next if mode == :coerce || acc.key?(api_name) || const == Imagekitio::Internal::OMIT + acc.store(api_name, const) + end + + acc + end + + # @api private + # + # @return [Object] + def to_sorbet_type + self + end + end + + class << self + # @api private + # + # @param model [Imagekitio::Internal::Type::BaseModel] + # @param convert [Boolean] + # + # @return [Hash{Symbol=>Object}] + def recursively_to_h(model, convert:) + rec = ->(x) do + case x + in Imagekitio::Internal::Type::BaseModel + if convert + fields = x.class.known_fields + x.to_h.to_h do |key, val| + [key, rec.call(fields.key?(key) ? x.public_send(key) : val)] + rescue Imagekitio::Errors::ConversionError + [key, rec.call(val)] + end + else + rec.call(x.to_h) + end + in Hash + x.transform_values(&rec) + in Array + x.map(&rec) + else + x + end + end + rec.call(model) + end + end + + # @api public + # + # Returns the raw value associated with the given key, if found. Otherwise, nil is + # returned. + # + # It is valid to lookup keys that are not in the API spec, for example to access + # undocumented features. This method does not parse response data into + # higher-level types. Lookup by anything other than a Symbol is an ArgumentError. + # + # @param key [Symbol] + # + # @return [Object, nil] + def [](key) + unless key.instance_of?(Symbol) + raise ArgumentError.new("Expected symbol key for lookup, got #{key.inspect}") + end + + @data[key] + end + + # @api public + # + # Returns a Hash of the data underlying this object. O(1) + # + # Keys are Symbols and values are the raw values from the response. The return + # value indicates which values were ever set on the object. i.e. there will be a + # key in this hash if they ever were, even if the set value was nil. + # + # This method is not recursive. The returned value is shared by the object, so it + # should not be mutated. + # + # @return [Hash{Symbol=>Object}] + def to_h = @data + + alias_method :to_hash, :to_h + + # @api public + # + # In addition to the behaviour of `#to_h`, this method will recursively call + # `#to_h` on nested models. + # + # @return [Hash{Symbol=>Object}] + def deep_to_h = self.class.recursively_to_h(@data, convert: false) + + # @param keys [Array, nil] + # + # @return [Hash{Symbol=>Object}] + # + # @example + # # `base_overlay` is a `Imagekitio::BaseOverlay` + # base_overlay => { + # position: position, + # timing: timing + # } + def deconstruct_keys(keys) + (keys || self.class.known_fields.keys) + .filter_map do |k| + unless self.class.known_fields.key?(k) + next + end + + [k, public_send(k)] + end + .to_h + end + + # @api public + # + # @param a [Object] + # + # @return [String] + def to_json(*a) = Imagekitio::Internal::Type::Converter.dump(self.class, self).to_json(*a) + + # @api public + # + # @param a [Object] + # + # @return [String] + def to_yaml(*a) = Imagekitio::Internal::Type::Converter.dump(self.class, self).to_yaml(*a) + + # Create a new instance of a model. + # + # @param data [Hash{Symbol=>Object}, self] + def initialize(data = {}) + @data = {} + @coerced = {} + Imagekitio::Internal::Util.coerce_hash!(data).each do + if self.class.known_fields.key?(_1) + public_send(:"#{_1}=", _2) + else + @data.store(_1, _2) + @coerced.store(_1, false) + end + end + end + + class << self + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + return super() if depth.positive? + + depth = depth.succ + deferred = fields.transform_values do |field| + type, required, nilable = field.fetch_values(:type, :required, :nilable) + inspected = [ + Imagekitio::Internal::Type::Converter.inspect(type, depth: depth), + !required || nilable ? "nil" : nil + ].compact.join(" | ") + -> { inspected }.tap { _1.define_singleton_method(:inspect) { call } } + end + + "#{name}[#{deferred.inspect}]" + end + end + + # @api public + # + # @return [String] + def to_s = deep_to_h.to_s + + # @api private + # + # @return [String] + def inspect + converted = self.class.recursively_to_h(self, convert: true) + "#<#{self.class}:0x#{object_id.to_s(16)} #{converted}>" + end + + define_sorbet_constant!(:KnownField) do + T.type_alias { {mode: T.nilable(Symbol), required: T::Boolean, nilable: T::Boolean} } + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/base_page.rb b/lib/imagekitio/internal/type/base_page.rb new file mode 100644 index 00000000..eb794d13 --- /dev/null +++ b/lib/imagekitio/internal/type/base_page.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + # + # @generic Elem + # + # This module provides a base implementation for paginated responses in the SDK. + module BasePage + # rubocop:disable Lint/UnusedMethodArgument + + # @api public + # + # @return [Boolean] + def next_page? = (raise NotImplementedError) + + # @api public + # + # @raise [Imagekitio::Errors::APIError] + # @return [self] + def next_page = (raise NotImplementedError) + + # @api public + # + # @param blk [Proc] + # + # @yieldparam [generic] + # @return [void] + def auto_paging_each(&blk) = (raise NotImplementedError) + + # @return [Enumerable>] + def to_enum = super(:auto_paging_each) + + alias_method :enum_for, :to_enum + + # @api private + # + # @param client [Imagekitio::Internal::Transport::BaseClient] + # @param req [Hash{Symbol=>Object}] + # @param headers [Hash{String=>String}] + # @param page_data [Object] + def initialize(client:, req:, headers:, page_data:) + @client = client + @req = req + @model = req.fetch(:model) + super() + end + + # rubocop:enable Lint/UnusedMethodArgument + end + end + end +end diff --git a/lib/imagekitio/internal/type/boolean.rb b/lib/imagekitio/internal/type/boolean.rb new file mode 100644 index 00000000..6884a060 --- /dev/null +++ b/lib/imagekitio/internal/type/boolean.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + # + # @abstract + # + # Ruby has no Boolean class; this is something for models to refer to. + class Boolean + extend Imagekitio::Internal::Type::Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + private_class_method :new + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.===(other) = other == true || other == false + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.==(other) = other.is_a?(Class) && other <= Imagekitio::Internal::Type::Boolean + + class << self + # @api private + # + # Coerce value to Boolean if possible, otherwise return the original value. + # + # @param value [Boolean, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Boolean, Object] + def coerce(value, state:) + state.fetch(:exactness)[value == true || value == false ? :yes : :no] += 1 + value + end + + # @!method dump(value, state:) + # @api private + # + # @param value [Boolean, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Boolean, Object] + + # @api private + # + # @return [Object] + def to_sorbet_type + T::Boolean + end + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/converter.rb b/lib/imagekitio/internal/type/converter.rb new file mode 100644 index 00000000..486ce9bc --- /dev/null +++ b/lib/imagekitio/internal/type/converter.rb @@ -0,0 +1,327 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + module Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + # rubocop:disable Lint/UnusedMethodArgument + + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(value, state:) = (raise NotImplementedError) + + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Object] + def dump(value, state:) + case value + in Array + value.map { Imagekitio::Internal::Type::Unknown.dump(_1, state: state) } + in Hash + value.transform_values { Imagekitio::Internal::Type::Unknown.dump(_1, state: state) } + in Imagekitio::Internal::Type::BaseModel + value.class.dump(value, state: state) + in StringIO + value.string + in Pathname | IO + state[:can_retry] = false if value.is_a?(IO) + Imagekitio::FilePart.new(value) + in Imagekitio::FilePart + state[:can_retry] = false if value.content.is_a?(IO) + value + else + value + end + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + super() + end + + # rubocop:enable Lint/UnusedMethodArgument + + class << self + # @api private + # + # @param spec [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + # + # @return [Proc] + def type_info(spec) + case spec + in Proc + spec + in Hash + type_info(spec.slice(:const, :enum, :union).first&.last) + in true | false + -> { Imagekitio::Internal::Type::Boolean } + in Imagekitio::Internal::Type::Converter | Class | Symbol + -> { spec } + in NilClass | Integer | Float + -> { spec.class } + end + end + + # @api private + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] . + # + # @option type_info [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option type_info [Proc] :enum + # + # @option type_info [Proc] :union + # + # @option type_info [Boolean] :"nil?" + # + # @param spec [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + # + # @return [Hash{Symbol=>Object}] + def meta_info(type_info, spec) + [spec, type_info].grep(Hash).first.to_h.except(:const, :enum, :union, :nil?) + end + + # @api private + # + # @param translate_names [Boolean] + # + # @return [Hash{Symbol=>Object}] + def new_coerce_state(translate_names: true) + { + translate_names: translate_names, + strictness: true, + exactness: {yes: 0, no: 0, maybe: 0}, + error: nil, + branched: 0 + } + end + + # @api private + # + # Based on `target`, transform `value` into `target`, to the extent possible: + # + # 1. if the given `value` conforms to `target` already, return the given `value` + # 2. if it's possible and safe to convert the given `value` to `target`, then the + # converted value + # 3. otherwise, the given `value` unaltered + # + # The coercion process is subject to improvement between minor release versions. + # See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode + # + # @param target [Imagekitio::Internal::Type::Converter, Class] + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false`. This informs the coercion strategy + # when we have to decide between multiple possible conversion targets: + # + # - `true`: the conversion must be exact, with minimum coercion. + # - `false`: the conversion can be approximate, with some coercion. + # + # The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For + # any given conversion attempt, the exactness will be updated based on how closely + # the value recursively matches the target type: + # + # - `yes`: the value can be converted to the target type with minimum coercion. + # - `maybe`: the value can be converted to the target type with some reasonable + # coercion. + # - `no`: the value cannot be converted to the target type. + # + # See implementation below for more details. + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(target, value, state: Imagekitio::Internal::Type::Converter.new_coerce_state) + # rubocop:disable Metrics/BlockNesting + exactness = state.fetch(:exactness) + + case target + in Imagekitio::Internal::Type::Converter + return target.coerce(value, state: state) + in Class + if value.is_a?(target) + exactness[:yes] += 1 + return value + end + + case target + in -> { _1 <= NilClass } + exactness[value.nil? ? :yes : :maybe] += 1 + return nil + in -> { _1 <= Integer } + case value + in Integer + exactness[:yes] += 1 + return value + else + Kernel.then do + return Integer(value).tap { exactness[:maybe] += 1 } + rescue ArgumentError, TypeError => e + state[:error] = e + end + end + in -> { _1 <= Float } + if value.is_a?(Numeric) + exactness[:yes] += 1 + return Float(value) + else + Kernel.then do + return Float(value).tap { exactness[:maybe] += 1 } + rescue ArgumentError, TypeError => e + state[:error] = e + end + end + in -> { _1 <= String } + case value + in String | Symbol | Numeric + exactness[value.is_a?(Numeric) ? :maybe : :yes] += 1 + return value.to_s + in StringIO + exactness[:yes] += 1 + return value.string + else + state[:error] = TypeError.new("#{value.class} can't be coerced into #{String}") + end + in -> { _1 <= Date || _1 <= Time } + Kernel.then do + return target.parse(value).tap { exactness[:yes] += 1 } + rescue ArgumentError, TypeError => e + state[:error] = e + end + in -> { _1 <= StringIO } if value.is_a?(String) + exactness[:yes] += 1 + return StringIO.new(value.b) + else + end + in Symbol + case value + in Symbol | String + if value.to_sym == target + exactness[:yes] += 1 + return target + else + exactness[:maybe] += 1 + return value + end + else + message = "cannot convert non-matching #{value.class} into #{target.inspect}" + state[:error] = ArgumentError.new(message) + end + else + end + + exactness[:no] += 1 + value + # rubocop:enable Metrics/BlockNesting + end + + # @api private + # + # @param target [Imagekitio::Internal::Type::Converter, Class] + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Object] + def dump(target, value, state: {can_retry: true}) + case target + in Imagekitio::Internal::Type::Converter + target.dump(value, state: state) + else + Imagekitio::Internal::Type::Unknown.dump(value, state: state) + end + end + + # @api private + # + # @param target [Object] + # @param depth [Integer] + # + # @return [String] + def inspect(target, depth:) + case target + in Imagekitio::Internal::Type::Converter + target.inspect(depth: depth.succ) + else + target.inspect + end + end + end + + define_sorbet_constant!(:Input) do + T.type_alias { T.any(Imagekitio::Internal::Type::Converter, T::Class[T.anything]) } + end + define_sorbet_constant!(:CoerceState) do + T.type_alias do + { + translate_names: T::Boolean, + strictness: T::Boolean, + exactness: {yes: Integer, no: Integer, maybe: Integer}, + error: T::Class[StandardError], + branched: Integer + } + end + end + define_sorbet_constant!(:DumpState) do + T.type_alias { {can_retry: T::Boolean} } + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/enum.rb b/lib/imagekitio/internal/type/enum.rb new file mode 100644 index 00000000..8bc0591f --- /dev/null +++ b/lib/imagekitio/internal/type/enum.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + # + # A value from among a specified list of options. OpenAPI enum values map to Ruby + # values in the SDK as follows: + # + # 1. boolean => true | false + # 2. integer => Integer + # 3. float => Float + # 4. string => Symbol + # + # We can therefore convert string values to Symbols, but can't convert other + # values safely. + # + # @example + # # `streaming_resolution` is a `Imagekitio::StreamingResolution` + # case streaming_resolution + # when Imagekitio::StreamingResolution::STREAMING_RESOLUTION_240 + # # ... + # when Imagekitio::StreamingResolution::STREAMING_RESOLUTION_360 + # # ... + # when Imagekitio::StreamingResolution::STREAMING_RESOLUTION_480 + # # ... + # else + # puts(streaming_resolution) + # end + # + # @example + # case streaming_resolution + # in :"240" + # # ... + # in :"360" + # # ... + # in :"480" + # # ... + # else + # puts(streaming_resolution) + # end + module Enum + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + # All of the valid Symbol values for this enum. + # + # @return [Array] + def values = constants.map { const_get(_1) } + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ===(other) = values.include?(other) + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + # rubocop:disable Style/CaseEquality + Imagekitio::Internal::Type::Enum === other && other.values.to_set == values.to_set + # rubocop:enable Style/CaseEquality + end + + # @api public + # + # @return [Integer] + def hash = values.to_set.hash + + # @api private + # + # Unlike with primitives, `Enum` additionally validates that the value is a member + # of the enum. + # + # @param value [String, Symbol, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Symbol, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + val = value.is_a?(String) ? value.to_sym : value + + if values.include?(val) + exactness[:yes] += 1 + val + elsif values.first&.class == val.class + exactness[:maybe] += 1 + value + else + exactness[:no] += 1 + state[:error] = TypeError.new("#{value.class} can't be coerced into #{self}") + value + end + end + + # @!method dump(value, state:) + # @api private + # + # @param value [Symbol, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Symbol, Object] + + # @api private + # + # @return [Object] + def to_sorbet_type + types = values.map { Imagekitio::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq + case types + in [] + T.noreturn + in [type] + type + else + T.any(*types) + end + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + if depth.positive? + return is_a?(Module) ? super() : self.class.name + end + + members = values.map { Imagekitio::Internal::Type::Converter.inspect(_1, depth: depth.succ) } + prefix = is_a?(Module) ? name : self.class.name + + "#{prefix}[#{members.join(' | ')}]" + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/file_input.rb b/lib/imagekitio/internal/type/file_input.rb new file mode 100644 index 00000000..ef9455d9 --- /dev/null +++ b/lib/imagekitio/internal/type/file_input.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + # + # @abstract + # + # Either `Pathname` or `StringIO`, or `IO`, or + # `Imagekitio::Internal::Type::FileInput`. + # + # Note: when `IO` is used, all retries are disabled, since many IO` streams are + # not rewindable. + class FileInput + extend Imagekitio::Internal::Type::Converter + + private_class_method :new + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.===(other) + case other + in Pathname | StringIO | IO | String | Imagekitio::FilePart + true + else + false + end + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.==(other) = other.is_a?(Class) && other <= Imagekitio::Internal::Type::FileInput + + class << self + # @api private + # + # @param value [StringIO, String, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [StringIO, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + case value + in String + exactness[:yes] += 1 + StringIO.new(value) + in StringIO + exactness[:yes] += 1 + value + else + state[:error] = TypeError.new("#{value.class} can't be coerced into #{StringIO}") + exactness[:no] += 1 + value + end + end + + # @api private + # + # @param value [Pathname, StringIO, IO, String, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Pathname, StringIO, IO, String, Object] + def dump(value, state:) + case value + in StringIO | String + # https://datatracker.ietf.org/doc/html/rfc7578#section-4.2 + # while not required, a filename is recommended, and in practice many servers do expect this + Imagekitio::FilePart.new(value, filename: "upload") + in IO + state[:can_retry] = false + value.to_path.nil? ? Imagekitio::FilePart.new(value, filename: "upload") : value + in Imagekitio::FilePart if value.content.is_a?(IO) + state[:can_retry] = false + value + else + value + end + end + + # @api private + # + # @return [Object] + def to_sorbet_type + T.any(Pathname, StringIO, IO, String, Imagekitio::FilePart) + end + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/hash_of.rb b/lib/imagekitio/internal/type/hash_of.rb new file mode 100644 index 00000000..aca1e07f --- /dev/null +++ b/lib/imagekitio/internal/type/hash_of.rb @@ -0,0 +1,188 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + # + # @abstract + # + # @generic Elem + # + # Hash of items of a given type. + class HashOf + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + private_class_method :new + + # @overload [](type_info, spec = {}) + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + # + # @return [self] + def self.[](...) = new(...) + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ===(other) + type = item_type + case other + in Hash + other.all? do |key, val| + case [key, val] + in [Symbol | String, ^type] + true + else + false + end + end + else + false + end + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + # rubocop:disable Layout/LineLength + other.is_a?(Imagekitio::Internal::Type::HashOf) && other.nilable? == nilable? && other.item_type == item_type + # rubocop:enable Layout/LineLength + end + + # @api public + # + # @return [Integer] + def hash = [self.class, item_type].hash + + # @api private + # + # @param value [Hash{Object=>Object}, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Hash{Symbol=>Object}, Object] + def coerce(value, state:) + exactness = state.fetch(:exactness) + + unless value.is_a?(Hash) + exactness[:no] += 1 + state[:error] = TypeError.new("#{value.class} can't be coerced into #{Hash}") + return value + end + + target = item_type + exactness[:yes] += 1 + value + .to_h do |key, val| + k = key.is_a?(String) ? key.to_sym : key + v = + case [nilable?, val] + in [true, nil] + exactness[:yes] += 1 + nil + else + Imagekitio::Internal::Type::Converter.coerce(target, val, state: state) + end + + exactness[:no] += 1 unless k.is_a?(Symbol) + [k, v] + end + end + + # @api private + # + # @param value [Hash{Object=>Object}, Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Hash{Symbol=>Object}, Object] + def dump(value, state:) + target = item_type + if value.is_a?(Hash) + value.transform_values do + Imagekitio::Internal::Type::Converter.dump(target, _1, state: state) + end + else + super + end + end + + # @api private + # + # @return [Object] + def to_sorbet_type + T::Hash[Imagekitio::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)] + end + + # @api private + # + # @return [generic] + protected def item_type = @item_type_fn.call + + # @api private + # + # @return [Boolean] + protected def nilable? = @nilable + + # @api private + # + # @param type_info [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + def initialize(type_info, spec = {}) + @item_type_fn = Imagekitio::Internal::Type::Converter.type_info(type_info || spec) + @meta = Imagekitio::Internal::Type::Converter.meta_info(type_info, spec) + @nilable = spec.fetch(:nil?, false) + end + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + items = Imagekitio::Internal::Type::Converter.inspect(item_type, depth: depth.succ) + + "#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]" + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/request_parameters.rb b/lib/imagekitio/internal/type/request_parameters.rb new file mode 100644 index 00000000..f1df8941 --- /dev/null +++ b/lib/imagekitio/internal/type/request_parameters.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + module RequestParameters + # @!attribute request_options + # Options to specify HTTP behaviour for this request. + # + # @return [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + + # @param mod [Module] + def self.included(mod) + raise ArgumentError.new(mod) unless mod <= Imagekitio::Internal::Type::BaseModel + + mod.optional(:request_options, Imagekitio::RequestOptions) + end + + # @api private + module Converter + # @api private + # + # @param params [Object] + # + # @return [Array(Object, Hash{Symbol=>Object})] + def dump_request(params) + state = {can_retry: true} + case (dumped = dump(params, state: state)) + in Hash + options = Imagekitio::Internal::Util.coerce_hash!(dumped[:request_options]).to_h + request_options = state.fetch(:can_retry) ? options : {**options, max_retries: 0} + [dumped.except(:request_options), request_options] + else + [dumped, nil] + end + end + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/union.rb b/lib/imagekitio/internal/type/union.rb new file mode 100644 index 00000000..47fdfd0b --- /dev/null +++ b/lib/imagekitio/internal/type/union.rb @@ -0,0 +1,250 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + # + # @example + # # `overlay` is a `Imagekitio::Overlay` + # case overlay + # when Imagekitio::TextOverlay + # # ... + # when Imagekitio::ImageOverlay + # # ... + # when Imagekitio::VideoOverlay + # # ... + # else + # puts(overlay) + # end + module Union + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + # @api private + # + # All of the specified variant info for this union. + # + # @return [ArrayObject})>] + private def known_variants = (@known_variants ||= []) + + # @api private + # + # @return [ArrayObject})>] + protected def derefed_variants + known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] } + end + + # All of the specified variants for this union. + # + # @return [Array] + def variants = derefed_variants.map { _2 } + + # @api private + # + # @param property [Symbol] + private def discriminator(property) + case property + in Symbol + @discriminator = property + end + end + + # @api private + # + # @param key [Symbol, Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] + # + # @param spec [Hash{Symbol=>Object}, Proc, Imagekitio::Internal::Type::Converter, Class] . + # + # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const + # + # @option spec [Proc] :enum + # + # @option spec [Proc] :union + # + # @option spec [Boolean] :"nil?" + private def variant(key, spec = nil) + meta = Imagekitio::Internal::Type::Converter.meta_info(nil, spec) + variant_info = + case key + in Symbol + [key, Imagekitio::Internal::Type::Converter.type_info(spec), meta] + in Proc | Imagekitio::Internal::Type::Converter | Class | Hash + [nil, Imagekitio::Internal::Type::Converter.type_info(key), meta] + end + + known_variants << variant_info + end + + # @api private + # + # @param value [Object] + # + # @return [Imagekitio::Internal::Type::Converter, Class, nil] + private def resolve_variant(value) + case [@discriminator, value] + in [_, Imagekitio::Internal::Type::BaseModel] + value.class + in [Symbol, Hash] + key = value.fetch(@discriminator) do + value.fetch(@discriminator.to_s, Imagekitio::Internal::OMIT) + end + + return nil if key == Imagekitio::Internal::OMIT + + key = key.to_sym if key.is_a?(String) + _, found = known_variants.find { |k,| k == key } + found&.call + else + nil + end + end + + # rubocop:disable Style/HashEachMethods + # rubocop:disable Style/CaseEquality + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ===(other) + known_variants.any? do |_, variant_fn| + variant_fn.call === other + end + end + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def ==(other) + Imagekitio::Internal::Type::Union === other && other.derefed_variants == derefed_variants + end + + # @api public + # + # @return [Integer] + def hash = variants.hash + + # @api private + # + # Tries to efficiently coerce the given value to one of the known variants. + # + # If the value cannot match any of the known variants, the coercion is considered + # non-viable and returns the original value. + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(value, state:) + if (target = resolve_variant(value)) + return Imagekitio::Internal::Type::Converter.coerce(target, value, state: state) + end + + strictness = state.fetch(:strictness) + exactness = state.fetch(:exactness) + + alternatives = [] + known_variants.each do |_, variant_fn| + target = variant_fn.call + exact = state[:exactness] = {yes: 0, no: 0, maybe: 0} + state[:branched] += 1 + + coerced = Imagekitio::Internal::Type::Converter.coerce(target, value, state: state) + yes, no, maybe = exact.values + if (no + maybe).zero? || (!strictness && yes.positive?) + exact.each { exactness[_1] += _2 } + state[:exactness] = exactness + return coerced + elsif maybe.positive? + alternatives << [[-yes, -maybe, no], exact, coerced] + end + end + + case alternatives.sort_by!(&:first) + in [] + exactness[:no] += 1 + state[:error] = ArgumentError.new("no matching variant for #{value.inspect}") + value + in [[_, exact, coerced], *] + exact.each { exactness[_1] += _2 } + coerced + end + .tap { state[:exactness] = exactness } + ensure + state[:strictness] = strictness + end + + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Object] + def dump(value, state:) + if (target = resolve_variant(value)) + return Imagekitio::Internal::Type::Converter.dump(target, value, state: state) + end + + known_variants.each do + target = _2.call + return Imagekitio::Internal::Type::Converter.dump(target, value, state: state) if target === value + end + + super + end + + # @api private + # + # @return [Object] + def to_sorbet_type + types = variants.map { Imagekitio::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq + case types + in [] + T.noreturn + in [type] + type + else + T.any(*types) + end + end + + # rubocop:enable Style/CaseEquality + # rubocop:enable Style/HashEachMethods + + # @api private + # + # @param depth [Integer] + # + # @return [String] + def inspect(depth: 0) + if depth.positive? + return is_a?(Module) ? super() : self.class.name + end + + members = variants.map { Imagekitio::Internal::Type::Converter.inspect(_1, depth: depth.succ) } + prefix = is_a?(Module) ? name : self.class.name + + "#{prefix}[#{members.join(' | ')}]" + end + end + end + end +end diff --git a/lib/imagekitio/internal/type/unknown.rb b/lib/imagekitio/internal/type/unknown.rb new file mode 100644 index 00000000..3dbe1d59 --- /dev/null +++ b/lib/imagekitio/internal/type/unknown.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + module Type + # @api private + # + # @abstract + # + # When we don't know what to expect for the value. + class Unknown + extend Imagekitio::Internal::Type::Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + # rubocop:disable Lint/UnusedMethodArgument + + private_class_method :new + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.===(other) = true + + # @api public + # + # @param other [Object] + # + # @return [Boolean] + def self.==(other) = other.is_a?(Class) && other <= Imagekitio::Internal::Type::Unknown + + class << self + # @api private + # + # No coercion needed for Unknown type. + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :translate_names + # + # @option state [Boolean] :strictness + # + # @option state [Hash{Symbol=>Object}] :exactness + # + # @option state [Class] :error + # + # @option state [Integer] :branched + # + # @return [Object] + def coerce(value, state:) + state.fetch(:exactness)[:yes] += 1 + value + end + + # @!method dump(value, state:) + # @api private + # + # @param value [Object] + # + # @param state [Hash{Symbol=>Object}] . + # + # @option state [Boolean] :can_retry + # + # @return [Object] + + # @api private + # + # @return [Object] + def to_sorbet_type + T.anything + end + end + + # rubocop:enable Lint/UnusedMethodArgument + end + end + end +end diff --git a/lib/imagekitio/internal/util.rb b/lib/imagekitio/internal/util.rb new file mode 100644 index 00000000..77125eca --- /dev/null +++ b/lib/imagekitio/internal/util.rb @@ -0,0 +1,915 @@ +# frozen_string_literal: true + +module Imagekitio + module Internal + # @api private + module Util + # @api private + # + # @return [Float] + def self.monotonic_secs = Process.clock_gettime(Process::CLOCK_MONOTONIC) + + # @api private + # + # @param ns [Module, Class] + # + # @return [Enumerable] + def self.walk_namespaces(ns) + ns.constants(false).lazy.flat_map do + case (c = ns.const_get(_1, false)) + in Module | Class + walk_namespaces(c) + else + [] + end + end + .chain([ns]) + end + + class << self + # @api private + # + # @return [String] + def arch + case (arch = RbConfig::CONFIG["arch"])&.downcase + in nil + "unknown" + in /aarch64|arm64/ + "arm64" + in /x86_64/ + "x64" + in /arm/ + "arm" + else + "other:#{arch}" + end + end + + # @api private + # + # @return [String] + def os + case (host = RbConfig::CONFIG["host_os"])&.downcase + in nil + "Unknown" + in /linux/ + "Linux" + in /darwin/ + "MacOS" + in /freebsd/ + "FreeBSD" + in /openbsd/ + "OpenBSD" + in /mswin|mingw|cygwin|ucrt/ + "Windows" + else + "Other:#{host}" + end + end + end + + class << self + # @api private + # + # @param input [Object] + # + # @return [Boolean] + def primitive?(input) + case input + in true | false | Numeric | Symbol | String + true + else + false + end + end + + # @api private + # + # @param input [String, Boolean] + # + # @return [Boolean, Object] + def coerce_boolean(input) + case input.is_a?(String) ? input.downcase : input + in "true" + true + in "false" + false + else + input + end + end + + # @api private + # + # @param input [String, Boolean] + # + # @raise [ArgumentError] + # @return [Boolean, nil] + def coerce_boolean!(input) + case coerce_boolean(input) + in true | false | nil => coerced + coerced + else + raise ArgumentError.new("Unable to coerce #{input.inspect} into boolean value") + end + end + + # @api private + # + # @param input [String, Integer] + # + # @return [Integer, Object] + def coerce_integer(input) + Integer(input, exception: false) || input + end + + # @api private + # + # @param input [String, Integer, Float] + # + # @return [Float, Object] + def coerce_float(input) + Float(input, exception: false) || input + end + + # @api private + # + # @param input [Object] + # + # @return [Hash{Object=>Object}, Object] + def coerce_hash(input) + case input + in NilClass | Array | Set | Enumerator | StringIO | IO + input + else + input.respond_to?(:to_h) ? input.to_h : input + end + end + + # @api private + # + # @param input [Object] + # + # @raise [ArgumentError] + # @return [Hash{Object=>Object}, nil] + def coerce_hash!(input) + case coerce_hash(input) + in Hash | nil => coerced + coerced + else + message = "Expected a #{Hash} or #{Imagekitio::Internal::Type::BaseModel}, got #{data.inspect}" + raise ArgumentError.new(message) + end + end + end + + class << self + # @api private + # + # @param lhs [Object] + # @param rhs [Object] + # @param concat [Boolean] + # + # @return [Object] + private def deep_merge_lr(lhs, rhs, concat: false) + case [lhs, rhs, concat] + in [Hash, Hash, _] + lhs.merge(rhs) { deep_merge_lr(_2, _3, concat: concat) } + in [Array, Array, true] + lhs.concat(rhs) + else + rhs + end + end + + # @api private + # + # Recursively merge one hash with another. If the values at a given key are not + # both hashes, just take the new value. + # + # @param values [Array] + # + # @param sentinel [Object, nil] the value to return if no values are provided. + # + # @param concat [Boolean] whether to merge sequences by concatenation. + # + # @return [Object] + def deep_merge(*values, sentinel: nil, concat: false) + case values + in [value, *values] + values.reduce(value) do |acc, val| + deep_merge_lr(acc, val, concat: concat) + end + else + sentinel + end + end + + # @api private + # + # @param data [Hash{Symbol=>Object}, Array, Object] + # @param pick [Symbol, Integer, Array, Proc, nil] + # @param blk [Proc, nil] + # + # @return [Object, nil] + def dig(data, pick, &blk) + case [data, pick] + in [_, nil] + data + in [Hash, Symbol] | [Array, Integer] + data.fetch(pick) { blk&.call } + in [Hash | Array, Array] + pick.reduce(data) do |acc, key| + case acc + in Hash if acc.key?(key) + acc.fetch(key) + in Array if key.is_a?(Integer) && key < acc.length + acc[key] + else + return blk&.call + end + end + in [_, Proc] + pick.call(data) + else + blk&.call + end + end + end + + class << self + # @api private + # + # @param uri [URI::Generic] + # + # @return [String] + def uri_origin(uri) + "#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}" + end + + # @api private + # + # @param path [String, Array] + # + # @return [String] + def interpolate_path(path) + case path + in String + path + in [] + "" + in [String => p, *interpolations] + encoded = interpolations.map { ERB::Util.url_encode(_1) } + format(p, *encoded) + end + end + end + + class << self + # @api private + # + # @param query [String, nil] + # + # @return [Hash{String=>Array}] + def decode_query(query) + CGI.parse(query.to_s) + end + + # @api private + # + # @param query [Hash{String=>Array, String, nil}, nil] + # + # @return [String, nil] + def encode_query(query) + query.to_h.empty? ? nil : URI.encode_www_form(query) + end + end + + class << self + # @api private + # + # @param url [URI::Generic, String] + # + # @return [Hash{Symbol=>String, Integer, nil}] + def parse_uri(url) + parsed = URI::Generic.component.zip(URI.split(url)).to_h + {**parsed, query: decode_query(parsed.fetch(:query))} + end + + # @api private + # + # @param parsed [Hash{Symbol=>String, Integer, nil}] . + # + # @option parsed [String, nil] :scheme + # + # @option parsed [String, nil] :host + # + # @option parsed [Integer, nil] :port + # + # @option parsed [String, nil] :path + # + # @option parsed [Hash{String=>Array}] :query + # + # @return [URI::Generic] + def unparse_uri(parsed) + URI::Generic.build(**parsed, query: encode_query(parsed.fetch(:query))) + end + + # @api private + # + # @param lhs [Hash{Symbol=>String, Integer, nil}] . + # + # @option lhs [String, nil] :scheme + # + # @option lhs [String, nil] :host + # + # @option lhs [Integer, nil] :port + # + # @option lhs [String, nil] :path + # + # @option lhs [Hash{String=>Array}] :query + # + # @param rhs [Hash{Symbol=>String, Integer, nil}] . + # + # @option rhs [String, nil] :scheme + # + # @option rhs [String, nil] :host + # + # @option rhs [Integer, nil] :port + # + # @option rhs [String, nil] :path + # + # @option rhs [Hash{String=>Array}] :query + # + # @return [URI::Generic] + def join_parsed_uri(lhs, rhs) + base_path, base_query = lhs.fetch_values(:path, :query) + slashed = base_path.end_with?("/") ? base_path : "#{base_path}/" + + merged = {**parse_uri(rhs.fetch(:path)), **rhs.except(:path, :query)} + parsed_path, parsed_query = merged.fetch_values(:path, :query) + override = URI::Generic.build(**merged.slice(:scheme, :host, :port), path: parsed_path) + + joined = URI.join(URI::Generic.build(lhs.except(:path, :query)), slashed, override) + query = deep_merge( + joined.path == base_path ? base_query : {}, + parsed_query, + rhs[:query].to_h, + concat: true + ) + + joined.query = encode_query(query) + joined + end + end + + class << self + # @api private + # + # @param headers [Hash{String=>String, Integer, Array, nil}] + # + # @return [Hash{String=>String}] + def normalized_headers(*headers) + {}.merge(*headers.compact).to_h do |key, val| + value = + case val + in Array + val.filter_map { _1&.to_s&.strip }.join(", ") + else + val&.to_s&.strip + end + [key.downcase, value] + end + end + end + + # @api private + # + # An adapter that satisfies the IO interface required by `::IO.copy_stream` + class ReadIOAdapter + # @api private + # + # @return [Boolean, nil] + def close? = @closing + + # @api private + def close + case @stream + in Enumerator + Imagekitio::Internal::Util.close_fused!(@stream) + in IO if close? + @stream.close + else + end + end + + # @api private + # + # @param max_len [Integer, nil] + # + # @return [String] + private def read_enum(max_len) + case max_len + in nil + @stream.to_a.join + in Integer + @buf << @stream.next while @buf.length < max_len + @buf.slice!(..max_len) + end + rescue StopIteration + @stream = nil + @buf.slice!(0..) + end + + # @api private + # + # @param max_len [Integer, nil] + # @param out_string [String, nil] + # + # @return [String, nil] + def read(max_len = nil, out_string = nil) + case @stream + in nil + nil + in IO | StringIO + @stream.read(max_len, out_string) + in Enumerator + read = read_enum(max_len) + case out_string + in String + out_string.replace(read) + in nil + read + end + end + .tap(&@blk) + end + + # @api private + # + # @param src [String, Pathname, StringIO, Enumerable] + # @param blk [Proc] + # + # @yieldparam [String] + def initialize(src, &blk) + @stream = + case src + in String + StringIO.new(src) + in Pathname + @closing = true + src.open(binmode: true) + else + src + end + @buf = String.new + @blk = blk + end + end + + class << self + # @param blk [Proc] + # + # @yieldparam [Enumerator::Yielder] + # @return [Enumerable] + def writable_enum(&blk) + Enumerator.new do |y| + y.define_singleton_method(:write) do + self << _1.dup + _1.bytesize + end + + blk.call(y) + end + end + end + + # @type [Regexp] + JSON_CONTENT = %r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)} + # @type [Regexp] + JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)} + + class << self + # @api private + # + # @param y [Enumerator::Yielder] + # @param val [Object] + # @param closing [Array] + # @param content_type [String, nil] + private def write_multipart_content(y, val:, closing:, content_type: nil) + content_line = "Content-Type: %s\r\n\r\n" + + case val + in Imagekitio::FilePart + return write_multipart_content( + y, + val: val.content, + closing: closing, + content_type: val.content_type + ) + in Pathname + y << format(content_line, content_type || "application/octet-stream") + io = val.open(binmode: true) + closing << io.method(:close) + IO.copy_stream(io, y) + in IO + y << format(content_line, content_type || "application/octet-stream") + IO.copy_stream(val, y) + in StringIO + y << format(content_line, content_type || "application/octet-stream") + y << val.string + in -> { primitive?(_1) } + y << format(content_line, content_type || "text/plain") + y << val.to_s + else + y << format(content_line, content_type || "application/json") + y << JSON.generate(val) + end + y << "\r\n" + end + + # @api private + # + # @param y [Enumerator::Yielder] + # @param boundary [String] + # @param key [Symbol, String] + # @param val [Object] + # @param closing [Array] + private def write_multipart_chunk(y, boundary:, key:, val:, closing:) + y << "--#{boundary}\r\n" + y << "Content-Disposition: form-data" + + unless key.nil? + name = ERB::Util.url_encode(key.to_s) + y << "; name=\"#{name}\"" + end + + case val + in Imagekitio::FilePart unless val.filename.nil? + filename = ERB::Util.url_encode(val.filename) + y << "; filename=\"#{filename}\"" + in Pathname | IO + filename = ERB::Util.url_encode(::File.basename(val.to_path)) + y << "; filename=\"#{filename}\"" + else + end + y << "\r\n" + + write_multipart_content(y, val: val, closing: closing) + end + + # @api private + # + # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content + # + # @param body [Object] + # + # @return [Array(String, Enumerable)] + private def encode_multipart_streaming(body) + # RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length + boundary = SecureRandom.urlsafe_base64(46) + + closing = [] + strio = writable_enum do |y| + case body + in Hash + body.each do |key, val| + case val + in Array if val.all? { primitive?(_1) } + val.each do |v| + write_multipart_chunk(y, boundary: boundary, key: key, val: v, closing: closing) + end + else + write_multipart_chunk(y, boundary: boundary, key: key, val: val, closing: closing) + end + end + else + write_multipart_chunk(y, boundary: boundary, key: nil, val: body, closing: closing) + end + y << "--#{boundary}--\r\n" + end + + fused_io = fused_enum(strio) { closing.each(&:call) } + [boundary, fused_io] + end + + # @api private + # + # @param headers [Hash{String=>String}] + # @param body [Object] + # + # @return [Object] + def encode_content(headers, body) + # rubocop:disable Style/CaseEquality + # rubocop:disable Layout/LineLength + content_type = headers["content-type"] + case [content_type, body] + in [Imagekitio::Internal::Util::JSON_CONTENT, Hash | Array | -> { primitive?(_1) }] + [headers, JSON.generate(body)] + in [Imagekitio::Internal::Util::JSONL_CONTENT, Enumerable] unless Imagekitio::Internal::Type::FileInput === body + [headers, body.lazy.map { JSON.generate(_1) }] + in [%r{^multipart/form-data}, Hash | Imagekitio::Internal::Type::FileInput] + boundary, strio = encode_multipart_streaming(body) + headers = {**headers, "content-type" => "#{content_type}; boundary=#{boundary}"} + [headers, strio] + in [_, Symbol | Numeric] + [headers, body.to_s] + in [_, StringIO] + [headers, body.string] + in [_, Imagekitio::FilePart] + [headers, body.content] + else + [headers, body] + end + # rubocop:enable Layout/LineLength + # rubocop:enable Style/CaseEquality + end + + # @api private + # + # https://www.iana.org/assignments/character-sets/character-sets.xhtml + # + # @param content_type [String] + # @param text [String] + def force_charset!(content_type, text:) + charset = /charset=([^;\s]+)/.match(content_type)&.captures&.first + + return unless charset + + begin + encoding = Encoding.find(charset) + text.force_encoding(encoding) + rescue ArgumentError + nil + end + end + + # @api private + # + # Assumes each chunk in stream has `Encoding::BINARY`. + # + # @param headers [Hash{String=>String}] + # @param stream [Enumerable] + # @param suppress_error [Boolean] + # + # @raise [JSON::ParserError] + # @return [Object] + def decode_content(headers, stream:, suppress_error: false) + case (content_type = headers["content-type"]) + in Imagekitio::Internal::Util::JSON_CONTENT + json = stream.to_a.join + begin + JSON.parse(json, symbolize_names: true) + rescue JSON::ParserError => e + raise e unless suppress_error + json + end + in Imagekitio::Internal::Util::JSONL_CONTENT + lines = decode_lines(stream) + chain_fused(lines) do |y| + lines.each { y << JSON.parse(_1, symbolize_names: true) } + end + in %r{^text/event-stream} + lines = decode_lines(stream) + decode_sse(lines) + else + text = stream.to_a.join + force_charset!(content_type, text: text) + StringIO.new(text) + end + end + end + + class << self + # @api private + # + # https://doc.rust-lang.org/std/iter/trait.FusedIterator.html + # + # @param enum [Enumerable] + # @param external [Boolean] + # @param close [Proc] + # + # @return [Enumerable] + def fused_enum(enum, external: false, &close) + fused = false + iter = Enumerator.new do |y| + next if fused + + fused = true + if external + loop { y << enum.next } + else + enum.each(&y) + end + ensure + close&.call + close = nil + end + + iter.define_singleton_method(:rewind) do + fused = true + self + end + iter + end + + # @api private + # + # @param enum [Enumerable, nil] + def close_fused!(enum) + return unless enum.is_a?(Enumerator) + + # rubocop:disable Lint/UnreachableLoop + enum.rewind.each { break } + # rubocop:enable Lint/UnreachableLoop + end + + # @api private + # + # @param enum [Enumerable, nil] + # @param blk [Proc] + # + # @yieldparam [Enumerator::Yielder] + # @return [Enumerable] + def chain_fused(enum, &blk) + iter = Enumerator.new { blk.call(_1) } + fused_enum(iter) { close_fused!(enum) } + end + end + + class << self + # @api private + # + # Assumes Strings have been forced into having `Encoding::BINARY`. + # + # This decoder is responsible for reassembling lines split across multiple + # fragments. + # + # @param enum [Enumerable] + # + # @return [Enumerable] + def decode_lines(enum) + re = /(\r\n|\r|\n)/ + buffer = String.new + cr_seen = nil + + chain_fused(enum) do |y| + enum.each do |row| + offset = buffer.bytesize + buffer << row + while (match = re.match(buffer, cr_seen&.to_i || offset)) + case [match.captures.first, cr_seen] + in ["\r", nil] + cr_seen = match.end(1) + next + in ["\r" | "\r\n", Integer] + y << buffer.slice!(..(cr_seen.pred)) + else + y << buffer.slice!(..(match.end(1).pred)) + end + offset = 0 + cr_seen = nil + end + end + + y << buffer.slice!(..(cr_seen.pred)) unless cr_seen.nil? + y << buffer unless buffer.empty? + end + end + + # @api private + # + # https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream + # + # Assumes that `lines` has been decoded with `#decode_lines`. + # + # @param lines [Enumerable] + # + # @return [EnumerableObject}>] + def decode_sse(lines) + # rubocop:disable Metrics/BlockLength + chain_fused(lines) do |y| + blank = {event: nil, data: nil, id: nil, retry: nil} + current = {} + + lines.each do |line| + case line.sub(/\R$/, "") + in "" + next if current.empty? + y << {**blank, **current} + current = {} + in /^:/ + next + in /^([^:]+):\s?(.*)$/ + field, value = Regexp.last_match.captures + case field + in "event" + current.merge!(event: value) + in "data" + (current[:data] ||= String.new) << (value << "\n") + in "id" unless value.include?("\0") + current.merge!(id: value) + in "retry" if /^\d+$/ =~ value + current.merge!(retry: Integer(value)) + else + end + else + end + end + # rubocop:enable Metrics/BlockLength + + y << {**blank, **current} unless current.empty? + end + end + end + + # @api private + module SorbetRuntimeSupport + class MissingSorbetRuntimeError < ::RuntimeError + end + + # @api private + # + # @return [Hash{Symbol=>Object}] + private def sorbet_runtime_constants = @sorbet_runtime_constants ||= {} + + # @api private + # + # @param name [Symbol] + def const_missing(name) + super unless sorbet_runtime_constants.key?(name) + + unless Object.const_defined?(:T) + message = "Trying to access a Sorbet constant #{name.inspect} without `sorbet-runtime`." + raise MissingSorbetRuntimeError.new(message) + end + + sorbet_runtime_constants.fetch(name).call + end + + # @api private + # + # @param name [Symbol] + # + # @return [Boolean] + def sorbet_constant_defined?(name) = sorbet_runtime_constants.key?(name) + + # @api private + # + # @param name [Symbol] + # @param blk [Proc] + def define_sorbet_constant!(name, &blk) = sorbet_runtime_constants.store(name, blk) + + # @api private + # + # @return [Object] + def to_sorbet_type = raise NotImplementedError + + class << self + # @api private + # + # @param type [Imagekitio::Internal::Util::SorbetRuntimeSupport, Object] + # + # @return [Object] + def to_sorbet_type(type) + case type + in Imagekitio::Internal::Util::SorbetRuntimeSupport + type.to_sorbet_type + in Class | Module + type + in true | false + T::Boolean + else + type.class + end + end + end + end + + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + define_sorbet_constant!(:ParsedUri) do + T.type_alias do + { + scheme: T.nilable(String), + host: T.nilable(String), + port: T.nilable(Integer), + path: T.nilable(String), + query: T::Hash[String, T::Array[String]] + } + end + end + + define_sorbet_constant!(:ServerSentEvent) do + T.type_alias do + { + event: T.nilable(String), + data: T.nilable(String), + id: T.nilable(String), + retry: T.nilable(Integer) + } + end + end + end + end +end diff --git a/lib/imagekitio/models.rb b/lib/imagekitio/models.rb new file mode 100644 index 00000000..06ffc0cf --- /dev/null +++ b/lib/imagekitio/models.rb @@ -0,0 +1,160 @@ +# frozen_string_literal: true + +module Imagekitio + [Imagekitio::Internal::Type::BaseModel, *Imagekitio::Internal::Type::BaseModel.subclasses].each do |cls| + cls.define_sorbet_constant!(:OrHash) { T.type_alias { T.any(cls, Imagekitio::Internal::AnyHash) } } + end + + Imagekitio::Internal::Util.walk_namespaces(Imagekitio::Models).each do |mod| + case mod + in Imagekitio::Internal::Type::Enum | Imagekitio::Internal::Type::Union + mod.constants.each do |name| + case mod.const_get(name) + in true | false + mod.define_sorbet_constant!(:TaggedBoolean) { T.type_alias { T::Boolean } } + mod.define_sorbet_constant!(:OrBoolean) { T.type_alias { T::Boolean } } + in Integer + mod.define_sorbet_constant!(:TaggedInteger) { T.type_alias { Integer } } + mod.define_sorbet_constant!(:OrInteger) { T.type_alias { Integer } } + in Float + mod.define_sorbet_constant!(:TaggedFloat) { T.type_alias { Float } } + mod.define_sorbet_constant!(:OrFloat) { T.type_alias { Float } } + in Symbol + mod.define_sorbet_constant!(:TaggedSymbol) { T.type_alias { Symbol } } + mod.define_sorbet_constant!(:OrSymbol) { T.type_alias { T.any(Symbol, String) } } + else + end + end + else + end + end + + Imagekitio::Internal::Util.walk_namespaces(Imagekitio::Models) + .lazy + .grep(Imagekitio::Internal::Type::Union) + .each do |mod| + const = :Variants + next if mod.sorbet_constant_defined?(const) + + mod.define_sorbet_constant!(const) { T.type_alias { mod.to_sorbet_type } } + end + + Accounts = Imagekitio::Models::Accounts + + AssetListParams = Imagekitio::Models::AssetListParams + + BaseOverlay = Imagekitio::Models::BaseOverlay + + BaseWebhookEvent = Imagekitio::Models::BaseWebhookEvent + + Beta = Imagekitio::Models::Beta + + Cache = Imagekitio::Models::Cache + + CustomMetadataField = Imagekitio::Models::CustomMetadataField + + CustomMetadataFieldCreateParams = Imagekitio::Models::CustomMetadataFieldCreateParams + + CustomMetadataFieldDeleteParams = Imagekitio::Models::CustomMetadataFieldDeleteParams + + CustomMetadataFieldListParams = Imagekitio::Models::CustomMetadataFieldListParams + + CustomMetadataFieldUpdateParams = Imagekitio::Models::CustomMetadataFieldUpdateParams + + ExtensionItem = Imagekitio::Models::ExtensionItem + + # @type [Imagekitio::Internal::Type::Converter] + Extensions = Imagekitio::Models::Extensions + + File = Imagekitio::Models::File + + FileCopyParams = Imagekitio::Models::FileCopyParams + + FileDeleteParams = Imagekitio::Models::FileDeleteParams + + FileGetParams = Imagekitio::Models::FileGetParams + + FileMoveParams = Imagekitio::Models::FileMoveParams + + FileRenameParams = Imagekitio::Models::FileRenameParams + + Files = Imagekitio::Models::Files + + FileUpdateParams = Imagekitio::Models::FileUpdateParams + + FileUploadParams = Imagekitio::Models::FileUploadParams + + Folder = Imagekitio::Models::Folder + + FolderCopyParams = Imagekitio::Models::FolderCopyParams + + FolderCreateParams = Imagekitio::Models::FolderCreateParams + + FolderDeleteParams = Imagekitio::Models::FolderDeleteParams + + FolderMoveParams = Imagekitio::Models::FolderMoveParams + + FolderRenameParams = Imagekitio::Models::FolderRenameParams + + Folders = Imagekitio::Models::Folders + + GetImageAttributesOptions = Imagekitio::Models::GetImageAttributesOptions + + ImageOverlay = Imagekitio::Models::ImageOverlay + + Metadata = Imagekitio::Models::Metadata + + Overlay = Imagekitio::Models::Overlay + + OverlayPosition = Imagekitio::Models::OverlayPosition + + OverlayTiming = Imagekitio::Models::OverlayTiming + + ResponsiveImageAttributes = Imagekitio::Models::ResponsiveImageAttributes + + SolidColorOverlay = Imagekitio::Models::SolidColorOverlay + + SolidColorOverlayTransformation = Imagekitio::Models::SolidColorOverlayTransformation + + SrcOptions = Imagekitio::Models::SrcOptions + + StreamingResolution = Imagekitio::Models::StreamingResolution + + SubtitleOverlay = Imagekitio::Models::SubtitleOverlay + + SubtitleOverlayTransformation = Imagekitio::Models::SubtitleOverlayTransformation + + TextOverlay = Imagekitio::Models::TextOverlay + + TextOverlayTransformation = Imagekitio::Models::TextOverlayTransformation + + Transformation = Imagekitio::Models::Transformation + + TransformationPosition = Imagekitio::Models::TransformationPosition + + UnsafeUnwrapWebhookEvent = Imagekitio::Models::UnsafeUnwrapWebhookEvent + + UnwrapWebhookEvent = Imagekitio::Models::UnwrapWebhookEvent + + UpdateFileRequest = Imagekitio::Models::UpdateFileRequest + + UploadPostTransformErrorEvent = Imagekitio::Models::UploadPostTransformErrorEvent + + UploadPostTransformSuccessEvent = Imagekitio::Models::UploadPostTransformSuccessEvent + + UploadPreTransformErrorEvent = Imagekitio::Models::UploadPreTransformErrorEvent + + UploadPreTransformSuccessEvent = Imagekitio::Models::UploadPreTransformSuccessEvent + + VideoOverlay = Imagekitio::Models::VideoOverlay + + VideoTransformationAcceptedEvent = Imagekitio::Models::VideoTransformationAcceptedEvent + + VideoTransformationErrorEvent = Imagekitio::Models::VideoTransformationErrorEvent + + VideoTransformationReadyEvent = Imagekitio::Models::VideoTransformationReadyEvent + + WebhookUnsafeUnwrapParams = Imagekitio::Models::WebhookUnsafeUnwrapParams + + WebhookUnwrapParams = Imagekitio::Models::WebhookUnwrapParams +end diff --git a/lib/imagekitio/models/accounts/origin_create_params.rb b/lib/imagekitio/models/accounts/origin_create_params.rb new file mode 100644 index 00000000..f3ffaa1d --- /dev/null +++ b/lib/imagekitio/models/accounts/origin_create_params.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::Origins#create + class OriginCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute origin_request + # Schema for origin request resources. + # + # @return [Imagekitio::Models::Accounts::OriginRequest::S3, Imagekitio::Models::Accounts::OriginRequest::S3Compatible, Imagekitio::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekitio::Models::Accounts::OriginRequest::WebFolder, Imagekitio::Models::Accounts::OriginRequest::WebProxy, Imagekitio::Models::Accounts::OriginRequest::Gcs, Imagekitio::Models::Accounts::OriginRequest::AzureBlob, Imagekitio::Models::Accounts::OriginRequest::AkeneoPim] + required :origin_request, union: -> { Imagekitio::Accounts::OriginRequest } + + # @!method initialize(origin_request:, request_options: {}) + # @param origin_request [Imagekitio::Models::Accounts::OriginRequest::S3, Imagekitio::Models::Accounts::OriginRequest::S3Compatible, Imagekitio::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekitio::Models::Accounts::OriginRequest::WebFolder, Imagekitio::Models::Accounts::OriginRequest::WebProxy, Imagekitio::Models::Accounts::OriginRequest::Gcs, Imagekitio::Models::Accounts::OriginRequest::AzureBlob, Imagekitio::Models::Accounts::OriginRequest::AkeneoPim] Schema for origin request resources. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/origin_delete_params.rb b/lib/imagekitio/models/accounts/origin_delete_params.rb new file mode 100644 index 00000000..d27dc434 --- /dev/null +++ b/lib/imagekitio/models/accounts/origin_delete_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::Origins#delete + class OriginDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/origin_get_params.rb b/lib/imagekitio/models/accounts/origin_get_params.rb new file mode 100644 index 00000000..70940dcf --- /dev/null +++ b/lib/imagekitio/models/accounts/origin_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::Origins#get + class OriginGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/origin_list_params.rb b/lib/imagekitio/models/accounts/origin_list_params.rb new file mode 100644 index 00000000..4c924a7e --- /dev/null +++ b/lib/imagekitio/models/accounts/origin_list_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::Origins#list + class OriginListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/origin_list_response.rb b/lib/imagekitio/models/accounts/origin_list_response.rb new file mode 100644 index 00000000..a7bba41b --- /dev/null +++ b/lib/imagekitio/models/accounts/origin_list_response.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @type [Imagekitio::Internal::Type::Converter] + OriginListResponse = + Imagekitio::Internal::Type::ArrayOf[union: -> { Imagekitio::Accounts::OriginResponse }] + end + end +end diff --git a/lib/imagekitio/models/accounts/origin_request.rb b/lib/imagekitio/models/accounts/origin_request.rb new file mode 100644 index 00000000..091b669d --- /dev/null +++ b/lib/imagekitio/models/accounts/origin_request.rb @@ -0,0 +1,547 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # Schema for origin request resources. + module OriginRequest + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :S3, -> { Imagekitio::Accounts::OriginRequest::S3 } + + variant :S3_COMPATIBLE, -> { Imagekitio::Accounts::OriginRequest::S3Compatible } + + variant :CLOUDINARY_BACKUP, -> { Imagekitio::Accounts::OriginRequest::CloudinaryBackup } + + variant :WEB_FOLDER, -> { Imagekitio::Accounts::OriginRequest::WebFolder } + + variant :WEB_PROXY, -> { Imagekitio::Accounts::OriginRequest::WebProxy } + + variant :GCS, -> { Imagekitio::Accounts::OriginRequest::Gcs } + + variant :AZURE_BLOB, -> { Imagekitio::Accounts::OriginRequest::AzureBlob } + + variant :AKENEO_PIM, -> { Imagekitio::Accounts::OriginRequest::AkeneoPim } + + class S3 < Imagekitio::Internal::Type::BaseModel + # @!attribute access_key + # Access key for the bucket. + # + # @return [String] + required :access_key, String, api_name: :accessKey + + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute secret_key + # Secret key for the bucket. + # + # @return [String] + required :secret_key, String, api_name: :secretKey + + # @!attribute type + # + # @return [Symbol, :S3] + required :type, const: :S3 + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String, nil] + optional :prefix, String + + # @!method initialize(access_key:, bucket:, name:, secret_key:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, type: :S3) + # @param access_key [String] Access key for the bucket. + # + # @param bucket [String] S3 bucket name. + # + # @param name [String] Display name of the origin. + # + # @param secret_key [String] Secret key for the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param type [Symbol, :S3] + end + + class S3Compatible < Imagekitio::Internal::Type::BaseModel + # @!attribute access_key + # Access key for the bucket. + # + # @return [String] + required :access_key, String, api_name: :accessKey + + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute endpoint + # Custom S3-compatible endpoint. + # + # @return [String] + required :endpoint, String + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute secret_key + # Secret key for the bucket. + # + # @return [String] + required :secret_key, String, api_name: :secretKey + + # @!attribute type + # + # @return [Symbol, :S3_COMPATIBLE] + required :type, const: :S3_COMPATIBLE + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String, nil] + optional :prefix, String + + # @!attribute s3_force_path_style + # Use path-style S3 URLs? + # + # @return [Boolean, nil] + optional :s3_force_path_style, Imagekitio::Internal::Type::Boolean, api_name: :s3ForcePathStyle + + # @!method initialize(access_key:, bucket:, endpoint:, name:, secret_key:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, s3_force_path_style: nil, type: :S3_COMPATIBLE) + # @param access_key [String] Access key for the bucket. + # + # @param bucket [String] S3 bucket name. + # + # @param endpoint [String] Custom S3-compatible endpoint. + # + # @param name [String] Display name of the origin. + # + # @param secret_key [String] Secret key for the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param s3_force_path_style [Boolean] Use path-style S3 URLs? + # + # @param type [Symbol, :S3_COMPATIBLE] + end + + class CloudinaryBackup < Imagekitio::Internal::Type::BaseModel + # @!attribute access_key + # Access key for the bucket. + # + # @return [String] + required :access_key, String, api_name: :accessKey + + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute secret_key + # Secret key for the bucket. + # + # @return [String] + required :secret_key, String, api_name: :secretKey + + # @!attribute type + # + # @return [Symbol, :CLOUDINARY_BACKUP] + required :type, const: :CLOUDINARY_BACKUP + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String, nil] + optional :prefix, String + + # @!method initialize(access_key:, bucket:, name:, secret_key:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, type: :CLOUDINARY_BACKUP) + # @param access_key [String] Access key for the bucket. + # + # @param bucket [String] S3 bucket name. + # + # @param name [String] Display name of the origin. + # + # @param secret_key [String] Secret key for the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param type [Symbol, :CLOUDINARY_BACKUP] + end + + class WebFolder < Imagekitio::Internal::Type::BaseModel + # @!attribute base_url + # Root URL for the web folder origin. + # + # @return [String] + required :base_url, String, api_name: :baseUrl + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :WEB_FOLDER] + required :type, const: :WEB_FOLDER + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute forward_host_header_to_origin + # Forward the Host header to origin? + # + # @return [Boolean, nil] + optional :forward_host_header_to_origin, + Imagekitio::Internal::Type::Boolean, + api_name: :forwardHostHeaderToOrigin + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!method initialize(base_url:, name:, base_url_for_canonical_header: nil, forward_host_header_to_origin: nil, include_canonical_header: nil, type: :WEB_FOLDER) + # @param base_url [String] Root URL for the web folder origin. + # + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param forward_host_header_to_origin [Boolean] Forward the Host header to origin? + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param type [Symbol, :WEB_FOLDER] + end + + class WebProxy < Imagekitio::Internal::Type::BaseModel + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :WEB_PROXY] + required :type, const: :WEB_PROXY + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!method initialize(name:, base_url_for_canonical_header: nil, include_canonical_header: nil, type: :WEB_PROXY) + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param type [Symbol, :WEB_PROXY] + end + + class Gcs < Imagekitio::Internal::Type::BaseModel + # @!attribute bucket + # + # @return [String] + required :bucket, String + + # @!attribute client_email + # + # @return [String] + required :client_email, String, api_name: :clientEmail + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute private_key + # + # @return [String] + required :private_key, String, api_name: :privateKey + + # @!attribute type + # + # @return [Symbol, :GCS] + required :type, const: :GCS + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # + # @return [String, nil] + optional :prefix, String + + # @!method initialize(bucket:, client_email:, name:, private_key:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, type: :GCS) + # @param bucket [String] + # + # @param client_email [String] + # + # @param name [String] Display name of the origin. + # + # @param private_key [String] + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] + # + # @param type [Symbol, :GCS] + end + + class AzureBlob < Imagekitio::Internal::Type::BaseModel + # @!attribute account_name + # + # @return [String] + required :account_name, String, api_name: :accountName + + # @!attribute container + # + # @return [String] + required :container, String + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute sas_token + # + # @return [String] + required :sas_token, String, api_name: :sasToken + + # @!attribute type + # + # @return [Symbol, :AZURE_BLOB] + required :type, const: :AZURE_BLOB + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute prefix + # + # @return [String, nil] + optional :prefix, String + + # @!method initialize(account_name:, container:, name:, sas_token:, base_url_for_canonical_header: nil, include_canonical_header: nil, prefix: nil, type: :AZURE_BLOB) + # @param account_name [String] + # + # @param container [String] + # + # @param name [String] Display name of the origin. + # + # @param sas_token [String] + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param prefix [String] + # + # @param type [Symbol, :AZURE_BLOB] + end + + class AkeneoPim < Imagekitio::Internal::Type::BaseModel + # @!attribute base_url + # Akeneo instance base URL. + # + # @return [String] + required :base_url, String, api_name: :baseUrl + + # @!attribute client_id + # Akeneo API client ID. + # + # @return [String] + required :client_id, String, api_name: :clientId + + # @!attribute client_secret + # Akeneo API client secret. + # + # @return [String] + required :client_secret, String, api_name: :clientSecret + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute password + # Akeneo API password. + # + # @return [String] + required :password, String + + # @!attribute type + # + # @return [Symbol, :AKENEO_PIM] + required :type, const: :AKENEO_PIM + + # @!attribute username + # Akeneo API username. + # + # @return [String] + required :username, String + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean, nil] + optional :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!method initialize(base_url:, client_id:, client_secret:, name:, password:, username:, base_url_for_canonical_header: nil, include_canonical_header: nil, type: :AKENEO_PIM) + # @param base_url [String] Akeneo instance base URL. + # + # @param client_id [String] Akeneo API client ID. + # + # @param client_secret [String] Akeneo API client secret. + # + # @param name [String] Display name of the origin. + # + # @param password [String] Akeneo API password. + # + # @param username [String] Akeneo API username. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param type [Symbol, :AKENEO_PIM] + end + + # @!method self.variants + # @return [Array(Imagekitio::Models::Accounts::OriginRequest::S3, Imagekitio::Models::Accounts::OriginRequest::S3Compatible, Imagekitio::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekitio::Models::Accounts::OriginRequest::WebFolder, Imagekitio::Models::Accounts::OriginRequest::WebProxy, Imagekitio::Models::Accounts::OriginRequest::Gcs, Imagekitio::Models::Accounts::OriginRequest::AzureBlob, Imagekitio::Models::Accounts::OriginRequest::AkeneoPim)] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/origin_response.rb b/lib/imagekitio/models/accounts/origin_response.rb new file mode 100644 index 00000000..71d255ad --- /dev/null +++ b/lib/imagekitio/models/accounts/origin_response.rb @@ -0,0 +1,568 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # Origin object as returned by the API (sensitive fields removed). + # + # @see Imagekitio::Resources::Accounts::Origins#create + module OriginResponse + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :S3, -> { Imagekitio::Accounts::OriginResponse::S3 } + + variant :S3_COMPATIBLE, -> { Imagekitio::Accounts::OriginResponse::S3Compatible } + + variant :CLOUDINARY_BACKUP, -> { Imagekitio::Accounts::OriginResponse::CloudinaryBackup } + + variant :WEB_FOLDER, -> { Imagekitio::Accounts::OriginResponse::WebFolder } + + variant :WEB_PROXY, -> { Imagekitio::Accounts::OriginResponse::WebProxy } + + variant :GCS, -> { Imagekitio::Accounts::OriginResponse::Gcs } + + variant :AZURE_BLOB, -> { Imagekitio::Accounts::OriginResponse::AzureBlob } + + variant :AKENEO_PIM, -> { Imagekitio::Accounts::OriginResponse::AkeneoPim } + + class S3 < Imagekitio::Internal::Type::BaseModel + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String] + required :prefix, String + + # @!attribute type + # + # @return [Symbol, :S3] + required :type, const: :S3 + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, bucket:, include_canonical_header:, name:, prefix:, base_url_for_canonical_header: nil, type: :S3) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginResponse::S3} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param bucket [String] S3 bucket name. + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :S3] + end + + class S3Compatible < Imagekitio::Internal::Type::BaseModel + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute endpoint + # Custom S3-compatible endpoint. + # + # @return [String] + required :endpoint, String + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String] + required :prefix, String + + # @!attribute s3_force_path_style + # Use path-style S3 URLs? + # + # @return [Boolean] + required :s3_force_path_style, Imagekitio::Internal::Type::Boolean, api_name: :s3ForcePathStyle + + # @!attribute type + # + # @return [Symbol, :S3_COMPATIBLE] + required :type, const: :S3_COMPATIBLE + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, bucket:, endpoint:, include_canonical_header:, name:, prefix:, s3_force_path_style:, base_url_for_canonical_header: nil, type: :S3_COMPATIBLE) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginResponse::S3Compatible} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param bucket [String] S3 bucket name. + # + # @param endpoint [String] Custom S3-compatible endpoint. + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param s3_force_path_style [Boolean] Use path-style S3 URLs? + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :S3_COMPATIBLE] + end + + class CloudinaryBackup < Imagekitio::Internal::Type::BaseModel + # @!attribute bucket + # S3 bucket name. + # + # @return [String] + required :bucket, String + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # Path prefix inside the bucket. + # + # @return [String] + required :prefix, String + + # @!attribute type + # + # @return [Symbol, :CLOUDINARY_BACKUP] + required :type, const: :CLOUDINARY_BACKUP + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, bucket:, include_canonical_header:, name:, prefix:, base_url_for_canonical_header: nil, type: :CLOUDINARY_BACKUP) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginResponse::CloudinaryBackup} for more + # details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param bucket [String] S3 bucket name. + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] Path prefix inside the bucket. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :CLOUDINARY_BACKUP] + end + + class WebFolder < Imagekitio::Internal::Type::BaseModel + # @!attribute base_url + # Root URL for the web folder origin. + # + # @return [String] + required :base_url, String, api_name: :baseUrl + + # @!attribute forward_host_header_to_origin + # Forward the Host header to origin? + # + # @return [Boolean] + required :forward_host_header_to_origin, + Imagekitio::Internal::Type::Boolean, + api_name: :forwardHostHeaderToOrigin + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :WEB_FOLDER] + required :type, const: :WEB_FOLDER + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, base_url:, forward_host_header_to_origin:, include_canonical_header:, name:, base_url_for_canonical_header: nil, type: :WEB_FOLDER) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginResponse::WebFolder} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param base_url [String] Root URL for the web folder origin. + # + # @param forward_host_header_to_origin [Boolean] Forward the Host header to origin? + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :WEB_FOLDER] + end + + class WebProxy < Imagekitio::Internal::Type::BaseModel + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :WEB_PROXY] + required :type, const: :WEB_PROXY + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, include_canonical_header:, name:, base_url_for_canonical_header: nil, type: :WEB_PROXY) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginResponse::WebProxy} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :WEB_PROXY] + end + + class Gcs < Imagekitio::Internal::Type::BaseModel + # @!attribute bucket + # + # @return [String] + required :bucket, String + + # @!attribute client_email + # + # @return [String] + required :client_email, String, api_name: :clientEmail + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # + # @return [String] + required :prefix, String + + # @!attribute type + # + # @return [Symbol, :GCS] + required :type, const: :GCS + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, bucket:, client_email:, include_canonical_header:, name:, prefix:, base_url_for_canonical_header: nil, type: :GCS) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginResponse::Gcs} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param bucket [String] + # + # @param client_email [String] + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :GCS] + end + + class AzureBlob < Imagekitio::Internal::Type::BaseModel + # @!attribute account_name + # + # @return [String] + required :account_name, String, api_name: :accountName + + # @!attribute container + # + # @return [String] + required :container, String + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute prefix + # + # @return [String] + required :prefix, String + + # @!attribute type + # + # @return [Symbol, :AZURE_BLOB] + required :type, const: :AZURE_BLOB + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, account_name:, container:, include_canonical_header:, name:, prefix:, base_url_for_canonical_header: nil, type: :AZURE_BLOB) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginResponse::AzureBlob} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param account_name [String] + # + # @param container [String] + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param prefix [String] + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :AZURE_BLOB] + end + + class AkeneoPim < Imagekitio::Internal::Type::BaseModel + # @!attribute base_url + # Akeneo instance base URL. + # + # @return [String] + required :base_url, String, api_name: :baseUrl + + # @!attribute include_canonical_header + # Whether to send a Canonical header. + # + # @return [Boolean] + required :include_canonical_header, + Imagekitio::Internal::Type::Boolean, + api_name: :includeCanonicalHeader + + # @!attribute name + # Display name of the origin. + # + # @return [String] + required :name, String + + # @!attribute type + # + # @return [Symbol, :AKENEO_PIM] + required :type, const: :AKENEO_PIM + + # @!attribute base_url_for_canonical_header + # URL used in the Canonical header (if enabled). + # + # @return [String, nil] + optional :base_url_for_canonical_header, String, api_name: :baseUrlForCanonicalHeader + + response_only do + # @!attribute id + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, base_url:, include_canonical_header:, name:, base_url_for_canonical_header: nil, type: :AKENEO_PIM) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginResponse::AkeneoPim} for more details. + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param base_url [String] Akeneo instance base URL. + # + # @param include_canonical_header [Boolean] Whether to send a Canonical header. + # + # @param name [String] Display name of the origin. + # + # @param base_url_for_canonical_header [String] URL used in the Canonical header (if enabled). + # + # @param type [Symbol, :AKENEO_PIM] + end + + # @!method self.variants + # @return [Array(Imagekitio::Models::Accounts::OriginResponse::S3, Imagekitio::Models::Accounts::OriginResponse::S3Compatible, Imagekitio::Models::Accounts::OriginResponse::CloudinaryBackup, Imagekitio::Models::Accounts::OriginResponse::WebFolder, Imagekitio::Models::Accounts::OriginResponse::WebProxy, Imagekitio::Models::Accounts::OriginResponse::Gcs, Imagekitio::Models::Accounts::OriginResponse::AzureBlob, Imagekitio::Models::Accounts::OriginResponse::AkeneoPim)] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/origin_update_params.rb b/lib/imagekitio/models/accounts/origin_update_params.rb new file mode 100644 index 00000000..8f4d15c4 --- /dev/null +++ b/lib/imagekitio/models/accounts/origin_update_params.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::Origins#update + class OriginUpdateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute origin_request + # Schema for origin request resources. + # + # @return [Imagekitio::Models::Accounts::OriginRequest::S3, Imagekitio::Models::Accounts::OriginRequest::S3Compatible, Imagekitio::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekitio::Models::Accounts::OriginRequest::WebFolder, Imagekitio::Models::Accounts::OriginRequest::WebProxy, Imagekitio::Models::Accounts::OriginRequest::Gcs, Imagekitio::Models::Accounts::OriginRequest::AzureBlob, Imagekitio::Models::Accounts::OriginRequest::AkeneoPim] + required :origin_request, union: -> { Imagekitio::Accounts::OriginRequest } + + # @!method initialize(origin_request:, request_options: {}) + # @param origin_request [Imagekitio::Models::Accounts::OriginRequest::S3, Imagekitio::Models::Accounts::OriginRequest::S3Compatible, Imagekitio::Models::Accounts::OriginRequest::CloudinaryBackup, Imagekitio::Models::Accounts::OriginRequest::WebFolder, Imagekitio::Models::Accounts::OriginRequest::WebProxy, Imagekitio::Models::Accounts::OriginRequest::Gcs, Imagekitio::Models::Accounts::OriginRequest::AzureBlob, Imagekitio::Models::Accounts::OriginRequest::AkeneoPim] Schema for origin request resources. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/url_endpoint_create_params.rb b/lib/imagekitio/models/accounts/url_endpoint_create_params.rb new file mode 100644 index 00000000..bda512fe --- /dev/null +++ b/lib/imagekitio/models/accounts/url_endpoint_create_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::URLEndpoints#create + class URLEndpointCreateParams < Imagekitio::Models::Accounts::URLEndpointRequest + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/url_endpoint_delete_params.rb b/lib/imagekitio/models/accounts/url_endpoint_delete_params.rb new file mode 100644 index 00000000..45e557d2 --- /dev/null +++ b/lib/imagekitio/models/accounts/url_endpoint_delete_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::URLEndpoints#delete + class URLEndpointDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/url_endpoint_get_params.rb b/lib/imagekitio/models/accounts/url_endpoint_get_params.rb new file mode 100644 index 00000000..12a217a1 --- /dev/null +++ b/lib/imagekitio/models/accounts/url_endpoint_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::URLEndpoints#get + class URLEndpointGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/url_endpoint_list_params.rb b/lib/imagekitio/models/accounts/url_endpoint_list_params.rb new file mode 100644 index 00000000..66618368 --- /dev/null +++ b/lib/imagekitio/models/accounts/url_endpoint_list_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::URLEndpoints#list + class URLEndpointListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/url_endpoint_list_response.rb b/lib/imagekitio/models/accounts/url_endpoint_list_response.rb new file mode 100644 index 00000000..9ae3c934 --- /dev/null +++ b/lib/imagekitio/models/accounts/url_endpoint_list_response.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @type [Imagekitio::Internal::Type::Converter] + URLEndpointListResponse = + Imagekitio::Internal::Type::ArrayOf[-> { Imagekitio::Accounts::URLEndpointResponse }] + end + end +end diff --git a/lib/imagekitio/models/accounts/url_endpoint_request.rb b/lib/imagekitio/models/accounts/url_endpoint_request.rb new file mode 100644 index 00000000..7400259c --- /dev/null +++ b/lib/imagekitio/models/accounts/url_endpoint_request.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + class URLEndpointRequest < Imagekitio::Internal::Type::BaseModel + # @!attribute description + # Description of the URL endpoint. + # + # @return [String] + required :description, String + + # @!attribute 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. + # + # @return [Array, nil] + optional :origins, Imagekitio::Internal::Type::ArrayOf[String] + + # @!attribute url_prefix + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + # + # @return [String, nil] + optional :url_prefix, String, api_name: :urlPrefix + + # @!attribute url_rewriter + # Configuration for third-party URL rewriting. + # + # @return [Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai, nil] + optional :url_rewriter, + union: -> { Imagekitio::Accounts::URLEndpointRequest::URLRewriter }, + api_name: :urlRewriter + + # @!method initialize(description:, origins: nil, url_prefix: nil, url_rewriter: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::URLEndpointRequest} for more details. + # + # Schema for URL endpoint resource. + # + # @param description [String] Description of the URL endpoint. + # + # @param origins [Array] Ordered list of origin IDs to try when the file isn’t in the Media Library; Imag + # + # @param url_prefix [String] Path segment appended to your base URL to form the endpoint (letters, digits, an + # + # @param url_rewriter [Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai] Configuration for third-party URL rewriting. + + # Configuration for third-party URL rewriting. + # + # @see Imagekitio::Models::Accounts::URLEndpointRequest#url_rewriter + module URLRewriter + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :CLOUDINARY, -> { Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary } + + variant :IMGIX, -> { Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix } + + variant :AKAMAI, -> { Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai } + + class Cloudinary < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :CLOUDINARY] + required :type, const: :CLOUDINARY + + # @!attribute preserve_asset_delivery_types + # Whether to preserve `/` in the rewritten URL. + # + # @return [Boolean, nil] + optional :preserve_asset_delivery_types, + Imagekitio::Internal::Type::Boolean, + api_name: :preserveAssetDeliveryTypes + + # @!method initialize(preserve_asset_delivery_types: nil, type: :CLOUDINARY) + # @param preserve_asset_delivery_types [Boolean] Whether to preserve `/` in the rewritten URL. + # + # @param type [Symbol, :CLOUDINARY] + end + + class Imgix < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :IMGIX] + required :type, const: :IMGIX + + # @!method initialize(type: :IMGIX) + # @param type [Symbol, :IMGIX] + end + + class Akamai < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :AKAMAI] + required :type, const: :AKAMAI + + # @!method initialize(type: :AKAMAI) + # @param type [Symbol, :AKAMAI] + end + + # @!method self.variants + # @return [Array(Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai)] + end + end + end + end +end diff --git a/lib/imagekitio/models/accounts/url_endpoint_response.rb b/lib/imagekitio/models/accounts/url_endpoint_response.rb new file mode 100644 index 00000000..03669337 --- /dev/null +++ b/lib/imagekitio/models/accounts/url_endpoint_response.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::URLEndpoints#create + class URLEndpointResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute description + # Description of the URL endpoint. + # + # @return [String] + required :description, String + + # @!attribute 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. + # + # @return [Array] + required :origins, Imagekitio::Internal::Type::ArrayOf[String] + + # @!attribute url_prefix + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + # + # @return [String] + required :url_prefix, String, api_name: :urlPrefix + + # @!attribute url_rewriter + # Configuration for third-party URL rewriting. + # + # @return [Imagekitio::Models::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, Imagekitio::Models::Accounts::URLEndpointResponse::URLRewriter::Imgix, Imagekitio::Models::Accounts::URLEndpointResponse::URLRewriter::Akamai, nil] + optional :url_rewriter, + union: -> { Imagekitio::Accounts::URLEndpointResponse::URLRewriter }, + api_name: :urlRewriter + + response_only do + # @!attribute 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`. + # + # @return [String] + required :id, String + end + + # @!method initialize(id:, description:, origins:, url_prefix:, url_rewriter: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::URLEndpointResponse} for more details. + # + # URL‑endpoint object as returned by the API. + # + # @param id [String] Unique identifier for the URL-endpoint. This is generated by ImageKit when you c + # + # @param description [String] Description of the URL endpoint. + # + # @param origins [Array] Ordered list of origin IDs to try when the file isn’t in the Media Library; Imag + # + # @param url_prefix [String] Path segment appended to your base URL to form the endpoint (letters, digits, an + # + # @param url_rewriter [Imagekitio::Models::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, Imagekitio::Models::Accounts::URLEndpointResponse::URLRewriter::Imgix, Imagekitio::Models::Accounts::URLEndpointResponse::URLRewriter::Akamai] Configuration for third-party URL rewriting. + + # Configuration for third-party URL rewriting. + # + # @see Imagekitio::Models::Accounts::URLEndpointResponse#url_rewriter + module URLRewriter + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :CLOUDINARY, -> { Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Cloudinary } + + variant :IMGIX, -> { Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Imgix } + + variant :AKAMAI, -> { Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Akamai } + + class Cloudinary < Imagekitio::Internal::Type::BaseModel + # @!attribute preserve_asset_delivery_types + # Whether to preserve `/` in the rewritten URL. + # + # @return [Boolean] + required :preserve_asset_delivery_types, + Imagekitio::Internal::Type::Boolean, + api_name: :preserveAssetDeliveryTypes + + # @!attribute type + # + # @return [Symbol, :CLOUDINARY] + required :type, const: :CLOUDINARY + + # @!method initialize(preserve_asset_delivery_types:, type: :CLOUDINARY) + # @param preserve_asset_delivery_types [Boolean] Whether to preserve `/` in the rewritten URL. + # + # @param type [Symbol, :CLOUDINARY] + end + + class Imgix < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :IMGIX] + required :type, const: :IMGIX + + # @!method initialize(type: :IMGIX) + # @param type [Symbol, :IMGIX] + end + + class Akamai < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # + # @return [Symbol, :AKAMAI] + required :type, const: :AKAMAI + + # @!method initialize(type: :AKAMAI) + # @param type [Symbol, :AKAMAI] + end + + # @!method self.variants + # @return [Array(Imagekitio::Models::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, Imagekitio::Models::Accounts::URLEndpointResponse::URLRewriter::Imgix, Imagekitio::Models::Accounts::URLEndpointResponse::URLRewriter::Akamai)] + end + end + end + end +end diff --git a/lib/imagekitio/models/accounts/url_endpoint_update_params.rb b/lib/imagekitio/models/accounts/url_endpoint_update_params.rb new file mode 100644 index 00000000..5d79eeae --- /dev/null +++ b/lib/imagekitio/models/accounts/url_endpoint_update_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::URLEndpoints#update + class URLEndpointUpdateParams < Imagekitio::Models::Accounts::URLEndpointRequest + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/usage_get_params.rb b/lib/imagekitio/models/accounts/usage_get_params.rb new file mode 100644 index 00000000..a87bc6f9 --- /dev/null +++ b/lib/imagekitio/models/accounts/usage_get_params.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::Usage#get + class UsageGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute end_date + # 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. + # + # @return [Date] + required :end_date, Date + + # @!attribute start_date + # 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. + # + # @return [Date] + required :start_date, Date + + # @!method initialize(end_date:, start_date:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::UsageGetParams} for more details. + # + # @param end_date [Date] Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + # + # @param start_date [Date] Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/accounts/usage_get_response.rb b/lib/imagekitio/models/accounts/usage_get_response.rb new file mode 100644 index 00000000..45ff657b --- /dev/null +++ b/lib/imagekitio/models/accounts/usage_get_response.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Accounts + # @see Imagekitio::Resources::Accounts::Usage#get + class UsageGetResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute bandwidth_bytes + # Amount of bandwidth used in bytes. + # + # @return [Integer, nil] + optional :bandwidth_bytes, Integer, api_name: :bandwidthBytes + + # @!attribute extension_units_count + # Number of extension units used. + # + # @return [Integer, nil] + optional :extension_units_count, Integer, api_name: :extensionUnitsCount + + # @!attribute media_library_storage_bytes + # Storage used by media library in bytes. + # + # @return [Integer, nil] + optional :media_library_storage_bytes, Integer, api_name: :mediaLibraryStorageBytes + + # @!attribute original_cache_storage_bytes + # Storage used by the original cache in bytes. + # + # @return [Integer, nil] + optional :original_cache_storage_bytes, Integer, api_name: :originalCacheStorageBytes + + # @!attribute video_processing_units_count + # Number of video processing units used. + # + # @return [Integer, nil] + optional :video_processing_units_count, Integer, api_name: :videoProcessingUnitsCount + + # @!method initialize(bandwidth_bytes: nil, extension_units_count: nil, media_library_storage_bytes: nil, original_cache_storage_bytes: nil, video_processing_units_count: nil) + # @param bandwidth_bytes [Integer] Amount of bandwidth used in bytes. + # + # @param extension_units_count [Integer] Number of extension units used. + # + # @param media_library_storage_bytes [Integer] Storage used by media library in bytes. + # + # @param original_cache_storage_bytes [Integer] Storage used by the original cache in bytes. + # + # @param video_processing_units_count [Integer] Number of video processing units used. + end + end + end +end diff --git a/lib/imagekitio/models/asset_list_params.rb b/lib/imagekitio/models/asset_list_params.rb new file mode 100644 index 00000000..287e488c --- /dev/null +++ b/lib/imagekitio/models/asset_list_params.rb @@ -0,0 +1,158 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Assets#list + class AssetListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute file_type + # 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) + # + # @return [Symbol, Imagekitio::Models::AssetListParams::FileType, nil] + optional :file_type, enum: -> { Imagekitio::AssetListParams::FileType } + + # @!attribute limit + # The maximum number of results to return in response. + # + # @return [Integer, nil] + optional :limit, Integer + + # @!attribute 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. + # + # @return [String, nil] + optional :path, String + + # @!attribute search_query + # 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. + # + # @return [String, nil] + optional :search_query, String + + # @!attribute skip + # The number of results to skip before returning results. + # + # @return [Integer, nil] + optional :skip, Integer + + # @!attribute sort + # Sort the results by one of the supported fields in ascending or descending + # order. + # + # @return [Symbol, Imagekitio::Models::AssetListParams::Sort, nil] + optional :sort, enum: -> { Imagekitio::AssetListParams::Sort } + + # @!attribute 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`) + # + # @return [Symbol, Imagekitio::Models::AssetListParams::Type, nil] + optional :type, enum: -> { Imagekitio::AssetListParams::Type } + + # @!method initialize(file_type: nil, limit: nil, path: nil, search_query: nil, skip: nil, sort: nil, type: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::AssetListParams} for more details. + # + # @param file_type [Symbol, Imagekitio::Models::AssetListParams::FileType] Filter results by file type. + # + # @param limit [Integer] The maximum number of results to return in response. + # + # @param path [String] Folder path if you want to limit the search within a specific folder. For exampl + # + # @param search_query [String] Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + # + # @param skip [Integer] The number of results to skip before returning results. + # + # @param sort [Symbol, Imagekitio::Models::AssetListParams::Sort] Sort the results by one of the supported fields in ascending or descending order + # + # @param type [Symbol, Imagekitio::Models::AssetListParams::Type] Filter results by asset type. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + + # 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) + module FileType + extend Imagekitio::Internal::Type::Enum + + ALL = :all + IMAGE = :image + NON_IMAGE = :"non-image" + + # @!method self.values + # @return [Array] + end + + # Sort the results by one of the supported fields in ascending or descending + # order. + module Sort + extend Imagekitio::Internal::Type::Enum + + ASC_NAME = :ASC_NAME + DESC_NAME = :DESC_NAME + ASC_CREATED = :ASC_CREATED + DESC_CREATED = :DESC_CREATED + ASC_UPDATED = :ASC_UPDATED + DESC_UPDATED = :DESC_UPDATED + ASC_HEIGHT = :ASC_HEIGHT + DESC_HEIGHT = :DESC_HEIGHT + ASC_WIDTH = :ASC_WIDTH + DESC_WIDTH = :DESC_WIDTH + ASC_SIZE = :ASC_SIZE + DESC_SIZE = :DESC_SIZE + ASC_RELEVANCE = :ASC_RELEVANCE + DESC_RELEVANCE = :DESC_RELEVANCE + + # @!method self.values + # @return [Array] + end + + # 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`) + module Type + extend Imagekitio::Internal::Type::Enum + + FILE = :file + FILE_VERSION = :"file-version" + FOLDER = :folder + ALL = :all + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekitio/models/asset_list_response.rb b/lib/imagekitio/models/asset_list_response.rb new file mode 100644 index 00000000..7c693fe8 --- /dev/null +++ b/lib/imagekitio/models/asset_list_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # Object containing details of a file or file version. + module AssetListResponseItem + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :folder, -> { Imagekitio::Folder } + + # Object containing details of a file or file version. + variant -> { Imagekitio::File } + + # @!method self.variants + # @return [Array(Imagekitio::Models::Folder, Imagekitio::Models::File)] + end + + # @type [Imagekitio::Internal::Type::Converter] + AssetListResponse = + Imagekitio::Internal::Type::ArrayOf[union: -> { Imagekitio::Models::AssetListResponseItem }] + end +end diff --git a/lib/imagekitio/models/base_overlay.rb b/lib/imagekitio/models/base_overlay.rb new file mode 100644 index 00000000..d48136fb --- /dev/null +++ b/lib/imagekitio/models/base_overlay.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class BaseOverlay < Imagekitio::Internal::Type::BaseModel + # @!attribute position + # + # @return [Imagekitio::Models::OverlayPosition, nil] + optional :position, -> { Imagekitio::OverlayPosition } + + # @!attribute timing + # + # @return [Imagekitio::Models::OverlayTiming, nil] + optional :timing, -> { Imagekitio::OverlayTiming } + + # @!method initialize(position: nil, timing: nil) + # @param position [Imagekitio::Models::OverlayPosition] + # @param timing [Imagekitio::Models::OverlayTiming] + end + end +end diff --git a/lib/imagekitio/models/base_webhook_event.rb b/lib/imagekitio/models/base_webhook_event.rb new file mode 100644 index 00000000..1c96fa1a --- /dev/null +++ b/lib/imagekitio/models/base_webhook_event.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class BaseWebhookEvent < Imagekitio::Internal::Type::BaseModel + # @!attribute id + # Unique identifier for the event. + # + # @return [String] + required :id, String + + # @!attribute type + # The type of webhook event. + # + # @return [String] + required :type, String + + # @!method initialize(id:, type:) + # @param id [String] Unique identifier for the event. + # + # @param type [String] The type of webhook event. + end + end +end diff --git a/lib/imagekitio/models/beta/v2/file_upload_params.rb b/lib/imagekitio/models/beta/v2/file_upload_params.rb new file mode 100644 index 00000000..a2a6cf20 --- /dev/null +++ b/lib/imagekitio/models/beta/v2/file_upload_params.rb @@ -0,0 +1,510 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Beta + module V2 + # @see Imagekitio::Resources::Beta::V2::Files#upload + class FileUploadParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # Serialize upload options to handle proper formatting for ImageKit backend API. + # Special cases handled: + # - tags: converted to comma-separated string + # - responseFields: converted to comma-separated string + # - extensions: JSON stringified + # - customMetadata: JSON stringified + # - transformation: JSON stringified + # + # @api private + # + # @param params [Object] + # + # @return [Array(Object, Hash{Symbol=>Object})] + def self.dump_request(params) + state = {can_retry: true} + case (dumped = dump(params, state: state)) + in Hash + serialized = serialize_upload_options(dumped) + options = Imagekitio::Internal::Util.coerce_hash!(serialized[:request_options]).to_h + request_options = state.fetch(:can_retry) ? options : {**options, max_retries: 0} + [serialized.except(:request_options), request_options] + else + [dumped, nil] + end + end + + # @api private + # + # @param upload_options [Hash{Symbol=>Object}] + # + # @return [Hash{Symbol=>Object}] + def self.serialize_upload_options(upload_options) + serialized = {} + + upload_options.each do |key, value| + # Skip nil values + if value.nil? + serialized[key] = value + next + end + + serialized[key] = case key + when :tags, :responseFields + # Tags and response fields should be comma-separated strings + value.is_a?(Array) ? value.join(",") : value + when :extensions + # Extensions should be JSON stringified + value.is_a?(Array) ? JSON.generate(value) : value + when :customMetadata + # Custom metadata should be JSON stringified + value.is_a?(Hash) ? JSON.generate(value) : value + when :transformation + # Transformation should be JSON stringified + value.is_a?(Hash) || value.respond_to?(:to_h) ? JSON.generate(value) : value + else + value + end + end + + serialized + end + + # @!attribute 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. + # + # @return [Pathname, StringIO, IO, String, Imagekitio::FilePart] + required :file, Imagekitio::Internal::Type::FileInput + + # @!attribute file_name + # The name with which the file has to be uploaded. + # + # @return [String] + required :file_name, String, api_name: :fileName + + # @!attribute 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. + # + # **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. + # + # @return [String, nil] + optional :token, String + + # @!attribute 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). + # + # @return [String, nil] + optional :checks, String + + # @!attribute custom_coordinates + # 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. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates + + # @!attribute custom_metadata + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. + # + # @return [String, nil] + optional :description, String + + # @!attribute extensions + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + # + # @return [Array, nil] + optional :extensions, -> { Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::ExtensionItem] } + + # @!attribute 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. + # + # @return [String, nil] + optional :folder, String + + # @!attribute is_private_file + # 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. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekitio::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # 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. + # + # @return [Boolean, nil] + optional :is_published, Imagekitio::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute overwrite_ai_tags + # 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. + # + # @return [Boolean, nil] + optional :overwrite_ai_tags, Imagekitio::Internal::Type::Boolean, api_name: :overwriteAITags + + # @!attribute overwrite_custom_metadata + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + # + # @return [Boolean, nil] + optional :overwrite_custom_metadata, + Imagekitio::Internal::Type::Boolean, + api_name: :overwriteCustomMetadata + + # @!attribute overwrite_file + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + # + # @return [Boolean, nil] + optional :overwrite_file, Imagekitio::Internal::Type::Boolean, api_name: :overwriteFile + + # @!attribute overwrite_tags + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + # + # @return [Boolean, nil] + optional :overwrite_tags, Imagekitio::Internal::Type::Boolean, api_name: :overwriteTags + + # @!attribute response_fields + # Array of response field keys to include in the API response body. + # + # @return [Array, nil] + optional :response_fields, + -> { + Imagekitio::Internal::Type::ArrayOf[enum: Imagekitio::Beta::V2::FileUploadParams::ResponseField] + }, + api_name: :responseFields + + # @!attribute 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. + # + # @return [Array, nil] + optional :tags, Imagekitio::Internal::Type::ArrayOf[String] + + # @!attribute 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. + # + # @return [Imagekitio::Models::Beta::V2::FileUploadParams::Transformation, nil] + optional :transformation, -> { Imagekitio::Beta::V2::FileUploadParams::Transformation } + + # @!attribute use_unique_file_name + # 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. + # + # @return [Boolean, nil] + optional :use_unique_file_name, Imagekitio::Internal::Type::Boolean, api_name: :useUniqueFileName + + # @!attribute webhook_url + # 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. + # + # @return [String, nil] + optional :webhook_url, String, api_name: :webhookUrl + + # @!method initialize(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, response_fields: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadParams} for more details. + # + # @param file [Pathname, StringIO, IO, String, Imagekitio::FilePart] The API accepts any of the following: + # + # @param file_name [String] The name with which the file has to be uploaded. + # + # @param token [String] This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses i + # + # @param checks [String] Server-side checks to run on the asset. + # + # @param custom_coordinates [String] Define an important area in the image. This is only relevant for image type file + # + # @param custom_metadata [Hash{Symbol=>Object}] JSON key-value pairs to associate with the asset. Create the custom metadata fie + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param folder [String] The folder path in which the image has to be uploaded. If the folder(s) didn't e + # + # @param is_private_file [Boolean] Whether to mark the file as private or not. + # + # @param is_published [Boolean] Whether to upload file as published or not. + # + # @param overwrite_ai_tags [Boolean] If set to `true` and a file already exists at the exact location, its AITags wil + # + # @param overwrite_custom_metadata [Boolean] If the request does not have `customMetadata`, and a file already exists at the + # + # @param overwrite_file [Boolean] If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # + # @param overwrite_tags [Boolean] If the request does not have `tags`, and a file already exists at the exact loca + # + # @param response_fields [Array] Array of response field keys to include in the API response body. + # + # @param tags [Array] Set the tags while uploading the file. + # + # @param transformation [Imagekitio::Models::Beta::V2::FileUploadParams::Transformation] Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # @param use_unique_file_name [Boolean] Whether to use a unique filename for this file or not. + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + + module ResponseField + extend Imagekitio::Internal::Type::Enum + + TAGS = :tags + CUSTOM_COORDINATES = :customCoordinates + IS_PRIVATE_FILE = :isPrivateFile + EMBEDDED_METADATA = :embeddedMetadata + IS_PUBLISHED = :isPublished + CUSTOM_METADATA = :customMetadata + METADATA = :metadata + SELECTED_FIELDS_SCHEMA = :selectedFieldsSchema + + # @!method self.values + # @return [Array] + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute post + # 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`. + # + # @return [Array, nil] + optional :post, + -> { Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::Beta::V2::FileUploadParams::Transformation::Post] } + + # @!attribute pre + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + # + # @return [String, nil] + optional :pre, String + + # @!method initialize(post: nil, pre: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadParams::Transformation} for more + # details. + # + # 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 post [Array] List of transformations to apply _after_ the file is uploaded. + # + # @param pre [String] Transformation string to apply before uploading the file to the Media Library. U + + module Post + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :transformation, + -> { Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Transformation } + + variant :"gif-to-video", -> { Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo } + + variant :thumbnail, -> { Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail } + + variant :abs, -> { Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs } + + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Transformation type. + # + # @return [Symbol, :transformation] + required :type, const: :transformation + + # @!attribute value + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + # + # @return [String] + required :value, String + + # @!method initialize(value:, type: :transformation) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Transformation} + # for more details. + # + # @param value [String] Transformation string (e.g. `w-200,h-200`). + # + # @param type [Symbol, :transformation] Transformation type. + end + + class GifToVideo < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Converts an animated GIF into an MP4. + # + # @return [Symbol, :"gif-to-video"] + required :type, const: :"gif-to-video" + + # @!attribute value + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + # + # @return [String, nil] + optional :value, String + + # @!method initialize(value: nil, type: :"gif-to-video") + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo} + # for more details. + # + # @param value [String] Optional transformation string to apply to the output video. + # + # @param type [Symbol, :"gif-to-video"] Converts an animated GIF into an MP4. + end + + class Thumbnail < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Generates a thumbnail image. + # + # @return [Symbol, :thumbnail] + required :type, const: :thumbnail + + # @!attribute value + # Optional transformation string. + # **Example**: `w-150,h-150` + # + # @return [String, nil] + optional :value, String + + # @!method initialize(value: nil, type: :thumbnail) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail} + # for more details. + # + # @param value [String] Optional transformation string. + # + # @param type [Symbol, :thumbnail] Generates a thumbnail image. + end + + class Abs < Imagekitio::Internal::Type::BaseModel + # @!attribute protocol + # Streaming protocol to use (`hls` or `dash`). + # + # @return [Symbol, Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol] + required :protocol, + enum: -> { Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol } + + # @!attribute type + # Adaptive Bitrate Streaming (ABS) setup. + # + # @return [Symbol, :abs] + required :type, const: :abs + + # @!attribute value + # List of different representations you want to create separated by an underscore. + # + # @return [String] + required :value, String + + # @!method initialize(protocol:, value:, type: :abs) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs} for + # more details. + # + # @param protocol [Symbol, Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol] Streaming protocol to use (`hls` or `dash`). + # + # @param value [String] List of different representations you want to create separated by an underscore. + # + # @param type [Symbol, :abs] Adaptive Bitrate Streaming (ABS) setup. + + # Streaming protocol to use (`hls` or `dash`). + # + # @see Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs#protocol + module Protocol + extend Imagekitio::Internal::Type::Enum + + HLS = :hls + DASH = :dash + + # @!method self.values + # @return [Array] + end + end + + # @!method self.variants + # @return [Array(Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Transformation, Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs)] + end + end + end + end + end + end +end diff --git a/lib/imagekitio/models/beta/v2/file_upload_response.rb b/lib/imagekitio/models/beta/v2/file_upload_response.rb new file mode 100644 index 00000000..e9e69068 --- /dev/null +++ b/lib/imagekitio/models/beta/v2/file_upload_response.rb @@ -0,0 +1,618 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Beta + module V2 + # @see Imagekitio::Resources::Beta::V2::Files#upload + class FileUploadResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute ai_tags + # An array of tags assigned to the uploaded file by auto tagging. + # + # @return [Array, nil] + optional :ai_tags, + -> { Imagekitio::Internal::Type::ArrayOf[Imagekitio::Models::Beta::V2::FileUploadResponse::AITag] }, + api_name: :AITags, + nil?: true + + # @!attribute audio_codec + # The audio codec used in the video (only for video). + # + # @return [String, nil] + optional :audio_codec, String, api_name: :audioCodec + + # @!attribute bit_rate + # The bit rate of the video in kbps (only for video). + # + # @return [Integer, nil] + optional :bit_rate, Integer, api_name: :bitRate + + # @!attribute custom_coordinates + # 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. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # 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. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + # + # @return [String, nil] + optional :description, String + + # @!attribute duration + # The duration of the video in seconds (only for video). + # + # @return [Integer, nil] + optional :duration, Integer + + # @!attribute embedded_metadata + # 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. + # + # @return [Hash{Symbol=>Object}, nil] + optional :embedded_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :embeddedMetadata + + # @!attribute extension_status + # 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. + # + # @return [Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus, nil] + optional :extension_status, + -> { Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus }, + api_name: :extensionStatus + + # @!attribute file_id + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + # + # @return [String, nil] + optional :file_id, String, api_name: :fileId + + # @!attribute file_path + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + # + # @return [String, nil] + optional :file_path, String, api_name: :filePath + + # @!attribute file_type + # Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @return [String, nil] + optional :file_type, String, api_name: :fileType + + # @!attribute height + # Height of the image in pixels (Only for images) + # + # @return [Float, nil] + optional :height, Float + + # @!attribute is_private_file + # 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. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekitio::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # 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. + # + # @return [Boolean, nil] + optional :is_published, Imagekitio::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute metadata + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + # + # @return [Imagekitio::Models::Metadata, nil] + optional :metadata, -> { Imagekitio::Metadata } + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute selected_fields_schema + # 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. + # + # @return [Hash{Symbol=>Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema}, nil] + optional :selected_fields_schema, + -> { Imagekitio::Internal::Type::HashOf[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema] }, + api_name: :selectedFieldsSchema + + # @!attribute size + # Size of the image file in Bytes. + # + # @return [Float, nil] + optional :size, Float + + # @!attribute tags + # 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. + # + # @return [Array, nil] + optional :tags, Imagekitio::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute thumbnail_url + # In the case of an image, a small thumbnail URL. + # + # @return [String, nil] + optional :thumbnail_url, String, api_name: :thumbnailUrl + + # @!attribute url + # A publicly accessible URL of the file. + # + # @return [String, nil] + optional :url, String + + # @!attribute version_info + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @return [Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo, nil] + optional :version_info, + -> { Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo }, + api_name: :versionInfo + + # @!attribute video_codec + # The video codec used in the video (only for video). + # + # @return [String, nil] + optional :video_codec, String, api_name: :videoCodec + + # @!attribute width + # Width of the image in pixels (Only for Images) + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(ai_tags: nil, audio_codec: nil, bit_rate: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, duration: nil, embedded_metadata: nil, extension_status: nil, file_id: nil, file_path: nil, file_type: nil, height: nil, is_private_file: nil, is_published: nil, metadata: nil, name: nil, selected_fields_schema: nil, size: nil, tags: nil, thumbnail_url: nil, url: nil, version_info: nil, video_codec: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadResponse} for more details. + # + # Object containing details of a successful upload. + # + # @param ai_tags [Array, nil] An array of tags assigned to the uploaded file by auto tagging. + # + # @param audio_codec [String] The audio codec used in the video (only for video). + # + # @param bit_rate [Integer] The bit rate of the video in kbps (only for video). + # + # @param custom_coordinates [String, nil] Value of custom coordinates associated with the image in the format `x,y,width,h + # + # @param custom_metadata [Hash{Symbol=>Object}] A key-value data associated with the asset. Use `responseField` in API request t + # + # @param description [String] Optional text to describe the contents of the file. Can be set by the user or th + # + # @param duration [Integer] The duration of the video in seconds (only for video). + # + # @param embedded_metadata [Hash{Symbol=>Object}] Consolidated embedded metadata associated with the file. It includes exif, iptc, + # + # @param extension_status [Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus] Extension names with their processing status at the time of completion of the re + # + # @param file_id [String] Unique fileId. Store this fileld in your database, as this will be used to perfo + # + # @param file_path [String] The relative path of the file in the media library e.g. `/marketing-assets/new-b + # + # @param file_type [String] Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @param height [Float] Height of the image in pixels (Only for images) + # + # @param is_private_file [Boolean] Is the file marked as private. It can be either `true` or `false`. Send `isPriva + # + # @param is_published [Boolean] Is the file published or in draft state. It can be either `true` or `false`. Sen + # + # @param metadata [Imagekitio::Models::Metadata] Legacy metadata. Send `metadata` in `responseFields` in API request to get metad + # + # @param name [String] Name of the asset. + # + # @param selected_fields_schema [Hash{Symbol=>Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema}] This field is included in the response only if the Path policy feature is availa + # + # @param size [Float] Size of the image file in Bytes. + # + # @param tags [Array, nil] The array of tags associated with the asset. If no tags are set, it will be `nul + # + # @param thumbnail_url [String] In the case of an image, a small thumbnail URL. + # + # @param url [String] A publicly accessible URL of the file. + # + # @param version_info [Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo] An object containing the file or file version's `id` (versionId) and `name`. + # + # @param video_codec [String] The video codec used in the video (only for video). + # + # @param width [Float] Width of the image in pixels (Only for Images) + + class AITag < Imagekitio::Internal::Type::BaseModel + # @!attribute confidence + # Confidence score of the tag. + # + # @return [Float, nil] + optional :confidence, Float + + # @!attribute name + # Name of the tag. + # + # @return [String, nil] + optional :name, String + + # @!attribute source + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + # + # @return [String, nil] + optional :source, String + + # @!method initialize(confidence: nil, name: nil, source: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadResponse::AITag} for more details. + # + # @param confidence [Float] Confidence score of the tag. + # + # @param name [String] Name of the tag. + # + # @param source [String] Array of `AITags` associated with the image. If no `AITags` are set, it will be + end + + # @see Imagekitio::Models::Beta::V2::FileUploadResponse#extension_status + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + # @!attribute ai_auto_description + # + # @return [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription, nil] + optional :ai_auto_description, + enum: -> { Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription }, + api_name: :"ai-auto-description" + + # @!attribute aws_auto_tagging + # + # @return [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging, nil] + optional :aws_auto_tagging, + enum: -> { Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging }, + api_name: :"aws-auto-tagging" + + # @!attribute google_auto_tagging + # + # @return [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging, nil] + optional :google_auto_tagging, + enum: -> { Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging }, + api_name: :"google-auto-tagging" + + # @!attribute remove_bg + # + # @return [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg, nil] + optional :remove_bg, + enum: -> { Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg }, + api_name: :"remove-bg" + + # @!method initialize(ai_auto_description: nil, aws_auto_tagging: nil, google_auto_tagging: nil, remove_bg: nil) + # 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 ai_auto_description [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription] + # @param aws_auto_tagging [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging] + # @param google_auto_tagging [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging] + # @param remove_bg [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg] + + # @see Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus#ai_auto_description + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus#aws_auto_tagging + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus#google_auto_tagging + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus#remove_bg + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + end + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Type of the custom metadata field. + # + # @return [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type] + required :type, enum: -> { Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type } + + # @!attribute default_value + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue }, + api_name: :defaultValue + + # @!attribute is_value_required + # Specifies if the custom metadata field is required or not. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekitio::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # 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. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MaxValue }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # 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. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MinValue }, + api_name: :minValue + + # @!attribute read_only + # 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. + # + # @return [Boolean, nil] + optional :read_only, Imagekitio::Internal::Type::Boolean, api_name: :readOnly + + # @!attribute select_options + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::SelectOption] }, + api_name: :selectOptions + + # @!attribute select_options_truncated + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + # + # @return [Boolean, nil] + optional :select_options_truncated, + Imagekitio::Internal::Type::Boolean, + api_name: :selectOptionsTruncated + + # @!method initialize(type:, default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, read_only: nil, select_options: nil, select_options_truncated: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema} for + # more details. + # + # @param type [Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type] Type of the custom metadata field. + # + # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. The value should match the `ty + # + # @param is_value_required [Boolean] Specifies if the custom metadata field is required or not. + # + # @param max_length [Float] Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param max_value [String, Float] Maximum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param min_length [Float] Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param min_value [String, Float] Minimum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param read_only [Boolean] Indicates whether the custom metadata field is read only. A read only field cann + # + # @param select_options [Array] An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @param select_options_truncated [Boolean] Specifies if the selectOptions array is truncated. It is truncated when number o + + # Type of the custom metadata field. + # + # @see Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema#type + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT = :Text + TEXTAREA = :Textarea + NUMBER = :Number + DATE = :Date + BOOLEAN = :Boolean + SINGLE_SELECT = :SingleSelect + MULTI_SELECT = :MultiSelect + + # @!method self.values + # @return [Array] + end + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + # + # @see Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema#default_value + module DefaultValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::MixedArray } + + module Mixed + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekitio::Internal::Type::Converter] + MixedArray = + Imagekitio::Internal::Type::ArrayOf[union: -> { Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Mixed }] + end + + # 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. + # + # @see Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema#max_value + module MaxValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # 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. + # + # @see Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema#min_value + module MinValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + + # @see Imagekitio::Models::Beta::V2::FileUploadResponse#version_info + class VersionInfo < Imagekitio::Internal::Type::BaseModel + # @!attribute id + # Unique identifier of the file version. + # + # @return [String, nil] + optional :id, String + + # @!attribute name + # Name of the file version. + # + # @return [String, nil] + optional :name, String + + # @!method initialize(id: nil, name: nil) + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @param id [String] Unique identifier of the file version. + # + # @param name [String] Name of the file version. + end + end + end + end + end +end diff --git a/lib/imagekitio/models/cache/invalidation_create_params.rb b/lib/imagekitio/models/cache/invalidation_create_params.rb new file mode 100644 index 00000000..2e400739 --- /dev/null +++ b/lib/imagekitio/models/cache/invalidation_create_params.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Cache + # @see Imagekitio::Resources::Cache::Invalidation#create + class InvalidationCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute url + # The full URL of the file to be purged. + # + # @return [String] + required :url, String + + # @!method initialize(url:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Cache::InvalidationCreateParams} for more details. + # + # @param url [String] The full URL of the file to be purged. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/cache/invalidation_create_response.rb b/lib/imagekitio/models/cache/invalidation_create_response.rb new file mode 100644 index 00000000..8739f659 --- /dev/null +++ b/lib/imagekitio/models/cache/invalidation_create_response.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Cache + # @see Imagekitio::Resources::Cache::Invalidation#create + class InvalidationCreateResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute request_id + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + # + # @return [String, nil] + optional :request_id, String, api_name: :requestId + + # @!method initialize(request_id: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Cache::InvalidationCreateResponse} for more details. + # + # @param request_id [String] Unique identifier of the purge request. This can be used to check the status of + end + end + end +end diff --git a/lib/imagekitio/models/cache/invalidation_get_params.rb b/lib/imagekitio/models/cache/invalidation_get_params.rb new file mode 100644 index 00000000..850a1fa7 --- /dev/null +++ b/lib/imagekitio/models/cache/invalidation_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Cache + # @see Imagekitio::Resources::Cache::Invalidation#get + class InvalidationGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/cache/invalidation_get_response.rb b/lib/imagekitio/models/cache/invalidation_get_response.rb new file mode 100644 index 00000000..f9fc571e --- /dev/null +++ b/lib/imagekitio/models/cache/invalidation_get_response.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Cache + # @see Imagekitio::Resources::Cache::Invalidation#get + class InvalidationGetResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute status + # Status of the purge request. + # + # @return [Symbol, Imagekitio::Models::Cache::InvalidationGetResponse::Status, nil] + optional :status, enum: -> { Imagekitio::Models::Cache::InvalidationGetResponse::Status } + + # @!method initialize(status: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Cache::InvalidationGetResponse} for more details. + # + # @param status [Symbol, Imagekitio::Models::Cache::InvalidationGetResponse::Status] Status of the purge request. + + # Status of the purge request. + # + # @see Imagekitio::Models::Cache::InvalidationGetResponse#status + module Status + extend Imagekitio::Internal::Type::Enum + + PENDING = :Pending + COMPLETED = :Completed + + # @!method self.values + # @return [Array] + end + end + end + end +end diff --git a/lib/imagekitio/models/custom_metadata_field.rb b/lib/imagekitio/models/custom_metadata_field.rb new file mode 100644 index 00000000..bf69f73f --- /dev/null +++ b/lib/imagekitio/models/custom_metadata_field.rb @@ -0,0 +1,243 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::CustomMetadataFields#create + class CustomMetadataField < Imagekitio::Internal::Type::BaseModel + # @!attribute id + # Unique identifier for the custom metadata field. Use this to update the field. + # + # @return [String] + required :id, String + + # @!attribute label + # 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. + # + # @return [String] + required :label, String + + # @!attribute name + # 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. + # + # @return [String] + required :name, String + + # @!attribute schema + # An object that describes the rules for the custom metadata field value. + # + # @return [Imagekitio::Models::CustomMetadataField::Schema] + required :schema, -> { Imagekitio::CustomMetadataField::Schema } + + # @!method initialize(id:, label:, name:, schema:) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataField} for more details. + # + # Object containing details of a custom metadata field. + # + # @param id [String] Unique identifier for the custom metadata field. Use this to update the field. + # + # @param label [String] Human readable name of the custom metadata field. This name is displayed as form + # + # @param name [String] API name of the custom metadata field. This becomes the key while setting `custo + # + # @param schema [Imagekitio::Models::CustomMetadataField::Schema] An object that describes the rules for the custom metadata field value. + + # @see Imagekitio::Models::CustomMetadataField#schema + class Schema < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Type of the custom metadata field. + # + # @return [Symbol, Imagekitio::Models::CustomMetadataField::Schema::Type] + required :type, enum: -> { Imagekitio::CustomMetadataField::Schema::Type } + + # @!attribute default_value + # The default value for this custom metadata field. Data type of default value + # depends on the field type. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { Imagekitio::CustomMetadataField::Schema::DefaultValue }, + api_name: :defaultValue + + # @!attribute is_value_required + # Specifies if the this custom metadata field is required or not. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekitio::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # 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. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { + Imagekitio::CustomMetadataField::Schema::MaxValue + }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # 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. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { + Imagekitio::CustomMetadataField::Schema::MinValue + }, + api_name: :minValue + + # @!attribute select_options + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { + Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::CustomMetadataField::Schema::SelectOption] + }, + api_name: :selectOptions + + # @!method initialize(type:, default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, select_options: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataField::Schema} for more details. + # + # An object that describes the rules for the custom metadata field value. + # + # @param type [Symbol, Imagekitio::Models::CustomMetadataField::Schema::Type] Type of the custom metadata field. + # + # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. Data type of default value dep + # + # @param is_value_required [Boolean] Specifies if the this custom metadata field is required or not. + # + # @param max_length [Float] Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param max_value [String, Float] Maximum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param min_length [Float] Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param min_value [String, Float] Minimum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param select_options [Array] An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + + # Type of the custom metadata field. + # + # @see Imagekitio::Models::CustomMetadataField::Schema#type + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT = :Text + TEXTAREA = :Textarea + NUMBER = :Number + DATE = :Date + BOOLEAN = :Boolean + SINGLE_SELECT = :SingleSelect + MULTI_SELECT = :MultiSelect + + # @!method self.values + # @return [Array] + end + + # The default value for this custom metadata field. Data type of default value + # depends on the field type. + # + # @see Imagekitio::Models::CustomMetadataField::Schema#default_value + module DefaultValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekitio::Models::CustomMetadataField::Schema::DefaultValue::MixedArray } + + module Mixed + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekitio::Internal::Type::Converter] + MixedArray = + Imagekitio::Internal::Type::ArrayOf[union: -> { + Imagekitio::CustomMetadataField::Schema::DefaultValue::Mixed + }] + end + + # 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. + # + # @see Imagekitio::Models::CustomMetadataField::Schema#max_value + module MaxValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # 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. + # + # @see Imagekitio::Models::CustomMetadataField::Schema#min_value + module MinValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + end + end +end diff --git a/lib/imagekitio/models/custom_metadata_field_create_params.rb b/lib/imagekitio/models/custom_metadata_field_create_params.rb new file mode 100644 index 00000000..570b94cb --- /dev/null +++ b/lib/imagekitio/models/custom_metadata_field_create_params.rb @@ -0,0 +1,238 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::CustomMetadataFields#create + class CustomMetadataFieldCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute 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. + # + # @return [String] + required :label, String + + # @!attribute name + # API name of the custom metadata field. This should be unique across all + # (including deleted) custom metadata fields. + # + # @return [String] + required :name, String + + # @!attribute schema + # + # @return [Imagekitio::Models::CustomMetadataFieldCreateParams::Schema] + required :schema, -> { Imagekitio::CustomMetadataFieldCreateParams::Schema } + + # @!method initialize(label:, name:, schema:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataFieldCreateParams} for more details. + # + # @param label [String] Human readable name of the custom metadata field. This should be unique across a + # + # @param name [String] API name of the custom metadata field. This should be unique across all (includi + # + # @param schema [Imagekitio::Models::CustomMetadataFieldCreateParams::Schema] + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + + class Schema < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Type of the custom metadata field. + # + # @return [Symbol, Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::Type] + required :type, enum: -> { Imagekitio::CustomMetadataFieldCreateParams::Schema::Type } + + # @!attribute default_value + # 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. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue }, + api_name: :defaultValue + + # @!attribute is_value_required + # 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. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekitio::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # 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. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { Imagekitio::CustomMetadataFieldCreateParams::Schema::MaxValue }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # 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. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { Imagekitio::CustomMetadataFieldCreateParams::Schema::MinValue }, + api_name: :minValue + + # @!attribute select_options + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { + Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::CustomMetadataFieldCreateParams::Schema::SelectOption] + }, + api_name: :selectOptions + + # @!method initialize(type:, default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, select_options: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataFieldCreateParams::Schema} for more details. + # + # @param type [Symbol, Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::Type] Type of the custom metadata field. + # + # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. This property is only required + # + # @param is_value_required [Boolean] Sets this custom metadata field as required. Setting custom metadata fields on a + # + # @param max_length [Float] Maximum length of string. Only set this property if `type` is set to `Text` or ` + # + # @param max_value [String, Float] Maximum value of the field. Only set this property if field type is `Date` or `N + # + # @param min_length [Float] Minimum length of string. Only set this property if `type` is set to `Text` or ` + # + # @param min_value [String, Float] Minimum value of the field. Only set this property if field type is `Date` or `N + # + # @param select_options [Array] An array of allowed values. This property is only required if `type` property is + + # Type of the custom metadata field. + # + # @see Imagekitio::Models::CustomMetadataFieldCreateParams::Schema#type + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT = :Text + TEXTAREA = :Textarea + NUMBER = :Number + DATE = :Date + BOOLEAN = :Boolean + SINGLE_SELECT = :SingleSelect + MULTI_SELECT = :MultiSelect + + # @!method self.values + # @return [Array] + end + + # 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. + # + # @see Imagekitio::Models::CustomMetadataFieldCreateParams::Schema#default_value + module DefaultValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::DefaultValue::MixedArray } + + module Mixed + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekitio::Internal::Type::Converter] + MixedArray = + Imagekitio::Internal::Type::ArrayOf[union: -> { + Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Mixed + }] + end + + # 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. + # + # @see Imagekitio::Models::CustomMetadataFieldCreateParams::Schema#max_value + module MaxValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # 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. + # + # @see Imagekitio::Models::CustomMetadataFieldCreateParams::Schema#min_value + module MinValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + end + end +end diff --git a/lib/imagekitio/models/custom_metadata_field_delete_params.rb b/lib/imagekitio/models/custom_metadata_field_delete_params.rb new file mode 100644 index 00000000..118fc7bc --- /dev/null +++ b/lib/imagekitio/models/custom_metadata_field_delete_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::CustomMetadataFields#delete + class CustomMetadataFieldDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/custom_metadata_field_delete_response.rb b/lib/imagekitio/models/custom_metadata_field_delete_response.rb new file mode 100644 index 00000000..11a49967 --- /dev/null +++ b/lib/imagekitio/models/custom_metadata_field_delete_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::CustomMetadataFields#delete + class CustomMetadataFieldDeleteResponse < Imagekitio::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekitio/models/custom_metadata_field_list_params.rb b/lib/imagekitio/models/custom_metadata_field_list_params.rb new file mode 100644 index 00000000..32e2e8b2 --- /dev/null +++ b/lib/imagekitio/models/custom_metadata_field_list_params.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::CustomMetadataFields#list + class CustomMetadataFieldListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute folder_path + # 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. + # + # @return [String, nil] + optional :folder_path, String + + # @!attribute include_deleted + # Set it to `true` to include deleted field objects in the API response. + # + # @return [Boolean, nil] + optional :include_deleted, Imagekitio::Internal::Type::Boolean + + # @!method initialize(folder_path: nil, include_deleted: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataFieldListParams} for more details. + # + # @param folder_path [String] The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custo + # + # @param include_deleted [Boolean] Set it to `true` to include deleted field objects in the API response. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/custom_metadata_field_list_response.rb b/lib/imagekitio/models/custom_metadata_field_list_response.rb new file mode 100644 index 00000000..06e4f254 --- /dev/null +++ b/lib/imagekitio/models/custom_metadata_field_list_response.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @type [Imagekitio::Internal::Type::Converter] + CustomMetadataFieldListResponse = + Imagekitio::Internal::Type::ArrayOf[-> { Imagekitio::CustomMetadataField }] + end +end diff --git a/lib/imagekitio/models/custom_metadata_field_update_params.rb b/lib/imagekitio/models/custom_metadata_field_update_params.rb new file mode 100644 index 00000000..bf648397 --- /dev/null +++ b/lib/imagekitio/models/custom_metadata_field_update_params.rb @@ -0,0 +1,212 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::CustomMetadataFields#update + class CustomMetadataFieldUpdateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute 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. + # + # @return [String, nil] + optional :label, String + + # @!attribute 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`. + # + # @return [Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema, nil] + optional :schema, -> { Imagekitio::CustomMetadataFieldUpdateParams::Schema } + + # @!method initialize(label: nil, schema: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataFieldUpdateParams} for more details. + # + # @param label [String] Human readable name of the custom metadata field. This should be unique across a + # + # @param schema [Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema] An object that describes the rules for the custom metadata key. This parameter i + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + + class Schema < Imagekitio::Internal::Type::BaseModel + # @!attribute default_value + # 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. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue }, + api_name: :defaultValue + + # @!attribute is_value_required + # 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. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekitio::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # 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. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { Imagekitio::CustomMetadataFieldUpdateParams::Schema::MaxValue }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # 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. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { Imagekitio::CustomMetadataFieldUpdateParams::Schema::MinValue }, + api_name: :minValue + + # @!attribute select_options + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { + Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::CustomMetadataFieldUpdateParams::Schema::SelectOption] + }, + api_name: :selectOptions + + # @!method initialize(default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, select_options: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema} for more details. + # + # 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 default_value [String, Float, Boolean, Array] The default value for this custom metadata field. This property is only required + # + # @param is_value_required [Boolean] Sets this custom metadata field as required. Setting custom metadata fields on a + # + # @param max_length [Float] Maximum length of string. Only set this property if `type` is set to `Text` or ` + # + # @param max_value [String, Float] Maximum value of the field. Only set this property if field type is `Date` or `N + # + # @param min_length [Float] Minimum length of string. Only set this property if `type` is set to `Text` or ` + # + # @param min_value [String, Float] Minimum value of the field. Only set this property if field type is `Date` or `N + # + # @param select_options [Array] An array of allowed values. This property is only required if `type` property is + + # 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. + # + # @see Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema#default_value + module DefaultValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::DefaultValue::MixedArray } + + module Mixed + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekitio::Internal::Type::Converter] + MixedArray = + Imagekitio::Internal::Type::ArrayOf[union: -> { + Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Mixed + }] + end + + # 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. + # + # @see Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema#max_value + module MaxValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # 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. + # + # @see Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema#min_value + module MinValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + end + end +end diff --git a/lib/imagekitio/models/extensions.rb b/lib/imagekitio/models/extensions.rb new file mode 100644 index 00000000..b71af518 --- /dev/null +++ b/lib/imagekitio/models/extensions.rb @@ -0,0 +1,136 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module ExtensionItem + extend Imagekitio::Internal::Type::Union + + discriminator :name + + variant :"remove-bg", -> { Imagekitio::ExtensionItem::RemoveBg } + + variant :"ai-auto-description", -> { Imagekitio::ExtensionItem::AIAutoDescription } + + variant -> { Imagekitio::ExtensionItem::AutoTaggingExtension } + + class RemoveBg < Imagekitio::Internal::Type::BaseModel + # @!attribute name + # Specifies the background removal extension. + # + # @return [Symbol, :"remove-bg"] + required :name, const: :"remove-bg" + + # @!attribute options + # + # @return [Imagekitio::Models::ExtensionItem::RemoveBg::Options, nil] + optional :options, -> { Imagekitio::ExtensionItem::RemoveBg::Options } + + # @!method initialize(options: nil, name: :"remove-bg") + # @param options [Imagekitio::Models::ExtensionItem::RemoveBg::Options] + # + # @param name [Symbol, :"remove-bg"] Specifies the background removal extension. + + # @see Imagekitio::Models::ExtensionItem::RemoveBg#options + class Options < Imagekitio::Internal::Type::BaseModel + # @!attribute add_shadow + # Whether to add an artificial shadow to the result. Default is false. Note: + # Adding shadows is currently only supported for car photos. + # + # @return [Boolean, nil] + optional :add_shadow, Imagekitio::Internal::Type::Boolean + + # @!attribute bg_color + # 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. + # + # @return [String, nil] + optional :bg_color, String + + # @!attribute bg_image_url + # Sets a background image from a URL. If this parameter is set, `bg_color` must be + # empty. + # + # @return [String, nil] + optional :bg_image_url, String + + # @!attribute semitransparency + # Allows semi-transparent regions in the result. Default is true. Note: + # Semitransparency is currently only supported for car windows. + # + # @return [Boolean, nil] + optional :semitransparency, Imagekitio::Internal::Type::Boolean + + # @!method initialize(add_shadow: nil, bg_color: nil, bg_image_url: nil, semitransparency: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::ExtensionItem::RemoveBg::Options} for more details. + # + # @param add_shadow [Boolean] Whether to add an artificial shadow to the result. Default is false. Note: Addin + # + # @param bg_color [String] Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or col + # + # @param bg_image_url [String] Sets a background image from a URL. If this parameter is set, `bg_color` must be + # + # @param semitransparency [Boolean] Allows semi-transparent regions in the result. Default is true. Note: Semitransp + end + end + + class AutoTaggingExtension < Imagekitio::Internal::Type::BaseModel + # @!attribute max_tags + # Maximum number of tags to attach to the asset. + # + # @return [Integer] + required :max_tags, Integer, api_name: :maxTags + + # @!attribute min_confidence + # Minimum confidence level for tags to be considered valid. + # + # @return [Integer] + required :min_confidence, Integer, api_name: :minConfidence + + # @!attribute name + # Specifies the auto-tagging extension used. + # + # @return [Symbol, Imagekitio::Models::ExtensionItem::AutoTaggingExtension::Name] + required :name, enum: -> { Imagekitio::ExtensionItem::AutoTaggingExtension::Name } + + # @!method initialize(max_tags:, min_confidence:, name:) + # @param max_tags [Integer] Maximum number of tags to attach to the asset. + # + # @param min_confidence [Integer] Minimum confidence level for tags to be considered valid. + # + # @param name [Symbol, Imagekitio::Models::ExtensionItem::AutoTaggingExtension::Name] Specifies the auto-tagging extension used. + + # Specifies the auto-tagging extension used. + # + # @see Imagekitio::Models::ExtensionItem::AutoTaggingExtension#name + module Name + extend Imagekitio::Internal::Type::Enum + + GOOGLE_AUTO_TAGGING = :"google-auto-tagging" + AWS_AUTO_TAGGING = :"aws-auto-tagging" + + # @!method self.values + # @return [Array] + end + end + + class AIAutoDescription < Imagekitio::Internal::Type::BaseModel + # @!attribute name + # Specifies the auto description extension. + # + # @return [Symbol, :"ai-auto-description"] + required :name, const: :"ai-auto-description" + + # @!method initialize(name: :"ai-auto-description") + # @param name [Symbol, :"ai-auto-description"] Specifies the auto description extension. + end + + # @!method self.variants + # @return [Array(Imagekitio::Models::ExtensionItem::RemoveBg, Imagekitio::Models::ExtensionItem::AIAutoDescription, Imagekitio::Models::ExtensionItem::AutoTaggingExtension)] + end + + # @type [Imagekitio::Internal::Type::Converter] + Extensions = Imagekitio::Internal::Type::ArrayOf[union: -> { Imagekitio::ExtensionItem }] + end +end diff --git a/lib/imagekitio/models/file.rb b/lib/imagekitio/models/file.rb new file mode 100644 index 00000000..5145ba57 --- /dev/null +++ b/lib/imagekitio/models/file.rb @@ -0,0 +1,497 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#get + class File < Imagekitio::Internal::Type::BaseModel + # @!attribute ai_tags + # An array of tags assigned to the file by auto tagging. + # + # @return [Array, nil] + optional :ai_tags, + -> { Imagekitio::Internal::Type::ArrayOf[Imagekitio::File::AITag] }, + api_name: :AITags, + nil?: true + + # @!attribute created_at + # Date and time when the file was uploaded. The date and time is in ISO8601 + # format. + # + # @return [Time, nil] + optional :created_at, Time, api_name: :createdAt + + # @!attribute custom_coordinates + # An string with custom coordinates of the file. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # An object with custom metadata for the file. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + # + # @return [String, nil] + optional :description, String + + # @!attribute file_id + # Unique identifier of the asset. + # + # @return [String, nil] + optional :file_id, String, api_name: :fileId + + # @!attribute file_path + # 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`. + # + # @return [String, nil] + optional :file_path, String, api_name: :filePath + + # @!attribute file_type + # Type of the file. Possible values are `image`, `non-image`. + # + # @return [String, nil] + optional :file_type, String, api_name: :fileType + + # @!attribute has_alpha + # Specifies if the image has an alpha channel. + # + # @return [Boolean, nil] + optional :has_alpha, Imagekitio::Internal::Type::Boolean, api_name: :hasAlpha + + # @!attribute height + # Height of the file. + # + # @return [Float, nil] + optional :height, Float + + # @!attribute is_private_file + # Specifies if the file is private or not. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekitio::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # Specifies if the file is published or not. + # + # @return [Boolean, nil] + optional :is_published, Imagekitio::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute mime + # MIME type of the file. + # + # @return [String, nil] + optional :mime, String + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute selected_fields_schema + # 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. + # + # @return [Hash{Symbol=>Imagekitio::Models::File::SelectedFieldsSchema}, nil] + optional :selected_fields_schema, + -> { Imagekitio::Internal::Type::HashOf[Imagekitio::File::SelectedFieldsSchema] }, + api_name: :selectedFieldsSchema + + # @!attribute size + # Size of the file in bytes. + # + # @return [Float, nil] + optional :size, Float + + # @!attribute tags + # An array of tags assigned to the file. Tags are used to search files in the + # media library. + # + # @return [Array, nil] + optional :tags, Imagekitio::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute thumbnail + # URL of the thumbnail image. This URL is used to access the thumbnail image of + # the file in the media library. + # + # @return [String, nil] + optional :thumbnail, String + + # @!attribute type + # Type of the asset. + # + # @return [Symbol, Imagekitio::Models::File::Type, nil] + optional :type, enum: -> { Imagekitio::File::Type } + + # @!attribute updated_at + # Date and time when the file was last updated. The date and time is in ISO8601 + # format. + # + # @return [Time, nil] + optional :updated_at, Time, api_name: :updatedAt + + # @!attribute url + # URL of the file. + # + # @return [String, nil] + optional :url, String + + # @!attribute version_info + # An object with details of the file version. + # + # @return [Imagekitio::Models::File::VersionInfo, nil] + optional :version_info, -> { Imagekitio::File::VersionInfo }, api_name: :versionInfo + + # @!attribute width + # Width of the file. + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(ai_tags: nil, created_at: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, file_id: nil, file_path: nil, file_type: nil, has_alpha: nil, height: nil, is_private_file: nil, is_published: nil, mime: nil, name: nil, selected_fields_schema: nil, size: nil, tags: nil, thumbnail: nil, type: nil, updated_at: nil, url: nil, version_info: nil, width: nil) + # Some parameter documentations has been truncated, see {Imagekitio::Models::File} + # for more details. + # + # Object containing details of a file or file version. + # + # @param ai_tags [Array, nil] An array of tags assigned to the file by auto tagging. + # + # @param created_at [Time] Date and time when the file was uploaded. The date and time is in ISO8601 format + # + # @param custom_coordinates [String, nil] An string with custom coordinates of the file. + # + # @param custom_metadata [Hash{Symbol=>Object}] An object with custom metadata for the file. + # + # @param description [String] Optional text to describe the contents of the file. Can be set by the user or th + # + # @param file_id [String] Unique identifier of the asset. + # + # @param file_path [String] Path of the file. This is the path you would use in the URL to access the file. + # + # @param file_type [String] Type of the file. Possible values are `image`, `non-image`. + # + # @param has_alpha [Boolean] Specifies if the image has an alpha channel. + # + # @param height [Float] Height of the file. + # + # @param is_private_file [Boolean] Specifies if the file is private or not. + # + # @param is_published [Boolean] Specifies if the file is published or not. + # + # @param mime [String] MIME type of the file. + # + # @param name [String] Name of the asset. + # + # @param selected_fields_schema [Hash{Symbol=>Imagekitio::Models::File::SelectedFieldsSchema}] This field is included in the response only if the Path policy feature is availa + # + # @param size [Float] Size of the file in bytes. + # + # @param tags [Array, nil] An array of tags assigned to the file. Tags are used to search files in the medi + # + # @param thumbnail [String] URL of the thumbnail image. This URL is used to access the thumbnail image of th + # + # @param type [Symbol, Imagekitio::Models::File::Type] Type of the asset. + # + # @param updated_at [Time] Date and time when the file was last updated. The date and time is in ISO8601 fo + # + # @param url [String] URL of the file. + # + # @param version_info [Imagekitio::Models::File::VersionInfo] An object with details of the file version. + # + # @param width [Float] Width of the file. + + class AITag < Imagekitio::Internal::Type::BaseModel + # @!attribute confidence + # Confidence score of the tag. + # + # @return [Float, nil] + optional :confidence, Float + + # @!attribute name + # Name of the tag. + # + # @return [String, nil] + optional :name, String + + # @!attribute source + # Source of the tag. Possible values are `google-auto-tagging` and + # `aws-auto-tagging`. + # + # @return [String, nil] + optional :source, String + + # @!method initialize(confidence: nil, name: nil, source: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::File::AITag} for more details. + # + # @param confidence [Float] Confidence score of the tag. + # + # @param name [String] Name of the tag. + # + # @param source [String] Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-taggi + end + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Type of the custom metadata field. + # + # @return [Symbol, Imagekitio::Models::File::SelectedFieldsSchema::Type] + required :type, enum: -> { Imagekitio::File::SelectedFieldsSchema::Type } + + # @!attribute default_value + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { Imagekitio::File::SelectedFieldsSchema::DefaultValue }, + api_name: :defaultValue + + # @!attribute is_value_required + # Specifies if the custom metadata field is required or not. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekitio::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # 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. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { + Imagekitio::File::SelectedFieldsSchema::MaxValue + }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # 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. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { + Imagekitio::File::SelectedFieldsSchema::MinValue + }, + api_name: :minValue + + # @!attribute read_only + # 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. + # + # @return [Boolean, nil] + optional :read_only, Imagekitio::Internal::Type::Boolean, api_name: :readOnly + + # @!attribute select_options + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { + Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::File::SelectedFieldsSchema::SelectOption] + }, + api_name: :selectOptions + + # @!attribute select_options_truncated + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + # + # @return [Boolean, nil] + optional :select_options_truncated, + Imagekitio::Internal::Type::Boolean, + api_name: :selectOptionsTruncated + + # @!method initialize(type:, default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, read_only: nil, select_options: nil, select_options_truncated: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::File::SelectedFieldsSchema} for more details. + # + # @param type [Symbol, Imagekitio::Models::File::SelectedFieldsSchema::Type] Type of the custom metadata field. + # + # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. The value should match the `ty + # + # @param is_value_required [Boolean] Specifies if the custom metadata field is required or not. + # + # @param max_length [Float] Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param max_value [String, Float] Maximum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param min_length [Float] Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param min_value [String, Float] Minimum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param read_only [Boolean] Indicates whether the custom metadata field is read only. A read only field cann + # + # @param select_options [Array] An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @param select_options_truncated [Boolean] Specifies if the selectOptions array is truncated. It is truncated when number o + + # Type of the custom metadata field. + # + # @see Imagekitio::Models::File::SelectedFieldsSchema#type + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT = :Text + TEXTAREA = :Textarea + NUMBER = :Number + DATE = :Date + BOOLEAN = :Boolean + SINGLE_SELECT = :SingleSelect + MULTI_SELECT = :MultiSelect + + # @!method self.values + # @return [Array] + end + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + # + # @see Imagekitio::Models::File::SelectedFieldsSchema#default_value + module DefaultValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekitio::Models::File::SelectedFieldsSchema::DefaultValue::MixedArray } + + module Mixed + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekitio::Internal::Type::Converter] + MixedArray = + Imagekitio::Internal::Type::ArrayOf[union: -> { + Imagekitio::File::SelectedFieldsSchema::DefaultValue::Mixed + }] + end + + # 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. + # + # @see Imagekitio::Models::File::SelectedFieldsSchema#max_value + module MaxValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # 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. + # + # @see Imagekitio::Models::File::SelectedFieldsSchema#min_value + module MinValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + + # Type of the asset. + # + # @see Imagekitio::Models::File#type + module Type + extend Imagekitio::Internal::Type::Enum + + FILE = :file + FILE_VERSION = :"file-version" + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::File#version_info + class VersionInfo < Imagekitio::Internal::Type::BaseModel + # @!attribute id + # Unique identifier of the file version. + # + # @return [String, nil] + optional :id, String + + # @!attribute name + # Name of the file version. + # + # @return [String, nil] + optional :name, String + + # @!method initialize(id: nil, name: nil) + # An object with details of the file version. + # + # @param id [String] Unique identifier of the file version. + # + # @param name [String] Name of the file version. + end + end + end +end diff --git a/lib/imagekitio/models/file_copy_params.rb b/lib/imagekitio/models/file_copy_params.rb new file mode 100644 index 00000000..a43c52e9 --- /dev/null +++ b/lib/imagekitio/models/file_copy_params.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#copy + class FileCopyParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute destination_path + # Full path to the folder you want to copy the above file into. + # + # @return [String] + required :destination_path, String, api_name: :destinationPath + + # @!attribute source_file_path + # The full path of the file you want to copy. + # + # @return [String] + required :source_file_path, String, api_name: :sourceFilePath + + # @!attribute include_file_versions + # 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`. + # + # @return [Boolean, nil] + optional :include_file_versions, Imagekitio::Internal::Type::Boolean, api_name: :includeFileVersions + + # @!method initialize(destination_path:, source_file_path:, include_file_versions: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileCopyParams} for more details. + # + # @param destination_path [String] Full path to the folder you want to copy the above file into. + # + # @param source_file_path [String] The full path of the file you want to copy. + # + # @param include_file_versions [Boolean] Option to copy all versions of a file. By default, only the current version of t + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/file_copy_response.rb b/lib/imagekitio/models/file_copy_response.rb new file mode 100644 index 00000000..4e826b81 --- /dev/null +++ b/lib/imagekitio/models/file_copy_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#copy + class FileCopyResponse < Imagekitio::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekitio/models/file_delete_params.rb b/lib/imagekitio/models/file_delete_params.rb new file mode 100644 index 00000000..20b3a153 --- /dev/null +++ b/lib/imagekitio/models/file_delete_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#delete + class FileDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/file_get_params.rb b/lib/imagekitio/models/file_get_params.rb new file mode 100644 index 00000000..5bd7a0bc --- /dev/null +++ b/lib/imagekitio/models/file_get_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#get + class FileGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/file_move_params.rb b/lib/imagekitio/models/file_move_params.rb new file mode 100644 index 00000000..4b0f3ba0 --- /dev/null +++ b/lib/imagekitio/models/file_move_params.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#move + class FileMoveParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute destination_path + # Full path to the folder you want to move the above file into. + # + # @return [String] + required :destination_path, String, api_name: :destinationPath + + # @!attribute source_file_path + # The full path of the file you want to move. + # + # @return [String] + required :source_file_path, String, api_name: :sourceFilePath + + # @!method initialize(destination_path:, source_file_path:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileMoveParams} for more details. + # + # @param destination_path [String] Full path to the folder you want to move the above file into. + # + # @param source_file_path [String] The full path of the file you want to move. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/file_move_response.rb b/lib/imagekitio/models/file_move_response.rb new file mode 100644 index 00000000..039c8774 --- /dev/null +++ b/lib/imagekitio/models/file_move_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#move + class FileMoveResponse < Imagekitio::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekitio/models/file_rename_params.rb b/lib/imagekitio/models/file_rename_params.rb new file mode 100644 index 00000000..0960eaef --- /dev/null +++ b/lib/imagekitio/models/file_rename_params.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#rename + class FileRenameParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute file_path + # The full path of the file you want to rename. + # + # @return [String] + required :file_path, String, api_name: :filePath + + # @!attribute new_file_name + # 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 `_`. + # + # @return [String] + required :new_file_name, String, api_name: :newFileName + + # @!attribute purge_cache + # 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` + # + # @return [Boolean, nil] + optional :purge_cache, Imagekitio::Internal::Type::Boolean, api_name: :purgeCache + + # @!method initialize(file_path:, new_file_name:, purge_cache: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileRenameParams} for more details. + # + # @param file_path [String] The full path of the file you want to rename. + # + # @param new_file_name [String] The new name of the file. A filename can contain: + # + # @param purge_cache [Boolean] Option to purge cache for the old file and its versions' URLs. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/file_rename_response.rb b/lib/imagekitio/models/file_rename_response.rb new file mode 100644 index 00000000..0e1c3607 --- /dev/null +++ b/lib/imagekitio/models/file_rename_response.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#rename + class FileRenameResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute purge_request_id + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + # + # @return [String, nil] + optional :purge_request_id, String, api_name: :purgeRequestId + + # @!method initialize(purge_request_id: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileRenameResponse} for more details. + # + # @param purge_request_id [String] Unique identifier of the purge request. This can be used to check the status of + end + end +end diff --git a/lib/imagekitio/models/file_update_params.rb b/lib/imagekitio/models/file_update_params.rb new file mode 100644 index 00000000..47ebe5ba --- /dev/null +++ b/lib/imagekitio/models/file_update_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#update + class FileUpdateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute update_file_request + # Schema for update file update request. + # + # @return [Imagekitio::Models::UpdateFileRequest::UpdateFileDetails, Imagekitio::Models::UpdateFileRequest::ChangePublicationStatus] + required :update_file_request, union: -> { Imagekitio::UpdateFileRequest } + + # @!method initialize(update_file_request:, request_options: {}) + # @param update_file_request [Imagekitio::Models::UpdateFileRequest::UpdateFileDetails, Imagekitio::Models::UpdateFileRequest::ChangePublicationStatus] Schema for update file update request. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/file_update_response.rb b/lib/imagekitio/models/file_update_response.rb new file mode 100644 index 00000000..225df77b --- /dev/null +++ b/lib/imagekitio/models/file_update_response.rb @@ -0,0 +1,104 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#update + class FileUpdateResponse < Imagekitio::Models::File + # @!attribute extension_status + # + # @return [Imagekitio::Models::FileUpdateResponse::ExtensionStatus, nil] + optional :extension_status, + -> { Imagekitio::Models::FileUpdateResponse::ExtensionStatus }, + api_name: :extensionStatus + + # @!method initialize(extension_status: nil) + # Object containing details of a file or file version. + # + # @param extension_status [Imagekitio::Models::FileUpdateResponse::ExtensionStatus] + + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + # @!attribute ai_auto_description + # + # @return [Symbol, Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription, nil] + optional :ai_auto_description, + enum: -> { Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription }, + api_name: :"ai-auto-description" + + # @!attribute aws_auto_tagging + # + # @return [Symbol, Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging, nil] + optional :aws_auto_tagging, + enum: -> { Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging }, + api_name: :"aws-auto-tagging" + + # @!attribute google_auto_tagging + # + # @return [Symbol, Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging, nil] + optional :google_auto_tagging, + enum: -> { Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging }, + api_name: :"google-auto-tagging" + + # @!attribute remove_bg + # + # @return [Symbol, Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg, nil] + optional :remove_bg, + enum: -> { Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg }, + api_name: :"remove-bg" + + # @!method initialize(ai_auto_description: nil, aws_auto_tagging: nil, google_auto_tagging: nil, remove_bg: nil) + # @param ai_auto_description [Symbol, Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription] + # @param aws_auto_tagging [Symbol, Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging] + # @param google_auto_tagging [Symbol, Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging] + # @param remove_bg [Symbol, Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg] + + # @see Imagekitio::Models::FileUpdateResponse::ExtensionStatus#ai_auto_description + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::FileUpdateResponse::ExtensionStatus#aws_auto_tagging + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::FileUpdateResponse::ExtensionStatus#google_auto_tagging + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::FileUpdateResponse::ExtensionStatus#remove_bg + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + end + end + end +end diff --git a/lib/imagekitio/models/file_upload_params.rb b/lib/imagekitio/models/file_upload_params.rb new file mode 100644 index 00000000..7939d51b --- /dev/null +++ b/lib/imagekitio/models/file_upload_params.rb @@ -0,0 +1,540 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#upload + class FileUploadParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # Serialize upload options to handle proper formatting for ImageKit backend API. + # Special cases handled: + # - tags: converted to comma-separated string + # - responseFields: converted to comma-separated string + # - extensions: JSON stringified + # - customMetadata: JSON stringified + # - transformation: JSON stringified + # + # @api private + # + # @param params [Object] + # + # @return [Array(Object, Hash{Symbol=>Object})] + def self.dump_request(params) + state = {can_retry: true} + case (dumped = dump(params, state: state)) + in Hash + serialized = serialize_upload_options(dumped) + options = Imagekitio::Internal::Util.coerce_hash!(serialized[:request_options]).to_h + request_options = state.fetch(:can_retry) ? options : {**options, max_retries: 0} + [serialized.except(:request_options), request_options] + else + [dumped, nil] + end + end + + # @api private + # + # @param upload_options [Hash{Symbol=>Object}] + # + # @return [Hash{Symbol=>Object}] + def self.serialize_upload_options(upload_options) + serialized = {} + + upload_options.each do |key, value| + # Skip nil values + if value.nil? + serialized[key] = value + next + end + + serialized[key] = case key + when :tags, :responseFields + # Tags and response fields should be comma-separated strings + value.is_a?(Array) ? value.join(",") : value + when :extensions + # Extensions should be JSON stringified + value.is_a?(Array) ? JSON.generate(value) : value + when :customMetadata + # Custom metadata should be JSON stringified + value.is_a?(Hash) ? JSON.generate(value) : value + when :transformation + # Transformation should be JSON stringified + value.is_a?(Hash) || value.respond_to?(:to_h) ? JSON.generate(value) : value + else + value + end + end + + serialized + end + + # @!attribute 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. + # + # @return [Pathname, StringIO, IO, String, Imagekitio::FilePart] + required :file, Imagekitio::Internal::Type::FileInput + + # @!attribute file_name + # 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 `_` + # + # @return [String] + required :file_name, String, api_name: :fileName + + # @!attribute 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. + # + # @return [String, nil] + optional :token, String + + # @!attribute 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). + # + # @return [String, nil] + optional :checks, String + + # @!attribute custom_coordinates + # 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. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates + + # @!attribute custom_metadata + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. + # + # @return [String, nil] + optional :description, String + + # @!attribute 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. + # + # @return [Integer, nil] + optional :expire, Integer + + # @!attribute extensions + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + # + # @return [Array, nil] + optional :extensions, -> { Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::ExtensionItem] } + + # @!attribute 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. + # + # @return [String, nil] + optional :folder, String + + # @!attribute is_private_file + # 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. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekitio::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # 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. + # + # @return [Boolean, nil] + optional :is_published, Imagekitio::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute overwrite_ai_tags + # 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. + # + # @return [Boolean, nil] + optional :overwrite_ai_tags, Imagekitio::Internal::Type::Boolean, api_name: :overwriteAITags + + # @!attribute overwrite_custom_metadata + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + # + # @return [Boolean, nil] + optional :overwrite_custom_metadata, + Imagekitio::Internal::Type::Boolean, + api_name: :overwriteCustomMetadata + + # @!attribute overwrite_file + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + # + # @return [Boolean, nil] + optional :overwrite_file, Imagekitio::Internal::Type::Boolean, api_name: :overwriteFile + + # @!attribute overwrite_tags + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + # + # @return [Boolean, nil] + optional :overwrite_tags, Imagekitio::Internal::Type::Boolean, api_name: :overwriteTags + + # @!attribute public_key + # Your ImageKit.io public key. This field is only required for authentication when + # uploading a file from the client side. + # + # @return [String, nil] + optional :public_key, String, api_name: :publicKey + + # @!attribute response_fields + # Array of response field keys to include in the API response body. + # + # @return [Array, nil] + optional :response_fields, + -> { Imagekitio::Internal::Type::ArrayOf[enum: Imagekitio::FileUploadParams::ResponseField] }, + api_name: :responseFields + + # @!attribute 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. + # + # @return [String, nil] + optional :signature, String + + # @!attribute 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. + # + # @return [Array, nil] + optional :tags, Imagekitio::Internal::Type::ArrayOf[String] + + # @!attribute 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. + # + # @return [Imagekitio::Models::FileUploadParams::Transformation, nil] + optional :transformation, -> { Imagekitio::FileUploadParams::Transformation } + + # @!attribute use_unique_file_name + # 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. + # + # @return [Boolean, nil] + optional :use_unique_file_name, Imagekitio::Internal::Type::Boolean, api_name: :useUniqueFileName + + # @!attribute webhook_url + # 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. + # + # @return [String, nil] + optional :webhook_url, String, api_name: :webhookUrl + + # @!method initialize(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, expire: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, public_key: nil, response_fields: nil, signature: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadParams} for more details. + # + # @param file [Pathname, StringIO, IO, String, Imagekitio::FilePart] The API accepts any of the following: + # + # @param file_name [String] The name with which the file has to be uploaded. + # + # @param token [String] A unique value that the ImageKit.io server will use to recognize and prevent sub + # + # @param checks [String] Server-side checks to run on the asset. + # + # @param custom_coordinates [String] Define an important area in the image. This is only relevant for image type file + # + # @param custom_metadata [Hash{Symbol=>Object}] JSON key-value pairs to associate with the asset. Create the custom metadata fie + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param expire [Integer] The time until your signature is valid. It must be a [Unix time](https://en.wiki + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param folder [String] The folder path in which the image has to be uploaded. If the folder(s) didn't e + # + # @param is_private_file [Boolean] Whether to mark the file as private or not. + # + # @param is_published [Boolean] Whether to upload file as published or not. + # + # @param overwrite_ai_tags [Boolean] If set to `true` and a file already exists at the exact location, its AITags wil + # + # @param overwrite_custom_metadata [Boolean] If the request does not have `customMetadata`, and a file already exists at the + # + # @param overwrite_file [Boolean] If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # + # @param overwrite_tags [Boolean] If the request does not have `tags`, and a file already exists at the exact loca + # + # @param public_key [String] Your ImageKit.io public key. This field is only required for authentication when + # + # @param response_fields [Array] Array of response field keys to include in the API response body. + # + # @param signature [String] HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + # + # @param tags [Array] Set the tags while uploading the file. + # + # @param transformation [Imagekitio::Models::FileUploadParams::Transformation] Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # @param use_unique_file_name [Boolean] Whether to use a unique filename for this file or not. + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + + module ResponseField + extend Imagekitio::Internal::Type::Enum + + TAGS = :tags + CUSTOM_COORDINATES = :customCoordinates + IS_PRIVATE_FILE = :isPrivateFile + EMBEDDED_METADATA = :embeddedMetadata + IS_PUBLISHED = :isPublished + CUSTOM_METADATA = :customMetadata + METADATA = :metadata + SELECTED_FIELDS_SCHEMA = :selectedFieldsSchema + + # @!method self.values + # @return [Array] + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute post + # 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`. + # + # @return [Array, nil] + optional :post, + -> { Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::FileUploadParams::Transformation::Post] } + + # @!attribute pre + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + # + # @return [String, nil] + optional :pre, String + + # @!method initialize(post: nil, pre: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadParams::Transformation} for more details. + # + # 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 post [Array] List of transformations to apply _after_ the file is uploaded. + # + # @param pre [String] Transformation string to apply before uploading the file to the Media Library. U + + module Post + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :transformation, -> { Imagekitio::FileUploadParams::Transformation::Post::Transformation } + + variant :"gif-to-video", -> { Imagekitio::FileUploadParams::Transformation::Post::GifToVideo } + + variant :thumbnail, -> { Imagekitio::FileUploadParams::Transformation::Post::Thumbnail } + + variant :abs, -> { Imagekitio::FileUploadParams::Transformation::Post::Abs } + + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Transformation type. + # + # @return [Symbol, :transformation] + required :type, const: :transformation + + # @!attribute value + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + # + # @return [String] + required :value, String + + # @!method initialize(value:, type: :transformation) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadParams::Transformation::Post::Transformation} for + # more details. + # + # @param value [String] Transformation string (e.g. `w-200,h-200`). + # + # @param type [Symbol, :transformation] Transformation type. + end + + class GifToVideo < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Converts an animated GIF into an MP4. + # + # @return [Symbol, :"gif-to-video"] + required :type, const: :"gif-to-video" + + # @!attribute value + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + # + # @return [String, nil] + optional :value, String + + # @!method initialize(value: nil, type: :"gif-to-video") + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadParams::Transformation::Post::GifToVideo} for + # more details. + # + # @param value [String] Optional transformation string to apply to the output video. + # + # @param type [Symbol, :"gif-to-video"] Converts an animated GIF into an MP4. + end + + class Thumbnail < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Generates a thumbnail image. + # + # @return [Symbol, :thumbnail] + required :type, const: :thumbnail + + # @!attribute value + # Optional transformation string. + # **Example**: `w-150,h-150` + # + # @return [String, nil] + optional :value, String + + # @!method initialize(value: nil, type: :thumbnail) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadParams::Transformation::Post::Thumbnail} for more + # details. + # + # @param value [String] Optional transformation string. + # + # @param type [Symbol, :thumbnail] Generates a thumbnail image. + end + + class Abs < Imagekitio::Internal::Type::BaseModel + # @!attribute protocol + # Streaming protocol to use (`hls` or `dash`). + # + # @return [Symbol, Imagekitio::Models::FileUploadParams::Transformation::Post::Abs::Protocol] + required :protocol, enum: -> { Imagekitio::FileUploadParams::Transformation::Post::Abs::Protocol } + + # @!attribute type + # Adaptive Bitrate Streaming (ABS) setup. + # + # @return [Symbol, :abs] + required :type, const: :abs + + # @!attribute value + # List of different representations you want to create separated by an underscore. + # + # @return [String] + required :value, String + + # @!method initialize(protocol:, value:, type: :abs) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadParams::Transformation::Post::Abs} for more + # details. + # + # @param protocol [Symbol, Imagekitio::Models::FileUploadParams::Transformation::Post::Abs::Protocol] Streaming protocol to use (`hls` or `dash`). + # + # @param value [String] List of different representations you want to create separated by an underscore. + # + # @param type [Symbol, :abs] Adaptive Bitrate Streaming (ABS) setup. + + # Streaming protocol to use (`hls` or `dash`). + # + # @see Imagekitio::Models::FileUploadParams::Transformation::Post::Abs#protocol + module Protocol + extend Imagekitio::Internal::Type::Enum + + HLS = :hls + DASH = :dash + + # @!method self.values + # @return [Array] + end + end + + # @!method self.variants + # @return [Array(Imagekitio::Models::FileUploadParams::Transformation::Post::Transformation, Imagekitio::Models::FileUploadParams::Transformation::Post::GifToVideo, Imagekitio::Models::FileUploadParams::Transformation::Post::Thumbnail, Imagekitio::Models::FileUploadParams::Transformation::Post::Abs)] + end + end + end + end +end diff --git a/lib/imagekitio/models/file_upload_response.rb b/lib/imagekitio/models/file_upload_response.rb new file mode 100644 index 00000000..d5a95f96 --- /dev/null +++ b/lib/imagekitio/models/file_upload_response.rb @@ -0,0 +1,611 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Files#upload + class FileUploadResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute ai_tags + # An array of tags assigned to the uploaded file by auto tagging. + # + # @return [Array, nil] + optional :ai_tags, + -> { Imagekitio::Internal::Type::ArrayOf[Imagekitio::Models::FileUploadResponse::AITag] }, + api_name: :AITags, + nil?: true + + # @!attribute audio_codec + # The audio codec used in the video (only for video). + # + # @return [String, nil] + optional :audio_codec, String, api_name: :audioCodec + + # @!attribute bit_rate + # The bit rate of the video in kbps (only for video). + # + # @return [Integer, nil] + optional :bit_rate, Integer, api_name: :bitRate + + # @!attribute custom_coordinates + # 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. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # 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. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + # + # @return [String, nil] + optional :description, String + + # @!attribute duration + # The duration of the video in seconds (only for video). + # + # @return [Integer, nil] + optional :duration, Integer + + # @!attribute embedded_metadata + # 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. + # + # @return [Hash{Symbol=>Object}, nil] + optional :embedded_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :embeddedMetadata + + # @!attribute extension_status + # 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. + # + # @return [Imagekitio::Models::FileUploadResponse::ExtensionStatus, nil] + optional :extension_status, + -> { Imagekitio::Models::FileUploadResponse::ExtensionStatus }, + api_name: :extensionStatus + + # @!attribute file_id + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + # + # @return [String, nil] + optional :file_id, String, api_name: :fileId + + # @!attribute file_path + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + # + # @return [String, nil] + optional :file_path, String, api_name: :filePath + + # @!attribute file_type + # Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @return [String, nil] + optional :file_type, String, api_name: :fileType + + # @!attribute height + # Height of the image in pixels (Only for images) + # + # @return [Float, nil] + optional :height, Float + + # @!attribute is_private_file + # 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. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekitio::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # 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. + # + # @return [Boolean, nil] + optional :is_published, Imagekitio::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute metadata + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + # + # @return [Imagekitio::Models::Metadata, nil] + optional :metadata, -> { Imagekitio::Metadata } + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute selected_fields_schema + # 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. + # + # @return [Hash{Symbol=>Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema}, nil] + optional :selected_fields_schema, + -> { Imagekitio::Internal::Type::HashOf[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema] }, + api_name: :selectedFieldsSchema + + # @!attribute size + # Size of the image file in Bytes. + # + # @return [Float, nil] + optional :size, Float + + # @!attribute tags + # 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. + # + # @return [Array, nil] + optional :tags, Imagekitio::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute thumbnail_url + # In the case of an image, a small thumbnail URL. + # + # @return [String, nil] + optional :thumbnail_url, String, api_name: :thumbnailUrl + + # @!attribute url + # A publicly accessible URL of the file. + # + # @return [String, nil] + optional :url, String + + # @!attribute version_info + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @return [Imagekitio::Models::FileUploadResponse::VersionInfo, nil] + optional :version_info, -> { Imagekitio::Models::FileUploadResponse::VersionInfo }, api_name: :versionInfo + + # @!attribute video_codec + # The video codec used in the video (only for video). + # + # @return [String, nil] + optional :video_codec, String, api_name: :videoCodec + + # @!attribute width + # Width of the image in pixels (Only for Images) + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(ai_tags: nil, audio_codec: nil, bit_rate: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, duration: nil, embedded_metadata: nil, extension_status: nil, file_id: nil, file_path: nil, file_type: nil, height: nil, is_private_file: nil, is_published: nil, metadata: nil, name: nil, selected_fields_schema: nil, size: nil, tags: nil, thumbnail_url: nil, url: nil, version_info: nil, video_codec: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadResponse} for more details. + # + # Object containing details of a successful upload. + # + # @param ai_tags [Array, nil] An array of tags assigned to the uploaded file by auto tagging. + # + # @param audio_codec [String] The audio codec used in the video (only for video). + # + # @param bit_rate [Integer] The bit rate of the video in kbps (only for video). + # + # @param custom_coordinates [String, nil] Value of custom coordinates associated with the image in the format `x,y,width,h + # + # @param custom_metadata [Hash{Symbol=>Object}] A key-value data associated with the asset. Use `responseField` in API request t + # + # @param description [String] Optional text to describe the contents of the file. Can be set by the user or th + # + # @param duration [Integer] The duration of the video in seconds (only for video). + # + # @param embedded_metadata [Hash{Symbol=>Object}] Consolidated embedded metadata associated with the file. It includes exif, iptc, + # + # @param extension_status [Imagekitio::Models::FileUploadResponse::ExtensionStatus] Extension names with their processing status at the time of completion of the re + # + # @param file_id [String] Unique fileId. Store this fileld in your database, as this will be used to perfo + # + # @param file_path [String] The relative path of the file in the media library e.g. `/marketing-assets/new-b + # + # @param file_type [String] Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @param height [Float] Height of the image in pixels (Only for images) + # + # @param is_private_file [Boolean] Is the file marked as private. It can be either `true` or `false`. Send `isPriva + # + # @param is_published [Boolean] Is the file published or in draft state. It can be either `true` or `false`. Sen + # + # @param metadata [Imagekitio::Models::Metadata] Legacy metadata. Send `metadata` in `responseFields` in API request to get metad + # + # @param name [String] Name of the asset. + # + # @param selected_fields_schema [Hash{Symbol=>Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema}] This field is included in the response only if the Path policy feature is availa + # + # @param size [Float] Size of the image file in Bytes. + # + # @param tags [Array, nil] The array of tags associated with the asset. If no tags are set, it will be `nul + # + # @param thumbnail_url [String] In the case of an image, a small thumbnail URL. + # + # @param url [String] A publicly accessible URL of the file. + # + # @param version_info [Imagekitio::Models::FileUploadResponse::VersionInfo] An object containing the file or file version's `id` (versionId) and `name`. + # + # @param video_codec [String] The video codec used in the video (only for video). + # + # @param width [Float] Width of the image in pixels (Only for Images) + + class AITag < Imagekitio::Internal::Type::BaseModel + # @!attribute confidence + # Confidence score of the tag. + # + # @return [Float, nil] + optional :confidence, Float + + # @!attribute name + # Name of the tag. + # + # @return [String, nil] + optional :name, String + + # @!attribute source + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + # + # @return [String, nil] + optional :source, String + + # @!method initialize(confidence: nil, name: nil, source: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadResponse::AITag} for more details. + # + # @param confidence [Float] Confidence score of the tag. + # + # @param name [String] Name of the tag. + # + # @param source [String] Array of `AITags` associated with the image. If no `AITags` are set, it will be + end + + # @see Imagekitio::Models::FileUploadResponse#extension_status + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + # @!attribute ai_auto_description + # + # @return [Symbol, Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription, nil] + optional :ai_auto_description, + enum: -> { Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription }, + api_name: :"ai-auto-description" + + # @!attribute aws_auto_tagging + # + # @return [Symbol, Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging, nil] + optional :aws_auto_tagging, + enum: -> { Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging }, + api_name: :"aws-auto-tagging" + + # @!attribute google_auto_tagging + # + # @return [Symbol, Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging, nil] + optional :google_auto_tagging, + enum: -> { Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging }, + api_name: :"google-auto-tagging" + + # @!attribute remove_bg + # + # @return [Symbol, Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg, nil] + optional :remove_bg, + enum: -> { Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg }, + api_name: :"remove-bg" + + # @!method initialize(ai_auto_description: nil, aws_auto_tagging: nil, google_auto_tagging: nil, remove_bg: nil) + # 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 ai_auto_description [Symbol, Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription] + # @param aws_auto_tagging [Symbol, Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging] + # @param google_auto_tagging [Symbol, Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging] + # @param remove_bg [Symbol, Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg] + + # @see Imagekitio::Models::FileUploadResponse::ExtensionStatus#ai_auto_description + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::FileUploadResponse::ExtensionStatus#aws_auto_tagging + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::FileUploadResponse::ExtensionStatus#google_auto_tagging + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::FileUploadResponse::ExtensionStatus#remove_bg + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + end + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Type of the custom metadata field. + # + # @return [Symbol, Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type] + required :type, enum: -> { Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type } + + # @!attribute default_value + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue }, + api_name: :defaultValue + + # @!attribute is_value_required + # Specifies if the custom metadata field is required or not. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekitio::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # 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. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MaxValue }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # 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. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MinValue }, + api_name: :minValue + + # @!attribute read_only + # 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. + # + # @return [Boolean, nil] + optional :read_only, Imagekitio::Internal::Type::Boolean, api_name: :readOnly + + # @!attribute select_options + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::SelectOption] }, + api_name: :selectOptions + + # @!attribute select_options_truncated + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + # + # @return [Boolean, nil] + optional :select_options_truncated, + Imagekitio::Internal::Type::Boolean, + api_name: :selectOptionsTruncated + + # @!method initialize(type:, default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, read_only: nil, select_options: nil, select_options_truncated: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema} for more details. + # + # @param type [Symbol, Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type] Type of the custom metadata field. + # + # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. The value should match the `ty + # + # @param is_value_required [Boolean] Specifies if the custom metadata field is required or not. + # + # @param max_length [Float] Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param max_value [String, Float] Maximum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param min_length [Float] Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param min_value [String, Float] Minimum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param read_only [Boolean] Indicates whether the custom metadata field is read only. A read only field cann + # + # @param select_options [Array] An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @param select_options_truncated [Boolean] Specifies if the selectOptions array is truncated. It is truncated when number o + + # Type of the custom metadata field. + # + # @see Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema#type + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT = :Text + TEXTAREA = :Textarea + NUMBER = :Number + DATE = :Date + BOOLEAN = :Boolean + SINGLE_SELECT = :SingleSelect + MULTI_SELECT = :MultiSelect + + # @!method self.values + # @return [Array] + end + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + # + # @see Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema#default_value + module DefaultValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::MixedArray } + + module Mixed + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekitio::Internal::Type::Converter] + MixedArray = + Imagekitio::Internal::Type::ArrayOf[union: -> { Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Mixed }] + end + + # 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. + # + # @see Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema#max_value + module MaxValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # 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. + # + # @see Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema#min_value + module MinValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + + # @see Imagekitio::Models::FileUploadResponse#version_info + class VersionInfo < Imagekitio::Internal::Type::BaseModel + # @!attribute id + # Unique identifier of the file version. + # + # @return [String, nil] + optional :id, String + + # @!attribute name + # Name of the file version. + # + # @return [String, nil] + optional :name, String + + # @!method initialize(id: nil, name: nil) + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @param id [String] Unique identifier of the file version. + # + # @param name [String] Name of the file version. + end + end + end +end diff --git a/lib/imagekitio/models/files/bulk_add_tags_params.rb b/lib/imagekitio/models/files/bulk_add_tags_params.rb new file mode 100644 index 00000000..51dbca35 --- /dev/null +++ b/lib/imagekitio/models/files/bulk_add_tags_params.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Bulk#add_tags + class BulkAddTagsParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute file_ids + # An array of fileIds to which you want to add tags. + # + # @return [Array] + required :file_ids, Imagekitio::Internal::Type::ArrayOf[String], api_name: :fileIds + + # @!attribute tags + # An array of tags that you want to add to the files. + # + # @return [Array] + required :tags, Imagekitio::Internal::Type::ArrayOf[String] + + # @!method initialize(file_ids:, tags:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkAddTagsParams} for more details. + # + # @param file_ids [Array] An array of fileIds to which you want to add tags. + # + # @param tags [Array] An array of tags that you want to add to the files. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/files/bulk_add_tags_response.rb b/lib/imagekitio/models/files/bulk_add_tags_response.rb new file mode 100644 index 00000000..f03f4985 --- /dev/null +++ b/lib/imagekitio/models/files/bulk_add_tags_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Bulk#add_tags + class BulkAddTagsResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute successfully_updated_file_ids + # An array of fileIds that in which tags were successfully added. + # + # @return [Array, nil] + optional :successfully_updated_file_ids, + Imagekitio::Internal::Type::ArrayOf[String], + api_name: :successfullyUpdatedFileIds + + # @!method initialize(successfully_updated_file_ids: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkAddTagsResponse} for more details. + # + # @param successfully_updated_file_ids [Array] An array of fileIds that in which tags were successfully added. + end + end + end +end diff --git a/lib/imagekitio/models/files/bulk_delete_params.rb b/lib/imagekitio/models/files/bulk_delete_params.rb new file mode 100644 index 00000000..951adcc7 --- /dev/null +++ b/lib/imagekitio/models/files/bulk_delete_params.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Bulk#delete + class BulkDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute file_ids + # An array of fileIds which you want to delete. + # + # @return [Array] + required :file_ids, Imagekitio::Internal::Type::ArrayOf[String], api_name: :fileIds + + # @!method initialize(file_ids:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkDeleteParams} for more details. + # + # @param file_ids [Array] An array of fileIds which you want to delete. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/files/bulk_delete_response.rb b/lib/imagekitio/models/files/bulk_delete_response.rb new file mode 100644 index 00000000..da29543c --- /dev/null +++ b/lib/imagekitio/models/files/bulk_delete_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Bulk#delete + class BulkDeleteResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute successfully_deleted_file_ids + # An array of fileIds that were successfully deleted. + # + # @return [Array, nil] + optional :successfully_deleted_file_ids, + Imagekitio::Internal::Type::ArrayOf[String], + api_name: :successfullyDeletedFileIds + + # @!method initialize(successfully_deleted_file_ids: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkDeleteResponse} for more details. + # + # @param successfully_deleted_file_ids [Array] An array of fileIds that were successfully deleted. + end + end + end +end diff --git a/lib/imagekitio/models/files/bulk_remove_ai_tags_params.rb b/lib/imagekitio/models/files/bulk_remove_ai_tags_params.rb new file mode 100644 index 00000000..0f566d0b --- /dev/null +++ b/lib/imagekitio/models/files/bulk_remove_ai_tags_params.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Bulk#remove_ai_tags + class BulkRemoveAITagsParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute ai_tags + # An array of AITags that you want to remove from the files. + # + # @return [Array] + required :ai_tags, Imagekitio::Internal::Type::ArrayOf[String], api_name: :AITags + + # @!attribute file_ids + # An array of fileIds from which you want to remove AITags. + # + # @return [Array] + required :file_ids, Imagekitio::Internal::Type::ArrayOf[String], api_name: :fileIds + + # @!method initialize(ai_tags:, file_ids:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkRemoveAITagsParams} for more details. + # + # @param ai_tags [Array] An array of AITags that you want to remove from the files. + # + # @param file_ids [Array] An array of fileIds from which you want to remove AITags. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/files/bulk_remove_ai_tags_response.rb b/lib/imagekitio/models/files/bulk_remove_ai_tags_response.rb new file mode 100644 index 00000000..314fbe8e --- /dev/null +++ b/lib/imagekitio/models/files/bulk_remove_ai_tags_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Bulk#remove_ai_tags + class BulkRemoveAITagsResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute successfully_updated_file_ids + # An array of fileIds that in which AITags were successfully removed. + # + # @return [Array, nil] + optional :successfully_updated_file_ids, + Imagekitio::Internal::Type::ArrayOf[String], + api_name: :successfullyUpdatedFileIds + + # @!method initialize(successfully_updated_file_ids: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkRemoveAITagsResponse} for more details. + # + # @param successfully_updated_file_ids [Array] An array of fileIds that in which AITags were successfully removed. + end + end + end +end diff --git a/lib/imagekitio/models/files/bulk_remove_tags_params.rb b/lib/imagekitio/models/files/bulk_remove_tags_params.rb new file mode 100644 index 00000000..6f99862f --- /dev/null +++ b/lib/imagekitio/models/files/bulk_remove_tags_params.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Bulk#remove_tags + class BulkRemoveTagsParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute file_ids + # An array of fileIds from which you want to remove tags. + # + # @return [Array] + required :file_ids, Imagekitio::Internal::Type::ArrayOf[String], api_name: :fileIds + + # @!attribute tags + # An array of tags that you want to remove from the files. + # + # @return [Array] + required :tags, Imagekitio::Internal::Type::ArrayOf[String] + + # @!method initialize(file_ids:, tags:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkRemoveTagsParams} for more details. + # + # @param file_ids [Array] An array of fileIds from which you want to remove tags. + # + # @param tags [Array] An array of tags that you want to remove from the files. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/files/bulk_remove_tags_response.rb b/lib/imagekitio/models/files/bulk_remove_tags_response.rb new file mode 100644 index 00000000..19d44f90 --- /dev/null +++ b/lib/imagekitio/models/files/bulk_remove_tags_response.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Bulk#remove_tags + class BulkRemoveTagsResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute successfully_updated_file_ids + # An array of fileIds that in which tags were successfully removed. + # + # @return [Array, nil] + optional :successfully_updated_file_ids, + Imagekitio::Internal::Type::ArrayOf[String], + api_name: :successfullyUpdatedFileIds + + # @!method initialize(successfully_updated_file_ids: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkRemoveTagsResponse} for more details. + # + # @param successfully_updated_file_ids [Array] An array of fileIds that in which tags were successfully removed. + end + end + end +end diff --git a/lib/imagekitio/models/files/metadata_get_from_url_params.rb b/lib/imagekitio/models/files/metadata_get_from_url_params.rb new file mode 100644 index 00000000..84e51262 --- /dev/null +++ b/lib/imagekitio/models/files/metadata_get_from_url_params.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Metadata#get_from_url + class MetadataGetFromURLParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute url + # Should be a valid file URL. It should be accessible using your ImageKit.io + # account. + # + # @return [String] + required :url, String + + # @!method initialize(url:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::MetadataGetFromURLParams} for more details. + # + # @param url [String] Should be a valid file URL. It should be accessible using your ImageKit.io accou + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/files/metadata_get_params.rb b/lib/imagekitio/models/files/metadata_get_params.rb new file mode 100644 index 00000000..6b5f56d5 --- /dev/null +++ b/lib/imagekitio/models/files/metadata_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Metadata#get + class MetadataGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/files/version_delete_params.rb b/lib/imagekitio/models/files/version_delete_params.rb new file mode 100644 index 00000000..d38adabb --- /dev/null +++ b/lib/imagekitio/models/files/version_delete_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Versions#delete + class VersionDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute file_id + # + # @return [String] + required :file_id, String + + # @!method initialize(file_id:, request_options: {}) + # @param file_id [String] + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/files/version_delete_response.rb b/lib/imagekitio/models/files/version_delete_response.rb new file mode 100644 index 00000000..b904f5f9 --- /dev/null +++ b/lib/imagekitio/models/files/version_delete_response.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Versions#delete + class VersionDeleteResponse < Imagekitio::Internal::Type::BaseModel + # @!method initialize + end + end + end +end diff --git a/lib/imagekitio/models/files/version_get_params.rb b/lib/imagekitio/models/files/version_get_params.rb new file mode 100644 index 00000000..53a1e15e --- /dev/null +++ b/lib/imagekitio/models/files/version_get_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Versions#get + class VersionGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute file_id + # + # @return [String] + required :file_id, String + + # @!method initialize(file_id:, request_options: {}) + # @param file_id [String] + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/files/version_list_params.rb b/lib/imagekitio/models/files/version_list_params.rb new file mode 100644 index 00000000..71d6bae9 --- /dev/null +++ b/lib/imagekitio/models/files/version_list_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Versions#list + class VersionListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/files/version_list_response.rb b/lib/imagekitio/models/files/version_list_response.rb new file mode 100644 index 00000000..58464ab5 --- /dev/null +++ b/lib/imagekitio/models/files/version_list_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @type [Imagekitio::Internal::Type::Converter] + VersionListResponse = Imagekitio::Internal::Type::ArrayOf[-> { Imagekitio::File }] + end + end +end diff --git a/lib/imagekitio/models/files/version_restore_params.rb b/lib/imagekitio/models/files/version_restore_params.rb new file mode 100644 index 00000000..d3c6b2ea --- /dev/null +++ b/lib/imagekitio/models/files/version_restore_params.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Files + # @see Imagekitio::Resources::Files::Versions#restore + class VersionRestoreParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute file_id + # + # @return [String] + required :file_id, String + + # @!method initialize(file_id:, request_options: {}) + # @param file_id [String] + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/folder.rb b/lib/imagekitio/models/folder.rb new file mode 100644 index 00000000..4494e3dc --- /dev/null +++ b/lib/imagekitio/models/folder.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class Folder < Imagekitio::Internal::Type::BaseModel + # @!attribute created_at + # Date and time when the folder was created. The date and time is in ISO8601 + # format. + # + # @return [Time, nil] + optional :created_at, Time, api_name: :createdAt + + # @!attribute folder_id + # Unique identifier of the asset. + # + # @return [String, nil] + optional :folder_id, String, api_name: :folderId + + # @!attribute folder_path + # 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. + # + # @return [String, nil] + optional :folder_path, String, api_name: :folderPath + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute type + # Type of the asset. + # + # @return [Symbol, Imagekitio::Models::Folder::Type, nil] + optional :type, enum: -> { Imagekitio::Folder::Type } + + # @!attribute updated_at + # Date and time when the folder was last updated. The date and time is in ISO8601 + # format. + # + # @return [Time, nil] + optional :updated_at, Time, api_name: :updatedAt + + # @!method initialize(created_at: nil, folder_id: nil, folder_path: nil, name: nil, type: nil, updated_at: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Folder} for more details. + # + # @param created_at [Time] Date and time when the folder was created. The date and time is in ISO8601 forma + # + # @param folder_id [String] Unique identifier of the asset. + # + # @param folder_path [String] Path of the folder. This is the path you would use in the URL to access the fold + # + # @param name [String] Name of the asset. + # + # @param type [Symbol, Imagekitio::Models::Folder::Type] Type of the asset. + # + # @param updated_at [Time] Date and time when the folder was last updated. The date and time is in ISO8601 + + # Type of the asset. + # + # @see Imagekitio::Models::Folder#type + module Type + extend Imagekitio::Internal::Type::Enum + + FOLDER = :folder + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekitio/models/folder_copy_params.rb b/lib/imagekitio/models/folder_copy_params.rb new file mode 100644 index 00000000..695c8823 --- /dev/null +++ b/lib/imagekitio/models/folder_copy_params.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#copy + class FolderCopyParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute destination_path + # Full path to the destination folder where you want to copy the source folder + # into. + # + # @return [String] + required :destination_path, String, api_name: :destinationPath + + # @!attribute source_folder_path + # The full path to the source folder you want to copy. + # + # @return [String] + required :source_folder_path, String, api_name: :sourceFolderPath + + # @!attribute include_versions + # 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`. + # + # @return [Boolean, nil] + optional :include_versions, Imagekitio::Internal::Type::Boolean, api_name: :includeVersions + + # @!method initialize(destination_path:, source_folder_path:, include_versions: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderCopyParams} for more details. + # + # @param destination_path [String] Full path to the destination folder where you want to copy the source folder int + # + # @param source_folder_path [String] The full path to the source folder you want to copy. + # + # @param include_versions [Boolean] Option to copy all versions of files that are nested inside the selected folder. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/folder_copy_response.rb b/lib/imagekitio/models/folder_copy_response.rb new file mode 100644 index 00000000..89e02099 --- /dev/null +++ b/lib/imagekitio/models/folder_copy_response.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#copy + class FolderCopyResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute job_id + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + # + # @return [String] + required :job_id, String, api_name: :jobId + + # @!method initialize(job_id:) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderCopyResponse} for more details. + # + # Job submitted successfully. A `jobId` will be returned. + # + # @param job_id [String] Unique identifier of the bulk job. This can be used to check the status of the b + end + end +end diff --git a/lib/imagekitio/models/folder_create_params.rb b/lib/imagekitio/models/folder_create_params.rb new file mode 100644 index 00000000..d5b3279b --- /dev/null +++ b/lib/imagekitio/models/folder_create_params.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#create + class FolderCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute folder_name + # 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. + # `_`. + # + # @return [String] + required :folder_name, String, api_name: :folderName + + # @!attribute parent_folder_path + # 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. + # + # @return [String] + required :parent_folder_path, String, api_name: :parentFolderPath + + # @!method initialize(folder_name:, parent_folder_path:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderCreateParams} for more details. + # + # @param folder_name [String] The folder will be created with this name. + # + # @param parent_folder_path [String] The folder where the new folder should be created, for root use `/` else the pat + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/folder_create_response.rb b/lib/imagekitio/models/folder_create_response.rb new file mode 100644 index 00000000..082dd539 --- /dev/null +++ b/lib/imagekitio/models/folder_create_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#create + class FolderCreateResponse < Imagekitio::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekitio/models/folder_delete_params.rb b/lib/imagekitio/models/folder_delete_params.rb new file mode 100644 index 00000000..addc894f --- /dev/null +++ b/lib/imagekitio/models/folder_delete_params.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#delete + class FolderDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute folder_path + # Full path to the folder you want to delete. For example `/folder/to/delete/`. + # + # @return [String] + required :folder_path, String, api_name: :folderPath + + # @!method initialize(folder_path:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderDeleteParams} for more details. + # + # @param folder_path [String] Full path to the folder you want to delete. For example `/folder/to/delete/`. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/folder_delete_response.rb b/lib/imagekitio/models/folder_delete_response.rb new file mode 100644 index 00000000..ae8b5d3d --- /dev/null +++ b/lib/imagekitio/models/folder_delete_response.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#delete + class FolderDeleteResponse < Imagekitio::Internal::Type::BaseModel + # @!method initialize + end + end +end diff --git a/lib/imagekitio/models/folder_move_params.rb b/lib/imagekitio/models/folder_move_params.rb new file mode 100644 index 00000000..460ae217 --- /dev/null +++ b/lib/imagekitio/models/folder_move_params.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#move + class FolderMoveParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute destination_path + # Full path to the destination folder where you want to move the source folder + # into. + # + # @return [String] + required :destination_path, String, api_name: :destinationPath + + # @!attribute source_folder_path + # The full path to the source folder you want to move. + # + # @return [String] + required :source_folder_path, String, api_name: :sourceFolderPath + + # @!method initialize(destination_path:, source_folder_path:, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderMoveParams} for more details. + # + # @param destination_path [String] Full path to the destination folder where you want to move the source folder int + # + # @param source_folder_path [String] The full path to the source folder you want to move. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/folder_move_response.rb b/lib/imagekitio/models/folder_move_response.rb new file mode 100644 index 00000000..3129d29c --- /dev/null +++ b/lib/imagekitio/models/folder_move_response.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#move + class FolderMoveResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute job_id + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + # + # @return [String] + required :job_id, String, api_name: :jobId + + # @!method initialize(job_id:) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderMoveResponse} for more details. + # + # Job submitted successfully. A `jobId` will be returned. + # + # @param job_id [String] Unique identifier of the bulk job. This can be used to check the status of the b + end + end +end diff --git a/lib/imagekitio/models/folder_rename_params.rb b/lib/imagekitio/models/folder_rename_params.rb new file mode 100644 index 00000000..e04b6810 --- /dev/null +++ b/lib/imagekitio/models/folder_rename_params.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#rename + class FolderRenameParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!attribute folder_path + # The full path to the folder you want to rename. + # + # @return [String] + required :folder_path, String, api_name: :folderPath + + # @!attribute new_folder_name + # 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. `_`. + # + # @return [String] + required :new_folder_name, String, api_name: :newFolderName + + # @!attribute purge_cache + # 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` + # + # @return [Boolean, nil] + optional :purge_cache, Imagekitio::Internal::Type::Boolean, api_name: :purgeCache + + # @!method initialize(folder_path:, new_folder_name:, purge_cache: nil, request_options: {}) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderRenameParams} for more details. + # + # @param folder_path [String] The full path to the folder you want to rename. + # + # @param new_folder_name [String] The new name for the folder. + # + # @param purge_cache [Boolean] Option to purge cache for the old nested files and their versions' URLs. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/folder_rename_response.rb b/lib/imagekitio/models/folder_rename_response.rb new file mode 100644 index 00000000..752e8430 --- /dev/null +++ b/lib/imagekitio/models/folder_rename_response.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Folders#rename + class FolderRenameResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute job_id + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + # + # @return [String] + required :job_id, String, api_name: :jobId + + # @!method initialize(job_id:) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderRenameResponse} for more details. + # + # Job submitted successfully. A `jobId` will be returned. + # + # @param job_id [String] Unique identifier of the bulk job. This can be used to check the status of the b + end + end +end diff --git a/lib/imagekitio/models/folders/job_get_params.rb b/lib/imagekitio/models/folders/job_get_params.rb new file mode 100644 index 00000000..2e98d751 --- /dev/null +++ b/lib/imagekitio/models/folders/job_get_params.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Folders + # @see Imagekitio::Resources::Folders::Job#get + class JobGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end + end +end diff --git a/lib/imagekitio/models/folders/job_get_response.rb b/lib/imagekitio/models/folders/job_get_response.rb new file mode 100644 index 00000000..25334451 --- /dev/null +++ b/lib/imagekitio/models/folders/job_get_response.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + module Folders + # @see Imagekitio::Resources::Folders::Job#get + class JobGetResponse < Imagekitio::Internal::Type::BaseModel + # @!attribute job_id + # Unique identifier of the bulk job. + # + # @return [String, nil] + optional :job_id, String, api_name: :jobId + + # @!attribute purge_request_id + # Unique identifier of the purge request. This will be present only if + # `purgeCache` is set to `true` in the rename folder API request. + # + # @return [String, nil] + optional :purge_request_id, String, api_name: :purgeRequestId + + # @!attribute status + # Status of the bulk job. + # + # @return [Symbol, Imagekitio::Models::Folders::JobGetResponse::Status, nil] + optional :status, enum: -> { Imagekitio::Models::Folders::JobGetResponse::Status } + + # @!attribute type + # Type of the bulk job. + # + # @return [Symbol, Imagekitio::Models::Folders::JobGetResponse::Type, nil] + optional :type, enum: -> { Imagekitio::Models::Folders::JobGetResponse::Type } + + # @!method initialize(job_id: nil, purge_request_id: nil, status: nil, type: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Folders::JobGetResponse} for more details. + # + # @param job_id [String] Unique identifier of the bulk job. + # + # @param purge_request_id [String] Unique identifier of the purge request. This will be present only if `purgeCache + # + # @param status [Symbol, Imagekitio::Models::Folders::JobGetResponse::Status] Status of the bulk job. + # + # @param type [Symbol, Imagekitio::Models::Folders::JobGetResponse::Type] Type of the bulk job. + + # Status of the bulk job. + # + # @see Imagekitio::Models::Folders::JobGetResponse#status + module Status + extend Imagekitio::Internal::Type::Enum + + PENDING = :Pending + COMPLETED = :Completed + + # @!method self.values + # @return [Array] + end + + # Type of the bulk job. + # + # @see Imagekitio::Models::Folders::JobGetResponse#type + module Type + extend Imagekitio::Internal::Type::Enum + + COPY_FOLDER = :COPY_FOLDER + MOVE_FOLDER = :MOVE_FOLDER + RENAME_FOLDER = :RENAME_FOLDER + + # @!method self.values + # @return [Array] + end + end + end + end +end diff --git a/lib/imagekitio/models/get_image_attributes_options.rb b/lib/imagekitio/models/get_image_attributes_options.rb new file mode 100644 index 00000000..a8ee50b1 --- /dev/null +++ b/lib/imagekitio/models/get_image_attributes_options.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class GetImageAttributesOptions < Imagekitio::Models::SrcOptions + # @!attribute device_breakpoints + # 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. + # + # @return [Array, nil] + optional :device_breakpoints, Imagekitio::Internal::Type::ArrayOf[Float], api_name: :deviceBreakpoints + + # @!attribute image_breakpoints + # 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. + # + # @return [Array, nil] + optional :image_breakpoints, Imagekitio::Internal::Type::ArrayOf[Float], api_name: :imageBreakpoints + + # @!attribute sizes + # 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`. + # + # @return [String, nil] + optional :sizes, String + + # @!attribute width + # 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. + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(device_breakpoints: nil, image_breakpoints: nil, sizes: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::GetImageAttributesOptions} for more details. + # + # Options for generating responsive image attributes including `src`, `srcSet`, + # and `sizes` for HTML `` elements. This schema extends `SrcOptions` to add + # support for responsive image generation with breakpoints. + # + # @param device_breakpoints [Array] Custom list of **device-width breakpoints** in pixels. + # + # @param image_breakpoints [Array] Custom list of **image-specific breakpoints** in pixels. + # + # @param sizes [String] The value for the HTML `sizes` attribute + # + # @param width [Float] The intended display width of the image in pixels, + end + end +end diff --git a/lib/imagekitio/models/image_overlay.rb b/lib/imagekitio/models/image_overlay.rb new file mode 100644 index 00000000..401b77e5 --- /dev/null +++ b/lib/imagekitio/models/image_overlay.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class ImageOverlay < Imagekitio::Models::BaseOverlay + # @!attribute input + # Specifies the relative path to the image used as an overlay. + # + # @return [String] + required :input, String + + # @!attribute type + # + # @return [Symbol, :image] + required :type, const: :image + + # @!attribute encoding + # 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`. + # + # @return [Symbol, Imagekitio::Models::ImageOverlay::Encoding, nil] + optional :encoding, enum: -> { Imagekitio::ImageOverlay::Encoding } + + # @!attribute transformation + # 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). + # + # @return [Array, nil] + optional :transformation, -> { Imagekitio::Internal::Type::ArrayOf[Imagekitio::Transformation] } + + # @!method initialize(input:, encoding: nil, transformation: nil, type: :image) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::ImageOverlay} for more details. + # + # @param input [String] Specifies the relative path to the image used as an overlay. + # + # @param encoding [Symbol, Imagekitio::Models::ImageOverlay::Encoding] The input path can be included in the layer as either `i-{input}` or `ie-{base64 + # + # @param transformation [Array] Array of transformations to be applied to the overlay image. Supported transform + # + # @param type [Symbol, :image] + + # 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`. + module Encoding + extend Imagekitio::Internal::Type::Enum + + AUTO = :auto + PLAIN = :plain + BASE64 = :base64 + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekitio/models/metadata.rb b/lib/imagekitio/models/metadata.rb new file mode 100644 index 00000000..371ebc3b --- /dev/null +++ b/lib/imagekitio/models/metadata.rb @@ -0,0 +1,483 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class Metadata < Imagekitio::Internal::Type::BaseModel + # @!attribute audio_codec + # The audio codec used in the video (only for video). + # + # @return [String, nil] + optional :audio_codec, String, api_name: :audioCodec + + # @!attribute bit_rate + # The bit rate of the video in kbps (only for video). + # + # @return [Integer, nil] + optional :bit_rate, Integer, api_name: :bitRate + + # @!attribute density + # The density of the image in DPI. + # + # @return [Integer, nil] + optional :density, Integer + + # @!attribute duration + # The duration of the video in seconds (only for video). + # + # @return [Integer, nil] + optional :duration, Integer + + # @!attribute exif + # + # @return [Imagekitio::Models::Metadata::Exif, nil] + optional :exif, -> { Imagekitio::Metadata::Exif } + + # @!attribute format_ + # The format of the file (e.g., 'jpg', 'mp4'). + # + # @return [String, nil] + optional :format_, String, api_name: :format + + # @!attribute has_color_profile + # Indicates if the image has a color profile. + # + # @return [Boolean, nil] + optional :has_color_profile, Imagekitio::Internal::Type::Boolean, api_name: :hasColorProfile + + # @!attribute has_transparency + # Indicates if the image contains transparent areas. + # + # @return [Boolean, nil] + optional :has_transparency, Imagekitio::Internal::Type::Boolean, api_name: :hasTransparency + + # @!attribute height + # The height of the image or video in pixels. + # + # @return [Integer, nil] + optional :height, Integer + + # @!attribute p_hash + # Perceptual hash of the image. + # + # @return [String, nil] + optional :p_hash, String, api_name: :pHash + + # @!attribute quality + # The quality indicator of the image. + # + # @return [Integer, nil] + optional :quality, Integer + + # @!attribute size + # The file size in bytes. + # + # @return [Integer, nil] + optional :size, Integer + + # @!attribute video_codec + # The video codec used in the video (only for video). + # + # @return [String, nil] + optional :video_codec, String, api_name: :videoCodec + + # @!attribute width + # The width of the image or video in pixels. + # + # @return [Integer, nil] + optional :width, Integer + + # @!method initialize(audio_codec: nil, bit_rate: nil, density: nil, duration: nil, exif: nil, format_: nil, has_color_profile: nil, has_transparency: nil, height: nil, p_hash: nil, quality: nil, size: nil, video_codec: nil, width: nil) + # JSON object containing metadata. + # + # @param audio_codec [String] The audio codec used in the video (only for video). + # + # @param bit_rate [Integer] The bit rate of the video in kbps (only for video). + # + # @param density [Integer] The density of the image in DPI. + # + # @param duration [Integer] The duration of the video in seconds (only for video). + # + # @param exif [Imagekitio::Models::Metadata::Exif] + # + # @param format_ [String] The format of the file (e.g., 'jpg', 'mp4'). + # + # @param has_color_profile [Boolean] Indicates if the image has a color profile. + # + # @param has_transparency [Boolean] Indicates if the image contains transparent areas. + # + # @param height [Integer] The height of the image or video in pixels. + # + # @param p_hash [String] Perceptual hash of the image. + # + # @param quality [Integer] The quality indicator of the image. + # + # @param size [Integer] The file size in bytes. + # + # @param video_codec [String] The video codec used in the video (only for video). + # + # @param width [Integer] The width of the image or video in pixels. + + # @see Imagekitio::Models::Metadata#exif + class Exif < Imagekitio::Internal::Type::BaseModel + # @!attribute exif + # Object containing Exif details. + # + # @return [Imagekitio::Models::Metadata::Exif::Exif, nil] + optional :exif, -> { Imagekitio::Metadata::Exif::Exif } + + # @!attribute gps + # Object containing GPS information. + # + # @return [Imagekitio::Models::Metadata::Exif::Gps, nil] + optional :gps, -> { Imagekitio::Metadata::Exif::Gps } + + # @!attribute image + # Object containing EXIF image information. + # + # @return [Imagekitio::Models::Metadata::Exif::Image, nil] + optional :image, -> { Imagekitio::Metadata::Exif::Image } + + # @!attribute interoperability + # JSON object. + # + # @return [Imagekitio::Models::Metadata::Exif::Interoperability, nil] + optional :interoperability, -> { Imagekitio::Metadata::Exif::Interoperability } + + # @!attribute makernote + # + # @return [Hash{Symbol=>Object}, nil] + optional :makernote, Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown] + + # @!attribute thumbnail + # Object containing Thumbnail information. + # + # @return [Imagekitio::Models::Metadata::Exif::Thumbnail, nil] + optional :thumbnail, -> { Imagekitio::Metadata::Exif::Thumbnail } + + # @!method initialize(exif: nil, gps: nil, image: nil, interoperability: nil, makernote: nil, thumbnail: nil) + # @param exif [Imagekitio::Models::Metadata::Exif::Exif] Object containing Exif details. + # + # @param gps [Imagekitio::Models::Metadata::Exif::Gps] Object containing GPS information. + # + # @param image [Imagekitio::Models::Metadata::Exif::Image] Object containing EXIF image information. + # + # @param interoperability [Imagekitio::Models::Metadata::Exif::Interoperability] JSON object. + # + # @param makernote [Hash{Symbol=>Object}] + # + # @param thumbnail [Imagekitio::Models::Metadata::Exif::Thumbnail] Object containing Thumbnail information. + + # @see Imagekitio::Models::Metadata::Exif#exif + class Exif < Imagekitio::Internal::Type::BaseModel + # @!attribute aperture_value + # + # @return [Float, nil] + optional :aperture_value, Float, api_name: :ApertureValue + + # @!attribute color_space + # + # @return [Integer, nil] + optional :color_space, Integer, api_name: :ColorSpace + + # @!attribute create_date + # + # @return [String, nil] + optional :create_date, String, api_name: :CreateDate + + # @!attribute custom_rendered + # + # @return [Integer, nil] + optional :custom_rendered, Integer, api_name: :CustomRendered + + # @!attribute date_time_original + # + # @return [String, nil] + optional :date_time_original, String, api_name: :DateTimeOriginal + + # @!attribute exif_image_height + # + # @return [Integer, nil] + optional :exif_image_height, Integer, api_name: :ExifImageHeight + + # @!attribute exif_image_width + # + # @return [Integer, nil] + optional :exif_image_width, Integer, api_name: :ExifImageWidth + + # @!attribute exif_version + # + # @return [String, nil] + optional :exif_version, String, api_name: :ExifVersion + + # @!attribute exposure_compensation + # + # @return [Float, nil] + optional :exposure_compensation, Float, api_name: :ExposureCompensation + + # @!attribute exposure_mode + # + # @return [Integer, nil] + optional :exposure_mode, Integer, api_name: :ExposureMode + + # @!attribute exposure_program + # + # @return [Integer, nil] + optional :exposure_program, Integer, api_name: :ExposureProgram + + # @!attribute exposure_time + # + # @return [Float, nil] + optional :exposure_time, Float, api_name: :ExposureTime + + # @!attribute flash + # + # @return [Integer, nil] + optional :flash, Integer, api_name: :Flash + + # @!attribute flashpix_version + # + # @return [String, nil] + optional :flashpix_version, String, api_name: :FlashpixVersion + + # @!attribute f_number + # + # @return [Float, nil] + optional :f_number, Float, api_name: :FNumber + + # @!attribute focal_length + # + # @return [Integer, nil] + optional :focal_length, Integer, api_name: :FocalLength + + # @!attribute focal_plane_resolution_unit + # + # @return [Integer, nil] + optional :focal_plane_resolution_unit, Integer, api_name: :FocalPlaneResolutionUnit + + # @!attribute focal_plane_x_resolution + # + # @return [Float, nil] + optional :focal_plane_x_resolution, Float, api_name: :FocalPlaneXResolution + + # @!attribute focal_plane_y_resolution + # + # @return [Float, nil] + optional :focal_plane_y_resolution, Float, api_name: :FocalPlaneYResolution + + # @!attribute interop_offset + # + # @return [Integer, nil] + optional :interop_offset, Integer, api_name: :InteropOffset + + # @!attribute iso + # + # @return [Integer, nil] + optional :iso, Integer, api_name: :ISO + + # @!attribute metering_mode + # + # @return [Integer, nil] + optional :metering_mode, Integer, api_name: :MeteringMode + + # @!attribute scene_capture_type + # + # @return [Integer, nil] + optional :scene_capture_type, Integer, api_name: :SceneCaptureType + + # @!attribute shutter_speed_value + # + # @return [Float, nil] + optional :shutter_speed_value, Float, api_name: :ShutterSpeedValue + + # @!attribute sub_sec_time + # + # @return [String, nil] + optional :sub_sec_time, String, api_name: :SubSecTime + + # @!attribute white_balance + # + # @return [Integer, nil] + optional :white_balance, Integer, api_name: :WhiteBalance + + # @!method initialize(aperture_value: nil, color_space: nil, create_date: nil, custom_rendered: nil, date_time_original: nil, exif_image_height: nil, exif_image_width: nil, exif_version: nil, exposure_compensation: nil, exposure_mode: nil, exposure_program: nil, exposure_time: nil, flash: nil, flashpix_version: nil, f_number: nil, focal_length: nil, focal_plane_resolution_unit: nil, focal_plane_x_resolution: nil, focal_plane_y_resolution: nil, interop_offset: nil, iso: nil, metering_mode: nil, scene_capture_type: nil, shutter_speed_value: nil, sub_sec_time: nil, white_balance: nil) + # Object containing Exif details. + # + # @param aperture_value [Float] + # @param color_space [Integer] + # @param create_date [String] + # @param custom_rendered [Integer] + # @param date_time_original [String] + # @param exif_image_height [Integer] + # @param exif_image_width [Integer] + # @param exif_version [String] + # @param exposure_compensation [Float] + # @param exposure_mode [Integer] + # @param exposure_program [Integer] + # @param exposure_time [Float] + # @param flash [Integer] + # @param flashpix_version [String] + # @param f_number [Float] + # @param focal_length [Integer] + # @param focal_plane_resolution_unit [Integer] + # @param focal_plane_x_resolution [Float] + # @param focal_plane_y_resolution [Float] + # @param interop_offset [Integer] + # @param iso [Integer] + # @param metering_mode [Integer] + # @param scene_capture_type [Integer] + # @param shutter_speed_value [Float] + # @param sub_sec_time [String] + # @param white_balance [Integer] + end + + # @see Imagekitio::Models::Metadata::Exif#gps + class Gps < Imagekitio::Internal::Type::BaseModel + # @!attribute gps_version_id + # + # @return [Array, nil] + optional :gps_version_id, Imagekitio::Internal::Type::ArrayOf[Integer], api_name: :GPSVersionID + + # @!method initialize(gps_version_id: nil) + # Object containing GPS information. + # + # @param gps_version_id [Array] + end + + # @see Imagekitio::Models::Metadata::Exif#image + class Image < Imagekitio::Internal::Type::BaseModel + # @!attribute exif_offset + # + # @return [Integer, nil] + optional :exif_offset, Integer, api_name: :ExifOffset + + # @!attribute gps_info + # + # @return [Integer, nil] + optional :gps_info, Integer, api_name: :GPSInfo + + # @!attribute make + # + # @return [String, nil] + optional :make, String, api_name: :Make + + # @!attribute model + # + # @return [String, nil] + optional :model, String, api_name: :Model + + # @!attribute modify_date + # + # @return [String, nil] + optional :modify_date, String, api_name: :ModifyDate + + # @!attribute orientation + # + # @return [Integer, nil] + optional :orientation, Integer, api_name: :Orientation + + # @!attribute resolution_unit + # + # @return [Integer, nil] + optional :resolution_unit, Integer, api_name: :ResolutionUnit + + # @!attribute software + # + # @return [String, nil] + optional :software, String, api_name: :Software + + # @!attribute x_resolution + # + # @return [Integer, nil] + optional :x_resolution, Integer, api_name: :XResolution + + # @!attribute y_cb_cr_positioning + # + # @return [Integer, nil] + optional :y_cb_cr_positioning, Integer, api_name: :YCbCrPositioning + + # @!attribute y_resolution + # + # @return [Integer, nil] + optional :y_resolution, Integer, api_name: :YResolution + + # @!method initialize(exif_offset: nil, gps_info: nil, make: nil, model: nil, modify_date: nil, orientation: nil, resolution_unit: nil, software: nil, x_resolution: nil, y_cb_cr_positioning: nil, y_resolution: nil) + # Object containing EXIF image information. + # + # @param exif_offset [Integer] + # @param gps_info [Integer] + # @param make [String] + # @param model [String] + # @param modify_date [String] + # @param orientation [Integer] + # @param resolution_unit [Integer] + # @param software [String] + # @param x_resolution [Integer] + # @param y_cb_cr_positioning [Integer] + # @param y_resolution [Integer] + end + + # @see Imagekitio::Models::Metadata::Exif#interoperability + class Interoperability < Imagekitio::Internal::Type::BaseModel + # @!attribute interop_index + # + # @return [String, nil] + optional :interop_index, String, api_name: :InteropIndex + + # @!attribute interop_version + # + # @return [String, nil] + optional :interop_version, String, api_name: :InteropVersion + + # @!method initialize(interop_index: nil, interop_version: nil) + # JSON object. + # + # @param interop_index [String] + # @param interop_version [String] + end + + # @see Imagekitio::Models::Metadata::Exif#thumbnail + class Thumbnail < Imagekitio::Internal::Type::BaseModel + # @!attribute compression + # + # @return [Integer, nil] + optional :compression, Integer, api_name: :Compression + + # @!attribute resolution_unit + # + # @return [Integer, nil] + optional :resolution_unit, Integer, api_name: :ResolutionUnit + + # @!attribute thumbnail_length + # + # @return [Integer, nil] + optional :thumbnail_length, Integer, api_name: :ThumbnailLength + + # @!attribute thumbnail_offset + # + # @return [Integer, nil] + optional :thumbnail_offset, Integer, api_name: :ThumbnailOffset + + # @!attribute x_resolution + # + # @return [Integer, nil] + optional :x_resolution, Integer, api_name: :XResolution + + # @!attribute y_resolution + # + # @return [Integer, nil] + optional :y_resolution, Integer, api_name: :YResolution + + # @!method initialize(compression: nil, resolution_unit: nil, thumbnail_length: nil, thumbnail_offset: nil, x_resolution: nil, y_resolution: nil) + # Object containing Thumbnail information. + # + # @param compression [Integer] + # @param resolution_unit [Integer] + # @param thumbnail_length [Integer] + # @param thumbnail_offset [Integer] + # @param x_resolution [Integer] + # @param y_resolution [Integer] + end + end + end + end +end diff --git a/lib/imagekitio/models/overlay.rb b/lib/imagekitio/models/overlay.rb new file mode 100644 index 00000000..458c59b8 --- /dev/null +++ b/lib/imagekitio/models/overlay.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # 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). + module Overlay + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :text, -> { Imagekitio::TextOverlay } + + variant :image, -> { Imagekitio::ImageOverlay } + + variant :video, -> { Imagekitio::VideoOverlay } + + variant :subtitle, -> { Imagekitio::SubtitleOverlay } + + variant :solidColor, -> { Imagekitio::SolidColorOverlay } + + # @!method self.variants + # @return [Array(Imagekitio::Models::TextOverlay, Imagekitio::Models::ImageOverlay, Imagekitio::Models::VideoOverlay, Imagekitio::Models::SubtitleOverlay, Imagekitio::Models::SolidColorOverlay)] + end + end +end diff --git a/lib/imagekitio/models/overlay_position.rb b/lib/imagekitio/models/overlay_position.rb new file mode 100644 index 00000000..88dfd814 --- /dev/null +++ b/lib/imagekitio/models/overlay_position.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class OverlayPosition < Imagekitio::Internal::Type::BaseModel + # @!attribute focus + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + # + # @return [Symbol, Imagekitio::Models::OverlayPosition::Focus, nil] + optional :focus, enum: -> { Imagekitio::OverlayPosition::Focus } + + # @!attribute x + # 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). + # + # @return [Float, String, nil] + optional :x, union: -> { Imagekitio::OverlayPosition::X } + + # @!attribute y_ + # 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). + # + # @return [Float, String, nil] + optional :y_, union: -> { Imagekitio::OverlayPosition::Y }, api_name: :y + + # @!method initialize(focus: nil, x: nil, y_: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::OverlayPosition} for more details. + # + # @param focus [Symbol, Imagekitio::Models::OverlayPosition::Focus] Specifies the position of the overlay relative to the parent image or video. + # + # @param x [Float, String] Specifies the x-coordinate of the top-left corner of the base asset where the ov + # + # @param y_ [Float, String] Specifies the y-coordinate of the top-left corner of the base asset where the ov + + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + # + # @see Imagekitio::Models::OverlayPosition#focus + module Focus + extend Imagekitio::Internal::Type::Enum + + CENTER = :center + TOP = :top + LEFT = :left + BOTTOM = :bottom + RIGHT = :right + TOP_LEFT = :top_left + TOP_RIGHT = :top_right + BOTTOM_LEFT = :bottom_left + BOTTOM_RIGHT = :bottom_right + + # @!method self.values + # @return [Array] + end + + # 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). + # + # @see Imagekitio::Models::OverlayPosition#x + module X + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::OverlayPosition#y_ + module Y + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekitio/models/overlay_timing.rb b/lib/imagekitio/models/overlay_timing.rb new file mode 100644 index 00000000..2e00e42e --- /dev/null +++ b/lib/imagekitio/models/overlay_timing.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class OverlayTiming < Imagekitio::Internal::Type::BaseModel + # @!attribute duration + # 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. + # + # @return [Float, String, nil] + optional :duration, union: -> { Imagekitio::OverlayTiming::Duration } + + # @!attribute end_ + # 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. + # + # @return [Float, String, nil] + optional :end_, union: -> { Imagekitio::OverlayTiming::End }, api_name: :end + + # @!attribute start + # 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. + # + # @return [Float, String, nil] + optional :start, union: -> { Imagekitio::OverlayTiming::Start } + + # @!method initialize(duration: nil, end_: nil, start: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::OverlayTiming} for more details. + # + # @param duration [Float, String] Specifies the duration (in seconds) during which the overlay should appear on th + # + # @param end_ [Float, String] Specifies the end time (in seconds) for when the overlay should disappear from t + # + # @param start [Float, String] Specifies the start time (in seconds) for when the overlay should appear on the + + # 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. + # + # @see Imagekitio::Models::OverlayTiming#duration + module Duration + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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. + # + # @see Imagekitio::Models::OverlayTiming#end_ + module End + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + 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. + # + # @see Imagekitio::Models::OverlayTiming#start + module Start + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekitio/models/responsive_image_attributes.rb b/lib/imagekitio/models/responsive_image_attributes.rb new file mode 100644 index 00000000..5c0dd103 --- /dev/null +++ b/lib/imagekitio/models/responsive_image_attributes.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class ResponsiveImageAttributes < Imagekitio::Internal::Type::BaseModel + # @!attribute src + # URL for the _largest_ candidate (assigned to plain `src`). + # + # @return [String] + required :src, String + + # @!attribute sizes + # `sizes` returned (or synthesised as `100vw`). The value for the HTML `sizes` + # attribute. + # + # @return [String, nil] + optional :sizes, String + + # @!attribute src_set + # Candidate set with `w` or `x` descriptors. Multiple image URLs separated by + # commas, each with a descriptor. + # + # @return [String, nil] + optional :src_set, String, api_name: :srcSet + + # @!attribute width + # Width as a number (if `width` was provided in the input options). + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(src:, sizes: nil, src_set: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::ResponsiveImageAttributes} for more details. + # + # Resulting set of attributes suitable for an HTML `` element. Useful for + # enabling responsive image loading with `srcSet` and `sizes`. + # + # @param src [String] URL for the _largest_ candidate (assigned to plain `src`). + # + # @param sizes [String] `sizes` returned (or synthesised as `100vw`). + # + # @param src_set [String] Candidate set with `w` or `x` descriptors. + # + # @param width [Float] Width as a number (if `width` was provided in the input options). + end + end +end diff --git a/lib/imagekitio/models/solid_color_overlay.rb b/lib/imagekitio/models/solid_color_overlay.rb new file mode 100644 index 00000000..3d88d6ee --- /dev/null +++ b/lib/imagekitio/models/solid_color_overlay.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class SolidColorOverlay < Imagekitio::Models::BaseOverlay + # @!attribute color + # 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). + # + # @return [String] + required :color, String + + # @!attribute type + # + # @return [Symbol, :solidColor] + required :type, const: :solidColor + + # @!attribute transformation + # 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). + # + # @return [Array, nil] + optional :transformation, + -> { Imagekitio::Internal::Type::ArrayOf[Imagekitio::SolidColorOverlayTransformation] } + + # @!method initialize(color:, transformation: nil, type: :solidColor) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::SolidColorOverlay} for more details. + # + # @param color [String] Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA + # + # @param transformation [Array] Control width and height of the solid color overlay. Supported transformations d + # + # @param type [Symbol, :solidColor] + end + end +end diff --git a/lib/imagekitio/models/solid_color_overlay_transformation.rb b/lib/imagekitio/models/solid_color_overlay_transformation.rb new file mode 100644 index 00000000..a68593b1 --- /dev/null +++ b/lib/imagekitio/models/solid_color_overlay_transformation.rb @@ -0,0 +1,135 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class SolidColorOverlayTransformation < Imagekitio::Internal::Type::BaseModel + # @!attribute alpha + # Specifies the transparency level of the solid color overlay. Accepts integers + # from `1` to `9`. + # + # @return [Float, nil] + optional :alpha, Float + + # @!attribute background + # 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. + # + # @return [String, nil] + optional :background, String + + # @!attribute gradient + # 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). + # + # @return [Boolean, true, String, nil] + optional :gradient, union: -> { Imagekitio::SolidColorOverlayTransformation::Gradient } + + # @!attribute height + # 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). + # + # @return [Float, String, nil] + optional :height, union: -> { Imagekitio::SolidColorOverlayTransformation::Height } + + # @!attribute radius + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + # + # @return [Float, Symbol, :max, nil] + optional :radius, union: -> { Imagekitio::SolidColorOverlayTransformation::Radius } + + # @!attribute width + # 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). + # + # @return [Float, String, nil] + optional :width, union: -> { Imagekitio::SolidColorOverlayTransformation::Width } + + # @!method initialize(alpha: nil, background: nil, gradient: nil, height: nil, radius: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::SolidColorOverlayTransformation} for more details. + # + # @param alpha [Float] Specifies the transparency level of the solid color overlay. Accepts integers fr + # + # @param background [String] Specifies the background color of the solid color overlay. Accepts an RGB hex co + # + # @param gradient [Boolean, true, String] Creates a linear gradient with two colors. Pass `true` for a default gradient, o + # + # @param height [Float, String] Controls the height of the solid color overlay. Accepts a numeric value or an ar + # + # @param radius [Float, Symbol, :max] Specifies the corner radius of the solid color overlay. Set to `max` for circula + # + # @param width [Float, String] Controls the width of the solid color overlay. Accepts a numeric value or an ari + + # 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). + # + # @see Imagekitio::Models::SolidColorOverlayTransformation#gradient + module Gradient + extend Imagekitio::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # 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). + # + # @see Imagekitio::Models::SolidColorOverlayTransformation#height + module Height + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + # + # @see Imagekitio::Models::SolidColorOverlayTransformation#radius + module Radius + extend Imagekitio::Internal::Type::Union + + variant Float + + variant const: :max + + # @!method self.variants + # @return [Array(Float, Symbol, :max)] + end + + # 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). + # + # @see Imagekitio::Models::SolidColorOverlayTransformation#width + module Width + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekitio/models/src_options.rb b/lib/imagekitio/models/src_options.rb new file mode 100644 index 00000000..880df17d --- /dev/null +++ b/lib/imagekitio/models/src_options.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class SrcOptions < Imagekitio::Internal::Type::BaseModel + # @!attribute src + # 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. + # + # @return [String] + required :src, String + + # @!attribute url_endpoint + # Get your urlEndpoint from the + # [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + # + # @return [String] + required :url_endpoint, String, api_name: :urlEndpoint + + # @!attribute expires_in + # 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). + # + # @return [Float, nil] + optional :expires_in, Float, api_name: :expiresIn + + # @!attribute query_parameters + # 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. + # + # @return [Hash{Symbol=>String}, nil] + optional :query_parameters, Imagekitio::Internal::Type::HashOf[String], api_name: :queryParameters + + # @!attribute signed + # 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). + # + # @return [Boolean, nil] + optional :signed, Imagekitio::Internal::Type::Boolean + + # @!attribute transformation + # 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). + # + # @return [Array, nil] + optional :transformation, -> { Imagekitio::Internal::Type::ArrayOf[Imagekitio::Transformation] } + + # @!attribute transformation_position + # 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). + # + # @return [Symbol, Imagekitio::Models::TransformationPosition, nil] + optional :transformation_position, + enum: -> { Imagekitio::TransformationPosition }, + api_name: :transformationPosition + + # @!method initialize(src:, url_endpoint:, expires_in: nil, query_parameters: nil, signed: nil, transformation: nil, transformation_position: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::SrcOptions} for more details. + # + # Options for generating ImageKit URLs with transformations. See the + # [Transformations guide](https://imagekit.io/docs/transformations). + # + # @param src [String] Accepts a relative or absolute path of the resource. If a relative path is provi + # + # @param url_endpoint [String] Get your urlEndpoint from the [ImageKit dashboard](https://imagekit.io/dashboard + # + # @param expires_in [Float] When you want the signed URL to expire, specified in seconds. If `expiresIn` is + # + # @param query_parameters [Hash{Symbol=>String}] These are additional query parameters that you want to add to the final URL. + # + # @param signed [Boolean] Whether to sign the URL or not. Set this to `true` if you want to generate a sig + # + # @param transformation [Array] An array of objects specifying the transformations to be applied in the URL. If + # + # @param transformation_position [Symbol, Imagekitio::Models::TransformationPosition] By default, the transformation string is added as a query parameter in the URL, + end + end +end diff --git a/lib/imagekitio/models/streaming_resolution.rb b/lib/imagekitio/models/streaming_resolution.rb new file mode 100644 index 00000000..abd52f78 --- /dev/null +++ b/lib/imagekitio/models/streaming_resolution.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # Available streaming resolutions for + # [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) + module StreamingResolution + extend Imagekitio::Internal::Type::Enum + + STREAMING_RESOLUTION_240 = :"240" + STREAMING_RESOLUTION_360 = :"360" + STREAMING_RESOLUTION_480 = :"480" + STREAMING_RESOLUTION_720 = :"720" + STREAMING_RESOLUTION_1080 = :"1080" + STREAMING_RESOLUTION_1440 = :"1440" + STREAMING_RESOLUTION_2160 = :"2160" + + # @!method self.values + # @return [Array] + end + end +end diff --git a/lib/imagekitio/models/subtitle_overlay.rb b/lib/imagekitio/models/subtitle_overlay.rb new file mode 100644 index 00000000..70694b9b --- /dev/null +++ b/lib/imagekitio/models/subtitle_overlay.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class SubtitleOverlay < Imagekitio::Models::BaseOverlay + # @!attribute input + # Specifies the relative path to the subtitle file used as an overlay. + # + # @return [String] + required :input, String + + # @!attribute type + # + # @return [Symbol, :subtitle] + required :type, const: :subtitle + + # @!attribute encoding + # 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`. + # + # @return [Symbol, Imagekitio::Models::SubtitleOverlay::Encoding, nil] + optional :encoding, enum: -> { Imagekitio::SubtitleOverlay::Encoding } + + # @!attribute transformation + # Control styling of the subtitle. See + # [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + # + # @return [Array, nil] + optional :transformation, + -> { Imagekitio::Internal::Type::ArrayOf[Imagekitio::SubtitleOverlayTransformation] } + + # @!method initialize(input:, encoding: nil, transformation: nil, type: :subtitle) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::SubtitleOverlay} for more details. + # + # @param input [String] Specifies the relative path to the subtitle file used as an overlay. + # + # @param encoding [Symbol, Imagekitio::Models::SubtitleOverlay::Encoding] The input path can be included in the layer as either `i-{input}` or `ie-{base64 + # + # @param transformation [Array] Control styling of the subtitle. See [Styling subtitles](https://imagekit.io/doc + # + # @param type [Symbol, :subtitle] + + # 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`. + module Encoding + extend Imagekitio::Internal::Type::Enum + + AUTO = :auto + PLAIN = :plain + BASE64 = :base64 + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekitio/models/subtitle_overlay_transformation.rb b/lib/imagekitio/models/subtitle_overlay_transformation.rb new file mode 100644 index 00000000..1e06adb3 --- /dev/null +++ b/lib/imagekitio/models/subtitle_overlay_transformation.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class SubtitleOverlayTransformation < Imagekitio::Internal::Type::BaseModel + # @!attribute background + # 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) + # + # @return [String, nil] + optional :background, String + + # @!attribute color + # 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) + # + # @return [String, nil] + optional :color, String + + # @!attribute font_family + # Font family for subtitles. Refer to the + # [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + # + # @return [String, nil] + optional :font_family, String, api_name: :fontFamily + + # @!attribute font_outline + # 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) + # + # @return [String, nil] + optional :font_outline, String, api_name: :fontOutline + + # @!attribute font_shadow + # 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) + # + # @return [String, nil] + optional :font_shadow, String, api_name: :fontShadow + + # @!attribute font_size + # Sets the font size of subtitle text. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # + # @return [Float, nil] + optional :font_size, Float, api_name: :fontSize + + # @!attribute typography + # 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) + # + # @return [Symbol, Imagekitio::Models::SubtitleOverlayTransformation::Typography, nil] + optional :typography, enum: -> { Imagekitio::SubtitleOverlayTransformation::Typography } + + # @!method initialize(background: nil, color: nil, font_family: nil, font_outline: nil, font_shadow: nil, font_size: nil, typography: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::SubtitleOverlayTransformation} for more details. + # + # Subtitle styling options. + # [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # from the docs. + # + # @param background [String] Specifies the subtitle background color using a standard color name, an RGB colo + # + # @param color [String] Sets the font color of the subtitle text using a standard color name, an RGB col + # + # @param font_family [String] Font family for subtitles. Refer to the [supported fonts](https://imagekit.io/do + # + # @param font_outline [String] Sets the font outline of the subtitle text. + # + # @param font_shadow [String] Sets the font shadow for the subtitle text. + # + # @param font_size [Float] Sets the font size of subtitle text. + # + # @param typography [Symbol, Imagekitio::Models::SubtitleOverlayTransformation::Typography] Sets the typography style of the subtitle text. Supports values are `b` for bold + + # 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) + # + # @see Imagekitio::Models::SubtitleOverlayTransformation#typography + module Typography + extend Imagekitio::Internal::Type::Enum + + B = :b + I = :i + B_I = :b_i + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekitio/models/text_overlay.rb b/lib/imagekitio/models/text_overlay.rb new file mode 100644 index 00000000..3f022e8d --- /dev/null +++ b/lib/imagekitio/models/text_overlay.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class TextOverlay < Imagekitio::Models::BaseOverlay + # @!attribute text + # Specifies the text to be displayed in the overlay. The SDK automatically handles + # special characters and encoding. + # + # @return [String] + required :text, String + + # @!attribute type + # + # @return [Symbol, :text] + required :type, const: :text + + # @!attribute encoding + # 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`. + # + # @return [Symbol, Imagekitio::Models::TextOverlay::Encoding, nil] + optional :encoding, enum: -> { Imagekitio::TextOverlay::Encoding } + + # @!attribute transformation + # Control styling of the text overlay. See + # [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + # + # @return [Array, nil] + optional :transformation, + -> { Imagekitio::Internal::Type::ArrayOf[Imagekitio::TextOverlayTransformation] } + + # @!method initialize(text:, encoding: nil, transformation: nil, type: :text) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::TextOverlay} for more details. + # + # @param text [String] Specifies the text to be displayed in the overlay. The SDK automatically handles + # + # @param encoding [Symbol, Imagekitio::Models::TextOverlay::Encoding] Text can be included in the layer as either `i-{input}` (plain text) or `ie-{bas + # + # @param transformation [Array] Control styling of the text overlay. See [Text overlays](https://imagekit.io/doc + # + # @param type [Symbol, :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`. + module Encoding + extend Imagekitio::Internal::Type::Enum + + AUTO = :auto + PLAIN = :plain + BASE64 = :base64 + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekitio/models/text_overlay_transformation.rb b/lib/imagekitio/models/text_overlay_transformation.rb new file mode 100644 index 00000000..3a2f4d41 --- /dev/null +++ b/lib/imagekitio/models/text_overlay_transformation.rb @@ -0,0 +1,267 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class TextOverlayTransformation < Imagekitio::Internal::Type::BaseModel + # @!attribute alpha + # Specifies the transparency level of the text overlay. Accepts integers from `1` + # to `9`. + # + # @return [Float, nil] + optional :alpha, Float + + # @!attribute background + # Specifies the background color of the text overlay. Accepts an RGB hex code, an + # RGBA code, or a color name. + # + # @return [String, nil] + optional :background, String + + # @!attribute flip + # Flip the text overlay horizontally, vertically, or both. + # + # @return [Symbol, Imagekitio::Models::TextOverlayTransformation::Flip, nil] + optional :flip, enum: -> { Imagekitio::TextOverlayTransformation::Flip } + + # @!attribute font_color + # 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. + # + # @return [String, nil] + optional :font_color, String, api_name: :fontColor + + # @!attribute font_family + # 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). + # + # @return [String, nil] + optional :font_family, String, api_name: :fontFamily + + # @!attribute font_size + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + # + # @return [Float, String, nil] + optional :font_size, union: -> { Imagekitio::TextOverlayTransformation::FontSize }, api_name: :fontSize + + # @!attribute inner_alignment + # Specifies the inner alignment of the text when width is more than the text + # length. + # + # @return [Symbol, Imagekitio::Models::TextOverlayTransformation::InnerAlignment, nil] + optional :inner_alignment, + enum: -> { Imagekitio::TextOverlayTransformation::InnerAlignment }, + api_name: :innerAlignment + + # @!attribute line_height + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + # + # @return [Float, String, nil] + optional :line_height, + union: -> { Imagekitio::TextOverlayTransformation::LineHeight }, + api_name: :lineHeight + + # @!attribute padding + # 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. + # + # @return [Float, String, nil] + optional :padding, union: -> { Imagekitio::TextOverlayTransformation::Padding } + + # @!attribute radius + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + # + # @return [Float, Symbol, :max, nil] + optional :radius, union: -> { Imagekitio::TextOverlayTransformation::Radius } + + # @!attribute rotation + # 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. + # + # @return [Float, String, nil] + optional :rotation, union: -> { Imagekitio::TextOverlayTransformation::Rotation } + + # @!attribute typography + # 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`. + # + # @return [String, nil] + optional :typography, String + + # @!attribute width + # 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). + # + # @return [Float, String, nil] + optional :width, union: -> { Imagekitio::TextOverlayTransformation::Width } + + # @!method initialize(alpha: nil, background: nil, flip: nil, font_color: nil, font_family: nil, font_size: nil, inner_alignment: nil, line_height: nil, padding: nil, radius: nil, rotation: nil, typography: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::TextOverlayTransformation} for more details. + # + # @param alpha [Float] Specifies the transparency level of the text overlay. Accepts integers from `1` + # + # @param background [String] Specifies the background color of the text overlay. + # + # @param flip [Symbol, Imagekitio::Models::TextOverlayTransformation::Flip] Flip the text overlay horizontally, vertically, or both. + # + # @param font_color [String] Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., `F + # + # @param font_family [String] Specifies the font family of the overlaid text. Choose from the supported fonts + # + # @param font_size [Float, String] Specifies the font size of the overlaid text. Accepts a numeric value or an arit + # + # @param inner_alignment [Symbol, Imagekitio::Models::TextOverlayTransformation::InnerAlignment] Specifies the inner alignment of the text when width is more than the text lengt + # + # @param line_height [Float, String] Specifies the line height of the text overlay. + # + # @param padding [Float, String] Specifies the padding around the overlaid text. + # + # @param radius [Float, Symbol, :max] Specifies the corner radius of the text overlay. + # + # @param rotation [Float, String] Specifies the rotation angle of the text overlay. + # + # @param typography [String] Specifies the typography style of the text. + # + # @param width [Float, String] Specifies the maximum width (in pixels) of the overlaid text. The text wraps aut + + # Flip the text overlay horizontally, vertically, or both. + # + # @see Imagekitio::Models::TextOverlayTransformation#flip + module Flip + extend Imagekitio::Internal::Type::Enum + + H = :h + V = :v + H_V = :h_v + V_H = :v_h + + # @!method self.values + # @return [Array] + end + + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + # + # @see Imagekitio::Models::TextOverlayTransformation#font_size + module FontSize + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the inner alignment of the text when width is more than the text + # length. + # + # @see Imagekitio::Models::TextOverlayTransformation#inner_alignment + module InnerAlignment + extend Imagekitio::Internal::Type::Enum + + LEFT = :left + RIGHT = :right + CENTER = :center + + # @!method self.values + # @return [Array] + end + + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + # + # @see Imagekitio::Models::TextOverlayTransformation#line_height + module LineHeight + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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. + # + # @see Imagekitio::Models::TextOverlayTransformation#padding + module Padding + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + # + # @see Imagekitio::Models::TextOverlayTransformation#radius + module Radius + extend Imagekitio::Internal::Type::Union + + variant Float + + variant const: :max + + # @!method self.variants + # @return [Array(Float, Symbol, :max)] + end + + # 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. + # + # @see Imagekitio::Models::TextOverlayTransformation#rotation + module Rotation + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::TextOverlayTransformation#width + module Width + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekitio/models/transformation.rb b/lib/imagekitio/models/transformation.rb new file mode 100644 index 00000000..7fe5deb9 --- /dev/null +++ b/lib/imagekitio/models/transformation.rb @@ -0,0 +1,1100 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute ai_change_background + # 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). + # + # @return [String, nil] + optional :ai_change_background, String, api_name: :aiChangeBackground + + # @!attribute ai_drop_shadow + # 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). + # + # @return [Boolean, true, String, nil] + optional :ai_drop_shadow, + union: -> { + Imagekitio::Transformation::AIDropShadow + }, + api_name: :aiDropShadow + + # @!attribute ai_edit + # 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). + # + # @return [String, nil] + optional :ai_edit, String, api_name: :aiEdit + + # @!attribute ai_remove_background + # 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). + # + # @return [Boolean, Imagekitio::Models::Transformation::AIRemoveBackground, nil] + optional :ai_remove_background, + enum: -> { Imagekitio::Transformation::AIRemoveBackground }, + api_name: :aiRemoveBackground + + # @!attribute ai_remove_background_external + # 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). + # + # @return [Boolean, Imagekitio::Models::Transformation::AIRemoveBackgroundExternal, nil] + optional :ai_remove_background_external, + enum: -> { Imagekitio::Transformation::AIRemoveBackgroundExternal }, + api_name: :aiRemoveBackgroundExternal + + # @!attribute ai_retouch + # 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). + # + # @return [Boolean, Imagekitio::Models::Transformation::AIRetouch, nil] + optional :ai_retouch, enum: -> { Imagekitio::Transformation::AIRetouch }, api_name: :aiRetouch + + # @!attribute ai_upscale + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + # + # @return [Boolean, Imagekitio::Models::Transformation::AIUpscale, nil] + optional :ai_upscale, enum: -> { Imagekitio::Transformation::AIUpscale }, api_name: :aiUpscale + + # @!attribute ai_variation + # 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). + # + # @return [Boolean, Imagekitio::Models::Transformation::AIVariation, nil] + optional :ai_variation, enum: -> { Imagekitio::Transformation::AIVariation }, api_name: :aiVariation + + # @!attribute aspect_ratio + # 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). + # + # @return [Float, String, nil] + optional :aspect_ratio, union: -> { Imagekitio::Transformation::AspectRatio }, api_name: :aspectRatio + + # @!attribute audio_codec + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + # + # @return [Symbol, Imagekitio::Models::Transformation::AudioCodec, nil] + optional :audio_codec, enum: -> { Imagekitio::Transformation::AudioCodec }, api_name: :audioCodec + + # @!attribute background + # 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). + # - 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). + # + # @return [String, nil] + optional :background, String + + # @!attribute blur + # 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). + # + # @return [Float, nil] + optional :blur, Float + + # @!attribute border + # 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). + # + # @return [String, nil] + optional :border, String + + # @!attribute color_profile + # Indicates whether the output image should retain the original color profile. See + # [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + # + # @return [Boolean, nil] + optional :color_profile, Imagekitio::Internal::Type::Boolean, api_name: :colorProfile + + # @!attribute contrast_stretch + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + # + # @return [Boolean, Imagekitio::Models::Transformation::ContrastStretch, nil] + optional :contrast_stretch, + enum: -> { Imagekitio::Transformation::ContrastStretch }, + api_name: :contrastStretch + + # @!attribute crop + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + # + # @return [Symbol, Imagekitio::Models::Transformation::Crop, nil] + optional :crop, enum: -> { Imagekitio::Transformation::Crop } + + # @!attribute crop_mode + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + # + # @return [Symbol, Imagekitio::Models::Transformation::CropMode, nil] + optional :crop_mode, enum: -> { Imagekitio::Transformation::CropMode }, api_name: :cropMode + + # @!attribute default_image + # 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). + # + # @return [String, nil] + optional :default_image, String, api_name: :defaultImage + + # @!attribute dpr + # Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + # (DPR) calculation. See + # [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + # + # @return [Float, nil] + optional :dpr, Float + + # @!attribute duration + # 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). + # + # @return [Float, String, nil] + optional :duration, union: -> { Imagekitio::Transformation::Duration } + + # @!attribute end_offset + # 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). + # + # @return [Float, String, nil] + optional :end_offset, union: -> { Imagekitio::Transformation::EndOffset }, api_name: :endOffset + + # @!attribute flip + # 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). + # + # @return [Symbol, Imagekitio::Models::Transformation::Flip, nil] + optional :flip, enum: -> { Imagekitio::Transformation::Flip } + + # @!attribute focus + # 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) + # + # @return [String, nil] + optional :focus, String + + # @!attribute format_ + # 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). + # + # @return [Symbol, Imagekitio::Models::Transformation::Format, nil] + optional :format_, enum: -> { Imagekitio::Transformation::Format }, api_name: :format + + # @!attribute gradient + # 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). + # + # @return [Boolean, true, String, nil] + optional :gradient, union: -> { Imagekitio::Transformation::Gradient } + + # @!attribute grayscale + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + # + # @return [Boolean, Imagekitio::Models::Transformation::Grayscale, nil] + optional :grayscale, enum: -> { Imagekitio::Transformation::Grayscale } + + # @!attribute height + # 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) + # + # @return [Float, String, nil] + optional :height, union: -> { Imagekitio::Transformation::Height } + + # @!attribute lossless + # 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). + # + # @return [Boolean, nil] + optional :lossless, Imagekitio::Internal::Type::Boolean + + # @!attribute metadata + # 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). + # + # @return [Boolean, nil] + optional :metadata, Imagekitio::Internal::Type::Boolean + + # @!attribute named + # Named transformation reference. See + # [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + # + # @return [String, nil] + optional :named, String + + # @!attribute opacity + # Specifies the opacity level of the output image. See + # [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + # + # @return [Float, nil] + optional :opacity, Float + + # @!attribute original + # 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). + # + # @return [Boolean, nil] + optional :original, Imagekitio::Internal::Type::Boolean + + # @!attribute overlay + # 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). + # + # @return [Imagekitio::Models::Overlay, nil] + optional :overlay, union: -> { Imagekitio::Overlay } + + # @!attribute page + # 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). + # + # @return [Float, String, nil] + optional :page, union: -> { Imagekitio::Transformation::Page } + + # @!attribute progressive + # 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). + # + # @return [Boolean, nil] + optional :progressive, Imagekitio::Internal::Type::Boolean + + # @!attribute quality + # 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). + # + # @return [Float, nil] + optional :quality, Float + + # @!attribute radius + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + # + # @return [Float, Symbol, :max, nil] + optional :radius, union: -> { Imagekitio::Transformation::Radius } + + # @!attribute raw + # Pass any transformation not directly supported by the SDK. This transformation + # string is appended to the URL as provided. + # + # @return [String, nil] + optional :raw, String + + # @!attribute rotation + # 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). + # + # @return [Float, String, nil] + optional :rotation, union: -> { Imagekitio::Transformation::Rotation } + + # @!attribute shadow + # 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). + # + # @return [Boolean, true, String, nil] + optional :shadow, union: -> { Imagekitio::Transformation::Shadow } + + # @!attribute sharpen + # 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). + # + # @return [Boolean, true, Float, nil] + optional :sharpen, union: -> { Imagekitio::Transformation::Sharpen } + + # @!attribute start_offset + # 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). + # + # @return [Float, String, nil] + optional :start_offset, union: -> { Imagekitio::Transformation::StartOffset }, api_name: :startOffset + + # @!attribute streaming_resolutions + # 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). + # + # @return [Array, nil] + optional :streaming_resolutions, + -> { Imagekitio::Internal::Type::ArrayOf[enum: Imagekitio::StreamingResolution] }, + api_name: :streamingResolutions + + # @!attribute trim + # 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). + # + # @return [Boolean, true, Float, nil] + optional :trim, union: -> { Imagekitio::Transformation::Trim } + + # @!attribute unsharp_mask + # 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). + # + # @return [Boolean, true, String, nil] + optional :unsharp_mask, union: -> { Imagekitio::Transformation::UnsharpMask }, api_name: :unsharpMask + + # @!attribute video_codec + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + # + # @return [Symbol, Imagekitio::Models::Transformation::VideoCodec, nil] + optional :video_codec, enum: -> { Imagekitio::Transformation::VideoCodec }, api_name: :videoCodec + + # @!attribute width + # 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) + # + # @return [Float, String, nil] + optional :width, union: -> { Imagekitio::Transformation::Width } + + # @!attribute x + # 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). + # + # @return [Float, String, nil] + optional :x, union: -> { Imagekitio::Transformation::X } + + # @!attribute x_center + # 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). + # + # @return [Float, String, nil] + optional :x_center, union: -> { Imagekitio::Transformation::XCenter }, api_name: :xCenter + + # @!attribute y_ + # 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). + # + # @return [Float, String, nil] + optional :y_, union: -> { Imagekitio::Transformation::Y }, api_name: :y + + # @!attribute y_center + # 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). + # + # @return [Float, String, nil] + optional :y_center, union: -> { Imagekitio::Transformation::YCenter }, api_name: :yCenter + + # @!attribute zoom + # 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). + # + # @return [Float, nil] + optional :zoom, Float + + # @!method initialize(ai_change_background: nil, ai_drop_shadow: nil, ai_edit: nil, ai_remove_background: nil, ai_remove_background_external: nil, ai_retouch: nil, ai_upscale: nil, ai_variation: nil, aspect_ratio: nil, audio_codec: nil, background: nil, blur: nil, border: nil, color_profile: nil, contrast_stretch: nil, crop: nil, crop_mode: nil, default_image: nil, dpr: nil, duration: nil, end_offset: nil, flip: nil, focus: nil, format_: nil, gradient: nil, grayscale: nil, height: nil, lossless: nil, metadata: nil, named: nil, opacity: nil, original: nil, overlay: nil, page: nil, progressive: nil, quality: nil, radius: nil, raw: nil, rotation: nil, shadow: nil, sharpen: nil, start_offset: nil, streaming_resolutions: nil, trim: nil, unsharp_mask: nil, video_codec: nil, width: nil, x: nil, x_center: nil, y_: nil, y_center: nil, zoom: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Transformation} for more details. + # + # The SDK provides easy-to-use names for transformations. These names are + # converted to the corresponding transformation string before being added to the + # URL. SDKs are updated regularly to support new transformations. If you want to + # use a transformation that is not supported by the SDK, You can use the `raw` + # parameter to pass the transformation string directly. See the + # [Transformations documentation](https://imagekit.io/docs/transformations). + # + # @param ai_change_background [String] Uses AI to change the background. Provide a text prompt or a base64-encoded prom + # + # @param ai_drop_shadow [Boolean, true, String] Adds an AI-based drop shadow around a foreground object on a transparent or remo + # + # @param ai_edit [String] Uses AI to edit images based on a text prompt. Provide a text prompt or a base64 + # + # @param ai_remove_background [Boolean, Imagekitio::Models::Transformation::AIRemoveBackground] Applies ImageKit's in-house background removal. + # + # @param ai_remove_background_external [Boolean, Imagekitio::Models::Transformation::AIRemoveBackgroundExternal] Uses third-party background removal. + # + # @param ai_retouch [Boolean, Imagekitio::Models::Transformation::AIRetouch] Performs AI-based retouching to improve faces or product shots. Not supported in + # + # @param ai_upscale [Boolean, Imagekitio::Models::Transformation::AIUpscale] Upscales images beyond their original dimensions using AI. Not supported inside + # + # @param ai_variation [Boolean, Imagekitio::Models::Transformation::AIVariation] Generates a variation of an image using AI. This produces a new image with sligh + # + # @param aspect_ratio [Float, String] Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with e + # + # @param audio_codec [Symbol, Imagekitio::Models::Transformation::AudioCodec] Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See [Audio codec](htt + # + # @param background [String] Specifies the background to be used in conjunction with certain cropping strateg + # + # @param blur [Float] Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, o + # + # @param border [String] Adds a border to the output media. Accepts a string in the format `] An array of resolutions for adaptive bitrate streaming, e.g., [`240`, `360`, `48 + # + # @param trim [Boolean, true, Float] Useful for images with a solid or nearly solid background and a central object. + # + # @param unsharp_mask [Boolean, true, String] Applies Unsharp Masking (USM), an image sharpening technique. + # + # @param video_codec [Symbol, Imagekitio::Models::Transformation::VideoCodec] Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See [Video cod + # + # @param width [Float, String] Specifies the width of the output. If a value between 0 and 1 is provided, it is + # + # @param x [Float, String] Focus using cropped image coordinates - X coordinate. See [Focus using cropped c + # + # @param x_center [Float, String] Focus using cropped image coordinates - X center coordinate. See [Focus using cr + # + # @param y_ [Float, String] Focus using cropped image coordinates - Y coordinate. See [Focus using cropped c + # + # @param y_center [Float, String] Focus using cropped image coordinates - Y center coordinate. See [Focus using cr + # + # @param zoom [Float] Accepts a numeric value that determines how much to zoom in or out of the croppe + + # 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). + # + # @see Imagekitio::Models::Transformation#ai_drop_shadow + module AIDropShadow + extend Imagekitio::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#ai_remove_background + module AIRemoveBackground + extend Imagekitio::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#ai_remove_background_external + module AIRemoveBackgroundExternal + extend Imagekitio::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#ai_retouch + module AIRetouch + extend Imagekitio::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + # + # @see Imagekitio::Models::Transformation#ai_upscale + module AIUpscale + extend Imagekitio::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#ai_variation + module AIVariation + extend Imagekitio::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#aspect_ratio + module AspectRatio + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + # + # @see Imagekitio::Models::Transformation#audio_codec + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + AAC = :aac + OPUS = :opus + NONE = :none + + # @!method self.values + # @return [Array] + end + + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + # + # @see Imagekitio::Models::Transformation#contrast_stretch + module ContrastStretch + extend Imagekitio::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + # + # @see Imagekitio::Models::Transformation#crop + module Crop + extend Imagekitio::Internal::Type::Enum + + FORCE = :force + AT_MAX = :at_max + AT_MAX_ENLARGE = :at_max_enlarge + AT_LEAST = :at_least + MAINTAIN_RATIO = :maintain_ratio + + # @!method self.values + # @return [Array] + end + + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + # + # @see Imagekitio::Models::Transformation#crop_mode + module CropMode + extend Imagekitio::Internal::Type::Enum + + PAD_RESIZE = :pad_resize + EXTRACT = :extract + PAD_EXTRACT = :pad_extract + + # @!method self.values + # @return [Array] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#duration + module Duration + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#end_offset + module EndOffset + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#flip + module Flip + extend Imagekitio::Internal::Type::Enum + + H = :h + V = :v + H_V = :h_v + V_H = :v_h + + # @!method self.values + # @return [Array] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#format_ + module Format + extend Imagekitio::Internal::Type::Enum + + AUTO = :auto + WEBP = :webp + JPG = :jpg + JPEG = :jpeg + PNG = :png + GIF = :gif + SVG = :svg + MP4 = :mp4 + WEBM = :webm + AVIF = :avif + ORIG = :orig + + # @!method self.values + # @return [Array] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#gradient + module Gradient + extend Imagekitio::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + # + # @see Imagekitio::Models::Transformation#grayscale + module Grayscale + extend Imagekitio::Internal::Type::Enum + + TRUE = true + + # @!method self.values + # @return [Array] + end + + # 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) + # + # @see Imagekitio::Models::Transformation#height + module Height + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#page + module Page + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + # + # @see Imagekitio::Models::Transformation#radius + module Radius + extend Imagekitio::Internal::Type::Union + + variant Float + + variant const: :max + + # @!method self.variants + # @return [Array(Float, Symbol, :max)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#rotation + module Rotation + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#shadow + module Shadow + extend Imagekitio::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#sharpen + module Sharpen + extend Imagekitio::Internal::Type::Union + + variant const: true + + variant Float + + # @!method self.variants + # @return [Array(Boolean, true, Float)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#start_offset + module StartOffset + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#trim + module Trim + extend Imagekitio::Internal::Type::Union + + variant const: true + + variant Float + + # @!method self.variants + # @return [Array(Boolean, true, Float)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#unsharp_mask + module UnsharpMask + extend Imagekitio::Internal::Type::Union + + variant const: true + + variant String + + # @!method self.variants + # @return [Array(Boolean, true, String)] + end + + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + # + # @see Imagekitio::Models::Transformation#video_codec + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + H264 = :h264 + VP9 = :vp9 + AV1 = :av1 + NONE = :none + + # @!method self.values + # @return [Array] + end + + # 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) + # + # @see Imagekitio::Models::Transformation#width + module Width + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#x + module X + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#x_center + module XCenter + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#y_ + module Y + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + + # 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). + # + # @see Imagekitio::Models::Transformation#y_center + module YCenter + extend Imagekitio::Internal::Type::Union + + variant Float + + variant String + + # @!method self.variants + # @return [Array(Float, String)] + end + end + end +end diff --git a/lib/imagekitio/models/transformation_position.rb b/lib/imagekitio/models/transformation_position.rb new file mode 100644 index 00000000..649ea41b --- /dev/null +++ b/lib/imagekitio/models/transformation_position.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # 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). + module TransformationPosition + extend Imagekitio::Internal::Type::Enum + + PATH = :path + QUERY = :query + + # @!method self.values + # @return [Array] + end + end +end diff --git a/lib/imagekitio/models/unsafe_unwrap_webhook_event.rb b/lib/imagekitio/models/unsafe_unwrap_webhook_event.rb new file mode 100644 index 00000000..3ae76efc --- /dev/null +++ b/lib/imagekitio/models/unsafe_unwrap_webhook_event.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + module UnsafeUnwrapWebhookEvent + extend Imagekitio::Internal::Type::Union + + # Triggered when a new video transformation request is accepted for processing. This event confirms that ImageKit has received and queued your transformation request. Use this for debugging and tracking transformation lifecycle. + variant -> { Imagekitio::VideoTransformationAcceptedEvent } + + # Triggered when video encoding is finished and the transformed resource is ready to be served. This is the key event to listen for - update your database or CMS flags when you receive this so your application can start showing the transformed video to users. + variant -> { Imagekitio::VideoTransformationReadyEvent } + + # Triggered when an error occurs during video encoding. Listen to this webhook to log error reasons and debug issues. Check your origin and URL endpoint settings if the reason is related to download failure. For other errors, contact ImageKit support. + variant -> { Imagekitio::VideoTransformationErrorEvent } + + # Triggered when a pre-transformation completes successfully. The file has been processed with the requested transformation and is now available in the Media Library. + variant -> { Imagekitio::UploadPreTransformSuccessEvent } + + # Triggered when a pre-transformation fails. The file upload may have been accepted, but the requested transformation could not be applied. + variant -> { Imagekitio::UploadPreTransformErrorEvent } + + # Triggered when a post-transformation completes successfully. The transformed version of the file is now ready and can be accessed via the provided URL. Note that each post-transformation generates a separate webhook event. + variant -> { Imagekitio::UploadPostTransformSuccessEvent } + + # Triggered when a post-transformation fails. The original file remains available, but the requested transformation could not be generated. + variant -> { Imagekitio::UploadPostTransformErrorEvent } + + # @!method self.variants + # @return [Array(Imagekitio::Models::VideoTransformationAcceptedEvent, Imagekitio::Models::VideoTransformationReadyEvent, Imagekitio::Models::VideoTransformationErrorEvent, Imagekitio::Models::UploadPreTransformSuccessEvent, Imagekitio::Models::UploadPreTransformErrorEvent, Imagekitio::Models::UploadPostTransformSuccessEvent, Imagekitio::Models::UploadPostTransformErrorEvent)] + end + end +end diff --git a/lib/imagekitio/models/unwrap_webhook_event.rb b/lib/imagekitio/models/unwrap_webhook_event.rb new file mode 100644 index 00000000..ebbdfd88 --- /dev/null +++ b/lib/imagekitio/models/unwrap_webhook_event.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + module UnwrapWebhookEvent + extend Imagekitio::Internal::Type::Union + + # Triggered when a new video transformation request is accepted for processing. This event confirms that ImageKit has received and queued your transformation request. Use this for debugging and tracking transformation lifecycle. + variant -> { Imagekitio::VideoTransformationAcceptedEvent } + + # Triggered when video encoding is finished and the transformed resource is ready to be served. This is the key event to listen for - update your database or CMS flags when you receive this so your application can start showing the transformed video to users. + variant -> { Imagekitio::VideoTransformationReadyEvent } + + # Triggered when an error occurs during video encoding. Listen to this webhook to log error reasons and debug issues. Check your origin and URL endpoint settings if the reason is related to download failure. For other errors, contact ImageKit support. + variant -> { Imagekitio::VideoTransformationErrorEvent } + + # Triggered when a pre-transformation completes successfully. The file has been processed with the requested transformation and is now available in the Media Library. + variant -> { Imagekitio::UploadPreTransformSuccessEvent } + + # Triggered when a pre-transformation fails. The file upload may have been accepted, but the requested transformation could not be applied. + variant -> { Imagekitio::UploadPreTransformErrorEvent } + + # Triggered when a post-transformation completes successfully. The transformed version of the file is now ready and can be accessed via the provided URL. Note that each post-transformation generates a separate webhook event. + variant -> { Imagekitio::UploadPostTransformSuccessEvent } + + # Triggered when a post-transformation fails. The original file remains available, but the requested transformation could not be generated. + variant -> { Imagekitio::UploadPostTransformErrorEvent } + + # @!method self.variants + # @return [Array(Imagekitio::Models::VideoTransformationAcceptedEvent, Imagekitio::Models::VideoTransformationReadyEvent, Imagekitio::Models::VideoTransformationErrorEvent, Imagekitio::Models::UploadPreTransformSuccessEvent, Imagekitio::Models::UploadPreTransformErrorEvent, Imagekitio::Models::UploadPostTransformSuccessEvent, Imagekitio::Models::UploadPostTransformErrorEvent)] + end + end +end diff --git a/lib/imagekitio/models/update_file_request.rb b/lib/imagekitio/models/update_file_request.rb new file mode 100644 index 00000000..1e030a07 --- /dev/null +++ b/lib/imagekitio/models/update_file_request.rb @@ -0,0 +1,164 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # Schema for update file update request. + module UpdateFileRequest + extend Imagekitio::Internal::Type::Union + + variant -> { Imagekitio::UpdateFileRequest::UpdateFileDetails } + + variant -> { Imagekitio::UpdateFileRequest::ChangePublicationStatus } + + class UpdateFileDetails < Imagekitio::Internal::Type::BaseModel + # @!attribute custom_coordinates + # 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. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # 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. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. + # + # @return [String, nil] + optional :description, String + + # @!attribute extensions + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + # + # @return [Array, nil] + optional :extensions, -> { Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::ExtensionItem] } + + # @!attribute remove_ai_tags + # 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. + # + # @return [Array, Symbol, :all, nil] + optional :remove_ai_tags, + union: -> { Imagekitio::UpdateFileRequest::UpdateFileDetails::RemoveAITags }, + api_name: :removeAITags + + # @!attribute tags + # An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + # `null` to unset all tags associated with the file. + # + # @return [Array, nil] + optional :tags, Imagekitio::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute webhook_url + # 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. + # + # @return [String, nil] + optional :webhook_url, String, api_name: :webhookUrl + + # @!method initialize(custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, remove_ai_tags: nil, tags: nil, webhook_url: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::UpdateFileRequest::UpdateFileDetails} for more details. + # + # @param custom_coordinates [String, nil] Define an important area in the image in the format `x,y,width,height` e.g. `10, + # + # @param custom_metadata [Hash{Symbol=>Object}] A key-value data to be associated with the asset. To unset a key, send `null` va + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param remove_ai_tags [Array, Symbol, :all] An array of AITags associated with the file that you want to remove, e.g. `["car + # + # @param tags [Array, nil] An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `nul + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + + # 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. + # + # @see Imagekitio::Models::UpdateFileRequest::UpdateFileDetails#remove_ai_tags + module RemoveAITags + extend Imagekitio::Internal::Type::Union + + variant -> { Imagekitio::Models::UpdateFileRequest::UpdateFileDetails::RemoveAITags::StringArray } + + variant const: :all + + # @!method self.variants + # @return [Array(Array, Symbol, :all)] + + # @type [Imagekitio::Internal::Type::Converter] + StringArray = Imagekitio::Internal::Type::ArrayOf[String] + end + end + + class ChangePublicationStatus < Imagekitio::Internal::Type::BaseModel + # @!attribute publish + # Configure the publication status of a file and its versions. + # + # @return [Imagekitio::Models::UpdateFileRequest::ChangePublicationStatus::Publish, nil] + optional :publish, -> { Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish } + + # @!method initialize(publish: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::UpdateFileRequest::ChangePublicationStatus} for more + # details. + # + # @param publish [Imagekitio::Models::UpdateFileRequest::ChangePublicationStatus::Publish] Configure the publication status of a file and its versions. + + # @see Imagekitio::Models::UpdateFileRequest::ChangePublicationStatus#publish + class Publish < Imagekitio::Internal::Type::BaseModel + # @!attribute is_published + # Set to `true` to publish the file. Set to `false` to unpublish the file. + # + # @return [Boolean] + required :is_published, Imagekitio::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute include_file_versions + # Set to `true` to publish/unpublish all versions of the file. Set to `false` to + # publish/unpublish only the current version of the file. + # + # @return [Boolean, nil] + optional :include_file_versions, Imagekitio::Internal::Type::Boolean, api_name: :includeFileVersions + + # @!method initialize(is_published:, include_file_versions: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::UpdateFileRequest::ChangePublicationStatus::Publish} for + # more details. + # + # Configure the publication status of a file and its versions. + # + # @param is_published [Boolean] Set to `true` to publish the file. Set to `false` to unpublish the file. + # + # @param include_file_versions [Boolean] Set to `true` to publish/unpublish all versions of the file. Set to `false` to p + end + end + + # @!method self.variants + # @return [Array(Imagekitio::Models::UpdateFileRequest::UpdateFileDetails, Imagekitio::Models::UpdateFileRequest::ChangePublicationStatus)] + end + end +end diff --git a/lib/imagekitio/models/upload_post_transform_error_event.rb b/lib/imagekitio/models/upload_post_transform_error_event.rb new file mode 100644 index 00000000..aa5ce37d --- /dev/null +++ b/lib/imagekitio/models/upload_post_transform_error_event.rb @@ -0,0 +1,180 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class UploadPostTransformErrorEvent < Imagekitio::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp of when the event occurred in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekitio::Models::UploadPostTransformErrorEvent::Data] + required :data, -> { Imagekitio::UploadPostTransformErrorEvent::Data } + + # @!attribute request + # + # @return [Imagekitio::Models::UploadPostTransformErrorEvent::Request] + required :request, -> { Imagekitio::UploadPostTransformErrorEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"upload.post-transform.error"] + required :type, const: :"upload.post-transform.error" + + # @!method initialize(created_at:, data:, request:, type: :"upload.post-transform.error") + # Triggered when a post-transformation fails. The original file remains available, + # but the requested transformation could not be generated. + # + # @param created_at [Time] Timestamp of when the event occurred in ISO8601 format. + # + # @param data [Imagekitio::Models::UploadPostTransformErrorEvent::Data] + # + # @param request [Imagekitio::Models::UploadPostTransformErrorEvent::Request] + # + # @param type [Symbol, :"upload.post-transform.error"] + + class Data < Imagekitio::Internal::Type::BaseModel + # @!attribute file_id + # Unique identifier of the originally uploaded file. + # + # @return [String] + required :file_id, String, api_name: :fileId + + # @!attribute name + # Name of the file. + # + # @return [String] + required :name, String + + # @!attribute path + # Path of the file. + # + # @return [String] + required :path, String + + # @!attribute transformation + # + # @return [Imagekitio::Models::UploadPostTransformErrorEvent::Data::Transformation] + required :transformation, -> { Imagekitio::UploadPostTransformErrorEvent::Data::Transformation } + + # @!attribute url + # URL of the attempted post-transformation. + # + # @return [String] + required :url, String + + # @!method initialize(file_id:, name:, path:, transformation:, url:) + # @param file_id [String] Unique identifier of the originally uploaded file. + # + # @param name [String] Name of the file. + # + # @param path [String] Path of the file. + # + # @param transformation [Imagekitio::Models::UploadPostTransformErrorEvent::Data::Transformation] + # + # @param url [String] URL of the attempted post-transformation. + + # @see Imagekitio::Models::UploadPostTransformErrorEvent::Data#transformation + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute error + # + # @return [Imagekitio::Models::UploadPostTransformErrorEvent::Data::Transformation::Error] + required :error, -> { Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error } + + # @!method initialize(error:) + # @param error [Imagekitio::Models::UploadPostTransformErrorEvent::Data::Transformation::Error] + + # @see Imagekitio::Models::UploadPostTransformErrorEvent::Data::Transformation#error + class Error < Imagekitio::Internal::Type::BaseModel + # @!attribute reason + # Reason for the post-transformation failure. + # + # @return [String] + required :reason, String + + # @!method initialize(reason:) + # @param reason [String] Reason for the post-transformation failure. + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + # @!attribute transformation + # + # @return [Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation] + required :transformation, -> { Imagekitio::UploadPostTransformErrorEvent::Request::Transformation } + + # @!attribute x_request_id + # Unique identifier for the originating request. + # + # @return [String] + required :x_request_id, String + + # @!method initialize(transformation:, x_request_id:) + # @param transformation [Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation] + # + # @param x_request_id [String] Unique identifier for the originating request. + + # @see Imagekitio::Models::UploadPostTransformErrorEvent::Request#transformation + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Type of the requested post-transformation. + # + # @return [Symbol, Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::Type] + required :type, enum: -> { Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type } + + # @!attribute protocol + # Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @return [Symbol, Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::Protocol, nil] + optional :protocol, + enum: -> { Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Protocol } + + # @!attribute value + # Value for the requested transformation type. + # + # @return [String, nil] + optional :value, String + + # @!method initialize(type:, protocol: nil, value: nil) + # @param type [Symbol, Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::Type] Type of the requested post-transformation. + # + # @param protocol [Symbol, Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::Protocol] Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @param value [String] Value for the requested transformation type. + + # Type of the requested post-transformation. + # + # @see Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation#type + module Type + extend Imagekitio::Internal::Type::Enum + + TRANSFORMATION = :transformation + ABS = :abs + GIF_TO_VIDEO = :"gif-to-video" + THUMBNAIL = :thumbnail + + # @!method self.values + # @return [Array] + end + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @see Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation#protocol + module Protocol + extend Imagekitio::Internal::Type::Enum + + HLS = :hls + DASH = :dash + + # @!method self.values + # @return [Array] + end + end + end + end + end +end diff --git a/lib/imagekitio/models/upload_post_transform_success_event.rb b/lib/imagekitio/models/upload_post_transform_success_event.rb new file mode 100644 index 00000000..98e85a19 --- /dev/null +++ b/lib/imagekitio/models/upload_post_transform_success_event.rb @@ -0,0 +1,143 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class UploadPostTransformSuccessEvent < Imagekitio::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp of when the event occurred in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekitio::Models::UploadPostTransformSuccessEvent::Data] + required :data, -> { Imagekitio::UploadPostTransformSuccessEvent::Data } + + # @!attribute request + # + # @return [Imagekitio::Models::UploadPostTransformSuccessEvent::Request] + required :request, -> { Imagekitio::UploadPostTransformSuccessEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"upload.post-transform.success"] + required :type, const: :"upload.post-transform.success" + + # @!method initialize(created_at:, data:, request:, type: :"upload.post-transform.success") + # Triggered when a post-transformation completes successfully. The transformed + # version of the file is now ready and can be accessed via the provided URL. Note + # that each post-transformation generates a separate webhook event. + # + # @param created_at [Time] Timestamp of when the event occurred in ISO8601 format. + # + # @param data [Imagekitio::Models::UploadPostTransformSuccessEvent::Data] + # + # @param request [Imagekitio::Models::UploadPostTransformSuccessEvent::Request] + # + # @param type [Symbol, :"upload.post-transform.success"] + + class Data < Imagekitio::Internal::Type::BaseModel + # @!attribute file_id + # Unique identifier of the originally uploaded file. + # + # @return [String] + required :file_id, String, api_name: :fileId + + # @!attribute name + # Name of the file. + # + # @return [String] + required :name, String + + # @!attribute url + # URL of the generated post-transformation. + # + # @return [String] + required :url, String + + # @!method initialize(file_id:, name:, url:) + # @param file_id [String] Unique identifier of the originally uploaded file. + # + # @param name [String] Name of the file. + # + # @param url [String] URL of the generated post-transformation. + end + + class Request < Imagekitio::Internal::Type::BaseModel + # @!attribute transformation + # + # @return [Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation] + required :transformation, -> { Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation } + + # @!attribute x_request_id + # Unique identifier for the originating request. + # + # @return [String] + required :x_request_id, String + + # @!method initialize(transformation:, x_request_id:) + # @param transformation [Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation] + # + # @param x_request_id [String] Unique identifier for the originating request. + + # @see Imagekitio::Models::UploadPostTransformSuccessEvent::Request#transformation + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Type of the requested post-transformation. + # + # @return [Symbol, Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::Type] + required :type, enum: -> { Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type } + + # @!attribute protocol + # Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @return [Symbol, Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::Protocol, nil] + optional :protocol, + enum: -> { Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Protocol } + + # @!attribute value + # Value for the requested transformation type. + # + # @return [String, nil] + optional :value, String + + # @!method initialize(type:, protocol: nil, value: nil) + # @param type [Symbol, Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::Type] Type of the requested post-transformation. + # + # @param protocol [Symbol, Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::Protocol] Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @param value [String] Value for the requested transformation type. + + # Type of the requested post-transformation. + # + # @see Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation#type + module Type + extend Imagekitio::Internal::Type::Enum + + TRANSFORMATION = :transformation + ABS = :abs + GIF_TO_VIDEO = :"gif-to-video" + THUMBNAIL = :thumbnail + + # @!method self.values + # @return [Array] + end + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + # + # @see Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation#protocol + module Protocol + extend Imagekitio::Internal::Type::Enum + + HLS = :hls + DASH = :dash + + # @!method self.values + # @return [Array] + end + end + end + end + end +end diff --git a/lib/imagekitio/models/upload_pre_transform_error_event.rb b/lib/imagekitio/models/upload_pre_transform_error_event.rb new file mode 100644 index 00000000..8585fb3c --- /dev/null +++ b/lib/imagekitio/models/upload_pre_transform_error_event.rb @@ -0,0 +1,108 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class UploadPreTransformErrorEvent < Imagekitio::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp of when the event occurred in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekitio::Models::UploadPreTransformErrorEvent::Data] + required :data, -> { Imagekitio::UploadPreTransformErrorEvent::Data } + + # @!attribute request + # + # @return [Imagekitio::Models::UploadPreTransformErrorEvent::Request] + required :request, -> { Imagekitio::UploadPreTransformErrorEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"upload.pre-transform.error"] + required :type, const: :"upload.pre-transform.error" + + # @!method initialize(created_at:, data:, request:, type: :"upload.pre-transform.error") + # Triggered when a pre-transformation fails. The file upload may have been + # accepted, but the requested transformation could not be applied. + # + # @param created_at [Time] Timestamp of when the event occurred in ISO8601 format. + # + # @param data [Imagekitio::Models::UploadPreTransformErrorEvent::Data] + # + # @param request [Imagekitio::Models::UploadPreTransformErrorEvent::Request] + # + # @param type [Symbol, :"upload.pre-transform.error"] + + class Data < Imagekitio::Internal::Type::BaseModel + # @!attribute name + # Name of the file. + # + # @return [String] + required :name, String + + # @!attribute path + # Path of the file. + # + # @return [String] + required :path, String + + # @!attribute transformation + # + # @return [Imagekitio::Models::UploadPreTransformErrorEvent::Data::Transformation] + required :transformation, -> { Imagekitio::UploadPreTransformErrorEvent::Data::Transformation } + + # @!method initialize(name:, path:, transformation:) + # @param name [String] Name of the file. + # + # @param path [String] Path of the file. + # + # @param transformation [Imagekitio::Models::UploadPreTransformErrorEvent::Data::Transformation] + + # @see Imagekitio::Models::UploadPreTransformErrorEvent::Data#transformation + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute error + # + # @return [Imagekitio::Models::UploadPreTransformErrorEvent::Data::Transformation::Error] + required :error, -> { Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error } + + # @!method initialize(error:) + # @param error [Imagekitio::Models::UploadPreTransformErrorEvent::Data::Transformation::Error] + + # @see Imagekitio::Models::UploadPreTransformErrorEvent::Data::Transformation#error + class Error < Imagekitio::Internal::Type::BaseModel + # @!attribute reason + # Reason for the pre-transformation failure. + # + # @return [String] + required :reason, String + + # @!method initialize(reason:) + # @param reason [String] Reason for the pre-transformation failure. + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + # @!attribute transformation + # The requested pre-transformation string. + # + # @return [String] + required :transformation, String + + # @!attribute x_request_id + # Unique identifier for the originating request. + # + # @return [String] + required :x_request_id, String + + # @!method initialize(transformation:, x_request_id:) + # @param transformation [String] The requested pre-transformation string. + # + # @param x_request_id [String] Unique identifier for the originating request. + end + end + end +end diff --git a/lib/imagekitio/models/upload_pre_transform_success_event.rb b/lib/imagekitio/models/upload_pre_transform_success_event.rb new file mode 100644 index 00000000..b2474269 --- /dev/null +++ b/lib/imagekitio/models/upload_pre_transform_success_event.rb @@ -0,0 +1,690 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class UploadPreTransformSuccessEvent < Imagekitio::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp of when the event occurred in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # Object containing details of a successful upload. + # + # @return [Imagekitio::Models::UploadPreTransformSuccessEvent::Data] + required :data, -> { Imagekitio::UploadPreTransformSuccessEvent::Data } + + # @!attribute request + # + # @return [Imagekitio::Models::UploadPreTransformSuccessEvent::Request] + required :request, -> { Imagekitio::UploadPreTransformSuccessEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"upload.pre-transform.success"] + required :type, const: :"upload.pre-transform.success" + + # @!method initialize(created_at:, data:, request:, type: :"upload.pre-transform.success") + # Triggered when a pre-transformation completes successfully. The file has been + # processed with the requested transformation and is now available in the Media + # Library. + # + # @param created_at [Time] Timestamp of when the event occurred in ISO8601 format. + # + # @param data [Imagekitio::Models::UploadPreTransformSuccessEvent::Data] Object containing details of a successful upload. + # + # @param request [Imagekitio::Models::UploadPreTransformSuccessEvent::Request] + # + # @param type [Symbol, :"upload.pre-transform.success"] + + class Data < Imagekitio::Internal::Type::BaseModel + # @!attribute ai_tags + # An array of tags assigned to the uploaded file by auto tagging. + # + # @return [Array, nil] + optional :ai_tags, + -> { + Imagekitio::Internal::Type::ArrayOf[Imagekitio::UploadPreTransformSuccessEvent::Data::AITag] + }, + api_name: :AITags, + nil?: true + + # @!attribute audio_codec + # The audio codec used in the video (only for video). + # + # @return [String, nil] + optional :audio_codec, String, api_name: :audioCodec + + # @!attribute bit_rate + # The bit rate of the video in kbps (only for video). + # + # @return [Integer, nil] + optional :bit_rate, Integer, api_name: :bitRate + + # @!attribute custom_coordinates + # 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. + # + # @return [String, nil] + optional :custom_coordinates, String, api_name: :customCoordinates, nil?: true + + # @!attribute custom_metadata + # 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. + # + # @return [Hash{Symbol=>Object}, nil] + optional :custom_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :customMetadata + + # @!attribute description + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + # + # @return [String, nil] + optional :description, String + + # @!attribute duration + # The duration of the video in seconds (only for video). + # + # @return [Integer, nil] + optional :duration, Integer + + # @!attribute embedded_metadata + # 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. + # + # @return [Hash{Symbol=>Object}, nil] + optional :embedded_metadata, + Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown], + api_name: :embeddedMetadata + + # @!attribute extension_status + # 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. + # + # @return [Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus, nil] + optional :extension_status, + -> { Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus }, + api_name: :extensionStatus + + # @!attribute file_id + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + # + # @return [String, nil] + optional :file_id, String, api_name: :fileId + + # @!attribute file_path + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + # + # @return [String, nil] + optional :file_path, String, api_name: :filePath + + # @!attribute file_type + # Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @return [String, nil] + optional :file_type, String, api_name: :fileType + + # @!attribute height + # Height of the image in pixels (Only for images) + # + # @return [Float, nil] + optional :height, Float + + # @!attribute is_private_file + # 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. + # + # @return [Boolean, nil] + optional :is_private_file, Imagekitio::Internal::Type::Boolean, api_name: :isPrivateFile + + # @!attribute is_published + # 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. + # + # @return [Boolean, nil] + optional :is_published, Imagekitio::Internal::Type::Boolean, api_name: :isPublished + + # @!attribute metadata + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + # + # @return [Imagekitio::Models::Metadata, nil] + optional :metadata, -> { Imagekitio::Metadata } + + # @!attribute name + # Name of the asset. + # + # @return [String, nil] + optional :name, String + + # @!attribute selected_fields_schema + # 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. + # + # @return [Hash{Symbol=>Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema}, nil] + optional :selected_fields_schema, + -> { + Imagekitio::Internal::Type::HashOf[Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema] + }, + api_name: :selectedFieldsSchema + + # @!attribute size + # Size of the image file in Bytes. + # + # @return [Float, nil] + optional :size, Float + + # @!attribute tags + # 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. + # + # @return [Array, nil] + optional :tags, Imagekitio::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute thumbnail_url + # In the case of an image, a small thumbnail URL. + # + # @return [String, nil] + optional :thumbnail_url, String, api_name: :thumbnailUrl + + # @!attribute url + # A publicly accessible URL of the file. + # + # @return [String, nil] + optional :url, String + + # @!attribute version_info + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @return [Imagekitio::Models::UploadPreTransformSuccessEvent::Data::VersionInfo, nil] + optional :version_info, + -> { Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo }, + api_name: :versionInfo + + # @!attribute video_codec + # The video codec used in the video (only for video). + # + # @return [String, nil] + optional :video_codec, String, api_name: :videoCodec + + # @!attribute width + # Width of the image in pixels (Only for Images) + # + # @return [Float, nil] + optional :width, Float + + # @!method initialize(ai_tags: nil, audio_codec: nil, bit_rate: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, duration: nil, embedded_metadata: nil, extension_status: nil, file_id: nil, file_path: nil, file_type: nil, height: nil, is_private_file: nil, is_published: nil, metadata: nil, name: nil, selected_fields_schema: nil, size: nil, tags: nil, thumbnail_url: nil, url: nil, version_info: nil, video_codec: nil, width: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::UploadPreTransformSuccessEvent::Data} for more details. + # + # Object containing details of a successful upload. + # + # @param ai_tags [Array, nil] An array of tags assigned to the uploaded file by auto tagging. + # + # @param audio_codec [String] The audio codec used in the video (only for video). + # + # @param bit_rate [Integer] The bit rate of the video in kbps (only for video). + # + # @param custom_coordinates [String, nil] Value of custom coordinates associated with the image in the format `x,y,width,h + # + # @param custom_metadata [Hash{Symbol=>Object}] A key-value data associated with the asset. Use `responseField` in API request t + # + # @param description [String] Optional text to describe the contents of the file. Can be set by the user or th + # + # @param duration [Integer] The duration of the video in seconds (only for video). + # + # @param embedded_metadata [Hash{Symbol=>Object}] Consolidated embedded metadata associated with the file. It includes exif, iptc, + # + # @param extension_status [Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus] Extension names with their processing status at the time of completion of the re + # + # @param file_id [String] Unique fileId. Store this fileld in your database, as this will be used to perfo + # + # @param file_path [String] The relative path of the file in the media library e.g. `/marketing-assets/new-b + # + # @param file_type [String] Type of the uploaded file. Possible values are `image`, `non-image`. + # + # @param height [Float] Height of the image in pixels (Only for images) + # + # @param is_private_file [Boolean] Is the file marked as private. It can be either `true` or `false`. Send `isPriva + # + # @param is_published [Boolean] Is the file published or in draft state. It can be either `true` or `false`. Sen + # + # @param metadata [Imagekitio::Models::Metadata] Legacy metadata. Send `metadata` in `responseFields` in API request to get metad + # + # @param name [String] Name of the asset. + # + # @param selected_fields_schema [Hash{Symbol=>Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema}] This field is included in the response only if the Path policy feature is availa + # + # @param size [Float] Size of the image file in Bytes. + # + # @param tags [Array, nil] The array of tags associated with the asset. If no tags are set, it will be `nul + # + # @param thumbnail_url [String] In the case of an image, a small thumbnail URL. + # + # @param url [String] A publicly accessible URL of the file. + # + # @param version_info [Imagekitio::Models::UploadPreTransformSuccessEvent::Data::VersionInfo] An object containing the file or file version's `id` (versionId) and `name`. + # + # @param video_codec [String] The video codec used in the video (only for video). + # + # @param width [Float] Width of the image in pixels (Only for Images) + + class AITag < Imagekitio::Internal::Type::BaseModel + # @!attribute confidence + # Confidence score of the tag. + # + # @return [Float, nil] + optional :confidence, Float + + # @!attribute name + # Name of the tag. + # + # @return [String, nil] + optional :name, String + + # @!attribute source + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + # + # @return [String, nil] + optional :source, String + + # @!method initialize(confidence: nil, name: nil, source: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::UploadPreTransformSuccessEvent::Data::AITag} for more + # details. + # + # @param confidence [Float] Confidence score of the tag. + # + # @param name [String] Name of the tag. + # + # @param source [String] Array of `AITags` associated with the image. If no `AITags` are set, it will be + end + + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data#extension_status + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + # @!attribute ai_auto_description + # + # @return [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription, nil] + optional :ai_auto_description, + enum: -> { + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription + }, + api_name: :"ai-auto-description" + + # @!attribute aws_auto_tagging + # + # @return [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging, nil] + optional :aws_auto_tagging, + enum: -> { + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging + }, + api_name: :"aws-auto-tagging" + + # @!attribute google_auto_tagging + # + # @return [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging, nil] + optional :google_auto_tagging, + enum: -> { + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging + }, + api_name: :"google-auto-tagging" + + # @!attribute remove_bg + # + # @return [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg, nil] + optional :remove_bg, + enum: -> { Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg }, + api_name: :"remove-bg" + + # @!method initialize(ai_auto_description: nil, aws_auto_tagging: nil, google_auto_tagging: nil, remove_bg: nil) + # 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 ai_auto_description [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription] + # @param aws_auto_tagging [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging] + # @param google_auto_tagging [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging] + # @param remove_bg [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg] + + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus#ai_auto_description + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus#aws_auto_tagging + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus#google_auto_tagging + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus#remove_bg + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + SUCCESS = :success + PENDING = :pending + FAILED = :failed + + # @!method self.values + # @return [Array] + end + end + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # Type of the custom metadata field. + # + # @return [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type] + required :type, enum: -> { Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type } + + # @!attribute default_value + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + # + # @return [String, Float, Boolean, Array, nil] + optional :default_value, + union: -> { + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue + }, + api_name: :defaultValue + + # @!attribute is_value_required + # Specifies if the custom metadata field is required or not. + # + # @return [Boolean, nil] + optional :is_value_required, Imagekitio::Internal::Type::Boolean, api_name: :isValueRequired + + # @!attribute max_length + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :max_length, Float, api_name: :maxLength + + # @!attribute max_value + # 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. + # + # @return [String, Float, nil] + optional :max_value, + union: -> { + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MaxValue + }, + api_name: :maxValue + + # @!attribute min_length + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @return [Float, nil] + optional :min_length, Float, api_name: :minLength + + # @!attribute min_value + # 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. + # + # @return [String, Float, nil] + optional :min_value, + union: -> { + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MinValue + }, + api_name: :minValue + + # @!attribute read_only + # 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. + # + # @return [Boolean, nil] + optional :read_only, Imagekitio::Internal::Type::Boolean, api_name: :readOnly + + # @!attribute select_options + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @return [Array, nil] + optional :select_options, + -> { + Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::SelectOption] + }, + api_name: :selectOptions + + # @!attribute select_options_truncated + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + # + # @return [Boolean, nil] + optional :select_options_truncated, + Imagekitio::Internal::Type::Boolean, + api_name: :selectOptionsTruncated + + # @!method initialize(type:, default_value: nil, is_value_required: nil, max_length: nil, max_value: nil, min_length: nil, min_value: nil, read_only: nil, select_options: nil, select_options_truncated: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema} + # for more details. + # + # @param type [Symbol, Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type] Type of the custom metadata field. + # + # @param default_value [String, Float, Boolean, Array] The default value for this custom metadata field. The value should match the `ty + # + # @param is_value_required [Boolean] Specifies if the custom metadata field is required or not. + # + # @param max_length [Float] Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param max_value [String, Float] Maximum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param min_length [Float] Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + # + # @param min_value [String, Float] Minimum value of the field. Only set if field type is `Date` or `Number`. For `D + # + # @param read_only [Boolean] Indicates whether the custom metadata field is read only. A read only field cann + # + # @param select_options [Array] An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + # + # @param select_options_truncated [Boolean] Specifies if the selectOptions array is truncated. It is truncated when number o + + # Type of the custom metadata field. + # + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema#type + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT = :Text + TEXTAREA = :Textarea + NUMBER = :Number + DATE = :Date + BOOLEAN = :Boolean + SINGLE_SELECT = :SingleSelect + MULTI_SELECT = :MultiSelect + + # @!method self.values + # @return [Array] + end + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + # + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema#default_value + module DefaultValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # Default value should be of type array when custom metadata field type is set to `MultiSelect`. + variant -> { Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::MixedArray } + + module Mixed + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + + # @!method self.variants + # @return [Array(String, Float, Boolean, Array)] + + # @type [Imagekitio::Internal::Type::Converter] + MixedArray = + Imagekitio::Internal::Type::ArrayOf[union: -> { + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::Mixed + }] + end + + # 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. + # + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema#max_value + module MaxValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + # 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. + # + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema#min_value + module MinValue + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + # @!method self.variants + # @return [Array(String, Float)] + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + variant String + + variant Float + + variant Imagekitio::Internal::Type::Boolean + + # @!method self.variants + # @return [Array(String, Float, Boolean)] + end + end + + # @see Imagekitio::Models::UploadPreTransformSuccessEvent::Data#version_info + class VersionInfo < Imagekitio::Internal::Type::BaseModel + # @!attribute id + # Unique identifier of the file version. + # + # @return [String, nil] + optional :id, String + + # @!attribute name + # Name of the file version. + # + # @return [String, nil] + optional :name, String + + # @!method initialize(id: nil, name: nil) + # An object containing the file or file version's `id` (versionId) and `name`. + # + # @param id [String] Unique identifier of the file version. + # + # @param name [String] Name of the file version. + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + # @!attribute transformation + # The requested pre-transformation string. + # + # @return [String] + required :transformation, String + + # @!attribute x_request_id + # Unique identifier for the originating request. + # + # @return [String] + required :x_request_id, String + + # @!method initialize(transformation:, x_request_id:) + # @param transformation [String] The requested pre-transformation string. + # + # @param x_request_id [String] Unique identifier for the originating request. + end + end + end +end diff --git a/lib/imagekitio/models/video_overlay.rb b/lib/imagekitio/models/video_overlay.rb new file mode 100644 index 00000000..ef765102 --- /dev/null +++ b/lib/imagekitio/models/video_overlay.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class VideoOverlay < Imagekitio::Models::BaseOverlay + # @!attribute input + # Specifies the relative path to the video used as an overlay. + # + # @return [String] + required :input, String + + # @!attribute type + # + # @return [Symbol, :video] + required :type, const: :video + + # @!attribute encoding + # 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`. + # + # @return [Symbol, Imagekitio::Models::VideoOverlay::Encoding, nil] + optional :encoding, enum: -> { Imagekitio::VideoOverlay::Encoding } + + # @!attribute transformation + # 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). + # + # @return [Array, nil] + optional :transformation, -> { Imagekitio::Internal::Type::ArrayOf[Imagekitio::Transformation] } + + # @!method initialize(input:, encoding: nil, transformation: nil, type: :video) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::VideoOverlay} for more details. + # + # @param input [String] Specifies the relative path to the video used as an overlay. + # + # @param encoding [Symbol, Imagekitio::Models::VideoOverlay::Encoding] The input path can be included in the layer as either `i-{input}` or `ie-{base64 + # + # @param transformation [Array] Array of transformation to be applied to the overlay video. Except `streamingRes + # + # @param type [Symbol, :video] + + # 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`. + module Encoding + extend Imagekitio::Internal::Type::Enum + + AUTO = :auto + PLAIN = :plain + BASE64 = :base64 + + # @!method self.values + # @return [Array] + end + end + end +end diff --git a/lib/imagekitio/models/video_transformation_accepted_event.rb b/lib/imagekitio/models/video_transformation_accepted_event.rb new file mode 100644 index 00000000..9cd25cae --- /dev/null +++ b/lib/imagekitio/models/video_transformation_accepted_event.rb @@ -0,0 +1,279 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class VideoTransformationAcceptedEvent < Imagekitio::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp when the event was created in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekitio::Models::VideoTransformationAcceptedEvent::Data] + required :data, -> { Imagekitio::VideoTransformationAcceptedEvent::Data } + + # @!attribute request + # Information about the original request that triggered the video transformation. + # + # @return [Imagekitio::Models::VideoTransformationAcceptedEvent::Request] + required :request, -> { Imagekitio::VideoTransformationAcceptedEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"video.transformation.accepted"] + required :type, const: :"video.transformation.accepted" + + # @!method initialize(created_at:, data:, request:, type: :"video.transformation.accepted") + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + # + # @param created_at [Time] Timestamp when the event was created in ISO8601 format. + # + # @param data [Imagekitio::Models::VideoTransformationAcceptedEvent::Data] + # + # @param request [Imagekitio::Models::VideoTransformationAcceptedEvent::Request] Information about the original request that triggered the video transformation. + # + # @param type [Symbol, :"video.transformation.accepted"] + + class Data < Imagekitio::Internal::Type::BaseModel + # @!attribute asset + # Information about the source video asset being transformed. + # + # @return [Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Asset] + required :asset, -> { Imagekitio::VideoTransformationAcceptedEvent::Data::Asset } + + # @!attribute transformation + # Base information about a video transformation request. + # + # @return [Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation] + required :transformation, -> { Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation } + + # @!method initialize(asset:, transformation:) + # @param asset [Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Asset] Information about the source video asset being transformed. + # + # @param transformation [Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation] Base information about a video transformation request. + + # @see Imagekitio::Models::VideoTransformationAcceptedEvent::Data#asset + class Asset < Imagekitio::Internal::Type::BaseModel + # @!attribute url + # URL to download or access the source video file. + # + # @return [String] + required :url, String + + # @!method initialize(url:) + # Information about the source video asset being transformed. + # + # @param url [String] URL to download or access the source video file. + end + + # @see Imagekitio::Models::VideoTransformationAcceptedEvent::Data#transformation + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # 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 + # + # @return [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Type] + required :type, enum: -> { Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Type } + + # @!attribute options + # Configuration options for video transformations. + # + # @return [Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options, nil] + optional :options, -> { Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options } + + # @!method initialize(type:, options: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation} for + # more details. + # + # Base information about a video transformation request. + # + # @param type [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Type] Type of video transformation: + # + # @param options [Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options] Configuration options for video transformations. + + # 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 + # + # @see Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation#type + module Type + extend Imagekitio::Internal::Type::Enum + + VIDEO_TRANSFORMATION = :"video-transformation" + GIF_TO_VIDEO = :"gif-to-video" + VIDEO_THUMBNAIL = :"video-thumbnail" + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation#options + class Options < Imagekitio::Internal::Type::BaseModel + # @!attribute audio_codec + # Audio codec used for encoding (aac or opus). + # + # @return [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec, nil] + optional :audio_codec, + enum: -> { Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec } + + # @!attribute auto_rotate + # Whether to automatically rotate the video based on metadata. + # + # @return [Boolean, nil] + optional :auto_rotate, Imagekitio::Internal::Type::Boolean + + # @!attribute format_ + # Output format for the transformed video or thumbnail. + # + # @return [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format, nil] + optional :format_, + enum: -> { + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format + }, + api_name: :format + + # @!attribute quality + # Quality setting for the output video. + # + # @return [Integer, nil] + optional :quality, Integer + + # @!attribute stream_protocol + # Streaming protocol for adaptive bitrate streaming. + # + # @return [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol, nil] + optional :stream_protocol, + enum: -> { Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol } + + # @!attribute variants + # Array of quality representations for adaptive bitrate streaming. + # + # @return [Array, nil] + optional :variants, Imagekitio::Internal::Type::ArrayOf[String] + + # @!attribute video_codec + # Video codec used for encoding (h264, vp9, or av1). + # + # @return [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec, nil] + optional :video_codec, + enum: -> { Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec } + + # @!method initialize(audio_codec: nil, auto_rotate: nil, format_: nil, quality: nil, stream_protocol: nil, variants: nil, video_codec: nil) + # Configuration options for video transformations. + # + # @param audio_codec [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec] Audio codec used for encoding (aac or opus). + # + # @param auto_rotate [Boolean] Whether to automatically rotate the video based on metadata. + # + # @param format_ [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format] Output format for the transformed video or thumbnail. + # + # @param quality [Integer] Quality setting for the output video. + # + # @param stream_protocol [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol] Streaming protocol for adaptive bitrate streaming. + # + # @param variants [Array] Array of quality representations for adaptive bitrate streaming. + # + # @param video_codec [Symbol, Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec] Video codec used for encoding (h264, vp9, or av1). + + # Audio codec used for encoding (aac or opus). + # + # @see Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options#audio_codec + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + AAC = :aac + OPUS = :opus + + # @!method self.values + # @return [Array] + end + + # Output format for the transformed video or thumbnail. + # + # @see Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options#format_ + module Format + extend Imagekitio::Internal::Type::Enum + + MP4 = :mp4 + WEBM = :webm + JPG = :jpg + PNG = :png + WEBP = :webp + + # @!method self.values + # @return [Array] + end + + # Streaming protocol for adaptive bitrate streaming. + # + # @see Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options#stream_protocol + module StreamProtocol + extend Imagekitio::Internal::Type::Enum + + HLS = :HLS + DASH = :DASH + + # @!method self.values + # @return [Array] + end + + # Video codec used for encoding (h264, vp9, or av1). + # + # @see Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options#video_codec + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + H264 = :h264 + VP9 = :vp9 + AV1 = :av1 + + # @!method self.values + # @return [Array] + end + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + # @!attribute url + # Full URL of the transformation request that was submitted. + # + # @return [String] + required :url, String + + # @!attribute x_request_id + # Unique identifier for the originating transformation request. + # + # @return [String] + required :x_request_id, String + + # @!attribute user_agent + # User-Agent header from the original request that triggered the transformation. + # + # @return [String, nil] + optional :user_agent, String + + # @!method initialize(url:, x_request_id:, user_agent: nil) + # Information about the original request that triggered the video transformation. + # + # @param url [String] Full URL of the transformation request that was submitted. + # + # @param x_request_id [String] Unique identifier for the originating transformation request. + # + # @param user_agent [String] User-Agent header from the original request that triggered the transformation. + end + end + end +end diff --git a/lib/imagekitio/models/video_transformation_error_event.rb b/lib/imagekitio/models/video_transformation_error_event.rb new file mode 100644 index 00000000..4d740ef5 --- /dev/null +++ b/lib/imagekitio/models/video_transformation_error_event.rb @@ -0,0 +1,326 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class VideoTransformationErrorEvent < Imagekitio::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp when the event was created in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekitio::Models::VideoTransformationErrorEvent::Data] + required :data, -> { Imagekitio::VideoTransformationErrorEvent::Data } + + # @!attribute request + # Information about the original request that triggered the video transformation. + # + # @return [Imagekitio::Models::VideoTransformationErrorEvent::Request] + required :request, -> { Imagekitio::VideoTransformationErrorEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"video.transformation.error"] + required :type, const: :"video.transformation.error" + + # @!method initialize(created_at:, data:, request:, type: :"video.transformation.error") + # Triggered when an error occurs during video encoding. Listen to this webhook to + # log error reasons and debug issues. Check your origin and URL endpoint settings + # if the reason is related to download failure. For other errors, contact ImageKit + # support. + # + # @param created_at [Time] Timestamp when the event was created in ISO8601 format. + # + # @param data [Imagekitio::Models::VideoTransformationErrorEvent::Data] + # + # @param request [Imagekitio::Models::VideoTransformationErrorEvent::Request] Information about the original request that triggered the video transformation. + # + # @param type [Symbol, :"video.transformation.error"] + + class Data < Imagekitio::Internal::Type::BaseModel + # @!attribute asset + # Information about the source video asset being transformed. + # + # @return [Imagekitio::Models::VideoTransformationErrorEvent::Data::Asset] + required :asset, -> { Imagekitio::VideoTransformationErrorEvent::Data::Asset } + + # @!attribute transformation + # + # @return [Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation] + required :transformation, -> { Imagekitio::VideoTransformationErrorEvent::Data::Transformation } + + # @!method initialize(asset:, transformation:) + # @param asset [Imagekitio::Models::VideoTransformationErrorEvent::Data::Asset] Information about the source video asset being transformed. + # + # @param transformation [Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation] + + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data#asset + class Asset < Imagekitio::Internal::Type::BaseModel + # @!attribute url + # URL to download or access the source video file. + # + # @return [String] + required :url, String + + # @!method initialize(url:) + # Information about the source video asset being transformed. + # + # @param url [String] URL to download or access the source video file. + end + + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data#transformation + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # 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 + # + # @return [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Type] + required :type, enum: -> { Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Type } + + # @!attribute error + # Details about the transformation error. + # + # @return [Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error, nil] + optional :error, -> { Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error } + + # @!attribute options + # Configuration options for video transformations. + # + # @return [Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options, nil] + optional :options, -> { Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options } + + # @!method initialize(type:, error: nil, options: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation} for + # more details. + # + # @param type [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Type] Type of video transformation: + # + # @param error [Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error] Details about the transformation error. + # + # @param options [Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options] Configuration options for video transformations. + + # 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 + # + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation#type + module Type + extend Imagekitio::Internal::Type::Enum + + VIDEO_TRANSFORMATION = :"video-transformation" + GIF_TO_VIDEO = :"gif-to-video" + VIDEO_THUMBNAIL = :"video-thumbnail" + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation#error + class Error < Imagekitio::Internal::Type::BaseModel + # @!attribute reason + # 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 + # + # @return [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error::Reason] + required :reason, + enum: -> { Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::Reason } + + # @!method initialize(reason:) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error} + # for more details. + # + # Details about the transformation error. + # + # @param reason [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error::Reason] Specific reason for the transformation failure: + + # 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 + # + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error#reason + module Reason + extend Imagekitio::Internal::Type::Enum + + ENCODING_FAILED = :encoding_failed + DOWNLOAD_FAILED = :download_failed + INTERNAL_SERVER_ERROR = :internal_server_error + + # @!method self.values + # @return [Array] + end + end + + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation#options + class Options < Imagekitio::Internal::Type::BaseModel + # @!attribute audio_codec + # Audio codec used for encoding (aac or opus). + # + # @return [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec, nil] + optional :audio_codec, + enum: -> { Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec } + + # @!attribute auto_rotate + # Whether to automatically rotate the video based on metadata. + # + # @return [Boolean, nil] + optional :auto_rotate, Imagekitio::Internal::Type::Boolean + + # @!attribute format_ + # Output format for the transformed video or thumbnail. + # + # @return [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::Format, nil] + optional :format_, + enum: -> { + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format + }, + api_name: :format + + # @!attribute quality + # Quality setting for the output video. + # + # @return [Integer, nil] + optional :quality, Integer + + # @!attribute stream_protocol + # Streaming protocol for adaptive bitrate streaming. + # + # @return [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol, nil] + optional :stream_protocol, + enum: -> { Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol } + + # @!attribute variants + # Array of quality representations for adaptive bitrate streaming. + # + # @return [Array, nil] + optional :variants, Imagekitio::Internal::Type::ArrayOf[String] + + # @!attribute video_codec + # Video codec used for encoding (h264, vp9, or av1). + # + # @return [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec, nil] + optional :video_codec, + enum: -> { Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec } + + # @!method initialize(audio_codec: nil, auto_rotate: nil, format_: nil, quality: nil, stream_protocol: nil, variants: nil, video_codec: nil) + # Configuration options for video transformations. + # + # @param audio_codec [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec] Audio codec used for encoding (aac or opus). + # + # @param auto_rotate [Boolean] Whether to automatically rotate the video based on metadata. + # + # @param format_ [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::Format] Output format for the transformed video or thumbnail. + # + # @param quality [Integer] Quality setting for the output video. + # + # @param stream_protocol [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol] Streaming protocol for adaptive bitrate streaming. + # + # @param variants [Array] Array of quality representations for adaptive bitrate streaming. + # + # @param video_codec [Symbol, Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec] Video codec used for encoding (h264, vp9, or av1). + + # Audio codec used for encoding (aac or opus). + # + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options#audio_codec + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + AAC = :aac + OPUS = :opus + + # @!method self.values + # @return [Array] + end + + # Output format for the transformed video or thumbnail. + # + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options#format_ + module Format + extend Imagekitio::Internal::Type::Enum + + MP4 = :mp4 + WEBM = :webm + JPG = :jpg + PNG = :png + WEBP = :webp + + # @!method self.values + # @return [Array] + end + + # Streaming protocol for adaptive bitrate streaming. + # + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options#stream_protocol + module StreamProtocol + extend Imagekitio::Internal::Type::Enum + + HLS = :HLS + DASH = :DASH + + # @!method self.values + # @return [Array] + end + + # Video codec used for encoding (h264, vp9, or av1). + # + # @see Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options#video_codec + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + H264 = :h264 + VP9 = :vp9 + AV1 = :av1 + + # @!method self.values + # @return [Array] + end + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + # @!attribute url + # Full URL of the transformation request that was submitted. + # + # @return [String] + required :url, String + + # @!attribute x_request_id + # Unique identifier for the originating transformation request. + # + # @return [String] + required :x_request_id, String + + # @!attribute user_agent + # User-Agent header from the original request that triggered the transformation. + # + # @return [String, nil] + optional :user_agent, String + + # @!method initialize(url:, x_request_id:, user_agent: nil) + # Information about the original request that triggered the video transformation. + # + # @param url [String] Full URL of the transformation request that was submitted. + # + # @param x_request_id [String] Unique identifier for the originating transformation request. + # + # @param user_agent [String] User-Agent header from the original request that triggered the transformation. + end + end + end +end diff --git a/lib/imagekitio/models/video_transformation_ready_event.rb b/lib/imagekitio/models/video_transformation_ready_event.rb new file mode 100644 index 00000000..635dc13a --- /dev/null +++ b/lib/imagekitio/models/video_transformation_ready_event.rb @@ -0,0 +1,379 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + class VideoTransformationReadyEvent < Imagekitio::Models::BaseWebhookEvent + # @!attribute created_at + # Timestamp when the event was created in ISO8601 format. + # + # @return [Time] + required :created_at, Time + + # @!attribute data + # + # @return [Imagekitio::Models::VideoTransformationReadyEvent::Data] + required :data, -> { Imagekitio::VideoTransformationReadyEvent::Data } + + # @!attribute request + # Information about the original request that triggered the video transformation. + # + # @return [Imagekitio::Models::VideoTransformationReadyEvent::Request] + required :request, -> { Imagekitio::VideoTransformationReadyEvent::Request } + + # @!attribute type + # + # @return [Symbol, :"video.transformation.ready"] + required :type, const: :"video.transformation.ready" + + # @!attribute timings + # Performance metrics for the transformation process. + # + # @return [Imagekitio::Models::VideoTransformationReadyEvent::Timings, nil] + optional :timings, -> { Imagekitio::VideoTransformationReadyEvent::Timings } + + # @!method initialize(created_at:, data:, request:, timings: nil, type: :"video.transformation.ready") + # Triggered when video encoding is finished and the transformed resource is ready + # to be served. This is the key event to listen for - update your database or CMS + # flags when you receive this so your application can start showing the + # transformed video to users. + # + # @param created_at [Time] Timestamp when the event was created in ISO8601 format. + # + # @param data [Imagekitio::Models::VideoTransformationReadyEvent::Data] + # + # @param request [Imagekitio::Models::VideoTransformationReadyEvent::Request] Information about the original request that triggered the video transformation. + # + # @param timings [Imagekitio::Models::VideoTransformationReadyEvent::Timings] Performance metrics for the transformation process. + # + # @param type [Symbol, :"video.transformation.ready"] + + class Data < Imagekitio::Internal::Type::BaseModel + # @!attribute asset + # Information about the source video asset being transformed. + # + # @return [Imagekitio::Models::VideoTransformationReadyEvent::Data::Asset] + required :asset, -> { Imagekitio::VideoTransformationReadyEvent::Data::Asset } + + # @!attribute transformation + # + # @return [Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation] + required :transformation, -> { Imagekitio::VideoTransformationReadyEvent::Data::Transformation } + + # @!method initialize(asset:, transformation:) + # @param asset [Imagekitio::Models::VideoTransformationReadyEvent::Data::Asset] Information about the source video asset being transformed. + # + # @param transformation [Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation] + + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data#asset + class Asset < Imagekitio::Internal::Type::BaseModel + # @!attribute url + # URL to download or access the source video file. + # + # @return [String] + required :url, String + + # @!method initialize(url:) + # Information about the source video asset being transformed. + # + # @param url [String] URL to download or access the source video file. + end + + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data#transformation + class Transformation < Imagekitio::Internal::Type::BaseModel + # @!attribute type + # 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 + # + # @return [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Type] + required :type, enum: -> { Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Type } + + # @!attribute options + # Configuration options for video transformations. + # + # @return [Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options, nil] + optional :options, -> { Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options } + + # @!attribute output + # Information about the transformed output video. + # + # @return [Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Output, nil] + optional :output, -> { Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output } + + # @!method initialize(type:, options: nil, output: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation} for + # more details. + # + # @param type [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Type] Type of video transformation: + # + # @param options [Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options] Configuration options for video transformations. + # + # @param output [Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Output] Information about the transformed output video. + + # 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 + # + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation#type + module Type + extend Imagekitio::Internal::Type::Enum + + VIDEO_TRANSFORMATION = :"video-transformation" + GIF_TO_VIDEO = :"gif-to-video" + VIDEO_THUMBNAIL = :"video-thumbnail" + + # @!method self.values + # @return [Array] + end + + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation#options + class Options < Imagekitio::Internal::Type::BaseModel + # @!attribute audio_codec + # Audio codec used for encoding (aac or opus). + # + # @return [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec, nil] + optional :audio_codec, + enum: -> { Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec } + + # @!attribute auto_rotate + # Whether to automatically rotate the video based on metadata. + # + # @return [Boolean, nil] + optional :auto_rotate, Imagekitio::Internal::Type::Boolean + + # @!attribute format_ + # Output format for the transformed video or thumbnail. + # + # @return [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::Format, nil] + optional :format_, + enum: -> { + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format + }, + api_name: :format + + # @!attribute quality + # Quality setting for the output video. + # + # @return [Integer, nil] + optional :quality, Integer + + # @!attribute stream_protocol + # Streaming protocol for adaptive bitrate streaming. + # + # @return [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol, nil] + optional :stream_protocol, + enum: -> { Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol } + + # @!attribute variants + # Array of quality representations for adaptive bitrate streaming. + # + # @return [Array, nil] + optional :variants, Imagekitio::Internal::Type::ArrayOf[String] + + # @!attribute video_codec + # Video codec used for encoding (h264, vp9, or av1). + # + # @return [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec, nil] + optional :video_codec, + enum: -> { Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec } + + # @!method initialize(audio_codec: nil, auto_rotate: nil, format_: nil, quality: nil, stream_protocol: nil, variants: nil, video_codec: nil) + # Configuration options for video transformations. + # + # @param audio_codec [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec] Audio codec used for encoding (aac or opus). + # + # @param auto_rotate [Boolean] Whether to automatically rotate the video based on metadata. + # + # @param format_ [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::Format] Output format for the transformed video or thumbnail. + # + # @param quality [Integer] Quality setting for the output video. + # + # @param stream_protocol [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol] Streaming protocol for adaptive bitrate streaming. + # + # @param variants [Array] Array of quality representations for adaptive bitrate streaming. + # + # @param video_codec [Symbol, Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec] Video codec used for encoding (h264, vp9, or av1). + + # Audio codec used for encoding (aac or opus). + # + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options#audio_codec + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + AAC = :aac + OPUS = :opus + + # @!method self.values + # @return [Array] + end + + # Output format for the transformed video or thumbnail. + # + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options#format_ + module Format + extend Imagekitio::Internal::Type::Enum + + MP4 = :mp4 + WEBM = :webm + JPG = :jpg + PNG = :png + WEBP = :webp + + # @!method self.values + # @return [Array] + end + + # Streaming protocol for adaptive bitrate streaming. + # + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options#stream_protocol + module StreamProtocol + extend Imagekitio::Internal::Type::Enum + + HLS = :HLS + DASH = :DASH + + # @!method self.values + # @return [Array] + end + + # Video codec used for encoding (h264, vp9, or av1). + # + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options#video_codec + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + H264 = :h264 + VP9 = :vp9 + AV1 = :av1 + + # @!method self.values + # @return [Array] + end + end + + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation#output + class Output < Imagekitio::Internal::Type::BaseModel + # @!attribute url + # URL to access the transformed video. + # + # @return [String] + required :url, String + + # @!attribute video_metadata + # Metadata of the output video file. + # + # @return [Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata, nil] + optional :video_metadata, + -> { Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata } + + # @!method initialize(url:, video_metadata: nil) + # Information about the transformed output video. + # + # @param url [String] URL to access the transformed video. + # + # @param video_metadata [Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata] Metadata of the output video file. + + # @see Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Output#video_metadata + class VideoMetadata < Imagekitio::Internal::Type::BaseModel + # @!attribute bitrate + # Bitrate of the output video in bits per second. + # + # @return [Integer] + required :bitrate, Integer + + # @!attribute duration + # Duration of the output video in seconds. + # + # @return [Float] + required :duration, Float + + # @!attribute height + # Height of the output video in pixels. + # + # @return [Integer] + required :height, Integer + + # @!attribute width + # Width of the output video in pixels. + # + # @return [Integer] + required :width, Integer + + # @!method initialize(bitrate:, duration:, height:, width:) + # Metadata of the output video file. + # + # @param bitrate [Integer] Bitrate of the output video in bits per second. + # + # @param duration [Float] Duration of the output video in seconds. + # + # @param height [Integer] Height of the output video in pixels. + # + # @param width [Integer] Width of the output video in pixels. + end + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + # @!attribute url + # Full URL of the transformation request that was submitted. + # + # @return [String] + required :url, String + + # @!attribute x_request_id + # Unique identifier for the originating transformation request. + # + # @return [String] + required :x_request_id, String + + # @!attribute user_agent + # User-Agent header from the original request that triggered the transformation. + # + # @return [String, nil] + optional :user_agent, String + + # @!method initialize(url:, x_request_id:, user_agent: nil) + # Information about the original request that triggered the video transformation. + # + # @param url [String] Full URL of the transformation request that was submitted. + # + # @param x_request_id [String] Unique identifier for the originating transformation request. + # + # @param user_agent [String] User-Agent header from the original request that triggered the transformation. + end + + class Timings < Imagekitio::Internal::Type::BaseModel + # @!attribute download_duration + # Time spent downloading the source video from your origin or media library, in + # milliseconds. + # + # @return [Integer, nil] + optional :download_duration, Integer + + # @!attribute encoding_duration + # Time spent encoding the video, in milliseconds. + # + # @return [Integer, nil] + optional :encoding_duration, Integer + + # @!method initialize(download_duration: nil, encoding_duration: nil) + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::VideoTransformationReadyEvent::Timings} for more details. + # + # Performance metrics for the transformation process. + # + # @param download_duration [Integer] Time spent downloading the source video from your origin or media library, in mi + # + # @param encoding_duration [Integer] Time spent encoding the video, in milliseconds. + end + end + end +end diff --git a/lib/imagekitio/models/webhook_unsafe_unwrap_params.rb b/lib/imagekitio/models/webhook_unsafe_unwrap_params.rb new file mode 100644 index 00000000..a84166cc --- /dev/null +++ b/lib/imagekitio/models/webhook_unsafe_unwrap_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Webhooks#unsafe_unwrap + class WebhookUnsafeUnwrapParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/models/webhook_unwrap_params.rb b/lib/imagekitio/models/webhook_unwrap_params.rb new file mode 100644 index 00000000..a8b318a3 --- /dev/null +++ b/lib/imagekitio/models/webhook_unwrap_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Imagekitio + module Models + # @see Imagekitio::Resources::Webhooks#unwrap + class WebhookUnwrapParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + # @!method initialize(request_options: {}) + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/imagekitio/railtie.rb b/lib/imagekitio/railtie.rb deleted file mode 100644 index d07f716a..00000000 --- a/lib/imagekitio/railtie.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ImageKitIo - class Railtie < ::Rails::Railtie - end -end diff --git a/lib/imagekitio/request.rb b/lib/imagekitio/request.rb deleted file mode 100644 index 355450c4..00000000 --- a/lib/imagekitio/request.rb +++ /dev/null @@ -1,98 +0,0 @@ -# frozen_string_literal: true - -require "base64" -require "rest-client" -require "json" -require 'net/http/post/multipart' -require_relative './constant' -# Request requests and sends data from server -module ImageKitIo - class Request - include Constantable - - attr_reader :private_key, :public_key, :url_endpoint, :transformation_position, :options - - def initialize(private_key, public_key, url_endpoint, transformation_position = nil, options = nil) - @private_key = private_key - @public_key = public_key - @url_endpoint = url_endpoint - @transformation_position = transformation_position || constants.TRANSFORMATION_POSITION - @options = options || {} - end - - # creates required headers - def create_headers - headers = {'Accept-Encoding': "application/json", 'Content-Type': "application/json"} - headers.update(auth_headers) - end - - def auth_headers - encoded_private_key = Base64.strict_encode64(@private_key+":") - {Authorization: "Basic #{encoded_private_key}"} - end - - # request method communicates with server - def request(method, url, headers = create_headers, payload = nil) - headers ||= create_headers - response = {} - begin - if(method.downcase.to_sym == :post && payload.is_a?(Hash) && payload[:multipart]) - uri = URI.parse(url) - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = (uri.scheme == 'https') - req = Net::HTTP::Post::Multipart.new uri.path, payload, headers - resp = http.request(req) - response[:headers] = resp.to_hash - else - resp = RestClient::Request.new(method: method, - url: url, - headers: headers, - payload: payload).execute - response[:headers] = resp.raw_headers - end - response[:raw_body] = resp.body - response[:status_code] = resp.code - resp_c = resp.code.to_i - if [400, 403].include?(resp_c) - raise RestClient::ExceptionWithResponse, OpenStruct.new({ body: resp.body, code: resp_c, headers: response[:headers] }) - end - if (resp.code.to_i >= 200) && (resp.code.to_i < 204) - content_type = resp.respond_to?(:headers) ? resp.headers[:content_type] : resp.content_type - if (content_type.include? "application/json") - response[:response] = JSON.parse(resp.body.to_s) - else - raise RestClient::ExceptionWithResponse, OpenStruct.new(code: 404, body: resp.body) - end - elsif resp.code.to_i == 204 - response[:response] = {'success': true} - end - - rescue RestClient::ExceptionWithResponse => err - response[:status_code] = err.http_code if response[:status_code].nil? - response[:headers] = err.http_headers if response[:headers].nil? - response[:error] = if err.http_code.to_i == 404 - {'message': err.response.to_s} - else - err.response.is_a?(OpenStruct) ? JSON.parse(err.response.body) : JSON.parse(err.response) - end - end - response - end - - def request_stream(method, url, headers: nil, payload: nil, **options, &block) - headers ||= create_headers - response = { response: nil, error: nil } - begin - RestClient::Request.execute(method: method, - url: url, - headers: headers, - payload: payload, - **options, - block_response: block - ) - rescue RestClient::ExceptionWithResponse => err - err.http_code == 404 ? response[:error] = {'message': err.response.to_s} : JSON.parse(err.response) - end - end - end -end diff --git a/lib/imagekitio/request_options.rb b/lib/imagekitio/request_options.rb new file mode 100644 index 00000000..a372343e --- /dev/null +++ b/lib/imagekitio/request_options.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module Imagekitio + # Specify HTTP behaviour to use for a specific request. These options supplement + # or override those provided at the client level. + # + # When making a request, you can pass an actual {RequestOptions} instance, or + # simply pass a Hash with symbol keys matching the attributes on this class. + class RequestOptions < Imagekitio::Internal::Type::BaseModel + # @api private + # + # @param opts [Imagekitio::RequestOptions, Hash{Symbol=>Object}] + # + # @raise [ArgumentError] + def self.validate!(opts) + case opts + in Imagekitio::RequestOptions | Hash + opts.to_h.each_key do |k| + unless fields.include?(k) + raise ArgumentError.new("Request `opts` keys must be one of #{fields.keys}, got #{k.inspect}") + end + end + else + raise ArgumentError.new("Request `opts` must be a Hash or RequestOptions, got #{opts.inspect}") + end + end + + # @!attribute idempotency_key + # Idempotency key to send with request and all associated retries. Will only be + # sent for write requests. + # + # @return [String, nil] + optional :idempotency_key, String + + # @!attribute extra_query + # Extra query params to send with the request. These are `.merge`’d into any + # `query` given at the client level. + # + # @return [Hash{String=>Array, String, nil}, nil] + optional :extra_query, Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::ArrayOf[String]] + + # @!attribute extra_headers + # Extra headers to send with the request. These are `.merged`’d into any + # `extra_headers` given at the client level. + # + # @return [Hash{String=>String, nil}, nil] + optional :extra_headers, Imagekitio::Internal::Type::HashOf[String, nil?: true] + + # @!attribute extra_body + # Extra data to send with the request. These are deep merged into any data + # generated as part of the normal request. + # + # @return [Object, nil] + optional :extra_body, Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown] + + # @!attribute max_retries + # Maximum number of retries to attempt after a failed initial request. + # + # @return [Integer, nil] + optional :max_retries, Integer + + # @!attribute timeout + # Request timeout in seconds. + # + # @return [Float, nil] + optional :timeout, Float + + # @!method initialize(values = {}) + # Returns a new instance of RequestOptions. + # + # @param values [Hash{Symbol=>Object}] + + define_sorbet_constant!(:OrHash) do + T.type_alias { T.any(Imagekitio::RequestOptions, Imagekitio::Internal::AnyHash) } + end + end +end diff --git a/lib/imagekitio/resources/accounts.rb b/lib/imagekitio/resources/accounts.rb new file mode 100644 index 00000000..54395573 --- /dev/null +++ b/lib/imagekitio/resources/accounts.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Accounts + # @return [Imagekitio::Resources::Accounts::Usage] + attr_reader :usage + + # @return [Imagekitio::Resources::Accounts::Origins] + attr_reader :origins + + # @return [Imagekitio::Resources::Accounts::URLEndpoints] + attr_reader :url_endpoints + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + @usage = Imagekitio::Resources::Accounts::Usage.new(client: client) + @origins = Imagekitio::Resources::Accounts::Origins.new(client: client) + @url_endpoints = Imagekitio::Resources::Accounts::URLEndpoints.new(client: client) + end + end + end +end diff --git a/lib/imagekitio/resources/accounts/origins.rb b/lib/imagekitio/resources/accounts/origins.rb new file mode 100644 index 00000000..c9c630ee --- /dev/null +++ b/lib/imagekitio/resources/accounts/origins.rb @@ -0,0 +1,145 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Accounts + class Origins + # **Note:** This API is currently in beta. + # Creates a new origin and returns the origin object. + # + # @overload create(origin_request:, request_options: {}) + # + # @param origin_request [Imagekitio::Accounts::OriginRequest] Schema for origin request resources. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Accounts::OriginResponse::S3, Imagekitio::Models::Accounts::OriginResponse::S3Compatible, Imagekitio::Models::Accounts::OriginResponse::CloudinaryBackup, Imagekitio::Models::Accounts::OriginResponse::WebFolder, Imagekitio::Models::Accounts::OriginResponse::WebProxy, Imagekitio::Models::Accounts::OriginResponse::Gcs, Imagekitio::Models::Accounts::OriginResponse::AzureBlob, Imagekitio::Models::Accounts::OriginResponse::AkeneoPim] + # + # @see Imagekitio::Models::Accounts::OriginCreateParams + def create(params) + parsed, options = Imagekitio::Accounts::OriginCreateParams.dump_request(params) + case parsed + in {origin_request: Hash => union, **rest} + parsed = {**rest, **union} + else + end + @client.request( + method: :post, + path: "v1/accounts/origins", + body: parsed, + model: Imagekitio::Accounts::OriginResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginUpdateParams} for more details. + # + # **Note:** This API is currently in beta. + # Updates the origin identified by `id` and returns the updated origin object. + # + # @overload update(id, origin_request:, request_options: {}) + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param origin_request [Imagekitio::Accounts::OriginRequest] Schema for origin request resources. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Accounts::OriginResponse::S3, Imagekitio::Models::Accounts::OriginResponse::S3Compatible, Imagekitio::Models::Accounts::OriginResponse::CloudinaryBackup, Imagekitio::Models::Accounts::OriginResponse::WebFolder, Imagekitio::Models::Accounts::OriginResponse::WebProxy, Imagekitio::Models::Accounts::OriginResponse::Gcs, Imagekitio::Models::Accounts::OriginResponse::AzureBlob, Imagekitio::Models::Accounts::OriginResponse::AkeneoPim] + # + # @see Imagekitio::Models::Accounts::OriginUpdateParams + def update(id, params) + parsed, options = Imagekitio::Accounts::OriginUpdateParams.dump_request(params) + case parsed + in {origin_request: Hash => union, **rest} + parsed = {**rest, **union} + else + end + @client.request( + method: :put, + path: ["v1/accounts/origins/%1$s", id], + body: parsed, + model: Imagekitio::Accounts::OriginResponse, + options: options + ) + end + + # **Note:** This API is currently in beta. + # Returns an array of all configured origins for the current account. + # + # @overload list(request_options: {}) + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekitio::Models::Accounts::OriginListParams + def list(params = {}) + @client.request( + method: :get, + path: "v1/accounts/origins", + model: Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::Accounts::OriginResponse], + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginDeleteParams} for more details. + # + # **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. + # + # @overload delete(id, request_options: {}) + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Imagekitio::Models::Accounts::OriginDeleteParams + def delete(id, params = {}) + @client.request( + method: :delete, + path: ["v1/accounts/origins/%1$s", id], + model: NilClass, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::OriginGetParams} for more details. + # + # **Note:** This API is currently in beta. + # Retrieves the origin identified by `id`. + # + # @overload get(id, request_options: {}) + # + # @param id [String] Unique identifier for the origin. This is generated by ImageKit when you create + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Accounts::OriginResponse::S3, Imagekitio::Models::Accounts::OriginResponse::S3Compatible, Imagekitio::Models::Accounts::OriginResponse::CloudinaryBackup, Imagekitio::Models::Accounts::OriginResponse::WebFolder, Imagekitio::Models::Accounts::OriginResponse::WebProxy, Imagekitio::Models::Accounts::OriginResponse::Gcs, Imagekitio::Models::Accounts::OriginResponse::AzureBlob, Imagekitio::Models::Accounts::OriginResponse::AkeneoPim] + # + # @see Imagekitio::Models::Accounts::OriginGetParams + def get(id, params = {}) + @client.request( + method: :get, + path: ["v1/accounts/origins/%1$s", id], + model: Imagekitio::Accounts::OriginResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekitio/resources/accounts/url_endpoints.rb b/lib/imagekitio/resources/accounts/url_endpoints.rb new file mode 100644 index 00000000..bcd09d19 --- /dev/null +++ b/lib/imagekitio/resources/accounts/url_endpoints.rb @@ -0,0 +1,151 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Accounts + class URLEndpoints + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::URLEndpointCreateParams} for more details. + # + # **Note:** This API is currently in beta. + # Creates a new URL‑endpoint and returns the resulting object. + # + # @overload create(description:, origins: nil, url_prefix: nil, url_rewriter: nil, request_options: {}) + # + # @param description [String] Description of the URL endpoint. + # + # @param origins [Array] Ordered list of origin IDs to try when the file isn’t in the Media Library; Imag + # + # @param url_prefix [String] Path segment appended to your base URL to form the endpoint (letters, digits, an + # + # @param url_rewriter [Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai] Configuration for third-party URL rewriting. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Accounts::URLEndpointResponse] + # + # @see Imagekitio::Models::Accounts::URLEndpointCreateParams + def create(params) + parsed, options = Imagekitio::Accounts::URLEndpointCreateParams.dump_request(params) + @client.request( + method: :post, + path: "v1/accounts/url-endpoints", + body: parsed, + model: Imagekitio::Accounts::URLEndpointResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::URLEndpointUpdateParams} for more details. + # + # **Note:** This API is currently in beta. + # Updates the URL‑endpoint identified by `id` and returns the updated object. + # + # @overload update(id, description:, origins: nil, url_prefix: nil, url_rewriter: nil, request_options: {}) + # + # @param id [String] Unique identifier for the URL-endpoint. This is generated by ImageKit when you c + # + # @param description [String] Description of the URL endpoint. + # + # @param origins [Array] Ordered list of origin IDs to try when the file isn’t in the Media Library; Imag + # + # @param url_prefix [String] Path segment appended to your base URL to form the endpoint (letters, digits, an + # + # @param url_rewriter [Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Imgix, Imagekitio::Models::Accounts::URLEndpointRequest::URLRewriter::Akamai] Configuration for third-party URL rewriting. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Accounts::URLEndpointResponse] + # + # @see Imagekitio::Models::Accounts::URLEndpointUpdateParams + def update(id, params) + parsed, options = Imagekitio::Accounts::URLEndpointUpdateParams.dump_request(params) + @client.request( + method: :put, + path: ["v1/accounts/url-endpoints/%1$s", id], + body: parsed, + model: Imagekitio::Accounts::URLEndpointResponse, + options: options + ) + end + + # **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. + # + # @overload list(request_options: {}) + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekitio::Models::Accounts::URLEndpointListParams + def list(params = {}) + @client.request( + method: :get, + path: "v1/accounts/url-endpoints", + model: Imagekitio::Internal::Type::ArrayOf[Imagekitio::Accounts::URLEndpointResponse], + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::URLEndpointDeleteParams} for more details. + # + # **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. + # + # @overload delete(id, request_options: {}) + # + # @param id [String] Unique identifier for the URL-endpoint. This is generated by ImageKit when you c + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Imagekitio::Models::Accounts::URLEndpointDeleteParams + def delete(id, params = {}) + @client.request( + method: :delete, + path: ["v1/accounts/url-endpoints/%1$s", id], + model: NilClass, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::URLEndpointGetParams} for more details. + # + # **Note:** This API is currently in beta. + # Retrieves the URL‑endpoint identified by `id`. + # + # @overload get(id, request_options: {}) + # + # @param id [String] Unique identifier for the URL-endpoint. This is generated by ImageKit when you c + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Accounts::URLEndpointResponse] + # + # @see Imagekitio::Models::Accounts::URLEndpointGetParams + def get(id, params = {}) + @client.request( + method: :get, + path: ["v1/accounts/url-endpoints/%1$s", id], + model: Imagekitio::Accounts::URLEndpointResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekitio/resources/accounts/usage.rb b/lib/imagekitio/resources/accounts/usage.rb new file mode 100644 index 00000000..adcdbc94 --- /dev/null +++ b/lib/imagekitio/resources/accounts/usage.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Accounts + class Usage + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Accounts::UsageGetParams} for more details. + # + # 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. + # + # @overload get(end_date:, start_date:, request_options: {}) + # + # @param end_date [Date] Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. + # + # @param start_date [Date] Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Accounts::UsageGetResponse] + # + # @see Imagekitio::Models::Accounts::UsageGetParams + def get(params) + parsed, options = Imagekitio::Accounts::UsageGetParams.dump_request(params) + @client.request( + method: :get, + path: "v1/accounts/usage", + query: parsed.transform_keys(end_date: "endDate", start_date: "startDate"), + model: Imagekitio::Models::Accounts::UsageGetResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekitio/resources/assets.rb b/lib/imagekitio/resources/assets.rb new file mode 100644 index 00000000..f9d64ff9 --- /dev/null +++ b/lib/imagekitio/resources/assets.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Assets + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::AssetListParams} for more details. + # + # 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`. + # + # @overload list(file_type: nil, limit: nil, path: nil, search_query: nil, skip: nil, sort: nil, type: nil, request_options: {}) + # + # @param file_type [Symbol, Imagekitio::Models::AssetListParams::FileType] Filter results by file type. + # + # @param limit [Integer] The maximum number of results to return in response. + # + # @param path [String] Folder path if you want to limit the search within a specific folder. For exampl + # + # @param search_query [String] Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + # + # @param skip [Integer] The number of results to skip before returning results. + # + # @param sort [Symbol, Imagekitio::Models::AssetListParams::Sort] Sort the results by one of the supported fields in ascending or descending order + # + # @param type [Symbol, Imagekitio::Models::AssetListParams::Type] Filter results by asset type. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekitio::Models::AssetListParams + def list(params = {}) + parsed, options = Imagekitio::AssetListParams.dump_request(params) + @client.request( + method: :get, + path: "v1/files", + query: parsed.transform_keys(file_type: "fileType", search_query: "searchQuery"), + model: Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::Models::AssetListResponseItem], + options: options + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end +end diff --git a/lib/imagekitio/resources/beta.rb b/lib/imagekitio/resources/beta.rb new file mode 100644 index 00000000..20652dd6 --- /dev/null +++ b/lib/imagekitio/resources/beta.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Beta + # @return [Imagekitio::Resources::Beta::V2] + attr_reader :v2 + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + @v2 = Imagekitio::Resources::Beta::V2.new(client: client) + end + end + end +end diff --git a/lib/imagekitio/resources/beta/v2.rb b/lib/imagekitio/resources/beta/v2.rb new file mode 100644 index 00000000..2176d37b --- /dev/null +++ b/lib/imagekitio/resources/beta/v2.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Beta + class V2 + # @return [Imagekitio::Resources::Beta::V2::Files] + attr_reader :files + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + @files = Imagekitio::Resources::Beta::V2::Files.new(client: client) + end + end + end + end +end diff --git a/lib/imagekitio/resources/beta/v2/files.rb b/lib/imagekitio/resources/beta/v2/files.rb new file mode 100644 index 00000000..b5f5da37 --- /dev/null +++ b/lib/imagekitio/resources/beta/v2/files.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Beta + class V2 + class Files + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Beta::V2::FileUploadParams} for more details. + # + # 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 20MB for images, audio, and raw + # files, and 100MB for videos. On the paid plan, these limits increase to 40MB for + # images, audio, and raw files, and 2GB for videos. These limits can be further increased + # with higher-tier 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. + # + # @overload upload(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, response_fields: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) + # + # @param file [Pathname, StringIO, IO, String, Imagekitio::FilePart] The API accepts any of the following: + # + # @param file_name [String] The name with which the file has to be uploaded. + # + # @param token [String] This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses i + # + # @param checks [String] Server-side checks to run on the asset. + # + # @param custom_coordinates [String] Define an important area in the image. This is only relevant for image type file + # + # @param custom_metadata [Hash{Symbol=>Object}] JSON key-value pairs to associate with the asset. Create the custom metadata fie + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param folder [String] The folder path in which the image has to be uploaded. If the folder(s) didn't e + # + # @param is_private_file [Boolean] Whether to mark the file as private or not. + # + # @param is_published [Boolean] Whether to upload file as published or not. + # + # @param overwrite_ai_tags [Boolean] If set to `true` and a file already exists at the exact location, its AITags wil + # + # @param overwrite_custom_metadata [Boolean] If the request does not have `customMetadata`, and a file already exists at the + # + # @param overwrite_file [Boolean] If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # + # @param overwrite_tags [Boolean] If the request does not have `tags`, and a file already exists at the exact loca + # + # @param response_fields [Array] Array of response field keys to include in the API response body. + # + # @param tags [Array] Set the tags while uploading the file. + # + # @param transformation [Imagekitio::Models::Beta::V2::FileUploadParams::Transformation] Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # @param use_unique_file_name [Boolean] Whether to use a unique filename for this file or not. + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Beta::V2::FileUploadResponse] + # + # @see Imagekitio::Models::Beta::V2::FileUploadParams + def upload(params) + parsed, options = Imagekitio::Beta::V2::FileUploadParams.dump_request(params) + path = + @client.base_url_overridden? ? "api/v2/files/upload" : "https://upload.imagekit.io/api/v2/files/upload" + @client.request( + method: :post, + path: path, + headers: {"content-type" => "multipart/form-data"}, + body: parsed, + model: Imagekitio::Models::Beta::V2::FileUploadResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end + end + end +end diff --git a/lib/imagekitio/resources/cache.rb b/lib/imagekitio/resources/cache.rb new file mode 100644 index 00000000..6a152ac5 --- /dev/null +++ b/lib/imagekitio/resources/cache.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Cache + # @return [Imagekitio::Resources::Cache::Invalidation] + attr_reader :invalidation + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + @invalidation = Imagekitio::Resources::Cache::Invalidation.new(client: client) + end + end + end +end diff --git a/lib/imagekitio/resources/cache/invalidation.rb b/lib/imagekitio/resources/cache/invalidation.rb new file mode 100644 index 00000000..2b33348a --- /dev/null +++ b/lib/imagekitio/resources/cache/invalidation.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Cache + class Invalidation + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Cache::InvalidationCreateParams} for more details. + # + # 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. + # + # @overload create(url:, request_options: {}) + # + # @param url [String] The full URL of the file to be purged. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Cache::InvalidationCreateResponse] + # + # @see Imagekitio::Models::Cache::InvalidationCreateParams + def create(params) + parsed, options = Imagekitio::Cache::InvalidationCreateParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/purge", + body: parsed, + model: Imagekitio::Models::Cache::InvalidationCreateResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Cache::InvalidationGetParams} for more details. + # + # This API returns the status of a purge cache request. + # + # @overload get(request_id, request_options: {}) + # + # @param request_id [String] Should be a valid requestId. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Cache::InvalidationGetResponse] + # + # @see Imagekitio::Models::Cache::InvalidationGetParams + def get(request_id, params = {}) + @client.request( + method: :get, + path: ["v1/files/purge/%1$s", request_id], + model: Imagekitio::Models::Cache::InvalidationGetResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekitio/resources/custom_metadata_fields.rb b/lib/imagekitio/resources/custom_metadata_fields.rb new file mode 100644 index 00000000..7a811714 --- /dev/null +++ b/lib/imagekitio/resources/custom_metadata_fields.rb @@ -0,0 +1,133 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class CustomMetadataFields + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataFieldCreateParams} for more details. + # + # 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. + # + # @overload create(label:, name:, schema:, request_options: {}) + # + # @param label [String] Human readable name of the custom metadata field. This should be unique across a + # + # @param name [String] API name of the custom metadata field. This should be unique across all (includi + # + # @param schema [Imagekitio::Models::CustomMetadataFieldCreateParams::Schema] + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::CustomMetadataField] + # + # @see Imagekitio::Models::CustomMetadataFieldCreateParams + def create(params) + parsed, options = Imagekitio::CustomMetadataFieldCreateParams.dump_request(params) + @client.request( + method: :post, + path: "v1/customMetadataFields", + body: parsed, + model: Imagekitio::CustomMetadataField, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataFieldUpdateParams} for more details. + # + # This API updates the label or schema of an existing custom metadata field. + # + # @overload update(id, label: nil, schema: nil, request_options: {}) + # + # @param id [String] Should be a valid custom metadata field id. + # + # @param label [String] Human readable name of the custom metadata field. This should be unique across a + # + # @param schema [Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema] An object that describes the rules for the custom metadata key. This parameter i + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::CustomMetadataField] + # + # @see Imagekitio::Models::CustomMetadataFieldUpdateParams + def update(id, params = {}) + parsed, options = Imagekitio::CustomMetadataFieldUpdateParams.dump_request(params) + @client.request( + method: :patch, + path: ["v1/customMetadataFields/%1$s", id], + body: parsed, + model: Imagekitio::CustomMetadataField, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataFieldListParams} for more details. + # + # 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. + # + # @overload list(folder_path: nil, include_deleted: nil, request_options: {}) + # + # @param folder_path [String] The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custo + # + # @param include_deleted [Boolean] Set it to `true` to include deleted field objects in the API response. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekitio::Models::CustomMetadataFieldListParams + def list(params = {}) + parsed, options = Imagekitio::CustomMetadataFieldListParams.dump_request(params) + @client.request( + method: :get, + path: "v1/customMetadataFields", + query: parsed.transform_keys(folder_path: "folderPath", include_deleted: "includeDeleted"), + model: Imagekitio::Internal::Type::ArrayOf[Imagekitio::CustomMetadataField], + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::CustomMetadataFieldDeleteParams} for more details. + # + # 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. + # + # @overload delete(id, request_options: {}) + # + # @param id [String] Should be a valid custom metadata field id. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::CustomMetadataFieldDeleteResponse] + # + # @see Imagekitio::Models::CustomMetadataFieldDeleteParams + def delete(id, params = {}) + @client.request( + method: :delete, + path: ["v1/customMetadataFields/%1$s", id], + model: Imagekitio::Models::CustomMetadataFieldDeleteResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end +end diff --git a/lib/imagekitio/resources/files.rb b/lib/imagekitio/resources/files.rb new file mode 100644 index 00000000..ab7db3a5 --- /dev/null +++ b/lib/imagekitio/resources/files.rb @@ -0,0 +1,305 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Files + # @return [Imagekitio::Resources::Files::Bulk] + attr_reader :bulk + + # @return [Imagekitio::Resources::Files::Versions] + attr_reader :versions + + # @return [Imagekitio::Resources::Files::Metadata] + attr_reader :metadata + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUpdateParams} for more details. + # + # 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. + # + # @overload update(file_id, update_file_request:, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param update_file_request [Imagekitio::UpdateFileRequest] Schema for update file update request. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FileUpdateResponse] + # + # @see Imagekitio::Models::FileUpdateParams + def update(file_id, params) + parsed, options = Imagekitio::FileUpdateParams.dump_request(params) + case parsed + in {update_file_request: Hash => union, **rest} + parsed = {**rest, **union} + else + end + @client.request( + method: :patch, + path: ["v1/files/%1$s/details", file_id], + body: parsed, + model: Imagekitio::Models::FileUpdateResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileDeleteParams} for more details. + # + # 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. + # + # @overload delete(file_id, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [nil] + # + # @see Imagekitio::Models::FileDeleteParams + def delete(file_id, params = {}) + @client.request( + method: :delete, + path: ["v1/files/%1$s", file_id], + model: NilClass, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileCopyParams} for more details. + # + # 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. + # + # @overload copy(destination_path:, source_file_path:, include_file_versions: nil, request_options: {}) + # + # @param destination_path [String] Full path to the folder you want to copy the above file into. + # + # @param source_file_path [String] The full path of the file you want to copy. + # + # @param include_file_versions [Boolean] Option to copy all versions of a file. By default, only the current version of t + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FileCopyResponse] + # + # @see Imagekitio::Models::FileCopyParams + def copy(params) + parsed, options = Imagekitio::FileCopyParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/copy", + body: parsed, + model: Imagekitio::Models::FileCopyResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileGetParams} for more details. + # + # This API returns an object with details or attributes about the current version + # of the file. + # + # @overload get(file_id, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in the list and s + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::File] + # + # @see Imagekitio::Models::FileGetParams + def get(file_id, params = {}) + @client.request( + method: :get, + path: ["v1/files/%1$s/details", file_id], + model: Imagekitio::File, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileMoveParams} for more details. + # + # 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. + # + # @overload move(destination_path:, source_file_path:, request_options: {}) + # + # @param destination_path [String] Full path to the folder you want to move the above file into. + # + # @param source_file_path [String] The full path of the file you want to move. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FileMoveResponse] + # + # @see Imagekitio::Models::FileMoveParams + def move(params) + parsed, options = Imagekitio::FileMoveParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/move", + body: parsed, + model: Imagekitio::Models::FileMoveResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileRenameParams} for more details. + # + # 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. + # + # @overload rename(file_path:, new_file_name:, purge_cache: nil, request_options: {}) + # + # @param file_path [String] The full path of the file you want to rename. + # + # @param new_file_name [String] The new name of the file. A filename can contain: + # + # @param purge_cache [Boolean] Option to purge cache for the old file and its versions' URLs. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FileRenameResponse] + # + # @see Imagekitio::Models::FileRenameParams + def rename(params) + parsed, options = Imagekitio::FileRenameParams.dump_request(params) + @client.request( + method: :put, + path: "v1/files/rename", + body: parsed, + model: Imagekitio::Models::FileRenameResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FileUploadParams} for more details. + # + # 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 20MB for images, audio, and raw + # files and 100MB for videos. On the paid plan, these limits increase to 40MB for images, + # audio, and raw files and 2GB for videos. These limits can be further increased with + # higher-tier 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. + # + # @overload upload(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, expire: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, public_key: nil, response_fields: nil, signature: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {}) + # + # @param file [Pathname, StringIO, IO, String, Imagekitio::FilePart] The API accepts any of the following: + # + # @param file_name [String] The name with which the file has to be uploaded. + # + # @param token [String] A unique value that the ImageKit.io server will use to recognize and prevent sub + # + # @param checks [String] Server-side checks to run on the asset. + # + # @param custom_coordinates [String] Define an important area in the image. This is only relevant for image type file + # + # @param custom_metadata [Hash{Symbol=>Object}] JSON key-value pairs to associate with the asset. Create the custom metadata fie + # + # @param description [String] Optional text to describe the contents of the file. + # + # @param expire [Integer] The time until your signature is valid. It must be a [Unix time](https://en.wiki + # + # @param extensions [Array] Array of extensions to be applied to the asset. Each extension can be configured + # + # @param folder [String] The folder path in which the image has to be uploaded. If the folder(s) didn't e + # + # @param is_private_file [Boolean] Whether to mark the file as private or not. + # + # @param is_published [Boolean] Whether to upload file as published or not. + # + # @param overwrite_ai_tags [Boolean] If set to `true` and a file already exists at the exact location, its AITags wil + # + # @param overwrite_custom_metadata [Boolean] If the request does not have `customMetadata`, and a file already exists at the + # + # @param overwrite_file [Boolean] If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # + # @param overwrite_tags [Boolean] If the request does not have `tags`, and a file already exists at the exact loca + # + # @param public_key [String] Your ImageKit.io public key. This field is only required for authentication when + # + # @param response_fields [Array] Array of response field keys to include in the API response body. + # + # @param signature [String] HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + # + # @param tags [Array] Set the tags while uploading the file. + # + # @param transformation [Imagekitio::Models::FileUploadParams::Transformation] Configure pre-processing (`pre`) and post-processing (`post`) transformations. + # + # @param use_unique_file_name [Boolean] Whether to use a unique filename for this file or not. + # + # @param webhook_url [String] The final status of extensions after they have completed execution will be deliv + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FileUploadResponse] + # + # @see Imagekitio::Models::FileUploadParams + def upload(params) + parsed, options = Imagekitio::FileUploadParams.dump_request(params) + path = + @client.base_url_overridden? ? "api/v1/files/upload" : "https://upload.imagekit.io/api/v1/files/upload" + @client.request( + method: :post, + path: path, + headers: {"content-type" => "multipart/form-data"}, + body: parsed, + model: Imagekitio::Models::FileUploadResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + @bulk = Imagekitio::Resources::Files::Bulk.new(client: client) + @versions = Imagekitio::Resources::Files::Versions.new(client: client) + @metadata = Imagekitio::Resources::Files::Metadata.new(client: client) + end + end + end +end diff --git a/lib/imagekitio/resources/files/bulk.rb b/lib/imagekitio/resources/files/bulk.rb new file mode 100644 index 00000000..946d7af7 --- /dev/null +++ b/lib/imagekitio/resources/files/bulk.rb @@ -0,0 +1,131 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Files + class Bulk + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkDeleteParams} for more details. + # + # 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. + # + # @overload delete(file_ids:, request_options: {}) + # + # @param file_ids [Array] An array of fileIds which you want to delete. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Files::BulkDeleteResponse] + # + # @see Imagekitio::Models::Files::BulkDeleteParams + def delete(params) + parsed, options = Imagekitio::Files::BulkDeleteParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/batch/deleteByFileIds", + body: parsed, + model: Imagekitio::Models::Files::BulkDeleteResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkAddTagsParams} for more details. + # + # This API adds tags to multiple files in bulk. A maximum of 50 files can be + # specified at a time. + # + # @overload add_tags(file_ids:, tags:, request_options: {}) + # + # @param file_ids [Array] An array of fileIds to which you want to add tags. + # + # @param tags [Array] An array of tags that you want to add to the files. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Files::BulkAddTagsResponse] + # + # @see Imagekitio::Models::Files::BulkAddTagsParams + def add_tags(params) + parsed, options = Imagekitio::Files::BulkAddTagsParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/addTags", + body: parsed, + model: Imagekitio::Models::Files::BulkAddTagsResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkRemoveAITagsParams} for more details. + # + # This API removes AITags from multiple files in bulk. A maximum of 50 files can + # be specified at a time. + # + # @overload remove_ai_tags(ai_tags:, file_ids:, request_options: {}) + # + # @param ai_tags [Array] An array of AITags that you want to remove from the files. + # + # @param file_ids [Array] An array of fileIds from which you want to remove AITags. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Files::BulkRemoveAITagsResponse] + # + # @see Imagekitio::Models::Files::BulkRemoveAITagsParams + def remove_ai_tags(params) + parsed, options = Imagekitio::Files::BulkRemoveAITagsParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/removeAITags", + body: parsed, + model: Imagekitio::Models::Files::BulkRemoveAITagsResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::BulkRemoveTagsParams} for more details. + # + # This API removes tags from multiple files in bulk. A maximum of 50 files can be + # specified at a time. + # + # @overload remove_tags(file_ids:, tags:, request_options: {}) + # + # @param file_ids [Array] An array of fileIds from which you want to remove tags. + # + # @param tags [Array] An array of tags that you want to remove from the files. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Files::BulkRemoveTagsResponse] + # + # @see Imagekitio::Models::Files::BulkRemoveTagsParams + def remove_tags(params) + parsed, options = Imagekitio::Files::BulkRemoveTagsParams.dump_request(params) + @client.request( + method: :post, + path: "v1/files/removeTags", + body: parsed, + model: Imagekitio::Models::Files::BulkRemoveTagsResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekitio/resources/files/metadata.rb b/lib/imagekitio/resources/files/metadata.rb new file mode 100644 index 00000000..1e902b04 --- /dev/null +++ b/lib/imagekitio/resources/files/metadata.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Files + class Metadata + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::MetadataGetParams} for more details. + # + # 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. + # + # @overload get(file_id, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in the list and s + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Metadata] + # + # @see Imagekitio::Models::Files::MetadataGetParams + def get(file_id, params = {}) + @client.request( + method: :get, + path: ["v1/files/%1$s/metadata", file_id], + model: Imagekitio::Metadata, + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::MetadataGetFromURLParams} for more details. + # + # Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL + # using this API. + # + # @overload get_from_url(url:, request_options: {}) + # + # @param url [String] Should be a valid file URL. It should be accessible using your ImageKit.io accou + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Metadata] + # + # @see Imagekitio::Models::Files::MetadataGetFromURLParams + def get_from_url(params) + parsed, options = Imagekitio::Files::MetadataGetFromURLParams.dump_request(params) + @client.request( + method: :get, + path: "v1/files/metadata", + query: parsed, + model: Imagekitio::Metadata, + options: options + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekitio/resources/files/versions.rb b/lib/imagekitio/resources/files/versions.rb new file mode 100644 index 00000000..1857b354 --- /dev/null +++ b/lib/imagekitio/resources/files/versions.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Files + class Versions + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::VersionListParams} for more details. + # + # This API returns details of all versions of a file. + # + # @overload list(file_id, request_options: {}) + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Array] + # + # @see Imagekitio::Models::Files::VersionListParams + def list(file_id, params = {}) + @client.request( + method: :get, + path: ["v1/files/%1$s/versions", file_id], + model: Imagekitio::Internal::Type::ArrayOf[Imagekitio::File], + options: params[:request_options] + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::VersionDeleteParams} for more details. + # + # 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. + # + # @overload delete(version_id, file_id:, request_options: {}) + # + # @param version_id [String] The unique `versionId` of the uploaded file. `versionId` is returned in list and + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Files::VersionDeleteResponse] + # + # @see Imagekitio::Models::Files::VersionDeleteParams + def delete(version_id, params) + parsed, options = Imagekitio::Files::VersionDeleteParams.dump_request(params) + file_id = + parsed.delete(:file_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end + @client.request( + method: :delete, + path: ["v1/files/%1$s/versions/%2$s", file_id, version_id], + model: Imagekitio::Models::Files::VersionDeleteResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::VersionGetParams} for more details. + # + # This API returns an object with details or attributes of a file version. + # + # @overload get(version_id, file_id:, request_options: {}) + # + # @param version_id [String] The unique `versionId` of the uploaded file. `versionId` is returned in list and + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::File] + # + # @see Imagekitio::Models::Files::VersionGetParams + def get(version_id, params) + parsed, options = Imagekitio::Files::VersionGetParams.dump_request(params) + file_id = + parsed.delete(:file_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end + @client.request( + method: :get, + path: ["v1/files/%1$s/versions/%2$s", file_id, version_id], + model: Imagekitio::File, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Files::VersionRestoreParams} for more details. + # + # This API restores a file version as the current file version. + # + # @overload restore(version_id, file_id:, request_options: {}) + # + # @param version_id [String] The unique `versionId` of the uploaded file. `versionId` is returned in list and + # + # @param file_id [String] The unique `fileId` of the uploaded file. `fileId` is returned in list and searc + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::File] + # + # @see Imagekitio::Models::Files::VersionRestoreParams + def restore(version_id, params) + parsed, options = Imagekitio::Files::VersionRestoreParams.dump_request(params) + file_id = + parsed.delete(:file_id) do + raise ArgumentError.new("missing required path argument #{_1}") + end + @client.request( + method: :put, + path: ["v1/files/%1$s/versions/%2$s/restore", file_id, version_id], + model: Imagekitio::File, + options: options + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekitio/resources/folders.rb b/lib/imagekitio/resources/folders.rb new file mode 100644 index 00000000..f9c391e6 --- /dev/null +++ b/lib/imagekitio/resources/folders.rb @@ -0,0 +1,166 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Folders + # @return [Imagekitio::Resources::Folders::Job] + attr_reader :job + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderCreateParams} for more details. + # + # 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. + # + # @overload create(folder_name:, parent_folder_path:, request_options: {}) + # + # @param folder_name [String] The folder will be created with this name. + # + # @param parent_folder_path [String] The folder where the new folder should be created, for root use `/` else the pat + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FolderCreateResponse] + # + # @see Imagekitio::Models::FolderCreateParams + def create(params) + parsed, options = Imagekitio::FolderCreateParams.dump_request(params) + @client.request( + method: :post, + path: "v1/folder", + body: parsed, + model: Imagekitio::Models::FolderCreateResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderDeleteParams} for more details. + # + # This will delete a folder and all its contents permanently. The API returns an + # empty response. + # + # @overload delete(folder_path:, request_options: {}) + # + # @param folder_path [String] Full path to the folder you want to delete. For example `/folder/to/delete/`. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FolderDeleteResponse] + # + # @see Imagekitio::Models::FolderDeleteParams + def delete(params) + parsed, options = Imagekitio::FolderDeleteParams.dump_request(params) + @client.request( + method: :delete, + path: "v1/folder", + body: parsed, + model: Imagekitio::Models::FolderDeleteResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderCopyParams} for more details. + # + # 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. + # + # @overload copy(destination_path:, source_folder_path:, include_versions: nil, request_options: {}) + # + # @param destination_path [String] Full path to the destination folder where you want to copy the source folder int + # + # @param source_folder_path [String] The full path to the source folder you want to copy. + # + # @param include_versions [Boolean] Option to copy all versions of files that are nested inside the selected folder. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FolderCopyResponse] + # + # @see Imagekitio::Models::FolderCopyParams + def copy(params) + parsed, options = Imagekitio::FolderCopyParams.dump_request(params) + @client.request( + method: :post, + path: "v1/bulkJobs/copyFolder", + body: parsed, + model: Imagekitio::Models::FolderCopyResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderMoveParams} for more details. + # + # 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. + # + # @overload move(destination_path:, source_folder_path:, request_options: {}) + # + # @param destination_path [String] Full path to the destination folder where you want to move the source folder int + # + # @param source_folder_path [String] The full path to the source folder you want to move. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FolderMoveResponse] + # + # @see Imagekitio::Models::FolderMoveParams + def move(params) + parsed, options = Imagekitio::FolderMoveParams.dump_request(params) + @client.request( + method: :post, + path: "v1/bulkJobs/moveFolder", + body: parsed, + model: Imagekitio::Models::FolderMoveResponse, + options: options + ) + end + + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::FolderRenameParams} for more details. + # + # 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. + # + # @overload rename(folder_path:, new_folder_name:, purge_cache: nil, request_options: {}) + # + # @param folder_path [String] The full path to the folder you want to rename. + # + # @param new_folder_name [String] The new name for the folder. + # + # @param purge_cache [Boolean] Option to purge cache for the old nested files and their versions' URLs. + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::FolderRenameResponse] + # + # @see Imagekitio::Models::FolderRenameParams + def rename(params) + parsed, options = Imagekitio::FolderRenameParams.dump_request(params) + @client.request( + method: :post, + path: "v1/bulkJobs/renameFolder", + body: parsed, + model: Imagekitio::Models::FolderRenameResponse, + options: options + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + @job = Imagekitio::Resources::Folders::Job.new(client: client) + end + end + end +end diff --git a/lib/imagekitio/resources/folders/job.rb b/lib/imagekitio/resources/folders/job.rb new file mode 100644 index 00000000..1a3d494f --- /dev/null +++ b/lib/imagekitio/resources/folders/job.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Folders + class Job + # Some parameter documentations has been truncated, see + # {Imagekitio::Models::Folders::JobGetParams} for more details. + # + # This API returns the status of a bulk job like copy and move folder operations. + # + # @overload get(job_id, request_options: {}) + # + # @param job_id [String] The `jobId` is returned in the response of bulk job API e.g. copy folder or move + # + # @param request_options [Imagekitio::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Imagekitio::Models::Folders::JobGetResponse] + # + # @see Imagekitio::Models::Folders::JobGetParams + def get(job_id, params = {}) + @client.request( + method: :get, + path: ["v1/bulkJobs/%1$s", job_id], + model: Imagekitio::Models::Folders::JobGetResponse, + options: params[:request_options] + ) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end + end +end diff --git a/lib/imagekitio/resources/webhooks.rb b/lib/imagekitio/resources/webhooks.rb new file mode 100644 index 00000000..a01015e6 --- /dev/null +++ b/lib/imagekitio/resources/webhooks.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Imagekitio + module Resources + class Webhooks + # @param payload [String] The raw webhook payload as a string + # + # @return [Imagekitio::Models::VideoTransformationAcceptedEvent, Imagekitio::Models::VideoTransformationReadyEvent, Imagekitio::Models::VideoTransformationErrorEvent, Imagekitio::Models::UploadPreTransformSuccessEvent, Imagekitio::Models::UploadPreTransformErrorEvent, Imagekitio::Models::UploadPostTransformSuccessEvent, Imagekitio::Models::UploadPostTransformErrorEvent] + def unsafe_unwrap(payload) + parsed = JSON.parse(payload, symbolize_names: true) + Imagekitio::Internal::Type::Converter.coerce(Imagekitio::Models::UnsafeUnwrapWebhookEvent, parsed) + end + + # @param payload [String] The raw webhook payload as a string + # + # @return [Imagekitio::Models::VideoTransformationAcceptedEvent, Imagekitio::Models::VideoTransformationReadyEvent, Imagekitio::Models::VideoTransformationErrorEvent, Imagekitio::Models::UploadPreTransformSuccessEvent, Imagekitio::Models::UploadPreTransformErrorEvent, Imagekitio::Models::UploadPostTransformSuccessEvent, Imagekitio::Models::UploadPostTransformErrorEvent] + def unwrap(payload) + parsed = JSON.parse(payload, symbolize_names: true) + Imagekitio::Internal::Type::Converter.coerce(Imagekitio::Models::UnwrapWebhookEvent, parsed) + end + + # @api private + # + # @param client [Imagekitio::Client] + def initialize(client:) + @client = client + end + end + end +end diff --git a/lib/imagekitio/sdk/version.rb b/lib/imagekitio/sdk/version.rb deleted file mode 100644 index a9dac6ed..00000000 --- a/lib/imagekitio/sdk/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -module ImageKitIo - module Sdk - VERSION = '3.1.0' - end -end diff --git a/lib/imagekitio/url.rb b/lib/imagekitio/url.rb deleted file mode 100644 index b2b736ae..00000000 --- a/lib/imagekitio/url.rb +++ /dev/null @@ -1,216 +0,0 @@ -# frozen_string_literal: true - -# Url holds url generation method - -require "cgi" -require "addressable/uri" -require "openssl" -require_relative "./utils/formatter" -require_relative "sdk/version.rb" - -module ImageKitIo - class Url - include Constantable - - def initialize(request_obj) - @req_obj = request_obj - end - - def generate_url(options) - if options.key? :src - options[:transformation_position] = constants.TRANSFORMATION_POSITION - end - extended_options = extend_url_options(options) - build_url(extended_options) - end - - def build_url(options) - # build url from all options - - path = options.fetch(:path, "") - src = options.fetch(:src, "") - url_endpoint = options.fetch(:url_endpoint, "") - transformation_position = options[:transformation_position] - - unless constants.VALID_TRANSFORMATION_POSITION.include? transformation_position - raise ArgumentError, constants.INVALID_TRANSFORMATION_POS - end - - src_param_used_for_url = false - if (src != "") || (transformation_position == constants.QUERY_TRANSFORMATION_POSITION) - src_param_used_for_url = true - end - - if path == "" && src == "" - return "" - end - - result_url_hash = {'host': "", 'path': "", 'query': ""} - parsed_host = Addressable::URI.parse(url_endpoint) - existing_query = nil - if path != "" - parsed_url = Addressable::URI.parse(path) - # making sure single '/' at end - result_url_hash[:host] = parsed_host.host.to_s.chomp("/") + parsed_host.path.chomp("/") + "/" - path_without_query = Addressable::URI.parse(path) - path_without_query.fragment = path_without_query.query = nil - result_url_hash[:path] = path_without_query.hostname.nil? ? trim_slash(path_without_query.to_s) : CGI.escape(trim_slash(path_without_query.to_s)) - else - parsed_url = Addressable::URI.parse(src) - result_url_hash[:userinfo] = parsed_url.userinfo if parsed_url.userinfo - result_url_hash[:host] = parsed_url.host - result_url_hash[:path] = parsed_url.path - src_param_used_for_url = true - end - - existing_query = parsed_url.query - result_url_hash[:scheme] = parsed_host.scheme - query_params = {} - query_params = CGI.parse(existing_query).reject {|k, v| v.empty? }.transform_values(&:first) unless existing_query.nil? - options.fetch(:query_parameters, {}).each do |key, value| - query_params[key] = value - end - transformation_str = transformation_to_str(options[:transformation]).chomp("/") - unless transformation_str.nil? || transformation_str.strip.empty? - if (transformation_position == constants.QUERY_TRANSFORMATION_POSITION) || src_param_used_for_url == true - result_url_hash[:query] = "#{constants.TRANSFORMATION_PARAMETER}=#{transformation_str}" - query_params[:tr]=transformation_str - else - result_url_hash[:path] = "#{constants.TRANSFORMATION_PARAMETER}:#{transformation_str}/#{result_url_hash[:path]}" - end - end - - result_url_hash[:host] = result_url_hash[:host].to_s.reverse.chomp("/").reverse - result_url_hash[:path] = result_url_hash[:path].chomp("/") unless result_url_hash[:path].nil? - result_url_hash[:scheme] ||= "https" - - query_param_arr = [] - query_params.each do |key, value| - if value.to_s == "" - query_param_arr.push(key.to_s) - else - query_param_arr.push(key.to_s + "=" + value.to_s) - end - end - query_param_str = query_param_arr.join("&") - result_url_hash[:query] = query_param_str - url = hash_to_url(result_url_hash) - if options[:signed] - private_key = options[:private_key] - expire_seconds = options[:expire_seconds] - expire_timestamp = get_signature_timestamp(expire_seconds) - url_signature = get_signature(private_key, url, url_endpoint, expire_timestamp) - query_param_arr.push(constants.SIGNATURE_PARAMETER + "=" + url_signature) - - if expire_timestamp && (expire_timestamp != constants.TIMESTAMP) - query_param_arr.push(constants.TIMESTAMP_PARAMETER + "=" + expire_timestamp.to_s) - end - query_param_str = query_param_arr.join("&") - result_url_hash[:query] = query_param_str - - url=hash_to_url(result_url_hash) - end - url - end - - def transformation_to_str(transformation) - # creates transformation_position string for url - # from transformation dictionary - - unless transformation.is_a?(Array) - return "" - end - - parsed_transforms = [] - (0..(transformation.length - 1)).each do |i| - parsed_transform_step = [] - - transformation[i].keys.each do |key| - transform_key = constants.SUPPORTED_TRANS.fetch(key, nil) - transform_key ||= key - - if transform_key == "oi" || transform_key == "di" - transformation[i][key][0] = "" if transformation[i][key][0] == "/" - transformation[i][key] = transformation[i][key].gsub("/", "@@") - end - - if transformation[i][key] == "-" - parsed_transform_step.push(transform_key) - elsif transform_key == 'raw' - parsed_transform_step.push(transformation[i][key]) - else - parsed_transform_step.push("#{transform_key}#{constants.TRANSFORM_KEY_VALUE_DELIMITER}#{transformation[i][key]}") - end - end - parsed_transforms.push(parsed_transform_step.join(constants.TRANSFORM_DELIMITER)) - end - parsed_transforms.join(constants.CHAIN_TRANSFORM_DELIMITER) - end - - def get_signature_timestamp(seconds) - # this function returns either default time stamp - # or current unix time and expiry seconds to get - # signature time stamp - - if seconds.to_i == 0 - constants.DEFAULT_TIMESTAMP - else - DateTime.now.strftime("%s").to_i + seconds.to_i - end - end - - def get_signature(private_key, url, url_endpoint, expiry_timestamp) - # creates signature(hashed hex key) and returns from - # private_key, url, url_endpoint and expiry_timestamp - if expiry_timestamp==0 - expiry_timestamp=constants.DEFAULT_TIMESTAMP - end - if url_endpoint[url_endpoint.length-1]!="/" - url_endpoint+="/" - end - replaced_url=url.gsub(url_endpoint, "") - replaced_url = replaced_url + expiry_timestamp.to_s - OpenSSL::HMAC.hexdigest("SHA1", private_key, replaced_url) - end - - def extend_url_options(options) - attr_dict = {"public_key": @req_obj.public_key, - "private_key": @req_obj.private_key, - "url_endpoint": @req_obj.url_endpoint, - "transformation_position": @req_obj.transformation_position, } - # extending url options - attr_dict.merge(options) - end - - def hash_to_url(url_hash) - generated_url = url_hash.fetch(:scheme, "") + "://" + url_hash.fetch(:host, "") + url_hash.fetch(:path, "") - if url_hash[:query] != "" - generated_url = generated_url + "?" + url_hash.fetch(:query, "") - return generated_url - end - generated_url - end - - def trim_slash(str, both = true) - if str == "" - return "" - end - # remove slash from a string - # if both is not provide trims both slash - # example - '/abc/' returns 'abc' - # if both=false it will only trim end slash - # example - '/abc/' returns '/abc' - # NOTE: IT'S RECOMMENDED TO USE inbuilt .chomp('string you want to remove') - # FOR REMOVING ONLY TRAILING SLASh - if both - str[0].chomp("/") + str[1..-2] + str[-1].chomp("/") - else - str.chomp("/") - end - end - - # class Imagekit - - # end - end -end diff --git a/lib/imagekitio/utils/calculation.rb b/lib/imagekitio/utils/calculation.rb deleted file mode 100644 index 5709090d..00000000 --- a/lib/imagekitio/utils/calculation.rb +++ /dev/null @@ -1,45 +0,0 @@ -require "date" -require "securerandom" - -module ImageKitIo - module Utils - module Calculation - DEFAULT_TIME_DIFF = 60 * 30 - - module_function - - def is_valid_hex(hex_string) - # checks if hexadecimal value is valid or not - /^[[:xdigit:]]+$/ === hex_string - end - - def hamming_distance(first, second) - # Calculate Hamming distance between to hex string - unless is_valid_hex(first) && is_valid_hex(second) - raise ArgumentError, "Both argument should be hexadecimal" - end - a = first.to_i(16) - b = second.to_i(16) - (a ^ b).to_s(2).count("1") - end - - def get_authenticated_params(token, expire, private_key) - # return authenticated param - default_expire = DateTime.now.strftime("%s").to_i + DEFAULT_TIME_DIFF - token ||= SecureRandom.uuid - expire ||= default_expire - - auth_params = {'token': token, 'expire': expire, 'signature': ""} - unless private_key - return nil - end - - signature = OpenSSL::HMAC.hexdigest("SHA1", private_key, token.to_s + expire.to_s) - auth_params[:token] = token - auth_params[:expire] = expire - auth_params[:signature] = signature - auth_params - end - end - end -end diff --git a/lib/imagekitio/utils/formatter.rb b/lib/imagekitio/utils/formatter.rb deleted file mode 100644 index f86a09da..00000000 --- a/lib/imagekitio/utils/formatter.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'json' - -module ImageKitIo - module Utils - module Formatter - - module_function - def snake_to_camel(word) - word_list = word.split("_") - result = [] - word_list&.each { |i| - if i == word_list[0] - result.push(i) - else - result.push(i.capitalize) - end - } - result.join - end - - def camel_to_snake(camel_word) - # convert camel case to snake case - camel_word.to_s.gsub(/::/, "/") - .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') - .gsub(/([a-z\d])([A-Z])/, '\1_\2') - .tr("-", "_") - .downcase - end - - def request_formatter(data) - result = {} - data.each do |key, val| - result[snake_to_camel(key.to_s)] = val - end - result - end - - def format_to_json(options, key, expected_class) - options ||= {} - val = options[key] - if !val.nil? && val.is_a?(expected_class) - options[key] = options[key].to_json - end - options - end - end - end -end diff --git a/lib/imagekitio/utils/option_validator.rb b/lib/imagekitio/utils/option_validator.rb deleted file mode 100644 index 45036c60..00000000 --- a/lib/imagekitio/utils/option_validator.rb +++ /dev/null @@ -1,36 +0,0 @@ -require_relative './formatter' - -module ImageKitIo - module Utils - module OptionValidator - include Formatter - include Constantable - - module_function - - def validate_upload_options(options) - - # Validates upload value, checks if params are valid, - # changes snake to camel case which is supported by - # ImageKitIo server - - - response_list = [] - options.each do |key, val| - if constants.VALID_UPLOAD_OPTIONS.include?(key.to_s) - if val.is_a?(Array) - val = val.join(",") - end - if val.is_a?(TrueClass) || val.is_a?(FalseClass) - val = val.to_s - end - options[key] = val - else - return false - end - end - request_formatter(options) - end - end - end -end diff --git a/lib/imagekitio/version.rb b/lib/imagekitio/version.rb new file mode 100644 index 00000000..5c1df80d --- /dev/null +++ b/lib/imagekitio/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Imagekitio + VERSION = "4.0.0" +end diff --git a/lib/tasks/imagekitio/imagekitio_tasks.rake b/lib/tasks/imagekitio/imagekitio_tasks.rake deleted file mode 100644 index 8d6717f2..00000000 --- a/lib/tasks/imagekitio/imagekitio_tasks.rake +++ /dev/null @@ -1,4 +0,0 @@ -# desc "Explaining what the task does" -# task :imagekitio do -# # Task goes here -# end diff --git a/manifest.yaml b/manifest.yaml new file mode 100644 index 00000000..556686f5 --- /dev/null +++ b/manifest.yaml @@ -0,0 +1,15 @@ +dependencies: + - English + - cgi + - date + - erb + - etc + - json + - net/http + - pathname + - rbconfig + - securerandom + - set + - stringio + - time + - uri diff --git a/rbi/imagekitio/client.rbi b/rbi/imagekitio/client.rbi new file mode 100644 index 00000000..5d72af74 --- /dev/null +++ b/rbi/imagekitio/client.rbi @@ -0,0 +1,92 @@ +# typed: strong + +module Imagekitio + class Client < Imagekitio::Internal::Transport::BaseClient + DEFAULT_MAX_RETRIES = 2 + + DEFAULT_TIMEOUT_IN_SECONDS = T.let(60.0, Float) + + DEFAULT_INITIAL_RETRY_DELAY = T.let(0.5, Float) + + DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float) + + # Your ImageKit private API key (starts with `private_`). You can find this in the + # [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). + sig { returns(String) } + attr_reader :private_key + + # ImageKit uses your API key as username and ignores the password. The SDK sets a + # dummy value. You can ignore this field. + sig { returns(T.nilable(String)) } + attr_reader :password + + sig { returns(Imagekitio::Resources::CustomMetadataFields) } + attr_reader :custom_metadata_fields + + sig { returns(Imagekitio::Resources::Files) } + attr_reader :files + + sig { returns(Imagekitio::Resources::Assets) } + attr_reader :assets + + sig { returns(Imagekitio::Resources::Cache) } + attr_reader :cache + + sig { returns(Imagekitio::Resources::Folders) } + attr_reader :folders + + sig { returns(Imagekitio::Resources::Accounts) } + attr_reader :accounts + + sig { returns(Imagekitio::Resources::Beta) } + attr_reader :beta + + sig { returns(Imagekitio::Resources::Webhooks) } + attr_reader :webhooks + + sig { returns(Imagekitio::Helper) } + attr_reader :helper + + # @api private + sig { override.returns(T::Hash[String, String]) } + private def auth_headers + end + + # @api private + sig { returns(T::Boolean) } + def base_url_overridden? + end + + # Creates and returns a new client for interacting with the API. + sig do + params( + private_key: T.nilable(String), + password: T.nilable(String), + base_url: T.nilable(String), + max_retries: Integer, + timeout: Float, + initial_retry_delay: Float, + max_retry_delay: Float + ).returns(T.attached_class) + end + def self.new( + # Your ImageKit private API key (starts with `private_`). You can find this in the + # [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). Defaults + # to `ENV["IMAGEKIT_PRIVATE_KEY"]` + private_key: ENV["IMAGEKIT_PRIVATE_KEY"], + # ImageKit uses your API key as username and ignores the password. The SDK sets a + # dummy value. You can ignore this field. Defaults to + # `ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"]` + password: ENV.fetch("OPTIONAL_IMAGEKIT_IGNORES_THIS", "do_not_set"), + # Override the default base URL for the API, e.g., + # `"https://api.example.com/v2/"`. Defaults to `ENV["IMAGE_KIT_BASE_URL"]` + base_url: ENV["IMAGE_KIT_BASE_URL"], + # Max number of retries to attempt after a failed retryable request. + max_retries: Imagekitio::Client::DEFAULT_MAX_RETRIES, + timeout: Imagekitio::Client::DEFAULT_TIMEOUT_IN_SECONDS, + initial_retry_delay: Imagekitio::Client::DEFAULT_INITIAL_RETRY_DELAY, + max_retry_delay: Imagekitio::Client::DEFAULT_MAX_RETRY_DELAY + ) + end + end +end diff --git a/rbi/imagekitio/errors.rbi b/rbi/imagekitio/errors.rbi new file mode 100644 index 00000000..b7e41111 --- /dev/null +++ b/rbi/imagekitio/errors.rbi @@ -0,0 +1,205 @@ +# typed: strong + +module Imagekitio + module Errors + class Error < StandardError + sig { returns(T.nilable(StandardError)) } + attr_accessor :cause + end + + class ConversionError < Imagekitio::Errors::Error + sig { returns(T.nilable(StandardError)) } + def cause + end + + # @api private + sig do + params( + on: T::Class[StandardError], + method: Symbol, + target: T.anything, + value: T.anything, + cause: T.nilable(StandardError) + ).returns(T.attached_class) + end + def self.new(on:, method:, target:, value:, cause: nil) + end + end + + class APIError < Imagekitio::Errors::Error + sig { returns(URI::Generic) } + attr_accessor :url + + sig { returns(T.nilable(Integer)) } + attr_accessor :status + + sig { returns(T.nilable(T::Hash[String, String])) } + attr_accessor :headers + + sig { returns(T.nilable(T.anything)) } + attr_accessor :body + + # @api private + sig do + params( + url: URI::Generic, + status: T.nilable(Integer), + headers: T.nilable(T::Hash[String, String]), + body: T.nilable(Object), + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: nil + ) + end + end + + class APIConnectionError < Imagekitio::Errors::APIError + sig { returns(NilClass) } + attr_accessor :status + + sig { returns(NilClass) } + attr_accessor :body + + # @api private + sig do + params( + url: URI::Generic, + status: NilClass, + headers: T.nilable(T::Hash[String, String]), + body: NilClass, + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: "Connection error." + ) + end + end + + class APITimeoutError < Imagekitio::Errors::APIConnectionError + # @api private + sig do + params( + url: URI::Generic, + status: NilClass, + headers: T.nilable(T::Hash[String, String]), + body: NilClass, + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + url:, + status: nil, + headers: nil, + body: nil, + request: nil, + response: nil, + message: "Request timed out." + ) + end + end + + class APIStatusError < Imagekitio::Errors::APIError + # @api private + sig do + params( + url: URI::Generic, + status: Integer, + headers: T.nilable(T::Hash[String, String]), + body: T.nilable(Object), + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.for( + url:, + status:, + headers:, + body:, + request:, + response:, + message: nil + ) + end + + sig { returns(Integer) } + attr_accessor :status + + # @api private + sig do + params( + url: URI::Generic, + status: Integer, + headers: T.nilable(T::Hash[String, String]), + body: T.nilable(Object), + request: NilClass, + response: NilClass, + message: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + url:, + status:, + headers:, + body:, + request:, + response:, + message: nil + ) + end + end + + class BadRequestError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 400 + end + + class AuthenticationError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 401 + end + + class PermissionDeniedError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 403 + end + + class NotFoundError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 404 + end + + class ConflictError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 409 + end + + class UnprocessableEntityError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 422 + end + + class RateLimitError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = 429 + end + + class InternalServerError < Imagekitio::Errors::APIStatusError + HTTP_STATUS = T.let((500..), T::Range[Integer]) + end + end +end diff --git a/rbi/imagekitio/file_part.rbi b/rbi/imagekitio/file_part.rbi new file mode 100644 index 00000000..30b6ce18 --- /dev/null +++ b/rbi/imagekitio/file_part.rbi @@ -0,0 +1,37 @@ +# typed: strong + +module Imagekitio + class FilePart + sig { returns(T.any(Pathname, StringIO, IO, String)) } + attr_reader :content + + sig { returns(T.nilable(String)) } + attr_reader :content_type + + sig { returns(T.nilable(String)) } + attr_reader :filename + + # @api private + sig { returns(String) } + private def read + end + + sig { params(a: T.anything).returns(String) } + def to_json(*a) + end + + sig { params(a: T.anything).returns(String) } + def to_yaml(*a) + end + + sig do + params( + content: T.any(Pathname, StringIO, IO, String), + filename: T.nilable(T.any(Pathname, String)), + content_type: T.nilable(String) + ).returns(T.attached_class) + end + def self.new(content, filename: nil, content_type: nil) + end + end +end diff --git a/rbi/imagekitio/helpers/helper.rbi b/rbi/imagekitio/helpers/helper.rbi new file mode 100644 index 00000000..f3babc75 --- /dev/null +++ b/rbi/imagekitio/helpers/helper.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module Imagekitio + class Helper + sig { params(client: Imagekitio::Client).void } + def initialize(client:) + end + + # Builds a URL with transformations applied + sig { params(options: Imagekitio::Models::SrcOptions).returns(String) } + def build_url(options) + end + + # Generates transformation string from transformation objects + sig do + params( + transformations: T::Array[Imagekitio::Models::Transformation] + ).returns(String) + end + def build_transformation_string(transformations) + end + + # Generates authentication parameters for client-side file uploads + sig do + params(token: T.nilable(String), expire: T.nilable(Integer)).returns( + T::Hash[Symbol, T.any(String, Integer)] + ) + end + def get_authentication_parameters(token = nil, expire = nil) + end + + # Generates responsive image attributes for use in HTML tags + sig do + params(options: Imagekitio::Models::GetImageAttributesOptions).returns( + Imagekitio::Models::ResponsiveImageAttributes + ) + end + def get_responsive_image_attributes(options) + end + end +end diff --git a/rbi/imagekitio/internal.rbi b/rbi/imagekitio/internal.rbi new file mode 100644 index 00000000..25d559ce --- /dev/null +++ b/rbi/imagekitio/internal.rbi @@ -0,0 +1,18 @@ +# typed: strong + +module Imagekitio + module Internal + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + # Due to the current WIP status of Shapes support in Sorbet, types referencing + # this alias might be refined in the future. + AnyHash = T.type_alias { T::Hash[Symbol, T.anything] } + + FileInput = + T.type_alias do + T.any(Pathname, StringIO, IO, String, Imagekitio::FilePart) + end + + OMIT = T.let(Object.new.freeze, T.anything) + end +end diff --git a/rbi/imagekitio/internal/transport/base_client.rbi b/rbi/imagekitio/internal/transport/base_client.rbi new file mode 100644 index 00000000..445a4149 --- /dev/null +++ b/rbi/imagekitio/internal/transport/base_client.rbi @@ -0,0 +1,295 @@ +# typed: strong + +module Imagekitio + module Internal + module Transport + # @api private + class BaseClient + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + abstract! + + RequestComponents = + T.type_alias do + { + method: Symbol, + path: T.any(String, T::Array[String]), + query: + T.nilable( + T::Hash[String, T.nilable(T.any(T::Array[String], String))] + ), + headers: + T.nilable( + T::Hash[ + String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + ) + ] + ), + body: T.nilable(T.anything), + unwrap: + T.nilable( + T.any( + Symbol, + Integer, + T::Array[T.any(Symbol, Integer)], + T.proc.params(arg0: T.anything).returns(T.anything) + ) + ), + page: + T.nilable( + T::Class[ + Imagekitio::Internal::Type::BasePage[ + Imagekitio::Internal::Type::BaseModel + ] + ] + ), + stream: T.nilable(T::Class[T.anything]), + model: T.nilable(Imagekitio::Internal::Type::Converter::Input), + options: T.nilable(Imagekitio::RequestOptions::OrHash) + } + end + + RequestInput = + T.type_alias do + { + method: Symbol, + url: URI::Generic, + headers: T::Hash[String, String], + body: T.anything, + max_retries: Integer, + timeout: Float + } + end + + # from whatwg fetch spec + MAX_REDIRECTS = 20 + + PLATFORM_HEADERS = T::Hash[String, String] + + class << self + # @api private + sig do + params( + req: + Imagekitio::Internal::Transport::BaseClient::RequestComponents + ).void + end + def validate!(req) + end + + # @api private + sig do + params(status: Integer, headers: T::Hash[String, String]).returns( + T::Boolean + ) + end + def should_retry?(status, headers:) + end + + # @api private + sig do + params( + request: + Imagekitio::Internal::Transport::BaseClient::RequestInput, + status: Integer, + response_headers: T::Hash[String, String] + ).returns(Imagekitio::Internal::Transport::BaseClient::RequestInput) + end + def follow_redirect(request, status:, response_headers:) + end + + # @api private + sig do + params( + status: T.any(Integer, Imagekitio::Errors::APIConnectionError), + stream: T.nilable(T::Enumerable[String]) + ).void + end + def reap_connection!(status, stream:) + end + end + + sig { returns(URI::Generic) } + attr_reader :base_url + + sig { returns(Float) } + attr_reader :timeout + + sig { returns(Integer) } + attr_reader :max_retries + + sig { returns(Float) } + attr_reader :initial_retry_delay + + sig { returns(Float) } + attr_reader :max_retry_delay + + sig { returns(T::Hash[String, String]) } + attr_reader :headers + + sig { returns(T.nilable(String)) } + attr_reader :idempotency_header + + # @api private + sig { returns(Imagekitio::Internal::Transport::PooledNetRequester) } + attr_reader :requester + + # @api private + sig do + params( + base_url: String, + timeout: Float, + max_retries: Integer, + initial_retry_delay: Float, + max_retry_delay: Float, + headers: + T::Hash[ + String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + ) + ], + idempotency_header: T.nilable(String) + ).returns(T.attached_class) + end + def self.new( + base_url:, + timeout: 0.0, + max_retries: 0, + initial_retry_delay: 0.0, + max_retry_delay: 0.0, + headers: {}, + idempotency_header: nil + ) + end + + # @api private + sig { overridable.returns(T::Hash[String, String]) } + private def auth_headers + end + + # @api private + sig { returns(String) } + private def generate_idempotency_key + end + + # @api private + sig do + overridable + .params( + req: + Imagekitio::Internal::Transport::BaseClient::RequestComponents, + opts: Imagekitio::Internal::AnyHash + ) + .returns(Imagekitio::Internal::Transport::BaseClient::RequestInput) + end + private def build_request(req, opts) + end + + # @api private + sig do + params( + headers: T::Hash[String, String], + retry_count: Integer + ).returns(Float) + end + private def retry_delay(headers, retry_count:) + end + + # @api private + sig do + params( + request: Imagekitio::Internal::Transport::BaseClient::RequestInput, + redirect_count: Integer, + retry_count: Integer, + send_retry_header: T::Boolean + ).returns([Integer, Net::HTTPResponse, T::Enumerable[String]]) + end + def send_request( + request, + redirect_count:, + retry_count:, + send_retry_header: + ) + end + + # Execute the request specified by `req`. This is the method that all resource + # methods call into. + # + # @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: Imagekitio::Internal::Type::Unknown, options: {}) + sig do + params( + method: Symbol, + path: T.any(String, T::Array[String]), + query: + T.nilable( + T::Hash[String, T.nilable(T.any(T::Array[String], String))] + ), + headers: + T.nilable( + T::Hash[ + String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + ) + ] + ), + body: T.nilable(T.anything), + unwrap: + T.nilable( + T.any( + Symbol, + Integer, + T::Array[T.any(Symbol, Integer)], + T.proc.params(arg0: T.anything).returns(T.anything) + ) + ), + page: + T.nilable( + T::Class[ + Imagekitio::Internal::Type::BasePage[ + Imagekitio::Internal::Type::BaseModel + ] + ] + ), + stream: T.nilable(T::Class[T.anything]), + model: T.nilable(Imagekitio::Internal::Type::Converter::Input), + options: T.nilable(Imagekitio::RequestOptions::OrHash) + ).returns(T.anything) + end + def request( + method, + path, + query: {}, + headers: {}, + body: nil, + unwrap: nil, + page: nil, + stream: nil, + model: Imagekitio::Internal::Type::Unknown, + options: {} + ) + end + + # @api private + sig { returns(String) } + def inspect + end + end + end + end +end diff --git a/rbi/imagekitio/internal/transport/pooled_net_requester.rbi b/rbi/imagekitio/internal/transport/pooled_net_requester.rbi new file mode 100644 index 00000000..e0c582fd --- /dev/null +++ b/rbi/imagekitio/internal/transport/pooled_net_requester.rbi @@ -0,0 +1,80 @@ +# typed: strong + +module Imagekitio + module Internal + module Transport + # @api private + class PooledNetRequester + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + Request = + T.type_alias do + { + method: Symbol, + url: URI::Generic, + headers: T::Hash[String, String], + body: T.anything, + deadline: Float + } + end + + # from the golang stdlib + # https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49 + KEEP_ALIVE_TIMEOUT = 30 + + DEFAULT_MAX_CONNECTIONS = T.let(T.unsafe(nil), Integer) + + class << self + # @api private + sig { params(url: URI::Generic).returns(Net::HTTP) } + def connect(url) + end + + # @api private + sig { params(conn: Net::HTTP, deadline: Float).void } + def calibrate_socket_timeout(conn, deadline) + end + + # @api private + sig do + params( + request: + Imagekitio::Internal::Transport::PooledNetRequester::Request, + blk: T.proc.params(arg0: String).void + ).returns([Net::HTTPGenericRequest, T.proc.void]) + end + def build_request(request, &blk) + end + end + + # @api private + sig do + params( + url: URI::Generic, + deadline: Float, + blk: T.proc.params(arg0: Net::HTTP).void + ).void + end + private def with_pool(url, deadline:, &blk) + end + + # @api private + sig do + params( + request: + Imagekitio::Internal::Transport::PooledNetRequester::Request + ).returns([Integer, Net::HTTPResponse, T::Enumerable[String]]) + end + def execute(request) + end + + # @api private + sig { params(size: Integer).returns(T.attached_class) } + def self.new( + size: Imagekitio::Internal::Transport::PooledNetRequester::DEFAULT_MAX_CONNECTIONS + ) + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/array_of.rbi b/rbi/imagekitio/internal/type/array_of.rbi new file mode 100644 index 00000000..7930d3ca --- /dev/null +++ b/rbi/imagekitio/internal/type/array_of.rbi @@ -0,0 +1,104 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + # + # Array of items of a given type. + class ArrayOf + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + abstract! + + Elem = type_member(:out) + + sig do + params( + type_info: + T.any( + Imagekitio::Internal::AnyHash, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ), + spec: Imagekitio::Internal::AnyHash + ).returns(T.attached_class) + end + def self.[](type_info, spec = {}) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + # @api private + sig do + override + .params( + value: T.any(T::Array[T.anything], T.anything), + state: Imagekitio::Internal::Type::Converter::CoerceState + ) + .returns(T.any(T::Array[T.anything], T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(T::Array[T.anything], T.anything), + state: Imagekitio::Internal::Type::Converter::DumpState + ) + .returns(T.any(T::Array[T.anything], T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + # @api private + sig { returns(Elem) } + protected def item_type + end + + # @api private + sig { returns(T::Boolean) } + protected def nilable? + end + + # @api private + sig do + params( + type_info: + T.any( + Imagekitio::Internal::AnyHash, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ), + spec: Imagekitio::Internal::AnyHash + ).void + end + def initialize(type_info, spec = {}) + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/base_model.rbi b/rbi/imagekitio/internal/type/base_model.rbi new file mode 100644 index 00000000..c8686a20 --- /dev/null +++ b/rbi/imagekitio/internal/type/base_model.rbi @@ -0,0 +1,304 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + class BaseModel + extend Imagekitio::Internal::Type::Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + abstract! + + KnownField = + T.type_alias do + { + mode: T.nilable(Symbol), + required: T::Boolean, + nilable: T::Boolean + } + end + + OrHash = + T.type_alias do + T.any( + Imagekitio::Internal::Type::BaseModel, + Imagekitio::Internal::AnyHash + ) + end + + class << self + # @api private + # + # Assumes superclass fields are totally defined before fields are accessed / + # defined on subclasses. + sig { params(child: T.self_type).void } + def inherited(child) + end + + # @api private + sig do + returns( + T::Hash[ + Symbol, + T.all( + Imagekitio::Internal::Type::BaseModel::KnownField, + { + type_fn: + T.proc.returns( + Imagekitio::Internal::Type::Converter::Input + ) + } + ) + ] + ) + end + def known_fields + end + + # @api private + sig do + returns( + T::Hash[ + Symbol, + T.all( + Imagekitio::Internal::Type::BaseModel::KnownField, + { type: Imagekitio::Internal::Type::Converter::Input } + ) + ] + ) + end + def fields + end + + # @api private + sig do + params( + name_sym: Symbol, + required: T::Boolean, + type_info: + T.any( + { + const: + T.nilable( + T.any(NilClass, T::Boolean, Integer, Float, Symbol) + ), + enum: + T.nilable( + T.proc.returns( + Imagekitio::Internal::Type::Converter::Input + ) + ), + union: + T.nilable( + T.proc.returns( + Imagekitio::Internal::Type::Converter::Input + ) + ), + api_name: Symbol, + nil?: T::Boolean + }, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ), + spec: Imagekitio::Internal::AnyHash + ).void + end + private def add_field(name_sym, required:, type_info:, spec:) + end + + # @api private + sig do + params( + name_sym: Symbol, + type_info: + T.any( + Imagekitio::Internal::AnyHash, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ), + spec: Imagekitio::Internal::AnyHash + ).void + end + def required(name_sym, type_info, spec = {}) + end + + # @api private + sig do + params( + name_sym: Symbol, + type_info: + T.any( + Imagekitio::Internal::AnyHash, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ), + spec: Imagekitio::Internal::AnyHash + ).void + end + def optional(name_sym, type_info, spec = {}) + end + + # @api private + # + # `request_only` attributes not excluded from `.#coerce` when receiving responses + # even if well behaved servers should not send them + sig { params(blk: T.proc.void).void } + private def request_only(&blk) + end + + # @api private + # + # `response_only` attributes are omitted from `.#dump` when making requests + sig { params(blk: T.proc.void).void } + private def response_only(&blk) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + class << self + # @api private + sig do + override + .params( + value: + T.any( + Imagekitio::Internal::Type::BaseModel, + T::Hash[T.anything, T.anything], + T.anything + ), + state: Imagekitio::Internal::Type::Converter::CoerceState + ) + .returns(T.any(T.attached_class, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(T.attached_class, T.anything), + state: Imagekitio::Internal::Type::Converter::DumpState + ) + .returns(T.any(T::Hash[T.anything, T.anything], T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + end + + class << self + # @api private + sig do + params( + model: Imagekitio::Internal::Type::BaseModel, + convert: T::Boolean + ).returns(Imagekitio::Internal::AnyHash) + end + def recursively_to_h(model, convert:) + end + end + + # Returns the raw value associated with the given key, if found. Otherwise, nil is + # returned. + # + # It is valid to lookup keys that are not in the API spec, for example to access + # undocumented features. This method does not parse response data into + # higher-level types. Lookup by anything other than a Symbol is an ArgumentError. + sig { params(key: Symbol).returns(T.nilable(T.anything)) } + def [](key) + end + + # Returns a Hash of the data underlying this object. O(1) + # + # Keys are Symbols and values are the raw values from the response. The return + # value indicates which values were ever set on the object. i.e. there will be a + # key in this hash if they ever were, even if the set value was nil. + # + # This method is not recursive. The returned value is shared by the object, so it + # should not be mutated. + sig { overridable.returns(Imagekitio::Internal::AnyHash) } + def to_h + end + + # Returns a Hash of the data underlying this object. O(1) + # + # Keys are Symbols and values are the raw values from the response. The return + # value indicates which values were ever set on the object. i.e. there will be a + # key in this hash if they ever were, even if the set value was nil. + # + # This method is not recursive. The returned value is shared by the object, so it + # should not be mutated. + sig { overridable.returns(Imagekitio::Internal::AnyHash) } + def to_hash + end + + # In addition to the behaviour of `#to_h`, this method will recursively call + # `#to_h` on nested models. + sig { overridable.returns(Imagekitio::Internal::AnyHash) } + def deep_to_h + end + + sig do + params(keys: T.nilable(T::Array[Symbol])).returns( + Imagekitio::Internal::AnyHash + ) + end + def deconstruct_keys(keys) + end + + sig { params(a: T.anything).returns(String) } + def to_json(*a) + end + + sig { params(a: T.anything).returns(String) } + def to_yaml(*a) + end + + # Create a new instance of a model. + sig do + params(data: T.any(T::Hash[Symbol, T.anything], T.self_type)).returns( + T.attached_class + ) + end + def self.new(data = {}) + end + + class << self + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + + sig { returns(String) } + def to_s + end + + # @api private + sig { returns(String) } + def inspect + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/base_page.rbi b/rbi/imagekitio/internal/type/base_page.rbi new file mode 100644 index 00000000..6fcae4da --- /dev/null +++ b/rbi/imagekitio/internal/type/base_page.rbi @@ -0,0 +1,42 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + # + # This module provides a base implementation for paginated responses in the SDK. + module BasePage + Elem = type_member(:out) + + sig { overridable.returns(T::Boolean) } + def next_page? + end + + sig { overridable.returns(T.self_type) } + def next_page + end + + sig { overridable.params(blk: T.proc.params(arg0: Elem).void).void } + def auto_paging_each(&blk) + end + + sig { returns(T::Enumerable[Elem]) } + def to_enum + end + + # @api private + sig do + params( + client: Imagekitio::Internal::Transport::BaseClient, + req: Imagekitio::Internal::Transport::BaseClient::RequestComponents, + headers: T::Hash[String, String], + page_data: T.anything + ).void + end + def initialize(client:, req:, headers:, page_data:) + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/boolean.rbi b/rbi/imagekitio/internal/type/boolean.rbi new file mode 100644 index 00000000..e419242a --- /dev/null +++ b/rbi/imagekitio/internal/type/boolean.rbi @@ -0,0 +1,58 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + # + # Ruby has no Boolean class; this is something for models to refer to. + class Boolean + extend Imagekitio::Internal::Type::Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + abstract! + + sig { params(other: T.anything).returns(T::Boolean) } + def self.===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def self.==(other) + end + + class << self + # @api private + # + # Coerce value to Boolean if possible, otherwise return the original value. + sig do + override + .params( + value: T.any(T::Boolean, T.anything), + state: Imagekitio::Internal::Type::Converter::CoerceState + ) + .returns(T.any(T::Boolean, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(T::Boolean, T.anything), + state: Imagekitio::Internal::Type::Converter::DumpState + ) + .returns(T.any(T::Boolean, T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/converter.rbi b/rbi/imagekitio/internal/type/converter.rbi new file mode 100644 index 00000000..773dabe4 --- /dev/null +++ b/rbi/imagekitio/internal/type/converter.rbi @@ -0,0 +1,216 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + module Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + Input = + T.type_alias do + T.any(Imagekitio::Internal::Type::Converter, T::Class[T.anything]) + end + + CoerceState = + T.type_alias do + { + translate_names: T::Boolean, + strictness: T::Boolean, + exactness: { + yes: Integer, + no: Integer, + maybe: Integer + }, + error: T::Class[StandardError], + branched: Integer + } + end + + DumpState = T.type_alias { { can_retry: T::Boolean } } + + # @api private + sig do + overridable + .params( + value: T.anything, + state: Imagekitio::Internal::Type::Converter::CoerceState + ) + .returns(T.anything) + end + def coerce(value, state:) + end + + # @api private + sig do + overridable + .params( + value: T.anything, + state: Imagekitio::Internal::Type::Converter::DumpState + ) + .returns(T.anything) + end + def dump(value, state:) + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + + class << self + # @api private + sig do + params( + spec: + T.any( + { + const: + T.nilable( + T.any(NilClass, T::Boolean, Integer, Float, Symbol) + ), + enum: + T.nilable( + T.proc.returns( + Imagekitio::Internal::Type::Converter::Input + ) + ), + union: + T.nilable( + T.proc.returns( + Imagekitio::Internal::Type::Converter::Input + ) + ) + }, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ) + ).returns(T.proc.returns(T.anything)) + end + def self.type_info(spec) + end + + # @api private + sig do + params( + type_info: + T.any( + { + const: + T.nilable( + T.any(NilClass, T::Boolean, Integer, Float, Symbol) + ), + enum: + T.nilable( + T.proc.returns( + Imagekitio::Internal::Type::Converter::Input + ) + ), + union: + T.nilable( + T.proc.returns( + Imagekitio::Internal::Type::Converter::Input + ) + ) + }, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ), + spec: + T.any( + { + const: + T.nilable( + T.any(NilClass, T::Boolean, Integer, Float, Symbol) + ), + enum: + T.nilable( + T.proc.returns( + Imagekitio::Internal::Type::Converter::Input + ) + ), + union: + T.nilable( + T.proc.returns( + Imagekitio::Internal::Type::Converter::Input + ) + ) + }, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ) + ).returns(Imagekitio::Internal::AnyHash) + end + def self.meta_info(type_info, spec) + end + + # @api private + sig do + params(translate_names: T::Boolean).returns( + Imagekitio::Internal::Type::Converter::CoerceState + ) + end + def self.new_coerce_state(translate_names: true) + end + + # @api private + # + # Based on `target`, transform `value` into `target`, to the extent possible: + # + # 1. if the given `value` conforms to `target` already, return the given `value` + # 2. if it's possible and safe to convert the given `value` to `target`, then the + # converted value + # 3. otherwise, the given `value` unaltered + # + # The coercion process is subject to improvement between minor release versions. + # See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode + sig do + params( + target: Imagekitio::Internal::Type::Converter::Input, + value: T.anything, + state: Imagekitio::Internal::Type::Converter::CoerceState + ).returns(T.anything) + end + def self.coerce( + target, + value, + # The `strictness` is one of `true`, `false`. This informs the coercion strategy + # when we have to decide between multiple possible conversion targets: + # + # - `true`: the conversion must be exact, with minimum coercion. + # - `false`: the conversion can be approximate, with some coercion. + # + # The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For + # any given conversion attempt, the exactness will be updated based on how closely + # the value recursively matches the target type: + # + # - `yes`: the value can be converted to the target type with minimum coercion. + # - `maybe`: the value can be converted to the target type with some reasonable + # coercion. + # - `no`: the value cannot be converted to the target type. + # + # See implementation below for more details. + state: Imagekitio::Internal::Type::Converter.new_coerce_state + ) + end + + # @api private + sig do + params( + target: Imagekitio::Internal::Type::Converter::Input, + value: T.anything, + state: Imagekitio::Internal::Type::Converter::DumpState + ).returns(T.anything) + end + def self.dump(target, value, state: { can_retry: true }) + end + + # @api private + sig { params(target: T.anything, depth: Integer).returns(String) } + def self.inspect(target, depth:) + end + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/enum.rbi b/rbi/imagekitio/internal/type/enum.rbi new file mode 100644 index 00000000..781fd8d2 --- /dev/null +++ b/rbi/imagekitio/internal/type/enum.rbi @@ -0,0 +1,82 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + # + # A value from among a specified list of options. OpenAPI enum values map to Ruby + # values in the SDK as follows: + # + # 1. boolean => true | false + # 2. integer => Integer + # 3. float => Float + # 4. string => Symbol + # + # We can therefore convert string values to Symbols, but can't convert other + # values safely. + module Enum + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + # All of the valid Symbol values for this enum. + sig do + overridable.returns( + T::Array[T.any(NilClass, T::Boolean, Integer, Float, Symbol)] + ) + end + def values + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + # @api private + # + # Unlike with primitives, `Enum` additionally validates that the value is a member + # of the enum. + sig do + override + .params( + value: T.any(String, Symbol, T.anything), + state: Imagekitio::Internal::Type::Converter::CoerceState + ) + .returns(T.any(Symbol, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(Symbol, T.anything), + state: Imagekitio::Internal::Type::Converter::DumpState + ) + .returns(T.any(Symbol, T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/file_input.rbi b/rbi/imagekitio/internal/type/file_input.rbi new file mode 100644 index 00000000..13bdf4cf --- /dev/null +++ b/rbi/imagekitio/internal/type/file_input.rbi @@ -0,0 +1,59 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + # + # Either `Pathname` or `StringIO`, or `IO`, or + # `Imagekitio::Internal::Type::FileInput`. + # + # Note: when `IO` is used, all retries are disabled, since many IO` streams are + # not rewindable. + class FileInput + extend Imagekitio::Internal::Type::Converter + + abstract! + + sig { params(other: T.anything).returns(T::Boolean) } + def self.===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def self.==(other) + end + + class << self + # @api private + sig do + override + .params( + value: T.any(StringIO, String, T.anything), + state: Imagekitio::Internal::Type::Converter::CoerceState + ) + .returns(T.any(StringIO, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(Pathname, StringIO, IO, String, T.anything), + state: Imagekitio::Internal::Type::Converter::DumpState + ) + .returns(T.any(Pathname, StringIO, IO, String, T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/hash_of.rbi b/rbi/imagekitio/internal/type/hash_of.rbi new file mode 100644 index 00000000..00a7d1d0 --- /dev/null +++ b/rbi/imagekitio/internal/type/hash_of.rbi @@ -0,0 +1,104 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + # + # Hash of items of a given type. + class HashOf + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + abstract! + + Elem = type_member(:out) + + sig do + params( + type_info: + T.any( + Imagekitio::Internal::AnyHash, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ), + spec: Imagekitio::Internal::AnyHash + ).returns(T.attached_class) + end + def self.[](type_info, spec = {}) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + # @api private + sig do + override + .params( + value: T.any(T::Hash[T.anything, T.anything], T.anything), + state: Imagekitio::Internal::Type::Converter::CoerceState + ) + .returns(T.any(Imagekitio::Internal::AnyHash, T.anything)) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.any(T::Hash[T.anything, T.anything], T.anything), + state: Imagekitio::Internal::Type::Converter::DumpState + ) + .returns(T.any(Imagekitio::Internal::AnyHash, T.anything)) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + # @api private + sig { returns(Elem) } + protected def item_type + end + + # @api private + sig { returns(T::Boolean) } + protected def nilable? + end + + # @api private + sig do + params( + type_info: + T.any( + Imagekitio::Internal::AnyHash, + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::Type::Converter::Input + ), + spec: Imagekitio::Internal::AnyHash + ).void + end + def initialize(type_info, spec = {}) + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/request_parameters.rbi b/rbi/imagekitio/internal/type/request_parameters.rbi new file mode 100644 index 00000000..4937893f --- /dev/null +++ b/rbi/imagekitio/internal/type/request_parameters.rbi @@ -0,0 +1,29 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + module RequestParameters + # Options to specify HTTP behaviour for this request. + sig { returns(Imagekitio::RequestOptions) } + attr_reader :request_options + + sig { params(request_options: Imagekitio::RequestOptions::OrHash).void } + attr_writer :request_options + + # @api private + module Converter + # @api private + sig do + params(params: T.anything).returns( + [T.anything, Imagekitio::Internal::AnyHash] + ) + end + def dump_request(params) + end + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/union.rbi b/rbi/imagekitio/internal/type/union.rbi new file mode 100644 index 00000000..149a3325 --- /dev/null +++ b/rbi/imagekitio/internal/type/union.rbi @@ -0,0 +1,128 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + module Union + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + # @api private + # + # All of the specified variant info for this union. + sig do + returns( + T::Array[ + [ + T.nilable(Symbol), + T.proc.returns(Imagekitio::Internal::Type::Converter::Input), + Imagekitio::Internal::AnyHash + ] + ] + ) + end + private def known_variants + end + + # @api private + sig do + returns( + T::Array[ + [T.nilable(Symbol), T.anything, Imagekitio::Internal::AnyHash] + ] + ) + end + protected def derefed_variants + end + + # All of the specified variants for this union. + sig { overridable.returns(T::Array[T.anything]) } + def variants + end + + # @api private + sig { params(property: Symbol).void } + private def discriminator(property) + end + + # @api private + sig do + params( + key: + T.any( + Symbol, + Imagekitio::Internal::AnyHash, + T.proc.returns(T.anything), + T.anything + ), + spec: + T.any( + Imagekitio::Internal::AnyHash, + T.proc.returns(T.anything), + T.anything + ) + ).void + end + private def variant(key, spec = nil) + end + + # @api private + sig { params(value: T.anything).returns(T.nilable(T.anything)) } + private def resolve_variant(value) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def ==(other) + end + + sig { returns(Integer) } + def hash + end + + # @api private + # + # Tries to efficiently coerce the given value to one of the known variants. + # + # If the value cannot match any of the known variants, the coercion is considered + # non-viable and returns the original value. + sig do + override + .params( + value: T.anything, + state: Imagekitio::Internal::Type::Converter::CoerceState + ) + .returns(T.anything) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.anything, + state: Imagekitio::Internal::Type::Converter::DumpState + ) + .returns(T.anything) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + # @api private + sig { params(depth: Integer).returns(String) } + def inspect(depth: 0) + end + end + end + end +end diff --git a/rbi/imagekitio/internal/type/unknown.rbi b/rbi/imagekitio/internal/type/unknown.rbi new file mode 100644 index 00000000..404914b3 --- /dev/null +++ b/rbi/imagekitio/internal/type/unknown.rbi @@ -0,0 +1,58 @@ +# typed: strong + +module Imagekitio + module Internal + module Type + # @api private + # + # When we don't know what to expect for the value. + class Unknown + extend Imagekitio::Internal::Type::Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + abstract! + + sig { params(other: T.anything).returns(T::Boolean) } + def self.===(other) + end + + sig { params(other: T.anything).returns(T::Boolean) } + def self.==(other) + end + + class << self + # @api private + # + # No coercion needed for Unknown type. + sig do + override + .params( + value: T.anything, + state: Imagekitio::Internal::Type::Converter::CoerceState + ) + .returns(T.anything) + end + def coerce(value, state:) + end + + # @api private + sig do + override + .params( + value: T.anything, + state: Imagekitio::Internal::Type::Converter::DumpState + ) + .returns(T.anything) + end + def dump(value, state:) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + end + end + end + end +end diff --git a/rbi/imagekitio/internal/util.rbi b/rbi/imagekitio/internal/util.rbi new file mode 100644 index 00000000..9fbebf93 --- /dev/null +++ b/rbi/imagekitio/internal/util.rbi @@ -0,0 +1,487 @@ +# typed: strong + +module Imagekitio + module Internal + # @api private + module Util + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + # @api private + sig { returns(Float) } + def self.monotonic_secs + end + + # @api private + sig do + params(ns: T.any(Module, T::Class[T.anything])).returns( + T::Enumerable[T.any(Module, T::Class[T.anything])] + ) + end + def self.walk_namespaces(ns) + end + + class << self + # @api private + sig { returns(String) } + def arch + end + + # @api private + sig { returns(String) } + def os + end + end + + class << self + # @api private + sig { params(input: T.anything).returns(T::Boolean) } + def primitive?(input) + end + + # @api private + sig do + params(input: T.any(String, T::Boolean)).returns( + T.any(T::Boolean, T.anything) + ) + end + def coerce_boolean(input) + end + + # @api private + sig do + params(input: T.any(String, T::Boolean)).returns( + T.nilable(T::Boolean) + ) + end + def coerce_boolean!(input) + end + + # @api private + sig do + params(input: T.any(String, Integer)).returns( + T.any(Integer, T.anything) + ) + end + def coerce_integer(input) + end + + # @api private + sig do + params(input: T.any(String, Integer, Float)).returns( + T.any(Float, T.anything) + ) + end + def coerce_float(input) + end + + # @api private + sig do + params(input: T.anything).returns( + T.any(T::Hash[T.anything, T.anything], T.anything) + ) + end + def coerce_hash(input) + end + + # @api private + sig do + params(input: T.anything).returns( + T.nilable(T::Hash[T.anything, T.anything]) + ) + end + def coerce_hash!(input) + end + end + + class << self + # @api private + sig do + params(lhs: T.anything, rhs: T.anything, concat: T::Boolean).returns( + T.anything + ) + end + private def deep_merge_lr(lhs, rhs, concat: false) + end + + # @api private + # + # Recursively merge one hash with another. If the values at a given key are not + # both hashes, just take the new value. + sig do + params( + values: T::Array[T.anything], + sentinel: T.nilable(T.anything), + concat: T::Boolean + ).returns(T.anything) + end + def deep_merge( + *values, + # the value to return if no values are provided. + sentinel: nil, + # whether to merge sequences by concatenation. + concat: false + ) + end + + # @api private + sig do + params( + data: + T.any( + Imagekitio::Internal::AnyHash, + T::Array[T.anything], + T.anything + ), + pick: + T.nilable( + T.any( + Symbol, + Integer, + T::Array[T.any(Symbol, Integer)], + T.proc.params(arg0: T.anything).returns(T.anything) + ) + ), + blk: T.nilable(T.proc.returns(T.anything)) + ).returns(T.nilable(T.anything)) + end + def dig(data, pick, &blk) + end + end + + class << self + # @api private + sig { params(uri: URI::Generic).returns(String) } + def uri_origin(uri) + end + + # @api private + sig { params(path: T.any(String, T::Array[String])).returns(String) } + def interpolate_path(path) + end + end + + class << self + # @api private + sig do + params(query: T.nilable(String)).returns( + T::Hash[String, T::Array[String]] + ) + end + def decode_query(query) + end + + # @api private + sig do + params( + query: + T.nilable( + T::Hash[String, T.nilable(T.any(T::Array[String], String))] + ) + ).returns(T.nilable(String)) + end + def encode_query(query) + end + end + + ParsedUri = + T.type_alias do + { + scheme: T.nilable(String), + host: T.nilable(String), + port: T.nilable(Integer), + path: T.nilable(String), + query: T::Hash[String, T::Array[String]] + } + end + + class << self + # @api private + sig do + params(url: T.any(URI::Generic, String)).returns( + Imagekitio::Internal::Util::ParsedUri + ) + end + def parse_uri(url) + end + + # @api private + sig do + params(parsed: Imagekitio::Internal::Util::ParsedUri).returns( + URI::Generic + ) + end + def unparse_uri(parsed) + end + + # @api private + sig do + params( + lhs: Imagekitio::Internal::Util::ParsedUri, + rhs: Imagekitio::Internal::Util::ParsedUri + ).returns(URI::Generic) + end + def join_parsed_uri(lhs, rhs) + end + end + + class << self + # @api private + sig do + params( + headers: + T::Hash[ + String, + T.nilable( + T.any( + String, + Integer, + T::Array[T.nilable(T.any(String, Integer))] + ) + ) + ] + ).returns(T::Hash[String, String]) + end + def normalized_headers(*headers) + end + end + + # @api private + # + # An adapter that satisfies the IO interface required by `::IO.copy_stream` + class ReadIOAdapter + # @api private + sig { returns(T.nilable(T::Boolean)) } + def close? + end + + # @api private + sig { void } + def close + end + + # @api private + sig { params(max_len: T.nilable(Integer)).returns(String) } + private def read_enum(max_len) + end + + # @api private + sig do + params( + max_len: T.nilable(Integer), + out_string: T.nilable(String) + ).returns(T.nilable(String)) + end + def read(max_len = nil, out_string = nil) + end + + # @api private + sig do + params( + src: T.any(String, Pathname, StringIO, T::Enumerable[String]), + blk: T.proc.params(arg0: String).void + ).returns(T.attached_class) + end + def self.new(src, &blk) + end + end + + class << self + sig do + params(blk: T.proc.params(y: Enumerator::Yielder).void).returns( + T::Enumerable[String] + ) + end + def writable_enum(&blk) + end + end + + JSON_CONTENT = + T.let(%r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)}, Regexp) + JSONL_CONTENT = + T.let(%r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}, Regexp) + + class << self + # @api private + sig do + params( + y: Enumerator::Yielder, + val: T.anything, + closing: T::Array[T.proc.void], + content_type: T.nilable(String) + ).void + end + private def write_multipart_content( + y, + val:, + closing:, + content_type: nil + ) + end + + # @api private + sig do + params( + y: Enumerator::Yielder, + boundary: String, + key: T.any(Symbol, String), + val: T.anything, + closing: T::Array[T.proc.void] + ).void + end + private def write_multipart_chunk(y, boundary:, key:, val:, closing:) + end + + # @api private + # + # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content + sig do + params(body: T.anything).returns([String, T::Enumerable[String]]) + end + private def encode_multipart_streaming(body) + end + + # @api private + sig do + params(headers: T::Hash[String, String], body: T.anything).returns( + T.anything + ) + end + def encode_content(headers, body) + end + + # @api private + # + # https://www.iana.org/assignments/character-sets/character-sets.xhtml + sig { params(content_type: String, text: String).void } + def force_charset!(content_type, text:) + end + + # @api private + # + # Assumes each chunk in stream has `Encoding::BINARY`. + sig do + params( + headers: T::Hash[String, String], + stream: T::Enumerable[String], + suppress_error: T::Boolean + ).returns(T.anything) + end + def decode_content(headers, stream:, suppress_error: false) + end + end + + class << self + # @api private + # + # https://doc.rust-lang.org/std/iter/trait.FusedIterator.html + sig do + params( + enum: T::Enumerable[T.anything], + external: T::Boolean, + close: T.proc.void + ).returns(T::Enumerable[T.anything]) + end + def fused_enum(enum, external: false, &close) + end + + # @api private + sig { params(enum: T.nilable(T::Enumerable[T.anything])).void } + def close_fused!(enum) + end + + # @api private + sig do + params( + enum: T.nilable(T::Enumerable[T.anything]), + blk: T.proc.params(arg0: Enumerator::Yielder).void + ).returns(T::Enumerable[T.anything]) + end + def chain_fused(enum, &blk) + end + end + + ServerSentEvent = + T.type_alias do + { + event: T.nilable(String), + data: T.nilable(String), + id: T.nilable(String), + retry: T.nilable(Integer) + } + end + + class << self + # @api private + # + # Assumes Strings have been forced into having `Encoding::BINARY`. + # + # This decoder is responsible for reassembling lines split across multiple + # fragments. + sig do + params(enum: T::Enumerable[String]).returns(T::Enumerable[String]) + end + def decode_lines(enum) + end + + # @api private + # + # https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream + # + # Assumes that `lines` has been decoded with `#decode_lines`. + sig do + params(lines: T::Enumerable[String]).returns( + T::Enumerable[Imagekitio::Internal::Util::ServerSentEvent] + ) + end + def decode_sse(lines) + end + end + + # @api private + module SorbetRuntimeSupport + class MissingSorbetRuntimeError < ::RuntimeError + end + + # @api private + sig { returns(T::Hash[Symbol, T.anything]) } + private def sorbet_runtime_constants + end + + # @api private + sig { params(name: Symbol).void } + def const_missing(name) + end + + # @api private + sig { params(name: Symbol).returns(T::Boolean) } + def sorbet_constant_defined?(name) + end + + # @api private + sig { params(name: Symbol, blk: T.proc.returns(T.anything)).void } + def define_sorbet_constant!(name, &blk) + end + + # @api private + sig { returns(T.anything) } + def to_sorbet_type + end + + class << self + # @api private + sig do + params( + type: + T.any( + Imagekitio::Internal::Util::SorbetRuntimeSupport, + T.anything + ) + ).returns(T.anything) + end + def to_sorbet_type(type) + end + end + end + end + end +end diff --git a/rbi/imagekitio/models.rbi b/rbi/imagekitio/models.rbi new file mode 100644 index 00000000..5e425cc7 --- /dev/null +++ b/rbi/imagekitio/models.rbi @@ -0,0 +1,135 @@ +# typed: strong + +module Imagekitio + Accounts = Imagekitio::Models::Accounts + + AssetListParams = Imagekitio::Models::AssetListParams + + BaseOverlay = Imagekitio::Models::BaseOverlay + + BaseWebhookEvent = Imagekitio::Models::BaseWebhookEvent + + Beta = Imagekitio::Models::Beta + + Cache = Imagekitio::Models::Cache + + CustomMetadataField = Imagekitio::Models::CustomMetadataField + + CustomMetadataFieldCreateParams = + Imagekitio::Models::CustomMetadataFieldCreateParams + + CustomMetadataFieldDeleteParams = + Imagekitio::Models::CustomMetadataFieldDeleteParams + + CustomMetadataFieldListParams = + Imagekitio::Models::CustomMetadataFieldListParams + + CustomMetadataFieldUpdateParams = + Imagekitio::Models::CustomMetadataFieldUpdateParams + + ExtensionItem = Imagekitio::Models::ExtensionItem + + Extensions = + T.let(Imagekitio::Models::Extensions, Imagekitio::Internal::Type::Converter) + + File = Imagekitio::Models::File + + FileCopyParams = Imagekitio::Models::FileCopyParams + + FileDeleteParams = Imagekitio::Models::FileDeleteParams + + FileGetParams = Imagekitio::Models::FileGetParams + + FileMoveParams = Imagekitio::Models::FileMoveParams + + FileRenameParams = Imagekitio::Models::FileRenameParams + + Files = Imagekitio::Models::Files + + FileUpdateParams = Imagekitio::Models::FileUpdateParams + + FileUploadParams = Imagekitio::Models::FileUploadParams + + Folder = Imagekitio::Models::Folder + + FolderCopyParams = Imagekitio::Models::FolderCopyParams + + FolderCreateParams = Imagekitio::Models::FolderCreateParams + + FolderDeleteParams = Imagekitio::Models::FolderDeleteParams + + FolderMoveParams = Imagekitio::Models::FolderMoveParams + + FolderRenameParams = Imagekitio::Models::FolderRenameParams + + Folders = Imagekitio::Models::Folders + + GetImageAttributesOptions = Imagekitio::Models::GetImageAttributesOptions + + ImageOverlay = Imagekitio::Models::ImageOverlay + + Metadata = Imagekitio::Models::Metadata + + Overlay = Imagekitio::Models::Overlay + + OverlayPosition = Imagekitio::Models::OverlayPosition + + OverlayTiming = Imagekitio::Models::OverlayTiming + + ResponsiveImageAttributes = Imagekitio::Models::ResponsiveImageAttributes + + SolidColorOverlay = Imagekitio::Models::SolidColorOverlay + + SolidColorOverlayTransformation = + Imagekitio::Models::SolidColorOverlayTransformation + + SrcOptions = Imagekitio::Models::SrcOptions + + StreamingResolution = Imagekitio::Models::StreamingResolution + + SubtitleOverlay = Imagekitio::Models::SubtitleOverlay + + SubtitleOverlayTransformation = + Imagekitio::Models::SubtitleOverlayTransformation + + TextOverlay = Imagekitio::Models::TextOverlay + + TextOverlayTransformation = Imagekitio::Models::TextOverlayTransformation + + Transformation = Imagekitio::Models::Transformation + + TransformationPosition = Imagekitio::Models::TransformationPosition + + UnsafeUnwrapWebhookEvent = Imagekitio::Models::UnsafeUnwrapWebhookEvent + + UnwrapWebhookEvent = Imagekitio::Models::UnwrapWebhookEvent + + UpdateFileRequest = Imagekitio::Models::UpdateFileRequest + + UploadPostTransformErrorEvent = + Imagekitio::Models::UploadPostTransformErrorEvent + + UploadPostTransformSuccessEvent = + Imagekitio::Models::UploadPostTransformSuccessEvent + + UploadPreTransformErrorEvent = + Imagekitio::Models::UploadPreTransformErrorEvent + + UploadPreTransformSuccessEvent = + Imagekitio::Models::UploadPreTransformSuccessEvent + + VideoOverlay = Imagekitio::Models::VideoOverlay + + VideoTransformationAcceptedEvent = + Imagekitio::Models::VideoTransformationAcceptedEvent + + VideoTransformationErrorEvent = + Imagekitio::Models::VideoTransformationErrorEvent + + VideoTransformationReadyEvent = + Imagekitio::Models::VideoTransformationReadyEvent + + WebhookUnsafeUnwrapParams = Imagekitio::Models::WebhookUnsafeUnwrapParams + + WebhookUnwrapParams = Imagekitio::Models::WebhookUnwrapParams +end diff --git a/rbi/imagekitio/models/accounts/origin_create_params.rbi b/rbi/imagekitio/models/accounts/origin_create_params.rbi new file mode 100644 index 00000000..f8d241a4 --- /dev/null +++ b/rbi/imagekitio/models/accounts/origin_create_params.rbi @@ -0,0 +1,81 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class OriginCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginCreateParams, + Imagekitio::Internal::AnyHash + ) + end + + # Schema for origin request resources. + sig do + returns( + T.any( + Imagekitio::Accounts::OriginRequest::S3, + Imagekitio::Accounts::OriginRequest::S3Compatible, + Imagekitio::Accounts::OriginRequest::CloudinaryBackup, + Imagekitio::Accounts::OriginRequest::WebFolder, + Imagekitio::Accounts::OriginRequest::WebProxy, + Imagekitio::Accounts::OriginRequest::Gcs, + Imagekitio::Accounts::OriginRequest::AzureBlob, + Imagekitio::Accounts::OriginRequest::AkeneoPim + ) + ) + end + attr_accessor :origin_request + + sig do + params( + origin_request: + T.any( + Imagekitio::Accounts::OriginRequest::S3::OrHash, + Imagekitio::Accounts::OriginRequest::S3Compatible::OrHash, + Imagekitio::Accounts::OriginRequest::CloudinaryBackup::OrHash, + Imagekitio::Accounts::OriginRequest::WebFolder::OrHash, + Imagekitio::Accounts::OriginRequest::WebProxy::OrHash, + Imagekitio::Accounts::OriginRequest::Gcs::OrHash, + Imagekitio::Accounts::OriginRequest::AzureBlob::OrHash, + Imagekitio::Accounts::OriginRequest::AkeneoPim::OrHash + ), + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Schema for origin request resources. + origin_request:, + request_options: {} + ) + end + + sig do + override.returns( + { + origin_request: + T.any( + Imagekitio::Accounts::OriginRequest::S3, + Imagekitio::Accounts::OriginRequest::S3Compatible, + Imagekitio::Accounts::OriginRequest::CloudinaryBackup, + Imagekitio::Accounts::OriginRequest::WebFolder, + Imagekitio::Accounts::OriginRequest::WebProxy, + Imagekitio::Accounts::OriginRequest::Gcs, + Imagekitio::Accounts::OriginRequest::AzureBlob, + Imagekitio::Accounts::OriginRequest::AkeneoPim + ), + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/origin_delete_params.rbi b/rbi/imagekitio/models/accounts/origin_delete_params.rbi new file mode 100644 index 00000000..c01c6212 --- /dev/null +++ b/rbi/imagekitio/models/accounts/origin_delete_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class OriginDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginDeleteParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/origin_get_params.rbi b/rbi/imagekitio/models/accounts/origin_get_params.rbi new file mode 100644 index 00000000..0e37c3b0 --- /dev/null +++ b/rbi/imagekitio/models/accounts/origin_get_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class OriginGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginGetParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/origin_list_params.rbi b/rbi/imagekitio/models/accounts/origin_list_params.rbi new file mode 100644 index 00000000..0a757d4f --- /dev/null +++ b/rbi/imagekitio/models/accounts/origin_list_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class OriginListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginListParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/origin_list_response.rbi b/rbi/imagekitio/models/accounts/origin_list_response.rbi new file mode 100644 index 00000000..5830b885 --- /dev/null +++ b/rbi/imagekitio/models/accounts/origin_list_response.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + OriginListResponse = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + union: Imagekitio::Accounts::OriginResponse + ], + Imagekitio::Internal::Type::Converter + ) + end + end +end diff --git a/rbi/imagekitio/models/accounts/origin_request.rbi b/rbi/imagekitio/models/accounts/origin_request.rbi new file mode 100644 index 00000000..00020cf4 --- /dev/null +++ b/rbi/imagekitio/models/accounts/origin_request.rbi @@ -0,0 +1,775 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + # Schema for origin request resources. + module OriginRequest + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginRequest::S3, + Imagekitio::Accounts::OriginRequest::S3Compatible, + Imagekitio::Accounts::OriginRequest::CloudinaryBackup, + Imagekitio::Accounts::OriginRequest::WebFolder, + Imagekitio::Accounts::OriginRequest::WebProxy, + Imagekitio::Accounts::OriginRequest::Gcs, + Imagekitio::Accounts::OriginRequest::AzureBlob, + Imagekitio::Accounts::OriginRequest::AkeneoPim + ) + end + + class S3 < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginRequest::S3, + Imagekitio::Internal::AnyHash + ) + end + + # Access key for the bucket. + sig { returns(String) } + attr_accessor :access_key + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Secret key for the bucket. + sig { returns(String) } + attr_accessor :secret_key + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + # Path prefix inside the bucket. + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + sig do + params( + access_key: String, + bucket: String, + name: String, + secret_key: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Access key for the bucket. + access_key:, + # S3 bucket name. + bucket:, + # Display name of the origin. + name:, + # Secret key for the bucket. + secret_key:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + # Path prefix inside the bucket. + prefix: nil, + type: :S3 + ) + end + + sig do + override.returns( + { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String + } + ) + end + def to_hash + end + end + + class S3Compatible < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginRequest::S3Compatible, + Imagekitio::Internal::AnyHash + ) + end + + # Access key for the bucket. + sig { returns(String) } + attr_accessor :access_key + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Custom S3-compatible endpoint. + sig { returns(String) } + attr_accessor :endpoint + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Secret key for the bucket. + sig { returns(String) } + attr_accessor :secret_key + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + # Path prefix inside the bucket. + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + # Use path-style S3 URLs? + sig { returns(T.nilable(T::Boolean)) } + attr_reader :s3_force_path_style + + sig { params(s3_force_path_style: T::Boolean).void } + attr_writer :s3_force_path_style + + sig do + params( + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + s3_force_path_style: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Access key for the bucket. + access_key:, + # S3 bucket name. + bucket:, + # Custom S3-compatible endpoint. + endpoint:, + # Display name of the origin. + name:, + # Secret key for the bucket. + secret_key:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + # Path prefix inside the bucket. + prefix: nil, + # Use path-style S3 URLs? + s3_force_path_style: nil, + type: :S3_COMPATIBLE + ) + end + + sig do + override.returns( + { + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + s3_force_path_style: T::Boolean + } + ) + end + def to_hash + end + end + + class CloudinaryBackup < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginRequest::CloudinaryBackup, + Imagekitio::Internal::AnyHash + ) + end + + # Access key for the bucket. + sig { returns(String) } + attr_accessor :access_key + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Secret key for the bucket. + sig { returns(String) } + attr_accessor :secret_key + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + # Path prefix inside the bucket. + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + sig do + params( + access_key: String, + bucket: String, + name: String, + secret_key: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Access key for the bucket. + access_key:, + # S3 bucket name. + bucket:, + # Display name of the origin. + name:, + # Secret key for the bucket. + secret_key:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + # Path prefix inside the bucket. + prefix: nil, + type: :CLOUDINARY_BACKUP + ) + end + + sig do + override.returns( + { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String + } + ) + end + def to_hash + end + end + + class WebFolder < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginRequest::WebFolder, + Imagekitio::Internal::AnyHash + ) + end + + # Root URL for the web folder origin. + sig { returns(String) } + attr_accessor :base_url + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Forward the Host header to origin? + sig { returns(T.nilable(T::Boolean)) } + attr_reader :forward_host_header_to_origin + + sig { params(forward_host_header_to_origin: T::Boolean).void } + attr_writer :forward_host_header_to_origin + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig do + params( + base_url: String, + name: String, + base_url_for_canonical_header: String, + forward_host_header_to_origin: T::Boolean, + include_canonical_header: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Root URL for the web folder origin. + base_url:, + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Forward the Host header to origin? + forward_host_header_to_origin: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + type: :WEB_FOLDER + ) + end + + sig do + override.returns( + { + base_url: String, + name: String, + type: Symbol, + base_url_for_canonical_header: String, + forward_host_header_to_origin: T::Boolean, + include_canonical_header: T::Boolean + } + ) + end + def to_hash + end + end + + class WebProxy < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginRequest::WebProxy, + Imagekitio::Internal::AnyHash + ) + end + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig do + params( + name: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + type: :WEB_PROXY + ) + end + + sig do + override.returns( + { + name: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean + } + ) + end + def to_hash + end + end + + class Gcs < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginRequest::Gcs, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :bucket + + sig { returns(String) } + attr_accessor :client_email + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(String) } + attr_accessor :private_key + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + sig do + params( + bucket: String, + client_email: String, + name: String, + private_key: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + bucket:, + client_email:, + # Display name of the origin. + name:, + private_key:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + prefix: nil, + type: :GCS + ) + end + + sig do + override.returns( + { + bucket: String, + client_email: String, + name: String, + private_key: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String + } + ) + end + def to_hash + end + end + + class AzureBlob < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginRequest::AzureBlob, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :account_name + + sig { returns(String) } + attr_accessor :container + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(String) } + attr_accessor :sas_token + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig { returns(T.nilable(String)) } + attr_reader :prefix + + sig { params(prefix: String).void } + attr_writer :prefix + + sig do + params( + account_name: String, + container: String, + name: String, + sas_token: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + account_name:, + container:, + # Display name of the origin. + name:, + sas_token:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + prefix: nil, + type: :AZURE_BLOB + ) + end + + sig do + override.returns( + { + account_name: String, + container: String, + name: String, + sas_token: String, + type: Symbol, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + prefix: String + } + ) + end + def to_hash + end + end + + class AkeneoPim < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginRequest::AkeneoPim, + Imagekitio::Internal::AnyHash + ) + end + + # Akeneo instance base URL. + sig { returns(String) } + attr_accessor :base_url + + # Akeneo API client ID. + sig { returns(String) } + attr_accessor :client_id + + # Akeneo API client secret. + sig { returns(String) } + attr_accessor :client_secret + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Akeneo API password. + sig { returns(String) } + attr_accessor :password + + sig { returns(Symbol) } + attr_accessor :type + + # Akeneo API username. + sig { returns(String) } + attr_accessor :username + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Whether to send a Canonical header. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_canonical_header + + sig { params(include_canonical_header: T::Boolean).void } + attr_writer :include_canonical_header + + sig do + params( + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + username: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Akeneo instance base URL. + base_url:, + # Akeneo API client ID. + client_id:, + # Akeneo API client secret. + client_secret:, + # Display name of the origin. + name:, + # Akeneo API password. + password:, + # Akeneo API username. + username:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + # Whether to send a Canonical header. + include_canonical_header: nil, + type: :AKENEO_PIM + ) + end + + sig do + override.returns( + { + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + type: Symbol, + username: String, + base_url_for_canonical_header: String, + include_canonical_header: T::Boolean + } + ) + end + def to_hash + end + end + + sig do + override.returns( + T::Array[Imagekitio::Accounts::OriginRequest::Variants] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/origin_response.rbi b/rbi/imagekitio/models/accounts/origin_response.rbi new file mode 100644 index 00000000..d5eb1027 --- /dev/null +++ b/rbi/imagekitio/models/accounts/origin_response.rbi @@ -0,0 +1,718 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + # Origin object as returned by the API (sensitive fields removed). + module OriginResponse + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginResponse::S3, + Imagekitio::Accounts::OriginResponse::S3Compatible, + Imagekitio::Accounts::OriginResponse::CloudinaryBackup, + Imagekitio::Accounts::OriginResponse::WebFolder, + Imagekitio::Accounts::OriginResponse::WebProxy, + Imagekitio::Accounts::OriginResponse::Gcs, + Imagekitio::Accounts::OriginResponse::AzureBlob, + Imagekitio::Accounts::OriginResponse::AkeneoPim + ) + end + + class S3 < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginResponse::S3, + Imagekitio::Internal::AnyHash + ) + end + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Path prefix inside the bucket. + sig { returns(String) } + attr_accessor :prefix + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + bucket: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # S3 bucket name. + bucket:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # Path prefix inside the bucket. + prefix:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :S3 + ) + end + + sig do + override.returns( + { + id: String, + bucket: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class S3Compatible < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginResponse::S3Compatible, + Imagekitio::Internal::AnyHash + ) + end + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Custom S3-compatible endpoint. + sig { returns(String) } + attr_accessor :endpoint + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Path prefix inside the bucket. + sig { returns(String) } + attr_accessor :prefix + + # Use path-style S3 URLs? + sig { returns(T::Boolean) } + attr_accessor :s3_force_path_style + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + bucket: String, + endpoint: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + s3_force_path_style: T::Boolean, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # S3 bucket name. + bucket:, + # Custom S3-compatible endpoint. + endpoint:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # Path prefix inside the bucket. + prefix:, + # Use path-style S3 URLs? + s3_force_path_style:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :S3_COMPATIBLE + ) + end + + sig do + override.returns( + { + id: String, + bucket: String, + endpoint: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + s3_force_path_style: T::Boolean, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class CloudinaryBackup < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginResponse::CloudinaryBackup, + Imagekitio::Internal::AnyHash + ) + end + + # S3 bucket name. + sig { returns(String) } + attr_accessor :bucket + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + # Path prefix inside the bucket. + sig { returns(String) } + attr_accessor :prefix + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + bucket: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # S3 bucket name. + bucket:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # Path prefix inside the bucket. + prefix:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :CLOUDINARY_BACKUP + ) + end + + sig do + override.returns( + { + id: String, + bucket: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class WebFolder < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginResponse::WebFolder, + Imagekitio::Internal::AnyHash + ) + end + + # Root URL for the web folder origin. + sig { returns(String) } + attr_accessor :base_url + + # Forward the Host header to origin? + sig { returns(T::Boolean) } + attr_accessor :forward_host_header_to_origin + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + base_url: String, + forward_host_header_to_origin: T::Boolean, + include_canonical_header: T::Boolean, + name: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # Root URL for the web folder origin. + base_url:, + # Forward the Host header to origin? + forward_host_header_to_origin:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :WEB_FOLDER + ) + end + + sig do + override.returns( + { + id: String, + base_url: String, + forward_host_header_to_origin: T::Boolean, + include_canonical_header: T::Boolean, + name: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class WebProxy < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginResponse::WebProxy, + Imagekitio::Internal::AnyHash + ) + end + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + include_canonical_header: T::Boolean, + name: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :WEB_PROXY + ) + end + + sig do + override.returns( + { + id: String, + include_canonical_header: T::Boolean, + name: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class Gcs < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginResponse::Gcs, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :bucket + + sig { returns(String) } + attr_accessor :client_email + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(String) } + attr_accessor :prefix + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + bucket: String, + client_email: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + bucket:, + client_email:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + prefix:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :GCS + ) + end + + sig do + override.returns( + { + id: String, + bucket: String, + client_email: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class AzureBlob < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginResponse::AzureBlob, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :account_name + + sig { returns(String) } + attr_accessor :container + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(String) } + attr_accessor :prefix + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + account_name: String, + container: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + account_name:, + container:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + prefix:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :AZURE_BLOB + ) + end + + sig do + override.returns( + { + id: String, + account_name: String, + container: String, + include_canonical_header: T::Boolean, + name: String, + prefix: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + class AkeneoPim < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginResponse::AkeneoPim, + Imagekitio::Internal::AnyHash + ) + end + + # Akeneo instance base URL. + sig { returns(String) } + attr_accessor :base_url + + # Whether to send a Canonical header. + sig { returns(T::Boolean) } + attr_accessor :include_canonical_header + + # Display name of the origin. + sig { returns(String) } + attr_accessor :name + + sig { returns(Symbol) } + attr_accessor :type + + # URL used in the Canonical header (if enabled). + sig { returns(T.nilable(String)) } + attr_reader :base_url_for_canonical_header + + sig { params(base_url_for_canonical_header: String).void } + attr_writer :base_url_for_canonical_header + + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + sig { returns(String) } + attr_accessor :id + + sig do + params( + id: String, + base_url: String, + include_canonical_header: T::Boolean, + name: String, + base_url_for_canonical_header: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id:, + # Akeneo instance base URL. + base_url:, + # Whether to send a Canonical header. + include_canonical_header:, + # Display name of the origin. + name:, + # URL used in the Canonical header (if enabled). + base_url_for_canonical_header: nil, + type: :AKENEO_PIM + ) + end + + sig do + override.returns( + { + id: String, + base_url: String, + include_canonical_header: T::Boolean, + name: String, + type: Symbol, + base_url_for_canonical_header: String + } + ) + end + def to_hash + end + end + + sig do + override.returns( + T::Array[Imagekitio::Accounts::OriginResponse::Variants] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/origin_update_params.rbi b/rbi/imagekitio/models/accounts/origin_update_params.rbi new file mode 100644 index 00000000..276f6e66 --- /dev/null +++ b/rbi/imagekitio/models/accounts/origin_update_params.rbi @@ -0,0 +1,81 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class OriginUpdateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::OriginUpdateParams, + Imagekitio::Internal::AnyHash + ) + end + + # Schema for origin request resources. + sig do + returns( + T.any( + Imagekitio::Accounts::OriginRequest::S3, + Imagekitio::Accounts::OriginRequest::S3Compatible, + Imagekitio::Accounts::OriginRequest::CloudinaryBackup, + Imagekitio::Accounts::OriginRequest::WebFolder, + Imagekitio::Accounts::OriginRequest::WebProxy, + Imagekitio::Accounts::OriginRequest::Gcs, + Imagekitio::Accounts::OriginRequest::AzureBlob, + Imagekitio::Accounts::OriginRequest::AkeneoPim + ) + ) + end + attr_accessor :origin_request + + sig do + params( + origin_request: + T.any( + Imagekitio::Accounts::OriginRequest::S3::OrHash, + Imagekitio::Accounts::OriginRequest::S3Compatible::OrHash, + Imagekitio::Accounts::OriginRequest::CloudinaryBackup::OrHash, + Imagekitio::Accounts::OriginRequest::WebFolder::OrHash, + Imagekitio::Accounts::OriginRequest::WebProxy::OrHash, + Imagekitio::Accounts::OriginRequest::Gcs::OrHash, + Imagekitio::Accounts::OriginRequest::AzureBlob::OrHash, + Imagekitio::Accounts::OriginRequest::AkeneoPim::OrHash + ), + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Schema for origin request resources. + origin_request:, + request_options: {} + ) + end + + sig do + override.returns( + { + origin_request: + T.any( + Imagekitio::Accounts::OriginRequest::S3, + Imagekitio::Accounts::OriginRequest::S3Compatible, + Imagekitio::Accounts::OriginRequest::CloudinaryBackup, + Imagekitio::Accounts::OriginRequest::WebFolder, + Imagekitio::Accounts::OriginRequest::WebProxy, + Imagekitio::Accounts::OriginRequest::Gcs, + Imagekitio::Accounts::OriginRequest::AzureBlob, + Imagekitio::Accounts::OriginRequest::AkeneoPim + ), + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/url_endpoint_create_params.rbi b/rbi/imagekitio/models/accounts/url_endpoint_create_params.rbi new file mode 100644 index 00000000..655546c3 --- /dev/null +++ b/rbi/imagekitio/models/accounts/url_endpoint_create_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class URLEndpointCreateParams < Imagekitio::Models::Accounts::URLEndpointRequest + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointCreateParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/url_endpoint_delete_params.rbi b/rbi/imagekitio/models/accounts/url_endpoint_delete_params.rbi new file mode 100644 index 00000000..2872f0b2 --- /dev/null +++ b/rbi/imagekitio/models/accounts/url_endpoint_delete_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class URLEndpointDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointDeleteParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/url_endpoint_get_params.rbi b/rbi/imagekitio/models/accounts/url_endpoint_get_params.rbi new file mode 100644 index 00000000..b3d65268 --- /dev/null +++ b/rbi/imagekitio/models/accounts/url_endpoint_get_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class URLEndpointGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointGetParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/url_endpoint_list_params.rbi b/rbi/imagekitio/models/accounts/url_endpoint_list_params.rbi new file mode 100644 index 00000000..ac51f50b --- /dev/null +++ b/rbi/imagekitio/models/accounts/url_endpoint_list_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class URLEndpointListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointListParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/url_endpoint_list_response.rbi b/rbi/imagekitio/models/accounts/url_endpoint_list_response.rbi new file mode 100644 index 00000000..4ffb994d --- /dev/null +++ b/rbi/imagekitio/models/accounts/url_endpoint_list_response.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + URLEndpointListResponse = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + Imagekitio::Accounts::URLEndpointResponse + ], + Imagekitio::Internal::Type::Converter + ) + end + end +end diff --git a/rbi/imagekitio/models/accounts/url_endpoint_request.rbi b/rbi/imagekitio/models/accounts/url_endpoint_request.rbi new file mode 100644 index 00000000..8e42816f --- /dev/null +++ b/rbi/imagekitio/models/accounts/url_endpoint_request.rbi @@ -0,0 +1,218 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class URLEndpointRequest < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointRequest, + Imagekitio::Internal::AnyHash + ) + end + + # Description of the URL endpoint. + sig { returns(String) } + attr_accessor :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. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :origins + + sig { params(origins: T::Array[String]).void } + attr_writer :origins + + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + sig { returns(T.nilable(String)) } + attr_reader :url_prefix + + sig { params(url_prefix: String).void } + attr_writer :url_prefix + + # Configuration for third-party URL rewriting. + sig do + returns( + T.nilable( + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai + ) + ) + ) + end + attr_reader :url_rewriter + + sig do + params( + url_rewriter: + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary::OrHash, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix::OrHash, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai::OrHash + ) + ).void + end + attr_writer :url_rewriter + + # Schema for URL endpoint resource. + sig do + params( + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary::OrHash, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix::OrHash, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai::OrHash + ) + ).returns(T.attached_class) + end + def self.new( + # Description of the URL endpoint. + 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. + origins: nil, + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + url_prefix: nil, + # Configuration for third-party URL rewriting. + url_rewriter: nil + ) + end + + sig do + override.returns( + { + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai + ) + } + ) + end + def to_hash + end + + # Configuration for third-party URL rewriting. + module URLRewriter + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai + ) + end + + class Cloudinary < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + # Whether to preserve `/` in the rewritten URL. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :preserve_asset_delivery_types + + sig { params(preserve_asset_delivery_types: T::Boolean).void } + attr_writer :preserve_asset_delivery_types + + sig do + params( + preserve_asset_delivery_types: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Whether to preserve `/` in the rewritten URL. + preserve_asset_delivery_types: nil, + type: :CLOUDINARY + ) + end + + sig do + override.returns( + { type: Symbol, preserve_asset_delivery_types: T::Boolean } + ) + end + def to_hash + end + end + + class Imgix < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + sig { params(type: Symbol).returns(T.attached_class) } + def self.new(type: :IMGIX) + end + + sig { override.returns({ type: Symbol }) } + def to_hash + end + end + + class Akamai < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + sig { params(type: Symbol).returns(T.attached_class) } + def self.new(type: :AKAMAI) + end + + sig { override.returns({ type: Symbol }) } + def to_hash + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/url_endpoint_response.rbi b/rbi/imagekitio/models/accounts/url_endpoint_response.rbi new file mode 100644 index 00000000..96905355 --- /dev/null +++ b/rbi/imagekitio/models/accounts/url_endpoint_response.rbi @@ -0,0 +1,213 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class URLEndpointResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointResponse, + Imagekitio::Internal::AnyHash + ) + end + + # Description of the URL endpoint. + sig { returns(String) } + attr_accessor :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. + sig { returns(T::Array[String]) } + attr_accessor :origins + + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + sig { returns(String) } + attr_accessor :url_prefix + + # Configuration for third-party URL rewriting. + sig do + returns( + T.nilable( + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Variants + ) + ) + end + attr_reader :url_rewriter + + sig do + params( + url_rewriter: + T.any( + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Cloudinary::OrHash, + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Imgix::OrHash, + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Akamai::OrHash + ) + ).void + end + attr_writer :url_rewriter + + # 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`. + sig { returns(String) } + attr_accessor :id + + # URL‑endpoint object as returned by the API. + sig do + params( + id: String, + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Cloudinary::OrHash, + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Imgix::OrHash, + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Akamai::OrHash + ) + ).returns(T.attached_class) + end + def self.new( + # 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`. + id:, + # Description of the URL endpoint. + 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. + origins:, + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + url_prefix:, + # Configuration for third-party URL rewriting. + url_rewriter: nil + ) + end + + sig do + override.returns( + { + id: String, + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Variants + } + ) + end + def to_hash + end + + # Configuration for third-party URL rewriting. + module URLRewriter + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Imgix, + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Akamai + ) + end + + class Cloudinary < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Cloudinary, + Imagekitio::Internal::AnyHash + ) + end + + # Whether to preserve `/` in the rewritten URL. + sig { returns(T::Boolean) } + attr_accessor :preserve_asset_delivery_types + + sig { returns(Symbol) } + attr_accessor :type + + sig do + params( + preserve_asset_delivery_types: T::Boolean, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Whether to preserve `/` in the rewritten URL. + preserve_asset_delivery_types:, + type: :CLOUDINARY + ) + end + + sig do + override.returns( + { preserve_asset_delivery_types: T::Boolean, type: Symbol } + ) + end + def to_hash + end + end + + class Imgix < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Imgix, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + sig { params(type: Symbol).returns(T.attached_class) } + def self.new(type: :IMGIX) + end + + sig { override.returns({ type: Symbol }) } + def to_hash + end + end + + class Akamai < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Akamai, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(Symbol) } + attr_accessor :type + + sig { params(type: Symbol).returns(T.attached_class) } + def self.new(type: :AKAMAI) + end + + sig { override.returns({ type: Symbol }) } + def to_hash + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/url_endpoint_update_params.rbi b/rbi/imagekitio/models/accounts/url_endpoint_update_params.rbi new file mode 100644 index 00000000..7e23f2d1 --- /dev/null +++ b/rbi/imagekitio/models/accounts/url_endpoint_update_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class URLEndpointUpdateParams < Imagekitio::Models::Accounts::URLEndpointRequest + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::URLEndpointUpdateParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/usage_get_params.rbi b/rbi/imagekitio/models/accounts/usage_get_params.rbi new file mode 100644 index 00000000..563f7451 --- /dev/null +++ b/rbi/imagekitio/models/accounts/usage_get_params.rbi @@ -0,0 +1,60 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class UsageGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Accounts::UsageGetParams, + Imagekitio::Internal::AnyHash + ) + end + + # 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. + sig { returns(Date) } + attr_accessor :end_date + + # 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. + sig { returns(Date) } + attr_accessor :start_date + + sig do + params( + end_date: Date, + start_date: Date, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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. + end_date:, + # 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. + start_date:, + request_options: {} + ) + end + + sig do + override.returns( + { + end_date: Date, + start_date: Date, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/accounts/usage_get_response.rbi b/rbi/imagekitio/models/accounts/usage_get_response.rbi new file mode 100644 index 00000000..8e53de30 --- /dev/null +++ b/rbi/imagekitio/models/accounts/usage_get_response.rbi @@ -0,0 +1,89 @@ +# typed: strong + +module Imagekitio + module Models + module Accounts + class UsageGetResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Accounts::UsageGetResponse, + Imagekitio::Internal::AnyHash + ) + end + + # Amount of bandwidth used in bytes. + sig { returns(T.nilable(Integer)) } + attr_reader :bandwidth_bytes + + sig { params(bandwidth_bytes: Integer).void } + attr_writer :bandwidth_bytes + + # Number of extension units used. + sig { returns(T.nilable(Integer)) } + attr_reader :extension_units_count + + sig { params(extension_units_count: Integer).void } + attr_writer :extension_units_count + + # Storage used by media library in bytes. + sig { returns(T.nilable(Integer)) } + attr_reader :media_library_storage_bytes + + sig { params(media_library_storage_bytes: Integer).void } + attr_writer :media_library_storage_bytes + + # Storage used by the original cache in bytes. + sig { returns(T.nilable(Integer)) } + attr_reader :original_cache_storage_bytes + + sig { params(original_cache_storage_bytes: Integer).void } + attr_writer :original_cache_storage_bytes + + # Number of video processing units used. + sig { returns(T.nilable(Integer)) } + attr_reader :video_processing_units_count + + sig { params(video_processing_units_count: Integer).void } + attr_writer :video_processing_units_count + + sig do + params( + bandwidth_bytes: Integer, + extension_units_count: Integer, + media_library_storage_bytes: Integer, + original_cache_storage_bytes: Integer, + video_processing_units_count: Integer + ).returns(T.attached_class) + end + def self.new( + # Amount of bandwidth used in bytes. + bandwidth_bytes: nil, + # Number of extension units used. + extension_units_count: nil, + # Storage used by media library in bytes. + media_library_storage_bytes: nil, + # Storage used by the original cache in bytes. + original_cache_storage_bytes: nil, + # Number of video processing units used. + video_processing_units_count: nil + ) + end + + sig do + override.returns( + { + bandwidth_bytes: Integer, + extension_units_count: Integer, + media_library_storage_bytes: Integer, + original_cache_storage_bytes: Integer, + video_processing_units_count: Integer + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/asset_list_params.rbi b/rbi/imagekitio/models/asset_list_params.rbi new file mode 100644 index 00000000..e194dfd4 --- /dev/null +++ b/rbi/imagekitio/models/asset_list_params.rbi @@ -0,0 +1,281 @@ +# typed: strong + +module Imagekitio + module Models + class AssetListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::AssetListParams, Imagekitio::Internal::AnyHash) + end + + # 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) + sig do + returns(T.nilable(Imagekitio::AssetListParams::FileType::OrSymbol)) + end + attr_reader :file_type + + sig do + params(file_type: Imagekitio::AssetListParams::FileType::OrSymbol).void + end + attr_writer :file_type + + # The maximum number of results to return in response. + sig { returns(T.nilable(Integer)) } + attr_reader :limit + + sig { params(limit: Integer).void } + attr_writer :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. + sig { returns(T.nilable(String)) } + attr_reader :path + + sig { params(path: String).void } + attr_writer :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. + sig { returns(T.nilable(String)) } + attr_reader :search_query + + sig { params(search_query: String).void } + attr_writer :search_query + + # The number of results to skip before returning results. + sig { returns(T.nilable(Integer)) } + attr_reader :skip + + sig { params(skip: Integer).void } + attr_writer :skip + + # Sort the results by one of the supported fields in ascending or descending + # order. + sig { returns(T.nilable(Imagekitio::AssetListParams::Sort::OrSymbol)) } + attr_reader :sort + + sig { params(sort: Imagekitio::AssetListParams::Sort::OrSymbol).void } + attr_writer :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`) + sig { returns(T.nilable(Imagekitio::AssetListParams::Type::OrSymbol)) } + attr_reader :type + + sig { params(type: Imagekitio::AssetListParams::Type::OrSymbol).void } + attr_writer :type + + sig do + params( + file_type: Imagekitio::AssetListParams::FileType::OrSymbol, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekitio::AssetListParams::Sort::OrSymbol, + type: Imagekitio::AssetListParams::Type::OrSymbol, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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) + file_type: nil, + # The maximum number of results to return in response. + limit: nil, + # 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. + path: nil, + # 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. + search_query: nil, + # The number of results to skip before returning results. + skip: nil, + # Sort the results by one of the supported fields in ascending or descending + # order. + sort: nil, + # 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`) + type: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + file_type: Imagekitio::AssetListParams::FileType::OrSymbol, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekitio::AssetListParams::Sort::OrSymbol, + type: Imagekitio::AssetListParams::Type::OrSymbol, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + + # 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) + module FileType + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::AssetListParams::FileType) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + ALL = T.let(:all, Imagekitio::AssetListParams::FileType::TaggedSymbol) + IMAGE = + T.let(:image, Imagekitio::AssetListParams::FileType::TaggedSymbol) + NON_IMAGE = + T.let( + :"non-image", + Imagekitio::AssetListParams::FileType::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Imagekitio::AssetListParams::FileType::TaggedSymbol] + ) + end + def self.values + end + end + + # Sort the results by one of the supported fields in ascending or descending + # order. + module Sort + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::AssetListParams::Sort) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + ASC_NAME = + T.let(:ASC_NAME, Imagekitio::AssetListParams::Sort::TaggedSymbol) + DESC_NAME = + T.let(:DESC_NAME, Imagekitio::AssetListParams::Sort::TaggedSymbol) + ASC_CREATED = + T.let(:ASC_CREATED, Imagekitio::AssetListParams::Sort::TaggedSymbol) + DESC_CREATED = + T.let(:DESC_CREATED, Imagekitio::AssetListParams::Sort::TaggedSymbol) + ASC_UPDATED = + T.let(:ASC_UPDATED, Imagekitio::AssetListParams::Sort::TaggedSymbol) + DESC_UPDATED = + T.let(:DESC_UPDATED, Imagekitio::AssetListParams::Sort::TaggedSymbol) + ASC_HEIGHT = + T.let(:ASC_HEIGHT, Imagekitio::AssetListParams::Sort::TaggedSymbol) + DESC_HEIGHT = + T.let(:DESC_HEIGHT, Imagekitio::AssetListParams::Sort::TaggedSymbol) + ASC_WIDTH = + T.let(:ASC_WIDTH, Imagekitio::AssetListParams::Sort::TaggedSymbol) + DESC_WIDTH = + T.let(:DESC_WIDTH, Imagekitio::AssetListParams::Sort::TaggedSymbol) + ASC_SIZE = + T.let(:ASC_SIZE, Imagekitio::AssetListParams::Sort::TaggedSymbol) + DESC_SIZE = + T.let(:DESC_SIZE, Imagekitio::AssetListParams::Sort::TaggedSymbol) + ASC_RELEVANCE = + T.let(:ASC_RELEVANCE, Imagekitio::AssetListParams::Sort::TaggedSymbol) + DESC_RELEVANCE = + T.let( + :DESC_RELEVANCE, + Imagekitio::AssetListParams::Sort::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Imagekitio::AssetListParams::Sort::TaggedSymbol] + ) + end + def self.values + end + end + + # 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`) + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::AssetListParams::Type) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + FILE = T.let(:file, Imagekitio::AssetListParams::Type::TaggedSymbol) + FILE_VERSION = + T.let( + :"file-version", + Imagekitio::AssetListParams::Type::TaggedSymbol + ) + FOLDER = T.let(:folder, Imagekitio::AssetListParams::Type::TaggedSymbol) + ALL = T.let(:all, Imagekitio::AssetListParams::Type::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::AssetListParams::Type::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekitio/models/asset_list_response.rbi b/rbi/imagekitio/models/asset_list_response.rbi new file mode 100644 index 00000000..2818b745 --- /dev/null +++ b/rbi/imagekitio/models/asset_list_response.rbi @@ -0,0 +1,28 @@ +# typed: strong + +module Imagekitio + module Models + # Object containing details of a file or file version. + module AssetListResponseItem + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Imagekitio::Folder, Imagekitio::File) } + + sig do + override.returns( + T::Array[Imagekitio::Models::AssetListResponseItem::Variants] + ) + end + def self.variants + end + end + + AssetListResponse = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + union: Imagekitio::Models::AssetListResponseItem + ], + Imagekitio::Internal::Type::Converter + ) + end +end diff --git a/rbi/imagekitio/models/base_overlay.rbi b/rbi/imagekitio/models/base_overlay.rbi new file mode 100644 index 00000000..30cca96c --- /dev/null +++ b/rbi/imagekitio/models/base_overlay.rbi @@ -0,0 +1,44 @@ +# typed: strong + +module Imagekitio + module Models + class BaseOverlay < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::BaseOverlay, Imagekitio::Internal::AnyHash) + end + + sig { returns(T.nilable(Imagekitio::OverlayPosition)) } + attr_reader :position + + sig { params(position: Imagekitio::OverlayPosition::OrHash).void } + attr_writer :position + + sig { returns(T.nilable(Imagekitio::OverlayTiming)) } + attr_reader :timing + + sig { params(timing: Imagekitio::OverlayTiming::OrHash).void } + attr_writer :timing + + sig do + params( + position: Imagekitio::OverlayPosition::OrHash, + timing: Imagekitio::OverlayTiming::OrHash + ).returns(T.attached_class) + end + def self.new(position: nil, timing: nil) + end + + sig do + override.returns( + { + position: Imagekitio::OverlayPosition, + timing: Imagekitio::OverlayTiming + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/base_webhook_event.rbi b/rbi/imagekitio/models/base_webhook_event.rbi new file mode 100644 index 00000000..28ad3694 --- /dev/null +++ b/rbi/imagekitio/models/base_webhook_event.rbi @@ -0,0 +1,33 @@ +# typed: strong + +module Imagekitio + module Models + class BaseWebhookEvent < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::BaseWebhookEvent, Imagekitio::Internal::AnyHash) + end + + # Unique identifier for the event. + sig { returns(String) } + attr_accessor :id + + # The type of webhook event. + sig { returns(String) } + attr_accessor :type + + sig { params(id: String, type: String).returns(T.attached_class) } + def self.new( + # Unique identifier for the event. + id:, + # The type of webhook event. + type: + ) + end + + sig { override.returns({ id: String, type: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/beta/v2/file_upload_params.rbi b/rbi/imagekitio/models/beta/v2/file_upload_params.rbi new file mode 100644 index 00000000..cb350106 --- /dev/null +++ b/rbi/imagekitio/models/beta/v2/file_upload_params.rbi @@ -0,0 +1,861 @@ +# typed: strong + +module Imagekitio + module Models + module Beta + module V2 + class FileUploadParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Beta::V2::FileUploadParams, + Imagekitio::Internal::AnyHash + ) + end + + # 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. + sig { returns(Imagekitio::Internal::FileInput) } + attr_accessor :file + + # The name with which the file has to be uploaded. + sig { returns(String) } + attr_accessor :file_name + + # 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. + sig { returns(T.nilable(String)) } + attr_reader :token + + sig { params(token: String).void } + attr_writer :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). + sig { returns(T.nilable(String)) } + attr_reader :checks + + sig { params(checks: String).void } + attr_writer :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. + sig { returns(T.nilable(String)) } + attr_reader :custom_coordinates + + sig { params(custom_coordinates: String).void } + attr_writer :custom_coordinates + + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg, + Imagekitio::ExtensionItem::AIAutoDescription, + Imagekitio::ExtensionItem::AutoTaggingExtension + ) + ] + ) + ) + end + attr_reader :extensions + + sig do + params( + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg::OrHash, + Imagekitio::ExtensionItem::AIAutoDescription::OrHash, + Imagekitio::ExtensionItem::AutoTaggingExtension::OrHash + ) + ] + ).void + end + attr_writer :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. + sig { returns(T.nilable(String)) } + attr_reader :folder + + sig { params(folder: String).void } + attr_writer :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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_ai_tags + + sig { params(overwrite_ai_tags: T::Boolean).void } + attr_writer :overwrite_ai_tags + + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_custom_metadata + + sig { params(overwrite_custom_metadata: T::Boolean).void } + attr_writer :overwrite_custom_metadata + + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_file + + sig { params(overwrite_file: T::Boolean).void } + attr_writer :overwrite_file + + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_tags + + sig { params(overwrite_tags: T::Boolean).void } + attr_writer :overwrite_tags + + # Array of response field keys to include in the API response body. + sig do + returns( + T.nilable( + T::Array[ + Imagekitio::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ] + ) + ) + end + attr_reader :response_fields + + sig do + params( + response_fields: + T::Array[ + Imagekitio::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ] + ).void + end + attr_writer :response_fields + + # 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. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :tags + + sig { params(tags: T::Array[String]).void } + attr_writer :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. + sig do + returns( + T.nilable(Imagekitio::Beta::V2::FileUploadParams::Transformation) + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekitio::Beta::V2::FileUploadParams::Transformation::OrHash + ).void + end + attr_writer :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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :use_unique_file_name + + sig { params(use_unique_file_name: T::Boolean).void } + attr_writer :use_unique_file_name + + # 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. + sig { returns(T.nilable(String)) } + attr_reader :webhook_url + + sig { params(webhook_url: String).void } + attr_writer :webhook_url + + sig do + params( + file: Imagekitio::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg::OrHash, + Imagekitio::ExtensionItem::AIAutoDescription::OrHash, + Imagekitio::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + response_fields: + T::Array[ + Imagekitio::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ], + tags: T::Array[String], + transformation: + Imagekitio::Beta::V2::FileUploadParams::Transformation::OrHash, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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. + file:, + # The name with which the file has to be uploaded. + file_name:, + # 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. + token: nil, + # 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). + checks: nil, + # 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. + custom_coordinates: nil, + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # 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. + folder: nil, + # 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. + is_private_file: nil, + # 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. + is_published: nil, + # 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. + overwrite_ai_tags: nil, + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + overwrite_custom_metadata: nil, + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + overwrite_file: nil, + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + overwrite_tags: nil, + # Array of response field keys to include in the API response body. + response_fields: nil, + # 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. + tags: nil, + # 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. + transformation: nil, + # 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. + use_unique_file_name: nil, + # 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. + webhook_url: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + file: Imagekitio::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg, + Imagekitio::ExtensionItem::AIAutoDescription, + Imagekitio::ExtensionItem::AutoTaggingExtension + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + response_fields: + T::Array[ + Imagekitio::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ], + tags: T::Array[String], + transformation: + Imagekitio::Beta::V2::FileUploadParams::Transformation, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + + module ResponseField + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Beta::V2::FileUploadParams::ResponseField + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TAGS = + T.let( + :tags, + Imagekitio::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + CUSTOM_COORDINATES = + T.let( + :customCoordinates, + Imagekitio::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + IS_PRIVATE_FILE = + T.let( + :isPrivateFile, + Imagekitio::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + EMBEDDED_METADATA = + T.let( + :embeddedMetadata, + Imagekitio::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + IS_PUBLISHED = + T.let( + :isPublished, + Imagekitio::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + CUSTOM_METADATA = + T.let( + :customMetadata, + Imagekitio::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + METADATA = + T.let( + :metadata, + Imagekitio::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + SELECTED_FIELDS_SCHEMA = + T.let( + :selectedFieldsSchema, + Imagekitio::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Beta::V2::FileUploadParams::ResponseField::TaggedSymbol + ] + ) + end + def self.values + end + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + # 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`. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Transformation, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs + ) + ] + ) + ) + end + attr_reader :post + + sig do + params( + post: + T::Array[ + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Transformation::OrHash, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo::OrHash, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail::OrHash, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::OrHash + ) + ] + ).void + end + attr_writer :post + + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + sig { returns(T.nilable(String)) } + attr_reader :pre + + sig { params(pre: String).void } + attr_writer :pre + + # 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. + sig do + params( + post: + T::Array[ + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Transformation::OrHash, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo::OrHash, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail::OrHash, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::OrHash + ) + ], + pre: String + ).returns(T.attached_class) + end + def self.new( + # 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`. + post: nil, + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + pre: nil + ) + end + + sig do + override.returns( + { + post: + T::Array[ + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Transformation, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs + ) + ], + pre: String + } + ) + end + def to_hash + end + + module Post + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Transformation, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs + ) + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + # Transformation type. + sig { returns(Symbol) } + attr_accessor :type + + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + sig { returns(String) } + attr_accessor :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + value:, + # Transformation type. + type: :transformation + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class GifToVideo < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo, + Imagekitio::Internal::AnyHash + ) + end + + # Converts an animated GIF into an MP4. + sig { returns(Symbol) } + attr_accessor :type + + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + value: nil, + # Converts an animated GIF into an MP4. + type: :"gif-to-video" + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class Thumbnail < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail, + Imagekitio::Internal::AnyHash + ) + end + + # Generates a thumbnail image. + sig { returns(Symbol) } + attr_accessor :type + + # Optional transformation string. + # **Example**: `w-150,h-150` + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Optional transformation string. + # **Example**: `w-150,h-150` + value: nil, + # Generates a thumbnail image. + type: :thumbnail + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class Abs < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs, + Imagekitio::Internal::AnyHash + ) + end + + # Streaming protocol to use (`hls` or `dash`). + sig do + returns( + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol + ) + end + attr_accessor :protocol + + # Adaptive Bitrate Streaming (ABS) setup. + sig { returns(Symbol) } + attr_accessor :type + + # List of different representations you want to create separated by an underscore. + sig { returns(String) } + attr_accessor :value + + sig do + params( + protocol: + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol, + value: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Streaming protocol to use (`hls` or `dash`). + protocol:, + # List of different representations you want to create separated by an underscore. + value:, + # Adaptive Bitrate Streaming (ABS) setup. + type: :abs + ) + end + + sig do + override.returns( + { + protocol: + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol, + type: Symbol, + value: String + } + ) + end + def to_hash + end + + # Streaming protocol to use (`hls` or `dash`). + module Protocol + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :hls, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ) + DASH = + T.let( + :dash, + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Variants + ] + ) + end + def self.variants + end + end + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/beta/v2/file_upload_response.rbi b/rbi/imagekitio/models/beta/v2/file_upload_response.rbi new file mode 100644 index 00000000..2c472e76 --- /dev/null +++ b/rbi/imagekitio/models/beta/v2/file_upload_response.rbi @@ -0,0 +1,1197 @@ +# typed: strong + +module Imagekitio + module Models + module Beta + module V2 + class FileUploadResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Beta::V2::FileUploadResponse, + Imagekitio::Internal::AnyHash + ) + end + + # An array of tags assigned to the uploaded file by auto tagging. + sig do + returns( + T.nilable( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::AITag + ] + ) + ) + end + attr_accessor :ai_tags + + # The audio codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :audio_codec + + sig { params(audio_codec: String).void } + attr_writer :audio_codec + + # The bit rate of the video in kbps (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :bit_rate + + sig { params(bit_rate: Integer).void } + attr_writer :bit_rate + + # 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. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # 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. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # The duration of the video in seconds (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :duration + + sig { params(duration: Integer).void } + attr_writer :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. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :embedded_metadata + + sig { params(embedded_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :embedded_metadata + + # 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. + sig do + returns( + T.nilable( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus + ) + ) + end + attr_reader :extension_status + + sig do + params( + extension_status: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::OrHash + ).void + end + attr_writer :extension_status + + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + sig { returns(T.nilable(String)) } + attr_reader :file_id + + sig { params(file_id: String).void } + attr_writer :file_id + + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + sig { returns(T.nilable(String)) } + attr_reader :file_path + + sig { params(file_path: String).void } + attr_writer :file_path + + # Type of the uploaded file. Possible values are `image`, `non-image`. + sig { returns(T.nilable(String)) } + attr_reader :file_type + + sig { params(file_type: String).void } + attr_writer :file_type + + # Height of the image in pixels (Only for images) + sig { returns(T.nilable(Float)) } + attr_reader :height + + sig { params(height: Float).void } + attr_writer :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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + sig { returns(T.nilable(Imagekitio::Metadata)) } + attr_reader :metadata + + sig { params(metadata: Imagekitio::Metadata::OrHash).void } + attr_writer :metadata + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :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. + sig do + returns( + T.nilable( + T::Hash[ + Symbol, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema + ] + ) + ) + end + attr_reader :selected_fields_schema + + sig do + params( + selected_fields_schema: + T::Hash[ + Symbol, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::OrHash + ] + ).void + end + attr_writer :selected_fields_schema + + # Size of the image file in Bytes. + sig { returns(T.nilable(Float)) } + attr_reader :size + + sig { params(size: Float).void } + attr_writer :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. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :tags + + # In the case of an image, a small thumbnail URL. + sig { returns(T.nilable(String)) } + attr_reader :thumbnail_url + + sig { params(thumbnail_url: String).void } + attr_writer :thumbnail_url + + # A publicly accessible URL of the file. + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url + + # An object containing the file or file version's `id` (versionId) and `name`. + sig do + returns( + T.nilable( + Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo + ) + ) + end + attr_reader :version_info + + sig do + params( + version_info: + Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo::OrHash + ).void + end + attr_writer :version_info + + # The video codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :video_codec + + sig { params(video_codec: String).void } + attr_writer :video_codec + + # Width of the image in pixels (Only for Images) + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Object containing details of a successful upload. + sig do + params( + ai_tags: + T.nilable( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::AITag::OrHash + ] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::OrHash, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekitio::Metadata::OrHash, + name: String, + selected_fields_schema: + T::Hash[ + Symbol, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::OrHash + ], + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo::OrHash, + video_codec: String, + width: Float + ).returns(T.attached_class) + end + def self.new( + # An array of tags assigned to the uploaded file by auto tagging. + ai_tags: nil, + # The audio codec used in the video (only for video). + audio_codec: nil, + # The bit rate of the video in kbps (only for video). + bit_rate: nil, + # 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. + custom_coordinates: nil, + # 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. + custom_metadata: nil, + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + description: nil, + # The duration of the video in seconds (only for video). + duration: nil, + # 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. + embedded_metadata: nil, + # 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. + extension_status: nil, + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + file_id: nil, + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + file_path: nil, + # Type of the uploaded file. Possible values are `image`, `non-image`. + file_type: nil, + # Height of the image in pixels (Only for images) + height: nil, + # 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. + is_private_file: nil, + # 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. + is_published: nil, + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + metadata: nil, + # Name of the asset. + name: nil, + # 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. + selected_fields_schema: nil, + # Size of the image file in Bytes. + size: nil, + # 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. + tags: nil, + # In the case of an image, a small thumbnail URL. + thumbnail_url: nil, + # A publicly accessible URL of the file. + url: nil, + # An object containing the file or file version's `id` (versionId) and `name`. + version_info: nil, + # The video codec used in the video (only for video). + video_codec: nil, + # Width of the image in pixels (Only for Images) + width: nil + ) + end + + sig do + override.returns( + { + ai_tags: + T.nilable( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::AITag + ] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekitio::Metadata, + name: String, + selected_fields_schema: + T::Hash[ + Symbol, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema + ], + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + ) + end + def to_hash + end + + class AITag < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Beta::V2::FileUploadResponse::AITag, + Imagekitio::Internal::AnyHash + ) + end + + # Confidence score of the tag. + sig { returns(T.nilable(Float)) } + attr_reader :confidence + + sig { params(confidence: Float).void } + attr_writer :confidence + + # Name of the tag. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + sig { returns(T.nilable(String)) } + attr_reader :source + + sig { params(source: String).void } + attr_writer :source + + sig do + params(confidence: Float, name: String, source: String).returns( + T.attached_class + ) + end + def self.new( + # Confidence score of the tag. + confidence: nil, + # Name of the tag. + name: nil, + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + source: nil + ) + end + + sig do + override.returns( + { confidence: Float, name: String, source: String } + ) + end + def to_hash + end + end + + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + Imagekitio::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + ) + end + attr_reader :ai_auto_description + + sig do + params( + ai_auto_description: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::OrSymbol + ).void + end + attr_writer :ai_auto_description + + sig do + returns( + T.nilable( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :aws_auto_tagging + + sig do + params( + aws_auto_tagging: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::OrSymbol + ).void + end + attr_writer :aws_auto_tagging + + sig do + returns( + T.nilable( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :google_auto_tagging + + sig do + params( + google_auto_tagging: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol + ).void + end + attr_writer :google_auto_tagging + + sig do + returns( + T.nilable( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + ) + end + attr_reader :remove_bg + + sig do + params( + remove_bg: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::OrSymbol + ).void + end + attr_writer :remove_bg + + # 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. + sig do + params( + ai_auto_description: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::OrSymbol, + aws_auto_tagging: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::OrSymbol, + google_auto_tagging: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol, + remove_bg: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::OrSymbol + ).returns(T.attached_class) + end + def self.new( + ai_auto_description: nil, + aws_auto_tagging: nil, + google_auto_tagging: nil, + remove_bg: nil + ) + end + + sig do + override.returns( + { + ai_auto_description: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol, + aws_auto_tagging: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol, + google_auto_tagging: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol, + remove_bg: + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + } + ) + end + def to_hash + end + + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ] + ) + end + def self.values + end + end + + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema, + Imagekitio::Internal::AnyHash + ) + end + + # Type of the custom metadata field. + sig do + returns( + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + end + attr_accessor :type + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + sig do + returns( + T.nilable( + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # Specifies if the custom metadata field is required or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants + ) + ) + end + attr_reader :max_value + + sig do + params( + max_value: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants + ) + ) + end + attr_reader :min_value + + sig do + params( + min_value: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants + ).void + end + attr_writer :min_value + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :read_only + + sig { params(read_only: T::Boolean).void } + attr_writer :read_only + + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :select_options_truncated + + sig { params(select_options_truncated: T::Boolean).void } + attr_writer :select_options_truncated + + sig do + params( + type: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::OrSymbol, + default_value: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants, + read_only: T::Boolean, + select_options: + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ], + select_options_truncated: T::Boolean + ).returns(T.attached_class) + end + def self.new( + # Type of the custom metadata field. + type:, + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + default_value: nil, + # Specifies if the custom metadata field is required or not. + is_value_required: nil, + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + max_length: nil, + # 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. + max_value: nil, + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + min_length: nil, + # 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. + min_value: nil, + # 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. + read_only: nil, + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + select_options: nil, + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + select_options_truncated: nil + ) + end + + sig do + override.returns( + { + type: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol, + default_value: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants, + read_only: T::Boolean, + select_options: + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ], + select_options_truncated: T::Boolean + } + ) + end + def to_hash + end + + # Type of the custom metadata field. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TEXT = + T.let( + :Text, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + TEXTAREA = + T.let( + :Textarea, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + NUMBER = + T.let( + :Number, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + DATE = + T.let( + :Date, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + BOOLEAN = + T.let( + :Boolean, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + SINGLE_SELECT = + T.let( + :SingleSelect, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + MULTI_SELECT = + T.let( + :MultiSelect, + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + module DefaultValue + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + union: + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Mixed + ], + Imagekitio::Internal::Type::Converter + ) + end + + # 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. + module MaxValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # 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. + module MinValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + + class VersionInfo < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the file version. + sig { returns(T.nilable(String)) } + attr_reader :id + + sig { params(id: String).void } + attr_writer :id + + # Name of the file version. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # An object containing the file or file version's `id` (versionId) and `name`. + sig { params(id: String, name: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the file version. + id: nil, + # Name of the file version. + name: nil + ) + end + + sig { override.returns({ id: String, name: String }) } + def to_hash + end + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/cache/invalidation_create_params.rbi b/rbi/imagekitio/models/cache/invalidation_create_params.rbi new file mode 100644 index 00000000..abf72f7c --- /dev/null +++ b/rbi/imagekitio/models/cache/invalidation_create_params.rbi @@ -0,0 +1,45 @@ +# typed: strong + +module Imagekitio + module Models + module Cache + class InvalidationCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Cache::InvalidationCreateParams, + Imagekitio::Internal::AnyHash + ) + end + + # The full URL of the file to be purged. + sig { returns(String) } + attr_accessor :url + + sig do + params( + url: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The full URL of the file to be purged. + url:, + request_options: {} + ) + end + + sig do + override.returns( + { url: String, request_options: Imagekitio::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/cache/invalidation_create_response.rbi b/rbi/imagekitio/models/cache/invalidation_create_response.rbi new file mode 100644 index 00000000..f6129934 --- /dev/null +++ b/rbi/imagekitio/models/cache/invalidation_create_response.rbi @@ -0,0 +1,37 @@ +# typed: strong + +module Imagekitio + module Models + module Cache + class InvalidationCreateResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Cache::InvalidationCreateResponse, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + sig { returns(T.nilable(String)) } + attr_reader :request_id + + sig { params(request_id: String).void } + attr_writer :request_id + + sig { params(request_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + request_id: nil + ) + end + + sig { override.returns({ request_id: String }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/cache/invalidation_get_params.rbi b/rbi/imagekitio/models/cache/invalidation_get_params.rbi new file mode 100644 index 00000000..991b116e --- /dev/null +++ b/rbi/imagekitio/models/cache/invalidation_get_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Cache + class InvalidationGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Cache::InvalidationGetParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/cache/invalidation_get_response.rbi b/rbi/imagekitio/models/cache/invalidation_get_response.rbi new file mode 100644 index 00000000..171a2a7e --- /dev/null +++ b/rbi/imagekitio/models/cache/invalidation_get_response.rbi @@ -0,0 +1,93 @@ +# typed: strong + +module Imagekitio + module Models + module Cache + class InvalidationGetResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Cache::InvalidationGetResponse, + Imagekitio::Internal::AnyHash + ) + end + + # Status of the purge request. + sig do + returns( + T.nilable( + Imagekitio::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + ) + ) + end + attr_reader :status + + sig do + params( + status: + Imagekitio::Models::Cache::InvalidationGetResponse::Status::OrSymbol + ).void + end + attr_writer :status + + sig do + params( + status: + Imagekitio::Models::Cache::InvalidationGetResponse::Status::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Status of the purge request. + status: nil + ) + end + + sig do + override.returns( + { + status: + Imagekitio::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + } + ) + end + def to_hash + end + + # Status of the purge request. + module Status + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::Cache::InvalidationGetResponse::Status + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + PENDING = + T.let( + :Pending, + Imagekitio::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + ) + COMPLETED = + T.let( + :Completed, + Imagekitio::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Cache::InvalidationGetResponse::Status::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/custom_metadata_field.rbi b/rbi/imagekitio/models/custom_metadata_field.rbi new file mode 100644 index 00000000..d727d437 --- /dev/null +++ b/rbi/imagekitio/models/custom_metadata_field.rbi @@ -0,0 +1,422 @@ +# typed: strong + +module Imagekitio + module Models + class CustomMetadataField < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::CustomMetadataField, Imagekitio::Internal::AnyHash) + end + + # Unique identifier for the custom metadata field. Use this to update the field. + sig { returns(String) } + attr_accessor :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. + sig { returns(String) } + attr_accessor :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. + sig { returns(String) } + attr_accessor :name + + # An object that describes the rules for the custom metadata field value. + sig { returns(Imagekitio::CustomMetadataField::Schema) } + attr_reader :schema + + sig do + params(schema: Imagekitio::CustomMetadataField::Schema::OrHash).void + end + attr_writer :schema + + # Object containing details of a custom metadata field. + sig do + params( + id: String, + label: String, + name: String, + schema: Imagekitio::CustomMetadataField::Schema::OrHash + ).returns(T.attached_class) + end + def self.new( + # Unique identifier for the custom metadata field. Use this to update the field. + 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. + 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. + name:, + # An object that describes the rules for the custom metadata field value. + schema: + ) + end + + sig do + override.returns( + { + id: String, + label: String, + name: String, + schema: Imagekitio::CustomMetadataField::Schema + } + ) + end + def to_hash + end + + class Schema < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::CustomMetadataField::Schema, + Imagekitio::Internal::AnyHash + ) + end + + # Type of the custom metadata field. + sig do + returns(Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol) + end + attr_accessor :type + + # The default value for this custom metadata field. Data type of default value + # depends on the field type. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataField::Schema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekitio::CustomMetadataField::Schema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # Specifies if the this custom metadata field is required or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataField::Schema::MaxValue::Variants + ) + ) + end + attr_reader :max_value + + sig do + params( + max_value: + Imagekitio::CustomMetadataField::Schema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataField::Schema::MinValue::Variants + ) + ) + end + attr_reader :min_value + + sig do + params( + min_value: + Imagekitio::CustomMetadataField::Schema::MinValue::Variants + ).void + end + attr_writer :min_value + + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekitio::CustomMetadataField::Schema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekitio::CustomMetadataField::Schema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + # An object that describes the rules for the custom metadata field value. + sig do + params( + type: Imagekitio::CustomMetadataField::Schema::Type::OrSymbol, + default_value: + Imagekitio::CustomMetadataField::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::CustomMetadataField::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::CustomMetadataField::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekitio::CustomMetadataField::Schema::SelectOption::Variants + ] + ).returns(T.attached_class) + end + def self.new( + # Type of the custom metadata field. + type:, + # The default value for this custom metadata field. Data type of default value + # depends on the field type. + default_value: nil, + # Specifies if the this custom metadata field is required or not. + is_value_required: nil, + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + max_length: nil, + # 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. + max_value: nil, + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + min_length: nil, + # 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. + min_value: nil, + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + select_options: nil + ) + end + + sig do + override.returns( + { + type: Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol, + default_value: + Imagekitio::CustomMetadataField::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::CustomMetadataField::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::CustomMetadataField::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekitio::CustomMetadataField::Schema::SelectOption::Variants + ] + } + ) + end + def to_hash + end + + # Type of the custom metadata field. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekitio::CustomMetadataField::Schema::Type) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TEXT = + T.let( + :Text, + Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol + ) + TEXTAREA = + T.let( + :Textarea, + Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol + ) + NUMBER = + T.let( + :Number, + Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol + ) + DATE = + T.let( + :Date, + Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol + ) + BOOLEAN = + T.let( + :Boolean, + Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol + ) + SINGLE_SELECT = + T.let( + :SingleSelect, + Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol + ) + MULTI_SELECT = + T.let( + :MultiSelect, + Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataField::Schema::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # The default value for this custom metadata field. Data type of default value + # depends on the field type. + module DefaultValue + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekitio::CustomMetadataField::Schema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataField::Schema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataField::Schema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + union: + Imagekitio::CustomMetadataField::Schema::DefaultValue::Mixed + ], + Imagekitio::Internal::Type::Converter + ) + end + + # 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. + module MaxValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataField::Schema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # 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. + module MinValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataField::Schema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataField::Schema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/custom_metadata_field_create_params.rbi b/rbi/imagekitio/models/custom_metadata_field_create_params.rbi new file mode 100644 index 00000000..a6622776 --- /dev/null +++ b/rbi/imagekitio/models/custom_metadata_field_create_params.rbi @@ -0,0 +1,443 @@ +# typed: strong + +module Imagekitio + module Models + class CustomMetadataFieldCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::CustomMetadataFieldCreateParams, + Imagekitio::Internal::AnyHash + ) + end + + # 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. + sig { returns(String) } + attr_accessor :label + + # API name of the custom metadata field. This should be unique across all + # (including deleted) custom metadata fields. + sig { returns(String) } + attr_accessor :name + + sig { returns(Imagekitio::CustomMetadataFieldCreateParams::Schema) } + attr_reader :schema + + sig do + params( + schema: Imagekitio::CustomMetadataFieldCreateParams::Schema::OrHash + ).void + end + attr_writer :schema + + sig do + params( + label: String, + name: String, + schema: Imagekitio::CustomMetadataFieldCreateParams::Schema::OrHash, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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. + label:, + # API name of the custom metadata field. This should be unique across all + # (including deleted) custom metadata fields. + name:, + schema:, + request_options: {} + ) + end + + sig do + override.returns( + { + label: String, + name: String, + schema: Imagekitio::CustomMetadataFieldCreateParams::Schema, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + + class Schema < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::CustomMetadataFieldCreateParams::Schema, + Imagekitio::Internal::AnyHash + ) + end + + # Type of the custom metadata field. + sig do + returns( + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol + ) + end + attr_accessor :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. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants + ) + ) + end + attr_reader :max_value + + sig do + params( + max_value: + Imagekitio::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataFieldCreateParams::Schema::MinValue::Variants + ) + ) + end + attr_reader :min_value + + sig do + params( + min_value: + Imagekitio::CustomMetadataFieldCreateParams::Schema::MinValue::Variants + ).void + end + attr_writer :min_value + + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + sig do + params( + type: + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol, + default_value: + Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::CustomMetadataFieldCreateParams::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + ).returns(T.attached_class) + end + def self.new( + # Type of the custom metadata field. + 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. + default_value: nil, + # 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. + is_value_required: nil, + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + max_length: nil, + # 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. + max_value: nil, + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + min_length: nil, + # 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. + min_value: nil, + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + select_options: nil + ) + end + + sig do + override.returns( + { + type: + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::OrSymbol, + default_value: + Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::CustomMetadataFieldCreateParams::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + } + ) + end + def to_hash + end + + # Type of the custom metadata field. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TEXT = + T.let( + :Text, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + TEXTAREA = + T.let( + :Textarea, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + NUMBER = + T.let( + :Number, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + DATE = + T.let( + :Date, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + BOOLEAN = + T.let( + :Boolean, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + SINGLE_SELECT = + T.let( + :SingleSelect, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + MULTI_SELECT = + T.let( + :MultiSelect, + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # 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. + module DefaultValue + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + union: + Imagekitio::CustomMetadataFieldCreateParams::Schema::DefaultValue::Mixed + ], + Imagekitio::Internal::Type::Converter + ) + end + + # 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. + module MaxValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # 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. + module MinValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldCreateParams::Schema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/custom_metadata_field_delete_params.rbi b/rbi/imagekitio/models/custom_metadata_field_delete_params.rbi new file mode 100644 index 00000000..219ec6a4 --- /dev/null +++ b/rbi/imagekitio/models/custom_metadata_field_delete_params.rbi @@ -0,0 +1,30 @@ +# typed: strong + +module Imagekitio + module Models + class CustomMetadataFieldDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::CustomMetadataFieldDeleteParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekitio::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/custom_metadata_field_delete_response.rbi b/rbi/imagekitio/models/custom_metadata_field_delete_response.rbi new file mode 100644 index 00000000..d8474e8c --- /dev/null +++ b/rbi/imagekitio/models/custom_metadata_field_delete_response.rbi @@ -0,0 +1,23 @@ +# typed: strong + +module Imagekitio + module Models + class CustomMetadataFieldDeleteResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::CustomMetadataFieldDeleteResponse, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/custom_metadata_field_list_params.rbi b/rbi/imagekitio/models/custom_metadata_field_list_params.rbi new file mode 100644 index 00000000..a0a8d01f --- /dev/null +++ b/rbi/imagekitio/models/custom_metadata_field_list_params.rbi @@ -0,0 +1,66 @@ +# typed: strong + +module Imagekitio + module Models + class CustomMetadataFieldListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::CustomMetadataFieldListParams, + Imagekitio::Internal::AnyHash + ) + end + + # 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. + sig { returns(T.nilable(String)) } + attr_reader :folder_path + + sig { params(folder_path: String).void } + attr_writer :folder_path + + # Set it to `true` to include deleted field objects in the API response. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_deleted + + sig { params(include_deleted: T::Boolean).void } + attr_writer :include_deleted + + sig do + params( + folder_path: String, + include_deleted: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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. + folder_path: nil, + # Set it to `true` to include deleted field objects in the API response. + include_deleted: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + folder_path: String, + include_deleted: T::Boolean, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/custom_metadata_field_list_response.rbi b/rbi/imagekitio/models/custom_metadata_field_list_response.rbi new file mode 100644 index 00000000..9b831657 --- /dev/null +++ b/rbi/imagekitio/models/custom_metadata_field_list_response.rbi @@ -0,0 +1,11 @@ +# typed: strong + +module Imagekitio + module Models + CustomMetadataFieldListResponse = + T.let( + Imagekitio::Internal::Type::ArrayOf[Imagekitio::CustomMetadataField], + Imagekitio::Internal::Type::Converter + ) + end +end diff --git a/rbi/imagekitio/models/custom_metadata_field_update_params.rbi b/rbi/imagekitio/models/custom_metadata_field_update_params.rbi new file mode 100644 index 00000000..62e96b2e --- /dev/null +++ b/rbi/imagekitio/models/custom_metadata_field_update_params.rbi @@ -0,0 +1,376 @@ +# typed: strong + +module Imagekitio + module Models + class CustomMetadataFieldUpdateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::CustomMetadataFieldUpdateParams, + Imagekitio::Internal::AnyHash + ) + end + + # 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. + sig { returns(T.nilable(String)) } + attr_reader :label + + sig { params(label: String).void } + attr_writer :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`. + sig do + returns(T.nilable(Imagekitio::CustomMetadataFieldUpdateParams::Schema)) + end + attr_reader :schema + + sig do + params( + schema: Imagekitio::CustomMetadataFieldUpdateParams::Schema::OrHash + ).void + end + attr_writer :schema + + sig do + params( + label: String, + schema: Imagekitio::CustomMetadataFieldUpdateParams::Schema::OrHash, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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. + label: nil, + # 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`. + schema: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + label: String, + schema: Imagekitio::CustomMetadataFieldUpdateParams::Schema, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + + class Schema < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::CustomMetadataFieldUpdateParams::Schema, + Imagekitio::Internal::AnyHash + ) + end + + # 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. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants + ) + ) + end + attr_reader :max_value + + sig do + params( + max_value: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants + ) + ) + end + attr_reader :min_value + + sig do + params( + min_value: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants + ).void + end + attr_writer :min_value + + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + # 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`. + sig do + params( + default_value: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + ).returns(T.attached_class) + end + def self.new( + # 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. + default_value: nil, + # 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. + is_value_required: nil, + # Maximum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + max_length: nil, + # 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. + max_value: nil, + # Minimum length of string. Only set this property if `type` is set to `Text` or + # `Textarea`. + min_length: nil, + # 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. + min_value: nil, + # An array of allowed values. This property is only required if `type` property is + # set to `SingleSelect` or `MultiSelect`. + select_options: nil + ) + end + + sig do + override.returns( + { + default_value: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants, + select_options: + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + } + ) + end + def to_hash + end + + # 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. + module DefaultValue + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + union: + Imagekitio::CustomMetadataFieldUpdateParams::Schema::DefaultValue::Mixed + ], + Imagekitio::Internal::Type::Converter + ) + end + + # 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. + module MaxValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # 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. + module MinValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::CustomMetadataFieldUpdateParams::Schema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/extensions.rbi b/rbi/imagekitio/models/extensions.rbi new file mode 100644 index 00000000..e93e473b --- /dev/null +++ b/rbi/imagekitio/models/extensions.rbi @@ -0,0 +1,274 @@ +# typed: strong + +module Imagekitio + module Models + module ExtensionItem + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::ExtensionItem::RemoveBg, + Imagekitio::ExtensionItem::AIAutoDescription, + Imagekitio::ExtensionItem::AutoTaggingExtension + ) + end + + class RemoveBg < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::ExtensionItem::RemoveBg, + Imagekitio::Internal::AnyHash + ) + end + + # Specifies the background removal extension. + sig { returns(Symbol) } + attr_accessor :name + + sig { returns(T.nilable(Imagekitio::ExtensionItem::RemoveBg::Options)) } + attr_reader :options + + sig do + params( + options: Imagekitio::ExtensionItem::RemoveBg::Options::OrHash + ).void + end + attr_writer :options + + sig do + params( + options: Imagekitio::ExtensionItem::RemoveBg::Options::OrHash, + name: Symbol + ).returns(T.attached_class) + end + def self.new( + options: nil, + # Specifies the background removal extension. + name: :"remove-bg" + ) + end + + sig do + override.returns( + { + name: Symbol, + options: Imagekitio::ExtensionItem::RemoveBg::Options + } + ) + end + def to_hash + end + + class Options < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::ExtensionItem::RemoveBg::Options, + Imagekitio::Internal::AnyHash + ) + end + + # Whether to add an artificial shadow to the result. Default is false. Note: + # Adding shadows is currently only supported for car photos. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :add_shadow + + sig { params(add_shadow: T::Boolean).void } + attr_writer :add_shadow + + # 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. + sig { returns(T.nilable(String)) } + attr_reader :bg_color + + sig { params(bg_color: String).void } + attr_writer :bg_color + + # Sets a background image from a URL. If this parameter is set, `bg_color` must be + # empty. + sig { returns(T.nilable(String)) } + attr_reader :bg_image_url + + sig { params(bg_image_url: String).void } + attr_writer :bg_image_url + + # Allows semi-transparent regions in the result. Default is true. Note: + # Semitransparency is currently only supported for car windows. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :semitransparency + + sig { params(semitransparency: T::Boolean).void } + attr_writer :semitransparency + + sig do + params( + add_shadow: T::Boolean, + bg_color: String, + bg_image_url: String, + semitransparency: T::Boolean + ).returns(T.attached_class) + end + def self.new( + # Whether to add an artificial shadow to the result. Default is false. Note: + # Adding shadows is currently only supported for car photos. + add_shadow: nil, + # 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. + bg_color: nil, + # Sets a background image from a URL. If this parameter is set, `bg_color` must be + # empty. + bg_image_url: nil, + # Allows semi-transparent regions in the result. Default is true. Note: + # Semitransparency is currently only supported for car windows. + semitransparency: nil + ) + end + + sig do + override.returns( + { + add_shadow: T::Boolean, + bg_color: String, + bg_image_url: String, + semitransparency: T::Boolean + } + ) + end + def to_hash + end + end + end + + class AutoTaggingExtension < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::ExtensionItem::AutoTaggingExtension, + Imagekitio::Internal::AnyHash + ) + end + + # Maximum number of tags to attach to the asset. + sig { returns(Integer) } + attr_accessor :max_tags + + # Minimum confidence level for tags to be considered valid. + sig { returns(Integer) } + attr_accessor :min_confidence + + # Specifies the auto-tagging extension used. + sig do + returns( + Imagekitio::ExtensionItem::AutoTaggingExtension::Name::OrSymbol + ) + end + attr_accessor :name + + sig do + params( + max_tags: Integer, + min_confidence: Integer, + name: + Imagekitio::ExtensionItem::AutoTaggingExtension::Name::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Maximum number of tags to attach to the asset. + max_tags:, + # Minimum confidence level for tags to be considered valid. + min_confidence:, + # Specifies the auto-tagging extension used. + name: + ) + end + + sig do + override.returns( + { + max_tags: Integer, + min_confidence: Integer, + name: + Imagekitio::ExtensionItem::AutoTaggingExtension::Name::OrSymbol + } + ) + end + def to_hash + end + + # Specifies the auto-tagging extension used. + module Name + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::ExtensionItem::AutoTaggingExtension::Name + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + GOOGLE_AUTO_TAGGING = + T.let( + :"google-auto-tagging", + Imagekitio::ExtensionItem::AutoTaggingExtension::Name::TaggedSymbol + ) + AWS_AUTO_TAGGING = + T.let( + :"aws-auto-tagging", + Imagekitio::ExtensionItem::AutoTaggingExtension::Name::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::ExtensionItem::AutoTaggingExtension::Name::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class AIAutoDescription < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::ExtensionItem::AIAutoDescription, + Imagekitio::Internal::AnyHash + ) + end + + # Specifies the auto description extension. + sig { returns(Symbol) } + attr_accessor :name + + sig { params(name: Symbol).returns(T.attached_class) } + def self.new( + # Specifies the auto description extension. + name: :"ai-auto-description" + ) + end + + sig { override.returns({ name: Symbol }) } + def to_hash + end + end + + sig { override.returns(T::Array[Imagekitio::ExtensionItem::Variants]) } + def self.variants + end + end + + Extensions = + T.let( + Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::ExtensionItem], + Imagekitio::Internal::Type::Converter + ) + end +end diff --git a/rbi/imagekitio/models/file.rbi b/rbi/imagekitio/models/file.rbi new file mode 100644 index 00000000..bc7304c4 --- /dev/null +++ b/rbi/imagekitio/models/file.rbi @@ -0,0 +1,789 @@ +# typed: strong + +module Imagekitio + module Models + class File < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias { T.any(Imagekitio::File, Imagekitio::Internal::AnyHash) } + + # An array of tags assigned to the file by auto tagging. + sig { returns(T.nilable(T::Array[Imagekitio::File::AITag])) } + attr_accessor :ai_tags + + # Date and time when the file was uploaded. The date and time is in ISO8601 + # format. + sig { returns(T.nilable(Time)) } + attr_reader :created_at + + sig { params(created_at: Time).void } + attr_writer :created_at + + # An string with custom coordinates of the file. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # An object with custom metadata for the file. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # Unique identifier of the asset. + sig { returns(T.nilable(String)) } + attr_reader :file_id + + sig { params(file_id: String).void } + attr_writer :file_id + + # 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`. + sig { returns(T.nilable(String)) } + attr_reader :file_path + + sig { params(file_path: String).void } + attr_writer :file_path + + # Type of the file. Possible values are `image`, `non-image`. + sig { returns(T.nilable(String)) } + attr_reader :file_type + + sig { params(file_type: String).void } + attr_writer :file_type + + # Specifies if the image has an alpha channel. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :has_alpha + + sig { params(has_alpha: T::Boolean).void } + attr_writer :has_alpha + + # Height of the file. + sig { returns(T.nilable(Float)) } + attr_reader :height + + sig { params(height: Float).void } + attr_writer :height + + # Specifies if the file is private or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # Specifies if the file is published or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # MIME type of the file. + sig { returns(T.nilable(String)) } + attr_reader :mime + + sig { params(mime: String).void } + attr_writer :mime + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :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. + sig do + returns( + T.nilable(T::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema]) + ) + end + attr_reader :selected_fields_schema + + sig do + params( + selected_fields_schema: + T::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema::OrHash] + ).void + end + attr_writer :selected_fields_schema + + # Size of the file in bytes. + sig { returns(T.nilable(Float)) } + attr_reader :size + + sig { params(size: Float).void } + attr_writer :size + + # An array of tags assigned to the file. Tags are used to search files in the + # media library. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :tags + + # URL of the thumbnail image. This URL is used to access the thumbnail image of + # the file in the media library. + sig { returns(T.nilable(String)) } + attr_reader :thumbnail + + sig { params(thumbnail: String).void } + attr_writer :thumbnail + + # Type of the asset. + sig { returns(T.nilable(Imagekitio::File::Type::TaggedSymbol)) } + attr_reader :type + + sig { params(type: Imagekitio::File::Type::OrSymbol).void } + attr_writer :type + + # Date and time when the file was last updated. The date and time is in ISO8601 + # format. + sig { returns(T.nilable(Time)) } + attr_reader :updated_at + + sig { params(updated_at: Time).void } + attr_writer :updated_at + + # URL of the file. + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url + + # An object with details of the file version. + sig { returns(T.nilable(Imagekitio::File::VersionInfo)) } + attr_reader :version_info + + sig { params(version_info: Imagekitio::File::VersionInfo::OrHash).void } + attr_writer :version_info + + # Width of the file. + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Object containing details of a file or file version. + sig do + params( + ai_tags: T.nilable(T::Array[Imagekitio::File::AITag::OrHash]), + created_at: Time, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + file_id: String, + file_path: String, + file_type: String, + has_alpha: T::Boolean, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + mime: String, + name: String, + selected_fields_schema: + T::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema::OrHash], + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail: String, + type: Imagekitio::File::Type::OrSymbol, + updated_at: Time, + url: String, + version_info: Imagekitio::File::VersionInfo::OrHash, + width: Float + ).returns(T.attached_class) + end + def self.new( + # An array of tags assigned to the file by auto tagging. + ai_tags: nil, + # Date and time when the file was uploaded. The date and time is in ISO8601 + # format. + created_at: nil, + # An string with custom coordinates of the file. + custom_coordinates: nil, + # An object with custom metadata for the file. + custom_metadata: nil, + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + description: nil, + # Unique identifier of the asset. + file_id: nil, + # 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`. + file_path: nil, + # Type of the file. Possible values are `image`, `non-image`. + file_type: nil, + # Specifies if the image has an alpha channel. + has_alpha: nil, + # Height of the file. + height: nil, + # Specifies if the file is private or not. + is_private_file: nil, + # Specifies if the file is published or not. + is_published: nil, + # MIME type of the file. + mime: nil, + # Name of the asset. + name: nil, + # 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. + selected_fields_schema: nil, + # Size of the file in bytes. + size: nil, + # An array of tags assigned to the file. Tags are used to search files in the + # media library. + tags: nil, + # URL of the thumbnail image. This URL is used to access the thumbnail image of + # the file in the media library. + thumbnail: nil, + # Type of the asset. + type: nil, + # Date and time when the file was last updated. The date and time is in ISO8601 + # format. + updated_at: nil, + # URL of the file. + url: nil, + # An object with details of the file version. + version_info: nil, + # Width of the file. + width: nil + ) + end + + sig do + override.returns( + { + ai_tags: T.nilable(T::Array[Imagekitio::File::AITag]), + created_at: Time, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + file_id: String, + file_path: String, + file_type: String, + has_alpha: T::Boolean, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + mime: String, + name: String, + selected_fields_schema: + T::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema], + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail: String, + type: Imagekitio::File::Type::TaggedSymbol, + updated_at: Time, + url: String, + version_info: Imagekitio::File::VersionInfo, + width: Float + } + ) + end + def to_hash + end + + class AITag < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::File::AITag, Imagekitio::Internal::AnyHash) + end + + # Confidence score of the tag. + sig { returns(T.nilable(Float)) } + attr_reader :confidence + + sig { params(confidence: Float).void } + attr_writer :confidence + + # Name of the tag. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Source of the tag. Possible values are `google-auto-tagging` and + # `aws-auto-tagging`. + sig { returns(T.nilable(String)) } + attr_reader :source + + sig { params(source: String).void } + attr_writer :source + + sig do + params(confidence: Float, name: String, source: String).returns( + T.attached_class + ) + end + def self.new( + # Confidence score of the tag. + confidence: nil, + # Name of the tag. + name: nil, + # Source of the tag. Possible values are `google-auto-tagging` and + # `aws-auto-tagging`. + source: nil + ) + end + + sig do + override.returns({ confidence: Float, name: String, source: String }) + end + def to_hash + end + end + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::File::SelectedFieldsSchema, + Imagekitio::Internal::AnyHash + ) + end + + # Type of the custom metadata field. + sig do + returns(Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol) + end + attr_accessor :type + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + sig do + returns( + T.nilable( + Imagekitio::File::SelectedFieldsSchema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekitio::File::SelectedFieldsSchema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # Specifies if the custom metadata field is required or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::File::SelectedFieldsSchema::MaxValue::Variants + ) + ) + end + attr_reader :max_value + + sig do + params( + max_value: + Imagekitio::File::SelectedFieldsSchema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::File::SelectedFieldsSchema::MinValue::Variants + ) + ) + end + attr_reader :min_value + + sig do + params( + min_value: + Imagekitio::File::SelectedFieldsSchema::MinValue::Variants + ).void + end + attr_writer :min_value + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :read_only + + sig { params(read_only: T::Boolean).void } + attr_writer :read_only + + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekitio::File::SelectedFieldsSchema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekitio::File::SelectedFieldsSchema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :select_options_truncated + + sig { params(select_options_truncated: T::Boolean).void } + attr_writer :select_options_truncated + + sig do + params( + type: Imagekitio::File::SelectedFieldsSchema::Type::OrSymbol, + default_value: + Imagekitio::File::SelectedFieldsSchema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::File::SelectedFieldsSchema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::File::SelectedFieldsSchema::MinValue::Variants, + read_only: T::Boolean, + select_options: + T::Array[ + Imagekitio::File::SelectedFieldsSchema::SelectOption::Variants + ], + select_options_truncated: T::Boolean + ).returns(T.attached_class) + end + def self.new( + # Type of the custom metadata field. + type:, + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + default_value: nil, + # Specifies if the custom metadata field is required or not. + is_value_required: nil, + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + max_length: nil, + # 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. + max_value: nil, + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + min_length: nil, + # 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. + min_value: nil, + # 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. + read_only: nil, + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + select_options: nil, + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + select_options_truncated: nil + ) + end + + sig do + override.returns( + { + type: Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol, + default_value: + Imagekitio::File::SelectedFieldsSchema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::File::SelectedFieldsSchema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::File::SelectedFieldsSchema::MinValue::Variants, + read_only: T::Boolean, + select_options: + T::Array[ + Imagekitio::File::SelectedFieldsSchema::SelectOption::Variants + ], + select_options_truncated: T::Boolean + } + ) + end + def to_hash + end + + # Type of the custom metadata field. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekitio::File::SelectedFieldsSchema::Type) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TEXT = + T.let( + :Text, + Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol + ) + TEXTAREA = + T.let( + :Textarea, + Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol + ) + NUMBER = + T.let( + :Number, + Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol + ) + DATE = + T.let( + :Date, + Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol + ) + BOOLEAN = + T.let( + :Boolean, + Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol + ) + SINGLE_SELECT = + T.let( + :SingleSelect, + Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol + ) + MULTI_SELECT = + T.let( + :MultiSelect, + Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::File::SelectedFieldsSchema::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + module DefaultValue + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekitio::File::SelectedFieldsSchema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::File::SelectedFieldsSchema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::File::SelectedFieldsSchema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + union: + Imagekitio::File::SelectedFieldsSchema::DefaultValue::Mixed + ], + Imagekitio::Internal::Type::Converter + ) + end + + # 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. + module MaxValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::File::SelectedFieldsSchema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # 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. + module MinValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::File::SelectedFieldsSchema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::File::SelectedFieldsSchema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + + # Type of the asset. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, Imagekitio::File::Type) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + FILE = T.let(:file, Imagekitio::File::Type::TaggedSymbol) + FILE_VERSION = + T.let(:"file-version", Imagekitio::File::Type::TaggedSymbol) + + sig { override.returns(T::Array[Imagekitio::File::Type::TaggedSymbol]) } + def self.values + end + end + + class VersionInfo < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::File::VersionInfo, Imagekitio::Internal::AnyHash) + end + + # Unique identifier of the file version. + sig { returns(T.nilable(String)) } + attr_reader :id + + sig { params(id: String).void } + attr_writer :id + + # Name of the file version. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # An object with details of the file version. + sig { params(id: String, name: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the file version. + id: nil, + # Name of the file version. + name: nil + ) + end + + sig { override.returns({ id: String, name: String }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/file_copy_params.rbi b/rbi/imagekitio/models/file_copy_params.rbi new file mode 100644 index 00000000..a8abbf1a --- /dev/null +++ b/rbi/imagekitio/models/file_copy_params.rbi @@ -0,0 +1,66 @@ +# typed: strong + +module Imagekitio + module Models + class FileCopyParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FileCopyParams, Imagekitio::Internal::AnyHash) + end + + # Full path to the folder you want to copy the above file into. + sig { returns(String) } + attr_accessor :destination_path + + # The full path of the file you want to copy. + sig { returns(String) } + attr_accessor :source_file_path + + # 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`. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_file_versions + + sig { params(include_file_versions: T::Boolean).void } + attr_writer :include_file_versions + + sig do + params( + destination_path: String, + source_file_path: String, + include_file_versions: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the folder you want to copy the above file into. + destination_path:, + # The full path of the file you want to copy. + source_file_path:, + # 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`. + include_file_versions: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + destination_path: String, + source_file_path: String, + include_file_versions: T::Boolean, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/file_copy_response.rbi b/rbi/imagekitio/models/file_copy_response.rbi new file mode 100644 index 00000000..a1f560f1 --- /dev/null +++ b/rbi/imagekitio/models/file_copy_response.rbi @@ -0,0 +1,23 @@ +# typed: strong + +module Imagekitio + module Models + class FileCopyResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileCopyResponse, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/file_delete_params.rbi b/rbi/imagekitio/models/file_delete_params.rbi new file mode 100644 index 00000000..529474d9 --- /dev/null +++ b/rbi/imagekitio/models/file_delete_params.rbi @@ -0,0 +1,27 @@ +# typed: strong + +module Imagekitio + module Models + class FileDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FileDeleteParams, Imagekitio::Internal::AnyHash) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekitio::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/file_get_params.rbi b/rbi/imagekitio/models/file_get_params.rbi new file mode 100644 index 00000000..0e0425c5 --- /dev/null +++ b/rbi/imagekitio/models/file_get_params.rbi @@ -0,0 +1,27 @@ +# typed: strong + +module Imagekitio + module Models + class FileGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FileGetParams, Imagekitio::Internal::AnyHash) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekitio::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/file_move_params.rbi b/rbi/imagekitio/models/file_move_params.rbi new file mode 100644 index 00000000..6ebb66f0 --- /dev/null +++ b/rbi/imagekitio/models/file_move_params.rbi @@ -0,0 +1,51 @@ +# typed: strong + +module Imagekitio + module Models + class FileMoveParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FileMoveParams, Imagekitio::Internal::AnyHash) + end + + # Full path to the folder you want to move the above file into. + sig { returns(String) } + attr_accessor :destination_path + + # The full path of the file you want to move. + sig { returns(String) } + attr_accessor :source_file_path + + sig do + params( + destination_path: String, + source_file_path: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the folder you want to move the above file into. + destination_path:, + # The full path of the file you want to move. + source_file_path:, + request_options: {} + ) + end + + sig do + override.returns( + { + destination_path: String, + source_file_path: String, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/file_move_response.rbi b/rbi/imagekitio/models/file_move_response.rbi new file mode 100644 index 00000000..9a62f027 --- /dev/null +++ b/rbi/imagekitio/models/file_move_response.rbi @@ -0,0 +1,23 @@ +# typed: strong + +module Imagekitio + module Models + class FileMoveResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileMoveResponse, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/file_rename_params.rbi b/rbi/imagekitio/models/file_rename_params.rbi new file mode 100644 index 00000000..b460cd72 --- /dev/null +++ b/rbi/imagekitio/models/file_rename_params.rbi @@ -0,0 +1,102 @@ +# typed: strong + +module Imagekitio + module Models + class FileRenameParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FileRenameParams, Imagekitio::Internal::AnyHash) + end + + # The full path of the file you want to rename. + sig { returns(String) } + attr_accessor :file_path + + # 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 `_`. + sig { returns(String) } + attr_accessor :new_file_name + + # 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` + sig { returns(T.nilable(T::Boolean)) } + attr_reader :purge_cache + + sig { params(purge_cache: T::Boolean).void } + attr_writer :purge_cache + + sig do + params( + file_path: String, + new_file_name: String, + purge_cache: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The full path of the file you want to rename. + file_path:, + # 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 `_`. + new_file_name:, + # 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` + purge_cache: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + file_path: String, + new_file_name: String, + purge_cache: T::Boolean, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/file_rename_response.rbi b/rbi/imagekitio/models/file_rename_response.rbi new file mode 100644 index 00000000..ec001111 --- /dev/null +++ b/rbi/imagekitio/models/file_rename_response.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Imagekitio + module Models + class FileRenameResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileRenameResponse, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + sig { returns(T.nilable(String)) } + attr_reader :purge_request_id + + sig { params(purge_request_id: String).void } + attr_writer :purge_request_id + + sig { params(purge_request_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the purge request. This can be used to check the status of + # the purge request. + purge_request_id: nil + ) + end + + sig { override.returns({ purge_request_id: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/file_update_params.rbi b/rbi/imagekitio/models/file_update_params.rbi new file mode 100644 index 00000000..c0d1a69c --- /dev/null +++ b/rbi/imagekitio/models/file_update_params.rbi @@ -0,0 +1,58 @@ +# typed: strong + +module Imagekitio + module Models + class FileUpdateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FileUpdateParams, Imagekitio::Internal::AnyHash) + end + + # Schema for update file update request. + sig do + returns( + T.any( + Imagekitio::UpdateFileRequest::UpdateFileDetails, + Imagekitio::UpdateFileRequest::ChangePublicationStatus + ) + ) + end + attr_accessor :update_file_request + + sig do + params( + update_file_request: + T.any( + Imagekitio::UpdateFileRequest::UpdateFileDetails::OrHash, + Imagekitio::UpdateFileRequest::ChangePublicationStatus::OrHash + ), + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Schema for update file update request. + update_file_request:, + request_options: {} + ) + end + + sig do + override.returns( + { + update_file_request: + T.any( + Imagekitio::UpdateFileRequest::UpdateFileDetails, + Imagekitio::UpdateFileRequest::ChangePublicationStatus + ), + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/file_update_response.rbi b/rbi/imagekitio/models/file_update_response.rbi new file mode 100644 index 00000000..3db28abe --- /dev/null +++ b/rbi/imagekitio/models/file_update_response.rbi @@ -0,0 +1,322 @@ +# typed: strong + +module Imagekitio + module Models + class FileUpdateResponse < Imagekitio::Models::File + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileUpdateResponse, + Imagekitio::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable(Imagekitio::Models::FileUpdateResponse::ExtensionStatus) + ) + end + attr_reader :extension_status + + sig do + params( + extension_status: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::OrHash + ).void + end + attr_writer :extension_status + + # Object containing details of a file or file version. + sig do + params( + extension_status: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::OrHash + ).returns(T.attached_class) + end + def self.new(extension_status: nil) + end + + sig do + override.returns( + { + extension_status: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus + } + ) + end + def to_hash + end + + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus, + Imagekitio::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + ) + end + attr_reader :ai_auto_description + + sig do + params( + ai_auto_description: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::OrSymbol + ).void + end + attr_writer :ai_auto_description + + sig do + returns( + T.nilable( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :aws_auto_tagging + + sig do + params( + aws_auto_tagging: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::OrSymbol + ).void + end + attr_writer :aws_auto_tagging + + sig do + returns( + T.nilable( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :google_auto_tagging + + sig do + params( + google_auto_tagging: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol + ).void + end + attr_writer :google_auto_tagging + + sig do + returns( + T.nilable( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + ) + end + attr_reader :remove_bg + + sig do + params( + remove_bg: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::OrSymbol + ).void + end + attr_writer :remove_bg + + sig do + params( + ai_auto_description: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::OrSymbol, + aws_auto_tagging: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::OrSymbol, + google_auto_tagging: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol, + remove_bg: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::OrSymbol + ).returns(T.attached_class) + end + def self.new( + ai_auto_description: nil, + aws_auto_tagging: nil, + google_auto_tagging: nil, + remove_bg: nil + ) + end + + sig do + override.returns( + { + ai_auto_description: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol, + aws_auto_tagging: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol, + google_auto_tagging: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol, + remove_bg: + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + } + ) + end + def to_hash + end + + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ] + ) + end + def self.values + end + end + + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/file_upload_params.rbi b/rbi/imagekitio/models/file_upload_params.rbi new file mode 100644 index 00000000..064e4c37 --- /dev/null +++ b/rbi/imagekitio/models/file_upload_params.rbi @@ -0,0 +1,897 @@ +# typed: strong + +module Imagekitio + module Models + class FileUploadParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FileUploadParams, Imagekitio::Internal::AnyHash) + end + + # 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. + sig { returns(Imagekitio::Internal::FileInput) } + attr_accessor :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 `_` + sig { returns(String) } + attr_accessor :file_name + + # 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. + sig { returns(T.nilable(String)) } + attr_reader :token + + sig { params(token: String).void } + attr_writer :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). + sig { returns(T.nilable(String)) } + attr_reader :checks + + sig { params(checks: String).void } + attr_writer :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. + sig { returns(T.nilable(String)) } + attr_reader :custom_coordinates + + sig { params(custom_coordinates: String).void } + attr_writer :custom_coordinates + + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :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. + sig { returns(T.nilable(Integer)) } + attr_reader :expire + + sig { params(expire: Integer).void } + attr_writer :expire + + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg, + Imagekitio::ExtensionItem::AIAutoDescription, + Imagekitio::ExtensionItem::AutoTaggingExtension + ) + ] + ) + ) + end + attr_reader :extensions + + sig do + params( + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg::OrHash, + Imagekitio::ExtensionItem::AIAutoDescription::OrHash, + Imagekitio::ExtensionItem::AutoTaggingExtension::OrHash + ) + ] + ).void + end + attr_writer :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. + sig { returns(T.nilable(String)) } + attr_reader :folder + + sig { params(folder: String).void } + attr_writer :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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_ai_tags + + sig { params(overwrite_ai_tags: T::Boolean).void } + attr_writer :overwrite_ai_tags + + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_custom_metadata + + sig { params(overwrite_custom_metadata: T::Boolean).void } + attr_writer :overwrite_custom_metadata + + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_file + + sig { params(overwrite_file: T::Boolean).void } + attr_writer :overwrite_file + + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :overwrite_tags + + sig { params(overwrite_tags: T::Boolean).void } + attr_writer :overwrite_tags + + # Your ImageKit.io public key. This field is only required for authentication when + # uploading a file from the client side. + sig { returns(T.nilable(String)) } + attr_reader :public_key + + sig { params(public_key: String).void } + attr_writer :public_key + + # Array of response field keys to include in the API response body. + sig do + returns( + T.nilable( + T::Array[Imagekitio::FileUploadParams::ResponseField::OrSymbol] + ) + ) + end + attr_reader :response_fields + + sig do + params( + response_fields: + T::Array[Imagekitio::FileUploadParams::ResponseField::OrSymbol] + ).void + end + attr_writer :response_fields + + # 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. + sig { returns(T.nilable(String)) } + attr_reader :signature + + sig { params(signature: String).void } + attr_writer :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. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :tags + + sig { params(tags: T::Array[String]).void } + attr_writer :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. + sig { returns(T.nilable(Imagekitio::FileUploadParams::Transformation)) } + attr_reader :transformation + + sig do + params( + transformation: Imagekitio::FileUploadParams::Transformation::OrHash + ).void + end + attr_writer :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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :use_unique_file_name + + sig { params(use_unique_file_name: T::Boolean).void } + attr_writer :use_unique_file_name + + # 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. + sig { returns(T.nilable(String)) } + attr_reader :webhook_url + + sig { params(webhook_url: String).void } + attr_writer :webhook_url + + sig do + params( + file: Imagekitio::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + expire: Integer, + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg::OrHash, + Imagekitio::ExtensionItem::AIAutoDescription::OrHash, + Imagekitio::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + public_key: String, + response_fields: + T::Array[Imagekitio::FileUploadParams::ResponseField::OrSymbol], + signature: String, + tags: T::Array[String], + transformation: Imagekitio::FileUploadParams::Transformation::OrHash, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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. + 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 `_` + file_name:, + # 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. + token: nil, + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + checks: nil, + # 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. + custom_coordinates: nil, + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # 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. + expire: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # 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. + folder: nil, + # 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. + is_private_file: nil, + # 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. + is_published: nil, + # 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. + overwrite_ai_tags: nil, + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + overwrite_custom_metadata: nil, + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + overwrite_file: nil, + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + overwrite_tags: nil, + # Your ImageKit.io public key. This field is only required for authentication when + # uploading a file from the client side. + public_key: nil, + # Array of response field keys to include in the API response body. + response_fields: nil, + # 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. + signature: nil, + # 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. + tags: nil, + # 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. + transformation: nil, + # 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. + use_unique_file_name: nil, + # 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. + webhook_url: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + file: Imagekitio::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + expire: Integer, + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg, + Imagekitio::ExtensionItem::AIAutoDescription, + Imagekitio::ExtensionItem::AutoTaggingExtension + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + public_key: String, + response_fields: + T::Array[Imagekitio::FileUploadParams::ResponseField::OrSymbol], + signature: String, + tags: T::Array[String], + transformation: Imagekitio::FileUploadParams::Transformation, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + + module ResponseField + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekitio::FileUploadParams::ResponseField) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TAGS = + T.let( + :tags, + Imagekitio::FileUploadParams::ResponseField::TaggedSymbol + ) + CUSTOM_COORDINATES = + T.let( + :customCoordinates, + Imagekitio::FileUploadParams::ResponseField::TaggedSymbol + ) + IS_PRIVATE_FILE = + T.let( + :isPrivateFile, + Imagekitio::FileUploadParams::ResponseField::TaggedSymbol + ) + EMBEDDED_METADATA = + T.let( + :embeddedMetadata, + Imagekitio::FileUploadParams::ResponseField::TaggedSymbol + ) + IS_PUBLISHED = + T.let( + :isPublished, + Imagekitio::FileUploadParams::ResponseField::TaggedSymbol + ) + CUSTOM_METADATA = + T.let( + :customMetadata, + Imagekitio::FileUploadParams::ResponseField::TaggedSymbol + ) + METADATA = + T.let( + :metadata, + Imagekitio::FileUploadParams::ResponseField::TaggedSymbol + ) + SELECTED_FIELDS_SCHEMA = + T.let( + :selectedFieldsSchema, + Imagekitio::FileUploadParams::ResponseField::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Imagekitio::FileUploadParams::ResponseField::TaggedSymbol] + ) + end + def self.values + end + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::FileUploadParams::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + # 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`. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekitio::FileUploadParams::Transformation::Post::Transformation, + Imagekitio::FileUploadParams::Transformation::Post::GifToVideo, + Imagekitio::FileUploadParams::Transformation::Post::Thumbnail, + Imagekitio::FileUploadParams::Transformation::Post::Abs + ) + ] + ) + ) + end + attr_reader :post + + sig do + params( + post: + T::Array[ + T.any( + Imagekitio::FileUploadParams::Transformation::Post::Transformation::OrHash, + Imagekitio::FileUploadParams::Transformation::Post::GifToVideo::OrHash, + Imagekitio::FileUploadParams::Transformation::Post::Thumbnail::OrHash, + Imagekitio::FileUploadParams::Transformation::Post::Abs::OrHash + ) + ] + ).void + end + attr_writer :post + + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + sig { returns(T.nilable(String)) } + attr_reader :pre + + sig { params(pre: String).void } + attr_writer :pre + + # 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. + sig do + params( + post: + T::Array[ + T.any( + Imagekitio::FileUploadParams::Transformation::Post::Transformation::OrHash, + Imagekitio::FileUploadParams::Transformation::Post::GifToVideo::OrHash, + Imagekitio::FileUploadParams::Transformation::Post::Thumbnail::OrHash, + Imagekitio::FileUploadParams::Transformation::Post::Abs::OrHash + ) + ], + pre: String + ).returns(T.attached_class) + end + def self.new( + # 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`. + post: nil, + # Transformation string to apply before uploading the file to the Media Library. + # Useful for optimizing files at ingestion. + pre: nil + ) + end + + sig do + override.returns( + { + post: + T::Array[ + T.any( + Imagekitio::FileUploadParams::Transformation::Post::Transformation, + Imagekitio::FileUploadParams::Transformation::Post::GifToVideo, + Imagekitio::FileUploadParams::Transformation::Post::Thumbnail, + Imagekitio::FileUploadParams::Transformation::Post::Abs + ) + ], + pre: String + } + ) + end + def to_hash + end + + module Post + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::FileUploadParams::Transformation::Post::Transformation, + Imagekitio::FileUploadParams::Transformation::Post::GifToVideo, + Imagekitio::FileUploadParams::Transformation::Post::Thumbnail, + Imagekitio::FileUploadParams::Transformation::Post::Abs + ) + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::FileUploadParams::Transformation::Post::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + # Transformation type. + sig { returns(Symbol) } + attr_accessor :type + + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + sig { returns(String) } + attr_accessor :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Transformation string (e.g. `w-200,h-200`). + # Same syntax as ImageKit URL-based transformations. + value:, + # Transformation type. + type: :transformation + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class GifToVideo < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::FileUploadParams::Transformation::Post::GifToVideo, + Imagekitio::Internal::AnyHash + ) + end + + # Converts an animated GIF into an MP4. + sig { returns(Symbol) } + attr_accessor :type + + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Optional transformation string to apply to the output video. + # **Example**: `q-80` + value: nil, + # Converts an animated GIF into an MP4. + type: :"gif-to-video" + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class Thumbnail < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::FileUploadParams::Transformation::Post::Thumbnail, + Imagekitio::Internal::AnyHash + ) + end + + # Generates a thumbnail image. + sig { returns(Symbol) } + attr_accessor :type + + # Optional transformation string. + # **Example**: `w-150,h-150` + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params(value: String, type: Symbol).returns(T.attached_class) + end + def self.new( + # Optional transformation string. + # **Example**: `w-150,h-150` + value: nil, + # Generates a thumbnail image. + type: :thumbnail + ) + end + + sig { override.returns({ type: Symbol, value: String }) } + def to_hash + end + end + + class Abs < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::FileUploadParams::Transformation::Post::Abs, + Imagekitio::Internal::AnyHash + ) + end + + # Streaming protocol to use (`hls` or `dash`). + sig do + returns( + Imagekitio::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol + ) + end + attr_accessor :protocol + + # Adaptive Bitrate Streaming (ABS) setup. + sig { returns(Symbol) } + attr_accessor :type + + # List of different representations you want to create separated by an underscore. + sig { returns(String) } + attr_accessor :value + + sig do + params( + protocol: + Imagekitio::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol, + value: String, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Streaming protocol to use (`hls` or `dash`). + protocol:, + # List of different representations you want to create separated by an underscore. + value:, + # Adaptive Bitrate Streaming (ABS) setup. + type: :abs + ) + end + + sig do + override.returns( + { + protocol: + Imagekitio::FileUploadParams::Transformation::Post::Abs::Protocol::OrSymbol, + type: Symbol, + value: String + } + ) + end + def to_hash + end + + # Streaming protocol to use (`hls` or `dash`). + module Protocol + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::FileUploadParams::Transformation::Post::Abs::Protocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :hls, + Imagekitio::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ) + DASH = + T.let( + :dash, + Imagekitio::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::FileUploadParams::Transformation::Post::Abs::Protocol::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::FileUploadParams::Transformation::Post::Variants + ] + ) + end + def self.variants + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/file_upload_response.rbi b/rbi/imagekitio/models/file_upload_response.rbi new file mode 100644 index 00000000..0e88ee70 --- /dev/null +++ b/rbi/imagekitio/models/file_upload_response.rbi @@ -0,0 +1,1176 @@ +# typed: strong + +module Imagekitio + module Models + class FileUploadResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileUploadResponse, + Imagekitio::Internal::AnyHash + ) + end + + # An array of tags assigned to the uploaded file by auto tagging. + sig do + returns( + T.nilable(T::Array[Imagekitio::Models::FileUploadResponse::AITag]) + ) + end + attr_accessor :ai_tags + + # The audio codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :audio_codec + + sig { params(audio_codec: String).void } + attr_writer :audio_codec + + # The bit rate of the video in kbps (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :bit_rate + + sig { params(bit_rate: Integer).void } + attr_writer :bit_rate + + # 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. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # 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. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # The duration of the video in seconds (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :duration + + sig { params(duration: Integer).void } + attr_writer :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. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :embedded_metadata + + sig { params(embedded_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :embedded_metadata + + # 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. + sig do + returns( + T.nilable(Imagekitio::Models::FileUploadResponse::ExtensionStatus) + ) + end + attr_reader :extension_status + + sig do + params( + extension_status: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::OrHash + ).void + end + attr_writer :extension_status + + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + sig { returns(T.nilable(String)) } + attr_reader :file_id + + sig { params(file_id: String).void } + attr_writer :file_id + + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + sig { returns(T.nilable(String)) } + attr_reader :file_path + + sig { params(file_path: String).void } + attr_writer :file_path + + # Type of the uploaded file. Possible values are `image`, `non-image`. + sig { returns(T.nilable(String)) } + attr_reader :file_type + + sig { params(file_type: String).void } + attr_writer :file_type + + # Height of the image in pixels (Only for images) + sig { returns(T.nilable(Float)) } + attr_reader :height + + sig { params(height: Float).void } + attr_writer :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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + sig { returns(T.nilable(Imagekitio::Metadata)) } + attr_reader :metadata + + sig { params(metadata: Imagekitio::Metadata::OrHash).void } + attr_writer :metadata + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :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. + sig do + returns( + T.nilable( + T::Hash[ + Symbol, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema + ] + ) + ) + end + attr_reader :selected_fields_schema + + sig do + params( + selected_fields_schema: + T::Hash[ + Symbol, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::OrHash + ] + ).void + end + attr_writer :selected_fields_schema + + # Size of the image file in Bytes. + sig { returns(T.nilable(Float)) } + attr_reader :size + + sig { params(size: Float).void } + attr_writer :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. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :tags + + # In the case of an image, a small thumbnail URL. + sig { returns(T.nilable(String)) } + attr_reader :thumbnail_url + + sig { params(thumbnail_url: String).void } + attr_writer :thumbnail_url + + # A publicly accessible URL of the file. + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url + + # An object containing the file or file version's `id` (versionId) and `name`. + sig do + returns(T.nilable(Imagekitio::Models::FileUploadResponse::VersionInfo)) + end + attr_reader :version_info + + sig do + params( + version_info: + Imagekitio::Models::FileUploadResponse::VersionInfo::OrHash + ).void + end + attr_writer :version_info + + # The video codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :video_codec + + sig { params(video_codec: String).void } + attr_writer :video_codec + + # Width of the image in pixels (Only for Images) + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Object containing details of a successful upload. + sig do + params( + ai_tags: + T.nilable( + T::Array[Imagekitio::Models::FileUploadResponse::AITag::OrHash] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::OrHash, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekitio::Metadata::OrHash, + name: String, + selected_fields_schema: + T::Hash[ + Symbol, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::OrHash + ], + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekitio::Models::FileUploadResponse::VersionInfo::OrHash, + video_codec: String, + width: Float + ).returns(T.attached_class) + end + def self.new( + # An array of tags assigned to the uploaded file by auto tagging. + ai_tags: nil, + # The audio codec used in the video (only for video). + audio_codec: nil, + # The bit rate of the video in kbps (only for video). + bit_rate: nil, + # 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. + custom_coordinates: nil, + # 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. + custom_metadata: nil, + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + description: nil, + # The duration of the video in seconds (only for video). + duration: nil, + # 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. + embedded_metadata: nil, + # 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. + extension_status: nil, + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + file_id: nil, + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + file_path: nil, + # Type of the uploaded file. Possible values are `image`, `non-image`. + file_type: nil, + # Height of the image in pixels (Only for images) + height: nil, + # 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. + is_private_file: nil, + # 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. + is_published: nil, + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + metadata: nil, + # Name of the asset. + name: nil, + # 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. + selected_fields_schema: nil, + # Size of the image file in Bytes. + size: nil, + # 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. + tags: nil, + # In the case of an image, a small thumbnail URL. + thumbnail_url: nil, + # A publicly accessible URL of the file. + url: nil, + # An object containing the file or file version's `id` (versionId) and `name`. + version_info: nil, + # The video codec used in the video (only for video). + video_codec: nil, + # Width of the image in pixels (Only for Images) + width: nil + ) + end + + sig do + override.returns( + { + ai_tags: + T.nilable( + T::Array[Imagekitio::Models::FileUploadResponse::AITag] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekitio::Models::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekitio::Metadata, + name: String, + selected_fields_schema: + T::Hash[ + Symbol, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema + ], + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: Imagekitio::Models::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + ) + end + def to_hash + end + + class AITag < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileUploadResponse::AITag, + Imagekitio::Internal::AnyHash + ) + end + + # Confidence score of the tag. + sig { returns(T.nilable(Float)) } + attr_reader :confidence + + sig { params(confidence: Float).void } + attr_writer :confidence + + # Name of the tag. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + sig { returns(T.nilable(String)) } + attr_reader :source + + sig { params(source: String).void } + attr_writer :source + + sig do + params(confidence: Float, name: String, source: String).returns( + T.attached_class + ) + end + def self.new( + # Confidence score of the tag. + confidence: nil, + # Name of the tag. + name: nil, + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + source: nil + ) + end + + sig do + override.returns({ confidence: Float, name: String, source: String }) + end + def to_hash + end + end + + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileUploadResponse::ExtensionStatus, + Imagekitio::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable( + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + ) + end + attr_reader :ai_auto_description + + sig do + params( + ai_auto_description: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::OrSymbol + ).void + end + attr_writer :ai_auto_description + + sig do + returns( + T.nilable( + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :aws_auto_tagging + + sig do + params( + aws_auto_tagging: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::OrSymbol + ).void + end + attr_writer :aws_auto_tagging + + sig do + returns( + T.nilable( + Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :google_auto_tagging + + sig do + params( + google_auto_tagging: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol + ).void + end + attr_writer :google_auto_tagging + + sig do + returns( + T.nilable( + Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + ) + end + attr_reader :remove_bg + + sig do + params( + remove_bg: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg::OrSymbol + ).void + end + attr_writer :remove_bg + + # 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. + sig do + params( + ai_auto_description: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::OrSymbol, + aws_auto_tagging: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::OrSymbol, + google_auto_tagging: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::OrSymbol, + remove_bg: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg::OrSymbol + ).returns(T.attached_class) + end + def self.new( + ai_auto_description: nil, + aws_auto_tagging: nil, + google_auto_tagging: nil, + remove_bg: nil + ) + end + + sig do + override.returns( + { + ai_auto_description: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol, + aws_auto_tagging: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol, + google_auto_tagging: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol, + remove_bg: + Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + } + ) + end + def to_hash + end + + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AIAutoDescription::TaggedSymbol + ] + ) + end + def self.values + end + end + + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::ExtensionStatus::RemoveBg::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema, + Imagekitio::Internal::AnyHash + ) + end + + # Type of the custom metadata field. + sig do + returns( + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + end + attr_accessor :type + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + sig do + returns( + T.nilable( + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # Specifies if the custom metadata field is required or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants + ) + ) + end + attr_reader :max_value + + sig do + params( + max_value: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants + ) + ) + end + attr_reader :min_value + + sig do + params( + min_value: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants + ).void + end + attr_writer :min_value + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :read_only + + sig { params(read_only: T::Boolean).void } + attr_writer :read_only + + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :select_options_truncated + + sig { params(select_options_truncated: T::Boolean).void } + attr_writer :select_options_truncated + + sig do + params( + type: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::OrSymbol, + default_value: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants, + read_only: T::Boolean, + select_options: + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ], + select_options_truncated: T::Boolean + ).returns(T.attached_class) + end + def self.new( + # Type of the custom metadata field. + type:, + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + default_value: nil, + # Specifies if the custom metadata field is required or not. + is_value_required: nil, + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + max_length: nil, + # 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. + max_value: nil, + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + min_length: nil, + # 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. + min_value: nil, + # 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. + read_only: nil, + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + select_options: nil, + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + select_options_truncated: nil + ) + end + + sig do + override.returns( + { + type: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol, + default_value: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants, + read_only: T::Boolean, + select_options: + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ], + select_options_truncated: T::Boolean + } + ) + end + def to_hash + end + + # Type of the custom metadata field. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TEXT = + T.let( + :Text, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + TEXTAREA = + T.let( + :Textarea, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + NUMBER = + T.let( + :Number, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + DATE = + T.let( + :Date, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + BOOLEAN = + T.let( + :Boolean, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + SINGLE_SELECT = + T.let( + :SingleSelect, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + MULTI_SELECT = + T.let( + :MultiSelect, + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + module DefaultValue + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + union: + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::Mixed + ], + Imagekitio::Internal::Type::Converter + ) + end + + # 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. + module MaxValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # 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. + module MinValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + + class VersionInfo < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FileUploadResponse::VersionInfo, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the file version. + sig { returns(T.nilable(String)) } + attr_reader :id + + sig { params(id: String).void } + attr_writer :id + + # Name of the file version. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # An object containing the file or file version's `id` (versionId) and `name`. + sig { params(id: String, name: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the file version. + id: nil, + # Name of the file version. + name: nil + ) + end + + sig { override.returns({ id: String, name: String }) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/bulk_add_tags_params.rbi b/rbi/imagekitio/models/files/bulk_add_tags_params.rbi new file mode 100644 index 00000000..837d0c0e --- /dev/null +++ b/rbi/imagekitio/models/files/bulk_add_tags_params.rbi @@ -0,0 +1,56 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class BulkAddTagsParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::BulkAddTagsParams, + Imagekitio::Internal::AnyHash + ) + end + + # An array of fileIds to which you want to add tags. + sig { returns(T::Array[String]) } + attr_accessor :file_ids + + # An array of tags that you want to add to the files. + sig { returns(T::Array[String]) } + attr_accessor :tags + + sig do + params( + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # An array of fileIds to which you want to add tags. + file_ids:, + # An array of tags that you want to add to the files. + tags:, + request_options: {} + ) + end + + sig do + override.returns( + { + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/bulk_add_tags_response.rbi b/rbi/imagekitio/models/files/bulk_add_tags_response.rbi new file mode 100644 index 00000000..0907c835 --- /dev/null +++ b/rbi/imagekitio/models/files/bulk_add_tags_response.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class BulkAddTagsResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Files::BulkAddTagsResponse, + Imagekitio::Internal::AnyHash + ) + end + + # An array of fileIds that in which tags were successfully added. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :successfully_updated_file_ids + + sig { params(successfully_updated_file_ids: T::Array[String]).void } + attr_writer :successfully_updated_file_ids + + sig do + params(successfully_updated_file_ids: T::Array[String]).returns( + T.attached_class + ) + end + def self.new( + # An array of fileIds that in which tags were successfully added. + successfully_updated_file_ids: nil + ) + end + + sig do + override.returns({ successfully_updated_file_ids: T::Array[String] }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/bulk_delete_params.rbi b/rbi/imagekitio/models/files/bulk_delete_params.rbi new file mode 100644 index 00000000..eb5cb210 --- /dev/null +++ b/rbi/imagekitio/models/files/bulk_delete_params.rbi @@ -0,0 +1,48 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class BulkDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::BulkDeleteParams, + Imagekitio::Internal::AnyHash + ) + end + + # An array of fileIds which you want to delete. + sig { returns(T::Array[String]) } + attr_accessor :file_ids + + sig do + params( + file_ids: T::Array[String], + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # An array of fileIds which you want to delete. + file_ids:, + request_options: {} + ) + end + + sig do + override.returns( + { + file_ids: T::Array[String], + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/bulk_delete_response.rbi b/rbi/imagekitio/models/files/bulk_delete_response.rbi new file mode 100644 index 00000000..bce23e4e --- /dev/null +++ b/rbi/imagekitio/models/files/bulk_delete_response.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class BulkDeleteResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Files::BulkDeleteResponse, + Imagekitio::Internal::AnyHash + ) + end + + # An array of fileIds that were successfully deleted. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :successfully_deleted_file_ids + + sig { params(successfully_deleted_file_ids: T::Array[String]).void } + attr_writer :successfully_deleted_file_ids + + sig do + params(successfully_deleted_file_ids: T::Array[String]).returns( + T.attached_class + ) + end + def self.new( + # An array of fileIds that were successfully deleted. + successfully_deleted_file_ids: nil + ) + end + + sig do + override.returns({ successfully_deleted_file_ids: T::Array[String] }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/bulk_remove_ai_tags_params.rbi b/rbi/imagekitio/models/files/bulk_remove_ai_tags_params.rbi new file mode 100644 index 00000000..4b18e35b --- /dev/null +++ b/rbi/imagekitio/models/files/bulk_remove_ai_tags_params.rbi @@ -0,0 +1,56 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class BulkRemoveAITagsParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::BulkRemoveAITagsParams, + Imagekitio::Internal::AnyHash + ) + end + + # An array of AITags that you want to remove from the files. + sig { returns(T::Array[String]) } + attr_accessor :ai_tags + + # An array of fileIds from which you want to remove AITags. + sig { returns(T::Array[String]) } + attr_accessor :file_ids + + sig do + params( + ai_tags: T::Array[String], + file_ids: T::Array[String], + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # An array of AITags that you want to remove from the files. + ai_tags:, + # An array of fileIds from which you want to remove AITags. + file_ids:, + request_options: {} + ) + end + + sig do + override.returns( + { + ai_tags: T::Array[String], + file_ids: T::Array[String], + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/bulk_remove_ai_tags_response.rbi b/rbi/imagekitio/models/files/bulk_remove_ai_tags_response.rbi new file mode 100644 index 00000000..afaeeada --- /dev/null +++ b/rbi/imagekitio/models/files/bulk_remove_ai_tags_response.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class BulkRemoveAITagsResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Files::BulkRemoveAITagsResponse, + Imagekitio::Internal::AnyHash + ) + end + + # An array of fileIds that in which AITags were successfully removed. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :successfully_updated_file_ids + + sig { params(successfully_updated_file_ids: T::Array[String]).void } + attr_writer :successfully_updated_file_ids + + sig do + params(successfully_updated_file_ids: T::Array[String]).returns( + T.attached_class + ) + end + def self.new( + # An array of fileIds that in which AITags were successfully removed. + successfully_updated_file_ids: nil + ) + end + + sig do + override.returns({ successfully_updated_file_ids: T::Array[String] }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/bulk_remove_tags_params.rbi b/rbi/imagekitio/models/files/bulk_remove_tags_params.rbi new file mode 100644 index 00000000..9fdeb011 --- /dev/null +++ b/rbi/imagekitio/models/files/bulk_remove_tags_params.rbi @@ -0,0 +1,56 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class BulkRemoveTagsParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::BulkRemoveTagsParams, + Imagekitio::Internal::AnyHash + ) + end + + # An array of fileIds from which you want to remove tags. + sig { returns(T::Array[String]) } + attr_accessor :file_ids + + # An array of tags that you want to remove from the files. + sig { returns(T::Array[String]) } + attr_accessor :tags + + sig do + params( + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # An array of fileIds from which you want to remove tags. + file_ids:, + # An array of tags that you want to remove from the files. + tags:, + request_options: {} + ) + end + + sig do + override.returns( + { + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/bulk_remove_tags_response.rbi b/rbi/imagekitio/models/files/bulk_remove_tags_response.rbi new file mode 100644 index 00000000..d6c6976c --- /dev/null +++ b/rbi/imagekitio/models/files/bulk_remove_tags_response.rbi @@ -0,0 +1,41 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class BulkRemoveTagsResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Files::BulkRemoveTagsResponse, + Imagekitio::Internal::AnyHash + ) + end + + # An array of fileIds that in which tags were successfully removed. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :successfully_updated_file_ids + + sig { params(successfully_updated_file_ids: T::Array[String]).void } + attr_writer :successfully_updated_file_ids + + sig do + params(successfully_updated_file_ids: T::Array[String]).returns( + T.attached_class + ) + end + def self.new( + # An array of fileIds that in which tags were successfully removed. + successfully_updated_file_ids: nil + ) + end + + sig do + override.returns({ successfully_updated_file_ids: T::Array[String] }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/metadata_get_from_url_params.rbi b/rbi/imagekitio/models/files/metadata_get_from_url_params.rbi new file mode 100644 index 00000000..aa191d0c --- /dev/null +++ b/rbi/imagekitio/models/files/metadata_get_from_url_params.rbi @@ -0,0 +1,47 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class MetadataGetFromURLParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::MetadataGetFromURLParams, + Imagekitio::Internal::AnyHash + ) + end + + # Should be a valid file URL. It should be accessible using your ImageKit.io + # account. + sig { returns(String) } + attr_accessor :url + + sig do + params( + url: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Should be a valid file URL. It should be accessible using your ImageKit.io + # account. + url:, + request_options: {} + ) + end + + sig do + override.returns( + { url: String, request_options: Imagekitio::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/metadata_get_params.rbi b/rbi/imagekitio/models/files/metadata_get_params.rbi new file mode 100644 index 00000000..f0e31e56 --- /dev/null +++ b/rbi/imagekitio/models/files/metadata_get_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class MetadataGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::MetadataGetParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/version_delete_params.rbi b/rbi/imagekitio/models/files/version_delete_params.rbi new file mode 100644 index 00000000..22c464cf --- /dev/null +++ b/rbi/imagekitio/models/files/version_delete_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class VersionDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::VersionDeleteParams, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :file_id + + sig do + params( + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(file_id:, request_options: {}) + end + + sig do + override.returns( + { file_id: String, request_options: Imagekitio::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/version_delete_response.rbi b/rbi/imagekitio/models/files/version_delete_response.rbi new file mode 100644 index 00000000..5d7590c7 --- /dev/null +++ b/rbi/imagekitio/models/files/version_delete_response.rbi @@ -0,0 +1,25 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class VersionDeleteResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Files::VersionDeleteResponse, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/version_get_params.rbi b/rbi/imagekitio/models/files/version_get_params.rbi new file mode 100644 index 00000000..5b63d9a3 --- /dev/null +++ b/rbi/imagekitio/models/files/version_get_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class VersionGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::VersionGetParams, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :file_id + + sig do + params( + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(file_id:, request_options: {}) + end + + sig do + override.returns( + { file_id: String, request_options: Imagekitio::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/version_list_params.rbi b/rbi/imagekitio/models/files/version_list_params.rbi new file mode 100644 index 00000000..3e3edd1b --- /dev/null +++ b/rbi/imagekitio/models/files/version_list_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class VersionListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::VersionListParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/files/version_list_response.rbi b/rbi/imagekitio/models/files/version_list_response.rbi new file mode 100644 index 00000000..f149f19c --- /dev/null +++ b/rbi/imagekitio/models/files/version_list_response.rbi @@ -0,0 +1,13 @@ +# typed: strong + +module Imagekitio + module Models + module Files + VersionListResponse = + T.let( + Imagekitio::Internal::Type::ArrayOf[Imagekitio::File], + Imagekitio::Internal::Type::Converter + ) + end + end +end diff --git a/rbi/imagekitio/models/files/version_restore_params.rbi b/rbi/imagekitio/models/files/version_restore_params.rbi new file mode 100644 index 00000000..37cfd965 --- /dev/null +++ b/rbi/imagekitio/models/files/version_restore_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Imagekitio + module Models + module Files + class VersionRestoreParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Files::VersionRestoreParams, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(String) } + attr_accessor :file_id + + sig do + params( + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(file_id:, request_options: {}) + end + + sig do + override.returns( + { file_id: String, request_options: Imagekitio::RequestOptions } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/folder.rbi b/rbi/imagekitio/models/folder.rbi new file mode 100644 index 00000000..d2b61d1c --- /dev/null +++ b/rbi/imagekitio/models/folder.rbi @@ -0,0 +1,121 @@ +# typed: strong + +module Imagekitio + module Models + class Folder < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::Folder, Imagekitio::Internal::AnyHash) + end + + # Date and time when the folder was created. The date and time is in ISO8601 + # format. + sig { returns(T.nilable(Time)) } + attr_reader :created_at + + sig { params(created_at: Time).void } + attr_writer :created_at + + # Unique identifier of the asset. + sig { returns(T.nilable(String)) } + attr_reader :folder_id + + sig { params(folder_id: String).void } + attr_writer :folder_id + + # 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. + sig { returns(T.nilable(String)) } + attr_reader :folder_path + + sig { params(folder_path: String).void } + attr_writer :folder_path + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Type of the asset. + sig { returns(T.nilable(Imagekitio::Folder::Type::TaggedSymbol)) } + attr_reader :type + + sig { params(type: Imagekitio::Folder::Type::OrSymbol).void } + attr_writer :type + + # Date and time when the folder was last updated. The date and time is in ISO8601 + # format. + sig { returns(T.nilable(Time)) } + attr_reader :updated_at + + sig { params(updated_at: Time).void } + attr_writer :updated_at + + sig do + params( + created_at: Time, + folder_id: String, + folder_path: String, + name: String, + type: Imagekitio::Folder::Type::OrSymbol, + updated_at: Time + ).returns(T.attached_class) + end + def self.new( + # Date and time when the folder was created. The date and time is in ISO8601 + # format. + created_at: nil, + # Unique identifier of the asset. + folder_id: nil, + # 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. + folder_path: nil, + # Name of the asset. + name: nil, + # Type of the asset. + type: nil, + # Date and time when the folder was last updated. The date and time is in ISO8601 + # format. + updated_at: nil + ) + end + + sig do + override.returns( + { + created_at: Time, + folder_id: String, + folder_path: String, + name: String, + type: Imagekitio::Folder::Type::TaggedSymbol, + updated_at: Time + } + ) + end + def to_hash + end + + # Type of the asset. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, Imagekitio::Folder::Type) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + FOLDER = T.let(:folder, Imagekitio::Folder::Type::TaggedSymbol) + + sig do + override.returns(T::Array[Imagekitio::Folder::Type::TaggedSymbol]) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekitio/models/folder_copy_params.rbi b/rbi/imagekitio/models/folder_copy_params.rbi new file mode 100644 index 00000000..ccadd4db --- /dev/null +++ b/rbi/imagekitio/models/folder_copy_params.rbi @@ -0,0 +1,68 @@ +# typed: strong + +module Imagekitio + module Models + class FolderCopyParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FolderCopyParams, Imagekitio::Internal::AnyHash) + end + + # Full path to the destination folder where you want to copy the source folder + # into. + sig { returns(String) } + attr_accessor :destination_path + + # The full path to the source folder you want to copy. + sig { returns(String) } + attr_accessor :source_folder_path + + # 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`. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_versions + + sig { params(include_versions: T::Boolean).void } + attr_writer :include_versions + + sig do + params( + destination_path: String, + source_folder_path: String, + include_versions: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the destination folder where you want to copy the source folder + # into. + destination_path:, + # The full path to the source folder you want to copy. + source_folder_path:, + # 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`. + include_versions: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + destination_path: String, + source_folder_path: String, + include_versions: T::Boolean, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folder_copy_response.rbi b/rbi/imagekitio/models/folder_copy_response.rbi new file mode 100644 index 00000000..cfaa16e7 --- /dev/null +++ b/rbi/imagekitio/models/folder_copy_response.rbi @@ -0,0 +1,33 @@ +# typed: strong + +module Imagekitio + module Models + class FolderCopyResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FolderCopyResponse, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + sig { returns(String) } + attr_accessor :job_id + + # Job submitted successfully. A `jobId` will be returned. + sig { params(job_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + job_id: + ) + end + + sig { override.returns({ job_id: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folder_create_params.rbi b/rbi/imagekitio/models/folder_create_params.rbi new file mode 100644 index 00000000..494de6dc --- /dev/null +++ b/rbi/imagekitio/models/folder_create_params.rbi @@ -0,0 +1,71 @@ +# typed: strong + +module Imagekitio + module Models + class FolderCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FolderCreateParams, Imagekitio::Internal::AnyHash) + end + + # 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. + # `_`. + sig { returns(String) } + attr_accessor :folder_name + + # 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. + sig { returns(String) } + attr_accessor :parent_folder_path + + sig do + params( + folder_name: String, + parent_folder_path: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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. + # `_`. + folder_name:, + # 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. + parent_folder_path:, + request_options: {} + ) + end + + sig do + override.returns( + { + folder_name: String, + parent_folder_path: String, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folder_create_response.rbi b/rbi/imagekitio/models/folder_create_response.rbi new file mode 100644 index 00000000..2060734f --- /dev/null +++ b/rbi/imagekitio/models/folder_create_response.rbi @@ -0,0 +1,23 @@ +# typed: strong + +module Imagekitio + module Models + class FolderCreateResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FolderCreateResponse, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folder_delete_params.rbi b/rbi/imagekitio/models/folder_delete_params.rbi new file mode 100644 index 00000000..db006cce --- /dev/null +++ b/rbi/imagekitio/models/folder_delete_params.rbi @@ -0,0 +1,40 @@ +# typed: strong + +module Imagekitio + module Models + class FolderDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FolderDeleteParams, Imagekitio::Internal::AnyHash) + end + + # Full path to the folder you want to delete. For example `/folder/to/delete/`. + sig { returns(String) } + attr_accessor :folder_path + + sig do + params( + folder_path: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the folder you want to delete. For example `/folder/to/delete/`. + folder_path:, + request_options: {} + ) + end + + sig do + override.returns( + { folder_path: String, request_options: Imagekitio::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folder_delete_response.rbi b/rbi/imagekitio/models/folder_delete_response.rbi new file mode 100644 index 00000000..df6c1578 --- /dev/null +++ b/rbi/imagekitio/models/folder_delete_response.rbi @@ -0,0 +1,23 @@ +# typed: strong + +module Imagekitio + module Models + class FolderDeleteResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FolderDeleteResponse, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.attached_class) } + def self.new + end + + sig { override.returns({}) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folder_move_params.rbi b/rbi/imagekitio/models/folder_move_params.rbi new file mode 100644 index 00000000..ac2eb0be --- /dev/null +++ b/rbi/imagekitio/models/folder_move_params.rbi @@ -0,0 +1,53 @@ +# typed: strong + +module Imagekitio + module Models + class FolderMoveParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FolderMoveParams, Imagekitio::Internal::AnyHash) + end + + # Full path to the destination folder where you want to move the source folder + # into. + sig { returns(String) } + attr_accessor :destination_path + + # The full path to the source folder you want to move. + sig { returns(String) } + attr_accessor :source_folder_path + + sig do + params( + destination_path: String, + source_folder_path: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # Full path to the destination folder where you want to move the source folder + # into. + destination_path:, + # The full path to the source folder you want to move. + source_folder_path:, + request_options: {} + ) + end + + sig do + override.returns( + { + destination_path: String, + source_folder_path: String, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folder_move_response.rbi b/rbi/imagekitio/models/folder_move_response.rbi new file mode 100644 index 00000000..5d613bc6 --- /dev/null +++ b/rbi/imagekitio/models/folder_move_response.rbi @@ -0,0 +1,33 @@ +# typed: strong + +module Imagekitio + module Models + class FolderMoveResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FolderMoveResponse, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + sig { returns(String) } + attr_accessor :job_id + + # Job submitted successfully. A `jobId` will be returned. + sig { params(job_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + job_id: + ) + end + + sig { override.returns({ job_id: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folder_rename_params.rbi b/rbi/imagekitio/models/folder_rename_params.rbi new file mode 100644 index 00000000..8a810ab8 --- /dev/null +++ b/rbi/imagekitio/models/folder_rename_params.rbi @@ -0,0 +1,98 @@ +# typed: strong + +module Imagekitio + module Models + class FolderRenameParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::FolderRenameParams, Imagekitio::Internal::AnyHash) + end + + # The full path to the folder you want to rename. + sig { returns(String) } + attr_accessor :folder_path + + # 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. `_`. + sig { returns(String) } + attr_accessor :new_folder_name + + # 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` + sig { returns(T.nilable(T::Boolean)) } + attr_reader :purge_cache + + sig { params(purge_cache: T::Boolean).void } + attr_writer :purge_cache + + sig do + params( + folder_path: String, + new_folder_name: String, + purge_cache: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new( + # The full path to the folder you want to rename. + folder_path:, + # 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. `_`. + new_folder_name:, + # 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` + purge_cache: nil, + request_options: {} + ) + end + + sig do + override.returns( + { + folder_path: String, + new_folder_name: String, + purge_cache: T::Boolean, + request_options: Imagekitio::RequestOptions + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folder_rename_response.rbi b/rbi/imagekitio/models/folder_rename_response.rbi new file mode 100644 index 00000000..379ef47d --- /dev/null +++ b/rbi/imagekitio/models/folder_rename_response.rbi @@ -0,0 +1,33 @@ +# typed: strong + +module Imagekitio + module Models + class FolderRenameResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::FolderRenameResponse, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + sig { returns(String) } + attr_accessor :job_id + + # Job submitted successfully. A `jobId` will be returned. + sig { params(job_id: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the bulk job. This can be used to check the status of the + # bulk job. + job_id: + ) + end + + sig { override.returns({ job_id: String }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/folders/job_get_params.rbi b/rbi/imagekitio/models/folders/job_get_params.rbi new file mode 100644 index 00000000..35a2e840 --- /dev/null +++ b/rbi/imagekitio/models/folders/job_get_params.rbi @@ -0,0 +1,34 @@ +# typed: strong + +module Imagekitio + module Models + module Folders + class JobGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::Folders::JobGetParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig do + override.returns({ request_options: Imagekitio::RequestOptions }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/folders/job_get_response.rbi b/rbi/imagekitio/models/folders/job_get_response.rbi new file mode 100644 index 00000000..275aeebd --- /dev/null +++ b/rbi/imagekitio/models/folders/job_get_response.rbi @@ -0,0 +1,173 @@ +# typed: strong + +module Imagekitio + module Models + module Folders + class JobGetResponse < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Models::Folders::JobGetResponse, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the bulk job. + sig { returns(T.nilable(String)) } + attr_reader :job_id + + sig { params(job_id: String).void } + attr_writer :job_id + + # Unique identifier of the purge request. This will be present only if + # `purgeCache` is set to `true` in the rename folder API request. + sig { returns(T.nilable(String)) } + attr_reader :purge_request_id + + sig { params(purge_request_id: String).void } + attr_writer :purge_request_id + + # Status of the bulk job. + sig do + returns( + T.nilable( + Imagekitio::Models::Folders::JobGetResponse::Status::TaggedSymbol + ) + ) + end + attr_reader :status + + sig do + params( + status: + Imagekitio::Models::Folders::JobGetResponse::Status::OrSymbol + ).void + end + attr_writer :status + + # Type of the bulk job. + sig do + returns( + T.nilable( + Imagekitio::Models::Folders::JobGetResponse::Type::TaggedSymbol + ) + ) + end + attr_reader :type + + sig do + params( + type: Imagekitio::Models::Folders::JobGetResponse::Type::OrSymbol + ).void + end + attr_writer :type + + sig do + params( + job_id: String, + purge_request_id: String, + status: + Imagekitio::Models::Folders::JobGetResponse::Status::OrSymbol, + type: Imagekitio::Models::Folders::JobGetResponse::Type::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Unique identifier of the bulk job. + job_id: nil, + # Unique identifier of the purge request. This will be present only if + # `purgeCache` is set to `true` in the rename folder API request. + purge_request_id: nil, + # Status of the bulk job. + status: nil, + # Type of the bulk job. + type: nil + ) + end + + sig do + override.returns( + { + job_id: String, + purge_request_id: String, + status: + Imagekitio::Models::Folders::JobGetResponse::Status::TaggedSymbol, + type: + Imagekitio::Models::Folders::JobGetResponse::Type::TaggedSymbol + } + ) + end + def to_hash + end + + # Status of the bulk job. + module Status + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekitio::Models::Folders::JobGetResponse::Status) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + PENDING = + T.let( + :Pending, + Imagekitio::Models::Folders::JobGetResponse::Status::TaggedSymbol + ) + COMPLETED = + T.let( + :Completed, + Imagekitio::Models::Folders::JobGetResponse::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Folders::JobGetResponse::Status::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Type of the bulk job. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekitio::Models::Folders::JobGetResponse::Type) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + COPY_FOLDER = + T.let( + :COPY_FOLDER, + Imagekitio::Models::Folders::JobGetResponse::Type::TaggedSymbol + ) + MOVE_FOLDER = + T.let( + :MOVE_FOLDER, + Imagekitio::Models::Folders::JobGetResponse::Type::TaggedSymbol + ) + RENAME_FOLDER = + T.let( + :RENAME_FOLDER, + Imagekitio::Models::Folders::JobGetResponse::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Models::Folders::JobGetResponse::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/get_image_attributes_options.rbi b/rbi/imagekitio/models/get_image_attributes_options.rbi new file mode 100644 index 00000000..9a170a5c --- /dev/null +++ b/rbi/imagekitio/models/get_image_attributes_options.rbi @@ -0,0 +1,121 @@ +# typed: strong + +module Imagekitio + module Models + class GetImageAttributesOptions < Imagekitio::Models::SrcOptions + OrHash = + T.type_alias do + T.any( + Imagekitio::GetImageAttributesOptions, + Imagekitio::Internal::AnyHash + ) + end + + # 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. + sig { returns(T.nilable(T::Array[Float])) } + attr_reader :device_breakpoints + + sig { params(device_breakpoints: T::Array[Float]).void } + attr_writer :device_breakpoints + + # 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. + sig { returns(T.nilable(T::Array[Float])) } + attr_reader :image_breakpoints + + sig { params(image_breakpoints: T::Array[Float]).void } + attr_writer :image_breakpoints + + # 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`. + sig { returns(T.nilable(String)) } + attr_reader :sizes + + sig { params(sizes: String).void } + attr_writer :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. + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Options for generating responsive image attributes including `src`, `srcSet`, + # and `sizes` for HTML `` elements. This schema extends `SrcOptions` to add + # support for responsive image generation with breakpoints. + sig do + params( + device_breakpoints: T::Array[Float], + image_breakpoints: T::Array[Float], + sizes: String, + width: Float + ).returns(T.attached_class) + end + def self.new( + # 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. + device_breakpoints: nil, + # 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. + image_breakpoints: nil, + # 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`. + sizes: nil, + # 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. + width: nil + ) + end + + sig do + override.returns( + { + device_breakpoints: T::Array[Float], + image_breakpoints: T::Array[Float], + sizes: String, + width: Float + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/image_overlay.rbi b/rbi/imagekitio/models/image_overlay.rbi new file mode 100644 index 00000000..fda4e3fe --- /dev/null +++ b/rbi/imagekitio/models/image_overlay.rbi @@ -0,0 +1,109 @@ +# typed: strong + +module Imagekitio + module Models + class ImageOverlay < Imagekitio::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekitio::ImageOverlay, Imagekitio::Internal::AnyHash) + end + + # Specifies the relative path to the image used as an overlay. + sig { returns(String) } + attr_accessor :input + + sig { returns(Symbol) } + attr_accessor :type + + # 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`. + sig { returns(T.nilable(Imagekitio::ImageOverlay::Encoding::OrSymbol)) } + attr_reader :encoding + + sig do + params(encoding: Imagekitio::ImageOverlay::Encoding::OrSymbol).void + end + attr_writer :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). + sig { returns(T.nilable(T::Array[Imagekitio::Transformation])) } + attr_reader :transformation + + sig { params(transformation: T::Array[Imagekitio::Transformation]).void } + attr_writer :transformation + + sig do + params( + input: String, + encoding: Imagekitio::ImageOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekitio::Transformation], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the relative path to the image used as an overlay. + 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`. + encoding: nil, + # 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). + transformation: nil, + type: :image + ) + end + + sig do + override.returns( + { + input: String, + type: Symbol, + encoding: Imagekitio::ImageOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekitio::Transformation] + } + ) + end + def to_hash + end + + # 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`. + module Encoding + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::ImageOverlay::Encoding) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekitio::ImageOverlay::Encoding::TaggedSymbol) + PLAIN = T.let(:plain, Imagekitio::ImageOverlay::Encoding::TaggedSymbol) + BASE64 = + T.let(:base64, Imagekitio::ImageOverlay::Encoding::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::ImageOverlay::Encoding::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekitio/models/metadata.rbi b/rbi/imagekitio/models/metadata.rbi new file mode 100644 index 00000000..dea32d8f --- /dev/null +++ b/rbi/imagekitio/models/metadata.rbi @@ -0,0 +1,813 @@ +# typed: strong + +module Imagekitio + module Models + class Metadata < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::Metadata, Imagekitio::Internal::AnyHash) + end + + # The audio codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :audio_codec + + sig { params(audio_codec: String).void } + attr_writer :audio_codec + + # The bit rate of the video in kbps (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :bit_rate + + sig { params(bit_rate: Integer).void } + attr_writer :bit_rate + + # The density of the image in DPI. + sig { returns(T.nilable(Integer)) } + attr_reader :density + + sig { params(density: Integer).void } + attr_writer :density + + # The duration of the video in seconds (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :duration + + sig { params(duration: Integer).void } + attr_writer :duration + + sig { returns(T.nilable(Imagekitio::Metadata::Exif)) } + attr_reader :exif + + sig { params(exif: Imagekitio::Metadata::Exif::OrHash).void } + attr_writer :exif + + # The format of the file (e.g., 'jpg', 'mp4'). + sig { returns(T.nilable(String)) } + attr_reader :format_ + + sig { params(format_: String).void } + attr_writer :format_ + + # Indicates if the image has a color profile. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :has_color_profile + + sig { params(has_color_profile: T::Boolean).void } + attr_writer :has_color_profile + + # Indicates if the image contains transparent areas. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :has_transparency + + sig { params(has_transparency: T::Boolean).void } + attr_writer :has_transparency + + # The height of the image or video in pixels. + sig { returns(T.nilable(Integer)) } + attr_reader :height + + sig { params(height: Integer).void } + attr_writer :height + + # Perceptual hash of the image. + sig { returns(T.nilable(String)) } + attr_reader :p_hash + + sig { params(p_hash: String).void } + attr_writer :p_hash + + # The quality indicator of the image. + sig { returns(T.nilable(Integer)) } + attr_reader :quality + + sig { params(quality: Integer).void } + attr_writer :quality + + # The file size in bytes. + sig { returns(T.nilable(Integer)) } + attr_reader :size + + sig { params(size: Integer).void } + attr_writer :size + + # The video codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :video_codec + + sig { params(video_codec: String).void } + attr_writer :video_codec + + # The width of the image or video in pixels. + sig { returns(T.nilable(Integer)) } + attr_reader :width + + sig { params(width: Integer).void } + attr_writer :width + + # JSON object containing metadata. + sig do + params( + audio_codec: String, + bit_rate: Integer, + density: Integer, + duration: Integer, + exif: Imagekitio::Metadata::Exif::OrHash, + format_: String, + has_color_profile: T::Boolean, + has_transparency: T::Boolean, + height: Integer, + p_hash: String, + quality: Integer, + size: Integer, + video_codec: String, + width: Integer + ).returns(T.attached_class) + end + def self.new( + # The audio codec used in the video (only for video). + audio_codec: nil, + # The bit rate of the video in kbps (only for video). + bit_rate: nil, + # The density of the image in DPI. + density: nil, + # The duration of the video in seconds (only for video). + duration: nil, + exif: nil, + # The format of the file (e.g., 'jpg', 'mp4'). + format_: nil, + # Indicates if the image has a color profile. + has_color_profile: nil, + # Indicates if the image contains transparent areas. + has_transparency: nil, + # The height of the image or video in pixels. + height: nil, + # Perceptual hash of the image. + p_hash: nil, + # The quality indicator of the image. + quality: nil, + # The file size in bytes. + size: nil, + # The video codec used in the video (only for video). + video_codec: nil, + # The width of the image or video in pixels. + width: nil + ) + end + + sig do + override.returns( + { + audio_codec: String, + bit_rate: Integer, + density: Integer, + duration: Integer, + exif: Imagekitio::Metadata::Exif, + format_: String, + has_color_profile: T::Boolean, + has_transparency: T::Boolean, + height: Integer, + p_hash: String, + quality: Integer, + size: Integer, + video_codec: String, + width: Integer + } + ) + end + def to_hash + end + + class Exif < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::Metadata::Exif, Imagekitio::Internal::AnyHash) + end + + # Object containing Exif details. + sig { returns(T.nilable(Imagekitio::Metadata::Exif::Exif)) } + attr_reader :exif + + sig { params(exif: Imagekitio::Metadata::Exif::Exif::OrHash).void } + attr_writer :exif + + # Object containing GPS information. + sig { returns(T.nilable(Imagekitio::Metadata::Exif::Gps)) } + attr_reader :gps + + sig { params(gps: Imagekitio::Metadata::Exif::Gps::OrHash).void } + attr_writer :gps + + # Object containing EXIF image information. + sig { returns(T.nilable(Imagekitio::Metadata::Exif::Image)) } + attr_reader :image + + sig { params(image: Imagekitio::Metadata::Exif::Image::OrHash).void } + attr_writer :image + + # JSON object. + sig { returns(T.nilable(Imagekitio::Metadata::Exif::Interoperability)) } + attr_reader :interoperability + + sig do + params( + interoperability: + Imagekitio::Metadata::Exif::Interoperability::OrHash + ).void + end + attr_writer :interoperability + + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :makernote + + sig { params(makernote: T::Hash[Symbol, T.anything]).void } + attr_writer :makernote + + # Object containing Thumbnail information. + sig { returns(T.nilable(Imagekitio::Metadata::Exif::Thumbnail)) } + attr_reader :thumbnail + + sig do + params(thumbnail: Imagekitio::Metadata::Exif::Thumbnail::OrHash).void + end + attr_writer :thumbnail + + sig do + params( + exif: Imagekitio::Metadata::Exif::Exif::OrHash, + gps: Imagekitio::Metadata::Exif::Gps::OrHash, + image: Imagekitio::Metadata::Exif::Image::OrHash, + interoperability: + Imagekitio::Metadata::Exif::Interoperability::OrHash, + makernote: T::Hash[Symbol, T.anything], + thumbnail: Imagekitio::Metadata::Exif::Thumbnail::OrHash + ).returns(T.attached_class) + end + def self.new( + # Object containing Exif details. + exif: nil, + # Object containing GPS information. + gps: nil, + # Object containing EXIF image information. + image: nil, + # JSON object. + interoperability: nil, + makernote: nil, + # Object containing Thumbnail information. + thumbnail: nil + ) + end + + sig do + override.returns( + { + exif: Imagekitio::Metadata::Exif::Exif, + gps: Imagekitio::Metadata::Exif::Gps, + image: Imagekitio::Metadata::Exif::Image, + interoperability: Imagekitio::Metadata::Exif::Interoperability, + makernote: T::Hash[Symbol, T.anything], + thumbnail: Imagekitio::Metadata::Exif::Thumbnail + } + ) + end + def to_hash + end + + class Exif < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Metadata::Exif::Exif, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.nilable(Float)) } + attr_reader :aperture_value + + sig { params(aperture_value: Float).void } + attr_writer :aperture_value + + sig { returns(T.nilable(Integer)) } + attr_reader :color_space + + sig { params(color_space: Integer).void } + attr_writer :color_space + + sig { returns(T.nilable(String)) } + attr_reader :create_date + + sig { params(create_date: String).void } + attr_writer :create_date + + sig { returns(T.nilable(Integer)) } + attr_reader :custom_rendered + + sig { params(custom_rendered: Integer).void } + attr_writer :custom_rendered + + sig { returns(T.nilable(String)) } + attr_reader :date_time_original + + sig { params(date_time_original: String).void } + attr_writer :date_time_original + + sig { returns(T.nilable(Integer)) } + attr_reader :exif_image_height + + sig { params(exif_image_height: Integer).void } + attr_writer :exif_image_height + + sig { returns(T.nilable(Integer)) } + attr_reader :exif_image_width + + sig { params(exif_image_width: Integer).void } + attr_writer :exif_image_width + + sig { returns(T.nilable(String)) } + attr_reader :exif_version + + sig { params(exif_version: String).void } + attr_writer :exif_version + + sig { returns(T.nilable(Float)) } + attr_reader :exposure_compensation + + sig { params(exposure_compensation: Float).void } + attr_writer :exposure_compensation + + sig { returns(T.nilable(Integer)) } + attr_reader :exposure_mode + + sig { params(exposure_mode: Integer).void } + attr_writer :exposure_mode + + sig { returns(T.nilable(Integer)) } + attr_reader :exposure_program + + sig { params(exposure_program: Integer).void } + attr_writer :exposure_program + + sig { returns(T.nilable(Float)) } + attr_reader :exposure_time + + sig { params(exposure_time: Float).void } + attr_writer :exposure_time + + sig { returns(T.nilable(Integer)) } + attr_reader :flash + + sig { params(flash: Integer).void } + attr_writer :flash + + sig { returns(T.nilable(String)) } + attr_reader :flashpix_version + + sig { params(flashpix_version: String).void } + attr_writer :flashpix_version + + sig { returns(T.nilable(Float)) } + attr_reader :f_number + + sig { params(f_number: Float).void } + attr_writer :f_number + + sig { returns(T.nilable(Integer)) } + attr_reader :focal_length + + sig { params(focal_length: Integer).void } + attr_writer :focal_length + + sig { returns(T.nilable(Integer)) } + attr_reader :focal_plane_resolution_unit + + sig { params(focal_plane_resolution_unit: Integer).void } + attr_writer :focal_plane_resolution_unit + + sig { returns(T.nilable(Float)) } + attr_reader :focal_plane_x_resolution + + sig { params(focal_plane_x_resolution: Float).void } + attr_writer :focal_plane_x_resolution + + sig { returns(T.nilable(Float)) } + attr_reader :focal_plane_y_resolution + + sig { params(focal_plane_y_resolution: Float).void } + attr_writer :focal_plane_y_resolution + + sig { returns(T.nilable(Integer)) } + attr_reader :interop_offset + + sig { params(interop_offset: Integer).void } + attr_writer :interop_offset + + sig { returns(T.nilable(Integer)) } + attr_reader :iso + + sig { params(iso: Integer).void } + attr_writer :iso + + sig { returns(T.nilable(Integer)) } + attr_reader :metering_mode + + sig { params(metering_mode: Integer).void } + attr_writer :metering_mode + + sig { returns(T.nilable(Integer)) } + attr_reader :scene_capture_type + + sig { params(scene_capture_type: Integer).void } + attr_writer :scene_capture_type + + sig { returns(T.nilable(Float)) } + attr_reader :shutter_speed_value + + sig { params(shutter_speed_value: Float).void } + attr_writer :shutter_speed_value + + sig { returns(T.nilable(String)) } + attr_reader :sub_sec_time + + sig { params(sub_sec_time: String).void } + attr_writer :sub_sec_time + + sig { returns(T.nilable(Integer)) } + attr_reader :white_balance + + sig { params(white_balance: Integer).void } + attr_writer :white_balance + + # Object containing Exif details. + sig do + params( + aperture_value: Float, + color_space: Integer, + create_date: String, + custom_rendered: Integer, + date_time_original: String, + exif_image_height: Integer, + exif_image_width: Integer, + exif_version: String, + exposure_compensation: Float, + exposure_mode: Integer, + exposure_program: Integer, + exposure_time: Float, + flash: Integer, + flashpix_version: String, + f_number: Float, + focal_length: Integer, + focal_plane_resolution_unit: Integer, + focal_plane_x_resolution: Float, + focal_plane_y_resolution: Float, + interop_offset: Integer, + iso: Integer, + metering_mode: Integer, + scene_capture_type: Integer, + shutter_speed_value: Float, + sub_sec_time: String, + white_balance: Integer + ).returns(T.attached_class) + end + def self.new( + aperture_value: nil, + color_space: nil, + create_date: nil, + custom_rendered: nil, + date_time_original: nil, + exif_image_height: nil, + exif_image_width: nil, + exif_version: nil, + exposure_compensation: nil, + exposure_mode: nil, + exposure_program: nil, + exposure_time: nil, + flash: nil, + flashpix_version: nil, + f_number: nil, + focal_length: nil, + focal_plane_resolution_unit: nil, + focal_plane_x_resolution: nil, + focal_plane_y_resolution: nil, + interop_offset: nil, + iso: nil, + metering_mode: nil, + scene_capture_type: nil, + shutter_speed_value: nil, + sub_sec_time: nil, + white_balance: nil + ) + end + + sig do + override.returns( + { + aperture_value: Float, + color_space: Integer, + create_date: String, + custom_rendered: Integer, + date_time_original: String, + exif_image_height: Integer, + exif_image_width: Integer, + exif_version: String, + exposure_compensation: Float, + exposure_mode: Integer, + exposure_program: Integer, + exposure_time: Float, + flash: Integer, + flashpix_version: String, + f_number: Float, + focal_length: Integer, + focal_plane_resolution_unit: Integer, + focal_plane_x_resolution: Float, + focal_plane_y_resolution: Float, + interop_offset: Integer, + iso: Integer, + metering_mode: Integer, + scene_capture_type: Integer, + shutter_speed_value: Float, + sub_sec_time: String, + white_balance: Integer + } + ) + end + def to_hash + end + end + + class Gps < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Metadata::Exif::Gps, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.nilable(T::Array[Integer])) } + attr_reader :gps_version_id + + sig { params(gps_version_id: T::Array[Integer]).void } + attr_writer :gps_version_id + + # Object containing GPS information. + sig do + params(gps_version_id: T::Array[Integer]).returns(T.attached_class) + end + def self.new(gps_version_id: nil) + end + + sig { override.returns({ gps_version_id: T::Array[Integer] }) } + def to_hash + end + end + + class Image < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Metadata::Exif::Image, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.nilable(Integer)) } + attr_reader :exif_offset + + sig { params(exif_offset: Integer).void } + attr_writer :exif_offset + + sig { returns(T.nilable(Integer)) } + attr_reader :gps_info + + sig { params(gps_info: Integer).void } + attr_writer :gps_info + + sig { returns(T.nilable(String)) } + attr_reader :make + + sig { params(make: String).void } + attr_writer :make + + sig { returns(T.nilable(String)) } + attr_reader :model + + sig { params(model: String).void } + attr_writer :model + + sig { returns(T.nilable(String)) } + attr_reader :modify_date + + sig { params(modify_date: String).void } + attr_writer :modify_date + + sig { returns(T.nilable(Integer)) } + attr_reader :orientation + + sig { params(orientation: Integer).void } + attr_writer :orientation + + sig { returns(T.nilable(Integer)) } + attr_reader :resolution_unit + + sig { params(resolution_unit: Integer).void } + attr_writer :resolution_unit + + sig { returns(T.nilable(String)) } + attr_reader :software + + sig { params(software: String).void } + attr_writer :software + + sig { returns(T.nilable(Integer)) } + attr_reader :x_resolution + + sig { params(x_resolution: Integer).void } + attr_writer :x_resolution + + sig { returns(T.nilable(Integer)) } + attr_reader :y_cb_cr_positioning + + sig { params(y_cb_cr_positioning: Integer).void } + attr_writer :y_cb_cr_positioning + + sig { returns(T.nilable(Integer)) } + attr_reader :y_resolution + + sig { params(y_resolution: Integer).void } + attr_writer :y_resolution + + # Object containing EXIF image information. + sig do + params( + exif_offset: Integer, + gps_info: Integer, + make: String, + model: String, + modify_date: String, + orientation: Integer, + resolution_unit: Integer, + software: String, + x_resolution: Integer, + y_cb_cr_positioning: Integer, + y_resolution: Integer + ).returns(T.attached_class) + end + def self.new( + exif_offset: nil, + gps_info: nil, + make: nil, + model: nil, + modify_date: nil, + orientation: nil, + resolution_unit: nil, + software: nil, + x_resolution: nil, + y_cb_cr_positioning: nil, + y_resolution: nil + ) + end + + sig do + override.returns( + { + exif_offset: Integer, + gps_info: Integer, + make: String, + model: String, + modify_date: String, + orientation: Integer, + resolution_unit: Integer, + software: String, + x_resolution: Integer, + y_cb_cr_positioning: Integer, + y_resolution: Integer + } + ) + end + def to_hash + end + end + + class Interoperability < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Metadata::Exif::Interoperability, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.nilable(String)) } + attr_reader :interop_index + + sig { params(interop_index: String).void } + attr_writer :interop_index + + sig { returns(T.nilable(String)) } + attr_reader :interop_version + + sig { params(interop_version: String).void } + attr_writer :interop_version + + # JSON object. + sig do + params(interop_index: String, interop_version: String).returns( + T.attached_class + ) + end + def self.new(interop_index: nil, interop_version: nil) + end + + sig do + override.returns({ interop_index: String, interop_version: String }) + end + def to_hash + end + end + + class Thumbnail < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::Metadata::Exif::Thumbnail, + Imagekitio::Internal::AnyHash + ) + end + + sig { returns(T.nilable(Integer)) } + attr_reader :compression + + sig { params(compression: Integer).void } + attr_writer :compression + + sig { returns(T.nilable(Integer)) } + attr_reader :resolution_unit + + sig { params(resolution_unit: Integer).void } + attr_writer :resolution_unit + + sig { returns(T.nilable(Integer)) } + attr_reader :thumbnail_length + + sig { params(thumbnail_length: Integer).void } + attr_writer :thumbnail_length + + sig { returns(T.nilable(Integer)) } + attr_reader :thumbnail_offset + + sig { params(thumbnail_offset: Integer).void } + attr_writer :thumbnail_offset + + sig { returns(T.nilable(Integer)) } + attr_reader :x_resolution + + sig { params(x_resolution: Integer).void } + attr_writer :x_resolution + + sig { returns(T.nilable(Integer)) } + attr_reader :y_resolution + + sig { params(y_resolution: Integer).void } + attr_writer :y_resolution + + # Object containing Thumbnail information. + sig do + params( + compression: Integer, + resolution_unit: Integer, + thumbnail_length: Integer, + thumbnail_offset: Integer, + x_resolution: Integer, + y_resolution: Integer + ).returns(T.attached_class) + end + def self.new( + compression: nil, + resolution_unit: nil, + thumbnail_length: nil, + thumbnail_offset: nil, + x_resolution: nil, + y_resolution: nil + ) + end + + sig do + override.returns( + { + compression: Integer, + resolution_unit: Integer, + thumbnail_length: Integer, + thumbnail_offset: Integer, + x_resolution: Integer, + y_resolution: Integer + } + ) + end + def to_hash + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/overlay.rbi b/rbi/imagekitio/models/overlay.rbi new file mode 100644 index 00000000..379bce0f --- /dev/null +++ b/rbi/imagekitio/models/overlay.rbi @@ -0,0 +1,28 @@ +# typed: strong + +module Imagekitio + module Models + # 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). + module Overlay + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::TextOverlay, + Imagekitio::ImageOverlay, + Imagekitio::VideoOverlay, + Imagekitio::SubtitleOverlay, + Imagekitio::SolidColorOverlay + ) + end + + sig { override.returns(T::Array[Imagekitio::Overlay::Variants]) } + def self.variants + end + end + end +end diff --git a/rbi/imagekitio/models/overlay_position.rbi b/rbi/imagekitio/models/overlay_position.rbi new file mode 100644 index 00000000..9897e1e4 --- /dev/null +++ b/rbi/imagekitio/models/overlay_position.rbi @@ -0,0 +1,148 @@ +# typed: strong + +module Imagekitio + module Models + class OverlayPosition < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::OverlayPosition, Imagekitio::Internal::AnyHash) + end + + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + sig { returns(T.nilable(Imagekitio::OverlayPosition::Focus::OrSymbol)) } + attr_reader :focus + + sig { params(focus: Imagekitio::OverlayPosition::Focus::OrSymbol).void } + attr_writer :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). + sig { returns(T.nilable(Imagekitio::OverlayPosition::X::Variants)) } + attr_reader :x + + sig { params(x: Imagekitio::OverlayPosition::X::Variants).void } + attr_writer :x + + # 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). + sig { returns(T.nilable(Imagekitio::OverlayPosition::Y::Variants)) } + attr_reader :y_ + + sig { params(y_: Imagekitio::OverlayPosition::Y::Variants).void } + attr_writer :y_ + + sig do + params( + focus: Imagekitio::OverlayPosition::Focus::OrSymbol, + x: Imagekitio::OverlayPosition::X::Variants, + y_: Imagekitio::OverlayPosition::Y::Variants + ).returns(T.attached_class) + end + def self.new( + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + focus: nil, + # 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). + x: nil, + # 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). + y_: nil + ) + end + + sig do + override.returns( + { + focus: Imagekitio::OverlayPosition::Focus::OrSymbol, + x: Imagekitio::OverlayPosition::X::Variants, + y_: Imagekitio::OverlayPosition::Y::Variants + } + ) + end + def to_hash + end + + # Specifies the position of the overlay relative to the parent image or video. + # Maps to `lfo` in the URL. + module Focus + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::OverlayPosition::Focus) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + CENTER = + T.let(:center, Imagekitio::OverlayPosition::Focus::TaggedSymbol) + TOP = T.let(:top, Imagekitio::OverlayPosition::Focus::TaggedSymbol) + LEFT = T.let(:left, Imagekitio::OverlayPosition::Focus::TaggedSymbol) + BOTTOM = + T.let(:bottom, Imagekitio::OverlayPosition::Focus::TaggedSymbol) + RIGHT = T.let(:right, Imagekitio::OverlayPosition::Focus::TaggedSymbol) + TOP_LEFT = + T.let(:top_left, Imagekitio::OverlayPosition::Focus::TaggedSymbol) + TOP_RIGHT = + T.let(:top_right, Imagekitio::OverlayPosition::Focus::TaggedSymbol) + BOTTOM_LEFT = + T.let(:bottom_left, Imagekitio::OverlayPosition::Focus::TaggedSymbol) + BOTTOM_RIGHT = + T.let(:bottom_right, Imagekitio::OverlayPosition::Focus::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::OverlayPosition::Focus::TaggedSymbol] + ) + end + def self.values + end + end + + # 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). + module X + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekitio::OverlayPosition::X::Variants]) + end + def self.variants + end + end + + # 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). + module Y + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekitio::OverlayPosition::Y::Variants]) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekitio/models/overlay_timing.rbi b/rbi/imagekitio/models/overlay_timing.rbi new file mode 100644 index 00000000..71901aae --- /dev/null +++ b/rbi/imagekitio/models/overlay_timing.rbi @@ -0,0 +1,135 @@ +# typed: strong + +module Imagekitio + module Models + class OverlayTiming < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::OverlayTiming, Imagekitio::Internal::AnyHash) + end + + # 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. + sig { returns(T.nilable(Imagekitio::OverlayTiming::Duration::Variants)) } + attr_reader :duration + + sig do + params(duration: Imagekitio::OverlayTiming::Duration::Variants).void + end + attr_writer :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. + sig { returns(T.nilable(Imagekitio::OverlayTiming::End::Variants)) } + attr_reader :end_ + + sig { params(end_: Imagekitio::OverlayTiming::End::Variants).void } + attr_writer :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. + sig { returns(T.nilable(Imagekitio::OverlayTiming::Start::Variants)) } + attr_reader :start + + sig { params(start: Imagekitio::OverlayTiming::Start::Variants).void } + attr_writer :start + + sig do + params( + duration: Imagekitio::OverlayTiming::Duration::Variants, + end_: Imagekitio::OverlayTiming::End::Variants, + start: Imagekitio::OverlayTiming::Start::Variants + ).returns(T.attached_class) + end + def self.new( + # 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. + duration: nil, + # 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. + end_: nil, + # 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. + start: nil + ) + end + + sig do + override.returns( + { + duration: Imagekitio::OverlayTiming::Duration::Variants, + end_: Imagekitio::OverlayTiming::End::Variants, + start: Imagekitio::OverlayTiming::Start::Variants + } + ) + end + def to_hash + end + + # 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. + module Duration + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::OverlayTiming::Duration::Variants] + ) + end + def self.variants + end + end + + # 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. + module End + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekitio::OverlayTiming::End::Variants]) + end + def self.variants + end + 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. + module Start + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekitio::OverlayTiming::Start::Variants]) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekitio/models/responsive_image_attributes.rbi b/rbi/imagekitio/models/responsive_image_attributes.rbi new file mode 100644 index 00000000..91cc9b04 --- /dev/null +++ b/rbi/imagekitio/models/responsive_image_attributes.rbi @@ -0,0 +1,74 @@ +# typed: strong + +module Imagekitio + module Models + class ResponsiveImageAttributes < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::ResponsiveImageAttributes, + Imagekitio::Internal::AnyHash + ) + end + + # URL for the _largest_ candidate (assigned to plain `src`). + sig { returns(String) } + attr_accessor :src + + # `sizes` returned (or synthesised as `100vw`). The value for the HTML `sizes` + # attribute. + sig { returns(T.nilable(String)) } + attr_reader :sizes + + sig { params(sizes: String).void } + attr_writer :sizes + + # Candidate set with `w` or `x` descriptors. Multiple image URLs separated by + # commas, each with a descriptor. + sig { returns(T.nilable(String)) } + attr_reader :src_set + + sig { params(src_set: String).void } + attr_writer :src_set + + # Width as a number (if `width` was provided in the input options). + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Resulting set of attributes suitable for an HTML `` element. Useful for + # enabling responsive image loading with `srcSet` and `sizes`. + sig do + params( + src: String, + sizes: String, + src_set: String, + width: Float + ).returns(T.attached_class) + end + def self.new( + # URL for the _largest_ candidate (assigned to plain `src`). + src:, + # `sizes` returned (or synthesised as `100vw`). The value for the HTML `sizes` + # attribute. + sizes: nil, + # Candidate set with `w` or `x` descriptors. Multiple image URLs separated by + # commas, each with a descriptor. + src_set: nil, + # Width as a number (if `width` was provided in the input options). + width: nil + ) + end + + sig do + override.returns( + { src: String, sizes: String, src_set: String, width: Float } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/solid_color_overlay.rbi b/rbi/imagekitio/models/solid_color_overlay.rbi new file mode 100644 index 00000000..330abba1 --- /dev/null +++ b/rbi/imagekitio/models/solid_color_overlay.rbi @@ -0,0 +1,79 @@ +# typed: strong + +module Imagekitio + module Models + class SolidColorOverlay < Imagekitio::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekitio::SolidColorOverlay, Imagekitio::Internal::AnyHash) + end + + # 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). + sig { returns(String) } + attr_accessor :color + + sig { returns(Symbol) } + attr_accessor :type + + # 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). + sig do + returns( + T.nilable(T::Array[Imagekitio::SolidColorOverlayTransformation]) + ) + end + attr_reader :transformation + + sig do + params( + transformation: + T::Array[Imagekitio::SolidColorOverlayTransformation::OrHash] + ).void + end + attr_writer :transformation + + sig do + params( + color: String, + transformation: + T::Array[Imagekitio::SolidColorOverlayTransformation::OrHash], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # 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). + 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). + transformation: nil, + type: :solidColor + ) + end + + sig do + override.returns( + { + color: String, + type: Symbol, + transformation: + T::Array[Imagekitio::SolidColorOverlayTransformation] + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/solid_color_overlay_transformation.rbi b/rbi/imagekitio/models/solid_color_overlay_transformation.rbi new file mode 100644 index 00000000..7c62ded4 --- /dev/null +++ b/rbi/imagekitio/models/solid_color_overlay_transformation.rbi @@ -0,0 +1,218 @@ +# typed: strong + +module Imagekitio + module Models + class SolidColorOverlayTransformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::SolidColorOverlayTransformation, + Imagekitio::Internal::AnyHash + ) + end + + # Specifies the transparency level of the solid color overlay. Accepts integers + # from `1` to `9`. + sig { returns(T.nilable(Float)) } + attr_reader :alpha + + sig { params(alpha: Float).void } + attr_writer :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. + sig { returns(T.nilable(String)) } + attr_reader :background + + sig { params(background: String).void } + attr_writer :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). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :gradient + + sig { params(gradient: T.any(T::Boolean, String)).void } + attr_writer :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). + sig do + returns( + T.nilable( + Imagekitio::SolidColorOverlayTransformation::Height::Variants + ) + ) + end + attr_reader :height + + sig do + params( + height: Imagekitio::SolidColorOverlayTransformation::Height::Variants + ).void + end + attr_writer :height + + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + sig { returns(T.nilable(T.any(Float, Symbol))) } + attr_reader :radius + + sig { params(radius: T.any(Float, Symbol)).void } + attr_writer :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). + sig do + returns( + T.nilable( + Imagekitio::SolidColorOverlayTransformation::Width::Variants + ) + ) + end + attr_reader :width + + sig do + params( + width: Imagekitio::SolidColorOverlayTransformation::Width::Variants + ).void + end + attr_writer :width + + sig do + params( + alpha: Float, + background: String, + gradient: T.any(T::Boolean, String), + height: Imagekitio::SolidColorOverlayTransformation::Height::Variants, + radius: T.any(Float, Symbol), + width: Imagekitio::SolidColorOverlayTransformation::Width::Variants + ).returns(T.attached_class) + end + def self.new( + # Specifies the transparency level of the solid color overlay. Accepts integers + # from `1` to `9`. + alpha: nil, + # 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. + background: nil, + # 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). + gradient: nil, + # 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). + height: nil, + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + radius: nil, + # 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). + width: nil + ) + end + + sig do + override.returns( + { + alpha: Float, + background: String, + gradient: T.any(T::Boolean, String), + height: + Imagekitio::SolidColorOverlayTransformation::Height::Variants, + radius: T.any(Float, Symbol), + width: Imagekitio::SolidColorOverlayTransformation::Width::Variants + } + ) + end + def to_hash + end + + # 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). + module Gradient + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns( + T::Array[ + Imagekitio::SolidColorOverlayTransformation::Gradient::Variants + ] + ) + end + def self.variants + end + end + + # 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). + module Height + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[ + Imagekitio::SolidColorOverlayTransformation::Height::Variants + ] + ) + end + def self.variants + end + end + + # Specifies the corner radius of the solid color overlay. Set to `max` for + # circular or oval shape. See + # [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + module Radius + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, Symbol) } + + sig do + override.returns( + T::Array[ + Imagekitio::SolidColorOverlayTransformation::Radius::Variants + ] + ) + end + def self.variants + end + end + + # 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). + module Width + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[ + Imagekitio::SolidColorOverlayTransformation::Width::Variants + ] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekitio/models/src_options.rbi b/rbi/imagekitio/models/src_options.rbi new file mode 100644 index 00000000..53566396 --- /dev/null +++ b/rbi/imagekitio/models/src_options.rbi @@ -0,0 +1,159 @@ +# typed: strong + +module Imagekitio + module Models + class SrcOptions < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::SrcOptions, Imagekitio::Internal::AnyHash) + end + + # 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. + sig { returns(String) } + attr_accessor :src + + # Get your urlEndpoint from the + # [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + sig { returns(String) } + attr_accessor :url_endpoint + + # 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). + sig { returns(T.nilable(Float)) } + attr_reader :expires_in + + sig { params(expires_in: Float).void } + attr_writer :expires_in + + # 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. + sig { returns(T.nilable(T::Hash[Symbol, String])) } + attr_reader :query_parameters + + sig { params(query_parameters: T::Hash[Symbol, String]).void } + attr_writer :query_parameters + + # 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). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :signed + + sig { params(signed: T::Boolean).void } + attr_writer :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). + sig { returns(T.nilable(T::Array[Imagekitio::Transformation])) } + attr_reader :transformation + + sig do + params( + transformation: T::Array[Imagekitio::Transformation::OrHash] + ).void + end + attr_writer :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). + sig { returns(T.nilable(Imagekitio::TransformationPosition::OrSymbol)) } + attr_reader :transformation_position + + sig do + params( + transformation_position: Imagekitio::TransformationPosition::OrSymbol + ).void + end + attr_writer :transformation_position + + # Options for generating ImageKit URLs with transformations. See the + # [Transformations guide](https://imagekit.io/docs/transformations). + sig do + params( + src: String, + url_endpoint: String, + expires_in: Float, + query_parameters: T::Hash[Symbol, String], + signed: T::Boolean, + transformation: T::Array[Imagekitio::Transformation::OrHash], + transformation_position: Imagekitio::TransformationPosition::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # 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. + src:, + # Get your urlEndpoint from the + # [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + url_endpoint:, + # 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). + expires_in: nil, + # 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. + query_parameters: nil, + # 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). + signed: nil, + # 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). + transformation: nil, + # 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). + transformation_position: nil + ) + end + + sig do + override.returns( + { + src: String, + url_endpoint: String, + expires_in: Float, + query_parameters: T::Hash[Symbol, String], + signed: T::Boolean, + transformation: T::Array[Imagekitio::Transformation], + transformation_position: + Imagekitio::TransformationPosition::OrSymbol + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/streaming_resolution.rbi b/rbi/imagekitio/models/streaming_resolution.rbi new file mode 100644 index 00000000..0509a040 --- /dev/null +++ b/rbi/imagekitio/models/streaming_resolution.rbi @@ -0,0 +1,38 @@ +# typed: strong + +module Imagekitio + module Models + # Available streaming resolutions for + # [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) + module StreamingResolution + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::StreamingResolution) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + STREAMING_RESOLUTION_240 = + T.let(:"240", Imagekitio::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_360 = + T.let(:"360", Imagekitio::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_480 = + T.let(:"480", Imagekitio::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_720 = + T.let(:"720", Imagekitio::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_1080 = + T.let(:"1080", Imagekitio::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_1440 = + T.let(:"1440", Imagekitio::StreamingResolution::TaggedSymbol) + STREAMING_RESOLUTION_2160 = + T.let(:"2160", Imagekitio::StreamingResolution::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::StreamingResolution::TaggedSymbol] + ) + end + def self.values + end + end + end +end diff --git a/rbi/imagekitio/models/subtitle_overlay.rbi b/rbi/imagekitio/models/subtitle_overlay.rbi new file mode 100644 index 00000000..dd1cb00a --- /dev/null +++ b/rbi/imagekitio/models/subtitle_overlay.rbi @@ -0,0 +1,114 @@ +# typed: strong + +module Imagekitio + module Models + class SubtitleOverlay < Imagekitio::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekitio::SubtitleOverlay, Imagekitio::Internal::AnyHash) + end + + # Specifies the relative path to the subtitle file used as an overlay. + sig { returns(String) } + attr_accessor :input + + sig { returns(Symbol) } + attr_accessor :type + + # 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`. + sig do + returns(T.nilable(Imagekitio::SubtitleOverlay::Encoding::OrSymbol)) + end + attr_reader :encoding + + sig do + params(encoding: Imagekitio::SubtitleOverlay::Encoding::OrSymbol).void + end + attr_writer :encoding + + # Control styling of the subtitle. See + # [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + sig do + returns(T.nilable(T::Array[Imagekitio::SubtitleOverlayTransformation])) + end + attr_reader :transformation + + sig do + params( + transformation: + T::Array[Imagekitio::SubtitleOverlayTransformation::OrHash] + ).void + end + attr_writer :transformation + + sig do + params( + input: String, + encoding: Imagekitio::SubtitleOverlay::Encoding::OrSymbol, + transformation: + T::Array[Imagekitio::SubtitleOverlayTransformation::OrHash], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the relative path to the subtitle file used as an overlay. + 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`. + encoding: nil, + # Control styling of the subtitle. See + # [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + transformation: nil, + type: :subtitle + ) + end + + sig do + override.returns( + { + input: String, + type: Symbol, + encoding: Imagekitio::SubtitleOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekitio::SubtitleOverlayTransformation] + } + ) + end + def to_hash + end + + # 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`. + module Encoding + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::SubtitleOverlay::Encoding) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekitio::SubtitleOverlay::Encoding::TaggedSymbol) + PLAIN = + T.let(:plain, Imagekitio::SubtitleOverlay::Encoding::TaggedSymbol) + BASE64 = + T.let(:base64, Imagekitio::SubtitleOverlay::Encoding::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::SubtitleOverlay::Encoding::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekitio/models/subtitle_overlay_transformation.rbi b/rbi/imagekitio/models/subtitle_overlay_transformation.rbi new file mode 100644 index 00000000..1c089c52 --- /dev/null +++ b/rbi/imagekitio/models/subtitle_overlay_transformation.rbi @@ -0,0 +1,215 @@ +# typed: strong + +module Imagekitio + module Models + class SubtitleOverlayTransformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::SubtitleOverlayTransformation, + Imagekitio::Internal::AnyHash + ) + end + + # 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) + sig { returns(T.nilable(String)) } + attr_reader :background + + sig { params(background: String).void } + attr_writer :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) + sig { returns(T.nilable(String)) } + attr_reader :color + + sig { params(color: String).void } + attr_writer :color + + # Font family for subtitles. Refer to the + # [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + sig { returns(T.nilable(String)) } + attr_reader :font_family + + sig { params(font_family: String).void } + attr_writer :font_family + + # 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) + sig { returns(T.nilable(String)) } + attr_reader :font_outline + + sig { params(font_outline: String).void } + attr_writer :font_outline + + # 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) + sig { returns(T.nilable(String)) } + attr_reader :font_shadow + + sig { params(font_shadow: String).void } + attr_writer :font_shadow + + # Sets the font size of subtitle text. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + sig { returns(T.nilable(Float)) } + attr_reader :font_size + + sig { params(font_size: Float).void } + attr_writer :font_size + + # 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) + sig do + returns( + T.nilable( + Imagekitio::SubtitleOverlayTransformation::Typography::OrSymbol + ) + ) + end + attr_reader :typography + + sig do + params( + typography: + Imagekitio::SubtitleOverlayTransformation::Typography::OrSymbol + ).void + end + attr_writer :typography + + # Subtitle styling options. + # [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + # from the docs. + sig do + params( + background: String, + color: String, + font_family: String, + font_outline: String, + font_shadow: String, + font_size: Float, + typography: + Imagekitio::SubtitleOverlayTransformation::Typography::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # 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) + background: nil, + # 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) + color: nil, + # Font family for subtitles. Refer to the + # [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + font_family: nil, + # 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) + font_outline: nil, + # 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) + font_shadow: nil, + # Sets the font size of subtitle text. + # + # [Subtitle styling options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + font_size: nil, + # 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) + typography: nil + ) + end + + sig do + override.returns( + { + background: String, + color: String, + font_family: String, + font_outline: String, + font_shadow: String, + font_size: Float, + typography: + Imagekitio::SubtitleOverlayTransformation::Typography::OrSymbol + } + ) + end + def to_hash + end + + # 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) + module Typography + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekitio::SubtitleOverlayTransformation::Typography) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + B = + T.let( + :b, + Imagekitio::SubtitleOverlayTransformation::Typography::TaggedSymbol + ) + I = + T.let( + :i, + Imagekitio::SubtitleOverlayTransformation::Typography::TaggedSymbol + ) + B_I = + T.let( + :b_i, + Imagekitio::SubtitleOverlayTransformation::Typography::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::SubtitleOverlayTransformation::Typography::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekitio/models/text_overlay.rbi b/rbi/imagekitio/models/text_overlay.rbi new file mode 100644 index 00000000..fe635400 --- /dev/null +++ b/rbi/imagekitio/models/text_overlay.rbi @@ -0,0 +1,110 @@ +# typed: strong + +module Imagekitio + module Models + class TextOverlay < Imagekitio::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekitio::TextOverlay, Imagekitio::Internal::AnyHash) + end + + # Specifies the text to be displayed in the overlay. The SDK automatically handles + # special characters and encoding. + sig { returns(String) } + attr_accessor :text + + sig { returns(Symbol) } + attr_accessor :type + + # 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`. + sig { returns(T.nilable(Imagekitio::TextOverlay::Encoding::OrSymbol)) } + attr_reader :encoding + + sig { params(encoding: Imagekitio::TextOverlay::Encoding::OrSymbol).void } + attr_writer :encoding + + # Control styling of the text overlay. See + # [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + sig do + returns(T.nilable(T::Array[Imagekitio::TextOverlayTransformation])) + end + attr_reader :transformation + + sig do + params( + transformation: + T::Array[Imagekitio::TextOverlayTransformation::OrHash] + ).void + end + attr_writer :transformation + + sig do + params( + text: String, + encoding: Imagekitio::TextOverlay::Encoding::OrSymbol, + transformation: + T::Array[Imagekitio::TextOverlayTransformation::OrHash], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the text to be displayed in the overlay. The SDK automatically handles + # special characters and encoding. + 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`. + encoding: nil, + # Control styling of the text overlay. See + # [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + transformation: nil, + type: :text + ) + end + + sig do + override.returns( + { + text: String, + type: Symbol, + encoding: Imagekitio::TextOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekitio::TextOverlayTransformation] + } + ) + end + def to_hash + end + + # 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`. + module Encoding + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::TextOverlay::Encoding) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekitio::TextOverlay::Encoding::TaggedSymbol) + PLAIN = T.let(:plain, Imagekitio::TextOverlay::Encoding::TaggedSymbol) + BASE64 = T.let(:base64, Imagekitio::TextOverlay::Encoding::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::TextOverlay::Encoding::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekitio/models/text_overlay_transformation.rbi b/rbi/imagekitio/models/text_overlay_transformation.rbi new file mode 100644 index 00000000..bc1f85b5 --- /dev/null +++ b/rbi/imagekitio/models/text_overlay_transformation.rbi @@ -0,0 +1,451 @@ +# typed: strong + +module Imagekitio + module Models + class TextOverlayTransformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::TextOverlayTransformation, + Imagekitio::Internal::AnyHash + ) + end + + # Specifies the transparency level of the text overlay. Accepts integers from `1` + # to `9`. + sig { returns(T.nilable(Float)) } + attr_reader :alpha + + sig { params(alpha: Float).void } + attr_writer :alpha + + # Specifies the background color of the text overlay. Accepts an RGB hex code, an + # RGBA code, or a color name. + sig { returns(T.nilable(String)) } + attr_reader :background + + sig { params(background: String).void } + attr_writer :background + + # Flip the text overlay horizontally, vertically, or both. + sig do + returns( + T.nilable(Imagekitio::TextOverlayTransformation::Flip::OrSymbol) + ) + end + attr_reader :flip + + sig do + params(flip: Imagekitio::TextOverlayTransformation::Flip::OrSymbol).void + end + attr_writer :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. + sig { returns(T.nilable(String)) } + attr_reader :font_color + + sig { params(font_color: String).void } + attr_writer :font_color + + # 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). + sig { returns(T.nilable(String)) } + attr_reader :font_family + + sig { params(font_family: String).void } + attr_writer :font_family + + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + sig do + returns( + T.nilable(Imagekitio::TextOverlayTransformation::FontSize::Variants) + ) + end + attr_reader :font_size + + sig do + params( + font_size: Imagekitio::TextOverlayTransformation::FontSize::Variants + ).void + end + attr_writer :font_size + + # Specifies the inner alignment of the text when width is more than the text + # length. + sig do + returns( + T.nilable( + Imagekitio::TextOverlayTransformation::InnerAlignment::OrSymbol + ) + ) + end + attr_reader :inner_alignment + + sig do + params( + inner_alignment: + Imagekitio::TextOverlayTransformation::InnerAlignment::OrSymbol + ).void + end + attr_writer :inner_alignment + + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + sig do + returns( + T.nilable(Imagekitio::TextOverlayTransformation::LineHeight::Variants) + ) + end + attr_reader :line_height + + sig do + params( + line_height: + Imagekitio::TextOverlayTransformation::LineHeight::Variants + ).void + end + attr_writer :line_height + + # 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. + sig do + returns( + T.nilable(Imagekitio::TextOverlayTransformation::Padding::Variants) + ) + end + attr_reader :padding + + sig do + params( + padding: Imagekitio::TextOverlayTransformation::Padding::Variants + ).void + end + attr_writer :padding + + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + sig { returns(T.nilable(T.any(Float, Symbol))) } + attr_reader :radius + + sig { params(radius: T.any(Float, Symbol)).void } + attr_writer :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. + sig do + returns( + T.nilable(Imagekitio::TextOverlayTransformation::Rotation::Variants) + ) + end + attr_reader :rotation + + sig do + params( + rotation: Imagekitio::TextOverlayTransformation::Rotation::Variants + ).void + end + attr_writer :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`. + sig { returns(T.nilable(String)) } + attr_reader :typography + + sig { params(typography: String).void } + attr_writer :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). + sig do + returns( + T.nilable(Imagekitio::TextOverlayTransformation::Width::Variants) + ) + end + attr_reader :width + + sig do + params( + width: Imagekitio::TextOverlayTransformation::Width::Variants + ).void + end + attr_writer :width + + sig do + params( + alpha: Float, + background: String, + flip: Imagekitio::TextOverlayTransformation::Flip::OrSymbol, + font_color: String, + font_family: String, + font_size: Imagekitio::TextOverlayTransformation::FontSize::Variants, + inner_alignment: + Imagekitio::TextOverlayTransformation::InnerAlignment::OrSymbol, + line_height: + Imagekitio::TextOverlayTransformation::LineHeight::Variants, + padding: Imagekitio::TextOverlayTransformation::Padding::Variants, + radius: T.any(Float, Symbol), + rotation: Imagekitio::TextOverlayTransformation::Rotation::Variants, + typography: String, + width: Imagekitio::TextOverlayTransformation::Width::Variants + ).returns(T.attached_class) + end + def self.new( + # Specifies the transparency level of the text overlay. Accepts integers from `1` + # to `9`. + alpha: nil, + # Specifies the background color of the text overlay. Accepts an RGB hex code, an + # RGBA code, or a color name. + background: nil, + # Flip the text overlay horizontally, vertically, or both. + flip: nil, + # 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. + font_color: nil, + # 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). + font_family: nil, + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + font_size: nil, + # Specifies the inner alignment of the text when width is more than the text + # length. + inner_alignment: nil, + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + line_height: nil, + # 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. + padding: nil, + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + radius: nil, + # 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. + rotation: nil, + # 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`. + typography: nil, + # 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). + width: nil + ) + end + + sig do + override.returns( + { + alpha: Float, + background: String, + flip: Imagekitio::TextOverlayTransformation::Flip::OrSymbol, + font_color: String, + font_family: String, + font_size: + Imagekitio::TextOverlayTransformation::FontSize::Variants, + inner_alignment: + Imagekitio::TextOverlayTransformation::InnerAlignment::OrSymbol, + line_height: + Imagekitio::TextOverlayTransformation::LineHeight::Variants, + padding: Imagekitio::TextOverlayTransformation::Padding::Variants, + radius: T.any(Float, Symbol), + rotation: Imagekitio::TextOverlayTransformation::Rotation::Variants, + typography: String, + width: Imagekitio::TextOverlayTransformation::Width::Variants + } + ) + end + def to_hash + end + + # Flip the text overlay horizontally, vertically, or both. + module Flip + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekitio::TextOverlayTransformation::Flip) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H = T.let(:h, Imagekitio::TextOverlayTransformation::Flip::TaggedSymbol) + V = T.let(:v, Imagekitio::TextOverlayTransformation::Flip::TaggedSymbol) + H_V = + T.let(:h_v, Imagekitio::TextOverlayTransformation::Flip::TaggedSymbol) + V_H = + T.let(:v_h, Imagekitio::TextOverlayTransformation::Flip::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::TextOverlayTransformation::Flip::TaggedSymbol] + ) + end + def self.values + end + end + + # Specifies the font size of the overlaid text. Accepts a numeric value or an + # arithmetic expression. + module FontSize + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::TextOverlayTransformation::FontSize::Variants] + ) + end + def self.variants + end + end + + # Specifies the inner alignment of the text when width is more than the text + # length. + module InnerAlignment + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Imagekitio::TextOverlayTransformation::InnerAlignment) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + LEFT = + T.let( + :left, + Imagekitio::TextOverlayTransformation::InnerAlignment::TaggedSymbol + ) + RIGHT = + T.let( + :right, + Imagekitio::TextOverlayTransformation::InnerAlignment::TaggedSymbol + ) + CENTER = + T.let( + :center, + Imagekitio::TextOverlayTransformation::InnerAlignment::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::TextOverlayTransformation::InnerAlignment::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Specifies the line height of the text overlay. Accepts integer values + # representing line height in points. It can also accept + # [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + # such as `bw_mul_0.2`, or `bh_div_20`. + module LineHeight + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[ + Imagekitio::TextOverlayTransformation::LineHeight::Variants + ] + ) + end + def self.variants + end + end + + # 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. + module Padding + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::TextOverlayTransformation::Padding::Variants] + ) + end + def self.variants + end + end + + # Specifies the corner radius of the text overlay. Set to `max` to achieve a + # circular or oval shape. + module Radius + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, Symbol) } + + sig do + override.returns( + T::Array[Imagekitio::TextOverlayTransformation::Radius::Variants] + ) + end + def self.variants + end + end + + # 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. + module Rotation + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::TextOverlayTransformation::Rotation::Variants] + ) + end + def self.variants + end + end + + # 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). + module Width + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::TextOverlayTransformation::Width::Variants] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekitio/models/transformation.rbi b/rbi/imagekitio/models/transformation.rbi new file mode 100644 index 00000000..0978362b --- /dev/null +++ b/rbi/imagekitio/models/transformation.rbi @@ -0,0 +1,1646 @@ +# typed: strong + +module Imagekitio + module Models + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::Transformation, Imagekitio::Internal::AnyHash) + end + + # 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). + sig { returns(T.nilable(String)) } + attr_reader :ai_change_background + + sig { params(ai_change_background: String).void } + attr_writer :ai_change_background + + # 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). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :ai_drop_shadow + + sig { params(ai_drop_shadow: T.any(T::Boolean, String)).void } + attr_writer :ai_drop_shadow + + # 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). + sig { returns(T.nilable(String)) } + attr_reader :ai_edit + + sig { params(ai_edit: String).void } + attr_writer :ai_edit + + # 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). + sig do + returns( + T.nilable(Imagekitio::Transformation::AIRemoveBackground::OrBoolean) + ) + end + attr_reader :ai_remove_background + + sig do + params( + ai_remove_background: + Imagekitio::Transformation::AIRemoveBackground::OrBoolean + ).void + end + attr_writer :ai_remove_background + + # 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). + sig do + returns( + T.nilable( + Imagekitio::Transformation::AIRemoveBackgroundExternal::OrBoolean + ) + ) + end + attr_reader :ai_remove_background_external + + sig do + params( + ai_remove_background_external: + Imagekitio::Transformation::AIRemoveBackgroundExternal::OrBoolean + ).void + end + attr_writer :ai_remove_background_external + + # 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). + sig do + returns(T.nilable(Imagekitio::Transformation::AIRetouch::OrBoolean)) + end + attr_reader :ai_retouch + + sig do + params( + ai_retouch: Imagekitio::Transformation::AIRetouch::OrBoolean + ).void + end + attr_writer :ai_retouch + + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + sig do + returns(T.nilable(Imagekitio::Transformation::AIUpscale::OrBoolean)) + end + attr_reader :ai_upscale + + sig do + params( + ai_upscale: Imagekitio::Transformation::AIUpscale::OrBoolean + ).void + end + attr_writer :ai_upscale + + # 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). + sig do + returns(T.nilable(Imagekitio::Transformation::AIVariation::OrBoolean)) + end + attr_reader :ai_variation + + sig do + params( + ai_variation: Imagekitio::Transformation::AIVariation::OrBoolean + ).void + end + attr_writer :ai_variation + + # 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). + sig do + returns(T.nilable(Imagekitio::Transformation::AspectRatio::Variants)) + end + attr_reader :aspect_ratio + + sig do + params( + aspect_ratio: Imagekitio::Transformation::AspectRatio::Variants + ).void + end + attr_writer :aspect_ratio + + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + sig do + returns(T.nilable(Imagekitio::Transformation::AudioCodec::OrSymbol)) + end + attr_reader :audio_codec + + sig do + params( + audio_codec: Imagekitio::Transformation::AudioCodec::OrSymbol + ).void + end + attr_writer :audio_codec + + # 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). + # - 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). + sig { returns(T.nilable(String)) } + attr_reader :background + + sig { params(background: String).void } + attr_writer :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). + sig { returns(T.nilable(Float)) } + attr_reader :blur + + sig { params(blur: Float).void } + attr_writer :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). + sig { returns(T.nilable(String)) } + attr_reader :border + + sig { params(border: String).void } + attr_writer :border + + # Indicates whether the output image should retain the original color profile. See + # [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :color_profile + + sig { params(color_profile: T::Boolean).void } + attr_writer :color_profile + + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + sig do + returns( + T.nilable(Imagekitio::Transformation::ContrastStretch::OrBoolean) + ) + end + attr_reader :contrast_stretch + + sig do + params( + contrast_stretch: + Imagekitio::Transformation::ContrastStretch::OrBoolean + ).void + end + attr_writer :contrast_stretch + + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + sig { returns(T.nilable(Imagekitio::Transformation::Crop::OrSymbol)) } + attr_reader :crop + + sig { params(crop: Imagekitio::Transformation::Crop::OrSymbol).void } + attr_writer :crop + + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + sig { returns(T.nilable(Imagekitio::Transformation::CropMode::OrSymbol)) } + attr_reader :crop_mode + + sig do + params(crop_mode: Imagekitio::Transformation::CropMode::OrSymbol).void + end + attr_writer :crop_mode + + # 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). + sig { returns(T.nilable(String)) } + attr_reader :default_image + + sig { params(default_image: String).void } + attr_writer :default_image + + # Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + # (DPR) calculation. See + # [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + sig { returns(T.nilable(Float)) } + attr_reader :dpr + + sig { params(dpr: Float).void } + attr_writer :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). + sig { returns(T.nilable(Imagekitio::Transformation::Duration::Variants)) } + attr_reader :duration + + sig do + params(duration: Imagekitio::Transformation::Duration::Variants).void + end + attr_writer :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). + sig do + returns(T.nilable(Imagekitio::Transformation::EndOffset::Variants)) + end + attr_reader :end_offset + + sig do + params(end_offset: Imagekitio::Transformation::EndOffset::Variants).void + end + attr_writer :end_offset + + # 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). + sig { returns(T.nilable(Imagekitio::Transformation::Flip::OrSymbol)) } + attr_reader :flip + + sig { params(flip: Imagekitio::Transformation::Flip::OrSymbol).void } + attr_writer :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) + sig { returns(T.nilable(String)) } + attr_reader :focus + + sig { params(focus: String).void } + attr_writer :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). + sig { returns(T.nilable(Imagekitio::Transformation::Format::OrSymbol)) } + attr_reader :format_ + + sig { params(format_: Imagekitio::Transformation::Format::OrSymbol).void } + attr_writer :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). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :gradient + + sig { params(gradient: T.any(T::Boolean, String)).void } + attr_writer :gradient + + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + sig do + returns(T.nilable(Imagekitio::Transformation::Grayscale::OrBoolean)) + end + attr_reader :grayscale + + sig do + params(grayscale: Imagekitio::Transformation::Grayscale::OrBoolean).void + end + attr_writer :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) + sig { returns(T.nilable(Imagekitio::Transformation::Height::Variants)) } + attr_reader :height + + sig { params(height: Imagekitio::Transformation::Height::Variants).void } + attr_writer :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). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :lossless + + sig { params(lossless: T::Boolean).void } + attr_writer :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). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :metadata + + sig { params(metadata: T::Boolean).void } + attr_writer :metadata + + # Named transformation reference. See + # [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + sig { returns(T.nilable(String)) } + attr_reader :named + + sig { params(named: String).void } + attr_writer :named + + # Specifies the opacity level of the output image. See + # [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + sig { returns(T.nilable(Float)) } + attr_reader :opacity + + sig { params(opacity: Float).void } + attr_writer :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). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :original + + sig { params(original: T::Boolean).void } + attr_writer :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). + sig { returns(T.nilable(Imagekitio::Overlay)) } + attr_reader :overlay + + sig { params(overlay: Imagekitio::Overlay).void } + attr_writer :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). + sig { returns(T.nilable(Imagekitio::Transformation::Page::Variants)) } + attr_reader :page + + sig { params(page: Imagekitio::Transformation::Page::Variants).void } + attr_writer :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). + sig { returns(T.nilable(T::Boolean)) } + attr_reader :progressive + + sig { params(progressive: T::Boolean).void } + attr_writer :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). + sig { returns(T.nilable(Float)) } + attr_reader :quality + + sig { params(quality: Float).void } + attr_writer :quality + + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + sig { returns(T.nilable(T.any(Float, Symbol))) } + attr_reader :radius + + sig { params(radius: T.any(Float, Symbol)).void } + attr_writer :radius + + # Pass any transformation not directly supported by the SDK. This transformation + # string is appended to the URL as provided. + sig { returns(T.nilable(String)) } + attr_reader :raw + + sig { params(raw: String).void } + attr_writer :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). + sig { returns(T.nilable(Imagekitio::Transformation::Rotation::Variants)) } + attr_reader :rotation + + sig do + params(rotation: Imagekitio::Transformation::Rotation::Variants).void + end + attr_writer :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). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :shadow + + sig { params(shadow: T.any(T::Boolean, String)).void } + attr_writer :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). + sig { returns(T.nilable(T.any(T::Boolean, Float))) } + attr_reader :sharpen + + sig { params(sharpen: T.any(T::Boolean, Float)).void } + attr_writer :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). + sig do + returns(T.nilable(Imagekitio::Transformation::StartOffset::Variants)) + end + attr_reader :start_offset + + sig do + params( + start_offset: Imagekitio::Transformation::StartOffset::Variants + ).void + end + attr_writer :start_offset + + # 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). + sig do + returns(T.nilable(T::Array[Imagekitio::StreamingResolution::OrSymbol])) + end + attr_reader :streaming_resolutions + + sig do + params( + streaming_resolutions: + T::Array[Imagekitio::StreamingResolution::OrSymbol] + ).void + end + attr_writer :streaming_resolutions + + # 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). + sig { returns(T.nilable(T.any(T::Boolean, Float))) } + attr_reader :trim + + sig { params(trim: T.any(T::Boolean, Float)).void } + attr_writer :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). + sig { returns(T.nilable(T.any(T::Boolean, String))) } + attr_reader :unsharp_mask + + sig { params(unsharp_mask: T.any(T::Boolean, String)).void } + attr_writer :unsharp_mask + + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + sig do + returns(T.nilable(Imagekitio::Transformation::VideoCodec::OrSymbol)) + end + attr_reader :video_codec + + sig do + params( + video_codec: Imagekitio::Transformation::VideoCodec::OrSymbol + ).void + end + attr_writer :video_codec + + # 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) + sig { returns(T.nilable(Imagekitio::Transformation::Width::Variants)) } + attr_reader :width + + sig { params(width: Imagekitio::Transformation::Width::Variants).void } + attr_writer :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). + sig { returns(T.nilable(Imagekitio::Transformation::X::Variants)) } + attr_reader :x + + sig { params(x: Imagekitio::Transformation::X::Variants).void } + attr_writer :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). + sig { returns(T.nilable(Imagekitio::Transformation::XCenter::Variants)) } + attr_reader :x_center + + sig do + params(x_center: Imagekitio::Transformation::XCenter::Variants).void + end + attr_writer :x_center + + # 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). + sig { returns(T.nilable(Imagekitio::Transformation::Y::Variants)) } + attr_reader :y_ + + sig { params(y_: Imagekitio::Transformation::Y::Variants).void } + attr_writer :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). + sig { returns(T.nilable(Imagekitio::Transformation::YCenter::Variants)) } + attr_reader :y_center + + sig do + params(y_center: Imagekitio::Transformation::YCenter::Variants).void + end + attr_writer :y_center + + # 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). + sig { returns(T.nilable(Float)) } + attr_reader :zoom + + sig { params(zoom: Float).void } + attr_writer :zoom + + # The SDK provides easy-to-use names for transformations. These names are + # converted to the corresponding transformation string before being added to the + # URL. SDKs are updated regularly to support new transformations. If you want to + # use a transformation that is not supported by the SDK, You can use the `raw` + # parameter to pass the transformation string directly. See the + # [Transformations documentation](https://imagekit.io/docs/transformations). + sig do + params( + ai_change_background: String, + ai_drop_shadow: T.any(T::Boolean, String), + ai_edit: String, + ai_remove_background: + Imagekitio::Transformation::AIRemoveBackground::OrBoolean, + ai_remove_background_external: + Imagekitio::Transformation::AIRemoveBackgroundExternal::OrBoolean, + ai_retouch: Imagekitio::Transformation::AIRetouch::OrBoolean, + ai_upscale: Imagekitio::Transformation::AIUpscale::OrBoolean, + ai_variation: Imagekitio::Transformation::AIVariation::OrBoolean, + aspect_ratio: Imagekitio::Transformation::AspectRatio::Variants, + audio_codec: Imagekitio::Transformation::AudioCodec::OrSymbol, + background: String, + blur: Float, + border: String, + color_profile: T::Boolean, + contrast_stretch: + Imagekitio::Transformation::ContrastStretch::OrBoolean, + crop: Imagekitio::Transformation::Crop::OrSymbol, + crop_mode: Imagekitio::Transformation::CropMode::OrSymbol, + default_image: String, + dpr: Float, + duration: Imagekitio::Transformation::Duration::Variants, + end_offset: Imagekitio::Transformation::EndOffset::Variants, + flip: Imagekitio::Transformation::Flip::OrSymbol, + focus: String, + format_: Imagekitio::Transformation::Format::OrSymbol, + gradient: T.any(T::Boolean, String), + grayscale: Imagekitio::Transformation::Grayscale::OrBoolean, + height: Imagekitio::Transformation::Height::Variants, + lossless: T::Boolean, + metadata: T::Boolean, + named: String, + opacity: Float, + original: T::Boolean, + overlay: Imagekitio::Overlay, + page: Imagekitio::Transformation::Page::Variants, + progressive: T::Boolean, + quality: Float, + radius: T.any(Float, Symbol), + raw: String, + rotation: Imagekitio::Transformation::Rotation::Variants, + shadow: T.any(T::Boolean, String), + sharpen: T.any(T::Boolean, Float), + start_offset: Imagekitio::Transformation::StartOffset::Variants, + streaming_resolutions: + T::Array[Imagekitio::StreamingResolution::OrSymbol], + trim: T.any(T::Boolean, Float), + unsharp_mask: T.any(T::Boolean, String), + video_codec: Imagekitio::Transformation::VideoCodec::OrSymbol, + width: Imagekitio::Transformation::Width::Variants, + x: Imagekitio::Transformation::X::Variants, + x_center: Imagekitio::Transformation::XCenter::Variants, + y_: Imagekitio::Transformation::Y::Variants, + y_center: Imagekitio::Transformation::YCenter::Variants, + zoom: Float + ).returns(T.attached_class) + end + def self.new( + # 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). + ai_change_background: nil, + # 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). + ai_drop_shadow: nil, + # 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). + ai_edit: nil, + # 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). + ai_remove_background: nil, + # 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). + ai_remove_background_external: nil, + # 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). + ai_retouch: nil, + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + ai_upscale: nil, + # 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). + ai_variation: nil, + # 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). + aspect_ratio: nil, + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + audio_codec: nil, + # 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). + # - 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). + background: nil, + # 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). + blur: nil, + # 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). + border: nil, + # Indicates whether the output image should retain the original color profile. See + # [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + color_profile: nil, + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + contrast_stretch: nil, + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + crop: nil, + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + crop_mode: nil, + # 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). + default_image: nil, + # Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio + # (DPR) calculation. See + # [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + dpr: nil, + # 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). + duration: nil, + # 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). + end_offset: nil, + # 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). + flip: nil, + # 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) + focus: nil, + # 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). + format_: nil, + # 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). + gradient: nil, + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + grayscale: nil, + # 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) + height: nil, + # 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). + lossless: nil, + # 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). + metadata: nil, + # Named transformation reference. See + # [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + named: nil, + # Specifies the opacity level of the output image. See + # [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + opacity: nil, + # 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). + original: nil, + # 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). + overlay: nil, + # 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). + page: nil, + # 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). + progressive: nil, + # 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). + quality: nil, + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + radius: nil, + # Pass any transformation not directly supported by the SDK. This transformation + # string is appended to the URL as provided. + raw: nil, + # 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). + rotation: nil, + # 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). + shadow: nil, + # 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). + sharpen: nil, + # 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). + start_offset: nil, + # 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). + streaming_resolutions: nil, + # 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). + trim: nil, + # 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). + unsharp_mask: nil, + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + video_codec: nil, + # 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) + width: nil, + # 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). + x: nil, + # 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). + x_center: nil, + # 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). + y_: nil, + # 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). + y_center: nil, + # 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). + zoom: nil + ) + end + + sig do + override.returns( + { + ai_change_background: String, + ai_drop_shadow: T.any(T::Boolean, String), + ai_edit: String, + ai_remove_background: + Imagekitio::Transformation::AIRemoveBackground::OrBoolean, + ai_remove_background_external: + Imagekitio::Transformation::AIRemoveBackgroundExternal::OrBoolean, + ai_retouch: Imagekitio::Transformation::AIRetouch::OrBoolean, + ai_upscale: Imagekitio::Transformation::AIUpscale::OrBoolean, + ai_variation: Imagekitio::Transformation::AIVariation::OrBoolean, + aspect_ratio: Imagekitio::Transformation::AspectRatio::Variants, + audio_codec: Imagekitio::Transformation::AudioCodec::OrSymbol, + background: String, + blur: Float, + border: String, + color_profile: T::Boolean, + contrast_stretch: + Imagekitio::Transformation::ContrastStretch::OrBoolean, + crop: Imagekitio::Transformation::Crop::OrSymbol, + crop_mode: Imagekitio::Transformation::CropMode::OrSymbol, + default_image: String, + dpr: Float, + duration: Imagekitio::Transformation::Duration::Variants, + end_offset: Imagekitio::Transformation::EndOffset::Variants, + flip: Imagekitio::Transformation::Flip::OrSymbol, + focus: String, + format_: Imagekitio::Transformation::Format::OrSymbol, + gradient: T.any(T::Boolean, String), + grayscale: Imagekitio::Transformation::Grayscale::OrBoolean, + height: Imagekitio::Transformation::Height::Variants, + lossless: T::Boolean, + metadata: T::Boolean, + named: String, + opacity: Float, + original: T::Boolean, + overlay: Imagekitio::Overlay, + page: Imagekitio::Transformation::Page::Variants, + progressive: T::Boolean, + quality: Float, + radius: T.any(Float, Symbol), + raw: String, + rotation: Imagekitio::Transformation::Rotation::Variants, + shadow: T.any(T::Boolean, String), + sharpen: T.any(T::Boolean, Float), + start_offset: Imagekitio::Transformation::StartOffset::Variants, + streaming_resolutions: + T::Array[Imagekitio::StreamingResolution::OrSymbol], + trim: T.any(T::Boolean, Float), + unsharp_mask: T.any(T::Boolean, String), + video_codec: Imagekitio::Transformation::VideoCodec::OrSymbol, + width: Imagekitio::Transformation::Width::Variants, + x: Imagekitio::Transformation::X::Variants, + x_center: Imagekitio::Transformation::XCenter::Variants, + y_: Imagekitio::Transformation::Y::Variants, + y_center: Imagekitio::Transformation::YCenter::Variants, + zoom: Float + } + ) + end + def to_hash + end + + # 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). + module AIDropShadow + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::AIDropShadow::Variants] + ) + end + def self.variants + end + end + + # 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). + module AIRemoveBackground + extend Imagekitio::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekitio::Transformation::AIRemoveBackground) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = + T.let( + true, + Imagekitio::Transformation::AIRemoveBackground::TaggedBoolean + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Transformation::AIRemoveBackground::TaggedBoolean + ] + ) + end + def self.values + end + end + + # 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). + module AIRemoveBackgroundExternal + extend Imagekitio::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all( + T::Boolean, + Imagekitio::Transformation::AIRemoveBackgroundExternal + ) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = + T.let( + true, + Imagekitio::Transformation::AIRemoveBackgroundExternal::TaggedBoolean + ) + + sig do + override.returns( + T::Array[ + Imagekitio::Transformation::AIRemoveBackgroundExternal::TaggedBoolean + ] + ) + end + def self.values + end + end + + # 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). + module AIRetouch + extend Imagekitio::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekitio::Transformation::AIRetouch) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = T.let(true, Imagekitio::Transformation::AIRetouch::TaggedBoolean) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::AIRetouch::TaggedBoolean] + ) + end + def self.values + end + end + + # Upscales images beyond their original dimensions using AI. Not supported inside + # overlay. See + # [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + module AIUpscale + extend Imagekitio::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekitio::Transformation::AIUpscale) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = T.let(true, Imagekitio::Transformation::AIUpscale::TaggedBoolean) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::AIUpscale::TaggedBoolean] + ) + end + def self.values + end + end + + # 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). + module AIVariation + extend Imagekitio::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekitio::Transformation::AIVariation) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = + T.let(true, Imagekitio::Transformation::AIVariation::TaggedBoolean) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::AIVariation::TaggedBoolean] + ) + end + def self.values + end + end + + # 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). + module AspectRatio + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::AspectRatio::Variants] + ) + end + def self.variants + end + end + + # Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + # [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::Transformation::AudioCodec) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AAC = T.let(:aac, Imagekitio::Transformation::AudioCodec::TaggedSymbol) + OPUS = + T.let(:opus, Imagekitio::Transformation::AudioCodec::TaggedSymbol) + NONE = + T.let(:none, Imagekitio::Transformation::AudioCodec::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::AudioCodec::TaggedSymbol] + ) + end + def self.values + end + end + + # Automatically enhances the contrast of an image (contrast stretch). See + # [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + module ContrastStretch + extend Imagekitio::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekitio::Transformation::ContrastStretch) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = + T.let( + true, + Imagekitio::Transformation::ContrastStretch::TaggedBoolean + ) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::ContrastStretch::TaggedBoolean] + ) + end + def self.values + end + end + + # Crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + module Crop + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::Transformation::Crop) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + FORCE = T.let(:force, Imagekitio::Transformation::Crop::TaggedSymbol) + AT_MAX = T.let(:at_max, Imagekitio::Transformation::Crop::TaggedSymbol) + AT_MAX_ENLARGE = + T.let(:at_max_enlarge, Imagekitio::Transformation::Crop::TaggedSymbol) + AT_LEAST = + T.let(:at_least, Imagekitio::Transformation::Crop::TaggedSymbol) + MAINTAIN_RATIO = + T.let(:maintain_ratio, Imagekitio::Transformation::Crop::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Crop::TaggedSymbol] + ) + end + def self.values + end + end + + # Additional crop modes for image resizing. See + # [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + module CropMode + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::Transformation::CropMode) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + PAD_RESIZE = + T.let(:pad_resize, Imagekitio::Transformation::CropMode::TaggedSymbol) + EXTRACT = + T.let(:extract, Imagekitio::Transformation::CropMode::TaggedSymbol) + PAD_EXTRACT = + T.let( + :pad_extract, + Imagekitio::Transformation::CropMode::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::CropMode::TaggedSymbol] + ) + end + def self.values + end + end + + # 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). + module Duration + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Duration::Variants] + ) + end + def self.variants + end + end + + # 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). + module EndOffset + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::EndOffset::Variants] + ) + end + def self.variants + end + end + + # 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). + module Flip + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::Transformation::Flip) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H = T.let(:h, Imagekitio::Transformation::Flip::TaggedSymbol) + V = T.let(:v, Imagekitio::Transformation::Flip::TaggedSymbol) + H_V = T.let(:h_v, Imagekitio::Transformation::Flip::TaggedSymbol) + V_H = T.let(:v_h, Imagekitio::Transformation::Flip::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Flip::TaggedSymbol] + ) + end + def self.values + end + end + + # 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). + module Format + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::Transformation::Format) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekitio::Transformation::Format::TaggedSymbol) + WEBP = T.let(:webp, Imagekitio::Transformation::Format::TaggedSymbol) + JPG = T.let(:jpg, Imagekitio::Transformation::Format::TaggedSymbol) + JPEG = T.let(:jpeg, Imagekitio::Transformation::Format::TaggedSymbol) + PNG = T.let(:png, Imagekitio::Transformation::Format::TaggedSymbol) + GIF = T.let(:gif, Imagekitio::Transformation::Format::TaggedSymbol) + SVG = T.let(:svg, Imagekitio::Transformation::Format::TaggedSymbol) + MP4 = T.let(:mp4, Imagekitio::Transformation::Format::TaggedSymbol) + WEBM = T.let(:webm, Imagekitio::Transformation::Format::TaggedSymbol) + AVIF = T.let(:avif, Imagekitio::Transformation::Format::TaggedSymbol) + ORIG = T.let(:orig, Imagekitio::Transformation::Format::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Format::TaggedSymbol] + ) + end + def self.values + end + end + + # 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). + module Gradient + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Gradient::Variants] + ) + end + def self.variants + end + end + + # Enables a grayscale effect for images. See + # [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + module Grayscale + extend Imagekitio::Internal::Type::Enum + + TaggedBoolean = + T.type_alias do + T.all(T::Boolean, Imagekitio::Transformation::Grayscale) + end + OrBoolean = T.type_alias { T::Boolean } + + TRUE = T.let(true, Imagekitio::Transformation::Grayscale::TaggedBoolean) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Grayscale::TaggedBoolean] + ) + end + def self.values + end + end + + # 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) + module Height + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Height::Variants] + ) + end + def self.variants + end + end + + # 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). + module Page + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekitio::Transformation::Page::Variants]) + end + def self.variants + end + end + + # Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular + # or oval shape. See + # [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + module Radius + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, Symbol) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Radius::Variants] + ) + end + def self.variants + end + end + + # 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). + module Rotation + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Rotation::Variants] + ) + end + def self.variants + end + end + + # 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). + module Shadow + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Shadow::Variants] + ) + end + def self.variants + end + end + + # 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). + module Sharpen + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, Float) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Sharpen::Variants] + ) + end + def self.variants + end + end + + # 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). + module StartOffset + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::StartOffset::Variants] + ) + end + def self.variants + end + end + + # 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). + module Trim + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, Float) } + + sig do + override.returns(T::Array[Imagekitio::Transformation::Trim::Variants]) + end + def self.variants + end + end + + # 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). + module UnsharpMask + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Boolean, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::UnsharpMask::Variants] + ) + end + def self.variants + end + end + + # Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + # [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::Transformation::VideoCodec) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H264 = + T.let(:h264, Imagekitio::Transformation::VideoCodec::TaggedSymbol) + VP9 = T.let(:vp9, Imagekitio::Transformation::VideoCodec::TaggedSymbol) + AV1 = T.let(:av1, Imagekitio::Transformation::VideoCodec::TaggedSymbol) + NONE = + T.let(:none, Imagekitio::Transformation::VideoCodec::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::Transformation::VideoCodec::TaggedSymbol] + ) + end + def self.values + end + end + + # 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) + module Width + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::Width::Variants] + ) + end + def self.variants + end + end + + # 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). + module X + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekitio::Transformation::X::Variants]) + end + def self.variants + end + end + + # 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). + module XCenter + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::XCenter::Variants] + ) + end + def self.variants + end + end + + # 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). + module Y + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns(T::Array[Imagekitio::Transformation::Y::Variants]) + end + def self.variants + end + end + + # 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). + module YCenter + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(Float, String) } + + sig do + override.returns( + T::Array[Imagekitio::Transformation::YCenter::Variants] + ) + end + def self.variants + end + end + end + end +end diff --git a/rbi/imagekitio/models/transformation_position.rbi b/rbi/imagekitio/models/transformation_position.rbi new file mode 100644 index 00000000..cfcec092 --- /dev/null +++ b/rbi/imagekitio/models/transformation_position.rbi @@ -0,0 +1,28 @@ +# typed: strong + +module Imagekitio + module Models + # 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). + module TransformationPosition + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::TransformationPosition) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + PATH = T.let(:path, Imagekitio::TransformationPosition::TaggedSymbol) + QUERY = T.let(:query, Imagekitio::TransformationPosition::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::TransformationPosition::TaggedSymbol] + ) + end + def self.values + end + end + end +end diff --git a/rbi/imagekitio/models/unsafe_unwrap_webhook_event.rbi b/rbi/imagekitio/models/unsafe_unwrap_webhook_event.rbi new file mode 100644 index 00000000..2e878626 --- /dev/null +++ b/rbi/imagekitio/models/unsafe_unwrap_webhook_event.rbi @@ -0,0 +1,33 @@ +# typed: strong + +module Imagekitio + module Models + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + module UnsafeUnwrapWebhookEvent + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::VideoTransformationAcceptedEvent, + Imagekitio::VideoTransformationReadyEvent, + Imagekitio::VideoTransformationErrorEvent, + Imagekitio::UploadPreTransformSuccessEvent, + Imagekitio::UploadPreTransformErrorEvent, + Imagekitio::UploadPostTransformSuccessEvent, + Imagekitio::UploadPostTransformErrorEvent + ) + end + + sig do + override.returns( + T::Array[Imagekitio::UnsafeUnwrapWebhookEvent::Variants] + ) + end + def self.variants + end + end + end +end diff --git a/rbi/imagekitio/models/unwrap_webhook_event.rbi b/rbi/imagekitio/models/unwrap_webhook_event.rbi new file mode 100644 index 00000000..8dcbd0dd --- /dev/null +++ b/rbi/imagekitio/models/unwrap_webhook_event.rbi @@ -0,0 +1,31 @@ +# typed: strong + +module Imagekitio + module Models + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + module UnwrapWebhookEvent + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::VideoTransformationAcceptedEvent, + Imagekitio::VideoTransformationReadyEvent, + Imagekitio::VideoTransformationErrorEvent, + Imagekitio::UploadPreTransformSuccessEvent, + Imagekitio::UploadPreTransformErrorEvent, + Imagekitio::UploadPostTransformSuccessEvent, + Imagekitio::UploadPostTransformErrorEvent + ) + end + + sig do + override.returns(T::Array[Imagekitio::UnwrapWebhookEvent::Variants]) + end + def self.variants + end + end + end +end diff --git a/rbi/imagekitio/models/update_file_request.rbi b/rbi/imagekitio/models/update_file_request.rbi new file mode 100644 index 00000000..3a818c9c --- /dev/null +++ b/rbi/imagekitio/models/update_file_request.rbi @@ -0,0 +1,316 @@ +# typed: strong + +module Imagekitio + module Models + # Schema for update file update request. + module UpdateFileRequest + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Imagekitio::UpdateFileRequest::UpdateFileDetails, + Imagekitio::UpdateFileRequest::ChangePublicationStatus + ) + end + + class UpdateFileDetails < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UpdateFileRequest::UpdateFileDetails, + Imagekitio::Internal::AnyHash + ) + end + + # 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. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # 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. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + sig do + returns( + T.nilable( + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg, + Imagekitio::ExtensionItem::AIAutoDescription, + Imagekitio::ExtensionItem::AutoTaggingExtension + ) + ] + ) + ) + end + attr_reader :extensions + + sig do + params( + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg::OrHash, + Imagekitio::ExtensionItem::AIAutoDescription::OrHash, + Imagekitio::ExtensionItem::AutoTaggingExtension::OrHash + ) + ] + ).void + end + attr_writer :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. + sig { returns(T.nilable(T.any(T::Array[String], Symbol))) } + attr_reader :remove_ai_tags + + sig { params(remove_ai_tags: T.any(T::Array[String], Symbol)).void } + attr_writer :remove_ai_tags + + # An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + # `null` to unset all tags associated with the file. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :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. + sig { returns(T.nilable(String)) } + attr_reader :webhook_url + + sig { params(webhook_url: String).void } + attr_writer :webhook_url + + sig do + params( + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg::OrHash, + Imagekitio::ExtensionItem::AIAutoDescription::OrHash, + Imagekitio::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + remove_ai_tags: T.any(T::Array[String], Symbol), + tags: T.nilable(T::Array[String]), + webhook_url: String + ).returns(T.attached_class) + end + def self.new( + # 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. + custom_coordinates: nil, + # 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. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # 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. + remove_ai_tags: nil, + # An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + # `null` to unset all tags associated with the file. + tags: nil, + # 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. + webhook_url: nil + ) + end + + sig do + override.returns( + { + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg, + Imagekitio::ExtensionItem::AIAutoDescription, + Imagekitio::ExtensionItem::AutoTaggingExtension + ) + ], + remove_ai_tags: T.any(T::Array[String], Symbol), + tags: T.nilable(T::Array[String]), + webhook_url: String + } + ) + end + def to_hash + end + + # 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. + module RemoveAITags + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(T::Array[String], Symbol) } + + sig do + override.returns( + T::Array[ + Imagekitio::UpdateFileRequest::UpdateFileDetails::RemoveAITags::Variants + ] + ) + end + def self.variants + end + + StringArray = + T.let( + Imagekitio::Internal::Type::ArrayOf[String], + Imagekitio::Internal::Type::Converter + ) + end + end + + class ChangePublicationStatus < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UpdateFileRequest::ChangePublicationStatus, + Imagekitio::Internal::AnyHash + ) + end + + # Configure the publication status of a file and its versions. + sig do + returns( + T.nilable( + Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish + ) + ) + end + attr_reader :publish + + sig do + params( + publish: + Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish::OrHash + ).void + end + attr_writer :publish + + sig do + params( + publish: + Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish::OrHash + ).returns(T.attached_class) + end + def self.new( + # Configure the publication status of a file and its versions. + publish: nil + ) + end + + sig do + override.returns( + { + publish: + Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish + } + ) + end + def to_hash + end + + class Publish < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish, + Imagekitio::Internal::AnyHash + ) + end + + # Set to `true` to publish the file. Set to `false` to unpublish the file. + sig { returns(T::Boolean) } + attr_accessor :is_published + + # Set to `true` to publish/unpublish all versions of the file. Set to `false` to + # publish/unpublish only the current version of the file. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :include_file_versions + + sig { params(include_file_versions: T::Boolean).void } + attr_writer :include_file_versions + + # Configure the publication status of a file and its versions. + sig do + params( + is_published: T::Boolean, + include_file_versions: T::Boolean + ).returns(T.attached_class) + end + def self.new( + # Set to `true` to publish the file. Set to `false` to unpublish the file. + is_published:, + # Set to `true` to publish/unpublish all versions of the file. Set to `false` to + # publish/unpublish only the current version of the file. + include_file_versions: nil + ) + end + + sig do + override.returns( + { is_published: T::Boolean, include_file_versions: T::Boolean } + ) + end + def to_hash + end + end + end + + sig do + override.returns(T::Array[Imagekitio::UpdateFileRequest::Variants]) + end + def self.variants + end + end + end +end diff --git a/rbi/imagekitio/models/upload_post_transform_error_event.rbi b/rbi/imagekitio/models/upload_post_transform_error_event.rbi new file mode 100644 index 00000000..51472bff --- /dev/null +++ b/rbi/imagekitio/models/upload_post_transform_error_event.rbi @@ -0,0 +1,434 @@ +# typed: strong + +module Imagekitio + module Models + class UploadPostTransformErrorEvent < Imagekitio::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformErrorEvent, + Imagekitio::Internal::AnyHash + ) + end + + # Timestamp of when the event occurred in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekitio::UploadPostTransformErrorEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekitio::UploadPostTransformErrorEvent::Data::OrHash + ).void + end + attr_writer :data + + sig { returns(Imagekitio::UploadPostTransformErrorEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekitio::UploadPostTransformErrorEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a post-transformation fails. The original file remains available, + # but the requested transformation could not be generated. + sig do + params( + created_at: Time, + data: Imagekitio::UploadPostTransformErrorEvent::Data::OrHash, + request: Imagekitio::UploadPostTransformErrorEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp of when the event occurred in ISO8601 format. + created_at:, + data:, + request:, + type: :"upload.post-transform.error" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekitio::UploadPostTransformErrorEvent::Data, + request: Imagekitio::UploadPostTransformErrorEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformErrorEvent::Data, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the originally uploaded file. + sig { returns(String) } + attr_accessor :file_id + + # Name of the file. + sig { returns(String) } + attr_accessor :name + + # Path of the file. + sig { returns(String) } + attr_accessor :path + + sig do + returns( + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + # URL of the attempted post-transformation. + sig { returns(String) } + attr_accessor :url + + sig do + params( + file_id: String, + name: String, + path: String, + transformation: + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::OrHash, + url: String + ).returns(T.attached_class) + end + def self.new( + # Unique identifier of the originally uploaded file. + file_id:, + # Name of the file. + name:, + # Path of the file. + path:, + transformation:, + # URL of the attempted post-transformation. + url: + ) + end + + sig do + override.returns( + { + file_id: String, + name: String, + path: String, + transformation: + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation, + url: String + } + ) + end + def to_hash + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + sig do + returns( + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error + ) + end + attr_reader :error + + sig do + params( + error: + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error::OrHash + ).void + end + attr_writer :error + + sig do + params( + error: + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error::OrHash + ).returns(T.attached_class) + end + def self.new(error:) + end + + sig do + override.returns( + { + error: + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error + } + ) + end + def to_hash + end + + class Error < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error, + Imagekitio::Internal::AnyHash + ) + end + + # Reason for the post-transformation failure. + sig { returns(String) } + attr_accessor :reason + + sig { params(reason: String).returns(T.attached_class) } + def self.new( + # Reason for the post-transformation failure. + reason: + ) + end + + sig { override.returns({ reason: String }) } + def to_hash + end + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformErrorEvent::Request, + Imagekitio::Internal::AnyHash + ) + end + + sig do + returns( + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::OrHash + ).void + end + attr_writer :transformation + + # Unique identifier for the originating request. + sig { returns(String) } + attr_accessor :x_request_id + + sig do + params( + transformation: + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::OrHash, + x_request_id: String + ).returns(T.attached_class) + end + def self.new( + transformation:, + # Unique identifier for the originating request. + x_request_id: + ) + end + + sig do + override.returns( + { + transformation: + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation, + x_request_id: String + } + ) + end + def to_hash + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + # Type of the requested post-transformation. + sig do + returns( + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + sig do + returns( + T.nilable( + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol + ) + ) + end + attr_reader :protocol + + sig do + params( + protocol: + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Protocol::OrSymbol + ).void + end + attr_writer :protocol + + # Value for the requested transformation type. + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params( + type: + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type::OrSymbol, + protocol: + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Protocol::OrSymbol, + value: String + ).returns(T.attached_class) + end + def self.new( + # Type of the requested post-transformation. + type:, + # Only applicable if transformation type is 'abs'. Streaming protocol used. + protocol: nil, + # Value for the requested transformation type. + value: nil + ) + end + + sig do + override.returns( + { + type: + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol, + protocol: + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol, + value: String + } + ) + end + def to_hash + end + + # Type of the requested post-transformation. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TRANSFORMATION = + T.let( + :transformation, + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + ABS = + T.let( + :abs, + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + THUMBNAIL = + T.let( + :thumbnail, + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + module Protocol + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Protocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :hls, + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol + ) + DASH = + T.let( + :dash, + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPostTransformErrorEvent::Request::Transformation::Protocol::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/upload_post_transform_success_event.rbi b/rbi/imagekitio/models/upload_post_transform_success_event.rbi new file mode 100644 index 00000000..f71b2e1d --- /dev/null +++ b/rbi/imagekitio/models/upload_post_transform_success_event.rbi @@ -0,0 +1,327 @@ +# typed: strong + +module Imagekitio + module Models + class UploadPostTransformSuccessEvent < Imagekitio::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformSuccessEvent, + Imagekitio::Internal::AnyHash + ) + end + + # Timestamp of when the event occurred in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekitio::UploadPostTransformSuccessEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekitio::UploadPostTransformSuccessEvent::Data::OrHash + ).void + end + attr_writer :data + + sig { returns(Imagekitio::UploadPostTransformSuccessEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekitio::UploadPostTransformSuccessEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a post-transformation completes successfully. The transformed + # version of the file is now ready and can be accessed via the provided URL. Note + # that each post-transformation generates a separate webhook event. + sig do + params( + created_at: Time, + data: Imagekitio::UploadPostTransformSuccessEvent::Data::OrHash, + request: Imagekitio::UploadPostTransformSuccessEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp of when the event occurred in ISO8601 format. + created_at:, + data:, + request:, + type: :"upload.post-transform.success" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekitio::UploadPostTransformSuccessEvent::Data, + request: Imagekitio::UploadPostTransformSuccessEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformSuccessEvent::Data, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the originally uploaded file. + sig { returns(String) } + attr_accessor :file_id + + # Name of the file. + sig { returns(String) } + attr_accessor :name + + # URL of the generated post-transformation. + sig { returns(String) } + attr_accessor :url + + sig do + params(file_id: String, name: String, url: String).returns( + T.attached_class + ) + end + def self.new( + # Unique identifier of the originally uploaded file. + file_id:, + # Name of the file. + name:, + # URL of the generated post-transformation. + url: + ) + end + + sig { override.returns({ file_id: String, name: String, url: String }) } + def to_hash + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformSuccessEvent::Request, + Imagekitio::Internal::AnyHash + ) + end + + sig do + returns( + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::OrHash + ).void + end + attr_writer :transformation + + # Unique identifier for the originating request. + sig { returns(String) } + attr_accessor :x_request_id + + sig do + params( + transformation: + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::OrHash, + x_request_id: String + ).returns(T.attached_class) + end + def self.new( + transformation:, + # Unique identifier for the originating request. + x_request_id: + ) + end + + sig do + override.returns( + { + transformation: + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation, + x_request_id: String + } + ) + end + def to_hash + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + # Type of the requested post-transformation. + sig do + returns( + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + sig do + returns( + T.nilable( + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol + ) + ) + end + attr_reader :protocol + + sig do + params( + protocol: + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::OrSymbol + ).void + end + attr_writer :protocol + + # Value for the requested transformation type. + sig { returns(T.nilable(String)) } + attr_reader :value + + sig { params(value: String).void } + attr_writer :value + + sig do + params( + type: + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type::OrSymbol, + protocol: + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::OrSymbol, + value: String + ).returns(T.attached_class) + end + def self.new( + # Type of the requested post-transformation. + type:, + # Only applicable if transformation type is 'abs'. Streaming protocol used. + protocol: nil, + # Value for the requested transformation type. + value: nil + ) + end + + sig do + override.returns( + { + type: + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol, + protocol: + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol, + value: String + } + ) + end + def to_hash + end + + # Type of the requested post-transformation. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TRANSFORMATION = + T.let( + :transformation, + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + ABS = + T.let( + :abs, + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + THUMBNAIL = + T.let( + :thumbnail, + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Only applicable if transformation type is 'abs'. Streaming protocol used. + module Protocol + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Protocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :hls, + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol + ) + DASH = + T.let( + :dash, + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation::Protocol::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end + end +end diff --git a/rbi/imagekitio/models/upload_pre_transform_error_event.rbi b/rbi/imagekitio/models/upload_pre_transform_error_event.rbi new file mode 100644 index 00000000..4963a4b7 --- /dev/null +++ b/rbi/imagekitio/models/upload_pre_transform_error_event.rbi @@ -0,0 +1,244 @@ +# typed: strong + +module Imagekitio + module Models + class UploadPreTransformErrorEvent < Imagekitio::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformErrorEvent, + Imagekitio::Internal::AnyHash + ) + end + + # Timestamp of when the event occurred in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekitio::UploadPreTransformErrorEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekitio::UploadPreTransformErrorEvent::Data::OrHash + ).void + end + attr_writer :data + + sig { returns(Imagekitio::UploadPreTransformErrorEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekitio::UploadPreTransformErrorEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a pre-transformation fails. The file upload may have been + # accepted, but the requested transformation could not be applied. + sig do + params( + created_at: Time, + data: Imagekitio::UploadPreTransformErrorEvent::Data::OrHash, + request: Imagekitio::UploadPreTransformErrorEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp of when the event occurred in ISO8601 format. + created_at:, + data:, + request:, + type: :"upload.pre-transform.error" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekitio::UploadPreTransformErrorEvent::Data, + request: Imagekitio::UploadPreTransformErrorEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformErrorEvent::Data, + Imagekitio::Internal::AnyHash + ) + end + + # Name of the file. + sig { returns(String) } + attr_accessor :name + + # Path of the file. + sig { returns(String) } + attr_accessor :path + + sig do + returns( + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + sig do + params( + name: String, + path: String, + transformation: + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::OrHash + ).returns(T.attached_class) + end + def self.new( + # Name of the file. + name:, + # Path of the file. + path:, + transformation: + ) + end + + sig do + override.returns( + { + name: String, + path: String, + transformation: + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation + } + ) + end + def to_hash + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + sig do + returns( + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error + ) + end + attr_reader :error + + sig do + params( + error: + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error::OrHash + ).void + end + attr_writer :error + + sig do + params( + error: + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error::OrHash + ).returns(T.attached_class) + end + def self.new(error:) + end + + sig do + override.returns( + { + error: + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error + } + ) + end + def to_hash + end + + class Error < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error, + Imagekitio::Internal::AnyHash + ) + end + + # Reason for the pre-transformation failure. + sig { returns(String) } + attr_accessor :reason + + sig { params(reason: String).returns(T.attached_class) } + def self.new( + # Reason for the pre-transformation failure. + reason: + ) + end + + sig { override.returns({ reason: String }) } + def to_hash + end + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformErrorEvent::Request, + Imagekitio::Internal::AnyHash + ) + end + + # The requested pre-transformation string. + sig { returns(String) } + attr_accessor :transformation + + # Unique identifier for the originating request. + sig { returns(String) } + attr_accessor :x_request_id + + sig do + params(transformation: String, x_request_id: String).returns( + T.attached_class + ) + end + def self.new( + # The requested pre-transformation string. + transformation:, + # Unique identifier for the originating request. + x_request_id: + ) + end + + sig do + override.returns({ transformation: String, x_request_id: String }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/upload_pre_transform_success_event.rbi b/rbi/imagekitio/models/upload_pre_transform_success_event.rbi new file mode 100644 index 00000000..f989dd66 --- /dev/null +++ b/rbi/imagekitio/models/upload_pre_transform_success_event.rbi @@ -0,0 +1,1300 @@ +# typed: strong + +module Imagekitio + module Models + class UploadPreTransformSuccessEvent < Imagekitio::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformSuccessEvent, + Imagekitio::Internal::AnyHash + ) + end + + # Timestamp of when the event occurred in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + # Object containing details of a successful upload. + sig { returns(Imagekitio::UploadPreTransformSuccessEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekitio::UploadPreTransformSuccessEvent::Data::OrHash + ).void + end + attr_writer :data + + sig { returns(Imagekitio::UploadPreTransformSuccessEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekitio::UploadPreTransformSuccessEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a pre-transformation completes successfully. The file has been + # processed with the requested transformation and is now available in the Media + # Library. + sig do + params( + created_at: Time, + data: Imagekitio::UploadPreTransformSuccessEvent::Data::OrHash, + request: Imagekitio::UploadPreTransformSuccessEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp of when the event occurred in ISO8601 format. + created_at:, + # Object containing details of a successful upload. + data:, + request:, + type: :"upload.pre-transform.success" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekitio::UploadPreTransformSuccessEvent::Data, + request: Imagekitio::UploadPreTransformSuccessEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformSuccessEvent::Data, + Imagekitio::Internal::AnyHash + ) + end + + # An array of tags assigned to the uploaded file by auto tagging. + sig do + returns( + T.nilable( + T::Array[Imagekitio::UploadPreTransformSuccessEvent::Data::AITag] + ) + ) + end + attr_accessor :ai_tags + + # The audio codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :audio_codec + + sig { params(audio_codec: String).void } + attr_writer :audio_codec + + # The bit rate of the video in kbps (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :bit_rate + + sig { params(bit_rate: Integer).void } + attr_writer :bit_rate + + # 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. + sig { returns(T.nilable(String)) } + attr_accessor :custom_coordinates + + # 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. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :custom_metadata + + sig { params(custom_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :custom_metadata + + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + sig { returns(T.nilable(String)) } + attr_reader :description + + sig { params(description: String).void } + attr_writer :description + + # The duration of the video in seconds (only for video). + sig { returns(T.nilable(Integer)) } + attr_reader :duration + + sig { params(duration: Integer).void } + attr_writer :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. + sig { returns(T.nilable(T::Hash[Symbol, T.anything])) } + attr_reader :embedded_metadata + + sig { params(embedded_metadata: T::Hash[Symbol, T.anything]).void } + attr_writer :embedded_metadata + + # 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. + sig do + returns( + T.nilable( + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus + ) + ) + end + attr_reader :extension_status + + sig do + params( + extension_status: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::OrHash + ).void + end + attr_writer :extension_status + + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + sig { returns(T.nilable(String)) } + attr_reader :file_id + + sig { params(file_id: String).void } + attr_writer :file_id + + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + sig { returns(T.nilable(String)) } + attr_reader :file_path + + sig { params(file_path: String).void } + attr_writer :file_path + + # Type of the uploaded file. Possible values are `image`, `non-image`. + sig { returns(T.nilable(String)) } + attr_reader :file_type + + sig { params(file_type: String).void } + attr_writer :file_type + + # Height of the image in pixels (Only for images) + sig { returns(T.nilable(Float)) } + attr_reader :height + + sig { params(height: Float).void } + attr_writer :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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_private_file + + sig { params(is_private_file: T::Boolean).void } + attr_writer :is_private_file + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_published + + sig { params(is_published: T::Boolean).void } + attr_writer :is_published + + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + sig { returns(T.nilable(Imagekitio::Metadata)) } + attr_reader :metadata + + sig { params(metadata: Imagekitio::Metadata::OrHash).void } + attr_writer :metadata + + # Name of the asset. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :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. + sig do + returns( + T.nilable( + T::Hash[ + Symbol, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema + ] + ) + ) + end + attr_reader :selected_fields_schema + + sig do + params( + selected_fields_schema: + T::Hash[ + Symbol, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::OrHash + ] + ).void + end + attr_writer :selected_fields_schema + + # Size of the image file in Bytes. + sig { returns(T.nilable(Float)) } + attr_reader :size + + sig { params(size: Float).void } + attr_writer :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. + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :tags + + # In the case of an image, a small thumbnail URL. + sig { returns(T.nilable(String)) } + attr_reader :thumbnail_url + + sig { params(thumbnail_url: String).void } + attr_writer :thumbnail_url + + # A publicly accessible URL of the file. + sig { returns(T.nilable(String)) } + attr_reader :url + + sig { params(url: String).void } + attr_writer :url + + # An object containing the file or file version's `id` (versionId) and `name`. + sig do + returns( + T.nilable( + Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo + ) + ) + end + attr_reader :version_info + + sig do + params( + version_info: + Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo::OrHash + ).void + end + attr_writer :version_info + + # The video codec used in the video (only for video). + sig { returns(T.nilable(String)) } + attr_reader :video_codec + + sig { params(video_codec: String).void } + attr_writer :video_codec + + # Width of the image in pixels (Only for Images) + sig { returns(T.nilable(Float)) } + attr_reader :width + + sig { params(width: Float).void } + attr_writer :width + + # Object containing details of a successful upload. + sig do + params( + ai_tags: + T.nilable( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::AITag::OrHash + ] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::OrHash, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekitio::Metadata::OrHash, + name: String, + selected_fields_schema: + T::Hash[ + Symbol, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::OrHash + ], + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo::OrHash, + video_codec: String, + width: Float + ).returns(T.attached_class) + end + def self.new( + # An array of tags assigned to the uploaded file by auto tagging. + ai_tags: nil, + # The audio codec used in the video (only for video). + audio_codec: nil, + # The bit rate of the video in kbps (only for video). + bit_rate: nil, + # 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. + custom_coordinates: nil, + # 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. + custom_metadata: nil, + # Optional text to describe the contents of the file. Can be set by the user or + # the ai-auto-description extension. + description: nil, + # The duration of the video in seconds (only for video). + duration: nil, + # 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. + embedded_metadata: nil, + # 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. + extension_status: nil, + # Unique fileId. Store this fileld in your database, as this will be used to + # perform update action on this file. + file_id: nil, + # The relative path of the file in the media library e.g. + # `/marketing-assets/new-banner.jpg`. + file_path: nil, + # Type of the uploaded file. Possible values are `image`, `non-image`. + file_type: nil, + # Height of the image in pixels (Only for images) + height: nil, + # 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. + is_private_file: nil, + # 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. + is_published: nil, + # Legacy metadata. Send `metadata` in `responseFields` in API request to get + # metadata in the upload API response. + metadata: nil, + # Name of the asset. + name: nil, + # 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. + selected_fields_schema: nil, + # Size of the image file in Bytes. + size: nil, + # 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. + tags: nil, + # In the case of an image, a small thumbnail URL. + thumbnail_url: nil, + # A publicly accessible URL of the file. + url: nil, + # An object containing the file or file version's `id` (versionId) and `name`. + version_info: nil, + # The video codec used in the video (only for video). + video_codec: nil, + # Width of the image in pixels (Only for Images) + width: nil + ) + end + + sig do + override.returns( + { + ai_tags: + T.nilable( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::AITag + ] + ), + audio_codec: String, + bit_rate: Integer, + custom_coordinates: T.nilable(String), + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + duration: Integer, + embedded_metadata: T::Hash[Symbol, T.anything], + extension_status: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: T::Boolean, + is_published: T::Boolean, + metadata: Imagekitio::Metadata, + name: String, + selected_fields_schema: + T::Hash[ + Symbol, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema + ], + size: Float, + tags: T.nilable(T::Array[String]), + thumbnail_url: String, + url: String, + version_info: + Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo, + video_codec: String, + width: Float + } + ) + end + def to_hash + end + + class AITag < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformSuccessEvent::Data::AITag, + Imagekitio::Internal::AnyHash + ) + end + + # Confidence score of the tag. + sig { returns(T.nilable(Float)) } + attr_reader :confidence + + sig { params(confidence: Float).void } + attr_writer :confidence + + # Name of the tag. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + sig { returns(T.nilable(String)) } + attr_reader :source + + sig { params(source: String).void } + attr_writer :source + + sig do + params(confidence: Float, name: String, source: String).returns( + T.attached_class + ) + end + def self.new( + # Confidence score of the tag. + confidence: nil, + # Name of the tag. + name: nil, + # Array of `AITags` associated with the image. If no `AITags` are set, it will be + # null. These tags can be added using the `google-auto-tagging` or + # `aws-auto-tagging` extensions. + source: nil + ) + end + + sig do + override.returns( + { confidence: Float, name: String, source: String } + ) + end + def to_hash + end + end + + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + Imagekitio::Internal::AnyHash + ) + end + + sig do + returns( + T.nilable( + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + ) + end + attr_reader :ai_auto_description + + sig do + params( + ai_auto_description: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::OrSymbol + ).void + end + attr_writer :ai_auto_description + + sig do + returns( + T.nilable( + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :aws_auto_tagging + + sig do + params( + aws_auto_tagging: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::OrSymbol + ).void + end + attr_writer :aws_auto_tagging + + sig do + returns( + T.nilable( + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + ) + end + attr_reader :google_auto_tagging + + sig do + params( + google_auto_tagging: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::OrSymbol + ).void + end + attr_writer :google_auto_tagging + + sig do + returns( + T.nilable( + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ) + ) + end + attr_reader :remove_bg + + sig do + params( + remove_bg: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::OrSymbol + ).void + end + attr_writer :remove_bg + + # 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. + sig do + params( + ai_auto_description: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::OrSymbol, + aws_auto_tagging: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::OrSymbol, + google_auto_tagging: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::OrSymbol, + remove_bg: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::OrSymbol + ).returns(T.attached_class) + end + def self.new( + ai_auto_description: nil, + aws_auto_tagging: nil, + google_auto_tagging: nil, + remove_bg: nil + ) + end + + sig do + override.returns( + { + ai_auto_description: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol, + aws_auto_tagging: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol, + google_auto_tagging: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol, + remove_bg: + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + } + ) + end + def to_hash + end + + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AIAutoDescription::TaggedSymbol + ] + ) + end + def self.values + end + end + + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::AwsAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::GoogleAutoTagging::TaggedSymbol + ] + ) + end + def self.values + end + end + + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + SUCCESS = + T.let( + :success, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ) + PENDING = + T.let( + :pending, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ) + FAILED = + T.let( + :failed, + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus::RemoveBg::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema, + Imagekitio::Internal::AnyHash + ) + end + + # Type of the custom metadata field. + sig do + returns( + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol + ) + end + attr_accessor :type + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + sig do + returns( + T.nilable( + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::Variants + ) + ) + end + attr_reader :default_value + + sig do + params( + default_value: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::Variants + ).void + end + attr_writer :default_value + + # Specifies if the custom metadata field is required or not. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :is_value_required + + sig { params(is_value_required: T::Boolean).void } + attr_writer :is_value_required + + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :max_length + + sig { params(max_length: Float).void } + attr_writer :max_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MaxValue::Variants + ) + ) + end + attr_reader :max_value + + sig do + params( + max_value: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MaxValue::Variants + ).void + end + attr_writer :max_value + + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + sig { returns(T.nilable(Float)) } + attr_reader :min_length + + sig { params(min_length: Float).void } + attr_writer :min_length + + # 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. + sig do + returns( + T.nilable( + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MinValue::Variants + ) + ) + end + attr_reader :min_value + + sig do + params( + min_value: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MinValue::Variants + ).void + end + attr_writer :min_value + + # 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. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :read_only + + sig { params(read_only: T::Boolean).void } + attr_writer :read_only + + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + sig do + returns( + T.nilable( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::SelectOption::Variants + ] + ) + ) + end + attr_reader :select_options + + sig do + params( + select_options: + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::SelectOption::Variants + ] + ).void + end + attr_writer :select_options + + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :select_options_truncated + + sig { params(select_options_truncated: T::Boolean).void } + attr_writer :select_options_truncated + + sig do + params( + type: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::OrSymbol, + default_value: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MinValue::Variants, + read_only: T::Boolean, + select_options: + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::SelectOption::Variants + ], + select_options_truncated: T::Boolean + ).returns(T.attached_class) + end + def self.new( + # Type of the custom metadata field. + type:, + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + default_value: nil, + # Specifies if the custom metadata field is required or not. + is_value_required: nil, + # Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + max_length: nil, + # 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. + max_value: nil, + # Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + min_length: nil, + # 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. + min_value: nil, + # 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. + read_only: nil, + # An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + select_options: nil, + # Specifies if the selectOptions array is truncated. It is truncated when number + # of options are > 100. + select_options_truncated: nil + ) + end + + sig do + override.returns( + { + type: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol, + default_value: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::Variants, + is_value_required: T::Boolean, + max_length: Float, + max_value: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MaxValue::Variants, + min_length: Float, + min_value: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MinValue::Variants, + read_only: T::Boolean, + select_options: + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::SelectOption::Variants + ], + select_options_truncated: T::Boolean + } + ) + end + def to_hash + end + + # Type of the custom metadata field. + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + TEXT = + T.let( + :Text, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol + ) + TEXTAREA = + T.let( + :Textarea, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol + ) + NUMBER = + T.let( + :Number, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol + ) + DATE = + T.let( + :Date, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol + ) + BOOLEAN = + T.let( + :Boolean, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol + ) + SINGLE_SELECT = + T.let( + :SingleSelect, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol + ) + MULTI_SELECT = + T.let( + :MultiSelect, + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + # The default value for this custom metadata field. The value should match the + # `type` of custom metadata field. + module DefaultValue + extend Imagekitio::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + String, + Float, + T::Boolean, + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::Mixed::Variants + ] + ) + end + + module Mixed + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::Mixed::Variants + ] + ) + end + def self.variants + end + end + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::Variants + ] + ) + end + def self.variants + end + + MixedArray = + T.let( + Imagekitio::Internal::Type::ArrayOf[ + union: + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::Mixed + ], + Imagekitio::Internal::Type::Converter + ) + end + + # 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. + module MaxValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MaxValue::Variants + ] + ) + end + def self.variants + end + end + + # 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. + module MinValue + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float) } + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::MinValue::Variants + ] + ) + end + def self.variants + end + end + + module SelectOption + extend Imagekitio::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Float, T::Boolean) } + + sig do + override.returns( + T::Array[ + Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::SelectOption::Variants + ] + ) + end + def self.variants + end + end + end + + class VersionInfo < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo, + Imagekitio::Internal::AnyHash + ) + end + + # Unique identifier of the file version. + sig { returns(T.nilable(String)) } + attr_reader :id + + sig { params(id: String).void } + attr_writer :id + + # Name of the file version. + sig { returns(T.nilable(String)) } + attr_reader :name + + sig { params(name: String).void } + attr_writer :name + + # An object containing the file or file version's `id` (versionId) and `name`. + sig { params(id: String, name: String).returns(T.attached_class) } + def self.new( + # Unique identifier of the file version. + id: nil, + # Name of the file version. + name: nil + ) + end + + sig { override.returns({ id: String, name: String }) } + def to_hash + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::UploadPreTransformSuccessEvent::Request, + Imagekitio::Internal::AnyHash + ) + end + + # The requested pre-transformation string. + sig { returns(String) } + attr_accessor :transformation + + # Unique identifier for the originating request. + sig { returns(String) } + attr_accessor :x_request_id + + sig do + params(transformation: String, x_request_id: String).returns( + T.attached_class + ) + end + def self.new( + # The requested pre-transformation string. + transformation:, + # Unique identifier for the originating request. + x_request_id: + ) + end + + sig do + override.returns({ transformation: String, x_request_id: String }) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/video_overlay.rbi b/rbi/imagekitio/models/video_overlay.rbi new file mode 100644 index 00000000..14469c27 --- /dev/null +++ b/rbi/imagekitio/models/video_overlay.rbi @@ -0,0 +1,105 @@ +# typed: strong + +module Imagekitio + module Models + class VideoOverlay < Imagekitio::Models::BaseOverlay + OrHash = + T.type_alias do + T.any(Imagekitio::VideoOverlay, Imagekitio::Internal::AnyHash) + end + + # Specifies the relative path to the video used as an overlay. + sig { returns(String) } + attr_accessor :input + + sig { returns(Symbol) } + attr_accessor :type + + # 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`. + sig { returns(T.nilable(Imagekitio::VideoOverlay::Encoding::OrSymbol)) } + attr_reader :encoding + + sig do + params(encoding: Imagekitio::VideoOverlay::Encoding::OrSymbol).void + end + attr_writer :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). + sig { returns(T.nilable(T::Array[Imagekitio::Transformation])) } + attr_reader :transformation + + sig { params(transformation: T::Array[Imagekitio::Transformation]).void } + attr_writer :transformation + + sig do + params( + input: String, + encoding: Imagekitio::VideoOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekitio::Transformation], + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Specifies the relative path to the video used as an overlay. + 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`. + encoding: nil, + # 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). + transformation: nil, + type: :video + ) + end + + sig do + override.returns( + { + input: String, + type: Symbol, + encoding: Imagekitio::VideoOverlay::Encoding::OrSymbol, + transformation: T::Array[Imagekitio::Transformation] + } + ) + end + def to_hash + end + + # 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`. + module Encoding + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias { T.all(Symbol, Imagekitio::VideoOverlay::Encoding) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AUTO = T.let(:auto, Imagekitio::VideoOverlay::Encoding::TaggedSymbol) + PLAIN = T.let(:plain, Imagekitio::VideoOverlay::Encoding::TaggedSymbol) + BASE64 = + T.let(:base64, Imagekitio::VideoOverlay::Encoding::TaggedSymbol) + + sig do + override.returns( + T::Array[Imagekitio::VideoOverlay::Encoding::TaggedSymbol] + ) + end + def self.values + end + end + end + end +end diff --git a/rbi/imagekitio/models/video_transformation_accepted_event.rbi b/rbi/imagekitio/models/video_transformation_accepted_event.rbi new file mode 100644 index 00000000..5a5e3bda --- /dev/null +++ b/rbi/imagekitio/models/video_transformation_accepted_event.rbi @@ -0,0 +1,659 @@ +# typed: strong + +module Imagekitio + module Models + class VideoTransformationAcceptedEvent < Imagekitio::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationAcceptedEvent, + Imagekitio::Internal::AnyHash + ) + end + + # Timestamp when the event was created in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekitio::VideoTransformationAcceptedEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekitio::VideoTransformationAcceptedEvent::Data::OrHash + ).void + end + attr_writer :data + + # Information about the original request that triggered the video transformation. + sig { returns(Imagekitio::VideoTransformationAcceptedEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekitio::VideoTransformationAcceptedEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when a new video transformation request is accepted for processing. + # This event confirms that ImageKit has received and queued your transformation + # request. Use this for debugging and tracking transformation lifecycle. + sig do + params( + created_at: Time, + data: Imagekitio::VideoTransformationAcceptedEvent::Data::OrHash, + request: + Imagekitio::VideoTransformationAcceptedEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp when the event was created in ISO8601 format. + created_at:, + data:, + # Information about the original request that triggered the video transformation. + request:, + type: :"video.transformation.accepted" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekitio::VideoTransformationAcceptedEvent::Data, + request: Imagekitio::VideoTransformationAcceptedEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationAcceptedEvent::Data, + Imagekitio::Internal::AnyHash + ) + end + + # Information about the source video asset being transformed. + sig do + returns(Imagekitio::VideoTransformationAcceptedEvent::Data::Asset) + end + attr_reader :asset + + sig do + params( + asset: + Imagekitio::VideoTransformationAcceptedEvent::Data::Asset::OrHash + ).void + end + attr_writer :asset + + # Base information about a video transformation request. + sig do + returns( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + sig do + params( + asset: + Imagekitio::VideoTransformationAcceptedEvent::Data::Asset::OrHash, + transformation: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::OrHash + ).returns(T.attached_class) + end + def self.new( + # Information about the source video asset being transformed. + asset:, + # Base information about a video transformation request. + transformation: + ) + end + + sig do + override.returns( + { + asset: Imagekitio::VideoTransformationAcceptedEvent::Data::Asset, + transformation: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation + } + ) + end + def to_hash + end + + class Asset < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationAcceptedEvent::Data::Asset, + Imagekitio::Internal::AnyHash + ) + end + + # URL to download or access the source video file. + sig { returns(String) } + attr_accessor :url + + # Information about the source video asset being transformed. + sig { params(url: String).returns(T.attached_class) } + def self.new( + # URL to download or access the source video file. + url: + ) + end + + sig { override.returns({ url: String }) } + def to_hash + end + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + # 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 + sig do + returns( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Configuration options for video transformations. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options + ) + ) + end + attr_reader :options + + sig do + params( + options: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::OrHash + ).void + end + attr_writer :options + + # Base information about a video transformation request. + sig do + params( + type: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Type::OrSymbol, + options: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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 + type:, + # Configuration options for video transformations. + options: nil + ) + end + + sig do + override.returns( + { + type: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol, + options: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options + } + ) + end + def to_hash + end + + # 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 + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIDEO_TRANSFORMATION = + T.let( + :"video-transformation", + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ) + VIDEO_THUMBNAIL = + T.let( + :"video-thumbnail", + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + class Options < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options, + Imagekitio::Internal::AnyHash + ) + end + + # Audio codec used for encoding (aac or opus). + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + ) + end + attr_reader :audio_codec + + sig do + params( + audio_codec: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::OrSymbol + ).void + end + attr_writer :audio_codec + + # Whether to automatically rotate the video based on metadata. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :auto_rotate + + sig { params(auto_rotate: T::Boolean).void } + attr_writer :auto_rotate + + # Output format for the transformed video or thumbnail. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::OrSymbol + ).void + end + attr_writer :format_ + + # Quality setting for the output video. + sig { returns(T.nilable(Integer)) } + attr_reader :quality + + sig { params(quality: Integer).void } + attr_writer :quality + + # Streaming protocol for adaptive bitrate streaming. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + ) + end + attr_reader :stream_protocol + + sig do + params( + stream_protocol: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::OrSymbol + ).void + end + attr_writer :stream_protocol + + # Array of quality representations for adaptive bitrate streaming. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :variants + + sig { params(variants: T::Array[String]).void } + attr_writer :variants + + # Video codec used for encoding (h264, vp9, or av1). + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + ) + end + attr_reader :video_codec + + sig do + params( + video_codec: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).void + end + attr_writer :video_codec + + # Configuration options for video transformations. + sig do + params( + audio_codec: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::OrSymbol, + auto_rotate: T::Boolean, + format_: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::OrSymbol, + quality: Integer, + stream_protocol: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::OrSymbol, + variants: T::Array[String], + video_codec: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Audio codec used for encoding (aac or opus). + audio_codec: nil, + # Whether to automatically rotate the video based on metadata. + auto_rotate: nil, + # Output format for the transformed video or thumbnail. + format_: nil, + # Quality setting for the output video. + quality: nil, + # Streaming protocol for adaptive bitrate streaming. + stream_protocol: nil, + # Array of quality representations for adaptive bitrate streaming. + variants: nil, + # Video codec used for encoding (h264, vp9, or av1). + video_codec: nil + ) + end + + sig do + override.returns( + { + audio_codec: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol, + auto_rotate: T::Boolean, + format_: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol, + quality: Integer, + stream_protocol: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol, + variants: T::Array[String], + video_codec: + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + } + ) + end + def to_hash + end + + # Audio codec used for encoding (aac or opus). + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AAC = + T.let( + :aac, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + OPUS = + T.let( + :opus, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Output format for the transformed video or thumbnail. + module Format + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + MP4 = + T.let( + :mp4, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBM = + T.let( + :webm, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + JPG = + T.let( + :jpg, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + PNG = + T.let( + :png, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBP = + T.let( + :webp, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::Format::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Streaming protocol for adaptive bitrate streaming. + module StreamProtocol + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :HLS, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + DASH = + T.let( + :DASH, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Video codec used for encoding (h264, vp9, or av1). + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H264 = + T.let( + :h264, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + VP9 = + T.let( + :vp9, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + AV1 = + T.let( + :av1, + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationAcceptedEvent::Request, + Imagekitio::Internal::AnyHash + ) + end + + # Full URL of the transformation request that was submitted. + sig { returns(String) } + attr_accessor :url + + # Unique identifier for the originating transformation request. + sig { returns(String) } + attr_accessor :x_request_id + + # User-Agent header from the original request that triggered the transformation. + sig { returns(T.nilable(String)) } + attr_reader :user_agent + + sig { params(user_agent: String).void } + attr_writer :user_agent + + # Information about the original request that triggered the video transformation. + sig do + params(url: String, x_request_id: String, user_agent: String).returns( + T.attached_class + ) + end + def self.new( + # Full URL of the transformation request that was submitted. + url:, + # Unique identifier for the originating transformation request. + x_request_id:, + # User-Agent header from the original request that triggered the transformation. + user_agent: nil + ) + end + + sig do + override.returns( + { url: String, x_request_id: String, user_agent: String } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/video_transformation_error_event.rbi b/rbi/imagekitio/models/video_transformation_error_event.rbi new file mode 100644 index 00000000..19e88513 --- /dev/null +++ b/rbi/imagekitio/models/video_transformation_error_event.rbi @@ -0,0 +1,772 @@ +# typed: strong + +module Imagekitio + module Models + class VideoTransformationErrorEvent < Imagekitio::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationErrorEvent, + Imagekitio::Internal::AnyHash + ) + end + + # Timestamp when the event was created in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekitio::VideoTransformationErrorEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekitio::VideoTransformationErrorEvent::Data::OrHash + ).void + end + attr_writer :data + + # Information about the original request that triggered the video transformation. + sig { returns(Imagekitio::VideoTransformationErrorEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekitio::VideoTransformationErrorEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Triggered when an error occurs during video encoding. Listen to this webhook to + # log error reasons and debug issues. Check your origin and URL endpoint settings + # if the reason is related to download failure. For other errors, contact ImageKit + # support. + sig do + params( + created_at: Time, + data: Imagekitio::VideoTransformationErrorEvent::Data::OrHash, + request: Imagekitio::VideoTransformationErrorEvent::Request::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp when the event was created in ISO8601 format. + created_at:, + data:, + # Information about the original request that triggered the video transformation. + request:, + type: :"video.transformation.error" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekitio::VideoTransformationErrorEvent::Data, + request: Imagekitio::VideoTransformationErrorEvent::Request, + type: Symbol + } + ) + end + def to_hash + end + + class Data < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationErrorEvent::Data, + Imagekitio::Internal::AnyHash + ) + end + + # Information about the source video asset being transformed. + sig { returns(Imagekitio::VideoTransformationErrorEvent::Data::Asset) } + attr_reader :asset + + sig do + params( + asset: + Imagekitio::VideoTransformationErrorEvent::Data::Asset::OrHash + ).void + end + attr_writer :asset + + sig do + returns( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + sig do + params( + asset: + Imagekitio::VideoTransformationErrorEvent::Data::Asset::OrHash, + transformation: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::OrHash + ).returns(T.attached_class) + end + def self.new( + # Information about the source video asset being transformed. + asset:, + transformation: + ) + end + + sig do + override.returns( + { + asset: Imagekitio::VideoTransformationErrorEvent::Data::Asset, + transformation: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation + } + ) + end + def to_hash + end + + class Asset < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationErrorEvent::Data::Asset, + Imagekitio::Internal::AnyHash + ) + end + + # URL to download or access the source video file. + sig { returns(String) } + attr_accessor :url + + # Information about the source video asset being transformed. + sig { params(url: String).returns(T.attached_class) } + def self.new( + # URL to download or access the source video file. + url: + ) + end + + sig { override.returns({ url: String }) } + def to_hash + end + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + # 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 + sig do + returns( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Details about the transformation error. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error + ) + ) + end + attr_reader :error + + sig do + params( + error: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::OrHash + ).void + end + attr_writer :error + + # Configuration options for video transformations. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options + ) + ) + end + attr_reader :options + + sig do + params( + options: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::OrHash + ).void + end + attr_writer :options + + sig do + params( + type: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Type::OrSymbol, + error: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::OrHash, + options: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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 + type:, + # Details about the transformation error. + error: nil, + # Configuration options for video transformations. + options: nil + ) + end + + sig do + override.returns( + { + type: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol, + error: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error, + options: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options + } + ) + end + def to_hash + end + + # 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 + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIDEO_TRANSFORMATION = + T.let( + :"video-transformation", + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ) + VIDEO_THUMBNAIL = + T.let( + :"video-thumbnail", + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + class Error < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error, + Imagekitio::Internal::AnyHash + ) + end + + # 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 + sig do + returns( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ) + end + attr_accessor :reason + + # Details about the transformation error. + sig do + params( + reason: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # 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 + reason: + ) + end + + sig do + override.returns( + { + reason: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + } + ) + end + def to_hash + end + + # 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 + module Reason + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::Reason + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + ENCODING_FAILED = + T.let( + :encoding_failed, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ) + DOWNLOAD_FAILED = + T.let( + :download_failed, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ) + INTERNAL_SERVER_ERROR = + T.let( + :internal_server_error, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error::Reason::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class Options < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options, + Imagekitio::Internal::AnyHash + ) + end + + # Audio codec used for encoding (aac or opus). + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + ) + end + attr_reader :audio_codec + + sig do + params( + audio_codec: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::OrSymbol + ).void + end + attr_writer :audio_codec + + # Whether to automatically rotate the video based on metadata. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :auto_rotate + + sig { params(auto_rotate: T::Boolean).void } + attr_writer :auto_rotate + + # Output format for the transformed video or thumbnail. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::OrSymbol + ).void + end + attr_writer :format_ + + # Quality setting for the output video. + sig { returns(T.nilable(Integer)) } + attr_reader :quality + + sig { params(quality: Integer).void } + attr_writer :quality + + # Streaming protocol for adaptive bitrate streaming. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + ) + end + attr_reader :stream_protocol + + sig do + params( + stream_protocol: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::OrSymbol + ).void + end + attr_writer :stream_protocol + + # Array of quality representations for adaptive bitrate streaming. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :variants + + sig { params(variants: T::Array[String]).void } + attr_writer :variants + + # Video codec used for encoding (h264, vp9, or av1). + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + ) + end + attr_reader :video_codec + + sig do + params( + video_codec: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).void + end + attr_writer :video_codec + + # Configuration options for video transformations. + sig do + params( + audio_codec: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::OrSymbol, + auto_rotate: T::Boolean, + format_: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::OrSymbol, + quality: Integer, + stream_protocol: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::OrSymbol, + variants: T::Array[String], + video_codec: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Audio codec used for encoding (aac or opus). + audio_codec: nil, + # Whether to automatically rotate the video based on metadata. + auto_rotate: nil, + # Output format for the transformed video or thumbnail. + format_: nil, + # Quality setting for the output video. + quality: nil, + # Streaming protocol for adaptive bitrate streaming. + stream_protocol: nil, + # Array of quality representations for adaptive bitrate streaming. + variants: nil, + # Video codec used for encoding (h264, vp9, or av1). + video_codec: nil + ) + end + + sig do + override.returns( + { + audio_codec: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol, + auto_rotate: T::Boolean, + format_: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol, + quality: Integer, + stream_protocol: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol, + variants: T::Array[String], + video_codec: + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + } + ) + end + def to_hash + end + + # Audio codec used for encoding (aac or opus). + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AAC = + T.let( + :aac, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + OPUS = + T.let( + :opus, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Output format for the transformed video or thumbnail. + module Format + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + MP4 = + T.let( + :mp4, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBM = + T.let( + :webm, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + JPG = + T.let( + :jpg, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + PNG = + T.let( + :png, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBP = + T.let( + :webp, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::Format::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Streaming protocol for adaptive bitrate streaming. + module StreamProtocol + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :HLS, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + DASH = + T.let( + :DASH, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Video codec used for encoding (h264, vp9, or av1). + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H264 = + T.let( + :h264, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + VP9 = + T.let( + :vp9, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + AV1 = + T.let( + :av1, + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationErrorEvent::Request, + Imagekitio::Internal::AnyHash + ) + end + + # Full URL of the transformation request that was submitted. + sig { returns(String) } + attr_accessor :url + + # Unique identifier for the originating transformation request. + sig { returns(String) } + attr_accessor :x_request_id + + # User-Agent header from the original request that triggered the transformation. + sig { returns(T.nilable(String)) } + attr_reader :user_agent + + sig { params(user_agent: String).void } + attr_writer :user_agent + + # Information about the original request that triggered the video transformation. + sig do + params(url: String, x_request_id: String, user_agent: String).returns( + T.attached_class + ) + end + def self.new( + # Full URL of the transformation request that was submitted. + url:, + # Unique identifier for the originating transformation request. + x_request_id:, + # User-Agent header from the original request that triggered the transformation. + user_agent: nil + ) + end + + sig do + override.returns( + { url: String, x_request_id: String, user_agent: String } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/video_transformation_ready_event.rbi b/rbi/imagekitio/models/video_transformation_ready_event.rbi new file mode 100644 index 00000000..74927f9e --- /dev/null +++ b/rbi/imagekitio/models/video_transformation_ready_event.rbi @@ -0,0 +1,864 @@ +# typed: strong + +module Imagekitio + module Models + class VideoTransformationReadyEvent < Imagekitio::Models::BaseWebhookEvent + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationReadyEvent, + Imagekitio::Internal::AnyHash + ) + end + + # Timestamp when the event was created in ISO8601 format. + sig { returns(Time) } + attr_accessor :created_at + + sig { returns(Imagekitio::VideoTransformationReadyEvent::Data) } + attr_reader :data + + sig do + params( + data: Imagekitio::VideoTransformationReadyEvent::Data::OrHash + ).void + end + attr_writer :data + + # Information about the original request that triggered the video transformation. + sig { returns(Imagekitio::VideoTransformationReadyEvent::Request) } + attr_reader :request + + sig do + params( + request: Imagekitio::VideoTransformationReadyEvent::Request::OrHash + ).void + end + attr_writer :request + + sig { returns(Symbol) } + attr_accessor :type + + # Performance metrics for the transformation process. + sig do + returns(T.nilable(Imagekitio::VideoTransformationReadyEvent::Timings)) + end + attr_reader :timings + + sig do + params( + timings: Imagekitio::VideoTransformationReadyEvent::Timings::OrHash + ).void + end + attr_writer :timings + + # Triggered when video encoding is finished and the transformed resource is ready + # to be served. This is the key event to listen for - update your database or CMS + # flags when you receive this so your application can start showing the + # transformed video to users. + sig do + params( + created_at: Time, + data: Imagekitio::VideoTransformationReadyEvent::Data::OrHash, + request: Imagekitio::VideoTransformationReadyEvent::Request::OrHash, + timings: Imagekitio::VideoTransformationReadyEvent::Timings::OrHash, + type: Symbol + ).returns(T.attached_class) + end + def self.new( + # Timestamp when the event was created in ISO8601 format. + created_at:, + data:, + # Information about the original request that triggered the video transformation. + request:, + # Performance metrics for the transformation process. + timings: nil, + type: :"video.transformation.ready" + ) + end + + sig do + override.returns( + { + created_at: Time, + data: Imagekitio::VideoTransformationReadyEvent::Data, + request: Imagekitio::VideoTransformationReadyEvent::Request, + type: Symbol, + timings: Imagekitio::VideoTransformationReadyEvent::Timings + } + ) + end + def to_hash + end + + class Data < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationReadyEvent::Data, + Imagekitio::Internal::AnyHash + ) + end + + # Information about the source video asset being transformed. + sig { returns(Imagekitio::VideoTransformationReadyEvent::Data::Asset) } + attr_reader :asset + + sig do + params( + asset: + Imagekitio::VideoTransformationReadyEvent::Data::Asset::OrHash + ).void + end + attr_writer :asset + + sig do + returns( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation + ) + end + attr_reader :transformation + + sig do + params( + transformation: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::OrHash + ).void + end + attr_writer :transformation + + sig do + params( + asset: + Imagekitio::VideoTransformationReadyEvent::Data::Asset::OrHash, + transformation: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::OrHash + ).returns(T.attached_class) + end + def self.new( + # Information about the source video asset being transformed. + asset:, + transformation: + ) + end + + sig do + override.returns( + { + asset: Imagekitio::VideoTransformationReadyEvent::Data::Asset, + transformation: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation + } + ) + end + def to_hash + end + + class Asset < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationReadyEvent::Data::Asset, + Imagekitio::Internal::AnyHash + ) + end + + # URL to download or access the source video file. + sig { returns(String) } + attr_accessor :url + + # Information about the source video asset being transformed. + sig { params(url: String).returns(T.attached_class) } + def self.new( + # URL to download or access the source video file. + url: + ) + end + + sig { override.returns({ url: String }) } + def to_hash + end + end + + class Transformation < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation, + Imagekitio::Internal::AnyHash + ) + end + + # 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 + sig do + returns( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ) + end + attr_accessor :type + + # Configuration options for video transformations. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options + ) + ) + end + attr_reader :options + + sig do + params( + options: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::OrHash + ).void + end + attr_writer :options + + # Information about the transformed output video. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output + ) + ) + end + attr_reader :output + + sig do + params( + output: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::OrHash + ).void + end + attr_writer :output + + sig do + params( + type: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Type::OrSymbol, + options: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::OrHash, + output: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::OrHash + ).returns(T.attached_class) + end + def self.new( + # 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 + type:, + # Configuration options for video transformations. + options: nil, + # Information about the transformed output video. + output: nil + ) + end + + sig do + override.returns( + { + type: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol, + options: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options, + output: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output + } + ) + end + def to_hash + end + + # 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 + module Type + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Type + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + VIDEO_TRANSFORMATION = + T.let( + :"video-transformation", + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ) + GIF_TO_VIDEO = + T.let( + :"gif-to-video", + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ) + VIDEO_THUMBNAIL = + T.let( + :"video-thumbnail", + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Type::TaggedSymbol + ] + ) + end + def self.values + end + end + + class Options < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options, + Imagekitio::Internal::AnyHash + ) + end + + # Audio codec used for encoding (aac or opus). + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + ) + end + attr_reader :audio_codec + + sig do + params( + audio_codec: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::OrSymbol + ).void + end + attr_writer :audio_codec + + # Whether to automatically rotate the video based on metadata. + sig { returns(T.nilable(T::Boolean)) } + attr_reader :auto_rotate + + sig { params(auto_rotate: T::Boolean).void } + attr_writer :auto_rotate + + # Output format for the transformed video or thumbnail. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + ) + end + attr_reader :format_ + + sig do + params( + format_: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::OrSymbol + ).void + end + attr_writer :format_ + + # Quality setting for the output video. + sig { returns(T.nilable(Integer)) } + attr_reader :quality + + sig { params(quality: Integer).void } + attr_writer :quality + + # Streaming protocol for adaptive bitrate streaming. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + ) + end + attr_reader :stream_protocol + + sig do + params( + stream_protocol: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::OrSymbol + ).void + end + attr_writer :stream_protocol + + # Array of quality representations for adaptive bitrate streaming. + sig { returns(T.nilable(T::Array[String])) } + attr_reader :variants + + sig { params(variants: T::Array[String]).void } + attr_writer :variants + + # Video codec used for encoding (h264, vp9, or av1). + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + ) + end + attr_reader :video_codec + + sig do + params( + video_codec: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).void + end + attr_writer :video_codec + + # Configuration options for video transformations. + sig do + params( + audio_codec: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::OrSymbol, + auto_rotate: T::Boolean, + format_: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::OrSymbol, + quality: Integer, + stream_protocol: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::OrSymbol, + variants: T::Array[String], + video_codec: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::OrSymbol + ).returns(T.attached_class) + end + def self.new( + # Audio codec used for encoding (aac or opus). + audio_codec: nil, + # Whether to automatically rotate the video based on metadata. + auto_rotate: nil, + # Output format for the transformed video or thumbnail. + format_: nil, + # Quality setting for the output video. + quality: nil, + # Streaming protocol for adaptive bitrate streaming. + stream_protocol: nil, + # Array of quality representations for adaptive bitrate streaming. + variants: nil, + # Video codec used for encoding (h264, vp9, or av1). + video_codec: nil + ) + end + + sig do + override.returns( + { + audio_codec: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol, + auto_rotate: T::Boolean, + format_: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol, + quality: Integer, + stream_protocol: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol, + variants: T::Array[String], + video_codec: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + } + ) + end + def to_hash + end + + # Audio codec used for encoding (aac or opus). + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + AAC = + T.let( + :aac, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + OPUS = + T.let( + :opus, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::AudioCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Output format for the transformed video or thumbnail. + module Format + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + MP4 = + T.let( + :mp4, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBM = + T.let( + :webm, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + JPG = + T.let( + :jpg, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + PNG = + T.let( + :png, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + WEBP = + T.let( + :webp, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::Format::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Streaming protocol for adaptive bitrate streaming. + module StreamProtocol + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + HLS = + T.let( + :HLS, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + DASH = + T.let( + :DASH, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::StreamProtocol::TaggedSymbol + ] + ) + end + def self.values + end + end + + # Video codec used for encoding (h264, vp9, or av1). + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + H264 = + T.let( + :h264, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + VP9 = + T.let( + :vp9, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + AV1 = + T.let( + :av1, + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options::VideoCodec::TaggedSymbol + ] + ) + end + def self.values + end + end + end + + class Output < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output, + Imagekitio::Internal::AnyHash + ) + end + + # URL to access the transformed video. + sig { returns(String) } + attr_accessor :url + + # Metadata of the output video file. + sig do + returns( + T.nilable( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + ) + ) + end + attr_reader :video_metadata + + sig do + params( + video_metadata: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata::OrHash + ).void + end + attr_writer :video_metadata + + # Information about the transformed output video. + sig do + params( + url: String, + video_metadata: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata::OrHash + ).returns(T.attached_class) + end + def self.new( + # URL to access the transformed video. + url:, + # Metadata of the output video file. + video_metadata: nil + ) + end + + sig do + override.returns( + { + url: String, + video_metadata: + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + } + ) + end + def to_hash + end + + class VideoMetadata < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata, + Imagekitio::Internal::AnyHash + ) + end + + # Bitrate of the output video in bits per second. + sig { returns(Integer) } + attr_accessor :bitrate + + # Duration of the output video in seconds. + sig { returns(Float) } + attr_accessor :duration + + # Height of the output video in pixels. + sig { returns(Integer) } + attr_accessor :height + + # Width of the output video in pixels. + sig { returns(Integer) } + attr_accessor :width + + # Metadata of the output video file. + sig do + params( + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + ).returns(T.attached_class) + end + def self.new( + # Bitrate of the output video in bits per second. + bitrate:, + # Duration of the output video in seconds. + duration:, + # Height of the output video in pixels. + height:, + # Width of the output video in pixels. + width: + ) + end + + sig do + override.returns( + { + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + } + ) + end + def to_hash + end + end + end + end + end + + class Request < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationReadyEvent::Request, + Imagekitio::Internal::AnyHash + ) + end + + # Full URL of the transformation request that was submitted. + sig { returns(String) } + attr_accessor :url + + # Unique identifier for the originating transformation request. + sig { returns(String) } + attr_accessor :x_request_id + + # User-Agent header from the original request that triggered the transformation. + sig { returns(T.nilable(String)) } + attr_reader :user_agent + + sig { params(user_agent: String).void } + attr_writer :user_agent + + # Information about the original request that triggered the video transformation. + sig do + params(url: String, x_request_id: String, user_agent: String).returns( + T.attached_class + ) + end + def self.new( + # Full URL of the transformation request that was submitted. + url:, + # Unique identifier for the originating transformation request. + x_request_id:, + # User-Agent header from the original request that triggered the transformation. + user_agent: nil + ) + end + + sig do + override.returns( + { url: String, x_request_id: String, user_agent: String } + ) + end + def to_hash + end + end + + class Timings < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any( + Imagekitio::VideoTransformationReadyEvent::Timings, + Imagekitio::Internal::AnyHash + ) + end + + # Time spent downloading the source video from your origin or media library, in + # milliseconds. + sig { returns(T.nilable(Integer)) } + attr_reader :download_duration + + sig { params(download_duration: Integer).void } + attr_writer :download_duration + + # Time spent encoding the video, in milliseconds. + sig { returns(T.nilable(Integer)) } + attr_reader :encoding_duration + + sig { params(encoding_duration: Integer).void } + attr_writer :encoding_duration + + # Performance metrics for the transformation process. + sig do + params( + download_duration: Integer, + encoding_duration: Integer + ).returns(T.attached_class) + end + def self.new( + # Time spent downloading the source video from your origin or media library, in + # milliseconds. + download_duration: nil, + # Time spent encoding the video, in milliseconds. + encoding_duration: nil + ) + end + + sig do + override.returns( + { download_duration: Integer, encoding_duration: Integer } + ) + end + def to_hash + end + end + end + end +end diff --git a/rbi/imagekitio/models/webhook_unsafe_unwrap_params.rbi b/rbi/imagekitio/models/webhook_unsafe_unwrap_params.rbi new file mode 100644 index 00000000..65b60535 --- /dev/null +++ b/rbi/imagekitio/models/webhook_unsafe_unwrap_params.rbi @@ -0,0 +1,30 @@ +# typed: strong + +module Imagekitio + module Models + class WebhookUnsafeUnwrapParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any( + Imagekitio::WebhookUnsafeUnwrapParams, + Imagekitio::Internal::AnyHash + ) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekitio::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/models/webhook_unwrap_params.rbi b/rbi/imagekitio/models/webhook_unwrap_params.rbi new file mode 100644 index 00000000..9cecafa8 --- /dev/null +++ b/rbi/imagekitio/models/webhook_unwrap_params.rbi @@ -0,0 +1,27 @@ +# typed: strong + +module Imagekitio + module Models + class WebhookUnwrapParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Imagekitio::WebhookUnwrapParams, Imagekitio::Internal::AnyHash) + end + + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T.attached_class + ) + end + def self.new(request_options: {}) + end + + sig { override.returns({ request_options: Imagekitio::RequestOptions }) } + def to_hash + end + end + end +end diff --git a/rbi/imagekitio/request_options.rbi b/rbi/imagekitio/request_options.rbi new file mode 100644 index 00000000..74a6791a --- /dev/null +++ b/rbi/imagekitio/request_options.rbi @@ -0,0 +1,59 @@ +# typed: strong + +module Imagekitio + # Specify HTTP behaviour to use for a specific request. These options supplement + # or override those provided at the client level. + # + # When making a request, you can pass an actual {RequestOptions} instance, or + # simply pass a Hash with symbol keys matching the attributes on this class. + class RequestOptions < Imagekitio::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Imagekitio::RequestOptions, Imagekitio::Internal::AnyHash) + end + + # @api private + sig { params(opts: Imagekitio::RequestOptions::OrHash).void } + def self.validate!(opts) + end + + # Idempotency key to send with request and all associated retries. Will only be + # sent for write requests. + sig { returns(T.nilable(String)) } + attr_accessor :idempotency_key + + # Extra query params to send with the request. These are `.merge`’d into any + # `query` given at the client level. + sig do + returns( + T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]) + ) + end + attr_accessor :extra_query + + # Extra headers to send with the request. These are `.merged`’d into any + # `extra_headers` given at the client level. + sig { returns(T.nilable(T::Hash[String, T.nilable(String)])) } + attr_accessor :extra_headers + + # Extra data to send with the request. These are deep merged into any data + # generated as part of the normal request. + sig { returns(T.nilable(T.anything)) } + attr_accessor :extra_body + + # Maximum number of retries to attempt after a failed initial request. + sig { returns(T.nilable(Integer)) } + attr_accessor :max_retries + + # Request timeout in seconds. + sig { returns(T.nilable(Float)) } + attr_accessor :timeout + + # Returns a new instance of RequestOptions. + sig do + params(values: Imagekitio::Internal::AnyHash).returns(T.attached_class) + end + def self.new(values = {}) + end + end +end diff --git a/rbi/imagekitio/resources/accounts.rbi b/rbi/imagekitio/resources/accounts.rbi new file mode 100644 index 00000000..19a20e7f --- /dev/null +++ b/rbi/imagekitio/resources/accounts.rbi @@ -0,0 +1,21 @@ +# typed: strong + +module Imagekitio + module Resources + class Accounts + sig { returns(Imagekitio::Resources::Accounts::Usage) } + attr_reader :usage + + sig { returns(Imagekitio::Resources::Accounts::Origins) } + attr_reader :origins + + sig { returns(Imagekitio::Resources::Accounts::URLEndpoints) } + attr_reader :url_endpoints + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekitio/resources/accounts/origins.rbi b/rbi/imagekitio/resources/accounts/origins.rbi new file mode 100644 index 00000000..869a5dc5 --- /dev/null +++ b/rbi/imagekitio/resources/accounts/origins.rbi @@ -0,0 +1,91 @@ +# typed: strong + +module Imagekitio + module Resources + class Accounts + class Origins + # **Note:** This API is currently in beta. + # Creates a new origin and returns the origin object. + sig do + params( + origin_request: Imagekitio::Accounts::OriginRequest, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Accounts::OriginResponse::Variants) + end + def create( + # Schema for origin request resources. + origin_request:, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Updates the origin identified by `id` and returns the updated origin object. + sig do + params( + id: String, + origin_request: Imagekitio::Accounts::OriginRequest, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Accounts::OriginResponse::Variants) + end + def update( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id, + # Schema for origin request resources. + origin_request:, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Returns an array of all configured origins for the current account. + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T::Array[Imagekitio::Accounts::OriginResponse::Variants] + ) + end + def list(request_options: {}) + end + + # **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. + sig do + params( + id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).void + end + def delete( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Retrieves the origin identified by `id`. + sig do + params( + id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Accounts::OriginResponse::Variants) + end + def get( + # Unique identifier for the origin. This is generated by ImageKit when you create + # a new origin. + id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekitio/resources/accounts/url_endpoints.rbi b/rbi/imagekitio/resources/accounts/url_endpoints.rbi new file mode 100644 index 00000000..4346dbc8 --- /dev/null +++ b/rbi/imagekitio/resources/accounts/url_endpoints.rbi @@ -0,0 +1,129 @@ +# typed: strong + +module Imagekitio + module Resources + class Accounts + class URLEndpoints + # **Note:** This API is currently in beta. + # Creates a new URL‑endpoint and returns the resulting object. + sig do + params( + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary::OrHash, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix::OrHash, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai::OrHash + ), + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Accounts::URLEndpointResponse) + end + def create( + # Description of the URL endpoint. + 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. + origins: nil, + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + url_prefix: nil, + # Configuration for third-party URL rewriting. + url_rewriter: nil, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Updates the URL‑endpoint identified by `id` and returns the updated object. + sig do + params( + id: String, + description: String, + origins: T::Array[String], + url_prefix: String, + url_rewriter: + T.any( + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary::OrHash, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix::OrHash, + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai::OrHash + ), + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Accounts::URLEndpointResponse) + end + def update( + # 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`. + id, + # Description of the URL endpoint. + 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. + origins: nil, + # Path segment appended to your base URL to form the endpoint (letters, digits, + # and hyphens only — or empty for the default endpoint). + url_prefix: nil, + # Configuration for third-party URL rewriting. + url_rewriter: nil, + request_options: {} + ) + end + + # **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. + sig do + params(request_options: Imagekitio::RequestOptions::OrHash).returns( + T::Array[Imagekitio::Accounts::URLEndpointResponse] + ) + end + def list(request_options: {}) + end + + # **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. + sig do + params( + id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).void + end + def delete( + # 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`. + id, + request_options: {} + ) + end + + # **Note:** This API is currently in beta. + # Retrieves the URL‑endpoint identified by `id`. + sig do + params( + id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Accounts::URLEndpointResponse) + end + def get( + # 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`. + id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekitio/resources/accounts/usage.rbi b/rbi/imagekitio/resources/accounts/usage.rbi new file mode 100644 index 00000000..83fb3b2d --- /dev/null +++ b/rbi/imagekitio/resources/accounts/usage.rbi @@ -0,0 +1,36 @@ +# typed: strong + +module Imagekitio + module Resources + class Accounts + class Usage + # 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. + sig do + params( + end_date: Date, + start_date: Date, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Accounts::UsageGetResponse) + end + def get( + # 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. + end_date:, + # 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. + start_date:, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekitio/resources/assets.rbi b/rbi/imagekitio/resources/assets.rbi new file mode 100644 index 00000000..14dda222 --- /dev/null +++ b/rbi/imagekitio/resources/assets.rbi @@ -0,0 +1,74 @@ +# typed: strong + +module Imagekitio + module Resources + class Assets + # 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`. + sig do + params( + file_type: Imagekitio::AssetListParams::FileType::OrSymbol, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekitio::AssetListParams::Sort::OrSymbol, + type: Imagekitio::AssetListParams::Type::OrSymbol, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T::Array[Imagekitio::Models::AssetListResponseItem::Variants]) + end + def list( + # 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) + file_type: nil, + # The maximum number of results to return in response. + limit: nil, + # 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. + path: nil, + # 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. + search_query: nil, + # The number of results to skip before returning results. + skip: nil, + # Sort the results by one of the supported fields in ascending or descending + # order. + sort: nil, + # 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`) + type: nil, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekitio/resources/beta.rbi b/rbi/imagekitio/resources/beta.rbi new file mode 100644 index 00000000..5500afd7 --- /dev/null +++ b/rbi/imagekitio/resources/beta.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module Imagekitio + module Resources + class Beta + sig { returns(Imagekitio::Resources::Beta::V2) } + attr_reader :v2 + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekitio/resources/beta/v2.rbi b/rbi/imagekitio/resources/beta/v2.rbi new file mode 100644 index 00000000..101abf70 --- /dev/null +++ b/rbi/imagekitio/resources/beta/v2.rbi @@ -0,0 +1,17 @@ +# typed: strong + +module Imagekitio + module Resources + class Beta + class V2 + sig { returns(Imagekitio::Resources::Beta::V2::Files) } + attr_reader :files + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekitio/resources/beta/v2/files.rbi b/rbi/imagekitio/resources/beta/v2/files.rbi new file mode 100644 index 00000000..3991c1e0 --- /dev/null +++ b/rbi/imagekitio/resources/beta/v2/files.rbi @@ -0,0 +1,193 @@ +# typed: strong + +module Imagekitio + module Resources + class Beta + class V2 + class Files + # 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 20MB for images, audio, and raw + # files, and 100MB for videos. On the paid plan, these limits increase to 40MB for + # images, audio, and raw files, and 2GB for videos. These limits can be further increased + # with higher-tier 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. + sig do + params( + file: Imagekitio::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg::OrHash, + Imagekitio::ExtensionItem::AIAutoDescription::OrHash, + Imagekitio::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + response_fields: + T::Array[ + Imagekitio::Beta::V2::FileUploadParams::ResponseField::OrSymbol + ], + tags: T::Array[String], + transformation: + Imagekitio::Beta::V2::FileUploadParams::Transformation::OrHash, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Beta::V2::FileUploadResponse) + end + def upload( + # 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. + file:, + # The name with which the file has to be uploaded. + file_name:, + # 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. + token: nil, + # 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). + checks: nil, + # 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. + custom_coordinates: nil, + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # 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. + folder: nil, + # 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. + is_private_file: nil, + # 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. + is_published: nil, + # 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. + overwrite_ai_tags: nil, + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + overwrite_custom_metadata: nil, + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + overwrite_file: nil, + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + overwrite_tags: nil, + # Array of response field keys to include in the API response body. + response_fields: nil, + # 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. + tags: nil, + # 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. + transformation: nil, + # 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. + use_unique_file_name: nil, + # 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. + webhook_url: nil, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end + end +end diff --git a/rbi/imagekitio/resources/cache.rbi b/rbi/imagekitio/resources/cache.rbi new file mode 100644 index 00000000..2f8a0364 --- /dev/null +++ b/rbi/imagekitio/resources/cache.rbi @@ -0,0 +1,15 @@ +# typed: strong + +module Imagekitio + module Resources + class Cache + sig { returns(Imagekitio::Resources::Cache::Invalidation) } + attr_reader :invalidation + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekitio/resources/cache/invalidation.rbi b/rbi/imagekitio/resources/cache/invalidation.rbi new file mode 100644 index 00000000..d3c6902c --- /dev/null +++ b/rbi/imagekitio/resources/cache/invalidation.rbi @@ -0,0 +1,44 @@ +# typed: strong + +module Imagekitio + module Resources + class Cache + class Invalidation + # 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. + sig do + params( + url: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Cache::InvalidationCreateResponse) + end + def create( + # The full URL of the file to be purged. + url:, + request_options: {} + ) + end + + # This API returns the status of a purge cache request. + sig do + params( + request_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Cache::InvalidationGetResponse) + end + def get( + # Should be a valid requestId. + request_id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekitio/resources/custom_metadata_fields.rbi b/rbi/imagekitio/resources/custom_metadata_fields.rbi new file mode 100644 index 00000000..c3f0a4cb --- /dev/null +++ b/rbi/imagekitio/resources/custom_metadata_fields.rbi @@ -0,0 +1,106 @@ +# typed: strong + +module Imagekitio + module Resources + class CustomMetadataFields + # 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. + sig do + params( + label: String, + name: String, + schema: Imagekitio::CustomMetadataFieldCreateParams::Schema::OrHash, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::CustomMetadataField) + end + def create( + # 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. + label:, + # API name of the custom metadata field. This should be unique across all + # (including deleted) custom metadata fields. + name:, + schema:, + request_options: {} + ) + end + + # This API updates the label or schema of an existing custom metadata field. + sig do + params( + id: String, + label: String, + schema: Imagekitio::CustomMetadataFieldUpdateParams::Schema::OrHash, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::CustomMetadataField) + end + def update( + # Should be a valid custom metadata field id. + id, + # 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. + label: nil, + # 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`. + schema: nil, + request_options: {} + ) + end + + # 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. + sig do + params( + folder_path: String, + include_deleted: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T::Array[Imagekitio::CustomMetadataField]) + end + def list( + # 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. + folder_path: nil, + # Set it to `true` to include deleted field objects in the API response. + include_deleted: nil, + request_options: {} + ) + end + + # 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. + sig do + params( + id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::CustomMetadataFieldDeleteResponse) + end + def delete( + # Should be a valid custom metadata field id. + id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekitio/resources/files.rbi b/rbi/imagekitio/resources/files.rbi new file mode 100644 index 00000000..d44448c3 --- /dev/null +++ b/rbi/imagekitio/resources/files.rbi @@ -0,0 +1,364 @@ +# typed: strong + +module Imagekitio + module Resources + class Files + sig { returns(Imagekitio::Resources::Files::Bulk) } + attr_reader :bulk + + sig { returns(Imagekitio::Resources::Files::Versions) } + attr_reader :versions + + sig { returns(Imagekitio::Resources::Files::Metadata) } + attr_reader :metadata + + # 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. + sig do + params( + file_id: String, + update_file_request: Imagekitio::UpdateFileRequest, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FileUpdateResponse) + end + def update( + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id, + # Schema for update file update request. + update_file_request:, + request_options: {} + ) + end + + # 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. + sig do + params( + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).void + end + def delete( + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id, + request_options: {} + ) + end + + # 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. + sig do + params( + destination_path: String, + source_file_path: String, + include_file_versions: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FileCopyResponse) + end + def copy( + # Full path to the folder you want to copy the above file into. + destination_path:, + # The full path of the file you want to copy. + source_file_path:, + # 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`. + include_file_versions: nil, + request_options: {} + ) + end + + # This API returns an object with details or attributes about the current version + # of the file. + sig do + params( + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::File) + end + def get( + # The unique `fileId` of the uploaded file. `fileId` is returned in the list and + # search assets API and upload API. + file_id, + request_options: {} + ) + end + + # 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. + sig do + params( + destination_path: String, + source_file_path: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FileMoveResponse) + end + def move( + # Full path to the folder you want to move the above file into. + destination_path:, + # The full path of the file you want to move. + source_file_path:, + request_options: {} + ) + end + + # 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. + sig do + params( + file_path: String, + new_file_name: String, + purge_cache: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FileRenameResponse) + end + def rename( + # The full path of the file you want to rename. + file_path:, + # 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 `_`. + new_file_name:, + # 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` + purge_cache: nil, + request_options: {} + ) + end + + # 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 20MB for images, audio, and raw + # files and 100MB for videos. On the paid plan, these limits increase to 40MB for images, + # audio, and raw files and 2GB for videos. These limits can be further increased with + # higher-tier 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. + sig do + params( + file: Imagekitio::Internal::FileInput, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: T::Hash[Symbol, T.anything], + description: String, + expire: Integer, + extensions: + T::Array[ + T.any( + Imagekitio::ExtensionItem::RemoveBg::OrHash, + Imagekitio::ExtensionItem::AIAutoDescription::OrHash, + Imagekitio::ExtensionItem::AutoTaggingExtension::OrHash + ) + ], + folder: String, + is_private_file: T::Boolean, + is_published: T::Boolean, + overwrite_ai_tags: T::Boolean, + overwrite_custom_metadata: T::Boolean, + overwrite_file: T::Boolean, + overwrite_tags: T::Boolean, + public_key: String, + response_fields: + T::Array[Imagekitio::FileUploadParams::ResponseField::OrSymbol], + signature: String, + tags: T::Array[String], + transformation: Imagekitio::FileUploadParams::Transformation::OrHash, + use_unique_file_name: T::Boolean, + webhook_url: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FileUploadResponse) + end + def upload( + # 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. + 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 `_` + file_name:, + # 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. + token: nil, + # Server-side checks to run on the asset. Read more about + # [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + checks: nil, + # 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. + custom_coordinates: nil, + # JSON key-value pairs to associate with the asset. Create the custom metadata + # fields before setting these values. + custom_metadata: nil, + # Optional text to describe the contents of the file. + description: nil, + # 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. + expire: nil, + # Array of extensions to be applied to the asset. Each extension can be configured + # with specific parameters based on the extension type. + extensions: nil, + # 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. + folder: nil, + # 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. + is_private_file: nil, + # 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. + is_published: nil, + # 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. + overwrite_ai_tags: nil, + # If the request does not have `customMetadata`, and a file already exists at the + # exact location, existing customMetadata will be removed. + overwrite_custom_metadata: nil, + # If `false` and `useUniqueFileName` is also `false`, and a file already exists at + # the exact location, upload API will return an error immediately. + overwrite_file: nil, + # If the request does not have `tags`, and a file already exists at the exact + # location, existing tags will be removed. + overwrite_tags: nil, + # Your ImageKit.io public key. This field is only required for authentication when + # uploading a file from the client side. + public_key: nil, + # Array of response field keys to include in the API response body. + response_fields: nil, + # 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. + signature: nil, + # 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. + tags: nil, + # 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. + transformation: nil, + # 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. + use_unique_file_name: nil, + # 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. + webhook_url: nil, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekitio/resources/files/bulk.rbi b/rbi/imagekitio/resources/files/bulk.rbi new file mode 100644 index 00000000..90f03559 --- /dev/null +++ b/rbi/imagekitio/resources/files/bulk.rbi @@ -0,0 +1,88 @@ +# typed: strong + +module Imagekitio + module Resources + class Files + class Bulk + # 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. + sig do + params( + file_ids: T::Array[String], + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Files::BulkDeleteResponse) + end + def delete( + # An array of fileIds which you want to delete. + file_ids:, + request_options: {} + ) + end + + # This API adds tags to multiple files in bulk. A maximum of 50 files can be + # specified at a time. + sig do + params( + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Files::BulkAddTagsResponse) + end + def add_tags( + # An array of fileIds to which you want to add tags. + file_ids:, + # An array of tags that you want to add to the files. + tags:, + request_options: {} + ) + end + + # This API removes AITags from multiple files in bulk. A maximum of 50 files can + # be specified at a time. + sig do + params( + ai_tags: T::Array[String], + file_ids: T::Array[String], + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Files::BulkRemoveAITagsResponse) + end + def remove_ai_tags( + # An array of AITags that you want to remove from the files. + ai_tags:, + # An array of fileIds from which you want to remove AITags. + file_ids:, + request_options: {} + ) + end + + # This API removes tags from multiple files in bulk. A maximum of 50 files can be + # specified at a time. + sig do + params( + file_ids: T::Array[String], + tags: T::Array[String], + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Files::BulkRemoveTagsResponse) + end + def remove_tags( + # An array of fileIds from which you want to remove tags. + file_ids:, + # An array of tags that you want to remove from the files. + tags:, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekitio/resources/files/metadata.rbi b/rbi/imagekitio/resources/files/metadata.rbi new file mode 100644 index 00000000..2a341ac4 --- /dev/null +++ b/rbi/imagekitio/resources/files/metadata.rbi @@ -0,0 +1,49 @@ +# typed: strong + +module Imagekitio + module Resources + class Files + class Metadata + # 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. + sig do + params( + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Metadata) + end + def get( + # The unique `fileId` of the uploaded file. `fileId` is returned in the list and + # search assets API and upload API. + file_id, + request_options: {} + ) + end + + # Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL + # using this API. + sig do + params( + url: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Metadata) + end + def get_from_url( + # Should be a valid file URL. It should be accessible using your ImageKit.io + # account. + url:, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekitio/resources/files/versions.rbi b/rbi/imagekitio/resources/files/versions.rbi new file mode 100644 index 00000000..7b9dfbda --- /dev/null +++ b/rbi/imagekitio/resources/files/versions.rbi @@ -0,0 +1,89 @@ +# typed: strong + +module Imagekitio + module Resources + class Files + class Versions + # This API returns details of all versions of a file. + sig do + params( + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(T::Array[Imagekitio::File]) + end + def list( + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id, + request_options: {} + ) + end + + # 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. + sig do + params( + version_id: String, + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Files::VersionDeleteResponse) + end + def delete( + # The unique `versionId` of the uploaded file. `versionId` is returned in list and + # search assets API and upload API. + version_id, + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id:, + request_options: {} + ) + end + + # This API returns an object with details or attributes of a file version. + sig do + params( + version_id: String, + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::File) + end + def get( + # The unique `versionId` of the uploaded file. `versionId` is returned in list and + # search assets API and upload API. + version_id, + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id:, + request_options: {} + ) + end + + # This API restores a file version as the current file version. + sig do + params( + version_id: String, + file_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::File) + end + def restore( + # The unique `versionId` of the uploaded file. `versionId` is returned in list and + # search assets API and upload API. + version_id, + # The unique `fileId` of the uploaded file. `fileId` is returned in list and + # search assets API and upload API. + file_id:, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekitio/resources/folders.rbi b/rbi/imagekitio/resources/folders.rbi new file mode 100644 index 00000000..f5f29604 --- /dev/null +++ b/rbi/imagekitio/resources/folders.rbi @@ -0,0 +1,146 @@ +# typed: strong + +module Imagekitio + module Resources + class Folders + sig { returns(Imagekitio::Resources::Folders::Job) } + attr_reader :job + + # 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. + sig do + params( + folder_name: String, + parent_folder_path: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FolderCreateResponse) + end + def create( + # 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. + # `_`. + folder_name:, + # 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. + parent_folder_path:, + request_options: {} + ) + end + + # This will delete a folder and all its contents permanently. The API returns an + # empty response. + sig do + params( + folder_path: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FolderDeleteResponse) + end + def delete( + # Full path to the folder you want to delete. For example `/folder/to/delete/`. + folder_path:, + request_options: {} + ) + end + + # 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. + sig do + params( + destination_path: String, + source_folder_path: String, + include_versions: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FolderCopyResponse) + end + def copy( + # Full path to the destination folder where you want to copy the source folder + # into. + destination_path:, + # The full path to the source folder you want to copy. + source_folder_path:, + # 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`. + include_versions: nil, + request_options: {} + ) + end + + # 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. + sig do + params( + destination_path: String, + source_folder_path: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FolderMoveResponse) + end + def move( + # Full path to the destination folder where you want to move the source folder + # into. + destination_path:, + # The full path to the source folder you want to move. + source_folder_path:, + request_options: {} + ) + end + + # 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. + sig do + params( + folder_path: String, + new_folder_name: String, + purge_cache: T::Boolean, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::FolderRenameResponse) + end + def rename( + # The full path to the folder you want to rename. + folder_path:, + # 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. `_`. + new_folder_name:, + # 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` + purge_cache: nil, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekitio/resources/folders/job.rbi b/rbi/imagekitio/resources/folders/job.rbi new file mode 100644 index 00000000..8b7d01b1 --- /dev/null +++ b/rbi/imagekitio/resources/folders/job.rbi @@ -0,0 +1,29 @@ +# typed: strong + +module Imagekitio + module Resources + class Folders + class Job + # This API returns the status of a bulk job like copy and move folder operations. + sig do + params( + job_id: String, + request_options: Imagekitio::RequestOptions::OrHash + ).returns(Imagekitio::Models::Folders::JobGetResponse) + end + def get( + # The `jobId` is returned in the response of bulk job API e.g. copy folder or move + # folder API. + job_id, + request_options: {} + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end + end +end diff --git a/rbi/imagekitio/resources/webhooks.rbi b/rbi/imagekitio/resources/webhooks.rbi new file mode 100644 index 00000000..0dadc535 --- /dev/null +++ b/rbi/imagekitio/resources/webhooks.rbi @@ -0,0 +1,50 @@ +# typed: strong + +module Imagekitio + module Resources + class Webhooks + sig do + params(payload: String).returns( + T.any( + Imagekitio::VideoTransformationAcceptedEvent, + Imagekitio::VideoTransformationReadyEvent, + Imagekitio::VideoTransformationErrorEvent, + Imagekitio::UploadPreTransformSuccessEvent, + Imagekitio::UploadPreTransformErrorEvent, + Imagekitio::UploadPostTransformSuccessEvent, + Imagekitio::UploadPostTransformErrorEvent + ) + ) + end + def unsafe_unwrap( + # The raw webhook payload as a string + payload + ) + end + + sig do + params(payload: String).returns( + T.any( + Imagekitio::VideoTransformationAcceptedEvent, + Imagekitio::VideoTransformationReadyEvent, + Imagekitio::VideoTransformationErrorEvent, + Imagekitio::UploadPreTransformSuccessEvent, + Imagekitio::UploadPreTransformErrorEvent, + Imagekitio::UploadPostTransformSuccessEvent, + Imagekitio::UploadPostTransformErrorEvent + ) + ) + end + def unwrap( + # The raw webhook payload as a string + payload + ) + end + + # @api private + sig { params(client: Imagekitio::Client).returns(T.attached_class) } + def self.new(client:) + end + end + end +end diff --git a/rbi/imagekitio/version.rbi b/rbi/imagekitio/version.rbi new file mode 100644 index 00000000..1db4e4b8 --- /dev/null +++ b/rbi/imagekitio/version.rbi @@ -0,0 +1,5 @@ +# typed: strong + +module Imagekitio + VERSION = T.let(T.unsafe(nil), String) +end diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..70a47571 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,70 @@ +{ + "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": "ruby", + "version-file": "lib/imagekitio/version.rb", + "extra-files": [ + { + "type": "ruby-readme", + "path": "README.md" + } + ] +} \ No newline at end of file diff --git a/scripts/bootstrap b/scripts/bootstrap new file mode 100755 index 00000000..34878642 --- /dev/null +++ b/scripts/bootstrap @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then + brew bundle check >/dev/null 2>&1 || { + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo + } +fi + +echo "==> Installing Ruby dependencies…" + +exec -- bundle install "$@" diff --git a/scripts/fast-format b/scripts/fast-format new file mode 100755 index 00000000..6d5973fb --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -euo pipefail + +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + +cd -- "$(dirname "$0")/.." +echo "Changed to directory: $PWD" + +if [ $# -eq 0 ]; then + echo "Usage: $0 [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +exec -- bundle exec rake format FORMAT_FILE="$1" diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..177d1e63 --- /dev/null +++ b/scripts/format @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +echo "==> Running formatters" + +exec -- bundle exec rake format "$@" diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..08b0dbeb --- /dev/null +++ b/scripts/lint @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +echo "==> Running linters" + +exec -- bundle exec rake lint "$@" diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 00000000..0b28f6ea --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..e0dc1374 --- /dev/null +++ b/scripts/test @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e + +cd -- "$(dirname -- "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +echo "==> Running tests" +bundle exec rake test "$@" diff --git a/sig/imagekitio/client.rbs b/sig/imagekitio/client.rbs new file mode 100644 index 00000000..59c0568a --- /dev/null +++ b/sig/imagekitio/client.rbs @@ -0,0 +1,47 @@ +module Imagekitio + class Client < Imagekitio::Internal::Transport::BaseClient + DEFAULT_MAX_RETRIES: 2 + + DEFAULT_TIMEOUT_IN_SECONDS: Float + + DEFAULT_INITIAL_RETRY_DELAY: Float + + DEFAULT_MAX_RETRY_DELAY: Float + + attr_reader private_key: String + + attr_reader password: String? + + attr_reader custom_metadata_fields: Imagekitio::Resources::CustomMetadataFields + + attr_reader files: Imagekitio::Resources::Files + + attr_reader assets: Imagekitio::Resources::Assets + + attr_reader cache: Imagekitio::Resources::Cache + + attr_reader folders: Imagekitio::Resources::Folders + + attr_reader accounts: Imagekitio::Resources::Accounts + + attr_reader beta: Imagekitio::Resources::Beta + + attr_reader webhooks: Imagekitio::Resources::Webhooks + + attr_reader helper: Imagekitio::Helper + + private def auth_headers: -> ::Hash[String, String] + + def base_url_overridden?: -> bool + + def initialize: ( + ?private_key: String?, + ?password: String?, + ?base_url: String?, + ?max_retries: Integer, + ?timeout: Float, + ?initial_retry_delay: Float, + ?max_retry_delay: Float + ) -> void + end +end diff --git a/sig/imagekitio/errors.rbs b/sig/imagekitio/errors.rbs new file mode 100644 index 00000000..b5d55488 --- /dev/null +++ b/sig/imagekitio/errors.rbs @@ -0,0 +1,117 @@ +module Imagekitio + module Errors + class Error < StandardError + attr_accessor cause: StandardError? + end + + class ConversionError < Imagekitio::Errors::Error + def cause: -> StandardError? + + def initialize: ( + on: Class, + method: Symbol, + target: top, + value: top, + ?cause: StandardError? + ) -> void + end + + class APIError < Imagekitio::Errors::Error + attr_accessor url: URI::Generic + + attr_accessor status: Integer? + + attr_accessor headers: ::Hash[String, String]? + + attr_accessor body: top? + + def initialize: ( + url: URI::Generic, + ?status: Integer?, + ?headers: ::Hash[String, String]?, + ?body: Object?, + ?request: nil, + ?response: nil, + ?message: String? + ) -> void + end + + class APIConnectionError < Imagekitio::Errors::APIError + def initialize: ( + url: URI::Generic, + ?status: nil, + ?headers: ::Hash[String, String]?, + ?body: nil, + ?request: nil, + ?response: nil, + ?message: String? + ) -> void + end + + class APITimeoutError < Imagekitio::Errors::APIConnectionError + def initialize: ( + url: URI::Generic, + ?status: nil, + ?headers: ::Hash[String, String]?, + ?body: nil, + ?request: nil, + ?response: nil, + ?message: String? + ) -> void + end + + class APIStatusError < Imagekitio::Errors::APIError + def self.for: ( + url: URI::Generic, + status: Integer, + headers: ::Hash[String, String]?, + body: Object?, + request: nil, + response: nil, + ?message: String? + ) -> instance + + def initialize: ( + url: URI::Generic, + status: Integer, + headers: ::Hash[String, String]?, + body: Object?, + request: nil, + response: nil, + ?message: String? + ) -> void + end + + class BadRequestError < Imagekitio::Errors::APIStatusError + HTTP_STATUS: 400 + end + + class AuthenticationError < Imagekitio::Errors::APIStatusError + HTTP_STATUS: 401 + end + + class PermissionDeniedError < Imagekitio::Errors::APIStatusError + HTTP_STATUS: 403 + end + + class NotFoundError < Imagekitio::Errors::APIStatusError + HTTP_STATUS: 404 + end + + class ConflictError < Imagekitio::Errors::APIStatusError + HTTP_STATUS: 409 + end + + class UnprocessableEntityError < Imagekitio::Errors::APIStatusError + HTTP_STATUS: 422 + end + + class RateLimitError < Imagekitio::Errors::APIStatusError + HTTP_STATUS: 429 + end + + class InternalServerError < Imagekitio::Errors::APIStatusError + HTTP_STATUS: Range[Integer] + end + end +end diff --git a/sig/imagekitio/file_part.rbs b/sig/imagekitio/file_part.rbs new file mode 100644 index 00000000..323ade3a --- /dev/null +++ b/sig/imagekitio/file_part.rbs @@ -0,0 +1,21 @@ +module Imagekitio + class FilePart + attr_reader content: Pathname | StringIO | IO | String + + attr_reader content_type: String? + + attr_reader filename: String? + + private def read: -> String + + def to_json: (*top a) -> String + + def to_yaml: (*top a) -> String + + def initialize: ( + Pathname | StringIO | IO | String content, + ?filename: (Pathname | String)?, + ?content_type: String? + ) -> void + end +end diff --git a/sig/imagekitio/helpers/helper.rbs b/sig/imagekitio/helpers/helper.rbs new file mode 100644 index 00000000..9756e66b --- /dev/null +++ b/sig/imagekitio/helpers/helper.rbs @@ -0,0 +1,24 @@ +module Imagekitio + class Helper + def initialize: (client: Imagekitio::Client) -> void + + # Builds a URL with transformations applied + def build_url: (Imagekitio::Models::SrcOptions options) -> String + + # Generates transformation string from transformation objects + def build_transformation_string: ( + Array[Imagekitio::Models::Transformation] transformations + ) -> String + + # Generates authentication parameters for client-side file uploads + def get_authentication_parameters: ( + ?String? token, + ?Integer? expire + ) -> Hash[Symbol, (String | Integer)] + + # Generates responsive image attributes for use in HTML tags + def get_responsive_image_attributes: ( + Imagekitio::Models::GetImageAttributesOptions options + ) -> Imagekitio::Models::ResponsiveImageAttributes + end +end diff --git a/sig/imagekitio/internal.rbs b/sig/imagekitio/internal.rbs new file mode 100644 index 00000000..f1649f46 --- /dev/null +++ b/sig/imagekitio/internal.rbs @@ -0,0 +1,9 @@ +module Imagekitio + module Internal + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + type file_input = Pathname | StringIO | IO | String | Imagekitio::FilePart + + OMIT: Object + end +end diff --git a/sig/imagekitio/internal/transport/base_client.rbs b/sig/imagekitio/internal/transport/base_client.rbs new file mode 100644 index 00000000..9ab9fe58 --- /dev/null +++ b/sig/imagekitio/internal/transport/base_client.rbs @@ -0,0 +1,131 @@ +module Imagekitio + module Internal + module Transport + class BaseClient + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + type request_components = + { + method: Symbol, + path: String | ::Array[String], + query: ::Hash[String, (::Array[String] | String)?]?, + headers: ::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?]?, + body: top?, + unwrap: (Symbol + | Integer + | ::Array[(Symbol | Integer)] + | (^(top arg0) -> top))?, + page: Class?, + stream: Class?, + model: Imagekitio::Internal::Type::Converter::input?, + options: Imagekitio::request_opts? + } + type request_input = + { + method: Symbol, + url: URI::Generic, + headers: ::Hash[String, String], + body: top, + max_retries: Integer, + timeout: Float + } + + MAX_REDIRECTS: 20 + + PLATFORM_HEADERS: ::Hash[String, String] + + def self.validate!: ( + Imagekitio::Internal::Transport::BaseClient::request_components req + ) -> void + + def self.should_retry?: ( + Integer status, + headers: ::Hash[String, String] + ) -> bool + + def self.follow_redirect: ( + Imagekitio::Internal::Transport::BaseClient::request_input request, + status: Integer, + response_headers: ::Hash[String, String] + ) -> Imagekitio::Internal::Transport::BaseClient::request_input + + def self.reap_connection!: ( + Integer | Imagekitio::Errors::APIConnectionError status, + stream: Enumerable[String]? + ) -> void + + attr_reader base_url: URI::Generic + + attr_reader timeout: Float + + attr_reader max_retries: Integer + + attr_reader initial_retry_delay: Float + + attr_reader max_retry_delay: Float + + attr_reader headers: ::Hash[String, String] + + attr_reader idempotency_header: String? + + # @api private + attr_reader requester: Imagekitio::Internal::Transport::PooledNetRequester + + def initialize: ( + base_url: String, + ?timeout: Float, + ?max_retries: Integer, + ?initial_retry_delay: Float, + ?max_retry_delay: Float, + ?headers: ::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?], + ?idempotency_header: String? + ) -> void + + private def auth_headers: -> ::Hash[String, String] + + private def generate_idempotency_key: -> String + + private def build_request: ( + Imagekitio::Internal::Transport::BaseClient::request_components req, + Imagekitio::request_options opts + ) -> Imagekitio::Internal::Transport::BaseClient::request_input + + private def retry_delay: ( + ::Hash[String, String] headers, + retry_count: Integer + ) -> Float + + def send_request: ( + Imagekitio::Internal::Transport::BaseClient::request_input request, + redirect_count: Integer, + retry_count: Integer, + send_retry_header: bool + ) -> [Integer, top, Enumerable[String]] + + def request: ( + Symbol method, + String | ::Array[String] path, + ?query: ::Hash[String, (::Array[String] | String)?]?, + ?headers: ::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?]?, + ?body: top?, + ?unwrap: (Symbol + | Integer + | ::Array[(Symbol | Integer)] + | (^(top arg0) -> top))?, + ?page: Class?, + ?stream: Class?, + ?model: Imagekitio::Internal::Type::Converter::input?, + ?options: Imagekitio::request_opts? + ) -> top + + def inspect: -> String + end + end + end +end diff --git a/sig/imagekitio/internal/transport/pooled_net_requester.rbs b/sig/imagekitio/internal/transport/pooled_net_requester.rbs new file mode 100644 index 00000000..6ef7c006 --- /dev/null +++ b/sig/imagekitio/internal/transport/pooled_net_requester.rbs @@ -0,0 +1,45 @@ +module Imagekitio + module Internal + module Transport + class PooledNetRequester + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + type request = + { + method: Symbol, + url: URI::Generic, + headers: ::Hash[String, String], + body: top, + deadline: Float + } + + KEEP_ALIVE_TIMEOUT: 30 + + DEFAULT_MAX_CONNECTIONS: Integer + + def self.connect: (URI::Generic url) -> top + + def self.calibrate_socket_timeout: (top conn, Float deadline) -> void + + def self.build_request: ( + Imagekitio::Internal::Transport::PooledNetRequester::request request + ) { + (String arg0) -> void + } -> [top, (^-> void)] + + private def with_pool: ( + URI::Generic url, + deadline: Float + ) { + (top arg0) -> void + } -> void + + def execute: ( + Imagekitio::Internal::Transport::PooledNetRequester::request request + ) -> [Integer, top, Enumerable[String]] + + def initialize: (?size: Integer) -> void + end + end + end +end diff --git a/sig/imagekitio/internal/type/array_of.rbs b/sig/imagekitio/internal/type/array_of.rbs new file mode 100644 index 00000000..8963ab2a --- /dev/null +++ b/sig/imagekitio/internal/type/array_of.rbs @@ -0,0 +1,48 @@ +module Imagekitio + module Internal + module Type + class ArrayOf[Elem] + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + def self.[]: ( + ::Hash[Symbol, top] + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> instance + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def hash: -> Integer + + def coerce: ( + ::Array[top] | top value, + state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> (::Array[top] | top) + + def dump: ( + ::Array[top] | top value, + state: Imagekitio::Internal::Type::Converter::dump_state + ) -> (::Array[top] | top) + + def to_sorbet_type: -> top + + def item_type: -> Elem + + def nilable?: -> bool + + def initialize: ( + ::Hash[Symbol, top] + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + def inspect: (?depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekitio/internal/type/base_model.rbs b/sig/imagekitio/internal/type/base_model.rbs new file mode 100644 index 00000000..f56ac365 --- /dev/null +++ b/sig/imagekitio/internal/type/base_model.rbs @@ -0,0 +1,102 @@ +module Imagekitio + module Internal + module Type + class BaseModel + extend Imagekitio::Internal::Type::Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + type known_field = + { mode: (:coerce | :dump)?, required: bool, nilable: bool } + + def self.inherited: (self child) -> void + + def self.known_fields: -> ::Hash[Symbol, (Imagekitio::Internal::Type::BaseModel::known_field + & { type_fn: (^-> Imagekitio::Internal::Type::Converter::input) })] + + def self.fields: -> ::Hash[Symbol, (Imagekitio::Internal::Type::BaseModel::known_field + & { type: Imagekitio::Internal::Type::Converter::input })] + + private def self.add_field: ( + Symbol name_sym, + required: bool, + type_info: { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> Imagekitio::Internal::Type::Converter::input?, + union: ^-> Imagekitio::Internal::Type::Converter::input?, + api_name: Symbol + } + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input, + spec: ::Hash[Symbol, top] + ) -> void + + def self.required: ( + Symbol name_sym, + ::Hash[Symbol, top] + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + def self.optional: ( + Symbol name_sym, + ::Hash[Symbol, top] + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + private def self.request_only: { -> void } -> void + + private def self.response_only: { -> void } -> void + + def self.==: (top other) -> bool + + def self.hash: -> Integer + + def ==: (top other) -> bool + + def hash: -> Integer + + def self.coerce: ( + Imagekitio::Internal::Type::BaseModel | ::Hash[top, top] | top value, + state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> (instance | top) + + def self.dump: ( + instance | top value, + state: Imagekitio::Internal::Type::Converter::dump_state + ) -> (::Hash[top, top] | top) + + def self.to_sorbet_type: -> top + + def self.recursively_to_h: ( + Imagekitio::Internal::Type::BaseModel model, + convert: bool + ) -> ::Hash[Symbol, top] + + def []: (Symbol key) -> top? + + def to_h: -> ::Hash[Symbol, top] + + alias to_hash to_h + + def deep_to_h: -> ::Hash[Symbol, top] + + def deconstruct_keys: (::Array[Symbol]? keys) -> ::Hash[Symbol, top] + + def to_json: (*top a) -> String + + def to_yaml: (*top a) -> String + + def initialize: (?::Hash[Symbol, top] | instance data) -> void + + def self.inspect: (?depth: Integer) -> String + + def to_s: -> String + + def inspect: -> String + end + end + end +end diff --git a/sig/imagekitio/internal/type/base_page.rbs b/sig/imagekitio/internal/type/base_page.rbs new file mode 100644 index 00000000..5aca2ab6 --- /dev/null +++ b/sig/imagekitio/internal/type/base_page.rbs @@ -0,0 +1,24 @@ +module Imagekitio + module Internal + module Type + module BasePage[Elem] + def next_page?: -> bool + + def next_page: -> instance + + def auto_paging_each: { (Elem arg0) -> void } -> void + + def to_enum: -> Enumerable[Elem] + + alias enum_for to_enum + + def initialize: ( + client: Imagekitio::Internal::Transport::BaseClient, + req: Imagekitio::Internal::Transport::BaseClient::request_components, + headers: ::Hash[String, String], + page_data: top + ) -> void + end + end + end +end diff --git a/sig/imagekitio/internal/type/boolean.rbs b/sig/imagekitio/internal/type/boolean.rbs new file mode 100644 index 00000000..99544d00 --- /dev/null +++ b/sig/imagekitio/internal/type/boolean.rbs @@ -0,0 +1,26 @@ +module Imagekitio + module Internal + module Type + class Boolean + extend Imagekitio::Internal::Type::Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + def self.===: (top other) -> bool + + def self.==: (top other) -> bool + + def self.coerce: ( + bool | top value, + state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> (bool | top) + + def self.dump: ( + bool | top value, + state: Imagekitio::Internal::Type::Converter::dump_state + ) -> (bool | top) + + def self.to_sorbet_type: -> top + end + end + end +end diff --git a/sig/imagekitio/internal/type/converter.rbs b/sig/imagekitio/internal/type/converter.rbs new file mode 100644 index 00000000..16df1d71 --- /dev/null +++ b/sig/imagekitio/internal/type/converter.rbs @@ -0,0 +1,79 @@ +module Imagekitio + module Internal + module Type + module Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + type input = Imagekitio::Internal::Type::Converter | Class + + type coerce_state = + { + translate_names: bool, + strictness: bool, + exactness: { yes: Integer, no: Integer, maybe: Integer }, + error: Class, + branched: Integer + } + + type dump_state = { can_retry: bool } + + def coerce: ( + top value, + state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> top + + def dump: ( + top value, + state: Imagekitio::Internal::Type::Converter::dump_state + ) -> top + + def inspect: (?depth: Integer) -> String + + def self.type_info: ( + { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> Imagekitio::Internal::Type::Converter::input?, + union: ^-> Imagekitio::Internal::Type::Converter::input? + } + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input spec + ) -> (^-> top) + + def self.meta_info: ( + { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> Imagekitio::Internal::Type::Converter::input?, + union: ^-> Imagekitio::Internal::Type::Converter::input? + } + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input type_info, + { + const: (nil | bool | Integer | Float | Symbol)?, + enum: ^-> Imagekitio::Internal::Type::Converter::input?, + union: ^-> Imagekitio::Internal::Type::Converter::input? + } + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input spec + ) -> ::Hash[Symbol, top] + + def self.new_coerce_state: ( + ?translate_names: bool + ) -> Imagekitio::Internal::Type::Converter::coerce_state + + def self.coerce: ( + Imagekitio::Internal::Type::Converter::input target, + top value, + ?state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> top + + def self.dump: ( + Imagekitio::Internal::Type::Converter::input target, + top value, + ?state: Imagekitio::Internal::Type::Converter::dump_state + ) -> top + + def self.inspect: (top target, depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekitio/internal/type/enum.rbs b/sig/imagekitio/internal/type/enum.rbs new file mode 100644 index 00000000..4588fd85 --- /dev/null +++ b/sig/imagekitio/internal/type/enum.rbs @@ -0,0 +1,32 @@ +module Imagekitio + module Internal + module Type + module Enum + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + def self.values: -> ::Array[(nil | bool | Integer | Float | Symbol)] + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def hash: -> Integer + + def coerce: ( + String | Symbol | top value, + state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> (Symbol | top) + + def dump: ( + Symbol | top value, + state: Imagekitio::Internal::Type::Converter::dump_state + ) -> (Symbol | top) + + def to_sorbet_type: -> top + + def inspect: (?depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekitio/internal/type/file_input.rbs b/sig/imagekitio/internal/type/file_input.rbs new file mode 100644 index 00000000..b40b77da --- /dev/null +++ b/sig/imagekitio/internal/type/file_input.rbs @@ -0,0 +1,25 @@ +module Imagekitio + module Internal + module Type + class FileInput + extend Imagekitio::Internal::Type::Converter + + def self.===: (top other) -> bool + + def self.==: (top other) -> bool + + def self.coerce: ( + StringIO | String | top value, + state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> (StringIO | top) + + def self.dump: ( + Pathname | StringIO | IO | String | top value, + state: Imagekitio::Internal::Type::Converter::dump_state + ) -> (Pathname | StringIO | IO | String | top) + + def self.to_sorbet_type: -> top + end + end + end +end diff --git a/sig/imagekitio/internal/type/hash_of.rbs b/sig/imagekitio/internal/type/hash_of.rbs new file mode 100644 index 00000000..df2f1326 --- /dev/null +++ b/sig/imagekitio/internal/type/hash_of.rbs @@ -0,0 +1,48 @@ +module Imagekitio + module Internal + module Type + class HashOf[Elem] + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + def self.[]: ( + ::Hash[Symbol, top] + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> instance + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def hash: -> Integer + + def coerce: ( + ::Hash[top, top] | top value, + state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> (::Hash[Symbol, top] | top) + + def dump: ( + ::Hash[top, top] | top value, + state: Imagekitio::Internal::Type::Converter::dump_state + ) -> (::Hash[Symbol, top] | top) + + def to_sorbet_type: -> top + + def item_type: -> Elem + + def nilable?: -> bool + + def initialize: ( + ::Hash[Symbol, top] + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input type_info, + ?::Hash[Symbol, top] spec + ) -> void + + def inspect: (?depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekitio/internal/type/request_parameters.rbs b/sig/imagekitio/internal/type/request_parameters.rbs new file mode 100644 index 00000000..c16a59fd --- /dev/null +++ b/sig/imagekitio/internal/type/request_parameters.rbs @@ -0,0 +1,19 @@ +module Imagekitio + module Internal + module Type + type request_parameters = { request_options: Imagekitio::request_opts } + + module RequestParameters + attr_reader request_options: Imagekitio::request_opts + + def request_options=: ( + Imagekitio::request_opts + ) -> Imagekitio::request_opts + + module Converter + def dump_request: (top params) -> [top, ::Hash[Symbol, top]] + end + end + end + end +end diff --git a/sig/imagekitio/internal/type/union.rbs b/sig/imagekitio/internal/type/union.rbs new file mode 100644 index 00000000..6bb475bd --- /dev/null +++ b/sig/imagekitio/internal/type/union.rbs @@ -0,0 +1,52 @@ +module Imagekitio + module Internal + module Type + module Union + include Imagekitio::Internal::Type::Converter + include Imagekitio::Internal::Util::SorbetRuntimeSupport + + private def self.known_variants: -> ::Array[[Symbol?, (^-> Imagekitio::Internal::Type::Converter::input), ::Hash[Symbol, top]]] + + def self.derefed_variants: -> ::Array[[Symbol?, top, ::Hash[Symbol, top]]] + + def self.variants: -> ::Array[top] + + private def self.discriminator: (Symbol property) -> void + + private def self.variant: ( + Symbol + | ::Hash[Symbol, top] + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input key, + ?::Hash[Symbol, top] + | ^-> Imagekitio::Internal::Type::Converter::input + | Imagekitio::Internal::Type::Converter::input spec + ) -> void + + private def self.resolve_variant: ( + top value + ) -> Imagekitio::Internal::Type::Converter::input? + + def ===: (top other) -> bool + + def ==: (top other) -> bool + + def hash: -> Integer + + def coerce: ( + top value, + state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> top + + def dump: ( + top value, + state: Imagekitio::Internal::Type::Converter::dump_state + ) -> top + + def to_sorbet_type: -> top + + def inspect: (?depth: Integer) -> String + end + end + end +end diff --git a/sig/imagekitio/internal/type/unknown.rbs b/sig/imagekitio/internal/type/unknown.rbs new file mode 100644 index 00000000..ddab4e3e --- /dev/null +++ b/sig/imagekitio/internal/type/unknown.rbs @@ -0,0 +1,26 @@ +module Imagekitio + module Internal + module Type + class Unknown + extend Imagekitio::Internal::Type::Converter + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + def self.===: (top other) -> bool + + def self.==: (top other) -> bool + + def self.coerce: ( + top value, + state: Imagekitio::Internal::Type::Converter::coerce_state + ) -> top + + def self.dump: ( + top value, + state: Imagekitio::Internal::Type::Converter::dump_state + ) -> top + + def self.to_sorbet_type: -> top + end + end + end +end diff --git a/sig/imagekitio/internal/util.rbs b/sig/imagekitio/internal/util.rbs new file mode 100644 index 00000000..73bf10f9 --- /dev/null +++ b/sig/imagekitio/internal/util.rbs @@ -0,0 +1,185 @@ +module Imagekitio + module Internal + module Util + extend Imagekitio::Internal::Util::SorbetRuntimeSupport + + def self?.monotonic_secs: -> Float + + def self?.walk_namespaces: ( + Module | Class ns + ) -> Enumerable[(Module | Class)] + + def self?.arch: -> String + + def self?.os: -> String + + def self?.primitive?: (top input) -> bool + + def self?.coerce_boolean: (String | bool input) -> (bool | top) + + def self?.coerce_boolean!: (String | bool input) -> bool? + + def self?.coerce_integer: (String | Integer input) -> (Integer | top) + + def self?.coerce_float: (String | Integer | Float input) -> (Float | top) + + def self?.coerce_hash: (top input) -> (::Hash[top, top] | top) + + def self?.coerce_hash!: (top input) -> ::Hash[top, top]? + + def self?.deep_merge_lr: (top lhs, top rhs, ?concat: bool) -> top + + def self?.deep_merge: ( + *::Array[top] values, + ?sentinel: top?, + ?concat: bool + ) -> top + + def self?.dig: ( + ::Hash[Symbol, top] | ::Array[top] | top data, + (Symbol + | Integer + | ::Array[(Symbol | Integer)] + | (^(top arg0) -> top))? pick + ) { + -> top? + } -> top? + + def self?.uri_origin: (URI::Generic uri) -> String + + def self?.interpolate_path: (String | ::Array[String] path) -> String + + def self?.decode_query: (String? query) -> ::Hash[String, ::Array[String]] + + def self?.encode_query: ( + ::Hash[String, (::Array[String] | String)?]? query + ) -> String? + + type parsed_uri = + { + scheme: String?, + host: String?, + port: Integer?, + path: String?, + query: ::Hash[String, ::Array[String]] + } + + def self?.parse_uri: ( + URI::Generic | String url + ) -> Imagekitio::Internal::Util::parsed_uri + + def self?.unparse_uri: ( + Imagekitio::Internal::Util::parsed_uri parsed + ) -> URI::Generic + + def self?.join_parsed_uri: ( + Imagekitio::Internal::Util::parsed_uri lhs, + Imagekitio::Internal::Util::parsed_uri rhs + ) -> URI::Generic + + def self?.normalized_headers: ( + *::Hash[String, (String + | Integer + | ::Array[(String | Integer)?])?] headers + ) -> ::Hash[String, String] + + class ReadIOAdapter + def close?: -> bool? + + def close: -> void + + private def read_enum: (Integer? max_len) -> String + + def read: (?Integer? max_len, ?String? out_string) -> String? + + def initialize: ( + String | Pathname | StringIO | Enumerable[String] src + ) { + (String arg0) -> void + } -> void + end + + def self?.writable_enum: { + (Enumerator::Yielder y) -> void + } -> Enumerable[String] + + JSON_CONTENT: Regexp + JSONL_CONTENT: Regexp + + def self?.write_multipart_content: ( + Enumerator::Yielder y, + val: top, + closing: ::Array[^-> void], + ?content_type: String? + ) -> void + + def self?.write_multipart_chunk: ( + Enumerator::Yielder y, + boundary: String, + key: Symbol | String, + val: top, + closing: ::Array[^-> void] + ) -> void + + def self?.encode_multipart_streaming: ( + top body + ) -> [String, Enumerable[String]] + + def self?.encode_content: ( + ::Hash[String, String] headers, + top body + ) -> top + + def self?.force_charset!: (String content_type, text: String) -> void + + def self?.decode_content: ( + ::Hash[String, String] headers, + stream: Enumerable[String], + ?suppress_error: bool + ) -> top + + def self?.fused_enum: ( + Enumerable[top] enum, + ?external: bool + ) { + -> void + } -> Enumerable[top] + + def self?.close_fused!: (Enumerable[top]? enum) -> void + + def self?.chain_fused: ( + Enumerable[top]? enum + ) { + (Enumerator::Yielder arg0) -> void + } -> Enumerable[top] + + type server_sent_event = + { event: String?, data: String?, id: String?, retry: Integer? } + + def self?.decode_lines: (Enumerable[String] enum) -> Enumerable[String] + + def self?.decode_sse: ( + Enumerable[String] lines + ) -> Enumerable[Imagekitio::Internal::Util::server_sent_event] + + module SorbetRuntimeSupport + class MissingSorbetRuntimeError < ::RuntimeError + end + + private def sorbet_runtime_constants: -> ::Hash[Symbol, top] + + def const_missing: (Symbol name) -> void + + def sorbet_constant_defined?: (Symbol name) -> bool + + def define_sorbet_constant!: (Symbol name) { -> top } -> void + + def to_sorbet_type: -> top + + def self.to_sorbet_type: ( + Imagekitio::Internal::Util::SorbetRuntimeSupport | top `type` + ) -> top + end + end + end +end diff --git a/sig/imagekitio/models.rbs b/sig/imagekitio/models.rbs new file mode 100644 index 00000000..2bb9e2d2 --- /dev/null +++ b/sig/imagekitio/models.rbs @@ -0,0 +1,119 @@ +module Imagekitio + module Accounts = Imagekitio::Models::Accounts + + class AssetListParams = Imagekitio::Models::AssetListParams + + class BaseOverlay = Imagekitio::Models::BaseOverlay + + class BaseWebhookEvent = Imagekitio::Models::BaseWebhookEvent + + module Beta = Imagekitio::Models::Beta + + module Cache = Imagekitio::Models::Cache + + class CustomMetadataField = Imagekitio::Models::CustomMetadataField + + class CustomMetadataFieldCreateParams = Imagekitio::Models::CustomMetadataFieldCreateParams + + class CustomMetadataFieldDeleteParams = Imagekitio::Models::CustomMetadataFieldDeleteParams + + class CustomMetadataFieldListParams = Imagekitio::Models::CustomMetadataFieldListParams + + class CustomMetadataFieldUpdateParams = Imagekitio::Models::CustomMetadataFieldUpdateParams + + type extension_item = Imagekitio::Models::extension_item + + Extensions: Imagekitio::Internal::Type::Converter + + class File = Imagekitio::Models::File + + class FileCopyParams = Imagekitio::Models::FileCopyParams + + class FileDeleteParams = Imagekitio::Models::FileDeleteParams + + class FileGetParams = Imagekitio::Models::FileGetParams + + class FileMoveParams = Imagekitio::Models::FileMoveParams + + class FileRenameParams = Imagekitio::Models::FileRenameParams + + module Files = Imagekitio::Models::Files + + class FileUpdateParams = Imagekitio::Models::FileUpdateParams + + class FileUploadParams = Imagekitio::Models::FileUploadParams + + class Folder = Imagekitio::Models::Folder + + class FolderCopyParams = Imagekitio::Models::FolderCopyParams + + class FolderCreateParams = Imagekitio::Models::FolderCreateParams + + class FolderDeleteParams = Imagekitio::Models::FolderDeleteParams + + class FolderMoveParams = Imagekitio::Models::FolderMoveParams + + class FolderRenameParams = Imagekitio::Models::FolderRenameParams + + module Folders = Imagekitio::Models::Folders + + class GetImageAttributesOptions = Imagekitio::Models::GetImageAttributesOptions + + class ImageOverlay = Imagekitio::Models::ImageOverlay + + class Metadata = Imagekitio::Models::Metadata + + module Overlay = Imagekitio::Models::Overlay + + class OverlayPosition = Imagekitio::Models::OverlayPosition + + class OverlayTiming = Imagekitio::Models::OverlayTiming + + class ResponsiveImageAttributes = Imagekitio::Models::ResponsiveImageAttributes + + class SolidColorOverlay = Imagekitio::Models::SolidColorOverlay + + class SolidColorOverlayTransformation = Imagekitio::Models::SolidColorOverlayTransformation + + class SrcOptions = Imagekitio::Models::SrcOptions + + module StreamingResolution = Imagekitio::Models::StreamingResolution + + class SubtitleOverlay = Imagekitio::Models::SubtitleOverlay + + class SubtitleOverlayTransformation = Imagekitio::Models::SubtitleOverlayTransformation + + class TextOverlay = Imagekitio::Models::TextOverlay + + class TextOverlayTransformation = Imagekitio::Models::TextOverlayTransformation + + class Transformation = Imagekitio::Models::Transformation + + module TransformationPosition = Imagekitio::Models::TransformationPosition + + module UnsafeUnwrapWebhookEvent = Imagekitio::Models::UnsafeUnwrapWebhookEvent + + module UnwrapWebhookEvent = Imagekitio::Models::UnwrapWebhookEvent + + module UpdateFileRequest = Imagekitio::Models::UpdateFileRequest + + class UploadPostTransformErrorEvent = Imagekitio::Models::UploadPostTransformErrorEvent + + class UploadPostTransformSuccessEvent = Imagekitio::Models::UploadPostTransformSuccessEvent + + class UploadPreTransformErrorEvent = Imagekitio::Models::UploadPreTransformErrorEvent + + class UploadPreTransformSuccessEvent = Imagekitio::Models::UploadPreTransformSuccessEvent + + class VideoOverlay = Imagekitio::Models::VideoOverlay + + class VideoTransformationAcceptedEvent = Imagekitio::Models::VideoTransformationAcceptedEvent + + class VideoTransformationErrorEvent = Imagekitio::Models::VideoTransformationErrorEvent + + class VideoTransformationReadyEvent = Imagekitio::Models::VideoTransformationReadyEvent + + class WebhookUnsafeUnwrapParams = Imagekitio::Models::WebhookUnsafeUnwrapParams + + class WebhookUnwrapParams = Imagekitio::Models::WebhookUnwrapParams +end diff --git a/sig/imagekitio/models/accounts/origin_create_params.rbs b/sig/imagekitio/models/accounts/origin_create_params.rbs new file mode 100644 index 00000000..92d6c6ab --- /dev/null +++ b/sig/imagekitio/models/accounts/origin_create_params.rbs @@ -0,0 +1,30 @@ +module Imagekitio + module Models + module Accounts + type origin_create_params = + { origin_request: Imagekitio::Models::Accounts::origin_request } + & Imagekitio::Internal::Type::request_parameters + + class OriginCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def origin_request: -> Imagekitio::Models::Accounts::origin_request + + def origin_request=: ( + Imagekitio::Models::Accounts::origin_request _ + ) -> Imagekitio::Models::Accounts::origin_request + + def initialize: ( + origin_request: Imagekitio::Models::Accounts::origin_request, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + origin_request: Imagekitio::Models::Accounts::origin_request, + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/origin_delete_params.rbs b/sig/imagekitio/models/accounts/origin_delete_params.rbs new file mode 100644 index 00000000..ed21916b --- /dev/null +++ b/sig/imagekitio/models/accounts/origin_delete_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Accounts + type origin_delete_params = + { } & Imagekitio::Internal::Type::request_parameters + + class OriginDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/origin_get_params.rbs b/sig/imagekitio/models/accounts/origin_get_params.rbs new file mode 100644 index 00000000..7bd58a8c --- /dev/null +++ b/sig/imagekitio/models/accounts/origin_get_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Accounts + type origin_get_params = + { } & Imagekitio::Internal::Type::request_parameters + + class OriginGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/origin_list_params.rbs b/sig/imagekitio/models/accounts/origin_list_params.rbs new file mode 100644 index 00000000..a275431c --- /dev/null +++ b/sig/imagekitio/models/accounts/origin_list_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Accounts + type origin_list_params = + { } & Imagekitio::Internal::Type::request_parameters + + class OriginListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/origin_list_response.rbs b/sig/imagekitio/models/accounts/origin_list_response.rbs new file mode 100644 index 00000000..26bbafa9 --- /dev/null +++ b/sig/imagekitio/models/accounts/origin_list_response.rbs @@ -0,0 +1,10 @@ +module Imagekitio + module Models + module Accounts + type origin_list_response = + ::Array[Imagekitio::Models::Accounts::origin_response] + + OriginListResponse: Imagekitio::Internal::Type::Converter + end + end +end diff --git a/sig/imagekitio/models/accounts/origin_request.rbs b/sig/imagekitio/models/accounts/origin_request.rbs new file mode 100644 index 00000000..2a315a07 --- /dev/null +++ b/sig/imagekitio/models/accounts/origin_request.rbs @@ -0,0 +1,468 @@ +module Imagekitio + module Models + module Accounts + type origin_request = + Imagekitio::Accounts::OriginRequest::S3 + | Imagekitio::Accounts::OriginRequest::S3Compatible + | Imagekitio::Accounts::OriginRequest::CloudinaryBackup + | Imagekitio::Accounts::OriginRequest::WebFolder + | Imagekitio::Accounts::OriginRequest::WebProxy + | Imagekitio::Accounts::OriginRequest::Gcs + | Imagekitio::Accounts::OriginRequest::AzureBlob + | Imagekitio::Accounts::OriginRequest::AkeneoPim + + module OriginRequest + extend Imagekitio::Internal::Type::Union + + type s3 = + { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: :S3, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + + class S3 < Imagekitio::Internal::Type::BaseModel + attr_accessor access_key: String + + attr_accessor bucket: String + + attr_accessor name: String + + attr_accessor secret_key: String + + attr_accessor type: :S3 + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + def initialize: ( + access_key: String, + bucket: String, + name: String, + secret_key: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?type: :S3 + ) -> void + + def to_hash: -> { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: :S3, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + end + + type s3_compatible = + { + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + type: :S3_COMPATIBLE, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String, + :s3_force_path_style => bool + } + + class S3Compatible < Imagekitio::Internal::Type::BaseModel + attr_accessor access_key: String + + attr_accessor bucket: String + + attr_accessor endpoint: String + + attr_accessor name: String + + attr_accessor secret_key: String + + attr_accessor type: :S3_COMPATIBLE + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + attr_reader s3_force_path_style: bool? + + def s3_force_path_style=: (bool) -> bool + + def initialize: ( + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?s3_force_path_style: bool, + ?type: :S3_COMPATIBLE + ) -> void + + def to_hash: -> { + access_key: String, + bucket: String, + endpoint: String, + name: String, + secret_key: String, + type: :S3_COMPATIBLE, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String, + :s3_force_path_style => bool + } + end + + type cloudinary_backup = + { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: :CLOUDINARY_BACKUP, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + + class CloudinaryBackup < Imagekitio::Internal::Type::BaseModel + attr_accessor access_key: String + + attr_accessor bucket: String + + attr_accessor name: String + + attr_accessor secret_key: String + + attr_accessor type: :CLOUDINARY_BACKUP + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + def initialize: ( + access_key: String, + bucket: String, + name: String, + secret_key: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?type: :CLOUDINARY_BACKUP + ) -> void + + def to_hash: -> { + access_key: String, + bucket: String, + name: String, + secret_key: String, + type: :CLOUDINARY_BACKUP, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + end + + type web_folder = + { + base_url: String, + name: String, + type: :WEB_FOLDER, + base_url_for_canonical_header: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool + } + + class WebFolder < Imagekitio::Internal::Type::BaseModel + attr_accessor base_url: String + + attr_accessor name: String + + attr_accessor type: :WEB_FOLDER + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader forward_host_header_to_origin: bool? + + def forward_host_header_to_origin=: (bool) -> bool + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + def initialize: ( + base_url: String, + name: String, + ?base_url_for_canonical_header: String, + ?forward_host_header_to_origin: bool, + ?include_canonical_header: bool, + ?type: :WEB_FOLDER + ) -> void + + def to_hash: -> { + base_url: String, + name: String, + type: :WEB_FOLDER, + base_url_for_canonical_header: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool + } + end + + type web_proxy = + { + name: String, + type: :WEB_PROXY, + base_url_for_canonical_header: String, + include_canonical_header: bool + } + + class WebProxy < Imagekitio::Internal::Type::BaseModel + attr_accessor name: String + + attr_accessor type: :WEB_PROXY + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + def initialize: ( + name: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?type: :WEB_PROXY + ) -> void + + def to_hash: -> { + name: String, + type: :WEB_PROXY, + base_url_for_canonical_header: String, + include_canonical_header: bool + } + end + + type gcs = + { + bucket: String, + client_email: String, + name: String, + private_key: String, + type: :GCS, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + + class Gcs < Imagekitio::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor client_email: String + + attr_accessor name: String + + attr_accessor private_key: String + + attr_accessor type: :GCS + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + def initialize: ( + bucket: String, + client_email: String, + name: String, + private_key: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?type: :GCS + ) -> void + + def to_hash: -> { + bucket: String, + client_email: String, + name: String, + private_key: String, + type: :GCS, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + end + + type azure_blob = + { + account_name: String, + container: String, + name: String, + sas_token: String, + type: :AZURE_BLOB, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + + class AzureBlob < Imagekitio::Internal::Type::BaseModel + attr_accessor account_name: String + + attr_accessor container: String + + attr_accessor name: String + + attr_accessor sas_token: String + + attr_accessor type: :AZURE_BLOB + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + attr_reader prefix: String? + + def prefix=: (String) -> String + + def initialize: ( + account_name: String, + container: String, + name: String, + sas_token: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?prefix: String, + ?type: :AZURE_BLOB + ) -> void + + def to_hash: -> { + account_name: String, + container: String, + name: String, + sas_token: String, + type: :AZURE_BLOB, + base_url_for_canonical_header: String, + include_canonical_header: bool, + prefix: String + } + end + + type akeneo_pim = + { + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + type: :AKENEO_PIM, + username: String, + base_url_for_canonical_header: String, + include_canonical_header: bool + } + + class AkeneoPim < Imagekitio::Internal::Type::BaseModel + attr_accessor base_url: String + + attr_accessor client_id: String + + attr_accessor client_secret: String + + attr_accessor name: String + + attr_accessor password: String + + attr_accessor type: :AKENEO_PIM + + attr_accessor username: String + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_reader include_canonical_header: bool? + + def include_canonical_header=: (bool) -> bool + + def initialize: ( + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + username: String, + ?base_url_for_canonical_header: String, + ?include_canonical_header: bool, + ?type: :AKENEO_PIM + ) -> void + + def to_hash: -> { + base_url: String, + client_id: String, + client_secret: String, + name: String, + password: String, + type: :AKENEO_PIM, + username: String, + base_url_for_canonical_header: String, + include_canonical_header: bool + } + end + + def self?.variants: -> ::Array[Imagekitio::Models::Accounts::origin_request] + end + end + end +end diff --git a/sig/imagekitio/models/accounts/origin_response.rbs b/sig/imagekitio/models/accounts/origin_response.rbs new file mode 100644 index 00000000..b6dbf227 --- /dev/null +++ b/sig/imagekitio/models/accounts/origin_response.rbs @@ -0,0 +1,418 @@ +module Imagekitio + module Models + module Accounts + type origin_response = + Imagekitio::Accounts::OriginResponse::S3 + | Imagekitio::Accounts::OriginResponse::S3Compatible + | Imagekitio::Accounts::OriginResponse::CloudinaryBackup + | Imagekitio::Accounts::OriginResponse::WebFolder + | Imagekitio::Accounts::OriginResponse::WebProxy + | Imagekitio::Accounts::OriginResponse::Gcs + | Imagekitio::Accounts::OriginResponse::AzureBlob + | Imagekitio::Accounts::OriginResponse::AkeneoPim + + module OriginResponse + extend Imagekitio::Internal::Type::Union + + type s3 = + { + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :S3, + base_url_for_canonical_header: String + } + + class S3 < Imagekitio::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor type: :S3 + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + ?base_url_for_canonical_header: String, + ?type: :S3 + ) -> void + + def to_hash: -> { + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :S3, + base_url_for_canonical_header: String + } + end + + type s3_compatible = + { + id: String, + bucket: String, + endpoint: String, + include_canonical_header: bool, + name: String, + prefix: String, + :s3_force_path_style => bool, + type: :S3_COMPATIBLE, + base_url_for_canonical_header: String + } + + class S3Compatible < Imagekitio::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor endpoint: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor s3_force_path_style: bool + + attr_accessor type: :S3_COMPATIBLE + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + bucket: String, + endpoint: String, + include_canonical_header: bool, + name: String, + prefix: String, + s3_force_path_style: bool, + ?base_url_for_canonical_header: String, + ?type: :S3_COMPATIBLE + ) -> void + + def to_hash: -> { + id: String, + bucket: String, + endpoint: String, + include_canonical_header: bool, + name: String, + prefix: String, + :s3_force_path_style => bool, + type: :S3_COMPATIBLE, + base_url_for_canonical_header: String + } + end + + type cloudinary_backup = + { + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :CLOUDINARY_BACKUP, + base_url_for_canonical_header: String + } + + class CloudinaryBackup < Imagekitio::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor type: :CLOUDINARY_BACKUP + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + ?base_url_for_canonical_header: String, + ?type: :CLOUDINARY_BACKUP + ) -> void + + def to_hash: -> { + id: String, + bucket: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :CLOUDINARY_BACKUP, + base_url_for_canonical_header: String + } + end + + type web_folder = + { + id: String, + base_url: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool, + name: String, + type: :WEB_FOLDER, + base_url_for_canonical_header: String + } + + class WebFolder < Imagekitio::Internal::Type::BaseModel + attr_accessor base_url: String + + attr_accessor forward_host_header_to_origin: bool + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor type: :WEB_FOLDER + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + base_url: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool, + name: String, + ?base_url_for_canonical_header: String, + ?type: :WEB_FOLDER + ) -> void + + def to_hash: -> { + id: String, + base_url: String, + forward_host_header_to_origin: bool, + include_canonical_header: bool, + name: String, + type: :WEB_FOLDER, + base_url_for_canonical_header: String + } + end + + type web_proxy = + { + id: String, + include_canonical_header: bool, + name: String, + type: :WEB_PROXY, + base_url_for_canonical_header: String + } + + class WebProxy < Imagekitio::Internal::Type::BaseModel + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor type: :WEB_PROXY + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + include_canonical_header: bool, + name: String, + ?base_url_for_canonical_header: String, + ?type: :WEB_PROXY + ) -> void + + def to_hash: -> { + id: String, + include_canonical_header: bool, + name: String, + type: :WEB_PROXY, + base_url_for_canonical_header: String + } + end + + type gcs = + { + id: String, + bucket: String, + client_email: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :GCS, + base_url_for_canonical_header: String + } + + class Gcs < Imagekitio::Internal::Type::BaseModel + attr_accessor bucket: String + + attr_accessor client_email: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor type: :GCS + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + bucket: String, + client_email: String, + include_canonical_header: bool, + name: String, + prefix: String, + ?base_url_for_canonical_header: String, + ?type: :GCS + ) -> void + + def to_hash: -> { + id: String, + bucket: String, + client_email: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :GCS, + base_url_for_canonical_header: String + } + end + + type azure_blob = + { + id: String, + account_name: String, + container: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :AZURE_BLOB, + base_url_for_canonical_header: String + } + + class AzureBlob < Imagekitio::Internal::Type::BaseModel + attr_accessor account_name: String + + attr_accessor container: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor prefix: String + + attr_accessor type: :AZURE_BLOB + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + account_name: String, + container: String, + include_canonical_header: bool, + name: String, + prefix: String, + ?base_url_for_canonical_header: String, + ?type: :AZURE_BLOB + ) -> void + + def to_hash: -> { + id: String, + account_name: String, + container: String, + include_canonical_header: bool, + name: String, + prefix: String, + type: :AZURE_BLOB, + base_url_for_canonical_header: String + } + end + + type akeneo_pim = + { + id: String, + base_url: String, + include_canonical_header: bool, + name: String, + type: :AKENEO_PIM, + base_url_for_canonical_header: String + } + + class AkeneoPim < Imagekitio::Internal::Type::BaseModel + attr_accessor base_url: String + + attr_accessor include_canonical_header: bool + + attr_accessor name: String + + attr_accessor type: :AKENEO_PIM + + attr_reader base_url_for_canonical_header: String? + + def base_url_for_canonical_header=: (String) -> String + + attr_accessor id: String + + def initialize: ( + id: String, + base_url: String, + include_canonical_header: bool, + name: String, + ?base_url_for_canonical_header: String, + ?type: :AKENEO_PIM + ) -> void + + def to_hash: -> { + id: String, + base_url: String, + include_canonical_header: bool, + name: String, + type: :AKENEO_PIM, + base_url_for_canonical_header: String + } + end + + def self?.variants: -> ::Array[Imagekitio::Models::Accounts::origin_response] + end + end + end +end diff --git a/sig/imagekitio/models/accounts/origin_update_params.rbs b/sig/imagekitio/models/accounts/origin_update_params.rbs new file mode 100644 index 00000000..ebbc257b --- /dev/null +++ b/sig/imagekitio/models/accounts/origin_update_params.rbs @@ -0,0 +1,30 @@ +module Imagekitio + module Models + module Accounts + type origin_update_params = + { origin_request: Imagekitio::Models::Accounts::origin_request } + & Imagekitio::Internal::Type::request_parameters + + class OriginUpdateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def origin_request: -> Imagekitio::Models::Accounts::origin_request + + def origin_request=: ( + Imagekitio::Models::Accounts::origin_request _ + ) -> Imagekitio::Models::Accounts::origin_request + + def initialize: ( + origin_request: Imagekitio::Models::Accounts::origin_request, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + origin_request: Imagekitio::Models::Accounts::origin_request, + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/url_endpoint_create_params.rbs b/sig/imagekitio/models/accounts/url_endpoint_create_params.rbs new file mode 100644 index 00000000..6ecd75d3 --- /dev/null +++ b/sig/imagekitio/models/accounts/url_endpoint_create_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Accounts + type url_endpoint_create_params = + { } & Imagekitio::Internal::Type::request_parameters + + class URLEndpointCreateParams < Imagekitio::Models::Accounts::URLEndpointRequest + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/url_endpoint_delete_params.rbs b/sig/imagekitio/models/accounts/url_endpoint_delete_params.rbs new file mode 100644 index 00000000..d4228eb4 --- /dev/null +++ b/sig/imagekitio/models/accounts/url_endpoint_delete_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Accounts + type url_endpoint_delete_params = + { } & Imagekitio::Internal::Type::request_parameters + + class URLEndpointDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/url_endpoint_get_params.rbs b/sig/imagekitio/models/accounts/url_endpoint_get_params.rbs new file mode 100644 index 00000000..91b94b41 --- /dev/null +++ b/sig/imagekitio/models/accounts/url_endpoint_get_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Accounts + type url_endpoint_get_params = + { } & Imagekitio::Internal::Type::request_parameters + + class URLEndpointGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/url_endpoint_list_params.rbs b/sig/imagekitio/models/accounts/url_endpoint_list_params.rbs new file mode 100644 index 00000000..2cc0e821 --- /dev/null +++ b/sig/imagekitio/models/accounts/url_endpoint_list_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Accounts + type url_endpoint_list_params = + { } & Imagekitio::Internal::Type::request_parameters + + class URLEndpointListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/url_endpoint_list_response.rbs b/sig/imagekitio/models/accounts/url_endpoint_list_response.rbs new file mode 100644 index 00000000..865283db --- /dev/null +++ b/sig/imagekitio/models/accounts/url_endpoint_list_response.rbs @@ -0,0 +1,10 @@ +module Imagekitio + module Models + module Accounts + type url_endpoint_list_response = + ::Array[Imagekitio::Accounts::URLEndpointResponse] + + URLEndpointListResponse: Imagekitio::Internal::Type::Converter + end + end +end diff --git a/sig/imagekitio/models/accounts/url_endpoint_request.rbs b/sig/imagekitio/models/accounts/url_endpoint_request.rbs new file mode 100644 index 00000000..e47408a2 --- /dev/null +++ b/sig/imagekitio/models/accounts/url_endpoint_request.rbs @@ -0,0 +1,97 @@ +module Imagekitio + module Models + module Accounts + type url_endpoint_request = + { + description: String, + origins: ::Array[String], + url_prefix: String, + url_rewriter: Imagekitio::Models::Accounts::URLEndpointRequest::url_rewriter + } + + class URLEndpointRequest < Imagekitio::Internal::Type::BaseModel + attr_accessor description: String + + attr_reader origins: ::Array[String]? + + def origins=: (::Array[String]) -> ::Array[String] + + attr_reader url_prefix: String? + + def url_prefix=: (String) -> String + + attr_reader url_rewriter: Imagekitio::Models::Accounts::URLEndpointRequest::url_rewriter? + + def url_rewriter=: ( + Imagekitio::Models::Accounts::URLEndpointRequest::url_rewriter + ) -> Imagekitio::Models::Accounts::URLEndpointRequest::url_rewriter + + def initialize: ( + description: String, + ?origins: ::Array[String], + ?url_prefix: String, + ?url_rewriter: Imagekitio::Models::Accounts::URLEndpointRequest::url_rewriter + ) -> void + + def to_hash: -> { + description: String, + origins: ::Array[String], + url_prefix: String, + url_rewriter: Imagekitio::Models::Accounts::URLEndpointRequest::url_rewriter + } + + type url_rewriter = + Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Cloudinary + | Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Imgix + | Imagekitio::Accounts::URLEndpointRequest::URLRewriter::Akamai + + module URLRewriter + extend Imagekitio::Internal::Type::Union + + type cloudinary = + { type: :CLOUDINARY, preserve_asset_delivery_types: bool } + + class Cloudinary < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :CLOUDINARY + + attr_reader preserve_asset_delivery_types: bool? + + def preserve_asset_delivery_types=: (bool) -> bool + + def initialize: ( + ?preserve_asset_delivery_types: bool, + ?type: :CLOUDINARY + ) -> void + + def to_hash: -> { + type: :CLOUDINARY, + preserve_asset_delivery_types: bool + } + end + + type imgix = { type: :IMGIX } + + class Imgix < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :IMGIX + + def initialize: (?type: :IMGIX) -> void + + def to_hash: -> { type: :IMGIX } + end + + type akamai = { type: :AKAMAI } + + class Akamai < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :AKAMAI + + def initialize: (?type: :AKAMAI) -> void + + def to_hash: -> { type: :AKAMAI } + end + + def self?.variants: -> ::Array[Imagekitio::Models::Accounts::URLEndpointRequest::url_rewriter] + end + end + end + end +end diff --git a/sig/imagekitio/models/accounts/url_endpoint_response.rbs b/sig/imagekitio/models/accounts/url_endpoint_response.rbs new file mode 100644 index 00000000..8187f432 --- /dev/null +++ b/sig/imagekitio/models/accounts/url_endpoint_response.rbs @@ -0,0 +1,96 @@ +module Imagekitio + module Models + module Accounts + type url_endpoint_response = + { + id: String, + description: String, + origins: ::Array[String], + url_prefix: String, + url_rewriter: Imagekitio::Models::Accounts::URLEndpointResponse::url_rewriter + } + + class URLEndpointResponse < Imagekitio::Internal::Type::BaseModel + attr_accessor description: String + + attr_accessor origins: ::Array[String] + + attr_accessor url_prefix: String + + attr_reader url_rewriter: Imagekitio::Models::Accounts::URLEndpointResponse::url_rewriter? + + def url_rewriter=: ( + Imagekitio::Models::Accounts::URLEndpointResponse::url_rewriter + ) -> Imagekitio::Models::Accounts::URLEndpointResponse::url_rewriter + + attr_accessor id: String + + def initialize: ( + id: String, + description: String, + origins: ::Array[String], + url_prefix: String, + ?url_rewriter: Imagekitio::Models::Accounts::URLEndpointResponse::url_rewriter + ) -> void + + def to_hash: -> { + id: String, + description: String, + origins: ::Array[String], + url_prefix: String, + url_rewriter: Imagekitio::Models::Accounts::URLEndpointResponse::url_rewriter + } + + type url_rewriter = + Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Cloudinary + | Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Imgix + | Imagekitio::Accounts::URLEndpointResponse::URLRewriter::Akamai + + module URLRewriter + extend Imagekitio::Internal::Type::Union + + type cloudinary = + { preserve_asset_delivery_types: bool, type: :CLOUDINARY } + + class Cloudinary < Imagekitio::Internal::Type::BaseModel + attr_accessor preserve_asset_delivery_types: bool + + attr_accessor type: :CLOUDINARY + + def initialize: ( + preserve_asset_delivery_types: bool, + ?type: :CLOUDINARY + ) -> void + + def to_hash: -> { + preserve_asset_delivery_types: bool, + type: :CLOUDINARY + } + end + + type imgix = { type: :IMGIX } + + class Imgix < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :IMGIX + + def initialize: (?type: :IMGIX) -> void + + def to_hash: -> { type: :IMGIX } + end + + type akamai = { type: :AKAMAI } + + class Akamai < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :AKAMAI + + def initialize: (?type: :AKAMAI) -> void + + def to_hash: -> { type: :AKAMAI } + end + + def self?.variants: -> ::Array[Imagekitio::Models::Accounts::URLEndpointResponse::url_rewriter] + end + end + end + end +end diff --git a/sig/imagekitio/models/accounts/url_endpoint_update_params.rbs b/sig/imagekitio/models/accounts/url_endpoint_update_params.rbs new file mode 100644 index 00000000..38b6c172 --- /dev/null +++ b/sig/imagekitio/models/accounts/url_endpoint_update_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Accounts + type url_endpoint_update_params = + { } & Imagekitio::Internal::Type::request_parameters + + class URLEndpointUpdateParams < Imagekitio::Models::Accounts::URLEndpointRequest + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/usage_get_params.rbs b/sig/imagekitio/models/accounts/usage_get_params.rbs new file mode 100644 index 00000000..35640101 --- /dev/null +++ b/sig/imagekitio/models/accounts/usage_get_params.rbs @@ -0,0 +1,30 @@ +module Imagekitio + module Models + module Accounts + type usage_get_params = + { end_date: Date, start_date: Date } + & Imagekitio::Internal::Type::request_parameters + + class UsageGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor end_date: Date + + attr_accessor start_date: Date + + def initialize: ( + end_date: Date, + start_date: Date, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + end_date: Date, + start_date: Date, + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/accounts/usage_get_response.rbs b/sig/imagekitio/models/accounts/usage_get_response.rbs new file mode 100644 index 00000000..9ff7b969 --- /dev/null +++ b/sig/imagekitio/models/accounts/usage_get_response.rbs @@ -0,0 +1,52 @@ +module Imagekitio + module Models + module Accounts + type usage_get_response = + { + bandwidth_bytes: Integer, + extension_units_count: Integer, + media_library_storage_bytes: Integer, + original_cache_storage_bytes: Integer, + video_processing_units_count: Integer + } + + class UsageGetResponse < Imagekitio::Internal::Type::BaseModel + attr_reader bandwidth_bytes: Integer? + + def bandwidth_bytes=: (Integer) -> Integer + + attr_reader extension_units_count: Integer? + + def extension_units_count=: (Integer) -> Integer + + attr_reader media_library_storage_bytes: Integer? + + def media_library_storage_bytes=: (Integer) -> Integer + + attr_reader original_cache_storage_bytes: Integer? + + def original_cache_storage_bytes=: (Integer) -> Integer + + attr_reader video_processing_units_count: Integer? + + def video_processing_units_count=: (Integer) -> Integer + + def initialize: ( + ?bandwidth_bytes: Integer, + ?extension_units_count: Integer, + ?media_library_storage_bytes: Integer, + ?original_cache_storage_bytes: Integer, + ?video_processing_units_count: Integer + ) -> void + + def to_hash: -> { + bandwidth_bytes: Integer, + extension_units_count: Integer, + media_library_storage_bytes: Integer, + original_cache_storage_bytes: Integer, + video_processing_units_count: Integer + } + end + end + end +end diff --git a/sig/imagekitio/models/asset_list_params.rbs b/sig/imagekitio/models/asset_list_params.rbs new file mode 100644 index 00000000..348abd0e --- /dev/null +++ b/sig/imagekitio/models/asset_list_params.rbs @@ -0,0 +1,138 @@ +module Imagekitio + module Models + type asset_list_params = + { + file_type: Imagekitio::Models::AssetListParams::file_type, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekitio::Models::AssetListParams::sort, + type: Imagekitio::Models::AssetListParams::type_ + } + & Imagekitio::Internal::Type::request_parameters + + class AssetListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_reader file_type: Imagekitio::Models::AssetListParams::file_type? + + def file_type=: ( + Imagekitio::Models::AssetListParams::file_type + ) -> Imagekitio::Models::AssetListParams::file_type + + attr_reader limit: Integer? + + def limit=: (Integer) -> Integer + + attr_reader path: String? + + def path=: (String) -> String + + attr_reader search_query: String? + + def search_query=: (String) -> String + + attr_reader skip: Integer? + + def skip=: (Integer) -> Integer + + attr_reader sort: Imagekitio::Models::AssetListParams::sort? + + def sort=: ( + Imagekitio::Models::AssetListParams::sort + ) -> Imagekitio::Models::AssetListParams::sort + + attr_reader type: Imagekitio::Models::AssetListParams::type_? + + def type=: ( + Imagekitio::Models::AssetListParams::type_ + ) -> Imagekitio::Models::AssetListParams::type_ + + def initialize: ( + ?file_type: Imagekitio::Models::AssetListParams::file_type, + ?limit: Integer, + ?path: String, + ?search_query: String, + ?skip: Integer, + ?sort: Imagekitio::Models::AssetListParams::sort, + ?type: Imagekitio::Models::AssetListParams::type_, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file_type: Imagekitio::Models::AssetListParams::file_type, + limit: Integer, + path: String, + search_query: String, + skip: Integer, + sort: Imagekitio::Models::AssetListParams::sort, + type: Imagekitio::Models::AssetListParams::type_, + request_options: Imagekitio::RequestOptions + } + + type file_type = :all | :image | :"non-image" + + module FileType + extend Imagekitio::Internal::Type::Enum + + ALL: :all + IMAGE: :image + NON_IMAGE: :"non-image" + + def self?.values: -> ::Array[Imagekitio::Models::AssetListParams::file_type] + end + + type sort = + :ASC_NAME + | :DESC_NAME + | :ASC_CREATED + | :DESC_CREATED + | :ASC_UPDATED + | :DESC_UPDATED + | :ASC_HEIGHT + | :DESC_HEIGHT + | :ASC_WIDTH + | :DESC_WIDTH + | :ASC_SIZE + | :DESC_SIZE + | :ASC_RELEVANCE + | :DESC_RELEVANCE + + module Sort + extend Imagekitio::Internal::Type::Enum + + ASC_NAME: :ASC_NAME + DESC_NAME: :DESC_NAME + ASC_CREATED: :ASC_CREATED + DESC_CREATED: :DESC_CREATED + ASC_UPDATED: :ASC_UPDATED + DESC_UPDATED: :DESC_UPDATED + ASC_HEIGHT: :ASC_HEIGHT + DESC_HEIGHT: :DESC_HEIGHT + ASC_WIDTH: :ASC_WIDTH + DESC_WIDTH: :DESC_WIDTH + ASC_SIZE: :ASC_SIZE + DESC_SIZE: :DESC_SIZE + ASC_RELEVANCE: :ASC_RELEVANCE + DESC_RELEVANCE: :DESC_RELEVANCE + + def self?.values: -> ::Array[Imagekitio::Models::AssetListParams::sort] + end + + type type_ = :file | :"file-version" | :folder | :all + + module Type + extend Imagekitio::Internal::Type::Enum + + FILE: :file + FILE_VERSION: :"file-version" + FOLDER: :folder + ALL: :all + + def self?.values: -> ::Array[Imagekitio::Models::AssetListParams::type_] + end + end + end +end diff --git a/sig/imagekitio/models/asset_list_response.rbs b/sig/imagekitio/models/asset_list_response.rbs new file mode 100644 index 00000000..31964de8 --- /dev/null +++ b/sig/imagekitio/models/asset_list_response.rbs @@ -0,0 +1,16 @@ +module Imagekitio + module Models + type asset_list_response_item = Imagekitio::Folder | Imagekitio::File + + module AssetListResponseItem + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::asset_list_response_item] + end + + type asset_list_response = + ::Array[Imagekitio::Models::asset_list_response_item] + + AssetListResponse: Imagekitio::Internal::Type::Converter + end +end diff --git a/sig/imagekitio/models/base_overlay.rbs b/sig/imagekitio/models/base_overlay.rbs new file mode 100644 index 00000000..04461b00 --- /dev/null +++ b/sig/imagekitio/models/base_overlay.rbs @@ -0,0 +1,31 @@ +module Imagekitio + module Models + type base_overlay = + { + position: Imagekitio::OverlayPosition, + timing: Imagekitio::OverlayTiming + } + + class BaseOverlay < Imagekitio::Internal::Type::BaseModel + attr_reader position: Imagekitio::OverlayPosition? + + def position=: ( + Imagekitio::OverlayPosition + ) -> Imagekitio::OverlayPosition + + attr_reader timing: Imagekitio::OverlayTiming? + + def timing=: (Imagekitio::OverlayTiming) -> Imagekitio::OverlayTiming + + def initialize: ( + ?position: Imagekitio::OverlayPosition, + ?timing: Imagekitio::OverlayTiming + ) -> void + + def to_hash: -> { + position: Imagekitio::OverlayPosition, + timing: Imagekitio::OverlayTiming + } + end + end +end diff --git a/sig/imagekitio/models/base_webhook_event.rbs b/sig/imagekitio/models/base_webhook_event.rbs new file mode 100644 index 00000000..710a4e77 --- /dev/null +++ b/sig/imagekitio/models/base_webhook_event.rbs @@ -0,0 +1,15 @@ +module Imagekitio + module Models + type base_webhook_event = { id: String, type: String } + + class BaseWebhookEvent < Imagekitio::Internal::Type::BaseModel + attr_accessor id: String + + attr_accessor type: String + + def initialize: (id: String, type: String) -> void + + def to_hash: -> { id: String, type: String } + end + end +end diff --git a/sig/imagekitio/models/beta/v2/file_upload_params.rbs b/sig/imagekitio/models/beta/v2/file_upload_params.rbs new file mode 100644 index 00000000..a7f959ca --- /dev/null +++ b/sig/imagekitio/models/beta/v2/file_upload_params.rbs @@ -0,0 +1,310 @@ +module Imagekitio + module Models + module Beta + module V2 + type file_upload_params = + { + file: Imagekitio::Internal::file_input, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: ::Hash[Symbol, top], + description: String, + extensions: Imagekitio::Models::extensions, + folder: String, + is_private_file: bool, + is_published: bool, + overwrite_ai_tags: bool, + overwrite_custom_metadata: bool, + overwrite_file: bool, + overwrite_tags: bool, + response_fields: ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::response_field], + tags: ::Array[String], + transformation: Imagekitio::Beta::V2::FileUploadParams::Transformation, + use_unique_file_name: bool, + webhook_url: String + } + & Imagekitio::Internal::Type::request_parameters + + class FileUploadParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor file: Imagekitio::Internal::file_input + + attr_accessor file_name: String + + attr_reader token: String? + + def token=: (String) -> String + + attr_reader checks: String? + + def checks=: (String) -> String + + attr_reader custom_coordinates: String? + + def custom_coordinates=: (String) -> String + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader extensions: Imagekitio::Models::extensions? + + def extensions=: ( + Imagekitio::Models::extensions + ) -> Imagekitio::Models::extensions + + attr_reader folder: String? + + def folder=: (String) -> String + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader overwrite_ai_tags: bool? + + def overwrite_ai_tags=: (bool) -> bool + + attr_reader overwrite_custom_metadata: bool? + + def overwrite_custom_metadata=: (bool) -> bool + + attr_reader overwrite_file: bool? + + def overwrite_file=: (bool) -> bool + + attr_reader overwrite_tags: bool? + + def overwrite_tags=: (bool) -> bool + + attr_reader response_fields: ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::response_field]? + + def response_fields=: ( + ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::response_field] + ) -> ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::response_field] + + attr_reader tags: ::Array[String]? + + def tags=: (::Array[String]) -> ::Array[String] + + attr_reader transformation: Imagekitio::Beta::V2::FileUploadParams::Transformation? + + def transformation=: ( + Imagekitio::Beta::V2::FileUploadParams::Transformation + ) -> Imagekitio::Beta::V2::FileUploadParams::Transformation + + attr_reader use_unique_file_name: bool? + + def use_unique_file_name=: (bool) -> bool + + attr_reader webhook_url: String? + + def webhook_url=: (String) -> String + + def initialize: ( + file: Imagekitio::Internal::file_input, + file_name: String, + ?token: String, + ?checks: String, + ?custom_coordinates: String, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?extensions: Imagekitio::Models::extensions, + ?folder: String, + ?is_private_file: bool, + ?is_published: bool, + ?overwrite_ai_tags: bool, + ?overwrite_custom_metadata: bool, + ?overwrite_file: bool, + ?overwrite_tags: bool, + ?response_fields: ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::response_field], + ?tags: ::Array[String], + ?transformation: Imagekitio::Beta::V2::FileUploadParams::Transformation, + ?use_unique_file_name: bool, + ?webhook_url: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file: Imagekitio::Internal::file_input, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: ::Hash[Symbol, top], + description: String, + extensions: Imagekitio::Models::extensions, + folder: String, + is_private_file: bool, + is_published: bool, + overwrite_ai_tags: bool, + overwrite_custom_metadata: bool, + overwrite_file: bool, + overwrite_tags: bool, + response_fields: ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::response_field], + tags: ::Array[String], + transformation: Imagekitio::Beta::V2::FileUploadParams::Transformation, + use_unique_file_name: bool, + webhook_url: String, + request_options: Imagekitio::RequestOptions + } + + type response_field = + :tags + | :customCoordinates + | :isPrivateFile + | :embeddedMetadata + | :isPublished + | :customMetadata + | :metadata + | :selectedFieldsSchema + + module ResponseField + extend Imagekitio::Internal::Type::Enum + + TAGS: :tags + CUSTOM_COORDINATES: :customCoordinates + IS_PRIVATE_FILE: :isPrivateFile + EMBEDDED_METADATA: :embeddedMetadata + IS_PUBLISHED: :isPublished + CUSTOM_METADATA: :customMetadata + METADATA: :metadata + SELECTED_FIELDS_SCHEMA: :selectedFieldsSchema + + def self?.values: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::response_field] + end + + type transformation = + { + post: ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::post], + pre: String + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_reader post: ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::post]? + + def post=: ( + ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::post] + ) -> ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::post] + + attr_reader pre: String? + + def pre=: (String) -> String + + def initialize: ( + ?post: ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::post], + ?pre: String + ) -> void + + def to_hash: -> { + post: ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::post], + pre: String + } + + type post = + Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Transformation + | Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::GifToVideo + | Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Thumbnail + | Imagekitio::Beta::V2::FileUploadParams::Transformation::Post::Abs + + module Post + extend Imagekitio::Internal::Type::Union + + type transformation = { type: :transformation, value: String } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :transformation + + attr_accessor value: String + + def initialize: (value: String, ?type: :transformation) -> void + + def to_hash: -> { type: :transformation, value: String } + end + + type gif_to_video = { type: :"gif-to-video", value: String } + + class GifToVideo < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :"gif-to-video" + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: (?value: String, ?type: :"gif-to-video") -> void + + def to_hash: -> { type: :"gif-to-video", value: String } + end + + type thumbnail = { type: :thumbnail, value: String } + + class Thumbnail < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :thumbnail + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: (?value: String, ?type: :thumbnail) -> void + + def to_hash: -> { type: :thumbnail, value: String } + end + + type abs = + { + protocol: Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol, + type: :abs, + value: String + } + + class Abs < Imagekitio::Internal::Type::BaseModel + attr_accessor protocol: Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol + + attr_accessor type: :abs + + attr_accessor value: String + + def initialize: ( + protocol: Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol, + value: String, + ?type: :abs + ) -> void + + def to_hash: -> { + protocol: Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol, + type: :abs, + value: String + } + + type protocol = :hls | :dash + + module Protocol + extend Imagekitio::Internal::Type::Enum + + HLS: :hls + DASH: :dash + + def self?.values: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::Post::Abs::protocol] + end + end + + def self?.variants: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::Transformation::post] + end + end + end + end + end + end +end diff --git a/sig/imagekitio/models/beta/v2/file_upload_response.rbs b/sig/imagekitio/models/beta/v2/file_upload_response.rbs new file mode 100644 index 00000000..3a4f392d --- /dev/null +++ b/sig/imagekitio/models/beta/v2/file_upload_response.rbs @@ -0,0 +1,487 @@ +module Imagekitio + module Models + module Beta + module V2 + type file_upload_response = + { + ai_tags: ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekitio::Metadata, + name: String, + selected_fields_schema: ::Hash[Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema], + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + + class FileUploadResponse < Imagekitio::Internal::Type::BaseModel + attr_accessor ai_tags: ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::AITag]? + + attr_reader audio_codec: String? + + def audio_codec=: (String) -> String + + attr_reader bit_rate: Integer? + + def bit_rate=: (Integer) -> Integer + + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader duration: Integer? + + def duration=: (Integer) -> Integer + + attr_reader embedded_metadata: ::Hash[Symbol, top]? + + def embedded_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader extension_status: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus? + + def extension_status=: ( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus + + attr_reader file_id: String? + + def file_id=: (String) -> String + + attr_reader file_path: String? + + def file_path=: (String) -> String + + attr_reader file_type: String? + + def file_type=: (String) -> String + + attr_reader height: Float? + + def height=: (Float) -> Float + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader metadata: Imagekitio::Metadata? + + def metadata=: (Imagekitio::Metadata) -> Imagekitio::Metadata + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader selected_fields_schema: ::Hash[Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema]? + + def selected_fields_schema=: ( + ::Hash[Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema] + ) -> ::Hash[Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema] + + attr_reader size: Float? + + def size=: (Float) -> Float + + attr_accessor tags: ::Array[String]? + + attr_reader thumbnail_url: String? + + def thumbnail_url=: (String) -> String + + attr_reader url: String? + + def url=: (String) -> String + + attr_reader version_info: Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo? + + def version_info=: ( + Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo + + attr_reader video_codec: String? + + def video_codec=: (String) -> String + + attr_reader width: Float? + + def width=: (Float) -> Float + + def initialize: ( + ?ai_tags: ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::AITag]?, + ?audio_codec: String, + ?bit_rate: Integer, + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?duration: Integer, + ?embedded_metadata: ::Hash[Symbol, top], + ?extension_status: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + ?file_id: String, + ?file_path: String, + ?file_type: String, + ?height: Float, + ?is_private_file: bool, + ?is_published: bool, + ?metadata: Imagekitio::Metadata, + ?name: String, + ?selected_fields_schema: ::Hash[Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema], + ?size: Float, + ?tags: ::Array[String]?, + ?thumbnail_url: String, + ?url: String, + ?version_info: Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo, + ?video_codec: String, + ?width: Float + ) -> void + + def to_hash: -> { + ai_tags: ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekitio::Metadata, + name: String, + selected_fields_schema: ::Hash[Symbol, Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema], + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + + type ai_tag = { confidence: Float, name: String, source: String } + + class AITag < Imagekitio::Internal::Type::BaseModel + attr_reader confidence: Float? + + def confidence=: (Float) -> Float + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader source: String? + + def source=: (String) -> String + + def initialize: ( + ?confidence: Float, + ?name: String, + ?source: String + ) -> void + + def to_hash: -> { confidence: Float, name: String, source: String } + end + + type extension_status = + { + ai_auto_description: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + } + + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + attr_reader ai_auto_description: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description? + + def ai_auto_description=: ( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description + + attr_reader aws_auto_tagging: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging? + + def aws_auto_tagging=: ( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging + + attr_reader google_auto_tagging: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging? + + def google_auto_tagging=: ( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging + + attr_reader remove_bg: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg? + + def remove_bg=: ( + Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + + def initialize: ( + ?ai_auto_description: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description, + ?aws_auto_tagging: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + ?google_auto_tagging: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging, + ?remove_bg: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + ) -> void + + def to_hash: -> { + ai_auto_description: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg + } + + type ai_auto_description = :success | :pending | :failed + + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::ai_auto_description] + end + + type aws_auto_tagging = :success | :pending | :failed + + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::aws_auto_tagging] + end + + type google_auto_tagging = :success | :pending | :failed + + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::google_auto_tagging] + end + + type remove_bg = :success | :pending | :failed + + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus::remove_bg] + end + end + + type selected_fields_schema = + { + type: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::type_, + default_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::max_value, + min_length: Float, + min_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::min_value, + read_only: bool, + select_options: ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::select_option], + select_options_truncated: bool + } + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::type_ + + attr_reader default_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::default_value? + + def default_value=: ( + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::default_value + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::max_value? + + def max_value=: ( + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::max_value + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::min_value? + + def min_value=: ( + Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::min_value + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::min_value + + attr_reader read_only: bool? + + def read_only=: (bool) -> bool + + attr_reader select_options: ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::select_option]? + + def select_options=: ( + ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::select_option] + ) -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::select_option] + + attr_reader select_options_truncated: bool? + + def select_options_truncated=: (bool) -> bool + + def initialize: ( + type: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::type_, + ?default_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::max_value, + ?min_length: Float, + ?min_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::min_value, + ?read_only: bool, + ?select_options: ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::select_option], + ?select_options_truncated: bool + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::type_, + default_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::max_value, + min_length: Float, + min_value: Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::min_value, + read_only: bool, + select_options: ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::select_option], + select_options_truncated: bool + } + + type type_ = + :Text + | :Textarea + | :Number + | :Date + | :Boolean + | :SingleSelect + | :MultiSelect + + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT: :Text + TEXTAREA: :Textarea + NUMBER: :Number + DATE: :Date + BOOLEAN: :Boolean + SINGLE_SELECT: :SingleSelect + MULTI_SELECT: :MultiSelect + + def self?.values: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::type_] + end + + type default_value = + String + | Float + | bool + | ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::mixed] + + module DefaultValue + extend Imagekitio::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::default_value] + + MixedArray: Imagekitio::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema::select_option] + end + end + + type version_info = { id: String, name: String } + + class VersionInfo < Imagekitio::Internal::Type::BaseModel + attr_reader id: String? + + def id=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + def initialize: (?id: String, ?name: String) -> void + + def to_hash: -> { id: String, name: String } + end + end + end + end + end +end diff --git a/sig/imagekitio/models/cache/invalidation_create_params.rbs b/sig/imagekitio/models/cache/invalidation_create_params.rbs new file mode 100644 index 00000000..32f5df91 --- /dev/null +++ b/sig/imagekitio/models/cache/invalidation_create_params.rbs @@ -0,0 +1,25 @@ +module Imagekitio + module Models + module Cache + type invalidation_create_params = + { url: String } & Imagekitio::Internal::Type::request_parameters + + class InvalidationCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor url: String + + def initialize: ( + url: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + url: String, + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/cache/invalidation_create_response.rbs b/sig/imagekitio/models/cache/invalidation_create_response.rbs new file mode 100644 index 00000000..c0925e61 --- /dev/null +++ b/sig/imagekitio/models/cache/invalidation_create_response.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Cache + type invalidation_create_response = { request_id: String } + + class InvalidationCreateResponse < Imagekitio::Internal::Type::BaseModel + attr_reader request_id: String? + + def request_id=: (String) -> String + + def initialize: (?request_id: String) -> void + + def to_hash: -> { request_id: String } + end + end + end +end diff --git a/sig/imagekitio/models/cache/invalidation_get_params.rbs b/sig/imagekitio/models/cache/invalidation_get_params.rbs new file mode 100644 index 00000000..663422da --- /dev/null +++ b/sig/imagekitio/models/cache/invalidation_get_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Cache + type invalidation_get_params = + { } & Imagekitio::Internal::Type::request_parameters + + class InvalidationGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/cache/invalidation_get_response.rbs b/sig/imagekitio/models/cache/invalidation_get_response.rbs new file mode 100644 index 00000000..9e74e972 --- /dev/null +++ b/sig/imagekitio/models/cache/invalidation_get_response.rbs @@ -0,0 +1,35 @@ +module Imagekitio + module Models + module Cache + type invalidation_get_response = + { status: Imagekitio::Models::Cache::InvalidationGetResponse::status } + + class InvalidationGetResponse < Imagekitio::Internal::Type::BaseModel + attr_reader status: Imagekitio::Models::Cache::InvalidationGetResponse::status? + + def status=: ( + Imagekitio::Models::Cache::InvalidationGetResponse::status + ) -> Imagekitio::Models::Cache::InvalidationGetResponse::status + + def initialize: ( + ?status: Imagekitio::Models::Cache::InvalidationGetResponse::status + ) -> void + + def to_hash: -> { + status: Imagekitio::Models::Cache::InvalidationGetResponse::status + } + + type status = :Pending | :Completed + + module Status + extend Imagekitio::Internal::Type::Enum + + PENDING: :Pending + COMPLETED: :Completed + + def self?.values: -> ::Array[Imagekitio::Models::Cache::InvalidationGetResponse::status] + end + end + end + end +end diff --git a/sig/imagekitio/models/custom_metadata_field.rbs b/sig/imagekitio/models/custom_metadata_field.rbs new file mode 100644 index 00000000..3c2071f5 --- /dev/null +++ b/sig/imagekitio/models/custom_metadata_field.rbs @@ -0,0 +1,178 @@ +module Imagekitio + module Models + type custom_metadata_field = + { + id: String, + label: String, + name: String, + schema: Imagekitio::CustomMetadataField::Schema + } + + class CustomMetadataField < Imagekitio::Internal::Type::BaseModel + attr_accessor id: String + + attr_accessor label: String + + attr_accessor name: String + + attr_accessor schema: Imagekitio::CustomMetadataField::Schema + + def initialize: ( + id: String, + label: String, + name: String, + schema: Imagekitio::CustomMetadataField::Schema + ) -> void + + def to_hash: -> { + id: String, + label: String, + name: String, + schema: Imagekitio::CustomMetadataField::Schema + } + + type schema = + { + type: Imagekitio::Models::CustomMetadataField::Schema::type_, + default_value: Imagekitio::Models::CustomMetadataField::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::CustomMetadataField::Schema::max_value, + min_length: Float, + min_value: Imagekitio::Models::CustomMetadataField::Schema::min_value, + select_options: ::Array[Imagekitio::Models::CustomMetadataField::Schema::select_option] + } + + class Schema < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::CustomMetadataField::Schema::type_ + + attr_reader default_value: Imagekitio::Models::CustomMetadataField::Schema::default_value? + + def default_value=: ( + Imagekitio::Models::CustomMetadataField::Schema::default_value + ) -> Imagekitio::Models::CustomMetadataField::Schema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekitio::Models::CustomMetadataField::Schema::max_value? + + def max_value=: ( + Imagekitio::Models::CustomMetadataField::Schema::max_value + ) -> Imagekitio::Models::CustomMetadataField::Schema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekitio::Models::CustomMetadataField::Schema::min_value? + + def min_value=: ( + Imagekitio::Models::CustomMetadataField::Schema::min_value + ) -> Imagekitio::Models::CustomMetadataField::Schema::min_value + + attr_reader select_options: ::Array[Imagekitio::Models::CustomMetadataField::Schema::select_option]? + + def select_options=: ( + ::Array[Imagekitio::Models::CustomMetadataField::Schema::select_option] + ) -> ::Array[Imagekitio::Models::CustomMetadataField::Schema::select_option] + + def initialize: ( + type: Imagekitio::Models::CustomMetadataField::Schema::type_, + ?default_value: Imagekitio::Models::CustomMetadataField::Schema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekitio::Models::CustomMetadataField::Schema::max_value, + ?min_length: Float, + ?min_value: Imagekitio::Models::CustomMetadataField::Schema::min_value, + ?select_options: ::Array[Imagekitio::Models::CustomMetadataField::Schema::select_option] + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::CustomMetadataField::Schema::type_, + default_value: Imagekitio::Models::CustomMetadataField::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::CustomMetadataField::Schema::max_value, + min_length: Float, + min_value: Imagekitio::Models::CustomMetadataField::Schema::min_value, + select_options: ::Array[Imagekitio::Models::CustomMetadataField::Schema::select_option] + } + + type type_ = + :Text + | :Textarea + | :Number + | :Date + | :Boolean + | :SingleSelect + | :MultiSelect + + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT: :Text + TEXTAREA: :Textarea + NUMBER: :Number + DATE: :Date + BOOLEAN: :Boolean + SINGLE_SELECT: :SingleSelect + MULTI_SELECT: :MultiSelect + + def self?.values: -> ::Array[Imagekitio::Models::CustomMetadataField::Schema::type_] + end + + type default_value = + String + | Float + | bool + | ::Array[Imagekitio::Models::CustomMetadataField::Schema::DefaultValue::mixed] + + module DefaultValue + extend Imagekitio::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataField::Schema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataField::Schema::default_value] + + MixedArray: Imagekitio::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataField::Schema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataField::Schema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataField::Schema::select_option] + end + end + end + end +end diff --git a/sig/imagekitio/models/custom_metadata_field_create_params.rbs b/sig/imagekitio/models/custom_metadata_field_create_params.rbs new file mode 100644 index 00000000..78f2ab99 --- /dev/null +++ b/sig/imagekitio/models/custom_metadata_field_create_params.rbs @@ -0,0 +1,179 @@ +module Imagekitio + module Models + type custom_metadata_field_create_params = + { + label: String, + name: String, + schema: Imagekitio::CustomMetadataFieldCreateParams::Schema + } + & Imagekitio::Internal::Type::request_parameters + + class CustomMetadataFieldCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor label: String + + attr_accessor name: String + + attr_accessor schema: Imagekitio::CustomMetadataFieldCreateParams::Schema + + def initialize: ( + label: String, + name: String, + schema: Imagekitio::CustomMetadataFieldCreateParams::Schema, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + label: String, + name: String, + schema: Imagekitio::CustomMetadataFieldCreateParams::Schema, + request_options: Imagekitio::RequestOptions + } + + type schema = + { + type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_, + default_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value, + min_length: Float, + min_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value, + select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + } + + class Schema < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_ + + attr_reader default_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value? + + def default_value=: ( + Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value + ) -> Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value? + + def max_value=: ( + Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value + ) -> Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value? + + def min_value=: ( + Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value + ) -> Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value + + attr_reader select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option]? + + def select_options=: ( + ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + ) -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + + def initialize: ( + type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_, + ?default_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value, + ?min_length: Float, + ?min_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value, + ?select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_, + default_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value, + min_length: Float, + min_value: Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value, + select_options: ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + } + + type type_ = + :Text + | :Textarea + | :Number + | :Date + | :Boolean + | :SingleSelect + | :MultiSelect + + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT: :Text + TEXTAREA: :Textarea + NUMBER: :Number + DATE: :Date + BOOLEAN: :Boolean + SINGLE_SELECT: :SingleSelect + MULTI_SELECT: :MultiSelect + + def self?.values: -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::type_] + end + + type default_value = + String + | Float + | bool + | ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::DefaultValue::mixed] + + module DefaultValue + extend Imagekitio::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::default_value] + + MixedArray: Imagekitio::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldCreateParams::Schema::select_option] + end + end + end + end +end diff --git a/sig/imagekitio/models/custom_metadata_field_delete_params.rbs b/sig/imagekitio/models/custom_metadata_field_delete_params.rbs new file mode 100644 index 00000000..7b31c289 --- /dev/null +++ b/sig/imagekitio/models/custom_metadata_field_delete_params.rbs @@ -0,0 +1,15 @@ +module Imagekitio + module Models + type custom_metadata_field_delete_params = + { } & Imagekitio::Internal::Type::request_parameters + + class CustomMetadataFieldDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end +end diff --git a/sig/imagekitio/models/custom_metadata_field_delete_response.rbs b/sig/imagekitio/models/custom_metadata_field_delete_response.rbs new file mode 100644 index 00000000..16676be0 --- /dev/null +++ b/sig/imagekitio/models/custom_metadata_field_delete_response.rbs @@ -0,0 +1,11 @@ +module Imagekitio + module Models + type custom_metadata_field_delete_response = { } + + class CustomMetadataFieldDeleteResponse < Imagekitio::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekitio/models/custom_metadata_field_list_params.rbs b/sig/imagekitio/models/custom_metadata_field_list_params.rbs new file mode 100644 index 00000000..86e220d5 --- /dev/null +++ b/sig/imagekitio/models/custom_metadata_field_list_params.rbs @@ -0,0 +1,32 @@ +module Imagekitio + module Models + type custom_metadata_field_list_params = + { folder_path: String, include_deleted: bool } + & Imagekitio::Internal::Type::request_parameters + + class CustomMetadataFieldListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_reader folder_path: String? + + def folder_path=: (String) -> String + + attr_reader include_deleted: bool? + + def include_deleted=: (bool) -> bool + + def initialize: ( + ?folder_path: String, + ?include_deleted: bool, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + folder_path: String, + include_deleted: bool, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/custom_metadata_field_list_response.rbs b/sig/imagekitio/models/custom_metadata_field_list_response.rbs new file mode 100644 index 00000000..08b6b60b --- /dev/null +++ b/sig/imagekitio/models/custom_metadata_field_list_response.rbs @@ -0,0 +1,8 @@ +module Imagekitio + module Models + type custom_metadata_field_list_response = + ::Array[Imagekitio::CustomMetadataField] + + CustomMetadataFieldListResponse: Imagekitio::Internal::Type::Converter + end +end diff --git a/sig/imagekitio/models/custom_metadata_field_update_params.rbs b/sig/imagekitio/models/custom_metadata_field_update_params.rbs new file mode 100644 index 00000000..0c6e9477 --- /dev/null +++ b/sig/imagekitio/models/custom_metadata_field_update_params.rbs @@ -0,0 +1,152 @@ +module Imagekitio + module Models + type custom_metadata_field_update_params = + { + label: String, + schema: Imagekitio::CustomMetadataFieldUpdateParams::Schema + } + & Imagekitio::Internal::Type::request_parameters + + class CustomMetadataFieldUpdateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_reader label: String? + + def label=: (String) -> String + + attr_reader schema: Imagekitio::CustomMetadataFieldUpdateParams::Schema? + + def schema=: ( + Imagekitio::CustomMetadataFieldUpdateParams::Schema + ) -> Imagekitio::CustomMetadataFieldUpdateParams::Schema + + def initialize: ( + ?label: String, + ?schema: Imagekitio::CustomMetadataFieldUpdateParams::Schema, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + label: String, + schema: Imagekitio::CustomMetadataFieldUpdateParams::Schema, + request_options: Imagekitio::RequestOptions + } + + type schema = + { + default_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::max_value, + min_length: Float, + min_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::min_value, + select_options: ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + } + + class Schema < Imagekitio::Internal::Type::BaseModel + attr_reader default_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::default_value? + + def default_value=: ( + Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::default_value + ) -> Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::max_value? + + def max_value=: ( + Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::max_value + ) -> Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::min_value? + + def min_value=: ( + Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::min_value + ) -> Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::min_value + + attr_reader select_options: ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::select_option]? + + def select_options=: ( + ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + ) -> ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + + def initialize: ( + ?default_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::max_value, + ?min_length: Float, + ?min_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::min_value, + ?select_options: ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + ) -> void + + def to_hash: -> { + default_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::max_value, + min_length: Float, + min_value: Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::min_value, + select_options: ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + } + + type default_value = + String + | Float + | bool + | ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::DefaultValue::mixed] + + module DefaultValue + extend Imagekitio::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::default_value] + + MixedArray: Imagekitio::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::CustomMetadataFieldUpdateParams::Schema::select_option] + end + end + end + end +end diff --git a/sig/imagekitio/models/extensions.rbs b/sig/imagekitio/models/extensions.rbs new file mode 100644 index 00000000..00a0c4c9 --- /dev/null +++ b/sig/imagekitio/models/extensions.rbs @@ -0,0 +1,132 @@ +module Imagekitio + module Models + type extension_item = + ExtensionItem::RemoveBg + | ExtensionItem::AIAutoDescription + | ExtensionItem::AutoTaggingExtension + + module ExtensionItem + extend Imagekitio::Internal::Type::Union + + type remove_bg = + { + name: :"remove-bg", + options: RemoveBg::Options + } + + class RemoveBg < Imagekitio::Internal::Type::BaseModel + attr_accessor name: :"remove-bg" + + attr_reader options: RemoveBg::Options? + + def options=: ( + RemoveBg::Options + ) -> RemoveBg::Options + + def initialize: ( + ?options: RemoveBg::Options, + ?name: :"remove-bg" + ) -> void + + def to_hash: -> { + name: :"remove-bg", + options: RemoveBg::Options + } + + type options = + { + add_shadow: bool, + bg_color: String, + bg_image_url: String, + semitransparency: bool + } + + class Options < Imagekitio::Internal::Type::BaseModel + attr_reader add_shadow: bool? + + def add_shadow=: (bool) -> bool + + attr_reader bg_color: String? + + def bg_color=: (String) -> String + + attr_reader bg_image_url: String? + + def bg_image_url=: (String) -> String + + attr_reader semitransparency: bool? + + def semitransparency=: (bool) -> bool + + def initialize: ( + ?add_shadow: bool, + ?bg_color: String, + ?bg_image_url: String, + ?semitransparency: bool + ) -> void + + def to_hash: -> { + add_shadow: bool, + bg_color: String, + bg_image_url: String, + semitransparency: bool + } + end + end + + type auto_tagging_extension = + { + max_tags: Integer, + min_confidence: Integer, + name: Imagekitio::Models::ExtensionItem::AutoTaggingExtension::name_ + } + + class AutoTaggingExtension < Imagekitio::Internal::Type::BaseModel + attr_accessor max_tags: Integer + + attr_accessor min_confidence: Integer + + attr_accessor name: Imagekitio::Models::ExtensionItem::AutoTaggingExtension::name_ + + def initialize: ( + max_tags: Integer, + min_confidence: Integer, + name: Imagekitio::Models::ExtensionItem::AutoTaggingExtension::name_ + ) -> void + + def to_hash: -> { + max_tags: Integer, + min_confidence: Integer, + name: Imagekitio::Models::ExtensionItem::AutoTaggingExtension::name_ + } + + type name_ = :"google-auto-tagging" | :"aws-auto-tagging" + + module Name + extend Imagekitio::Internal::Type::Enum + + GOOGLE_AUTO_TAGGING: :"google-auto-tagging" + AWS_AUTO_TAGGING: :"aws-auto-tagging" + + def self?.values: -> ::Array[Imagekitio::Models::ExtensionItem::AutoTaggingExtension::name_] + end + end + + type ai_auto_description = { name: :"ai-auto-description" } + + class AIAutoDescription < Imagekitio::Internal::Type::BaseModel + attr_accessor name: :"ai-auto-description" + + def initialize: (?name: :"ai-auto-description") -> void + + def to_hash: -> { name: :"ai-auto-description" } + end + + def self?.variants: -> ::Array[Imagekitio::Models::extension_item] + end + + type extensions = ::Array[Imagekitio::Models::extension_item] + + Extensions: Imagekitio::Internal::Type::Converter + end +end diff --git a/sig/imagekitio/models/file.rbs b/sig/imagekitio/models/file.rbs new file mode 100644 index 00000000..c84cdb72 --- /dev/null +++ b/sig/imagekitio/models/file.rbs @@ -0,0 +1,384 @@ +module Imagekitio + module Models + type file = + { + ai_tags: ::Array[Imagekitio::File::AITag]?, + created_at: Time, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + file_id: String, + file_path: String, + file_type: String, + has_alpha: bool, + height: Float, + is_private_file: bool, + is_published: bool, + mime: String, + name: String, + selected_fields_schema: ::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema], + size: Float, + tags: ::Array[String]?, + thumbnail: String, + type: Imagekitio::Models::File::type_, + updated_at: Time, + url: String, + version_info: Imagekitio::File::VersionInfo, + width: Float + } + + class File < Imagekitio::Internal::Type::BaseModel + attr_accessor ai_tags: ::Array[Imagekitio::File::AITag]? + + attr_reader created_at: Time? + + def created_at=: (Time) -> Time + + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader file_id: String? + + def file_id=: (String) -> String + + attr_reader file_path: String? + + def file_path=: (String) -> String + + attr_reader file_type: String? + + def file_type=: (String) -> String + + attr_reader has_alpha: bool? + + def has_alpha=: (bool) -> bool + + attr_reader height: Float? + + def height=: (Float) -> Float + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader mime: String? + + def mime=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader selected_fields_schema: ::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema]? + + def selected_fields_schema=: ( + ::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema] + ) -> ::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema] + + attr_reader size: Float? + + def size=: (Float) -> Float + + attr_accessor tags: ::Array[String]? + + attr_reader thumbnail: String? + + def thumbnail=: (String) -> String + + attr_reader type: Imagekitio::Models::File::type_? + + def type=: ( + Imagekitio::Models::File::type_ + ) -> Imagekitio::Models::File::type_ + + attr_reader updated_at: Time? + + def updated_at=: (Time) -> Time + + attr_reader url: String? + + def url=: (String) -> String + + attr_reader version_info: Imagekitio::File::VersionInfo? + + def version_info=: ( + Imagekitio::File::VersionInfo + ) -> Imagekitio::File::VersionInfo + + attr_reader width: Float? + + def width=: (Float) -> Float + + def initialize: ( + ?ai_tags: ::Array[Imagekitio::File::AITag]?, + ?created_at: Time, + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?file_id: String, + ?file_path: String, + ?file_type: String, + ?has_alpha: bool, + ?height: Float, + ?is_private_file: bool, + ?is_published: bool, + ?mime: String, + ?name: String, + ?selected_fields_schema: ::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema], + ?size: Float, + ?tags: ::Array[String]?, + ?thumbnail: String, + ?type: Imagekitio::Models::File::type_, + ?updated_at: Time, + ?url: String, + ?version_info: Imagekitio::File::VersionInfo, + ?width: Float + ) -> void + + def to_hash: -> { + ai_tags: ::Array[Imagekitio::File::AITag]?, + created_at: Time, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + file_id: String, + file_path: String, + file_type: String, + has_alpha: bool, + height: Float, + is_private_file: bool, + is_published: bool, + mime: String, + name: String, + selected_fields_schema: ::Hash[Symbol, Imagekitio::File::SelectedFieldsSchema], + size: Float, + tags: ::Array[String]?, + thumbnail: String, + type: Imagekitio::Models::File::type_, + updated_at: Time, + url: String, + version_info: Imagekitio::File::VersionInfo, + width: Float + } + + type ai_tag = { confidence: Float, name: String, source: String } + + class AITag < Imagekitio::Internal::Type::BaseModel + attr_reader confidence: Float? + + def confidence=: (Float) -> Float + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader source: String? + + def source=: (String) -> String + + def initialize: ( + ?confidence: Float, + ?name: String, + ?source: String + ) -> void + + def to_hash: -> { confidence: Float, name: String, source: String } + end + + type selected_fields_schema = + { + type: Imagekitio::Models::File::SelectedFieldsSchema::type_, + default_value: Imagekitio::Models::File::SelectedFieldsSchema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::File::SelectedFieldsSchema::max_value, + min_length: Float, + min_value: Imagekitio::Models::File::SelectedFieldsSchema::min_value, + read_only: bool, + select_options: ::Array[Imagekitio::Models::File::SelectedFieldsSchema::select_option], + select_options_truncated: bool + } + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::File::SelectedFieldsSchema::type_ + + attr_reader default_value: Imagekitio::Models::File::SelectedFieldsSchema::default_value? + + def default_value=: ( + Imagekitio::Models::File::SelectedFieldsSchema::default_value + ) -> Imagekitio::Models::File::SelectedFieldsSchema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekitio::Models::File::SelectedFieldsSchema::max_value? + + def max_value=: ( + Imagekitio::Models::File::SelectedFieldsSchema::max_value + ) -> Imagekitio::Models::File::SelectedFieldsSchema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekitio::Models::File::SelectedFieldsSchema::min_value? + + def min_value=: ( + Imagekitio::Models::File::SelectedFieldsSchema::min_value + ) -> Imagekitio::Models::File::SelectedFieldsSchema::min_value + + attr_reader read_only: bool? + + def read_only=: (bool) -> bool + + attr_reader select_options: ::Array[Imagekitio::Models::File::SelectedFieldsSchema::select_option]? + + def select_options=: ( + ::Array[Imagekitio::Models::File::SelectedFieldsSchema::select_option] + ) -> ::Array[Imagekitio::Models::File::SelectedFieldsSchema::select_option] + + attr_reader select_options_truncated: bool? + + def select_options_truncated=: (bool) -> bool + + def initialize: ( + type: Imagekitio::Models::File::SelectedFieldsSchema::type_, + ?default_value: Imagekitio::Models::File::SelectedFieldsSchema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekitio::Models::File::SelectedFieldsSchema::max_value, + ?min_length: Float, + ?min_value: Imagekitio::Models::File::SelectedFieldsSchema::min_value, + ?read_only: bool, + ?select_options: ::Array[Imagekitio::Models::File::SelectedFieldsSchema::select_option], + ?select_options_truncated: bool + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::File::SelectedFieldsSchema::type_, + default_value: Imagekitio::Models::File::SelectedFieldsSchema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::File::SelectedFieldsSchema::max_value, + min_length: Float, + min_value: Imagekitio::Models::File::SelectedFieldsSchema::min_value, + read_only: bool, + select_options: ::Array[Imagekitio::Models::File::SelectedFieldsSchema::select_option], + select_options_truncated: bool + } + + type type_ = + :Text + | :Textarea + | :Number + | :Date + | :Boolean + | :SingleSelect + | :MultiSelect + + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT: :Text + TEXTAREA: :Textarea + NUMBER: :Number + DATE: :Date + BOOLEAN: :Boolean + SINGLE_SELECT: :SingleSelect + MULTI_SELECT: :MultiSelect + + def self?.values: -> ::Array[Imagekitio::Models::File::SelectedFieldsSchema::type_] + end + + type default_value = + String + | Float + | bool + | ::Array[Imagekitio::Models::File::SelectedFieldsSchema::DefaultValue::mixed] + + module DefaultValue + extend Imagekitio::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::File::SelectedFieldsSchema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekitio::Models::File::SelectedFieldsSchema::default_value] + + MixedArray: Imagekitio::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::File::SelectedFieldsSchema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::File::SelectedFieldsSchema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::File::SelectedFieldsSchema::select_option] + end + end + + type type_ = :file | :"file-version" + + module Type + extend Imagekitio::Internal::Type::Enum + + FILE: :file + FILE_VERSION: :"file-version" + + def self?.values: -> ::Array[Imagekitio::Models::File::type_] + end + + type version_info = { id: String, name: String } + + class VersionInfo < Imagekitio::Internal::Type::BaseModel + attr_reader id: String? + + def id=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + def initialize: (?id: String, ?name: String) -> void + + def to_hash: -> { id: String, name: String } + end + end + end +end diff --git a/sig/imagekitio/models/file_copy_params.rbs b/sig/imagekitio/models/file_copy_params.rbs new file mode 100644 index 00000000..647d5ffb --- /dev/null +++ b/sig/imagekitio/models/file_copy_params.rbs @@ -0,0 +1,38 @@ +module Imagekitio + module Models + type file_copy_params = + { + destination_path: String, + source_file_path: String, + include_file_versions: bool + } + & Imagekitio::Internal::Type::request_parameters + + class FileCopyParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor destination_path: String + + attr_accessor source_file_path: String + + attr_reader include_file_versions: bool? + + def include_file_versions=: (bool) -> bool + + def initialize: ( + destination_path: String, + source_file_path: String, + ?include_file_versions: bool, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + destination_path: String, + source_file_path: String, + include_file_versions: bool, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/file_copy_response.rbs b/sig/imagekitio/models/file_copy_response.rbs new file mode 100644 index 00000000..d29d11ab --- /dev/null +++ b/sig/imagekitio/models/file_copy_response.rbs @@ -0,0 +1,11 @@ +module Imagekitio + module Models + type file_copy_response = { } + + class FileCopyResponse < Imagekitio::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekitio/models/file_delete_params.rbs b/sig/imagekitio/models/file_delete_params.rbs new file mode 100644 index 00000000..1ad75710 --- /dev/null +++ b/sig/imagekitio/models/file_delete_params.rbs @@ -0,0 +1,15 @@ +module Imagekitio + module Models + type file_delete_params = + { } & Imagekitio::Internal::Type::request_parameters + + class FileDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end +end diff --git a/sig/imagekitio/models/file_get_params.rbs b/sig/imagekitio/models/file_get_params.rbs new file mode 100644 index 00000000..3ee95b01 --- /dev/null +++ b/sig/imagekitio/models/file_get_params.rbs @@ -0,0 +1,14 @@ +module Imagekitio + module Models + type file_get_params = { } & Imagekitio::Internal::Type::request_parameters + + class FileGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end +end diff --git a/sig/imagekitio/models/file_move_params.rbs b/sig/imagekitio/models/file_move_params.rbs new file mode 100644 index 00000000..a53b9cce --- /dev/null +++ b/sig/imagekitio/models/file_move_params.rbs @@ -0,0 +1,28 @@ +module Imagekitio + module Models + type file_move_params = + { destination_path: String, source_file_path: String } + & Imagekitio::Internal::Type::request_parameters + + class FileMoveParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor destination_path: String + + attr_accessor source_file_path: String + + def initialize: ( + destination_path: String, + source_file_path: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + destination_path: String, + source_file_path: String, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/file_move_response.rbs b/sig/imagekitio/models/file_move_response.rbs new file mode 100644 index 00000000..7a5c5518 --- /dev/null +++ b/sig/imagekitio/models/file_move_response.rbs @@ -0,0 +1,11 @@ +module Imagekitio + module Models + type file_move_response = { } + + class FileMoveResponse < Imagekitio::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekitio/models/file_rename_params.rbs b/sig/imagekitio/models/file_rename_params.rbs new file mode 100644 index 00000000..ab2c7a96 --- /dev/null +++ b/sig/imagekitio/models/file_rename_params.rbs @@ -0,0 +1,34 @@ +module Imagekitio + module Models + type file_rename_params = + { file_path: String, new_file_name: String, purge_cache: bool } + & Imagekitio::Internal::Type::request_parameters + + class FileRenameParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor file_path: String + + attr_accessor new_file_name: String + + attr_reader purge_cache: bool? + + def purge_cache=: (bool) -> bool + + def initialize: ( + file_path: String, + new_file_name: String, + ?purge_cache: bool, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file_path: String, + new_file_name: String, + purge_cache: bool, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/file_rename_response.rbs b/sig/imagekitio/models/file_rename_response.rbs new file mode 100644 index 00000000..c80dfad0 --- /dev/null +++ b/sig/imagekitio/models/file_rename_response.rbs @@ -0,0 +1,15 @@ +module Imagekitio + module Models + type file_rename_response = { purge_request_id: String } + + class FileRenameResponse < Imagekitio::Internal::Type::BaseModel + attr_reader purge_request_id: String? + + def purge_request_id=: (String) -> String + + def initialize: (?purge_request_id: String) -> void + + def to_hash: -> { purge_request_id: String } + end + end +end diff --git a/sig/imagekitio/models/file_update_params.rbs b/sig/imagekitio/models/file_update_params.rbs new file mode 100644 index 00000000..e72f4345 --- /dev/null +++ b/sig/imagekitio/models/file_update_params.rbs @@ -0,0 +1,28 @@ +module Imagekitio + module Models + type file_update_params = + { update_file_request: Imagekitio::Models::update_file_request } + & Imagekitio::Internal::Type::request_parameters + + class FileUpdateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def update_file_request: -> Imagekitio::Models::update_file_request + + def update_file_request=: ( + Imagekitio::Models::update_file_request _ + ) -> Imagekitio::Models::update_file_request + + def initialize: ( + update_file_request: Imagekitio::Models::update_file_request, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + update_file_request: Imagekitio::Models::update_file_request, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/file_update_response.rbs b/sig/imagekitio/models/file_update_response.rbs new file mode 100644 index 00000000..8086d9a1 --- /dev/null +++ b/sig/imagekitio/models/file_update_response.rbs @@ -0,0 +1,120 @@ +module Imagekitio + module Models + type file_update_response = + { + extension_status: Imagekitio::Models::FileUpdateResponse::ExtensionStatus + } + + class FileUpdateResponse < Imagekitio::Models::File + def extension_status: -> Imagekitio::Models::FileUpdateResponse::ExtensionStatus? + + def extension_status=: ( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus _ + ) -> Imagekitio::Models::FileUpdateResponse::ExtensionStatus + + def initialize: ( + ?extension_status: Imagekitio::Models::FileUpdateResponse::ExtensionStatus + ) -> void + + def to_hash: -> { + extension_status: Imagekitio::Models::FileUpdateResponse::ExtensionStatus + } + + type extension_status = + { + ai_auto_description: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::remove_bg + } + + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + attr_reader ai_auto_description: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description? + + def ai_auto_description=: ( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description + ) -> Imagekitio::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description + + attr_reader aws_auto_tagging: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging? + + def aws_auto_tagging=: ( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging + ) -> Imagekitio::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging + + attr_reader google_auto_tagging: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging? + + def google_auto_tagging=: ( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging + ) -> Imagekitio::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging + + attr_reader remove_bg: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::remove_bg? + + def remove_bg=: ( + Imagekitio::Models::FileUpdateResponse::ExtensionStatus::remove_bg + ) -> Imagekitio::Models::FileUpdateResponse::ExtensionStatus::remove_bg + + def initialize: ( + ?ai_auto_description: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description, + ?aws_auto_tagging: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging, + ?google_auto_tagging: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging, + ?remove_bg: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::remove_bg + ) -> void + + def to_hash: -> { + ai_auto_description: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekitio::Models::FileUpdateResponse::ExtensionStatus::remove_bg + } + + type ai_auto_description = :success | :pending | :failed + + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::FileUpdateResponse::ExtensionStatus::ai_auto_description] + end + + type aws_auto_tagging = :success | :pending | :failed + + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::FileUpdateResponse::ExtensionStatus::aws_auto_tagging] + end + + type google_auto_tagging = :success | :pending | :failed + + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::FileUpdateResponse::ExtensionStatus::google_auto_tagging] + end + + type remove_bg = :success | :pending | :failed + + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::FileUpdateResponse::ExtensionStatus::remove_bg] + end + end + end + end +end diff --git a/sig/imagekitio/models/file_upload_params.rbs b/sig/imagekitio/models/file_upload_params.rbs new file mode 100644 index 00000000..fc4b7bed --- /dev/null +++ b/sig/imagekitio/models/file_upload_params.rbs @@ -0,0 +1,327 @@ +module Imagekitio + module Models + type file_upload_params = + { + file: Imagekitio::Internal::file_input, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: ::Hash[Symbol, top], + description: String, + expire: Integer, + extensions: Imagekitio::Models::extensions, + folder: String, + is_private_file: bool, + is_published: bool, + overwrite_ai_tags: bool, + overwrite_custom_metadata: bool, + overwrite_file: bool, + overwrite_tags: bool, + public_key: String, + response_fields: ::Array[Imagekitio::Models::FileUploadParams::response_field], + signature: String, + tags: ::Array[String], + transformation: Imagekitio::FileUploadParams::Transformation, + use_unique_file_name: bool, + webhook_url: String + } + & Imagekitio::Internal::Type::request_parameters + + class FileUploadParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor file: Imagekitio::Internal::file_input + + attr_accessor file_name: String + + attr_reader token: String? + + def token=: (String) -> String + + attr_reader checks: String? + + def checks=: (String) -> String + + attr_reader custom_coordinates: String? + + def custom_coordinates=: (String) -> String + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader expire: Integer? + + def expire=: (Integer) -> Integer + + attr_reader extensions: Imagekitio::Models::extensions? + + def extensions=: ( + Imagekitio::Models::extensions + ) -> Imagekitio::Models::extensions + + attr_reader folder: String? + + def folder=: (String) -> String + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader overwrite_ai_tags: bool? + + def overwrite_ai_tags=: (bool) -> bool + + attr_reader overwrite_custom_metadata: bool? + + def overwrite_custom_metadata=: (bool) -> bool + + attr_reader overwrite_file: bool? + + def overwrite_file=: (bool) -> bool + + attr_reader overwrite_tags: bool? + + def overwrite_tags=: (bool) -> bool + + attr_reader public_key: String? + + def public_key=: (String) -> String + + attr_reader response_fields: ::Array[Imagekitio::Models::FileUploadParams::response_field]? + + def response_fields=: ( + ::Array[Imagekitio::Models::FileUploadParams::response_field] + ) -> ::Array[Imagekitio::Models::FileUploadParams::response_field] + + attr_reader signature: String? + + def signature=: (String) -> String + + attr_reader tags: ::Array[String]? + + def tags=: (::Array[String]) -> ::Array[String] + + attr_reader transformation: Imagekitio::FileUploadParams::Transformation? + + def transformation=: ( + Imagekitio::FileUploadParams::Transformation + ) -> Imagekitio::FileUploadParams::Transformation + + attr_reader use_unique_file_name: bool? + + def use_unique_file_name=: (bool) -> bool + + attr_reader webhook_url: String? + + def webhook_url=: (String) -> String + + def initialize: ( + file: Imagekitio::Internal::file_input, + file_name: String, + ?token: String, + ?checks: String, + ?custom_coordinates: String, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?expire: Integer, + ?extensions: Imagekitio::Models::extensions, + ?folder: String, + ?is_private_file: bool, + ?is_published: bool, + ?overwrite_ai_tags: bool, + ?overwrite_custom_metadata: bool, + ?overwrite_file: bool, + ?overwrite_tags: bool, + ?public_key: String, + ?response_fields: ::Array[Imagekitio::Models::FileUploadParams::response_field], + ?signature: String, + ?tags: ::Array[String], + ?transformation: Imagekitio::FileUploadParams::Transformation, + ?use_unique_file_name: bool, + ?webhook_url: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file: Imagekitio::Internal::file_input, + file_name: String, + token: String, + checks: String, + custom_coordinates: String, + custom_metadata: ::Hash[Symbol, top], + description: String, + expire: Integer, + extensions: Imagekitio::Models::extensions, + folder: String, + is_private_file: bool, + is_published: bool, + overwrite_ai_tags: bool, + overwrite_custom_metadata: bool, + overwrite_file: bool, + overwrite_tags: bool, + public_key: String, + response_fields: ::Array[Imagekitio::Models::FileUploadParams::response_field], + signature: String, + tags: ::Array[String], + transformation: Imagekitio::FileUploadParams::Transformation, + use_unique_file_name: bool, + webhook_url: String, + request_options: Imagekitio::RequestOptions + } + + type response_field = + :tags + | :customCoordinates + | :isPrivateFile + | :embeddedMetadata + | :isPublished + | :customMetadata + | :metadata + | :selectedFieldsSchema + + module ResponseField + extend Imagekitio::Internal::Type::Enum + + TAGS: :tags + CUSTOM_COORDINATES: :customCoordinates + IS_PRIVATE_FILE: :isPrivateFile + EMBEDDED_METADATA: :embeddedMetadata + IS_PUBLISHED: :isPublished + CUSTOM_METADATA: :customMetadata + METADATA: :metadata + SELECTED_FIELDS_SCHEMA: :selectedFieldsSchema + + def self?.values: -> ::Array[Imagekitio::Models::FileUploadParams::response_field] + end + + type transformation = + { + post: ::Array[Imagekitio::Models::FileUploadParams::Transformation::post], + pre: String + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_reader post: ::Array[Imagekitio::Models::FileUploadParams::Transformation::post]? + + def post=: ( + ::Array[Imagekitio::Models::FileUploadParams::Transformation::post] + ) -> ::Array[Imagekitio::Models::FileUploadParams::Transformation::post] + + attr_reader pre: String? + + def pre=: (String) -> String + + def initialize: ( + ?post: ::Array[Imagekitio::Models::FileUploadParams::Transformation::post], + ?pre: String + ) -> void + + def to_hash: -> { + post: ::Array[Imagekitio::Models::FileUploadParams::Transformation::post], + pre: String + } + + type post = + Imagekitio::FileUploadParams::Transformation::Post::Transformation + | Imagekitio::FileUploadParams::Transformation::Post::GifToVideo + | Imagekitio::FileUploadParams::Transformation::Post::Thumbnail + | Imagekitio::FileUploadParams::Transformation::Post::Abs + + module Post + extend Imagekitio::Internal::Type::Union + + type transformation = { type: :transformation, value: String } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :transformation + + attr_accessor value: String + + def initialize: (value: String, ?type: :transformation) -> void + + def to_hash: -> { type: :transformation, value: String } + end + + type gif_to_video = { type: :"gif-to-video", value: String } + + class GifToVideo < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :"gif-to-video" + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: (?value: String, ?type: :"gif-to-video") -> void + + def to_hash: -> { type: :"gif-to-video", value: String } + end + + type thumbnail = { type: :thumbnail, value: String } + + class Thumbnail < Imagekitio::Internal::Type::BaseModel + attr_accessor type: :thumbnail + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: (?value: String, ?type: :thumbnail) -> void + + def to_hash: -> { type: :thumbnail, value: String } + end + + type abs = + { + protocol: Imagekitio::Models::FileUploadParams::Transformation::Post::Abs::protocol, + type: :abs, + value: String + } + + class Abs < Imagekitio::Internal::Type::BaseModel + attr_accessor protocol: Imagekitio::Models::FileUploadParams::Transformation::Post::Abs::protocol + + attr_accessor type: :abs + + attr_accessor value: String + + def initialize: ( + protocol: Imagekitio::Models::FileUploadParams::Transformation::Post::Abs::protocol, + value: String, + ?type: :abs + ) -> void + + def to_hash: -> { + protocol: Imagekitio::Models::FileUploadParams::Transformation::Post::Abs::protocol, + type: :abs, + value: String + } + + type protocol = :hls | :dash + + module Protocol + extend Imagekitio::Internal::Type::Enum + + HLS: :hls + DASH: :dash + + def self?.values: -> ::Array[Imagekitio::Models::FileUploadParams::Transformation::Post::Abs::protocol] + end + end + + def self?.variants: -> ::Array[Imagekitio::Models::FileUploadParams::Transformation::post] + end + end + end + end +end diff --git a/sig/imagekitio/models/file_upload_response.rbs b/sig/imagekitio/models/file_upload_response.rbs new file mode 100644 index 00000000..b94fc139 --- /dev/null +++ b/sig/imagekitio/models/file_upload_response.rbs @@ -0,0 +1,483 @@ +module Imagekitio + module Models + type file_upload_response = + { + ai_tags: ::Array[Imagekitio::Models::FileUploadResponse::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekitio::Models::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekitio::Metadata, + name: String, + selected_fields_schema: ::Hash[Symbol, Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema], + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekitio::Models::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + + class FileUploadResponse < Imagekitio::Internal::Type::BaseModel + attr_accessor ai_tags: ::Array[Imagekitio::Models::FileUploadResponse::AITag]? + + attr_reader audio_codec: String? + + def audio_codec=: (String) -> String + + attr_reader bit_rate: Integer? + + def bit_rate=: (Integer) -> Integer + + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader duration: Integer? + + def duration=: (Integer) -> Integer + + attr_reader embedded_metadata: ::Hash[Symbol, top]? + + def embedded_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader extension_status: Imagekitio::Models::FileUploadResponse::ExtensionStatus? + + def extension_status=: ( + Imagekitio::Models::FileUploadResponse::ExtensionStatus + ) -> Imagekitio::Models::FileUploadResponse::ExtensionStatus + + attr_reader file_id: String? + + def file_id=: (String) -> String + + attr_reader file_path: String? + + def file_path=: (String) -> String + + attr_reader file_type: String? + + def file_type=: (String) -> String + + attr_reader height: Float? + + def height=: (Float) -> Float + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader metadata: Imagekitio::Metadata? + + def metadata=: (Imagekitio::Metadata) -> Imagekitio::Metadata + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader selected_fields_schema: ::Hash[Symbol, Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema]? + + def selected_fields_schema=: ( + ::Hash[Symbol, Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema] + ) -> ::Hash[Symbol, Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema] + + attr_reader size: Float? + + def size=: (Float) -> Float + + attr_accessor tags: ::Array[String]? + + attr_reader thumbnail_url: String? + + def thumbnail_url=: (String) -> String + + attr_reader url: String? + + def url=: (String) -> String + + attr_reader version_info: Imagekitio::Models::FileUploadResponse::VersionInfo? + + def version_info=: ( + Imagekitio::Models::FileUploadResponse::VersionInfo + ) -> Imagekitio::Models::FileUploadResponse::VersionInfo + + attr_reader video_codec: String? + + def video_codec=: (String) -> String + + attr_reader width: Float? + + def width=: (Float) -> Float + + def initialize: ( + ?ai_tags: ::Array[Imagekitio::Models::FileUploadResponse::AITag]?, + ?audio_codec: String, + ?bit_rate: Integer, + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?duration: Integer, + ?embedded_metadata: ::Hash[Symbol, top], + ?extension_status: Imagekitio::Models::FileUploadResponse::ExtensionStatus, + ?file_id: String, + ?file_path: String, + ?file_type: String, + ?height: Float, + ?is_private_file: bool, + ?is_published: bool, + ?metadata: Imagekitio::Metadata, + ?name: String, + ?selected_fields_schema: ::Hash[Symbol, Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema], + ?size: Float, + ?tags: ::Array[String]?, + ?thumbnail_url: String, + ?url: String, + ?version_info: Imagekitio::Models::FileUploadResponse::VersionInfo, + ?video_codec: String, + ?width: Float + ) -> void + + def to_hash: -> { + ai_tags: ::Array[Imagekitio::Models::FileUploadResponse::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekitio::Models::FileUploadResponse::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekitio::Metadata, + name: String, + selected_fields_schema: ::Hash[Symbol, Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema], + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekitio::Models::FileUploadResponse::VersionInfo, + video_codec: String, + width: Float + } + + type ai_tag = { confidence: Float, name: String, source: String } + + class AITag < Imagekitio::Internal::Type::BaseModel + attr_reader confidence: Float? + + def confidence=: (Float) -> Float + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader source: String? + + def source=: (String) -> String + + def initialize: ( + ?confidence: Float, + ?name: String, + ?source: String + ) -> void + + def to_hash: -> { confidence: Float, name: String, source: String } + end + + type extension_status = + { + ai_auto_description: Imagekitio::Models::FileUploadResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekitio::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekitio::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekitio::Models::FileUploadResponse::ExtensionStatus::remove_bg + } + + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + attr_reader ai_auto_description: Imagekitio::Models::FileUploadResponse::ExtensionStatus::ai_auto_description? + + def ai_auto_description=: ( + Imagekitio::Models::FileUploadResponse::ExtensionStatus::ai_auto_description + ) -> Imagekitio::Models::FileUploadResponse::ExtensionStatus::ai_auto_description + + attr_reader aws_auto_tagging: Imagekitio::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging? + + def aws_auto_tagging=: ( + Imagekitio::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging + ) -> Imagekitio::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging + + attr_reader google_auto_tagging: Imagekitio::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging? + + def google_auto_tagging=: ( + Imagekitio::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging + ) -> Imagekitio::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging + + attr_reader remove_bg: Imagekitio::Models::FileUploadResponse::ExtensionStatus::remove_bg? + + def remove_bg=: ( + Imagekitio::Models::FileUploadResponse::ExtensionStatus::remove_bg + ) -> Imagekitio::Models::FileUploadResponse::ExtensionStatus::remove_bg + + def initialize: ( + ?ai_auto_description: Imagekitio::Models::FileUploadResponse::ExtensionStatus::ai_auto_description, + ?aws_auto_tagging: Imagekitio::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + ?google_auto_tagging: Imagekitio::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging, + ?remove_bg: Imagekitio::Models::FileUploadResponse::ExtensionStatus::remove_bg + ) -> void + + def to_hash: -> { + ai_auto_description: Imagekitio::Models::FileUploadResponse::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekitio::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekitio::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekitio::Models::FileUploadResponse::ExtensionStatus::remove_bg + } + + type ai_auto_description = :success | :pending | :failed + + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::FileUploadResponse::ExtensionStatus::ai_auto_description] + end + + type aws_auto_tagging = :success | :pending | :failed + + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::FileUploadResponse::ExtensionStatus::aws_auto_tagging] + end + + type google_auto_tagging = :success | :pending | :failed + + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::FileUploadResponse::ExtensionStatus::google_auto_tagging] + end + + type remove_bg = :success | :pending | :failed + + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::FileUploadResponse::ExtensionStatus::remove_bg] + end + end + + type selected_fields_schema = + { + type: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::type_, + default_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::max_value, + min_length: Float, + min_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::min_value, + read_only: bool, + select_options: ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::select_option], + select_options_truncated: bool + } + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::type_ + + attr_reader default_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::default_value? + + def default_value=: ( + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::default_value + ) -> Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::max_value? + + def max_value=: ( + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::max_value + ) -> Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::min_value? + + def min_value=: ( + Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::min_value + ) -> Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::min_value + + attr_reader read_only: bool? + + def read_only=: (bool) -> bool + + attr_reader select_options: ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::select_option]? + + def select_options=: ( + ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::select_option] + ) -> ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::select_option] + + attr_reader select_options_truncated: bool? + + def select_options_truncated=: (bool) -> bool + + def initialize: ( + type: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::type_, + ?default_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::max_value, + ?min_length: Float, + ?min_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::min_value, + ?read_only: bool, + ?select_options: ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::select_option], + ?select_options_truncated: bool + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::type_, + default_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::max_value, + min_length: Float, + min_value: Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::min_value, + read_only: bool, + select_options: ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::select_option], + select_options_truncated: bool + } + + type type_ = + :Text + | :Textarea + | :Number + | :Date + | :Boolean + | :SingleSelect + | :MultiSelect + + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT: :Text + TEXTAREA: :Textarea + NUMBER: :Number + DATE: :Date + BOOLEAN: :Boolean + SINGLE_SELECT: :SingleSelect + MULTI_SELECT: :MultiSelect + + def self?.values: -> ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::type_] + end + + type default_value = + String + | Float + | bool + | ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::mixed] + + module DefaultValue + extend Imagekitio::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::default_value] + + MixedArray: Imagekitio::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema::select_option] + end + end + + type version_info = { id: String, name: String } + + class VersionInfo < Imagekitio::Internal::Type::BaseModel + attr_reader id: String? + + def id=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + def initialize: (?id: String, ?name: String) -> void + + def to_hash: -> { id: String, name: String } + end + end + end +end diff --git a/sig/imagekitio/models/files/bulk_add_tags_params.rbs b/sig/imagekitio/models/files/bulk_add_tags_params.rbs new file mode 100644 index 00000000..bef017c2 --- /dev/null +++ b/sig/imagekitio/models/files/bulk_add_tags_params.rbs @@ -0,0 +1,30 @@ +module Imagekitio + module Models + module Files + type bulk_add_tags_params = + { file_ids: ::Array[String], tags: ::Array[String] } + & Imagekitio::Internal::Type::request_parameters + + class BulkAddTagsParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor file_ids: ::Array[String] + + attr_accessor tags: ::Array[String] + + def initialize: ( + file_ids: ::Array[String], + tags: ::Array[String], + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file_ids: ::Array[String], + tags: ::Array[String], + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/files/bulk_add_tags_response.rbs b/sig/imagekitio/models/files/bulk_add_tags_response.rbs new file mode 100644 index 00000000..dd845295 --- /dev/null +++ b/sig/imagekitio/models/files/bulk_add_tags_response.rbs @@ -0,0 +1,20 @@ +module Imagekitio + module Models + module Files + type bulk_add_tags_response = + { successfully_updated_file_ids: ::Array[String] } + + class BulkAddTagsResponse < Imagekitio::Internal::Type::BaseModel + attr_reader successfully_updated_file_ids: ::Array[String]? + + def successfully_updated_file_ids=: (::Array[String]) -> ::Array[String] + + def initialize: ( + ?successfully_updated_file_ids: ::Array[String] + ) -> void + + def to_hash: -> { successfully_updated_file_ids: ::Array[String] } + end + end + end +end diff --git a/sig/imagekitio/models/files/bulk_delete_params.rbs b/sig/imagekitio/models/files/bulk_delete_params.rbs new file mode 100644 index 00000000..8b5e7eff --- /dev/null +++ b/sig/imagekitio/models/files/bulk_delete_params.rbs @@ -0,0 +1,26 @@ +module Imagekitio + module Models + module Files + type bulk_delete_params = + { file_ids: ::Array[String] } + & Imagekitio::Internal::Type::request_parameters + + class BulkDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor file_ids: ::Array[String] + + def initialize: ( + file_ids: ::Array[String], + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file_ids: ::Array[String], + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/files/bulk_delete_response.rbs b/sig/imagekitio/models/files/bulk_delete_response.rbs new file mode 100644 index 00000000..a246aa77 --- /dev/null +++ b/sig/imagekitio/models/files/bulk_delete_response.rbs @@ -0,0 +1,20 @@ +module Imagekitio + module Models + module Files + type bulk_delete_response = + { successfully_deleted_file_ids: ::Array[String] } + + class BulkDeleteResponse < Imagekitio::Internal::Type::BaseModel + attr_reader successfully_deleted_file_ids: ::Array[String]? + + def successfully_deleted_file_ids=: (::Array[String]) -> ::Array[String] + + def initialize: ( + ?successfully_deleted_file_ids: ::Array[String] + ) -> void + + def to_hash: -> { successfully_deleted_file_ids: ::Array[String] } + end + end + end +end diff --git a/sig/imagekitio/models/files/bulk_remove_ai_tags_params.rbs b/sig/imagekitio/models/files/bulk_remove_ai_tags_params.rbs new file mode 100644 index 00000000..8e300597 --- /dev/null +++ b/sig/imagekitio/models/files/bulk_remove_ai_tags_params.rbs @@ -0,0 +1,30 @@ +module Imagekitio + module Models + module Files + type bulk_remove_ai_tags_params = + { ai_tags: ::Array[String], file_ids: ::Array[String] } + & Imagekitio::Internal::Type::request_parameters + + class BulkRemoveAITagsParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor ai_tags: ::Array[String] + + attr_accessor file_ids: ::Array[String] + + def initialize: ( + ai_tags: ::Array[String], + file_ids: ::Array[String], + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + ai_tags: ::Array[String], + file_ids: ::Array[String], + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/files/bulk_remove_ai_tags_response.rbs b/sig/imagekitio/models/files/bulk_remove_ai_tags_response.rbs new file mode 100644 index 00000000..8b7809dd --- /dev/null +++ b/sig/imagekitio/models/files/bulk_remove_ai_tags_response.rbs @@ -0,0 +1,20 @@ +module Imagekitio + module Models + module Files + type bulk_remove_ai_tags_response = + { successfully_updated_file_ids: ::Array[String] } + + class BulkRemoveAITagsResponse < Imagekitio::Internal::Type::BaseModel + attr_reader successfully_updated_file_ids: ::Array[String]? + + def successfully_updated_file_ids=: (::Array[String]) -> ::Array[String] + + def initialize: ( + ?successfully_updated_file_ids: ::Array[String] + ) -> void + + def to_hash: -> { successfully_updated_file_ids: ::Array[String] } + end + end + end +end diff --git a/sig/imagekitio/models/files/bulk_remove_tags_params.rbs b/sig/imagekitio/models/files/bulk_remove_tags_params.rbs new file mode 100644 index 00000000..5e6221b2 --- /dev/null +++ b/sig/imagekitio/models/files/bulk_remove_tags_params.rbs @@ -0,0 +1,30 @@ +module Imagekitio + module Models + module Files + type bulk_remove_tags_params = + { file_ids: ::Array[String], tags: ::Array[String] } + & Imagekitio::Internal::Type::request_parameters + + class BulkRemoveTagsParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor file_ids: ::Array[String] + + attr_accessor tags: ::Array[String] + + def initialize: ( + file_ids: ::Array[String], + tags: ::Array[String], + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file_ids: ::Array[String], + tags: ::Array[String], + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/files/bulk_remove_tags_response.rbs b/sig/imagekitio/models/files/bulk_remove_tags_response.rbs new file mode 100644 index 00000000..bf36edda --- /dev/null +++ b/sig/imagekitio/models/files/bulk_remove_tags_response.rbs @@ -0,0 +1,20 @@ +module Imagekitio + module Models + module Files + type bulk_remove_tags_response = + { successfully_updated_file_ids: ::Array[String] } + + class BulkRemoveTagsResponse < Imagekitio::Internal::Type::BaseModel + attr_reader successfully_updated_file_ids: ::Array[String]? + + def successfully_updated_file_ids=: (::Array[String]) -> ::Array[String] + + def initialize: ( + ?successfully_updated_file_ids: ::Array[String] + ) -> void + + def to_hash: -> { successfully_updated_file_ids: ::Array[String] } + end + end + end +end diff --git a/sig/imagekitio/models/files/metadata_get_from_url_params.rbs b/sig/imagekitio/models/files/metadata_get_from_url_params.rbs new file mode 100644 index 00000000..1380c370 --- /dev/null +++ b/sig/imagekitio/models/files/metadata_get_from_url_params.rbs @@ -0,0 +1,25 @@ +module Imagekitio + module Models + module Files + type metadata_get_from_url_params = + { url: String } & Imagekitio::Internal::Type::request_parameters + + class MetadataGetFromURLParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor url: String + + def initialize: ( + url: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + url: String, + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/files/metadata_get_params.rbs b/sig/imagekitio/models/files/metadata_get_params.rbs new file mode 100644 index 00000000..2a057118 --- /dev/null +++ b/sig/imagekitio/models/files/metadata_get_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Files + type metadata_get_params = + { } & Imagekitio::Internal::Type::request_parameters + + class MetadataGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/files/version_delete_params.rbs b/sig/imagekitio/models/files/version_delete_params.rbs new file mode 100644 index 00000000..60119658 --- /dev/null +++ b/sig/imagekitio/models/files/version_delete_params.rbs @@ -0,0 +1,25 @@ +module Imagekitio + module Models + module Files + type version_delete_params = + { file_id: String } & Imagekitio::Internal::Type::request_parameters + + class VersionDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor file_id: String + + def initialize: ( + file_id: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file_id: String, + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/files/version_delete_response.rbs b/sig/imagekitio/models/files/version_delete_response.rbs new file mode 100644 index 00000000..30fdbfea --- /dev/null +++ b/sig/imagekitio/models/files/version_delete_response.rbs @@ -0,0 +1,13 @@ +module Imagekitio + module Models + module Files + type version_delete_response = { } + + class VersionDeleteResponse < Imagekitio::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end + end +end diff --git a/sig/imagekitio/models/files/version_get_params.rbs b/sig/imagekitio/models/files/version_get_params.rbs new file mode 100644 index 00000000..1d74dfc1 --- /dev/null +++ b/sig/imagekitio/models/files/version_get_params.rbs @@ -0,0 +1,25 @@ +module Imagekitio + module Models + module Files + type version_get_params = + { file_id: String } & Imagekitio::Internal::Type::request_parameters + + class VersionGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor file_id: String + + def initialize: ( + file_id: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file_id: String, + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/files/version_list_params.rbs b/sig/imagekitio/models/files/version_list_params.rbs new file mode 100644 index 00000000..2d054b1c --- /dev/null +++ b/sig/imagekitio/models/files/version_list_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Files + type version_list_params = + { } & Imagekitio::Internal::Type::request_parameters + + class VersionListParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/files/version_list_response.rbs b/sig/imagekitio/models/files/version_list_response.rbs new file mode 100644 index 00000000..c8ac4129 --- /dev/null +++ b/sig/imagekitio/models/files/version_list_response.rbs @@ -0,0 +1,9 @@ +module Imagekitio + module Models + module Files + type version_list_response = ::Array[Imagekitio::File] + + VersionListResponse: Imagekitio::Internal::Type::Converter + end + end +end diff --git a/sig/imagekitio/models/files/version_restore_params.rbs b/sig/imagekitio/models/files/version_restore_params.rbs new file mode 100644 index 00000000..b0583cb8 --- /dev/null +++ b/sig/imagekitio/models/files/version_restore_params.rbs @@ -0,0 +1,25 @@ +module Imagekitio + module Models + module Files + type version_restore_params = + { file_id: String } & Imagekitio::Internal::Type::request_parameters + + class VersionRestoreParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor file_id: String + + def initialize: ( + file_id: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + file_id: String, + request_options: Imagekitio::RequestOptions + } + end + end + end +end diff --git a/sig/imagekitio/models/folder.rbs b/sig/imagekitio/models/folder.rbs new file mode 100644 index 00000000..b67e65e7 --- /dev/null +++ b/sig/imagekitio/models/folder.rbs @@ -0,0 +1,69 @@ +module Imagekitio + module Models + type folder = + { + created_at: Time, + folder_id: String, + folder_path: String, + name: String, + type: Imagekitio::Models::Folder::type_, + updated_at: Time + } + + class Folder < Imagekitio::Internal::Type::BaseModel + attr_reader created_at: Time? + + def created_at=: (Time) -> Time + + attr_reader folder_id: String? + + def folder_id=: (String) -> String + + attr_reader folder_path: String? + + def folder_path=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader type: Imagekitio::Models::Folder::type_? + + def type=: ( + Imagekitio::Models::Folder::type_ + ) -> Imagekitio::Models::Folder::type_ + + attr_reader updated_at: Time? + + def updated_at=: (Time) -> Time + + def initialize: ( + ?created_at: Time, + ?folder_id: String, + ?folder_path: String, + ?name: String, + ?type: Imagekitio::Models::Folder::type_, + ?updated_at: Time + ) -> void + + def to_hash: -> { + created_at: Time, + folder_id: String, + folder_path: String, + name: String, + type: Imagekitio::Models::Folder::type_, + updated_at: Time + } + + type type_ = :folder + + module Type + extend Imagekitio::Internal::Type::Enum + + FOLDER: :folder + + def self?.values: -> ::Array[Imagekitio::Models::Folder::type_] + end + end + end +end diff --git a/sig/imagekitio/models/folder_copy_params.rbs b/sig/imagekitio/models/folder_copy_params.rbs new file mode 100644 index 00000000..aa8cbfaf --- /dev/null +++ b/sig/imagekitio/models/folder_copy_params.rbs @@ -0,0 +1,38 @@ +module Imagekitio + module Models + type folder_copy_params = + { + destination_path: String, + source_folder_path: String, + include_versions: bool + } + & Imagekitio::Internal::Type::request_parameters + + class FolderCopyParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor destination_path: String + + attr_accessor source_folder_path: String + + attr_reader include_versions: bool? + + def include_versions=: (bool) -> bool + + def initialize: ( + destination_path: String, + source_folder_path: String, + ?include_versions: bool, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + destination_path: String, + source_folder_path: String, + include_versions: bool, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/folder_copy_response.rbs b/sig/imagekitio/models/folder_copy_response.rbs new file mode 100644 index 00000000..bdad7e86 --- /dev/null +++ b/sig/imagekitio/models/folder_copy_response.rbs @@ -0,0 +1,13 @@ +module Imagekitio + module Models + type folder_copy_response = { job_id: String } + + class FolderCopyResponse < Imagekitio::Internal::Type::BaseModel + attr_accessor job_id: String + + def initialize: (job_id: String) -> void + + def to_hash: -> { job_id: String } + end + end +end diff --git a/sig/imagekitio/models/folder_create_params.rbs b/sig/imagekitio/models/folder_create_params.rbs new file mode 100644 index 00000000..f488c652 --- /dev/null +++ b/sig/imagekitio/models/folder_create_params.rbs @@ -0,0 +1,28 @@ +module Imagekitio + module Models + type folder_create_params = + { folder_name: String, parent_folder_path: String } + & Imagekitio::Internal::Type::request_parameters + + class FolderCreateParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor folder_name: String + + attr_accessor parent_folder_path: String + + def initialize: ( + folder_name: String, + parent_folder_path: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + folder_name: String, + parent_folder_path: String, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/folder_create_response.rbs b/sig/imagekitio/models/folder_create_response.rbs new file mode 100644 index 00000000..182d8290 --- /dev/null +++ b/sig/imagekitio/models/folder_create_response.rbs @@ -0,0 +1,11 @@ +module Imagekitio + module Models + type folder_create_response = { } + + class FolderCreateResponse < Imagekitio::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekitio/models/folder_delete_params.rbs b/sig/imagekitio/models/folder_delete_params.rbs new file mode 100644 index 00000000..1e4a7f4f --- /dev/null +++ b/sig/imagekitio/models/folder_delete_params.rbs @@ -0,0 +1,23 @@ +module Imagekitio + module Models + type folder_delete_params = + { folder_path: String } & Imagekitio::Internal::Type::request_parameters + + class FolderDeleteParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor folder_path: String + + def initialize: ( + folder_path: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + folder_path: String, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/folder_delete_response.rbs b/sig/imagekitio/models/folder_delete_response.rbs new file mode 100644 index 00000000..6a89ebc1 --- /dev/null +++ b/sig/imagekitio/models/folder_delete_response.rbs @@ -0,0 +1,11 @@ +module Imagekitio + module Models + type folder_delete_response = { } + + class FolderDeleteResponse < Imagekitio::Internal::Type::BaseModel + def initialize: -> void + + def to_hash: -> { } + end + end +end diff --git a/sig/imagekitio/models/folder_move_params.rbs b/sig/imagekitio/models/folder_move_params.rbs new file mode 100644 index 00000000..c61c8be2 --- /dev/null +++ b/sig/imagekitio/models/folder_move_params.rbs @@ -0,0 +1,28 @@ +module Imagekitio + module Models + type folder_move_params = + { destination_path: String, source_folder_path: String } + & Imagekitio::Internal::Type::request_parameters + + class FolderMoveParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor destination_path: String + + attr_accessor source_folder_path: String + + def initialize: ( + destination_path: String, + source_folder_path: String, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + destination_path: String, + source_folder_path: String, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/folder_move_response.rbs b/sig/imagekitio/models/folder_move_response.rbs new file mode 100644 index 00000000..3d72f99f --- /dev/null +++ b/sig/imagekitio/models/folder_move_response.rbs @@ -0,0 +1,13 @@ +module Imagekitio + module Models + type folder_move_response = { job_id: String } + + class FolderMoveResponse < Imagekitio::Internal::Type::BaseModel + attr_accessor job_id: String + + def initialize: (job_id: String) -> void + + def to_hash: -> { job_id: String } + end + end +end diff --git a/sig/imagekitio/models/folder_rename_params.rbs b/sig/imagekitio/models/folder_rename_params.rbs new file mode 100644 index 00000000..8d22cd49 --- /dev/null +++ b/sig/imagekitio/models/folder_rename_params.rbs @@ -0,0 +1,34 @@ +module Imagekitio + module Models + type folder_rename_params = + { folder_path: String, new_folder_name: String, purge_cache: bool } + & Imagekitio::Internal::Type::request_parameters + + class FolderRenameParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + attr_accessor folder_path: String + + attr_accessor new_folder_name: String + + attr_reader purge_cache: bool? + + def purge_cache=: (bool) -> bool + + def initialize: ( + folder_path: String, + new_folder_name: String, + ?purge_cache: bool, + ?request_options: Imagekitio::request_opts + ) -> void + + def to_hash: -> { + folder_path: String, + new_folder_name: String, + purge_cache: bool, + request_options: Imagekitio::RequestOptions + } + end + end +end diff --git a/sig/imagekitio/models/folder_rename_response.rbs b/sig/imagekitio/models/folder_rename_response.rbs new file mode 100644 index 00000000..f5be1726 --- /dev/null +++ b/sig/imagekitio/models/folder_rename_response.rbs @@ -0,0 +1,13 @@ +module Imagekitio + module Models + type folder_rename_response = { job_id: String } + + class FolderRenameResponse < Imagekitio::Internal::Type::BaseModel + attr_accessor job_id: String + + def initialize: (job_id: String) -> void + + def to_hash: -> { job_id: String } + end + end +end diff --git a/sig/imagekitio/models/folders/job_get_params.rbs b/sig/imagekitio/models/folders/job_get_params.rbs new file mode 100644 index 00000000..73de9724 --- /dev/null +++ b/sig/imagekitio/models/folders/job_get_params.rbs @@ -0,0 +1,17 @@ +module Imagekitio + module Models + module Folders + type job_get_params = + { } & Imagekitio::Internal::Type::request_parameters + + class JobGetParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end + end +end diff --git a/sig/imagekitio/models/folders/job_get_response.rbs b/sig/imagekitio/models/folders/job_get_response.rbs new file mode 100644 index 00000000..3b4af32d --- /dev/null +++ b/sig/imagekitio/models/folders/job_get_response.rbs @@ -0,0 +1,72 @@ +module Imagekitio + module Models + module Folders + type job_get_response = + { + job_id: String, + purge_request_id: String, + status: Imagekitio::Models::Folders::JobGetResponse::status, + type: Imagekitio::Models::Folders::JobGetResponse::type_ + } + + class JobGetResponse < Imagekitio::Internal::Type::BaseModel + attr_reader job_id: String? + + def job_id=: (String) -> String + + attr_reader purge_request_id: String? + + def purge_request_id=: (String) -> String + + attr_reader status: Imagekitio::Models::Folders::JobGetResponse::status? + + def status=: ( + Imagekitio::Models::Folders::JobGetResponse::status + ) -> Imagekitio::Models::Folders::JobGetResponse::status + + attr_reader type: Imagekitio::Models::Folders::JobGetResponse::type_? + + def type=: ( + Imagekitio::Models::Folders::JobGetResponse::type_ + ) -> Imagekitio::Models::Folders::JobGetResponse::type_ + + def initialize: ( + ?job_id: String, + ?purge_request_id: String, + ?status: Imagekitio::Models::Folders::JobGetResponse::status, + ?type: Imagekitio::Models::Folders::JobGetResponse::type_ + ) -> void + + def to_hash: -> { + job_id: String, + purge_request_id: String, + status: Imagekitio::Models::Folders::JobGetResponse::status, + type: Imagekitio::Models::Folders::JobGetResponse::type_ + } + + type status = :Pending | :Completed + + module Status + extend Imagekitio::Internal::Type::Enum + + PENDING: :Pending + COMPLETED: :Completed + + def self?.values: -> ::Array[Imagekitio::Models::Folders::JobGetResponse::status] + end + + type type_ = :COPY_FOLDER | :MOVE_FOLDER | :RENAME_FOLDER + + module Type + extend Imagekitio::Internal::Type::Enum + + COPY_FOLDER: :COPY_FOLDER + MOVE_FOLDER: :MOVE_FOLDER + RENAME_FOLDER: :RENAME_FOLDER + + def self?.values: -> ::Array[Imagekitio::Models::Folders::JobGetResponse::type_] + end + end + end + end +end diff --git a/sig/imagekitio/models/get_image_attributes_options.rbs b/sig/imagekitio/models/get_image_attributes_options.rbs new file mode 100644 index 00000000..20928b19 --- /dev/null +++ b/sig/imagekitio/models/get_image_attributes_options.rbs @@ -0,0 +1,43 @@ +module Imagekitio + module Models + type get_image_attributes_options = + { + device_breakpoints: ::Array[Float], + image_breakpoints: ::Array[Float], + sizes: String, + width: Float + } + + class GetImageAttributesOptions < Imagekitio::Models::SrcOptions + def device_breakpoints: -> ::Array[Float]? + + def device_breakpoints=: (::Array[Float] _) -> ::Array[Float] + + def image_breakpoints: -> ::Array[Float]? + + def image_breakpoints=: (::Array[Float] _) -> ::Array[Float] + + def sizes: -> String? + + def sizes=: (String _) -> String + + def width: -> Float? + + def width=: (Float _) -> Float + + def initialize: ( + ?device_breakpoints: ::Array[Float], + ?image_breakpoints: ::Array[Float], + ?sizes: String, + ?width: Float + ) -> void + + def to_hash: -> { + device_breakpoints: ::Array[Float], + image_breakpoints: ::Array[Float], + sizes: String, + width: Float + } + end + end +end diff --git a/sig/imagekitio/models/image_overlay.rbs b/sig/imagekitio/models/image_overlay.rbs new file mode 100644 index 00000000..c9d3f886 --- /dev/null +++ b/sig/imagekitio/models/image_overlay.rbs @@ -0,0 +1,59 @@ +module Imagekitio + module Models + type image_overlay = + { + input: String, + type: :image, + encoding: Imagekitio::Models::ImageOverlay::encoding, + transformation: ::Array[Imagekitio::Transformation] + } + + class ImageOverlay < Imagekitio::Models::BaseOverlay + def input: -> String + + def input=: (String _) -> String + + def `type`: -> :image + + def type=: (:image _) -> :image + + def encoding: -> Imagekitio::Models::ImageOverlay::encoding? + + def encoding=: ( + Imagekitio::Models::ImageOverlay::encoding _ + ) -> Imagekitio::Models::ImageOverlay::encoding + + def transformation: -> ::Array[Imagekitio::Transformation]? + + def transformation=: ( + ::Array[Imagekitio::Transformation] _ + ) -> ::Array[Imagekitio::Transformation] + + def initialize: ( + input: String, + ?encoding: Imagekitio::Models::ImageOverlay::encoding, + ?transformation: ::Array[Imagekitio::Transformation], + ?type: :image + ) -> void + + def to_hash: -> { + input: String, + type: :image, + encoding: Imagekitio::Models::ImageOverlay::encoding, + transformation: ::Array[Imagekitio::Transformation] + } + + type encoding = :auto | :plain | :base64 + + module Encoding + extend Imagekitio::Internal::Type::Enum + + AUTO: :auto + PLAIN: :plain + BASE64: :base64 + + def self?.values: -> ::Array[Imagekitio::Models::ImageOverlay::encoding] + end + end + end +end diff --git a/sig/imagekitio/models/metadata.rbs b/sig/imagekitio/models/metadata.rbs new file mode 100644 index 00000000..082ac3ac --- /dev/null +++ b/sig/imagekitio/models/metadata.rbs @@ -0,0 +1,546 @@ +module Imagekitio + module Models + type metadata = + { + audio_codec: String, + bit_rate: Integer, + density: Integer, + duration: Integer, + exif: Imagekitio::Metadata::Exif, + format_: String, + has_color_profile: bool, + has_transparency: bool, + height: Integer, + p_hash: String, + quality: Integer, + size: Integer, + video_codec: String, + width: Integer + } + + class Metadata < Imagekitio::Internal::Type::BaseModel + attr_reader audio_codec: String? + + def audio_codec=: (String) -> String + + attr_reader bit_rate: Integer? + + def bit_rate=: (Integer) -> Integer + + attr_reader density: Integer? + + def density=: (Integer) -> Integer + + attr_reader duration: Integer? + + def duration=: (Integer) -> Integer + + attr_reader exif: Imagekitio::Metadata::Exif? + + def exif=: (Imagekitio::Metadata::Exif) -> Imagekitio::Metadata::Exif + + attr_reader format_: String? + + def format_=: (String) -> String + + attr_reader has_color_profile: bool? + + def has_color_profile=: (bool) -> bool + + attr_reader has_transparency: bool? + + def has_transparency=: (bool) -> bool + + attr_reader height: Integer? + + def height=: (Integer) -> Integer + + attr_reader p_hash: String? + + def p_hash=: (String) -> String + + attr_reader quality: Integer? + + def quality=: (Integer) -> Integer + + attr_reader size: Integer? + + def size=: (Integer) -> Integer + + attr_reader video_codec: String? + + def video_codec=: (String) -> String + + attr_reader width: Integer? + + def width=: (Integer) -> Integer + + def initialize: ( + ?audio_codec: String, + ?bit_rate: Integer, + ?density: Integer, + ?duration: Integer, + ?exif: Imagekitio::Metadata::Exif, + ?format_: String, + ?has_color_profile: bool, + ?has_transparency: bool, + ?height: Integer, + ?p_hash: String, + ?quality: Integer, + ?size: Integer, + ?video_codec: String, + ?width: Integer + ) -> void + + def to_hash: -> { + audio_codec: String, + bit_rate: Integer, + density: Integer, + duration: Integer, + exif: Imagekitio::Metadata::Exif, + format_: String, + has_color_profile: bool, + has_transparency: bool, + height: Integer, + p_hash: String, + quality: Integer, + size: Integer, + video_codec: String, + width: Integer + } + + type exif = + { + exif: Imagekitio::Metadata::Exif::Exif, + gps: Imagekitio::Metadata::Exif::Gps, + image: Imagekitio::Metadata::Exif::Image, + interoperability: Imagekitio::Metadata::Exif::Interoperability, + makernote: ::Hash[Symbol, top], + thumbnail: Imagekitio::Metadata::Exif::Thumbnail + } + + class Exif < Imagekitio::Internal::Type::BaseModel + attr_reader exif: Imagekitio::Metadata::Exif::Exif? + + def exif=: ( + Imagekitio::Metadata::Exif::Exif + ) -> Imagekitio::Metadata::Exif::Exif + + attr_reader gps: Imagekitio::Metadata::Exif::Gps? + + def gps=: ( + Imagekitio::Metadata::Exif::Gps + ) -> Imagekitio::Metadata::Exif::Gps + + attr_reader image: Imagekitio::Metadata::Exif::Image? + + def image=: ( + Imagekitio::Metadata::Exif::Image + ) -> Imagekitio::Metadata::Exif::Image + + attr_reader interoperability: Imagekitio::Metadata::Exif::Interoperability? + + def interoperability=: ( + Imagekitio::Metadata::Exif::Interoperability + ) -> Imagekitio::Metadata::Exif::Interoperability + + attr_reader makernote: ::Hash[Symbol, top]? + + def makernote=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader thumbnail: Imagekitio::Metadata::Exif::Thumbnail? + + def thumbnail=: ( + Imagekitio::Metadata::Exif::Thumbnail + ) -> Imagekitio::Metadata::Exif::Thumbnail + + def initialize: ( + ?exif: Imagekitio::Metadata::Exif::Exif, + ?gps: Imagekitio::Metadata::Exif::Gps, + ?image: Imagekitio::Metadata::Exif::Image, + ?interoperability: Imagekitio::Metadata::Exif::Interoperability, + ?makernote: ::Hash[Symbol, top], + ?thumbnail: Imagekitio::Metadata::Exif::Thumbnail + ) -> void + + def to_hash: -> { + exif: Imagekitio::Metadata::Exif::Exif, + gps: Imagekitio::Metadata::Exif::Gps, + image: Imagekitio::Metadata::Exif::Image, + interoperability: Imagekitio::Metadata::Exif::Interoperability, + makernote: ::Hash[Symbol, top], + thumbnail: Imagekitio::Metadata::Exif::Thumbnail + } + + type exif = + { + aperture_value: Float, + color_space: Integer, + create_date: String, + custom_rendered: Integer, + date_time_original: String, + exif_image_height: Integer, + exif_image_width: Integer, + exif_version: String, + exposure_compensation: Float, + exposure_mode: Integer, + exposure_program: Integer, + exposure_time: Float, + flash: Integer, + flashpix_version: String, + f_number: Float, + focal_length: Integer, + focal_plane_resolution_unit: Integer, + focal_plane_x_resolution: Float, + focal_plane_y_resolution: Float, + interop_offset: Integer, + iso: Integer, + metering_mode: Integer, + scene_capture_type: Integer, + shutter_speed_value: Float, + sub_sec_time: String, + white_balance: Integer + } + + class Exif < Imagekitio::Internal::Type::BaseModel + attr_reader aperture_value: Float? + + def aperture_value=: (Float) -> Float + + attr_reader color_space: Integer? + + def color_space=: (Integer) -> Integer + + attr_reader create_date: String? + + def create_date=: (String) -> String + + attr_reader custom_rendered: Integer? + + def custom_rendered=: (Integer) -> Integer + + attr_reader date_time_original: String? + + def date_time_original=: (String) -> String + + attr_reader exif_image_height: Integer? + + def exif_image_height=: (Integer) -> Integer + + attr_reader exif_image_width: Integer? + + def exif_image_width=: (Integer) -> Integer + + attr_reader exif_version: String? + + def exif_version=: (String) -> String + + attr_reader exposure_compensation: Float? + + def exposure_compensation=: (Float) -> Float + + attr_reader exposure_mode: Integer? + + def exposure_mode=: (Integer) -> Integer + + attr_reader exposure_program: Integer? + + def exposure_program=: (Integer) -> Integer + + attr_reader exposure_time: Float? + + def exposure_time=: (Float) -> Float + + attr_reader flash: Integer? + + def flash=: (Integer) -> Integer + + attr_reader flashpix_version: String? + + def flashpix_version=: (String) -> String + + attr_reader f_number: Float? + + def f_number=: (Float) -> Float + + attr_reader focal_length: Integer? + + def focal_length=: (Integer) -> Integer + + attr_reader focal_plane_resolution_unit: Integer? + + def focal_plane_resolution_unit=: (Integer) -> Integer + + attr_reader focal_plane_x_resolution: Float? + + def focal_plane_x_resolution=: (Float) -> Float + + attr_reader focal_plane_y_resolution: Float? + + def focal_plane_y_resolution=: (Float) -> Float + + attr_reader interop_offset: Integer? + + def interop_offset=: (Integer) -> Integer + + attr_reader iso: Integer? + + def iso=: (Integer) -> Integer + + attr_reader metering_mode: Integer? + + def metering_mode=: (Integer) -> Integer + + attr_reader scene_capture_type: Integer? + + def scene_capture_type=: (Integer) -> Integer + + attr_reader shutter_speed_value: Float? + + def shutter_speed_value=: (Float) -> Float + + attr_reader sub_sec_time: String? + + def sub_sec_time=: (String) -> String + + attr_reader white_balance: Integer? + + def white_balance=: (Integer) -> Integer + + def initialize: ( + ?aperture_value: Float, + ?color_space: Integer, + ?create_date: String, + ?custom_rendered: Integer, + ?date_time_original: String, + ?exif_image_height: Integer, + ?exif_image_width: Integer, + ?exif_version: String, + ?exposure_compensation: Float, + ?exposure_mode: Integer, + ?exposure_program: Integer, + ?exposure_time: Float, + ?flash: Integer, + ?flashpix_version: String, + ?f_number: Float, + ?focal_length: Integer, + ?focal_plane_resolution_unit: Integer, + ?focal_plane_x_resolution: Float, + ?focal_plane_y_resolution: Float, + ?interop_offset: Integer, + ?iso: Integer, + ?metering_mode: Integer, + ?scene_capture_type: Integer, + ?shutter_speed_value: Float, + ?sub_sec_time: String, + ?white_balance: Integer + ) -> void + + def to_hash: -> { + aperture_value: Float, + color_space: Integer, + create_date: String, + custom_rendered: Integer, + date_time_original: String, + exif_image_height: Integer, + exif_image_width: Integer, + exif_version: String, + exposure_compensation: Float, + exposure_mode: Integer, + exposure_program: Integer, + exposure_time: Float, + flash: Integer, + flashpix_version: String, + f_number: Float, + focal_length: Integer, + focal_plane_resolution_unit: Integer, + focal_plane_x_resolution: Float, + focal_plane_y_resolution: Float, + interop_offset: Integer, + iso: Integer, + metering_mode: Integer, + scene_capture_type: Integer, + shutter_speed_value: Float, + sub_sec_time: String, + white_balance: Integer + } + end + + type gps = { gps_version_id: ::Array[Integer] } + + class Gps < Imagekitio::Internal::Type::BaseModel + attr_reader gps_version_id: ::Array[Integer]? + + def gps_version_id=: (::Array[Integer]) -> ::Array[Integer] + + def initialize: (?gps_version_id: ::Array[Integer]) -> void + + def to_hash: -> { gps_version_id: ::Array[Integer] } + end + + type image = + { + exif_offset: Integer, + gps_info: Integer, + make: String, + model: String, + modify_date: String, + orientation: Integer, + resolution_unit: Integer, + software: String, + x_resolution: Integer, + y_cb_cr_positioning: Integer, + y_resolution: Integer + } + + class Image < Imagekitio::Internal::Type::BaseModel + attr_reader exif_offset: Integer? + + def exif_offset=: (Integer) -> Integer + + attr_reader gps_info: Integer? + + def gps_info=: (Integer) -> Integer + + attr_reader make: String? + + def make=: (String) -> String + + attr_reader model: String? + + def model=: (String) -> String + + attr_reader modify_date: String? + + def modify_date=: (String) -> String + + attr_reader orientation: Integer? + + def orientation=: (Integer) -> Integer + + attr_reader resolution_unit: Integer? + + def resolution_unit=: (Integer) -> Integer + + attr_reader software: String? + + def software=: (String) -> String + + attr_reader x_resolution: Integer? + + def x_resolution=: (Integer) -> Integer + + attr_reader y_cb_cr_positioning: Integer? + + def y_cb_cr_positioning=: (Integer) -> Integer + + attr_reader y_resolution: Integer? + + def y_resolution=: (Integer) -> Integer + + def initialize: ( + ?exif_offset: Integer, + ?gps_info: Integer, + ?make: String, + ?model: String, + ?modify_date: String, + ?orientation: Integer, + ?resolution_unit: Integer, + ?software: String, + ?x_resolution: Integer, + ?y_cb_cr_positioning: Integer, + ?y_resolution: Integer + ) -> void + + def to_hash: -> { + exif_offset: Integer, + gps_info: Integer, + make: String, + model: String, + modify_date: String, + orientation: Integer, + resolution_unit: Integer, + software: String, + x_resolution: Integer, + y_cb_cr_positioning: Integer, + y_resolution: Integer + } + end + + type interoperability = + { interop_index: String, interop_version: String } + + class Interoperability < Imagekitio::Internal::Type::BaseModel + attr_reader interop_index: String? + + def interop_index=: (String) -> String + + attr_reader interop_version: String? + + def interop_version=: (String) -> String + + def initialize: ( + ?interop_index: String, + ?interop_version: String + ) -> void + + def to_hash: -> { interop_index: String, interop_version: String } + end + + type thumbnail = + { + compression: Integer, + resolution_unit: Integer, + thumbnail_length: Integer, + thumbnail_offset: Integer, + x_resolution: Integer, + y_resolution: Integer + } + + class Thumbnail < Imagekitio::Internal::Type::BaseModel + attr_reader compression: Integer? + + def compression=: (Integer) -> Integer + + attr_reader resolution_unit: Integer? + + def resolution_unit=: (Integer) -> Integer + + attr_reader thumbnail_length: Integer? + + def thumbnail_length=: (Integer) -> Integer + + attr_reader thumbnail_offset: Integer? + + def thumbnail_offset=: (Integer) -> Integer + + attr_reader x_resolution: Integer? + + def x_resolution=: (Integer) -> Integer + + attr_reader y_resolution: Integer? + + def y_resolution=: (Integer) -> Integer + + def initialize: ( + ?compression: Integer, + ?resolution_unit: Integer, + ?thumbnail_length: Integer, + ?thumbnail_offset: Integer, + ?x_resolution: Integer, + ?y_resolution: Integer + ) -> void + + def to_hash: -> { + compression: Integer, + resolution_unit: Integer, + thumbnail_length: Integer, + thumbnail_offset: Integer, + x_resolution: Integer, + y_resolution: Integer + } + end + end + end + end +end diff --git a/sig/imagekitio/models/overlay.rbs b/sig/imagekitio/models/overlay.rbs new file mode 100644 index 00000000..c124fe05 --- /dev/null +++ b/sig/imagekitio/models/overlay.rbs @@ -0,0 +1,16 @@ +module Imagekitio + module Models + type overlay = + Imagekitio::TextOverlay + | Imagekitio::ImageOverlay + | Imagekitio::VideoOverlay + | Imagekitio::SubtitleOverlay + | Imagekitio::SolidColorOverlay + + module Overlay + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::overlay] + end + end +end diff --git a/sig/imagekitio/models/overlay_position.rbs b/sig/imagekitio/models/overlay_position.rbs new file mode 100644 index 00000000..e2c9c5a6 --- /dev/null +++ b/sig/imagekitio/models/overlay_position.rbs @@ -0,0 +1,85 @@ +module Imagekitio + module Models + type overlay_position = + { + focus: Imagekitio::Models::OverlayPosition::focus, + x: Imagekitio::Models::OverlayPosition::x, + y_: Imagekitio::Models::OverlayPosition::y_ + } + + class OverlayPosition < Imagekitio::Internal::Type::BaseModel + attr_reader focus: Imagekitio::Models::OverlayPosition::focus? + + def focus=: ( + Imagekitio::Models::OverlayPosition::focus + ) -> Imagekitio::Models::OverlayPosition::focus + + attr_reader x: Imagekitio::Models::OverlayPosition::x? + + def x=: ( + Imagekitio::Models::OverlayPosition::x + ) -> Imagekitio::Models::OverlayPosition::x + + attr_reader y_: Imagekitio::Models::OverlayPosition::y_? + + def y_=: ( + Imagekitio::Models::OverlayPosition::y_ + ) -> Imagekitio::Models::OverlayPosition::y_ + + def initialize: ( + ?focus: Imagekitio::Models::OverlayPosition::focus, + ?x: Imagekitio::Models::OverlayPosition::x, + ?y_: Imagekitio::Models::OverlayPosition::y_ + ) -> void + + def to_hash: -> { + focus: Imagekitio::Models::OverlayPosition::focus, + x: Imagekitio::Models::OverlayPosition::x, + y_: Imagekitio::Models::OverlayPosition::y_ + } + + type focus = + :center + | :top + | :left + | :bottom + | :right + | :top_left + | :top_right + | :bottom_left + | :bottom_right + + module Focus + extend Imagekitio::Internal::Type::Enum + + CENTER: :center + TOP: :top + LEFT: :left + BOTTOM: :bottom + RIGHT: :right + TOP_LEFT: :top_left + TOP_RIGHT: :top_right + BOTTOM_LEFT: :bottom_left + BOTTOM_RIGHT: :bottom_right + + def self?.values: -> ::Array[Imagekitio::Models::OverlayPosition::focus] + end + + type x = Float | String + + module X + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::OverlayPosition::x] + end + + type y_ = Float | String + + module Y + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::OverlayPosition::y_] + end + end + end +end diff --git a/sig/imagekitio/models/overlay_timing.rbs b/sig/imagekitio/models/overlay_timing.rbs new file mode 100644 index 00000000..4f5759de --- /dev/null +++ b/sig/imagekitio/models/overlay_timing.rbs @@ -0,0 +1,66 @@ +module Imagekitio + module Models + type overlay_timing = + { + duration: Imagekitio::Models::OverlayTiming::duration, + end_: Imagekitio::Models::OverlayTiming::end_, + start: Imagekitio::Models::OverlayTiming::start + } + + class OverlayTiming < Imagekitio::Internal::Type::BaseModel + attr_reader duration: Imagekitio::Models::OverlayTiming::duration? + + def duration=: ( + Imagekitio::Models::OverlayTiming::duration + ) -> Imagekitio::Models::OverlayTiming::duration + + attr_reader end_: Imagekitio::Models::OverlayTiming::end_? + + def end_=: ( + Imagekitio::Models::OverlayTiming::end_ + ) -> Imagekitio::Models::OverlayTiming::end_ + + attr_reader start: Imagekitio::Models::OverlayTiming::start? + + def start=: ( + Imagekitio::Models::OverlayTiming::start + ) -> Imagekitio::Models::OverlayTiming::start + + def initialize: ( + ?duration: Imagekitio::Models::OverlayTiming::duration, + ?end_: Imagekitio::Models::OverlayTiming::end_, + ?start: Imagekitio::Models::OverlayTiming::start + ) -> void + + def to_hash: -> { + duration: Imagekitio::Models::OverlayTiming::duration, + end_: Imagekitio::Models::OverlayTiming::end_, + start: Imagekitio::Models::OverlayTiming::start + } + + type duration = Float | String + + module Duration + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::OverlayTiming::duration] + end + + type end_ = Float | String + + module End + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::OverlayTiming::end_] + end + + type start = Float | String + + module Start + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::OverlayTiming::start] + end + end + end +end diff --git a/sig/imagekitio/models/responsive_image_attributes.rbs b/sig/imagekitio/models/responsive_image_attributes.rbs new file mode 100644 index 00000000..2fe55eec --- /dev/null +++ b/sig/imagekitio/models/responsive_image_attributes.rbs @@ -0,0 +1,36 @@ +module Imagekitio + module Models + type responsive_image_attributes = + { src: String, sizes: String, src_set: String, width: Float } + + class ResponsiveImageAttributes < Imagekitio::Internal::Type::BaseModel + attr_accessor src: String + + attr_reader sizes: String? + + def sizes=: (String) -> String + + attr_reader src_set: String? + + def src_set=: (String) -> String + + attr_reader width: Float? + + def width=: (Float) -> Float + + def initialize: ( + src: String, + ?sizes: String, + ?src_set: String, + ?width: Float + ) -> void + + def to_hash: -> { + src: String, + sizes: String, + src_set: String, + width: Float + } + end + end +end diff --git a/sig/imagekitio/models/solid_color_overlay.rbs b/sig/imagekitio/models/solid_color_overlay.rbs new file mode 100644 index 00000000..165260f6 --- /dev/null +++ b/sig/imagekitio/models/solid_color_overlay.rbs @@ -0,0 +1,38 @@ +module Imagekitio + module Models + type solid_color_overlay = + { + color: String, + type: :solidColor, + transformation: ::Array[Imagekitio::SolidColorOverlayTransformation] + } + + class SolidColorOverlay < Imagekitio::Models::BaseOverlay + def color: -> String + + def color=: (String _) -> String + + def `type`: -> :solidColor + + def type=: (:solidColor _) -> :solidColor + + def transformation: -> ::Array[Imagekitio::SolidColorOverlayTransformation]? + + def transformation=: ( + ::Array[Imagekitio::SolidColorOverlayTransformation] _ + ) -> ::Array[Imagekitio::SolidColorOverlayTransformation] + + def initialize: ( + color: String, + ?transformation: ::Array[Imagekitio::SolidColorOverlayTransformation], + ?type: :solidColor + ) -> void + + def to_hash: -> { + color: String, + type: :solidColor, + transformation: ::Array[Imagekitio::SolidColorOverlayTransformation] + } + end + end +end diff --git a/sig/imagekitio/models/solid_color_overlay_transformation.rbs b/sig/imagekitio/models/solid_color_overlay_transformation.rbs new file mode 100644 index 00000000..a2877675 --- /dev/null +++ b/sig/imagekitio/models/solid_color_overlay_transformation.rbs @@ -0,0 +1,97 @@ +module Imagekitio + module Models + type solid_color_overlay_transformation = + { + alpha: Float, + background: String, + gradient: Imagekitio::Models::SolidColorOverlayTransformation::gradient, + height: Imagekitio::Models::SolidColorOverlayTransformation::height, + radius: Imagekitio::Models::SolidColorOverlayTransformation::radius, + width: Imagekitio::Models::SolidColorOverlayTransformation::width + } + + class SolidColorOverlayTransformation < Imagekitio::Internal::Type::BaseModel + attr_reader alpha: Float? + + def alpha=: (Float) -> Float + + attr_reader background: String? + + def background=: (String) -> String + + attr_reader gradient: Imagekitio::Models::SolidColorOverlayTransformation::gradient? + + def gradient=: ( + Imagekitio::Models::SolidColorOverlayTransformation::gradient + ) -> Imagekitio::Models::SolidColorOverlayTransformation::gradient + + attr_reader height: Imagekitio::Models::SolidColorOverlayTransformation::height? + + def height=: ( + Imagekitio::Models::SolidColorOverlayTransformation::height + ) -> Imagekitio::Models::SolidColorOverlayTransformation::height + + attr_reader radius: Imagekitio::Models::SolidColorOverlayTransformation::radius? + + def radius=: ( + Imagekitio::Models::SolidColorOverlayTransformation::radius + ) -> Imagekitio::Models::SolidColorOverlayTransformation::radius + + attr_reader width: Imagekitio::Models::SolidColorOverlayTransformation::width? + + def width=: ( + Imagekitio::Models::SolidColorOverlayTransformation::width + ) -> Imagekitio::Models::SolidColorOverlayTransformation::width + + def initialize: ( + ?alpha: Float, + ?background: String, + ?gradient: Imagekitio::Models::SolidColorOverlayTransformation::gradient, + ?height: Imagekitio::Models::SolidColorOverlayTransformation::height, + ?radius: Imagekitio::Models::SolidColorOverlayTransformation::radius, + ?width: Imagekitio::Models::SolidColorOverlayTransformation::width + ) -> void + + def to_hash: -> { + alpha: Float, + background: String, + gradient: Imagekitio::Models::SolidColorOverlayTransformation::gradient, + height: Imagekitio::Models::SolidColorOverlayTransformation::height, + radius: Imagekitio::Models::SolidColorOverlayTransformation::radius, + width: Imagekitio::Models::SolidColorOverlayTransformation::width + } + + type gradient = true | String + + module Gradient + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::SolidColorOverlayTransformation::gradient] + end + + type height = Float | String + + module Height + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::SolidColorOverlayTransformation::height] + end + + type radius = Float | :max + + module Radius + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::SolidColorOverlayTransformation::radius] + end + + type width = Float | String + + module Width + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::SolidColorOverlayTransformation::width] + end + end + end +end diff --git a/sig/imagekitio/models/src_options.rbs b/sig/imagekitio/models/src_options.rbs new file mode 100644 index 00000000..d639bf63 --- /dev/null +++ b/sig/imagekitio/models/src_options.rbs @@ -0,0 +1,64 @@ +module Imagekitio + module Models + type src_options = + { + src: String, + url_endpoint: String, + expires_in: Float, + query_parameters: ::Hash[Symbol, String], + signed: bool, + transformation: ::Array[Imagekitio::Transformation], + transformation_position: Imagekitio::Models::transformation_position + } + + class SrcOptions < Imagekitio::Internal::Type::BaseModel + attr_accessor src: String + + attr_accessor url_endpoint: String + + attr_reader expires_in: Float? + + def expires_in=: (Float) -> Float + + attr_reader query_parameters: ::Hash[Symbol, String]? + + def query_parameters=: (::Hash[Symbol, String]) -> ::Hash[Symbol, String] + + attr_reader signed: bool? + + def signed=: (bool) -> bool + + attr_reader transformation: ::Array[Imagekitio::Transformation]? + + def transformation=: ( + ::Array[Imagekitio::Transformation] + ) -> ::Array[Imagekitio::Transformation] + + attr_reader transformation_position: Imagekitio::Models::transformation_position? + + def transformation_position=: ( + Imagekitio::Models::transformation_position + ) -> Imagekitio::Models::transformation_position + + def initialize: ( + src: String, + url_endpoint: String, + ?expires_in: Float, + ?query_parameters: ::Hash[Symbol, String], + ?signed: bool, + ?transformation: ::Array[Imagekitio::Transformation], + ?transformation_position: Imagekitio::Models::transformation_position + ) -> void + + def to_hash: -> { + src: String, + url_endpoint: String, + expires_in: Float, + query_parameters: ::Hash[Symbol, String], + signed: bool, + transformation: ::Array[Imagekitio::Transformation], + transformation_position: Imagekitio::Models::transformation_position + } + end + end +end diff --git a/sig/imagekitio/models/streaming_resolution.rbs b/sig/imagekitio/models/streaming_resolution.rbs new file mode 100644 index 00000000..71aa3716 --- /dev/null +++ b/sig/imagekitio/models/streaming_resolution.rbs @@ -0,0 +1,20 @@ +module Imagekitio + module Models + type streaming_resolution = + :"240" | :"360" | :"480" | :"720" | :"1080" | :"1440" | :"2160" + + module StreamingResolution + extend Imagekitio::Internal::Type::Enum + + STREAMING_RESOLUTION_240: :"240" + STREAMING_RESOLUTION_360: :"360" + STREAMING_RESOLUTION_480: :"480" + STREAMING_RESOLUTION_720: :"720" + STREAMING_RESOLUTION_1080: :"1080" + STREAMING_RESOLUTION_1440: :"1440" + STREAMING_RESOLUTION_2160: :"2160" + + def self?.values: -> ::Array[Imagekitio::Models::streaming_resolution] + end + end +end diff --git a/sig/imagekitio/models/subtitle_overlay.rbs b/sig/imagekitio/models/subtitle_overlay.rbs new file mode 100644 index 00000000..e1a0c4a3 --- /dev/null +++ b/sig/imagekitio/models/subtitle_overlay.rbs @@ -0,0 +1,59 @@ +module Imagekitio + module Models + type subtitle_overlay = + { + input: String, + type: :subtitle, + encoding: Imagekitio::Models::SubtitleOverlay::encoding, + transformation: ::Array[Imagekitio::SubtitleOverlayTransformation] + } + + class SubtitleOverlay < Imagekitio::Models::BaseOverlay + def input: -> String + + def input=: (String _) -> String + + def `type`: -> :subtitle + + def type=: (:subtitle _) -> :subtitle + + def encoding: -> Imagekitio::Models::SubtitleOverlay::encoding? + + def encoding=: ( + Imagekitio::Models::SubtitleOverlay::encoding _ + ) -> Imagekitio::Models::SubtitleOverlay::encoding + + def transformation: -> ::Array[Imagekitio::SubtitleOverlayTransformation]? + + def transformation=: ( + ::Array[Imagekitio::SubtitleOverlayTransformation] _ + ) -> ::Array[Imagekitio::SubtitleOverlayTransformation] + + def initialize: ( + input: String, + ?encoding: Imagekitio::Models::SubtitleOverlay::encoding, + ?transformation: ::Array[Imagekitio::SubtitleOverlayTransformation], + ?type: :subtitle + ) -> void + + def to_hash: -> { + input: String, + type: :subtitle, + encoding: Imagekitio::Models::SubtitleOverlay::encoding, + transformation: ::Array[Imagekitio::SubtitleOverlayTransformation] + } + + type encoding = :auto | :plain | :base64 + + module Encoding + extend Imagekitio::Internal::Type::Enum + + AUTO: :auto + PLAIN: :plain + BASE64: :base64 + + def self?.values: -> ::Array[Imagekitio::Models::SubtitleOverlay::encoding] + end + end + end +end diff --git a/sig/imagekitio/models/subtitle_overlay_transformation.rbs b/sig/imagekitio/models/subtitle_overlay_transformation.rbs new file mode 100644 index 00000000..6425cb1b --- /dev/null +++ b/sig/imagekitio/models/subtitle_overlay_transformation.rbs @@ -0,0 +1,78 @@ +module Imagekitio + module Models + type subtitle_overlay_transformation = + { + background: String, + color: String, + font_family: String, + font_outline: String, + font_shadow: String, + font_size: Float, + typography: Imagekitio::Models::SubtitleOverlayTransformation::typography + } + + class SubtitleOverlayTransformation < Imagekitio::Internal::Type::BaseModel + attr_reader background: String? + + def background=: (String) -> String + + attr_reader color: String? + + def color=: (String) -> String + + attr_reader font_family: String? + + def font_family=: (String) -> String + + attr_reader font_outline: String? + + def font_outline=: (String) -> String + + attr_reader font_shadow: String? + + def font_shadow=: (String) -> String + + attr_reader font_size: Float? + + def font_size=: (Float) -> Float + + attr_reader typography: Imagekitio::Models::SubtitleOverlayTransformation::typography? + + def typography=: ( + Imagekitio::Models::SubtitleOverlayTransformation::typography + ) -> Imagekitio::Models::SubtitleOverlayTransformation::typography + + def initialize: ( + ?background: String, + ?color: String, + ?font_family: String, + ?font_outline: String, + ?font_shadow: String, + ?font_size: Float, + ?typography: Imagekitio::Models::SubtitleOverlayTransformation::typography + ) -> void + + def to_hash: -> { + background: String, + color: String, + font_family: String, + font_outline: String, + font_shadow: String, + font_size: Float, + typography: Imagekitio::Models::SubtitleOverlayTransformation::typography + } + + type typography = :b | :i | :b_i + + module Typography + extend Imagekitio::Internal::Type::Enum + + B: :b + I: :i + B_I: :b_i + + def self?.values: -> ::Array[Imagekitio::Models::SubtitleOverlayTransformation::typography] + end + end + end +end diff --git a/sig/imagekitio/models/text_overlay.rbs b/sig/imagekitio/models/text_overlay.rbs new file mode 100644 index 00000000..d37c727c --- /dev/null +++ b/sig/imagekitio/models/text_overlay.rbs @@ -0,0 +1,59 @@ +module Imagekitio + module Models + type text_overlay = + { + text: String, + type: :text, + encoding: Imagekitio::Models::TextOverlay::encoding, + transformation: ::Array[Imagekitio::TextOverlayTransformation] + } + + class TextOverlay < Imagekitio::Models::BaseOverlay + def text: -> String + + def text=: (String _) -> String + + def `type`: -> :text + + def type=: (:text _) -> :text + + def encoding: -> Imagekitio::Models::TextOverlay::encoding? + + def encoding=: ( + Imagekitio::Models::TextOverlay::encoding _ + ) -> Imagekitio::Models::TextOverlay::encoding + + def transformation: -> ::Array[Imagekitio::TextOverlayTransformation]? + + def transformation=: ( + ::Array[Imagekitio::TextOverlayTransformation] _ + ) -> ::Array[Imagekitio::TextOverlayTransformation] + + def initialize: ( + text: String, + ?encoding: Imagekitio::Models::TextOverlay::encoding, + ?transformation: ::Array[Imagekitio::TextOverlayTransformation], + ?type: :text + ) -> void + + def to_hash: -> { + text: String, + type: :text, + encoding: Imagekitio::Models::TextOverlay::encoding, + transformation: ::Array[Imagekitio::TextOverlayTransformation] + } + + type encoding = :auto | :plain | :base64 + + module Encoding + extend Imagekitio::Internal::Type::Enum + + AUTO: :auto + PLAIN: :plain + BASE64: :base64 + + def self?.values: -> ::Array[Imagekitio::Models::TextOverlay::encoding] + end + end + end +end diff --git a/sig/imagekitio/models/text_overlay_transformation.rbs b/sig/imagekitio/models/text_overlay_transformation.rbs new file mode 100644 index 00000000..ab827889 --- /dev/null +++ b/sig/imagekitio/models/text_overlay_transformation.rbs @@ -0,0 +1,195 @@ +module Imagekitio + module Models + type text_overlay_transformation = + { + alpha: Float, + background: String, + flip: Imagekitio::Models::TextOverlayTransformation::flip, + font_color: String, + font_family: String, + font_size: Imagekitio::Models::TextOverlayTransformation::font_size, + inner_alignment: Imagekitio::Models::TextOverlayTransformation::inner_alignment, + line_height: Imagekitio::Models::TextOverlayTransformation::line_height, + padding: Imagekitio::Models::TextOverlayTransformation::padding, + radius: Imagekitio::Models::TextOverlayTransformation::radius, + rotation: Imagekitio::Models::TextOverlayTransformation::rotation, + typography: String, + width: Imagekitio::Models::TextOverlayTransformation::width + } + + class TextOverlayTransformation < Imagekitio::Internal::Type::BaseModel + attr_reader alpha: Float? + + def alpha=: (Float) -> Float + + attr_reader background: String? + + def background=: (String) -> String + + attr_reader flip: Imagekitio::Models::TextOverlayTransformation::flip? + + def flip=: ( + Imagekitio::Models::TextOverlayTransformation::flip + ) -> Imagekitio::Models::TextOverlayTransformation::flip + + attr_reader font_color: String? + + def font_color=: (String) -> String + + attr_reader font_family: String? + + def font_family=: (String) -> String + + attr_reader font_size: Imagekitio::Models::TextOverlayTransformation::font_size? + + def font_size=: ( + Imagekitio::Models::TextOverlayTransformation::font_size + ) -> Imagekitio::Models::TextOverlayTransformation::font_size + + attr_reader inner_alignment: Imagekitio::Models::TextOverlayTransformation::inner_alignment? + + def inner_alignment=: ( + Imagekitio::Models::TextOverlayTransformation::inner_alignment + ) -> Imagekitio::Models::TextOverlayTransformation::inner_alignment + + attr_reader line_height: Imagekitio::Models::TextOverlayTransformation::line_height? + + def line_height=: ( + Imagekitio::Models::TextOverlayTransformation::line_height + ) -> Imagekitio::Models::TextOverlayTransformation::line_height + + attr_reader padding: Imagekitio::Models::TextOverlayTransformation::padding? + + def padding=: ( + Imagekitio::Models::TextOverlayTransformation::padding + ) -> Imagekitio::Models::TextOverlayTransformation::padding + + attr_reader radius: Imagekitio::Models::TextOverlayTransformation::radius? + + def radius=: ( + Imagekitio::Models::TextOverlayTransformation::radius + ) -> Imagekitio::Models::TextOverlayTransformation::radius + + attr_reader rotation: Imagekitio::Models::TextOverlayTransformation::rotation? + + def rotation=: ( + Imagekitio::Models::TextOverlayTransformation::rotation + ) -> Imagekitio::Models::TextOverlayTransformation::rotation + + attr_reader typography: String? + + def typography=: (String) -> String + + attr_reader width: Imagekitio::Models::TextOverlayTransformation::width? + + def width=: ( + Imagekitio::Models::TextOverlayTransformation::width + ) -> Imagekitio::Models::TextOverlayTransformation::width + + def initialize: ( + ?alpha: Float, + ?background: String, + ?flip: Imagekitio::Models::TextOverlayTransformation::flip, + ?font_color: String, + ?font_family: String, + ?font_size: Imagekitio::Models::TextOverlayTransformation::font_size, + ?inner_alignment: Imagekitio::Models::TextOverlayTransformation::inner_alignment, + ?line_height: Imagekitio::Models::TextOverlayTransformation::line_height, + ?padding: Imagekitio::Models::TextOverlayTransformation::padding, + ?radius: Imagekitio::Models::TextOverlayTransformation::radius, + ?rotation: Imagekitio::Models::TextOverlayTransformation::rotation, + ?typography: String, + ?width: Imagekitio::Models::TextOverlayTransformation::width + ) -> void + + def to_hash: -> { + alpha: Float, + background: String, + flip: Imagekitio::Models::TextOverlayTransformation::flip, + font_color: String, + font_family: String, + font_size: Imagekitio::Models::TextOverlayTransformation::font_size, + inner_alignment: Imagekitio::Models::TextOverlayTransformation::inner_alignment, + line_height: Imagekitio::Models::TextOverlayTransformation::line_height, + padding: Imagekitio::Models::TextOverlayTransformation::padding, + radius: Imagekitio::Models::TextOverlayTransformation::radius, + rotation: Imagekitio::Models::TextOverlayTransformation::rotation, + typography: String, + width: Imagekitio::Models::TextOverlayTransformation::width + } + + type flip = :h | :v | :h_v | :v_h + + module Flip + extend Imagekitio::Internal::Type::Enum + + H: :h + V: :v + H_V: :h_v + V_H: :v_h + + def self?.values: -> ::Array[Imagekitio::Models::TextOverlayTransformation::flip] + end + + type font_size = Float | String + + module FontSize + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::TextOverlayTransformation::font_size] + end + + type inner_alignment = :left | :right | :center + + module InnerAlignment + extend Imagekitio::Internal::Type::Enum + + LEFT: :left + RIGHT: :right + CENTER: :center + + def self?.values: -> ::Array[Imagekitio::Models::TextOverlayTransformation::inner_alignment] + end + + type line_height = Float | String + + module LineHeight + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::TextOverlayTransformation::line_height] + end + + type padding = Float | String + + module Padding + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::TextOverlayTransformation::padding] + end + + type radius = Float | :max + + module Radius + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::TextOverlayTransformation::radius] + end + + type rotation = Float | String + + module Rotation + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::TextOverlayTransformation::rotation] + end + + type width = Float | String + + module Width + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::TextOverlayTransformation::width] + end + end + end +end diff --git a/sig/imagekitio/models/transformation.rbs b/sig/imagekitio/models/transformation.rbs new file mode 100644 index 00000000..8b3f4637 --- /dev/null +++ b/sig/imagekitio/models/transformation.rbs @@ -0,0 +1,763 @@ +module Imagekitio + module Models + type transformation = + { + ai_change_background: String, + ai_drop_shadow: Imagekitio::Models::Transformation::ai_drop_shadow, + ai_edit: String, + ai_remove_background: Imagekitio::Models::Transformation::ai_remove_background, + ai_remove_background_external: Imagekitio::Models::Transformation::ai_remove_background_external, + ai_retouch: Imagekitio::Models::Transformation::ai_retouch, + ai_upscale: Imagekitio::Models::Transformation::ai_upscale, + ai_variation: Imagekitio::Models::Transformation::ai_variation, + aspect_ratio: Imagekitio::Models::Transformation::aspect_ratio, + audio_codec: Imagekitio::Models::Transformation::audio_codec, + background: String, + blur: Float, + border: String, + color_profile: bool, + contrast_stretch: Imagekitio::Models::Transformation::contrast_stretch, + crop: Imagekitio::Models::Transformation::crop, + crop_mode: Imagekitio::Models::Transformation::crop_mode, + default_image: String, + dpr: Float, + duration: Imagekitio::Models::Transformation::duration, + end_offset: Imagekitio::Models::Transformation::end_offset, + flip: Imagekitio::Models::Transformation::flip, + focus: String, + format_: Imagekitio::Models::Transformation::format_, + gradient: Imagekitio::Models::Transformation::gradient, + grayscale: Imagekitio::Models::Transformation::grayscale, + height: Imagekitio::Models::Transformation::height, + lossless: bool, + metadata: bool, + named: String, + opacity: Float, + original: bool, + overlay: Imagekitio::Models::overlay, + page: Imagekitio::Models::Transformation::page, + progressive: bool, + quality: Float, + radius: Imagekitio::Models::Transformation::radius, + raw: String, + rotation: Imagekitio::Models::Transformation::rotation, + shadow: Imagekitio::Models::Transformation::shadow, + sharpen: Imagekitio::Models::Transformation::sharpen, + start_offset: Imagekitio::Models::Transformation::start_offset, + streaming_resolutions: ::Array[Imagekitio::Models::streaming_resolution], + trim: Imagekitio::Models::Transformation::trim, + unsharp_mask: Imagekitio::Models::Transformation::unsharp_mask, + video_codec: Imagekitio::Models::Transformation::video_codec, + width: Imagekitio::Models::Transformation::width, + x: Imagekitio::Models::Transformation::x, + x_center: Imagekitio::Models::Transformation::x_center, + y_: Imagekitio::Models::Transformation::y_, + y_center: Imagekitio::Models::Transformation::y_center, + zoom: Float + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_reader ai_change_background: String? + + def ai_change_background=: (String) -> String + + attr_reader ai_drop_shadow: Imagekitio::Models::Transformation::ai_drop_shadow? + + def ai_drop_shadow=: ( + Imagekitio::Models::Transformation::ai_drop_shadow + ) -> Imagekitio::Models::Transformation::ai_drop_shadow + + attr_reader ai_edit: String? + + def ai_edit=: (String) -> String + + attr_reader ai_remove_background: Imagekitio::Models::Transformation::ai_remove_background? + + def ai_remove_background=: ( + Imagekitio::Models::Transformation::ai_remove_background + ) -> Imagekitio::Models::Transformation::ai_remove_background + + attr_reader ai_remove_background_external: Imagekitio::Models::Transformation::ai_remove_background_external? + + def ai_remove_background_external=: ( + Imagekitio::Models::Transformation::ai_remove_background_external + ) -> Imagekitio::Models::Transformation::ai_remove_background_external + + attr_reader ai_retouch: Imagekitio::Models::Transformation::ai_retouch? + + def ai_retouch=: ( + Imagekitio::Models::Transformation::ai_retouch + ) -> Imagekitio::Models::Transformation::ai_retouch + + attr_reader ai_upscale: Imagekitio::Models::Transformation::ai_upscale? + + def ai_upscale=: ( + Imagekitio::Models::Transformation::ai_upscale + ) -> Imagekitio::Models::Transformation::ai_upscale + + attr_reader ai_variation: Imagekitio::Models::Transformation::ai_variation? + + def ai_variation=: ( + Imagekitio::Models::Transformation::ai_variation + ) -> Imagekitio::Models::Transformation::ai_variation + + attr_reader aspect_ratio: Imagekitio::Models::Transformation::aspect_ratio? + + def aspect_ratio=: ( + Imagekitio::Models::Transformation::aspect_ratio + ) -> Imagekitio::Models::Transformation::aspect_ratio + + attr_reader audio_codec: Imagekitio::Models::Transformation::audio_codec? + + def audio_codec=: ( + Imagekitio::Models::Transformation::audio_codec + ) -> Imagekitio::Models::Transformation::audio_codec + + attr_reader background: String? + + def background=: (String) -> String + + attr_reader blur: Float? + + def blur=: (Float) -> Float + + attr_reader border: String? + + def border=: (String) -> String + + attr_reader color_profile: bool? + + def color_profile=: (bool) -> bool + + attr_reader contrast_stretch: Imagekitio::Models::Transformation::contrast_stretch? + + def contrast_stretch=: ( + Imagekitio::Models::Transformation::contrast_stretch + ) -> Imagekitio::Models::Transformation::contrast_stretch + + attr_reader crop: Imagekitio::Models::Transformation::crop? + + def crop=: ( + Imagekitio::Models::Transformation::crop + ) -> Imagekitio::Models::Transformation::crop + + attr_reader crop_mode: Imagekitio::Models::Transformation::crop_mode? + + def crop_mode=: ( + Imagekitio::Models::Transformation::crop_mode + ) -> Imagekitio::Models::Transformation::crop_mode + + attr_reader default_image: String? + + def default_image=: (String) -> String + + attr_reader dpr: Float? + + def dpr=: (Float) -> Float + + attr_reader duration: Imagekitio::Models::Transformation::duration? + + def duration=: ( + Imagekitio::Models::Transformation::duration + ) -> Imagekitio::Models::Transformation::duration + + attr_reader end_offset: Imagekitio::Models::Transformation::end_offset? + + def end_offset=: ( + Imagekitio::Models::Transformation::end_offset + ) -> Imagekitio::Models::Transformation::end_offset + + attr_reader flip: Imagekitio::Models::Transformation::flip? + + def flip=: ( + Imagekitio::Models::Transformation::flip + ) -> Imagekitio::Models::Transformation::flip + + attr_reader focus: String? + + def focus=: (String) -> String + + attr_reader format_: Imagekitio::Models::Transformation::format_? + + def format_=: ( + Imagekitio::Models::Transformation::format_ + ) -> Imagekitio::Models::Transformation::format_ + + attr_reader gradient: Imagekitio::Models::Transformation::gradient? + + def gradient=: ( + Imagekitio::Models::Transformation::gradient + ) -> Imagekitio::Models::Transformation::gradient + + attr_reader grayscale: Imagekitio::Models::Transformation::grayscale? + + def grayscale=: ( + Imagekitio::Models::Transformation::grayscale + ) -> Imagekitio::Models::Transformation::grayscale + + attr_reader height: Imagekitio::Models::Transformation::height? + + def height=: ( + Imagekitio::Models::Transformation::height + ) -> Imagekitio::Models::Transformation::height + + attr_reader lossless: bool? + + def lossless=: (bool) -> bool + + attr_reader metadata: bool? + + def metadata=: (bool) -> bool + + attr_reader named: String? + + def named=: (String) -> String + + attr_reader opacity: Float? + + def opacity=: (Float) -> Float + + attr_reader original: bool? + + def original=: (bool) -> bool + + attr_reader overlay: Imagekitio::Models::overlay? + + def overlay=: (Imagekitio::Models::overlay) -> Imagekitio::Models::overlay + + attr_reader page: Imagekitio::Models::Transformation::page? + + def page=: ( + Imagekitio::Models::Transformation::page + ) -> Imagekitio::Models::Transformation::page + + attr_reader progressive: bool? + + def progressive=: (bool) -> bool + + attr_reader quality: Float? + + def quality=: (Float) -> Float + + attr_reader radius: Imagekitio::Models::Transformation::radius? + + def radius=: ( + Imagekitio::Models::Transformation::radius + ) -> Imagekitio::Models::Transformation::radius + + attr_reader raw: String? + + def raw=: (String) -> String + + attr_reader rotation: Imagekitio::Models::Transformation::rotation? + + def rotation=: ( + Imagekitio::Models::Transformation::rotation + ) -> Imagekitio::Models::Transformation::rotation + + attr_reader shadow: Imagekitio::Models::Transformation::shadow? + + def shadow=: ( + Imagekitio::Models::Transformation::shadow + ) -> Imagekitio::Models::Transformation::shadow + + attr_reader sharpen: Imagekitio::Models::Transformation::sharpen? + + def sharpen=: ( + Imagekitio::Models::Transformation::sharpen + ) -> Imagekitio::Models::Transformation::sharpen + + attr_reader start_offset: Imagekitio::Models::Transformation::start_offset? + + def start_offset=: ( + Imagekitio::Models::Transformation::start_offset + ) -> Imagekitio::Models::Transformation::start_offset + + attr_reader streaming_resolutions: ::Array[Imagekitio::Models::streaming_resolution]? + + def streaming_resolutions=: ( + ::Array[Imagekitio::Models::streaming_resolution] + ) -> ::Array[Imagekitio::Models::streaming_resolution] + + attr_reader trim: Imagekitio::Models::Transformation::trim? + + def trim=: ( + Imagekitio::Models::Transformation::trim + ) -> Imagekitio::Models::Transformation::trim + + attr_reader unsharp_mask: Imagekitio::Models::Transformation::unsharp_mask? + + def unsharp_mask=: ( + Imagekitio::Models::Transformation::unsharp_mask + ) -> Imagekitio::Models::Transformation::unsharp_mask + + attr_reader video_codec: Imagekitio::Models::Transformation::video_codec? + + def video_codec=: ( + Imagekitio::Models::Transformation::video_codec + ) -> Imagekitio::Models::Transformation::video_codec + + attr_reader width: Imagekitio::Models::Transformation::width? + + def width=: ( + Imagekitio::Models::Transformation::width + ) -> Imagekitio::Models::Transformation::width + + attr_reader x: Imagekitio::Models::Transformation::x? + + def x=: ( + Imagekitio::Models::Transformation::x + ) -> Imagekitio::Models::Transformation::x + + attr_reader x_center: Imagekitio::Models::Transformation::x_center? + + def x_center=: ( + Imagekitio::Models::Transformation::x_center + ) -> Imagekitio::Models::Transformation::x_center + + attr_reader y_: Imagekitio::Models::Transformation::y_? + + def y_=: ( + Imagekitio::Models::Transformation::y_ + ) -> Imagekitio::Models::Transformation::y_ + + attr_reader y_center: Imagekitio::Models::Transformation::y_center? + + def y_center=: ( + Imagekitio::Models::Transformation::y_center + ) -> Imagekitio::Models::Transformation::y_center + + attr_reader zoom: Float? + + def zoom=: (Float) -> Float + + def initialize: ( + ?ai_change_background: String, + ?ai_drop_shadow: Imagekitio::Models::Transformation::ai_drop_shadow, + ?ai_edit: String, + ?ai_remove_background: Imagekitio::Models::Transformation::ai_remove_background, + ?ai_remove_background_external: Imagekitio::Models::Transformation::ai_remove_background_external, + ?ai_retouch: Imagekitio::Models::Transformation::ai_retouch, + ?ai_upscale: Imagekitio::Models::Transformation::ai_upscale, + ?ai_variation: Imagekitio::Models::Transformation::ai_variation, + ?aspect_ratio: Imagekitio::Models::Transformation::aspect_ratio, + ?audio_codec: Imagekitio::Models::Transformation::audio_codec, + ?background: String, + ?blur: Float, + ?border: String, + ?color_profile: bool, + ?contrast_stretch: Imagekitio::Models::Transformation::contrast_stretch, + ?crop: Imagekitio::Models::Transformation::crop, + ?crop_mode: Imagekitio::Models::Transformation::crop_mode, + ?default_image: String, + ?dpr: Float, + ?duration: Imagekitio::Models::Transformation::duration, + ?end_offset: Imagekitio::Models::Transformation::end_offset, + ?flip: Imagekitio::Models::Transformation::flip, + ?focus: String, + ?format_: Imagekitio::Models::Transformation::format_, + ?gradient: Imagekitio::Models::Transformation::gradient, + ?grayscale: Imagekitio::Models::Transformation::grayscale, + ?height: Imagekitio::Models::Transformation::height, + ?lossless: bool, + ?metadata: bool, + ?named: String, + ?opacity: Float, + ?original: bool, + ?overlay: Imagekitio::Models::overlay, + ?page: Imagekitio::Models::Transformation::page, + ?progressive: bool, + ?quality: Float, + ?radius: Imagekitio::Models::Transformation::radius, + ?raw: String, + ?rotation: Imagekitio::Models::Transformation::rotation, + ?shadow: Imagekitio::Models::Transformation::shadow, + ?sharpen: Imagekitio::Models::Transformation::sharpen, + ?start_offset: Imagekitio::Models::Transformation::start_offset, + ?streaming_resolutions: ::Array[Imagekitio::Models::streaming_resolution], + ?trim: Imagekitio::Models::Transformation::trim, + ?unsharp_mask: Imagekitio::Models::Transformation::unsharp_mask, + ?video_codec: Imagekitio::Models::Transformation::video_codec, + ?width: Imagekitio::Models::Transformation::width, + ?x: Imagekitio::Models::Transformation::x, + ?x_center: Imagekitio::Models::Transformation::x_center, + ?y_: Imagekitio::Models::Transformation::y_, + ?y_center: Imagekitio::Models::Transformation::y_center, + ?zoom: Float + ) -> void + + def to_hash: -> { + ai_change_background: String, + ai_drop_shadow: Imagekitio::Models::Transformation::ai_drop_shadow, + ai_edit: String, + ai_remove_background: Imagekitio::Models::Transformation::ai_remove_background, + ai_remove_background_external: Imagekitio::Models::Transformation::ai_remove_background_external, + ai_retouch: Imagekitio::Models::Transformation::ai_retouch, + ai_upscale: Imagekitio::Models::Transformation::ai_upscale, + ai_variation: Imagekitio::Models::Transformation::ai_variation, + aspect_ratio: Imagekitio::Models::Transformation::aspect_ratio, + audio_codec: Imagekitio::Models::Transformation::audio_codec, + background: String, + blur: Float, + border: String, + color_profile: bool, + contrast_stretch: Imagekitio::Models::Transformation::contrast_stretch, + crop: Imagekitio::Models::Transformation::crop, + crop_mode: Imagekitio::Models::Transformation::crop_mode, + default_image: String, + dpr: Float, + duration: Imagekitio::Models::Transformation::duration, + end_offset: Imagekitio::Models::Transformation::end_offset, + flip: Imagekitio::Models::Transformation::flip, + focus: String, + format_: Imagekitio::Models::Transformation::format_, + gradient: Imagekitio::Models::Transformation::gradient, + grayscale: Imagekitio::Models::Transformation::grayscale, + height: Imagekitio::Models::Transformation::height, + lossless: bool, + metadata: bool, + named: String, + opacity: Float, + original: bool, + overlay: Imagekitio::Models::overlay, + page: Imagekitio::Models::Transformation::page, + progressive: bool, + quality: Float, + radius: Imagekitio::Models::Transformation::radius, + raw: String, + rotation: Imagekitio::Models::Transformation::rotation, + shadow: Imagekitio::Models::Transformation::shadow, + sharpen: Imagekitio::Models::Transformation::sharpen, + start_offset: Imagekitio::Models::Transformation::start_offset, + streaming_resolutions: ::Array[Imagekitio::Models::streaming_resolution], + trim: Imagekitio::Models::Transformation::trim, + unsharp_mask: Imagekitio::Models::Transformation::unsharp_mask, + video_codec: Imagekitio::Models::Transformation::video_codec, + width: Imagekitio::Models::Transformation::width, + x: Imagekitio::Models::Transformation::x, + x_center: Imagekitio::Models::Transformation::x_center, + y_: Imagekitio::Models::Transformation::y_, + y_center: Imagekitio::Models::Transformation::y_center, + zoom: Float + } + + type ai_drop_shadow = true | String + + module AIDropShadow + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::ai_drop_shadow] + end + + type ai_remove_background = true + + module AIRemoveBackground + extend Imagekitio::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::ai_remove_background] + end + + type ai_remove_background_external = true + + module AIRemoveBackgroundExternal + extend Imagekitio::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::ai_remove_background_external] + end + + type ai_retouch = true + + module AIRetouch + extend Imagekitio::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::ai_retouch] + end + + type ai_upscale = true + + module AIUpscale + extend Imagekitio::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::ai_upscale] + end + + type ai_variation = true + + module AIVariation + extend Imagekitio::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::ai_variation] + end + + type aspect_ratio = Float | String + + module AspectRatio + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::aspect_ratio] + end + + type audio_codec = :aac | :opus | :none + + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + AAC: :aac + OPUS: :opus + NONE: :none + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::audio_codec] + end + + type contrast_stretch = true + + module ContrastStretch + extend Imagekitio::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::contrast_stretch] + end + + type crop = + :force | :at_max | :at_max_enlarge | :at_least | :maintain_ratio + + module Crop + extend Imagekitio::Internal::Type::Enum + + FORCE: :force + AT_MAX: :at_max + AT_MAX_ENLARGE: :at_max_enlarge + AT_LEAST: :at_least + MAINTAIN_RATIO: :maintain_ratio + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::crop] + end + + type crop_mode = :pad_resize | :extract | :pad_extract + + module CropMode + extend Imagekitio::Internal::Type::Enum + + PAD_RESIZE: :pad_resize + EXTRACT: :extract + PAD_EXTRACT: :pad_extract + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::crop_mode] + end + + type duration = Float | String + + module Duration + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::duration] + end + + type end_offset = Float | String + + module EndOffset + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::end_offset] + end + + type flip = :h | :v | :h_v | :v_h + + module Flip + extend Imagekitio::Internal::Type::Enum + + H: :h + V: :v + H_V: :h_v + V_H: :v_h + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::flip] + end + + type format_ = + :auto + | :webp + | :jpg + | :jpeg + | :png + | :gif + | :svg + | :mp4 + | :webm + | :avif + | :orig + + module Format + extend Imagekitio::Internal::Type::Enum + + AUTO: :auto + WEBP: :webp + JPG: :jpg + JPEG: :jpeg + PNG: :png + GIF: :gif + SVG: :svg + MP4: :mp4 + WEBM: :webm + AVIF: :avif + ORIG: :orig + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::format_] + end + + type gradient = true | String + + module Gradient + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::gradient] + end + + type grayscale = true + + module Grayscale + extend Imagekitio::Internal::Type::Enum + + TRUE: true + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::grayscale] + end + + type height = Float | String + + module Height + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::height] + end + + type page = Float | String + + module Page + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::page] + end + + type radius = Float | :max + + module Radius + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::radius] + end + + type rotation = Float | String + + module Rotation + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::rotation] + end + + type shadow = true | String + + module Shadow + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::shadow] + end + + type sharpen = true | Float + + module Sharpen + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::sharpen] + end + + type start_offset = Float | String + + module StartOffset + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::start_offset] + end + + type trim = true | Float + + module Trim + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::trim] + end + + type unsharp_mask = true | String + + module UnsharpMask + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::unsharp_mask] + end + + type video_codec = :h264 | :vp9 | :av1 | :none + + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + H264: :h264 + VP9: :vp9 + AV1: :av1 + NONE: :none + + def self?.values: -> ::Array[Imagekitio::Models::Transformation::video_codec] + end + + type width = Float | String + + module Width + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::width] + end + + type x = Float | String + + module X + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::x] + end + + type x_center = Float | String + + module XCenter + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::x_center] + end + + type y_ = Float | String + + module Y + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::y_] + end + + type y_center = Float | String + + module YCenter + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::Transformation::y_center] + end + end + end +end diff --git a/sig/imagekitio/models/transformation_position.rbs b/sig/imagekitio/models/transformation_position.rbs new file mode 100644 index 00000000..9ba3ff1b --- /dev/null +++ b/sig/imagekitio/models/transformation_position.rbs @@ -0,0 +1,14 @@ +module Imagekitio + module Models + type transformation_position = :path | :query + + module TransformationPosition + extend Imagekitio::Internal::Type::Enum + + PATH: :path + QUERY: :query + + def self?.values: -> ::Array[Imagekitio::Models::transformation_position] + end + end +end diff --git a/sig/imagekitio/models/unsafe_unwrap_webhook_event.rbs b/sig/imagekitio/models/unsafe_unwrap_webhook_event.rbs new file mode 100644 index 00000000..12322bc6 --- /dev/null +++ b/sig/imagekitio/models/unsafe_unwrap_webhook_event.rbs @@ -0,0 +1,18 @@ +module Imagekitio + module Models + type unsafe_unwrap_webhook_event = + Imagekitio::VideoTransformationAcceptedEvent + | Imagekitio::VideoTransformationReadyEvent + | Imagekitio::VideoTransformationErrorEvent + | Imagekitio::UploadPreTransformSuccessEvent + | Imagekitio::UploadPreTransformErrorEvent + | Imagekitio::UploadPostTransformSuccessEvent + | Imagekitio::UploadPostTransformErrorEvent + + module UnsafeUnwrapWebhookEvent + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::unsafe_unwrap_webhook_event] + end + end +end diff --git a/sig/imagekitio/models/unwrap_webhook_event.rbs b/sig/imagekitio/models/unwrap_webhook_event.rbs new file mode 100644 index 00000000..f6d1bbc3 --- /dev/null +++ b/sig/imagekitio/models/unwrap_webhook_event.rbs @@ -0,0 +1,18 @@ +module Imagekitio + module Models + type unwrap_webhook_event = + Imagekitio::VideoTransformationAcceptedEvent + | Imagekitio::VideoTransformationReadyEvent + | Imagekitio::VideoTransformationErrorEvent + | Imagekitio::UploadPreTransformSuccessEvent + | Imagekitio::UploadPreTransformErrorEvent + | Imagekitio::UploadPostTransformSuccessEvent + | Imagekitio::UploadPostTransformErrorEvent + + module UnwrapWebhookEvent + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::unwrap_webhook_event] + end + end +end diff --git a/sig/imagekitio/models/update_file_request.rbs b/sig/imagekitio/models/update_file_request.rbs new file mode 100644 index 00000000..59d6a827 --- /dev/null +++ b/sig/imagekitio/models/update_file_request.rbs @@ -0,0 +1,122 @@ +module Imagekitio + module Models + type update_file_request = + Imagekitio::UpdateFileRequest::UpdateFileDetails + | Imagekitio::UpdateFileRequest::ChangePublicationStatus + + module UpdateFileRequest + extend Imagekitio::Internal::Type::Union + + type update_file_details = + { + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + extensions: Imagekitio::Models::extensions, + remove_ai_tags: Imagekitio::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags, + tags: ::Array[String]?, + webhook_url: String + } + + class UpdateFileDetails < Imagekitio::Internal::Type::BaseModel + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader extensions: Imagekitio::Models::extensions? + + def extensions=: ( + Imagekitio::Models::extensions + ) -> Imagekitio::Models::extensions + + attr_reader remove_ai_tags: Imagekitio::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags? + + def remove_ai_tags=: ( + Imagekitio::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags + ) -> Imagekitio::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags + + attr_accessor tags: ::Array[String]? + + attr_reader webhook_url: String? + + def webhook_url=: (String) -> String + + def initialize: ( + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?extensions: Imagekitio::Models::extensions, + ?remove_ai_tags: Imagekitio::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags, + ?tags: ::Array[String]?, + ?webhook_url: String + ) -> void + + def to_hash: -> { + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + extensions: Imagekitio::Models::extensions, + remove_ai_tags: Imagekitio::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags, + tags: ::Array[String]?, + webhook_url: String + } + + type remove_ai_tags = ::Array[String] | :all + + module RemoveAITags + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::UpdateFileRequest::UpdateFileDetails::remove_ai_tags] + + StringArray: Imagekitio::Internal::Type::Converter + end + end + + type change_publication_status = + { + publish: Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish + } + + class ChangePublicationStatus < Imagekitio::Internal::Type::BaseModel + attr_reader publish: Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish? + + def publish=: ( + Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish + ) -> Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish + + def initialize: ( + ?publish: Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish + ) -> void + + def to_hash: -> { + publish: Imagekitio::UpdateFileRequest::ChangePublicationStatus::Publish + } + + type publish = { is_published: bool, include_file_versions: bool } + + class Publish < Imagekitio::Internal::Type::BaseModel + attr_accessor is_published: bool + + attr_reader include_file_versions: bool? + + def include_file_versions=: (bool) -> bool + + def initialize: ( + is_published: bool, + ?include_file_versions: bool + ) -> void + + def to_hash: -> { is_published: bool, include_file_versions: bool } + end + end + + def self?.variants: -> ::Array[Imagekitio::Models::update_file_request] + end + end +end diff --git a/sig/imagekitio/models/upload_post_transform_error_event.rbs b/sig/imagekitio/models/upload_post_transform_error_event.rbs new file mode 100644 index 00000000..f22bc0a2 --- /dev/null +++ b/sig/imagekitio/models/upload_post_transform_error_event.rbs @@ -0,0 +1,192 @@ +module Imagekitio + module Models + type upload_post_transform_error_event = + { + created_at: Time, + data: Imagekitio::UploadPostTransformErrorEvent::Data, + request: Imagekitio::UploadPostTransformErrorEvent::Request, + type: :"upload.post-transform.error" + } + + class UploadPostTransformErrorEvent < Imagekitio::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekitio::UploadPostTransformErrorEvent::Data + + def data=: ( + Imagekitio::UploadPostTransformErrorEvent::Data _ + ) -> Imagekitio::UploadPostTransformErrorEvent::Data + + def request: -> Imagekitio::UploadPostTransformErrorEvent::Request + + def request=: ( + Imagekitio::UploadPostTransformErrorEvent::Request _ + ) -> Imagekitio::UploadPostTransformErrorEvent::Request + + def `type`: -> :"upload.post-transform.error" + + def type=: ( + :"upload.post-transform.error" _ + ) -> :"upload.post-transform.error" + + def initialize: ( + created_at: Time, + data: Imagekitio::UploadPostTransformErrorEvent::Data, + request: Imagekitio::UploadPostTransformErrorEvent::Request, + ?type: :"upload.post-transform.error" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekitio::UploadPostTransformErrorEvent::Data, + request: Imagekitio::UploadPostTransformErrorEvent::Request, + type: :"upload.post-transform.error" + } + + type data = + { + file_id: String, + name: String, + path: String, + transformation: Imagekitio::UploadPostTransformErrorEvent::Data::Transformation, + url: String + } + + class Data < Imagekitio::Internal::Type::BaseModel + attr_accessor file_id: String + + attr_accessor name: String + + attr_accessor path: String + + attr_accessor transformation: Imagekitio::UploadPostTransformErrorEvent::Data::Transformation + + attr_accessor url: String + + def initialize: ( + file_id: String, + name: String, + path: String, + transformation: Imagekitio::UploadPostTransformErrorEvent::Data::Transformation, + url: String + ) -> void + + def to_hash: -> { + file_id: String, + name: String, + path: String, + transformation: Imagekitio::UploadPostTransformErrorEvent::Data::Transformation, + url: String + } + + type transformation = + { + error: Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_accessor error: Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error + + def initialize: ( + error: Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error + ) -> void + + def to_hash: -> { + error: Imagekitio::UploadPostTransformErrorEvent::Data::Transformation::Error + } + + type error = { reason: String } + + class Error < Imagekitio::Internal::Type::BaseModel + attr_accessor reason: String + + def initialize: (reason: String) -> void + + def to_hash: -> { reason: String } + end + end + end + + type request = + { + transformation: Imagekitio::UploadPostTransformErrorEvent::Request::Transformation, + x_request_id: String + } + + class Request < Imagekitio::Internal::Type::BaseModel + attr_accessor transformation: Imagekitio::UploadPostTransformErrorEvent::Request::Transformation + + attr_accessor x_request_id: String + + def initialize: ( + transformation: Imagekitio::UploadPostTransformErrorEvent::Request::Transformation, + x_request_id: String + ) -> void + + def to_hash: -> { + transformation: Imagekitio::UploadPostTransformErrorEvent::Request::Transformation, + x_request_id: String + } + + type transformation = + { + type: Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::type_, + protocol: Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol, + value: String + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::type_ + + attr_reader protocol: Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol? + + def protocol=: ( + Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol + ) -> Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: ( + type: Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::type_, + ?protocol: Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol, + ?value: String + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::type_, + protocol: Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol, + value: String + } + + type type_ = :transformation | :abs | :"gif-to-video" | :thumbnail + + module Type + extend Imagekitio::Internal::Type::Enum + + TRANSFORMATION: :transformation + ABS: :abs + GIF_TO_VIDEO: :"gif-to-video" + THUMBNAIL: :thumbnail + + def self?.values: -> ::Array[Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::type_] + end + + type protocol = :hls | :dash + + module Protocol + extend Imagekitio::Internal::Type::Enum + + HLS: :hls + DASH: :dash + + def self?.values: -> ::Array[Imagekitio::Models::UploadPostTransformErrorEvent::Request::Transformation::protocol] + end + end + end + end + end +end diff --git a/sig/imagekitio/models/upload_post_transform_success_event.rbs b/sig/imagekitio/models/upload_post_transform_success_event.rbs new file mode 100644 index 00000000..5eb891f8 --- /dev/null +++ b/sig/imagekitio/models/upload_post_transform_success_event.rbs @@ -0,0 +1,142 @@ +module Imagekitio + module Models + type upload_post_transform_success_event = + { + created_at: Time, + data: Imagekitio::UploadPostTransformSuccessEvent::Data, + request: Imagekitio::UploadPostTransformSuccessEvent::Request, + type: :"upload.post-transform.success" + } + + class UploadPostTransformSuccessEvent < Imagekitio::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekitio::UploadPostTransformSuccessEvent::Data + + def data=: ( + Imagekitio::UploadPostTransformSuccessEvent::Data _ + ) -> Imagekitio::UploadPostTransformSuccessEvent::Data + + def request: -> Imagekitio::UploadPostTransformSuccessEvent::Request + + def request=: ( + Imagekitio::UploadPostTransformSuccessEvent::Request _ + ) -> Imagekitio::UploadPostTransformSuccessEvent::Request + + def `type`: -> :"upload.post-transform.success" + + def type=: ( + :"upload.post-transform.success" _ + ) -> :"upload.post-transform.success" + + def initialize: ( + created_at: Time, + data: Imagekitio::UploadPostTransformSuccessEvent::Data, + request: Imagekitio::UploadPostTransformSuccessEvent::Request, + ?type: :"upload.post-transform.success" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekitio::UploadPostTransformSuccessEvent::Data, + request: Imagekitio::UploadPostTransformSuccessEvent::Request, + type: :"upload.post-transform.success" + } + + type data = { file_id: String, name: String, url: String } + + class Data < Imagekitio::Internal::Type::BaseModel + attr_accessor file_id: String + + attr_accessor name: String + + attr_accessor url: String + + def initialize: (file_id: String, name: String, url: String) -> void + + def to_hash: -> { file_id: String, name: String, url: String } + end + + type request = + { + transformation: Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation, + x_request_id: String + } + + class Request < Imagekitio::Internal::Type::BaseModel + attr_accessor transformation: Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation + + attr_accessor x_request_id: String + + def initialize: ( + transformation: Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation, + x_request_id: String + ) -> void + + def to_hash: -> { + transformation: Imagekitio::UploadPostTransformSuccessEvent::Request::Transformation, + x_request_id: String + } + + type transformation = + { + type: Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_, + protocol: Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol, + value: String + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_ + + attr_reader protocol: Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol? + + def protocol=: ( + Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol + ) -> Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol + + attr_reader value: String? + + def value=: (String) -> String + + def initialize: ( + type: Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_, + ?protocol: Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol, + ?value: String + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_, + protocol: Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol, + value: String + } + + type type_ = :transformation | :abs | :"gif-to-video" | :thumbnail + + module Type + extend Imagekitio::Internal::Type::Enum + + TRANSFORMATION: :transformation + ABS: :abs + GIF_TO_VIDEO: :"gif-to-video" + THUMBNAIL: :thumbnail + + def self?.values: -> ::Array[Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::type_] + end + + type protocol = :hls | :dash + + module Protocol + extend Imagekitio::Internal::Type::Enum + + HLS: :hls + DASH: :dash + + def self?.values: -> ::Array[Imagekitio::Models::UploadPostTransformSuccessEvent::Request::Transformation::protocol] + end + end + end + end + end +end diff --git a/sig/imagekitio/models/upload_pre_transform_error_event.rbs b/sig/imagekitio/models/upload_pre_transform_error_event.rbs new file mode 100644 index 00000000..189e999e --- /dev/null +++ b/sig/imagekitio/models/upload_pre_transform_error_event.rbs @@ -0,0 +1,115 @@ +module Imagekitio + module Models + type upload_pre_transform_error_event = + { + created_at: Time, + data: Imagekitio::UploadPreTransformErrorEvent::Data, + request: Imagekitio::UploadPreTransformErrorEvent::Request, + type: :"upload.pre-transform.error" + } + + class UploadPreTransformErrorEvent < Imagekitio::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekitio::UploadPreTransformErrorEvent::Data + + def data=: ( + Imagekitio::UploadPreTransformErrorEvent::Data _ + ) -> Imagekitio::UploadPreTransformErrorEvent::Data + + def request: -> Imagekitio::UploadPreTransformErrorEvent::Request + + def request=: ( + Imagekitio::UploadPreTransformErrorEvent::Request _ + ) -> Imagekitio::UploadPreTransformErrorEvent::Request + + def `type`: -> :"upload.pre-transform.error" + + def type=: ( + :"upload.pre-transform.error" _ + ) -> :"upload.pre-transform.error" + + def initialize: ( + created_at: Time, + data: Imagekitio::UploadPreTransformErrorEvent::Data, + request: Imagekitio::UploadPreTransformErrorEvent::Request, + ?type: :"upload.pre-transform.error" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekitio::UploadPreTransformErrorEvent::Data, + request: Imagekitio::UploadPreTransformErrorEvent::Request, + type: :"upload.pre-transform.error" + } + + type data = + { + name: String, + path: String, + transformation: Imagekitio::UploadPreTransformErrorEvent::Data::Transformation + } + + class Data < Imagekitio::Internal::Type::BaseModel + attr_accessor name: String + + attr_accessor path: String + + attr_accessor transformation: Imagekitio::UploadPreTransformErrorEvent::Data::Transformation + + def initialize: ( + name: String, + path: String, + transformation: Imagekitio::UploadPreTransformErrorEvent::Data::Transformation + ) -> void + + def to_hash: -> { + name: String, + path: String, + transformation: Imagekitio::UploadPreTransformErrorEvent::Data::Transformation + } + + type transformation = + { + error: Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_accessor error: Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error + + def initialize: ( + error: Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error + ) -> void + + def to_hash: -> { + error: Imagekitio::UploadPreTransformErrorEvent::Data::Transformation::Error + } + + type error = { reason: String } + + class Error < Imagekitio::Internal::Type::BaseModel + attr_accessor reason: String + + def initialize: (reason: String) -> void + + def to_hash: -> { reason: String } + end + end + end + + type request = { transformation: String, x_request_id: String } + + class Request < Imagekitio::Internal::Type::BaseModel + attr_accessor transformation: String + + attr_accessor x_request_id: String + + def initialize: (transformation: String, x_request_id: String) -> void + + def to_hash: -> { transformation: String, x_request_id: String } + end + end + end +end diff --git a/sig/imagekitio/models/upload_pre_transform_success_event.rbs b/sig/imagekitio/models/upload_pre_transform_success_event.rbs new file mode 100644 index 00000000..90bf4311 --- /dev/null +++ b/sig/imagekitio/models/upload_pre_transform_success_event.rbs @@ -0,0 +1,541 @@ +module Imagekitio + module Models + type upload_pre_transform_success_event = + { + created_at: Time, + data: Imagekitio::UploadPreTransformSuccessEvent::Data, + request: Imagekitio::UploadPreTransformSuccessEvent::Request, + type: :"upload.pre-transform.success" + } + + class UploadPreTransformSuccessEvent < Imagekitio::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekitio::UploadPreTransformSuccessEvent::Data + + def data=: ( + Imagekitio::UploadPreTransformSuccessEvent::Data _ + ) -> Imagekitio::UploadPreTransformSuccessEvent::Data + + def request: -> Imagekitio::UploadPreTransformSuccessEvent::Request + + def request=: ( + Imagekitio::UploadPreTransformSuccessEvent::Request _ + ) -> Imagekitio::UploadPreTransformSuccessEvent::Request + + def `type`: -> :"upload.pre-transform.success" + + def type=: ( + :"upload.pre-transform.success" _ + ) -> :"upload.pre-transform.success" + + def initialize: ( + created_at: Time, + data: Imagekitio::UploadPreTransformSuccessEvent::Data, + request: Imagekitio::UploadPreTransformSuccessEvent::Request, + ?type: :"upload.pre-transform.success" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekitio::UploadPreTransformSuccessEvent::Data, + request: Imagekitio::UploadPreTransformSuccessEvent::Request, + type: :"upload.pre-transform.success" + } + + type data = + { + ai_tags: ::Array[Imagekitio::UploadPreTransformSuccessEvent::Data::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekitio::Metadata, + name: String, + selected_fields_schema: ::Hash[Symbol, Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema], + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo, + video_codec: String, + width: Float + } + + class Data < Imagekitio::Internal::Type::BaseModel + attr_accessor ai_tags: ::Array[Imagekitio::UploadPreTransformSuccessEvent::Data::AITag]? + + attr_reader audio_codec: String? + + def audio_codec=: (String) -> String + + attr_reader bit_rate: Integer? + + def bit_rate=: (Integer) -> Integer + + attr_accessor custom_coordinates: String? + + attr_reader custom_metadata: ::Hash[Symbol, top]? + + def custom_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader description: String? + + def description=: (String) -> String + + attr_reader duration: Integer? + + def duration=: (Integer) -> Integer + + attr_reader embedded_metadata: ::Hash[Symbol, top]? + + def embedded_metadata=: (::Hash[Symbol, top]) -> ::Hash[Symbol, top] + + attr_reader extension_status: Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus? + + def extension_status=: ( + Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus + ) -> Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus + + attr_reader file_id: String? + + def file_id=: (String) -> String + + attr_reader file_path: String? + + def file_path=: (String) -> String + + attr_reader file_type: String? + + def file_type=: (String) -> String + + attr_reader height: Float? + + def height=: (Float) -> Float + + attr_reader is_private_file: bool? + + def is_private_file=: (bool) -> bool + + attr_reader is_published: bool? + + def is_published=: (bool) -> bool + + attr_reader metadata: Imagekitio::Metadata? + + def metadata=: (Imagekitio::Metadata) -> Imagekitio::Metadata + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader selected_fields_schema: ::Hash[Symbol, Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema]? + + def selected_fields_schema=: ( + ::Hash[Symbol, Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema] + ) -> ::Hash[Symbol, Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema] + + attr_reader size: Float? + + def size=: (Float) -> Float + + attr_accessor tags: ::Array[String]? + + attr_reader thumbnail_url: String? + + def thumbnail_url=: (String) -> String + + attr_reader url: String? + + def url=: (String) -> String + + attr_reader version_info: Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo? + + def version_info=: ( + Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo + ) -> Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo + + attr_reader video_codec: String? + + def video_codec=: (String) -> String + + attr_reader width: Float? + + def width=: (Float) -> Float + + def initialize: ( + ?ai_tags: ::Array[Imagekitio::UploadPreTransformSuccessEvent::Data::AITag]?, + ?audio_codec: String, + ?bit_rate: Integer, + ?custom_coordinates: String?, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?duration: Integer, + ?embedded_metadata: ::Hash[Symbol, top], + ?extension_status: Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + ?file_id: String, + ?file_path: String, + ?file_type: String, + ?height: Float, + ?is_private_file: bool, + ?is_published: bool, + ?metadata: Imagekitio::Metadata, + ?name: String, + ?selected_fields_schema: ::Hash[Symbol, Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema], + ?size: Float, + ?tags: ::Array[String]?, + ?thumbnail_url: String, + ?url: String, + ?version_info: Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo, + ?video_codec: String, + ?width: Float + ) -> void + + def to_hash: -> { + ai_tags: ::Array[Imagekitio::UploadPreTransformSuccessEvent::Data::AITag]?, + audio_codec: String, + bit_rate: Integer, + custom_coordinates: String?, + custom_metadata: ::Hash[Symbol, top], + description: String, + duration: Integer, + embedded_metadata: ::Hash[Symbol, top], + extension_status: Imagekitio::UploadPreTransformSuccessEvent::Data::ExtensionStatus, + file_id: String, + file_path: String, + file_type: String, + height: Float, + is_private_file: bool, + is_published: bool, + metadata: Imagekitio::Metadata, + name: String, + selected_fields_schema: ::Hash[Symbol, Imagekitio::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema], + size: Float, + tags: ::Array[String]?, + thumbnail_url: String, + url: String, + version_info: Imagekitio::UploadPreTransformSuccessEvent::Data::VersionInfo, + video_codec: String, + width: Float + } + + type ai_tag = { confidence: Float, name: String, source: String } + + class AITag < Imagekitio::Internal::Type::BaseModel + attr_reader confidence: Float? + + def confidence=: (Float) -> Float + + attr_reader name: String? + + def name=: (String) -> String + + attr_reader source: String? + + def source=: (String) -> String + + def initialize: ( + ?confidence: Float, + ?name: String, + ?source: String + ) -> void + + def to_hash: -> { confidence: Float, name: String, source: String } + end + + type extension_status = + { + ai_auto_description: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + } + + class ExtensionStatus < Imagekitio::Internal::Type::BaseModel + attr_reader ai_auto_description: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description? + + def ai_auto_description=: ( + Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description + ) -> Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description + + attr_reader aws_auto_tagging: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging? + + def aws_auto_tagging=: ( + Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging + ) -> Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging + + attr_reader google_auto_tagging: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging? + + def google_auto_tagging=: ( + Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging + ) -> Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging + + attr_reader remove_bg: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg? + + def remove_bg=: ( + Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + ) -> Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + + def initialize: ( + ?ai_auto_description: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description, + ?aws_auto_tagging: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging, + ?google_auto_tagging: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging, + ?remove_bg: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + ) -> void + + def to_hash: -> { + ai_auto_description: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description, + aws_auto_tagging: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging, + google_auto_tagging: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging, + remove_bg: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg + } + + type ai_auto_description = :success | :pending | :failed + + module AIAutoDescription + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::ai_auto_description] + end + + type aws_auto_tagging = :success | :pending | :failed + + module AwsAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::aws_auto_tagging] + end + + type google_auto_tagging = :success | :pending | :failed + + module GoogleAutoTagging + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::google_auto_tagging] + end + + type remove_bg = :success | :pending | :failed + + module RemoveBg + extend Imagekitio::Internal::Type::Enum + + SUCCESS: :success + PENDING: :pending + FAILED: :failed + + def self?.values: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::ExtensionStatus::remove_bg] + end + end + + type selected_fields_schema = + { + type: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::type_, + default_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::max_value, + min_length: Float, + min_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::min_value, + read_only: bool, + select_options: ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::select_option], + select_options_truncated: bool + } + + class SelectedFieldsSchema < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::type_ + + attr_reader default_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::default_value? + + def default_value=: ( + Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::default_value + ) -> Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::default_value + + attr_reader is_value_required: bool? + + def is_value_required=: (bool) -> bool + + attr_reader max_length: Float? + + def max_length=: (Float) -> Float + + attr_reader max_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::max_value? + + def max_value=: ( + Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::max_value + ) -> Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::max_value + + attr_reader min_length: Float? + + def min_length=: (Float) -> Float + + attr_reader min_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::min_value? + + def min_value=: ( + Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::min_value + ) -> Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::min_value + + attr_reader read_only: bool? + + def read_only=: (bool) -> bool + + attr_reader select_options: ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::select_option]? + + def select_options=: ( + ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::select_option] + ) -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::select_option] + + attr_reader select_options_truncated: bool? + + def select_options_truncated=: (bool) -> bool + + def initialize: ( + type: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::type_, + ?default_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::default_value, + ?is_value_required: bool, + ?max_length: Float, + ?max_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::max_value, + ?min_length: Float, + ?min_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::min_value, + ?read_only: bool, + ?select_options: ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::select_option], + ?select_options_truncated: bool + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::type_, + default_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::default_value, + is_value_required: bool, + max_length: Float, + max_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::max_value, + min_length: Float, + min_value: Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::min_value, + read_only: bool, + select_options: ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::select_option], + select_options_truncated: bool + } + + type type_ = + :Text + | :Textarea + | :Number + | :Date + | :Boolean + | :SingleSelect + | :MultiSelect + + module Type + extend Imagekitio::Internal::Type::Enum + + TEXT: :Text + TEXTAREA: :Textarea + NUMBER: :Number + DATE: :Date + BOOLEAN: :Boolean + SINGLE_SELECT: :SingleSelect + MULTI_SELECT: :MultiSelect + + def self?.values: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::type_] + end + + type default_value = + String + | Float + | bool + | ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::mixed] + + module DefaultValue + extend Imagekitio::Internal::Type::Union + + type mixed = String | Float | bool + + module Mixed + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::DefaultValue::mixed] + end + + def self?.variants: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::default_value] + + MixedArray: Imagekitio::Internal::Type::Converter + end + + type max_value = String | Float + + module MaxValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::max_value] + end + + type min_value = String | Float + + module MinValue + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::min_value] + end + + type select_option = String | Float | bool + + module SelectOption + extend Imagekitio::Internal::Type::Union + + def self?.variants: -> ::Array[Imagekitio::Models::UploadPreTransformSuccessEvent::Data::SelectedFieldsSchema::select_option] + end + end + + type version_info = { id: String, name: String } + + class VersionInfo < Imagekitio::Internal::Type::BaseModel + attr_reader id: String? + + def id=: (String) -> String + + attr_reader name: String? + + def name=: (String) -> String + + def initialize: (?id: String, ?name: String) -> void + + def to_hash: -> { id: String, name: String } + end + end + + type request = { transformation: String, x_request_id: String } + + class Request < Imagekitio::Internal::Type::BaseModel + attr_accessor transformation: String + + attr_accessor x_request_id: String + + def initialize: (transformation: String, x_request_id: String) -> void + + def to_hash: -> { transformation: String, x_request_id: String } + end + end + end +end diff --git a/sig/imagekitio/models/video_overlay.rbs b/sig/imagekitio/models/video_overlay.rbs new file mode 100644 index 00000000..86c3ed06 --- /dev/null +++ b/sig/imagekitio/models/video_overlay.rbs @@ -0,0 +1,59 @@ +module Imagekitio + module Models + type video_overlay = + { + input: String, + type: :video, + encoding: Imagekitio::Models::VideoOverlay::encoding, + transformation: ::Array[Imagekitio::Transformation] + } + + class VideoOverlay < Imagekitio::Models::BaseOverlay + def input: -> String + + def input=: (String _) -> String + + def `type`: -> :video + + def type=: (:video _) -> :video + + def encoding: -> Imagekitio::Models::VideoOverlay::encoding? + + def encoding=: ( + Imagekitio::Models::VideoOverlay::encoding _ + ) -> Imagekitio::Models::VideoOverlay::encoding + + def transformation: -> ::Array[Imagekitio::Transformation]? + + def transformation=: ( + ::Array[Imagekitio::Transformation] _ + ) -> ::Array[Imagekitio::Transformation] + + def initialize: ( + input: String, + ?encoding: Imagekitio::Models::VideoOverlay::encoding, + ?transformation: ::Array[Imagekitio::Transformation], + ?type: :video + ) -> void + + def to_hash: -> { + input: String, + type: :video, + encoding: Imagekitio::Models::VideoOverlay::encoding, + transformation: ::Array[Imagekitio::Transformation] + } + + type encoding = :auto | :plain | :base64 + + module Encoding + extend Imagekitio::Internal::Type::Enum + + AUTO: :auto + PLAIN: :plain + BASE64: :base64 + + def self?.values: -> ::Array[Imagekitio::Models::VideoOverlay::encoding] + end + end + end +end diff --git a/sig/imagekitio/models/video_transformation_accepted_event.rbs b/sig/imagekitio/models/video_transformation_accepted_event.rbs new file mode 100644 index 00000000..c2ac8626 --- /dev/null +++ b/sig/imagekitio/models/video_transformation_accepted_event.rbs @@ -0,0 +1,261 @@ +module Imagekitio + module Models + type video_transformation_accepted_event = + { + created_at: Time, + data: Imagekitio::VideoTransformationAcceptedEvent::Data, + request: Imagekitio::VideoTransformationAcceptedEvent::Request, + type: :"video.transformation.accepted" + } + + class VideoTransformationAcceptedEvent < Imagekitio::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekitio::VideoTransformationAcceptedEvent::Data + + def data=: ( + Imagekitio::VideoTransformationAcceptedEvent::Data _ + ) -> Imagekitio::VideoTransformationAcceptedEvent::Data + + def request: -> Imagekitio::VideoTransformationAcceptedEvent::Request + + def request=: ( + Imagekitio::VideoTransformationAcceptedEvent::Request _ + ) -> Imagekitio::VideoTransformationAcceptedEvent::Request + + def `type`: -> :"video.transformation.accepted" + + def type=: ( + :"video.transformation.accepted" _ + ) -> :"video.transformation.accepted" + + def initialize: ( + created_at: Time, + data: Imagekitio::VideoTransformationAcceptedEvent::Data, + request: Imagekitio::VideoTransformationAcceptedEvent::Request, + ?type: :"video.transformation.accepted" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekitio::VideoTransformationAcceptedEvent::Data, + request: Imagekitio::VideoTransformationAcceptedEvent::Request, + type: :"video.transformation.accepted" + } + + type data = + { + asset: Imagekitio::VideoTransformationAcceptedEvent::Data::Asset, + transformation: Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation + } + + class Data < Imagekitio::Internal::Type::BaseModel + attr_accessor asset: Imagekitio::VideoTransformationAcceptedEvent::Data::Asset + + attr_accessor transformation: Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation + + def initialize: ( + asset: Imagekitio::VideoTransformationAcceptedEvent::Data::Asset, + transformation: Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation + ) -> void + + def to_hash: -> { + asset: Imagekitio::VideoTransformationAcceptedEvent::Data::Asset, + transformation: Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation + } + + type asset = { url: String } + + class Asset < Imagekitio::Internal::Type::BaseModel + attr_accessor url: String + + def initialize: (url: String) -> void + + def to_hash: -> { url: String } + end + + type transformation = + { + type: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_, + options: Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_ + + attr_reader options: Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options? + + def options=: ( + Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options + ) -> Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options + + def initialize: ( + type: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_, + ?options: Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_, + options: Imagekitio::VideoTransformationAcceptedEvent::Data::Transformation::Options + } + + type type_ = + :"video-transformation" | :"gif-to-video" | :"video-thumbnail" + + module Type + extend Imagekitio::Internal::Type::Enum + + VIDEO_TRANSFORMATION: :"video-transformation" + GIF_TO_VIDEO: :"gif-to-video" + VIDEO_THUMBNAIL: :"video-thumbnail" + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::type_] + end + + type options = + { + audio_codec: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + } + + class Options < Imagekitio::Internal::Type::BaseModel + attr_reader audio_codec: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec? + + def audio_codec=: ( + Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec + ) -> Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec + + attr_reader auto_rotate: bool? + + def auto_rotate=: (bool) -> bool + + attr_reader format_: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_? + + def format_=: ( + Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_ + ) -> Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_ + + attr_reader quality: Integer? + + def quality=: (Integer) -> Integer + + attr_reader stream_protocol: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol? + + def stream_protocol=: ( + Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol + ) -> Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol + + attr_reader variants: ::Array[String]? + + def variants=: (::Array[String]) -> ::Array[String] + + attr_reader video_codec: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec? + + def video_codec=: ( + Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + ) -> Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + + def initialize: ( + ?audio_codec: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec, + ?auto_rotate: bool, + ?format_: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_, + ?quality: Integer, + ?stream_protocol: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol, + ?variants: ::Array[String], + ?video_codec: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + ) -> void + + def to_hash: -> { + audio_codec: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec + } + + type audio_codec = :aac | :opus + + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + AAC: :aac + OPUS: :opus + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::audio_codec] + end + + type format_ = :mp4 | :webm | :jpg | :png | :webp + + module Format + extend Imagekitio::Internal::Type::Enum + + MP4: :mp4 + WEBM: :webm + JPG: :jpg + PNG: :png + WEBP: :webp + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::format_] + end + + type stream_protocol = :HLS | :DASH + + module StreamProtocol + extend Imagekitio::Internal::Type::Enum + + HLS: :HLS + DASH: :DASH + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::stream_protocol] + end + + type video_codec = :h264 | :vp9 | :av1 + + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + H264: :h264 + VP9: :vp9 + AV1: :av1 + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationAcceptedEvent::Data::Transformation::Options::video_codec] + end + end + end + end + + type request = { url: String, x_request_id: String, user_agent: String } + + class Request < Imagekitio::Internal::Type::BaseModel + attr_accessor url: String + + attr_accessor x_request_id: String + + attr_reader user_agent: String? + + def user_agent=: (String) -> String + + def initialize: ( + url: String, + x_request_id: String, + ?user_agent: String + ) -> void + + def to_hash: -> { + url: String, + x_request_id: String, + user_agent: String + } + end + end + end +end diff --git a/sig/imagekitio/models/video_transformation_error_event.rbs b/sig/imagekitio/models/video_transformation_error_event.rbs new file mode 100644 index 00000000..f973d1a3 --- /dev/null +++ b/sig/imagekitio/models/video_transformation_error_event.rbs @@ -0,0 +1,300 @@ +module Imagekitio + module Models + type video_transformation_error_event = + { + created_at: Time, + data: Imagekitio::VideoTransformationErrorEvent::Data, + request: Imagekitio::VideoTransformationErrorEvent::Request, + type: :"video.transformation.error" + } + + class VideoTransformationErrorEvent < Imagekitio::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekitio::VideoTransformationErrorEvent::Data + + def data=: ( + Imagekitio::VideoTransformationErrorEvent::Data _ + ) -> Imagekitio::VideoTransformationErrorEvent::Data + + def request: -> Imagekitio::VideoTransformationErrorEvent::Request + + def request=: ( + Imagekitio::VideoTransformationErrorEvent::Request _ + ) -> Imagekitio::VideoTransformationErrorEvent::Request + + def `type`: -> :"video.transformation.error" + + def type=: ( + :"video.transformation.error" _ + ) -> :"video.transformation.error" + + def initialize: ( + created_at: Time, + data: Imagekitio::VideoTransformationErrorEvent::Data, + request: Imagekitio::VideoTransformationErrorEvent::Request, + ?type: :"video.transformation.error" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekitio::VideoTransformationErrorEvent::Data, + request: Imagekitio::VideoTransformationErrorEvent::Request, + type: :"video.transformation.error" + } + + type data = + { + asset: Imagekitio::VideoTransformationErrorEvent::Data::Asset, + transformation: Imagekitio::VideoTransformationErrorEvent::Data::Transformation + } + + class Data < Imagekitio::Internal::Type::BaseModel + attr_accessor asset: Imagekitio::VideoTransformationErrorEvent::Data::Asset + + attr_accessor transformation: Imagekitio::VideoTransformationErrorEvent::Data::Transformation + + def initialize: ( + asset: Imagekitio::VideoTransformationErrorEvent::Data::Asset, + transformation: Imagekitio::VideoTransformationErrorEvent::Data::Transformation + ) -> void + + def to_hash: -> { + asset: Imagekitio::VideoTransformationErrorEvent::Data::Asset, + transformation: Imagekitio::VideoTransformationErrorEvent::Data::Transformation + } + + type asset = { url: String } + + class Asset < Imagekitio::Internal::Type::BaseModel + attr_accessor url: String + + def initialize: (url: String) -> void + + def to_hash: -> { url: String } + end + + type transformation = + { + type: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::type_, + error: Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error, + options: Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::type_ + + attr_reader error: Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error? + + def error=: ( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error + ) -> Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error + + attr_reader options: Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options? + + def options=: ( + Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options + ) -> Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options + + def initialize: ( + type: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::type_, + ?error: Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error, + ?options: Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::type_, + error: Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Error, + options: Imagekitio::VideoTransformationErrorEvent::Data::Transformation::Options + } + + type type_ = + :"video-transformation" | :"gif-to-video" | :"video-thumbnail" + + module Type + extend Imagekitio::Internal::Type::Enum + + VIDEO_TRANSFORMATION: :"video-transformation" + GIF_TO_VIDEO: :"gif-to-video" + VIDEO_THUMBNAIL: :"video-thumbnail" + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::type_] + end + + type error = + { + reason: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason + } + + class Error < Imagekitio::Internal::Type::BaseModel + attr_accessor reason: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason + + def initialize: ( + reason: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason + ) -> void + + def to_hash: -> { + reason: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason + } + + type reason = + :encoding_failed | :download_failed | :internal_server_error + + module Reason + extend Imagekitio::Internal::Type::Enum + + ENCODING_FAILED: :encoding_failed + DOWNLOAD_FAILED: :download_failed + INTERNAL_SERVER_ERROR: :internal_server_error + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Error::reason] + end + end + + type options = + { + audio_codec: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + } + + class Options < Imagekitio::Internal::Type::BaseModel + attr_reader audio_codec: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec? + + def audio_codec=: ( + Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec + ) -> Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec + + attr_reader auto_rotate: bool? + + def auto_rotate=: (bool) -> bool + + attr_reader format_: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_? + + def format_=: ( + Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_ + ) -> Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_ + + attr_reader quality: Integer? + + def quality=: (Integer) -> Integer + + attr_reader stream_protocol: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol? + + def stream_protocol=: ( + Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol + ) -> Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol + + attr_reader variants: ::Array[String]? + + def variants=: (::Array[String]) -> ::Array[String] + + attr_reader video_codec: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec? + + def video_codec=: ( + Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + ) -> Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + + def initialize: ( + ?audio_codec: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec, + ?auto_rotate: bool, + ?format_: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_, + ?quality: Integer, + ?stream_protocol: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol, + ?variants: ::Array[String], + ?video_codec: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + ) -> void + + def to_hash: -> { + audio_codec: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec + } + + type audio_codec = :aac | :opus + + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + AAC: :aac + OPUS: :opus + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::audio_codec] + end + + type format_ = :mp4 | :webm | :jpg | :png | :webp + + module Format + extend Imagekitio::Internal::Type::Enum + + MP4: :mp4 + WEBM: :webm + JPG: :jpg + PNG: :png + WEBP: :webp + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::format_] + end + + type stream_protocol = :HLS | :DASH + + module StreamProtocol + extend Imagekitio::Internal::Type::Enum + + HLS: :HLS + DASH: :DASH + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::stream_protocol] + end + + type video_codec = :h264 | :vp9 | :av1 + + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + H264: :h264 + VP9: :vp9 + AV1: :av1 + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationErrorEvent::Data::Transformation::Options::video_codec] + end + end + end + end + + type request = { url: String, x_request_id: String, user_agent: String } + + class Request < Imagekitio::Internal::Type::BaseModel + attr_accessor url: String + + attr_accessor x_request_id: String + + attr_reader user_agent: String? + + def user_agent=: (String) -> String + + def initialize: ( + url: String, + x_request_id: String, + ?user_agent: String + ) -> void + + def to_hash: -> { + url: String, + x_request_id: String, + user_agent: String + } + end + end + end +end diff --git a/sig/imagekitio/models/video_transformation_ready_event.rbs b/sig/imagekitio/models/video_transformation_ready_event.rbs new file mode 100644 index 00000000..1bf70a49 --- /dev/null +++ b/sig/imagekitio/models/video_transformation_ready_event.rbs @@ -0,0 +1,359 @@ +module Imagekitio + module Models + type video_transformation_ready_event = + { + created_at: Time, + data: Imagekitio::VideoTransformationReadyEvent::Data, + request: Imagekitio::VideoTransformationReadyEvent::Request, + type: :"video.transformation.ready", + timings: Imagekitio::VideoTransformationReadyEvent::Timings + } + + class VideoTransformationReadyEvent < Imagekitio::Models::BaseWebhookEvent + def created_at: -> Time + + def created_at=: (Time _) -> Time + + def data: -> Imagekitio::VideoTransformationReadyEvent::Data + + def data=: ( + Imagekitio::VideoTransformationReadyEvent::Data _ + ) -> Imagekitio::VideoTransformationReadyEvent::Data + + def request: -> Imagekitio::VideoTransformationReadyEvent::Request + + def request=: ( + Imagekitio::VideoTransformationReadyEvent::Request _ + ) -> Imagekitio::VideoTransformationReadyEvent::Request + + def `type`: -> :"video.transformation.ready" + + def type=: ( + :"video.transformation.ready" _ + ) -> :"video.transformation.ready" + + def timings: -> Imagekitio::VideoTransformationReadyEvent::Timings? + + def timings=: ( + Imagekitio::VideoTransformationReadyEvent::Timings _ + ) -> Imagekitio::VideoTransformationReadyEvent::Timings + + def initialize: ( + created_at: Time, + data: Imagekitio::VideoTransformationReadyEvent::Data, + request: Imagekitio::VideoTransformationReadyEvent::Request, + ?timings: Imagekitio::VideoTransformationReadyEvent::Timings, + ?type: :"video.transformation.ready" + ) -> void + + def to_hash: -> { + created_at: Time, + data: Imagekitio::VideoTransformationReadyEvent::Data, + request: Imagekitio::VideoTransformationReadyEvent::Request, + type: :"video.transformation.ready", + timings: Imagekitio::VideoTransformationReadyEvent::Timings + } + + type data = + { + asset: Imagekitio::VideoTransformationReadyEvent::Data::Asset, + transformation: Imagekitio::VideoTransformationReadyEvent::Data::Transformation + } + + class Data < Imagekitio::Internal::Type::BaseModel + attr_accessor asset: Imagekitio::VideoTransformationReadyEvent::Data::Asset + + attr_accessor transformation: Imagekitio::VideoTransformationReadyEvent::Data::Transformation + + def initialize: ( + asset: Imagekitio::VideoTransformationReadyEvent::Data::Asset, + transformation: Imagekitio::VideoTransformationReadyEvent::Data::Transformation + ) -> void + + def to_hash: -> { + asset: Imagekitio::VideoTransformationReadyEvent::Data::Asset, + transformation: Imagekitio::VideoTransformationReadyEvent::Data::Transformation + } + + type asset = { url: String } + + class Asset < Imagekitio::Internal::Type::BaseModel + attr_accessor url: String + + def initialize: (url: String) -> void + + def to_hash: -> { url: String } + end + + type transformation = + { + type: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::type_, + options: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options, + output: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output + } + + class Transformation < Imagekitio::Internal::Type::BaseModel + attr_accessor type: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::type_ + + attr_reader options: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options? + + def options=: ( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options + ) -> Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options + + attr_reader output: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output? + + def output=: ( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output + ) -> Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output + + def initialize: ( + type: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::type_, + ?options: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options, + ?output: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output + ) -> void + + def to_hash: -> { + type: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::type_, + options: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Options, + output: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output + } + + type type_ = + :"video-transformation" | :"gif-to-video" | :"video-thumbnail" + + module Type + extend Imagekitio::Internal::Type::Enum + + VIDEO_TRANSFORMATION: :"video-transformation" + GIF_TO_VIDEO: :"gif-to-video" + VIDEO_THUMBNAIL: :"video-thumbnail" + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::type_] + end + + type options = + { + audio_codec: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + } + + class Options < Imagekitio::Internal::Type::BaseModel + attr_reader audio_codec: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec? + + def audio_codec=: ( + Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec + ) -> Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec + + attr_reader auto_rotate: bool? + + def auto_rotate=: (bool) -> bool + + attr_reader format_: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_? + + def format_=: ( + Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_ + ) -> Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_ + + attr_reader quality: Integer? + + def quality=: (Integer) -> Integer + + attr_reader stream_protocol: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol? + + def stream_protocol=: ( + Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol + ) -> Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol + + attr_reader variants: ::Array[String]? + + def variants=: (::Array[String]) -> ::Array[String] + + attr_reader video_codec: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec? + + def video_codec=: ( + Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + ) -> Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + + def initialize: ( + ?audio_codec: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec, + ?auto_rotate: bool, + ?format_: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_, + ?quality: Integer, + ?stream_protocol: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol, + ?variants: ::Array[String], + ?video_codec: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + ) -> void + + def to_hash: -> { + audio_codec: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec, + auto_rotate: bool, + format_: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_, + quality: Integer, + stream_protocol: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol, + variants: ::Array[String], + video_codec: Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec + } + + type audio_codec = :aac | :opus + + module AudioCodec + extend Imagekitio::Internal::Type::Enum + + AAC: :aac + OPUS: :opus + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::audio_codec] + end + + type format_ = :mp4 | :webm | :jpg | :png | :webp + + module Format + extend Imagekitio::Internal::Type::Enum + + MP4: :mp4 + WEBM: :webm + JPG: :jpg + PNG: :png + WEBP: :webp + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::format_] + end + + type stream_protocol = :HLS | :DASH + + module StreamProtocol + extend Imagekitio::Internal::Type::Enum + + HLS: :HLS + DASH: :DASH + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::stream_protocol] + end + + type video_codec = :h264 | :vp9 | :av1 + + module VideoCodec + extend Imagekitio::Internal::Type::Enum + + H264: :h264 + VP9: :vp9 + AV1: :av1 + + def self?.values: -> ::Array[Imagekitio::Models::VideoTransformationReadyEvent::Data::Transformation::Options::video_codec] + end + end + + type output = + { + url: String, + video_metadata: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + } + + class Output < Imagekitio::Internal::Type::BaseModel + attr_accessor url: String + + attr_reader video_metadata: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata? + + def video_metadata=: ( + Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + ) -> Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + + def initialize: ( + url: String, + ?video_metadata: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + ) -> void + + def to_hash: -> { + url: String, + video_metadata: Imagekitio::VideoTransformationReadyEvent::Data::Transformation::Output::VideoMetadata + } + + type video_metadata = + { + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + } + + class VideoMetadata < Imagekitio::Internal::Type::BaseModel + attr_accessor bitrate: Integer + + attr_accessor duration: Float + + attr_accessor height: Integer + + attr_accessor width: Integer + + def initialize: ( + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + ) -> void + + def to_hash: -> { + bitrate: Integer, + duration: Float, + height: Integer, + width: Integer + } + end + end + end + end + + type request = { url: String, x_request_id: String, user_agent: String } + + class Request < Imagekitio::Internal::Type::BaseModel + attr_accessor url: String + + attr_accessor x_request_id: String + + attr_reader user_agent: String? + + def user_agent=: (String) -> String + + def initialize: ( + url: String, + x_request_id: String, + ?user_agent: String + ) -> void + + def to_hash: -> { + url: String, + x_request_id: String, + user_agent: String + } + end + + type timings = { download_duration: Integer, encoding_duration: Integer } + + class Timings < Imagekitio::Internal::Type::BaseModel + attr_reader download_duration: Integer? + + def download_duration=: (Integer) -> Integer + + attr_reader encoding_duration: Integer? + + def encoding_duration=: (Integer) -> Integer + + def initialize: ( + ?download_duration: Integer, + ?encoding_duration: Integer + ) -> void + + def to_hash: -> { + download_duration: Integer, + encoding_duration: Integer + } + end + end + end +end diff --git a/sig/imagekitio/models/webhook_unsafe_unwrap_params.rbs b/sig/imagekitio/models/webhook_unsafe_unwrap_params.rbs new file mode 100644 index 00000000..787afc10 --- /dev/null +++ b/sig/imagekitio/models/webhook_unsafe_unwrap_params.rbs @@ -0,0 +1,15 @@ +module Imagekitio + module Models + type webhook_unsafe_unwrap_params = + { } & Imagekitio::Internal::Type::request_parameters + + class WebhookUnsafeUnwrapParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end +end diff --git a/sig/imagekitio/models/webhook_unwrap_params.rbs b/sig/imagekitio/models/webhook_unwrap_params.rbs new file mode 100644 index 00000000..a07a2d12 --- /dev/null +++ b/sig/imagekitio/models/webhook_unwrap_params.rbs @@ -0,0 +1,15 @@ +module Imagekitio + module Models + type webhook_unwrap_params = + { } & Imagekitio::Internal::Type::request_parameters + + class WebhookUnwrapParams < Imagekitio::Internal::Type::BaseModel + extend Imagekitio::Internal::Type::RequestParameters::Converter + include Imagekitio::Internal::Type::RequestParameters + + def initialize: (?request_options: Imagekitio::request_opts) -> void + + def to_hash: -> { request_options: Imagekitio::RequestOptions } + end + end +end diff --git a/sig/imagekitio/request_options.rbs b/sig/imagekitio/request_options.rbs new file mode 100644 index 00000000..1f34da8f --- /dev/null +++ b/sig/imagekitio/request_options.rbs @@ -0,0 +1,36 @@ +module Imagekitio + type request_opts = + Imagekitio::RequestOptions + | Imagekitio::request_options + | ::Hash[Symbol, top] + + type request_options = + { + idempotency_key: String?, + extra_query: ::Hash[String, (::Array[String] | String)?]?, + extra_headers: ::Hash[String, String?]?, + extra_body: top?, + max_retries: Integer?, + timeout: Float? + } + + class RequestOptions < Imagekitio::Internal::Type::BaseModel + def self.validate!: (Imagekitio::request_opts opts) -> void + + attr_accessor idempotency_key: String? + + attr_accessor extra_query: ::Hash[String, (::Array[String] | String)?]? + + attr_accessor extra_headers: ::Hash[String, String?]? + + attr_accessor extra_body: top? + + attr_accessor max_retries: Integer? + + attr_accessor timeout: Float? + + def initialize: ( + ?Imagekitio::request_options | ::Hash[Symbol, top] values + ) -> void + end +end diff --git a/sig/imagekitio/resources/accounts.rbs b/sig/imagekitio/resources/accounts.rbs new file mode 100644 index 00000000..0e844846 --- /dev/null +++ b/sig/imagekitio/resources/accounts.rbs @@ -0,0 +1,13 @@ +module Imagekitio + module Resources + class Accounts + attr_reader usage: Imagekitio::Resources::Accounts::Usage + + attr_reader origins: Imagekitio::Resources::Accounts::Origins + + attr_reader url_endpoints: Imagekitio::Resources::Accounts::URLEndpoints + + def initialize: (client: Imagekitio::Client) -> void + end + end +end diff --git a/sig/imagekitio/resources/accounts/origins.rbs b/sig/imagekitio/resources/accounts/origins.rbs new file mode 100644 index 00000000..11b28b8b --- /dev/null +++ b/sig/imagekitio/resources/accounts/origins.rbs @@ -0,0 +1,34 @@ +module Imagekitio + module Resources + class Accounts + class Origins + def create: ( + origin_request: Imagekitio::Models::Accounts::OriginRequest, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Accounts::origin_response + + def update: ( + String id, + origin_request: Imagekitio::Models::Accounts::OriginRequest, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Accounts::origin_response + + def list: ( + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Accounts::origin_list_response + + def delete: ( + String id, + ?request_options: Imagekitio::request_opts + ) -> nil + + def get: ( + String id, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Accounts::origin_response + + def initialize: (client: Imagekitio::Client) -> void + end + end + end +end diff --git a/sig/imagekitio/resources/accounts/url_endpoints.rbs b/sig/imagekitio/resources/accounts/url_endpoints.rbs new file mode 100644 index 00000000..6c87a690 --- /dev/null +++ b/sig/imagekitio/resources/accounts/url_endpoints.rbs @@ -0,0 +1,40 @@ +module Imagekitio + module Resources + class Accounts + class URLEndpoints + def create: ( + description: String, + ?origins: ::Array[String], + ?url_prefix: String, + ?url_rewriter: Imagekitio::Models::Accounts::URLEndpointRequest::url_rewriter, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Accounts::URLEndpointResponse + + def update: ( + String id, + description: String, + ?origins: ::Array[String], + ?url_prefix: String, + ?url_rewriter: Imagekitio::Models::Accounts::URLEndpointRequest::url_rewriter, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Accounts::URLEndpointResponse + + def list: ( + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Accounts::url_endpoint_list_response + + def delete: ( + String id, + ?request_options: Imagekitio::request_opts + ) -> nil + + def get: ( + String id, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Accounts::URLEndpointResponse + + def initialize: (client: Imagekitio::Client) -> void + end + end + end +end diff --git a/sig/imagekitio/resources/accounts/usage.rbs b/sig/imagekitio/resources/accounts/usage.rbs new file mode 100644 index 00000000..3917760c --- /dev/null +++ b/sig/imagekitio/resources/accounts/usage.rbs @@ -0,0 +1,15 @@ +module Imagekitio + module Resources + class Accounts + class Usage + def get: ( + end_date: Date, + start_date: Date, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Accounts::UsageGetResponse + + def initialize: (client: Imagekitio::Client) -> void + end + end + end +end diff --git a/sig/imagekitio/resources/assets.rbs b/sig/imagekitio/resources/assets.rbs new file mode 100644 index 00000000..3561b9cb --- /dev/null +++ b/sig/imagekitio/resources/assets.rbs @@ -0,0 +1,18 @@ +module Imagekitio + module Resources + class Assets + def list: ( + ?file_type: Imagekitio::Models::AssetListParams::file_type, + ?limit: Integer, + ?path: String, + ?search_query: String, + ?skip: Integer, + ?sort: Imagekitio::Models::AssetListParams::sort, + ?type: Imagekitio::Models::AssetListParams::type_, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::asset_list_response + + def initialize: (client: Imagekitio::Client) -> void + end + end +end diff --git a/sig/imagekitio/resources/beta.rbs b/sig/imagekitio/resources/beta.rbs new file mode 100644 index 00000000..4a1485f9 --- /dev/null +++ b/sig/imagekitio/resources/beta.rbs @@ -0,0 +1,9 @@ +module Imagekitio + module Resources + class Beta + attr_reader v2: Imagekitio::Resources::Beta::V2 + + def initialize: (client: Imagekitio::Client) -> void + end + end +end diff --git a/sig/imagekitio/resources/beta/v2.rbs b/sig/imagekitio/resources/beta/v2.rbs new file mode 100644 index 00000000..d66806c7 --- /dev/null +++ b/sig/imagekitio/resources/beta/v2.rbs @@ -0,0 +1,11 @@ +module Imagekitio + module Resources + class Beta + class V2 + attr_reader files: Imagekitio::Resources::Beta::V2::Files + + def initialize: (client: Imagekitio::Client) -> void + end + end + end +end diff --git a/sig/imagekitio/resources/beta/v2/files.rbs b/sig/imagekitio/resources/beta/v2/files.rbs new file mode 100644 index 00000000..2df59535 --- /dev/null +++ b/sig/imagekitio/resources/beta/v2/files.rbs @@ -0,0 +1,35 @@ +module Imagekitio + module Resources + class Beta + class V2 + class Files + def upload: ( + file: Imagekitio::Internal::file_input, + file_name: String, + ?token: String, + ?checks: String, + ?custom_coordinates: String, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?extensions: Imagekitio::Models::extensions, + ?folder: String, + ?is_private_file: bool, + ?is_published: bool, + ?overwrite_ai_tags: bool, + ?overwrite_custom_metadata: bool, + ?overwrite_file: bool, + ?overwrite_tags: bool, + ?response_fields: ::Array[Imagekitio::Models::Beta::V2::FileUploadParams::response_field], + ?tags: ::Array[String], + ?transformation: Imagekitio::Beta::V2::FileUploadParams::Transformation, + ?use_unique_file_name: bool, + ?webhook_url: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Beta::V2::FileUploadResponse + + def initialize: (client: Imagekitio::Client) -> void + end + end + end + end +end diff --git a/sig/imagekitio/resources/cache.rbs b/sig/imagekitio/resources/cache.rbs new file mode 100644 index 00000000..002e5e99 --- /dev/null +++ b/sig/imagekitio/resources/cache.rbs @@ -0,0 +1,9 @@ +module Imagekitio + module Resources + class Cache + attr_reader invalidation: Imagekitio::Resources::Cache::Invalidation + + def initialize: (client: Imagekitio::Client) -> void + end + end +end diff --git a/sig/imagekitio/resources/cache/invalidation.rbs b/sig/imagekitio/resources/cache/invalidation.rbs new file mode 100644 index 00000000..5e8ef9a0 --- /dev/null +++ b/sig/imagekitio/resources/cache/invalidation.rbs @@ -0,0 +1,19 @@ +module Imagekitio + module Resources + class Cache + class Invalidation + def create: ( + url: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Cache::InvalidationCreateResponse + + def get: ( + String request_id, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Cache::InvalidationGetResponse + + def initialize: (client: Imagekitio::Client) -> void + end + end + end +end diff --git a/sig/imagekitio/resources/custom_metadata_fields.rbs b/sig/imagekitio/resources/custom_metadata_fields.rbs new file mode 100644 index 00000000..f4f8e326 --- /dev/null +++ b/sig/imagekitio/resources/custom_metadata_fields.rbs @@ -0,0 +1,32 @@ +module Imagekitio + module Resources + class CustomMetadataFields + def create: ( + label: String, + name: String, + schema: Imagekitio::CustomMetadataFieldCreateParams::Schema, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::CustomMetadataField + + def update: ( + String id, + ?label: String, + ?schema: Imagekitio::CustomMetadataFieldUpdateParams::Schema, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::CustomMetadataField + + def list: ( + ?folder_path: String, + ?include_deleted: bool, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::custom_metadata_field_list_response + + def delete: ( + String id, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::CustomMetadataFieldDeleteResponse + + def initialize: (client: Imagekitio::Client) -> void + end + end +end diff --git a/sig/imagekitio/resources/files.rbs b/sig/imagekitio/resources/files.rbs new file mode 100644 index 00000000..0b08f98e --- /dev/null +++ b/sig/imagekitio/resources/files.rbs @@ -0,0 +1,76 @@ +module Imagekitio + module Resources + class Files + attr_reader bulk: Imagekitio::Resources::Files::Bulk + + attr_reader versions: Imagekitio::Resources::Files::Versions + + attr_reader metadata: Imagekitio::Resources::Files::Metadata + + def update: ( + String file_id, + update_file_request: Imagekitio::Models::UpdateFileRequest, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FileUpdateResponse + + def delete: ( + String file_id, + ?request_options: Imagekitio::request_opts + ) -> nil + + def copy: ( + destination_path: String, + source_file_path: String, + ?include_file_versions: bool, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FileCopyResponse + + def get: ( + String file_id, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::File + + def move: ( + destination_path: String, + source_file_path: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FileMoveResponse + + def rename: ( + file_path: String, + new_file_name: String, + ?purge_cache: bool, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FileRenameResponse + + def upload: ( + file: Imagekitio::Internal::file_input, + file_name: String, + ?token: String, + ?checks: String, + ?custom_coordinates: String, + ?custom_metadata: ::Hash[Symbol, top], + ?description: String, + ?expire: Integer, + ?extensions: Imagekitio::Models::extensions, + ?folder: String, + ?is_private_file: bool, + ?is_published: bool, + ?overwrite_ai_tags: bool, + ?overwrite_custom_metadata: bool, + ?overwrite_file: bool, + ?overwrite_tags: bool, + ?public_key: String, + ?response_fields: ::Array[Imagekitio::Models::FileUploadParams::response_field], + ?signature: String, + ?tags: ::Array[String], + ?transformation: Imagekitio::FileUploadParams::Transformation, + ?use_unique_file_name: bool, + ?webhook_url: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FileUploadResponse + + def initialize: (client: Imagekitio::Client) -> void + end + end +end diff --git a/sig/imagekitio/resources/files/bulk.rbs b/sig/imagekitio/resources/files/bulk.rbs new file mode 100644 index 00000000..cb80b1e3 --- /dev/null +++ b/sig/imagekitio/resources/files/bulk.rbs @@ -0,0 +1,32 @@ +module Imagekitio + module Resources + class Files + class Bulk + def delete: ( + file_ids: ::Array[String], + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Files::BulkDeleteResponse + + def add_tags: ( + file_ids: ::Array[String], + tags: ::Array[String], + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Files::BulkAddTagsResponse + + def remove_ai_tags: ( + ai_tags: ::Array[String], + file_ids: ::Array[String], + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Files::BulkRemoveAITagsResponse + + def remove_tags: ( + file_ids: ::Array[String], + tags: ::Array[String], + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Files::BulkRemoveTagsResponse + + def initialize: (client: Imagekitio::Client) -> void + end + end + end +end diff --git a/sig/imagekitio/resources/files/metadata.rbs b/sig/imagekitio/resources/files/metadata.rbs new file mode 100644 index 00000000..1a647bc7 --- /dev/null +++ b/sig/imagekitio/resources/files/metadata.rbs @@ -0,0 +1,19 @@ +module Imagekitio + module Resources + class Files + class Metadata + def get: ( + String file_id, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Metadata + + def get_from_url: ( + url: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Metadata + + def initialize: (client: Imagekitio::Client) -> void + end + end + end +end diff --git a/sig/imagekitio/resources/files/versions.rbs b/sig/imagekitio/resources/files/versions.rbs new file mode 100644 index 00000000..3e981983 --- /dev/null +++ b/sig/imagekitio/resources/files/versions.rbs @@ -0,0 +1,32 @@ +module Imagekitio + module Resources + class Files + class Versions + def list: ( + String file_id, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Files::version_list_response + + def delete: ( + String version_id, + file_id: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Files::VersionDeleteResponse + + def get: ( + String version_id, + file_id: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::File + + def restore: ( + String version_id, + file_id: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::File + + def initialize: (client: Imagekitio::Client) -> void + end + end + end +end diff --git a/sig/imagekitio/resources/folders.rbs b/sig/imagekitio/resources/folders.rbs new file mode 100644 index 00000000..7ba23637 --- /dev/null +++ b/sig/imagekitio/resources/folders.rbs @@ -0,0 +1,40 @@ +module Imagekitio + module Resources + class Folders + attr_reader job: Imagekitio::Resources::Folders::Job + + def create: ( + folder_name: String, + parent_folder_path: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FolderCreateResponse + + def delete: ( + folder_path: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FolderDeleteResponse + + def copy: ( + destination_path: String, + source_folder_path: String, + ?include_versions: bool, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FolderCopyResponse + + def move: ( + destination_path: String, + source_folder_path: String, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FolderMoveResponse + + def rename: ( + folder_path: String, + new_folder_name: String, + ?purge_cache: bool, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::FolderRenameResponse + + def initialize: (client: Imagekitio::Client) -> void + end + end +end diff --git a/sig/imagekitio/resources/folders/job.rbs b/sig/imagekitio/resources/folders/job.rbs new file mode 100644 index 00000000..8ba37f21 --- /dev/null +++ b/sig/imagekitio/resources/folders/job.rbs @@ -0,0 +1,14 @@ +module Imagekitio + module Resources + class Folders + class Job + def get: ( + String job_id, + ?request_options: Imagekitio::request_opts + ) -> Imagekitio::Models::Folders::JobGetResponse + + def initialize: (client: Imagekitio::Client) -> void + end + end + end +end diff --git a/sig/imagekitio/resources/webhooks.rbs b/sig/imagekitio/resources/webhooks.rbs new file mode 100644 index 00000000..9cd2215b --- /dev/null +++ b/sig/imagekitio/resources/webhooks.rbs @@ -0,0 +1,27 @@ +module Imagekitio + module Resources + class Webhooks + def unsafe_unwrap: ( + String payload + ) -> (Imagekitio::VideoTransformationAcceptedEvent + | Imagekitio::VideoTransformationReadyEvent + | Imagekitio::VideoTransformationErrorEvent + | Imagekitio::UploadPreTransformSuccessEvent + | Imagekitio::UploadPreTransformErrorEvent + | Imagekitio::UploadPostTransformSuccessEvent + | Imagekitio::UploadPostTransformErrorEvent) + + def unwrap: ( + String payload + ) -> (Imagekitio::VideoTransformationAcceptedEvent + | Imagekitio::VideoTransformationReadyEvent + | Imagekitio::VideoTransformationErrorEvent + | Imagekitio::UploadPreTransformSuccessEvent + | Imagekitio::UploadPreTransformErrorEvent + | Imagekitio::UploadPostTransformSuccessEvent + | Imagekitio::UploadPostTransformErrorEvent) + + def initialize: (client: Imagekitio::Client) -> void + end + end +end diff --git a/sig/imagekitio/version.rbs b/sig/imagekitio/version.rbs new file mode 100644 index 00000000..62f8859a --- /dev/null +++ b/sig/imagekitio/version.rbs @@ -0,0 +1,3 @@ +module Imagekitio + VERSION: String +end diff --git a/sorbet/config b/sorbet/config new file mode 100644 index 00000000..6fe84ed8 --- /dev/null +++ b/sorbet/config @@ -0,0 +1,2 @@ +--dir=rbi/ +--ignore=test/ diff --git a/sorbet/rbi/.gitignore b/sorbet/rbi/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/sorbet/rbi/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/test/imagekit/api_service/bulk_test.rb b/test/imagekit/api_service/bulk_test.rb deleted file mode 100644 index a1a234fb..00000000 --- a/test/imagekit/api_service/bulk_test.rb +++ /dev/null @@ -1,185 +0,0 @@ -require_relative '../spec_helper' - -RSpec.describe ImageKitIo::ApiService::Bulk do - let(:bulk_api_service) { described_class } - let(:config) { ImageKitIo.config } - let(:constants) { ImageKitIo.constants } - let!(:private_key) { config.private_key } - let!(:public_key) { config.public_key } - let!(:url_endpoint) { config.url_endpoint } - - describe 'TestBatchDelete' do - it "test_remove_files_fails_on_unauthenticated_request" do - file_ids = %w[file_id_1 file_id_2] - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({code: 401, body: {}}) - - SUT = bulk_api_service.new(request_obj) - resp = SUT.remove_files(file_ids: file_ids) - - expect(@ac[:payload]).to eq({"fileIds": file_ids}.to_json) - expect(resp[:code]).to eq(401) - end - - it "test_remove_files_fails_on_item_not_found" do - file_ids = %w[file_id_1 file_id_2] - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({code: 404, body: {message: "The requested file(s) does not exist.", - help: "For support kindly contact us at support@imagekit.io .", - missingFileIds: file_ids,},},) - - SUT = bulk_api_service.new(request_obj) - resp = SUT.remove_files(file_ids: file_ids) - - expect(@ac[:payload]).to eq({"fileIds": file_ids}.to_json) - expect(resp[:code]).to eq(404) - expect(resp[:body][:missingFileIds]).to eq(file_ids) - end - - it "test_remove_files_succeeds" do - request_obj = double - file_ids = %w[file_id_1 file_id_2] - - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({code: 200, body: {successfullyDeletedFileIds: file_ids}}) - - SUT = bulk_api_service.new(request_obj) - resp = SUT.remove_files(file_ids: file_ids) - - expect(@ac[:payload]).to eq({"fileIds": file_ids}.to_json) - expect(resp[:code]).to eq(200) - expect(resp[:body][:successfullyDeletedFileIds]).to eq(file_ids) - end - end - - context 'batch tags' do - let!(:req_obj) { double } - let(:file_ids) { %[file_id_1 file_id_2] } - - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: { successfullyUpdatedFileIds: file_ids }}) - @sut = bulk_api_service.new(req_obj) - end - - context 'add_tags' do - it 'raises error on empty parameters' do - expect { - @sut.add_tags - }.to raise_error(ArgumentError) - end - - it 'test_add_tags' do - resp = @sut.add_tags(file_ids: file_ids, tags: ['custom_tag']) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/addTags") - expect(@ac[:payload]).to eq("{\"fileIds\":\"file_id_1 file_id_2\",\"tags\":[\"custom_tag\"]}") - expect(resp[:code]).to eq(200) - end - end - - context 'remove_tags' do - it 'raises error on empty parameters' do - expect { - @sut.remove_tags - }.to raise_error(ArgumentError) - end - - it 'test_remove_tags' do - resp = @sut.remove_tags(file_ids: file_ids, tags: ['custom_tag_remove']) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/removeTags") - expect(@ac[:payload]).to eq("{\"fileIds\":\"file_id_1 file_id_2\",\"tags\":[\"custom_tag_remove\"]}") - expect(resp[:code]).to eq(200) - end - end - - context 'remove_ai_tags' do - it 'raises error on empty parameters' do - expect { - @sut.remove_ai_tags - }.to raise_error(ArgumentError) - end - - it 'test_remove_ai_tags' do - resp = @sut.remove_ai_tags(file_ids: file_ids, ai_tags: ['custom_ai_tag']) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/removeAITags") - expect(@ac[:payload]).to eq("{\"fileIds\":\"file_id_1 file_id_2\",\"AITags\":[\"custom_ai_tag\"]}") - expect(resp[:code]).to eq(200) - end - end - end - - context 'job status' do - let(:req_obj) { double } - let(:job_id) { '619e038e20b7ef03efc4eeb9' } - - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - response_body = {"jobId"=> job_id, "type"=>"MOVE_FOLDER", "status"=>"Completed"} - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: response_body }) - @sut = bulk_api_service.new(req_obj) - end - - it 'raises error when parameter id not given' do - expect { - @sut.job_status - }.to raise_error(ArgumentError) - end - - it 'test_job_status' do - resp = @sut.job_status(job_id: job_id) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/bulkJobs/#{job_id}") - expect(@ac[:method]).to eq('get') - expect(@ac[:payload]).to eq({ :jobId => job_id}) - expect(resp[:body]['jobId']).to eq(job_id) - expect(resp[:body]['status']).to eq('Completed') - end - end -end diff --git a/test/imagekit/api_service/custom_metadata_field_test.rb b/test/imagekit/api_service/custom_metadata_field_test.rb deleted file mode 100644 index 5555bb9b..00000000 --- a/test/imagekit/api_service/custom_metadata_field_test.rb +++ /dev/null @@ -1,101 +0,0 @@ -require_relative '../spec_helper' - -RSpec.describe ImageKitIo::ApiService::CustomMetadataField do - let(:custom_metadata_service) { described_class } - let(:config) { ImageKitIo.config } - let(:constants) { ImageKitIo.constants } - let!(:private_key) { config.private_key } - let!(:public_key) { config.public_key } - let!(:url_endpoint) { config.url_endpoint } - - context 'custom metadata' do - let(:req_obj) { double } - let(:success_response) { - {"id"=>"619e667520b7ef03efc5d870", "name"=>"price1", "label"=>"price", "schema"=>{"type"=>"Number", "minValue"=>100, "maxValue"=>300}} - } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - - end - - it 'raises error when not providing parameter for create' do - @sut = custom_metadata_service.new(req_obj) - expect { - @sut.create(name: nil, label: 'test_label', schema: '') - }.to raise_error(ArgumentError) - end - - it 'test_create_custom_metadata' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: success_response }) - @sut = custom_metadata_service.new(req_obj) - resp = @sut.create( - name: 'price1', - label: 'price', - schema: { - type: 'Number', - minValue: 100, - maxValue: 300 - } - ) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/customMetadataFields") - expect(@ac[:method]).to eq('post') - expect(resp[:body]['id']).to eq(success_response["id"]) - end - - it 'test_get_custom_metadata' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: [success_response] }) - @sut = custom_metadata_service.new(req_obj) - resp = @sut.list - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/customMetadataFields") - expect(@ac[:method]).to eq('get') - expect(resp[:body]).to eq([success_response]) - end - - it 'raises error when parameter not provided on update_custom_metadata' do - @sut = custom_metadata_service.new(req_obj) - expect { - @sut.update(id: nil, label: 'test_label', schema: '') - }.to raise_error(ArgumentError) - end - - it 'test_update_custom_metadata' do - metadata_id = "619e667320b7ef03efc5d850" - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 200, body: {"id"=>metadata_id, "name"=>"price1", "label"=>"price1", "schema"=>{"type"=>"Number", "minValue"=>100, "maxValue"=>300}} }) - @sut = custom_metadata_service.new(req_obj) - resp = @sut.update(id: metadata_id, label: 'price1', schema: nil) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/customMetadataFields/#{metadata_id}") - expect(@ac[:method]).to eq('patch') - expect(resp[:body]).to eq({"id"=>metadata_id, "name"=>"price1", "label"=>"price1", "schema"=>{"type"=>"Number", "minValue"=>100, "maxValue"=>300}} ) - end - - it 'raises error when parameter not provided on update_custom_metadata' do - @sut = custom_metadata_service.new(req_obj) - expect { - @sut.delete - }.to raise_error(ArgumentError) - end - - it 'test_delete_custom_metadata' do - metadata_id = "619e667320b7ef03efc5d850" - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({code: 204, body: { success: true} }) - @sut = custom_metadata_service.new(req_obj) - @sut.delete(id: metadata_id) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/customMetadataFields/#{metadata_id}") - expect(@ac[:method]).to eq('delete') - end - end -end diff --git a/test/imagekit/api_service/file_test.rb b/test/imagekit/api_service/file_test.rb deleted file mode 100644 index 8707faf3..00000000 --- a/test/imagekit/api_service/file_test.rb +++ /dev/null @@ -1,1196 +0,0 @@ -require_relative '../spec_helper' - -RSpec.describe ImageKitIo::ApiService::File do - let(:file_api_service) { described_class } - let(:config) { ImageKitIo.config } - let(:constants) { ImageKitIo.constants } - let!(:private_key) { config.private_key } - let!(:public_key) { config.public_key } - let!(:url_endpoint) { config.url_endpoint } - - describe 'FileUploadTest' do - it "test_upload_with_valid_expected_success_without_tags_and_remote_url" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "http://remotefiles.com/fake_file.jpg", file_name: "my_file_name") - expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"http://remotefiles.com/fake_file.jpg\",\"fileName\":\"my_file_name\"}") - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_valid_expected_success_without_tags_and_base64" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - base64="f06830ca9f1e3e90" - upload = SUT.upload(file: base64, file_name: "my_file_name") - expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"#{base64}\",\"fileName\":\"my_file_name\"}") - expect(ImageKitIo::Utils::Calculation.is_valid_hex(base64)).to eq(true) - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_valid_expected_success_without_tags_and_file" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - file = open("test/imagekit/dummy_data/sample.jpg", "rb") - upload = SUT.upload(file: file, file_name: "my_file_name") - expect(@ac[:payload].keys).to eq([:multipart, :file, :fileName]) - expect(@ac[:payload][:file].io).to eq(file) - expect(@ac[:payload][:fileName]).to eq('my_file_name') - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_valid_expected_success_with_custom_coordinates" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", custom_coordinates: "10, 10, 100, 100") - - expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"./fake_file.jpg\",\"fileName\":\"my_file_name\",\"customCoordinates\":\"10, 10, 100, 100\"}") - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_valid_expected_success_with_extensions" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - SUT = file_api_service.new(request_obj) - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", extensions: [ - { - name: 'remove-bg', - options: { - add_shadow: true - } - } - ]) - expect(@ac[:payload]['extensions']).to eq("[{\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true}}]") - expect(upload[:status_code]).to eq(200) - end - - it "test_upload_with_valid_expected_success_with_customMetadata" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - SUT = file_api_service.new(request_obj) - upload = SUT.upload( - file: "./fake_file.jpg", - file_name: "my_file_name", - custom_metadata: { - brand: 'Nike', - color: 'red' - } - ) - expect(@ac[:payload]['customMetadata']).to eq("{\"brand\":\"Nike\",\"color\":\"red\"}") - expect(upload[:status_code]).to eq(200) - end - - it "test_upload_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", response_fields: %w[is_private_file tags], tags: %w[abc def], use_unique_file_name: false) - - expect(@ac[:payload].to_json).to eq("{\"multipart\":true,\"file\":\"./fake_file.jpg\",\"fileName\":\"my_file_name\",\"responseFields\":\"is_private_file,tags\",\"tags\":\"abc,def\",\"useUniqueFileName\":\"false\"}") - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_fails_on_invalid_options" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, message: nil}) - - SUT = file_api_service.new(request_obj) - expect{ - SUT.upload(file: "fake_file.jpg", file_name: "fake_name", invalid_option: "invalid_option" ) - }.to raise_error(ArgumentError) - end - - it "test_upload_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, message: nil}) - - SUT = file_api_service.new(request_obj) - upload = SUT.upload(file: "fake_file.jpg", file_name: "fake_name") - expect(@ac[:payload][:file]).to eq("fake_file.jpg") - expect(@ac[:payload][:fileName]).to eq("fake_name") - expect(upload[:status_code]).to eq(401) - end - - it "test_upload_with_valid_expected_success_with_transformation" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", transformation: { pre: 'l-text,i-Imagekit,fs-50,l-end', post: [{type: 'transformation', value: 'w-100'}]}) - - expect(@ac[:payload]['transformation']).to eq("{\"pre\":\"l-text,i-Imagekit,fs-50,l-end\",\"post\":[{\"type\":\"transformation\",\"value\":\"w-100\"}]}") - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_checks" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", checks: '"file.size" < "1mb"') - - expect(@ac[:payload]['checks']).to eq('"file.size" < "1mb"') - - expect(upload[:status_code]).to eq(200) - - end - - it "test_upload_with_is_published" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - - SUT = file_api_service.new(request_obj) - - upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", is_published: true ) - - expect(@ac[:payload]['isPublished']).to eq("true") - - expect(upload[:status_code]).to eq(200) - - end - - end - - describe 'FileListTest' do - it "test_list_files_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401}) - - SUT = file_api_service.new(request_obj) - resp = SUT.list("skip": 0, "limit": 10) - - expect(@ac[:payload].to_json).to eq("{\"skip\":0,\"limit\":10}") - expect(resp[:status_code]).to eq(401) - end - - it "test_list_files_succeeds_with_basic_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body:[]}) - - SUT = file_api_service.new(request_obj) - resp = SUT.list("skip": 0, "limit": 10) - expect(@ac[:payload].to_json).to eq("{\"skip\":0,\"limit\":10}") - expect(resp[:status_code]).to eq(200) - end - end - - describe 'FileVersionDetailTest' do - let(:success_response) { - "{\"fileId\":\"my_file_id\",\"name\":\"cat1.jpg\",\"size\":102117,\"versionInfo\":{\"id\":\"my_file_id\",\"name\":\"Version 2\"},\"filePath\":\"/cat1.jpg\",\"url\":\"https://ik.imagekit.io/app_id/cat1.jpg\",\"fileType\":\"image\",\"height\":700,\"width\":1050,\"thumbnailUrl\":\"https://ik.imagekit.io/app_id/tr:n-ik_ml_thumbnail/cat1.jpg\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"isPrivateFile\":true,\"customCoordinates\":null,\"metadata\":{\"height\":700,\"width\":1050,\"size\":70842,\"format\":\"jpg\",\"hasColorProfile\":false,\"quality\":0,\"density\":72,\"hasTransparency\":false,\"exif\":{},\"pHash\":\"90249d9b1fc74367\"}}" - } - it 'test_get_file_version_detail_succeeds_with_id' do - request_client = double - allow_any_instance_of(ImageKitIo::Request) - .to receive(:create_headers) - .and_return({}) - allow(RestClient::Request) - .to receive(:new) - .and_return(request_client) - allow(request_client) - .to receive(:execute) - .and_return(OpenStruct.new(code: 200, - body: success_response, - content_type: "application/json" - )) - - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - resp = SUT.get_file_version_detail(file_id: "my_file_id", version_id: 'my_file_id') - expect(resp).to_not have_key(:error) - expect(resp[:response]).to have_key('versionInfo') - expect(resp[:response]['versionInfo']['id']).to eq('my_file_id') - end - - it 'test_get_file_version_detail_failed_without_file_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.get_file_version_detail(version_id: 'file_version_id')}.to raise_error(ArgumentError, 'file_id is required') - end - - it 'test_get_file_version_detail_failed_without_version_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.get_file_version_detail(file_id: 'my_file_id')}.to raise_error(ArgumentError, 'version_id is required') - end - end - - describe 'FileVersionsTest' do - let(:success_response) { - "[{\"type\":\"file\",\"name\":\"cat1.jpg\",\"createdAt\":\"2022-06-02T11:50:44.402Z\",\"updatedAt\":\"2022-06-14T15:44:12.300Z\",\"fileId\":\"my_file_id\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"versionInfo\":{\"id\":\"my_file_id\",\"name\":\"Version 2\"},\"embeddedMetadata\":{\"DateCreated\":\"2022-06-14T15:44:12.299Z\",\"DateTimeCreated\":\"2022-06-14T15:44:12.299Z\"},\"customCoordinates\":null,\"customMetadata\":{},\"isPrivateFile\":true,\"url\":\"https://ik.imagekit.io/app_id/cat1.jpg\",\"thumbnail\":\"https://ik.imagekit.io/app_id/tr:n-ik_ml_thumbnail/cat1.jpg\",\"fileType\":\"image\",\"filePath\":\"/cat1.jpg\",\"height\":700,\"width\":1050,\"size\":102117,\"hasAlpha\":false,\"mime\":\"image/jpeg\"},{\"type\":\"file-version\",\"name\":\"cat1.jpg\",\"createdAt\":\"2022-06-14T15:44:10.910Z\",\"updatedAt\":\"2022-06-14T15:44:11.372Z\",\"fileId\":\"my_file_id\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"versionInfo\":{\"id\":\"my_file_second_version_id\",\"name\":\"Version 1\"},\"embeddedMetadata\":{\"DateCreated\":\"2022-06-02T11:50:45.537Z\",\"DateTimeCreated\":\"2022-06-02T11:50:45.540Z\"},\"customCoordinates\":null,\"customMetadata\":{},\"isPrivateFile\":true,\"url\":\"https://ik.imagekit.io/app_id/cat1.jpg?ik-obj-version=ik_version_id\",\"thumbnail\":\"https://ik.imagekit.io/app_id/tr:n-ik_ml_thumbnail/cat1.jpg?ik-obj-version=ik_version_id\",\"fileType\":\"image\",\"filePath\":\"/cat1.jpg\",\"height\":700,\"width\":1050,\"size\":102117,\"hasAlpha\":false,\"mime\":\"image/jpeg\"}]" - } - it 'test_get_file_versions_succeeds_with_id' do - request_client = double - allow_any_instance_of(ImageKitIo::Request) - .to receive(:create_headers) - .and_return({}) - allow(RestClient::Request) - .to receive(:new) - .and_return(request_client) - allow(request_client) - .to receive(:execute) - .and_return(OpenStruct.new(code: 200, - body: success_response, - content_type: "application/json" - )) - - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - resp = SUT.get_file_versions(file_id: "my_file_id") - expect(resp).to_not have_key(:error) - expect(resp[:response]).to be_an_instance_of(Array) - expect(resp[:response].length).to eq(2) - expect(resp[:response][0]['versionInfo']['id']).to eq('my_file_id') - expect(resp[:response][0]['versionInfo']['name']).to eq('Version 2') - expect(resp[:response][1]['versionInfo']['id']).to eq('my_file_second_version_id') - expect(resp[:response][1]['versionInfo']['name']).to eq('Version 1') - end - - it 'test_get_file_version_failed_without_file_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.get_file_versions}.to raise_error(ArgumentError) - end - end - - describe 'RestoreFileVersionTest' do - let(:success_response) { - "{\"type\":\"file\",\"name\":\"cat1.jpg\",\"createdAt\":\"2022-06-02T11:50:44.402Z\",\"updatedAt\":\"2022-06-14T16:20:06.258Z\",\"fileId\":\"my_file_id\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"versionInfo\":{\"id\":\"my_second_version\",\"name\":\"Version 2\"},\"embeddedMetadata\":{\"DateCreated\":\"2022-06-02T11:50:45.537Z\",\"DateTimeCreated\":\"2022-06-02T11:50:45.540Z\"},\"customCoordinates\":null,\"customMetadata\":{},\"isPrivateFile\":true,\"url\":\"https://ik.imagekit.io/app_id/cat1.jpg\",\"thumbnail\":\"https://ik.imagekit.io/app_id/tr:n-ik_ml_thumbnail/cat1.jpg\",\"fileType\":\"image\",\"filePath\":\"/cat1.jpg\",\"height\":700,\"width\":1050,\"size\":102117,\"hasAlpha\":false,\"mime\":\"image/jpeg\"}" - } - it 'test_restore_file_version_succeeds_with_id' do - request_client = double - allow_any_instance_of(ImageKitIo::Request) - .to receive(:create_headers) - .and_return({}) - allow(RestClient::Request) - .to receive(:new) - .and_return(request_client) - allow(request_client) - .to receive(:execute) - .and_return(OpenStruct.new(code: 200, - body: success_response, - content_type: "application/json" - )) - - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - resp = SUT.restore_file_version(file_id: "my_file_id", version_id: 'my_second_version') - expect(resp).to_not have_key(:error) - expect(resp[:response]['versionInfo']['id']).to eq('my_second_version') - expect(resp[:response]['versionInfo']['name']).to eq('Version 2') - end - - it 'test_restore_file_version_failed_without_file_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.restore_file_version(version_id: 'my_file_version_id')}.to raise_error(ArgumentError, 'file_id is required') - end - - it 'test_restore_file_version_failed_without_version_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.restore_file_version(file_id: 'my_file_id')}.to raise_error(ArgumentError, 'version_id is required') - end - end - - describe 'DeleteFileVersionTest' do - let(:success_response) { - "{\"success\":true}" - } - it 'test_restore_file_version_succeeds_with_id' do - request_client = double - allow_any_instance_of(ImageKitIo::Request) - .to receive(:create_headers) - .and_return({}) - allow(RestClient::Request) - .to receive(:new) - .and_return(request_client) - allow(request_client) - .to receive(:execute) - .and_return(OpenStruct.new(code: 200, - body: success_response, - content_type: "application/json" - )) - - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - resp = SUT.delete_file_version(file_id: "my_file_id", version_id: 'my_second_version') - expect(resp).to_not have_key(:error) - expect(resp[:response]['success']).to eq(true) - end - - it 'test_delete_file_version_without_file_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.delete_file_version(version_id: 'my_file_version_id')}.to raise_error(ArgumentError, 'file_id is required') - end - - it 'test_delete_file_version_failed_without_version_id' do - imagekit_request = ImageKitIo::Request.new(private_key, public_key, url_endpoint) - SUT = file_api_service.new(imagekit_request) - expect{SUT.delete_file_version(file_id: 'my_file_id')}.to raise_error(ArgumentError, 'version_id is required') - end - end - - describe 'FileDetailTest' do - it "test_get_file_details_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body:{message: "Unauthorized request!"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.details(file_identifier: "demo-file-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id/details/") - expect(resp[:status_code]).to eq(401) - expect(resp[:body][:message]).to eq("Unauthorized request!") - end - - it "test_file_details_succeeds_with_id" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {fileId: "demo-file-id"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.details(file_identifier: "demo-file-id") - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id/details/") - expect(resp[:status_code]).to eq(200) - end - end - - describe 'TestDeleteFile' do - it "test_file_delete_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {fileId: "demo-file-id"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.delete(file_id: "demo-file-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id") - expect(@ac[:method]).to eq("delete") - expect(resp[:status_code]).to eq(401) - end - - it "test_file_delete_fails_on_item_not_found" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 204, body: {fileId: "demo-file-id"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.delete(file_id: "demo-file-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id") - expect(@ac[:method]).to eq("delete") - expect(resp[:status_code]).to eq(204) - end - - it "test_file_delete_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {fileId: "demo-file-id"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.delete(file_id: "demo-file-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/demo-file-id") - expect(@ac[:method]).to eq("delete") - expect(resp[:status_code]).to eq(200) - - end - end - - describe 'TestPurgeCache' do - it "test_purge_cache_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.purge_cache(file_url: "file_url") - - expect(@ac[:payload].to_json).to eq("{\"url\":\"file_url\"}") - expect(resp[:status_code]).to eq(401) - end - - it "test_purge_cache_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {requestId:"requestId"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.purge_cache(file_url: "file_url") - - expect(@ac[:payload].to_json).to eq("{\"url\":\"file_url\"}") - expect(resp[:status_code]).to eq(200) - expect(resp[:body][:requestId]).to eq("requestId") - end - end - - describe 'TestPurgeCacheStatus' do - it "test_get_purge_cache_status_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.purge_cache_status(request_id: "request-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/purge/request-id") - expect(resp[:status_code]).to eq(401) - - end - - it "test_purge_cache_status_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {status: "Complete"}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.purge_cache_status(request_id: "request-id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/purge/request-id") - expect(resp[:status_code]).to eq(200) - expect(resp[:body][:status]).to eq("Complete") - end - end - - describe 'TestGetMetaData' do - it "test_get_metadata_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.get_metadata(file_id: "file_id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/file_id/metadata") - expect(resp[:status_code]).to eq(401) - - end - - it 'raises error when parameter not provided' do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {}}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.get_metadata - }.to raise_error(ArgumentError) - end - - it "test_get_metadata_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.get_metadata(file_id: "file_id") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/file_id/metadata") - expect(resp[:status_code]).to eq(200) - end - end - - describe 'TestUpdateFileDetails' do - it "test_details_fails_on_unauthenticated_request" do - - options = {"tags": %w[tag1 tag2], "custom_coordinates": "10,10,100,100"} - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.update_details(file_id: "file_id", **options) - expect(@ac[:payload]).to eq("{\"tags\":[\"tag1\",\"tag2\"],\"customCoordinates\":\"10,10,100,100\"}") - expect(resp[:status_code]).to eq(401) - - end - - it "test_update_file_details_succeeds_with_id" do - options = {tags: %w[tag1 tag2], "custom_coordinates": "10,10,100,100"} - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - resp = SUT.update_details(file_id: "file_id", **options) - - expect(JSON.parse(@ac[:payload])['tags']).to eq(options[:tags]) - expect(JSON.parse(@ac[:payload])['customCoordinates']).to eq(options[:custom_coordinates]) - expect(resp[:status_code]).to eq(200) - expect(resp[:body]).to eq(options) - end - - it "test_update_file_publication_status" do - options = { publish: { isPublished: true, includeFileVersions: true }} - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - resp = SUT.update_details(file_id: "file_id", **options) - - expect(JSON.parse(@ac[:payload])['publish']['isPublished']).to eq(options[:publish][:isPublished]) - expect(JSON.parse(@ac[:payload])['publish']['isPublished']).to eq(options[:publish][:includeFileVersions]) - expect(resp[:status_code]).to eq(200) - expect(resp[:body]).to eq(options) - end - - it "test_update_file_details_fails_missing_arguments" do - options = { tags: 'custom tag' } - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.update_details(file_id: "file_id", **options) - }.to raise_error(ArgumentError) - end - - it "test_update_file_details_fails_tags_not_an_array" do - options = {tags: "RANDOM_TEXT", "custom_coordinates": "10,10,100,100"} - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.update_details(file_id: "file_id", **options) - }.to raise_error(ArgumentError) - end - - it "test_update_file_details_fails_custom_coordinates_not_a_string" do - options = {"custom_coordinates": %w[random]} - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: options}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.update_details(file_id: "file_id", **options) - }.to raise_error(ArgumentError) - end - - it "test_update_file_details_expected_success_with_extensions" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - SUT = file_api_service.new(request_obj) - upload = SUT.update_details(file_id: "file_id_xyz", extensions: [ - { - 'name': 'google-auto-tagging', - 'maxTags': 5, - 'minConfidence': 95 - } - ]) - expect(@ac[:payload]).to eq("{\"extensions\":[{\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}]}") - expect(upload[:status_code]).to eq(200) - end - - it "test_update_with_valid_expected_success_with_customMetadata" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - @ac={} - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200}) - SUT = file_api_service.new(request_obj) - upload = SUT.update_details( - file_id: "file_id_xyz", - custom_metadata: { - brand: 'Nike', - color: 'red' - } - ) - expect(@ac[:payload]).to eq("{\"customMetadata\":{\"brand\":\"Nike\",\"color\":\"red\"}}") - expect(upload[:status_code]).to eq(200) - end - end - - describe 'TestGetRemoteFileURLMetaData' do - it "test_get_metadata_from_remote_url_fails_on_unauthenticated_request" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.get_metadata_from_remote_url(remote_file_url: "http://example.com/fakefileurl") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/metadata?url=http://example.com/fakefileurl") - expect(resp[:status_code]).to eq(401) - end - - it "test_get_metadata_from_remote_url_fails_on_blank_url" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 401, body: {}}) - - SUT = file_api_service.new(request_obj) - expect { - SUT.get_metadata_from_remote_url(remote_file_url: "") - }.to raise_error(ArgumentError) - end - - it "test_get_metadata_from_remote_url_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({status_code: 200, body: {}}) - - SUT = file_api_service.new(request_obj) - resp = SUT.get_metadata_from_remote_url(remote_file_url: "http://example.com/fakefileurl") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/metadata?url=http://example.com/fakefileurl") - expect(resp[:status_code]).to eq(200) - end - end - - context 'copy' do - let!(:req_obj) { double } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { success: true }}) - @sut = file_api_service.new(req_obj) - end - - it 'raises error when parameter not provided' do - expect { - @sut.copy(source_file_path: '', destination_path: nil) - }.to raise_error(ArgumentError) - - end - - it 'test_copy' do - source_file = 'test/dummy.png' - destination_path = '/my_image' - resp = @sut.copy(source_file_path: source_file, destination_path: destination_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/copy") - expect(@ac[:payload]).to eq("{\"sourceFilePath\":\"test/dummy.png\",\"destinationPath\":\"/my_image\",\"includeFileVersions\":false}") - expect(resp[:status_code]).to eq(200) - resp = @sut.copy(source_file_path: source_file, destination_path: destination_path, include_file_versions: true) - expect(@ac[:payload]).to eq("{\"sourceFilePath\":\"test/dummy.png\",\"destinationPath\":\"/my_image\",\"includeFileVersions\":true}") - expect(resp[:status_code]).to eq(200) - end - end - - context 'move' do - let!(:req_obj) { double } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { success: true }}) - @sut = file_api_service.new(req_obj) - end - - it 'raises error when parameter not provided' do - expect { - @sut.move(source_file_path: '', destination_path: nil) - }.to raise_error(ArgumentError) - - end - - it 'test_move' do - source_file = 'test/dummy.png' - destination_path = '/my_image' - resp = @sut.move(source_file_path: source_file, destination_path: destination_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/move") - expect(@ac[:payload]).to eq({:sourceFilePath=>"test/dummy.png", :destinationPath=>"/my_image"}) - expect(resp[:status_code]).to eq(200) - end - end - - context 'rename' do - let!(:req_obj) { double } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { success: true }}) - @sut = file_api_service.new(req_obj) - end - - it 'raises error when parameter not provided' do - expect { - @sut.rename(file_path: '', new_file_name: nil) - }.to raise_error(ArgumentError) - - end - - it 'test_rename' do - source_file = 'test/dummy.png' - new_name = 'my_image.png' - resp = @sut.rename(file_path: source_file, new_file_name: new_name) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/files/rename") - expect(@ac[:payload]).to eq("{\"filePath\":\"test/dummy.png\",\"newFileName\":\"my_image.png\"}") - expect(@ac[:method]).to eq('put') - expect(resp[:status_code]).to eq(200) - end - - it 'test_rename with the option purge_cache' do - source_file = 'test/dummy.png' - new_name = 'my_image.png' - resp = @sut.rename(file_path: source_file, new_file_name: new_name, purge_cache: true) - expect(@ac[:payload]).to eq("{\"filePath\":\"test/dummy.png\",\"newFileName\":\"my_image.png\",\"purgeCache\":true}") - end - end - - context 'stream file' do - let!(:req_obj) { double } - - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - allow(req_obj) - .to receive(:request_stream){|method,url,headers, &block| @ac={method: method, url: url, headers: headers, block: block}} - .and_return({status_code: 200, body: { success: true }}) - @sut = file_api_service.new(req_obj) - end - - it 'raises error when parameter not provided' do - expect { - @sut.stream_file - }.to raise_error(ArgumentError) - end - - it 'test_stream_file' do - remote_file_url = 'https://ik.imagekit.io/kcdfvxhgfkn/testing_Hx_I_Ys_c.jpg' - block = proc { - puts 'block given' - } - @sut.stream_file(remote_file_url: remote_file_url, &block) - - expect(@ac[:block].is_a?(Proc)).to be(true) - expect(@ac[:url]).to eq(remote_file_url) - end - end -end diff --git a/test/imagekit/api_service/folder_test.rb b/test/imagekit/api_service/folder_test.rb deleted file mode 100644 index ba42c4d2..00000000 --- a/test/imagekit/api_service/folder_test.rb +++ /dev/null @@ -1,127 +0,0 @@ -require_relative '../spec_helper' - -RSpec.describe ImageKitIo::ApiService::Folder do - let(:folder_api_service) { described_class } - let(:config) { ImageKitIo.config } - let(:constants) { ImageKitIo.constants } - let!(:private_key) { config.private_key } - let!(:public_key) { config.public_key } - let!(:url_endpoint) { config.url_endpoint } - - context 'folder' do - let!(:req_obj) { double } - before do - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(req_obj) - allow(req_obj) - .to receive(:create_headers) - .and_return({}) - end - - context 'create' do - it 'raises error when parameter not provided' do - @sut = folder_api_service.new(req_obj) - expect { - @sut.create('', nil) - }.to raise_error(ArgumentError) - end - - it 'test_create_folder' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 201, body: { success: true }}) - @sut = folder_api_service.new(req_obj) - folder_name = 'test_folder' - parent_folder = '' - resp = @sut.create(folder_name: folder_name, parent_folder_path: parent_folder) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/folder") - expect(@ac[:payload]).to eq("{\"folderName\":\"test_folder\",\"parentFolderPath\":\"\"}") - expect(@ac[:method]).to eq('post') - expect(resp[:status_code]).to eq(201) - end - end - - context 'delete' do - it 'raises error when parameter not provided' do - @sut = folder_api_service.new(req_obj) - expect { - @sut.delete - }.to raise_error(ArgumentError) - end - - it 'test_delete_folder' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 204, body: { success: true }}) - @sut = folder_api_service.new(req_obj) - folder_path = 'test_folder' - resp = @sut.delete(folder_path: folder_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/folder") - expect(@ac[:method]).to eq('delete') - expect(resp[:body][:success]).to be(true) - end - end - - context 'copy' do - it 'raises error when parameter not provided' do - @sut = folder_api_service.new(req_obj) - expect { - @sut.copy - }.to raise_error(ArgumentError) - end - - it 'test_copy_folder' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { jobId: '123456' }}) - @sut = folder_api_service.new(req_obj) - source_folder = 'my_folder' - destination_path = 'copied' - resp = @sut.copy(source_folder_path: source_folder, destination_path: destination_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/bulkJobs/copyFolder") - expect(@ac[:method]).to eq('post') - expect(@ac[:payload]).to eq("{\"sourceFolderPath\":\"my_folder\",\"destinationPath\":\"copied\",\"includeFileVersions\":false}") - expect(resp[:body][:jobId]).to eq('123456') - end - - it 'test_copy_folder_with_include_versions_parameter' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { jobId: '123456' }}) - @sut = folder_api_service.new(req_obj) - source_folder = 'my_folder' - destination_path = 'copied' - resp = @sut.copy(source_folder_path: source_folder, destination_path: destination_path, include_file_versions: true) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/bulkJobs/copyFolder") - expect(@ac[:method]).to eq('post') - expect(@ac[:payload]).to eq("{\"sourceFolderPath\":\"my_folder\",\"destinationPath\":\"copied\",\"includeFileVersions\":true}") - expect(resp[:body][:jobId]).to eq('123456') - end - end - - context 'move' do - it 'raises error when parameter not provided' do - @sut = folder_api_service.new(req_obj) - expect { - @sut.copy - }.to raise_error(ArgumentError) - end - - it 'test_move_folder' do - allow(req_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload: payload}} - .and_return({status_code: 200, body: { jobId: '123456' }}) - @sut = folder_api_service.new(req_obj) - source_folder = 'my_folder/inside_folder' - destination_path = 'moved/inside_another_folder' - resp = @sut.move(source_folder_path: source_folder, destination_path: destination_path) - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/bulkJobs/moveFolder") - expect(@ac[:method]).to eq('post') - expect(@ac[:payload]).to eq({:sourceFolderPath=>"my_folder/inside_folder", :destinationPath=>"moved/inside_another_folder"}) - expect(resp[:body][:jobId]).to eq('123456') - end - end - end -end diff --git a/test/imagekit/client_test.rb b/test/imagekit/client_test.rb deleted file mode 100644 index 33c13832..00000000 --- a/test/imagekit/client_test.rb +++ /dev/null @@ -1,409 +0,0 @@ -require_relative './spec_helper' -require 'rspec/autorun' - -RSpec.describe ImageKitIo::Client do - let(:subject) { described_class } - let!(:public_key) { 'public_xyz' } - let!(:private_key) { 'private_xyz' } - let!(:url_endpoint) { 'https://imagekit.io/your-imgekit-id' } - let(:constants) { ImageKitIo.constants } - - it "test_initialization_with_private_key_missing" do - request_obj = double - expect { - subject.new(" ", public_key, url_endpoint) - }.to raise_error(ArgumentError, constants.MISSING_PRIVATE_KEY) - end - - it "test_initialization_with_non_string_private_key" do - request_obj = double - expect { - subject.new({ RANDOM: "RANDOM"}, public_key, url_endpoint) - }.to raise_error(ArgumentError, constants.MISSING_PRIVATE_KEY) - end - - it "test_initialization_with_public_key_missing" do - request_obj = double - expect { - subject.new(private_key, " ", url_endpoint) - }.to raise_error(ArgumentError, constants.MISSING_PUBLIC_KEY) - end - - it "test_initialization_with_non_string_public_key" do - request_obj = double - expect { - subject.new(private_key, { RANDOM: "RANDOM"}, url_endpoint) - }.to raise_error(ArgumentError, constants.MISSING_PUBLIC_KEY) - end - - it "test_initialization_with_url_endpoint_missing" do - request_obj = double - expect { - subject.new(private_key, public_key, " ") - }.to raise_error(ArgumentError, constants.MISSING_URL_ENDPOINT) - end - - it "test_initialization_with_non_string_url_endpoint" do - request_obj = double - expect { - subject.new(private_key, public_key, { RANDOM: "RANDOM"}) - }.to raise_error(ArgumentError, constants.MISSING_URL_ENDPOINT) - end - - context 'FileUploadTest' do - it "test_upload_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - upload = SUT.upload_file(file: "fakefile.jpg", file_name: "fake", content_type: 'image/jpeg') - - expect(upload[:code]).to eq(200) - end - - - it "test_list_files_with_valid_expected_success" do - # test list_files method - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - file_list = SUT.list_files - - expect(file_list[:code]).to eq(200) - end - - it "test_file_versions_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - resp = SUT.file_versions(file_id: 'my_new_file_id') - - expect(resp[:code]).to eq(200) - end - - it "test_file_version_detail_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - resp = SUT.file_version_detail(file_id: 'my_new_file_id', version_id: 'my_file_version_id') - - expect(resp[:code]).to eq(200) - end - - it "test_delete_file_version_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - resp = SUT.delete_file_version(file_id: 'my_new_file_id', version_id: 'my_file_version_id') - - expect(resp[:code]).to eq(200) - end - - it "test_restore_file_version_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - resp = SUT.restore_file_version(file_id: 'my_new_file_id', version_id: 'my_file_version_id') - - expect(resp[:code]).to eq(200) - end - - it "test_get_file_details_with_valid_expected_success" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - file_detail = SUT.get_file_details(file_id: "http://example.com/fake.jpg") - - expect(file_detail[:code]).to eq(200) - end - - it "test_update_file_details_with_valid_expected_success" do - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - upload = SUT.update_file_details(file_id: "fake_id", tags: ["image_tag"], - custom_coordinates: "10,10,100, 100") - - expect(upload[:code]).to eq(200) - end - - it "test_delete_file_with_valid_expected_success" do - # test for delete_file - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - delete_resp = SUT.delete_file(file_id: "fake_id") - - expect(delete_resp[:code]).to eq(200) - end - - it "test_get_file_metadata_valid_expected_success" do - # test for get_file_metadata - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - resp = SUT.get_file_metadata(file_id: "fake_id") - - expect(resp[:code]).to eq(200) - end - - it "test_get_metadata_from_remote_url_succeeds" do - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}} - .and_return({code: 200, body: {}}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - resp = SUT.get_remote_file_url_metadata(remote_file_url: "http://example.com/fakefileurl") - - expect(@ac[:url]).to eq("https://api.imagekit.io/v1/metadata?url=http://example.com/fakefileurl") - expect(resp[:code]).to eq(200) - end - - it "test_purge_file_cache_valid_expected_success" do - # test for get_purge_file_cache - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - resp = SUT.purge_file_cache(file_url: "http://example.com/fake.jpg") - - expect(resp[:code]).to eq(200) - end - - it "test_purge_file_cache_status_valid_expected_success" do - # test for get_purge_file_cache - - request_obj = double - allow(ImageKitIo::Request) - .to receive(:new) - .with(private_key, public_key, url_endpoint) - .and_return(request_obj) - - allow(request_obj) - .to receive(:create_headers) - .and_return({}) - - allow(request_obj) - .to receive(:request) - .and_return({code: 200}) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - resp = SUT.purge_file_cache_status(request_id: "fake_id") - - expect(resp[:code]).to eq(200) - end - - it "test_phash_distance_fails_if_not_hexa" do - # test for get_purge_file_cache - - request_obj = double - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - expect { - SUT.phash_distance("f06830ca9f1e3e90", "RANDOM") - }.to raise_error(ArgumentError) - end - - it "test_phash_distance_fails_if_argument_missing" do - - request_obj = double - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - SUT.set_ik_request(request_obj) - - expect { - SUT.phash_distance("f06830ca9f1e3e90", " ") - }.to raise_error(ArgumentError) - end - - it "test_generate_url_with_path" do - # request_obj=ImageKitIo::Request.new(@private_key,@public_key,@url_endpoint) - # url_obj = Url.new(request_obj) - - SUT = ImageKitIo::Client.new(private_key, public_key, url_endpoint) - - options = {path: "/default-image.jpg", - url_endpoint: url_endpoint, - transformation: [{height: 300, width: 400}], - } - url = SUT.url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg") - end - - it "get_authentication_params_test_with_hard_coded_params" do - SUT = ImageKitIo::Client.new('private_key_test', public_key, url_endpoint) - # SUT.set_ik_request(request_obj) - - result=SUT.get_authentication_parameters('your_token',1582269249) - expect('your_token').to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('e71bcd6031016b060d349d212e23e85c791decdd').to eq(result[:signature]) - end - end -end diff --git a/test/imagekit/configuration_test.rb b/test/imagekit/configuration_test.rb deleted file mode 100644 index 74db598b..00000000 --- a/test/imagekit/configuration_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -require_relative './spec_helper' -require 'rspec/autorun' - -RSpec.describe ImageKitIo::Configurable do - let(:configurable_obj) { Class.new.send :include, ImageKitIo::Configurable} - - describe 'Configuration' do - it 'configure with the keys' do - configurable_obj.configure do |config| - config.public_key = 'public_key_123' - end - expect(configurable_obj.config.public_key).to eq('public_key_123') - # test the default service - expect(configurable_obj.config.service).to eq(:carrierwave) - end - - it 'configure without keys' do - expect(configurable_obj.config.service).to eq(:carrierwave) - expect(configurable_obj.config.private_key).to eq(nil) - end - - context 'constants' do - let(:constants) { configurable_obj.constants} - - it 'returns constant class' do - expect(constants).to eq(ImageKitIo::Constant) - end - - it "returns default key's value" do - expect(constants.BASE_URL).to eq("https://api.imagekit.io/v1/files") - end - - it "supports customization" do - constants.TIMESTAMP = '88888' - expect(constants.TIMESTAMP).to eq('88888') - configurable_obj.configure do |config| - config.constants.TIMESTAMP = '5555' - end - expect(configurable_obj.constants.TIMESTAMP).to eq('5555') - end - end - - context 'services' do - it 'configures carrierwave by default' do - expect(configurable_obj.config.service).to eq(:carrierwave) - expect(configurable_obj).to receive(:require_relative).with('../carrierwave/carrierwave') - expect(configurable_obj).to_not receive(:require_relative).with('../active_storage/active_storage') - configurable_obj.configure do |config| - config.private_key = 'private_key_123' - end - end - - it 'supports active_storage configuration' do - expect(configurable_obj).to_not receive(:require_relative).with('../carrierwave/carrierwave') - expect(configurable_obj).to receive(:require_relative).with('../active_storage/active_storage') - configurable_obj.configure do |config| - config.private_key = 'private_key_123' - config.service = :active_storage - end - expect(configurable_obj.config.service).to eq(:active_storage) - end - end - end -end diff --git a/test/imagekit/constant_test.rb b/test/imagekit/constant_test.rb deleted file mode 100644 index dbb0bcc4..00000000 --- a/test/imagekit/constant_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require_relative './spec_helper' -require 'rspec/autorun' - -RSpec.describe ImageKitIo::Constantable do - let(:constantable_class) { ImageKitIo::Constant } - - it 'defines the constants method in included class' do - constantable_obj = Class.new.send(:include, ImageKitIo::Constantable) - expect(constantable_obj).to receive(:constants).and_return(true) - constantable_obj.constants - end - - it "returns the defined constant's value" do - expect(constantable_class).to receive(:method_missing).and_call_original - expect(constantable_class.BASE_URL).to eq("https://api.imagekit.io/v1/files") - end -end diff --git a/test/imagekit/dummy_data/data.rb b/test/imagekit/dummy_data/data.rb deleted file mode 100644 index cf655e2c..00000000 --- a/test/imagekit/dummy_data/data.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -PRIVATE_KEY = "private_xyz" -PUBLIC_KEY = "public_xyz" -URL_ENDPOINT = "imagekit.io/your-imgekit-id/" diff --git a/test/imagekit/dummy_data/file.rb b/test/imagekit/dummy_data/file.rb deleted file mode 100644 index 67be48ed..00000000 --- a/test/imagekit/dummy_data/file.rb +++ /dev/null @@ -1,60 +0,0 @@ -FAILED_GENERIC_RESP = {"message": "Hi There is an error"} -SUCCESS_GENERIC_RESP = {"response": "Success"} -AUTHENTICATION_ERR_MSG = { - "message": "Your account cannot be authenticated.", - "help": "For support kindly contact us at support@imagekit.io .", -} -FAILED_DELETE_RESP = {"message": "Item Not Found"} - -SUCCESS_PURGE_CACHE_MSG = {"request_id": "fake_abc_xyz"} - -SUCCESS_PURGE_CACHE_STATUS_MSG = {"status": "pending"} - -SERVER_ERR_MSG = { - "message": "We have experienced an internal error while processing your request.", - "help": "For support kindly contact us at support@imagekit.io .", -} - -SUCCESS_LIST_RESP_MESSAGE = { - "response": [ - { - "type": "file", - "name": "default-image.jpg", - "fileId": "53dgd6023f28ft7fse488992c", - "tags": None, - "customCoordinates": None, - "isPrivateFile": None, - "url": "https://ik.imagekit.io/fakeid/default-image.jpg", - "thumbnail": "https://ik.imagekit.io/fakeid/tr:n-media_library_thumbnail/default-image.jpg", - "fileType": "image", - "filePath": "/default-image.jpg", - }, - { - "type": "file", - "name": "default-image.jpg", - "fileId": "53dgd6023f28ft7fse488992c", - "tags": None, - "customCoordinates": None, - "isPrivateFile": None, - "url": "https://ik.imagekit.io/fakeid/default-image.jpg", - "thumbnail": "https://ik.imagekit.io/fakeid/tr:n-media_library_thumbnail/default-image.jpg", - "fileType": "image", - "filePath": "/default-image.jpg", - }, - ], -} - -SUCCESS_DETAIL_MSG = { - "response": { - "type": "file", - "name": "default-image.jpg", - "fileId": "53dgd6023f28ft7fse488992c", - "tags": None, - "customCoordinates": None, - "isPrivateFile": None, - "url": "https://ik.imagekit.io/fakeid/default-image.jpg", - "thumbnail": "https://ik.imagekit.io/fakeid/tr:n-media_library_thumbnail/default-image.jpg", - "fileType": "image", - "filePath": "/default-image.jpg", - } -} diff --git a/test/imagekit/dummy_data/sample.jpg b/test/imagekit/dummy_data/sample.jpg deleted file mode 100644 index 1db39e04..00000000 Binary files a/test/imagekit/dummy_data/sample.jpg and /dev/null differ diff --git a/test/imagekit/request_test.rb b/test/imagekit/request_test.rb deleted file mode 100644 index 1fe06a04..00000000 --- a/test/imagekit/request_test.rb +++ /dev/null @@ -1,110 +0,0 @@ -require_relative "./spec_helper" -require "rspec/autorun" - -RSpec.describe ImageKitIo::Request do - let(:subject) { described_class } - - before(:each) do - @private_key = 'private_key_xyz' - @public_key = 'public_key_xyz' - @url_endpoint = 'https://imagekit.io/your-imgekit-id' - @request_obj = subject.new(@private_key, @public_key, @url_endpoint) - stub_request(:get, "https://www.examplenonjson.com").to_return(status: 200, body: "", headers: {content_type: "text/html"}) - stub_request(:get, "https://www.examplejson.com").to_return(body: '{"example_key": "example_value"}', headers: {content_type: "application/json"}) - stub_request(:get, "https://www.examplenotfound.com").to_return(status: 404) - stub_request(:get, "https://www.example204.com").to_return(status: 204) - end - describe 'TestRequest' do - it "test_request_init" do - request_obj = ImageKitIo::Request.new(@private_key, @public_key, @url_endpoint) - - expect(request_obj.private_key).to eq(@private_key) - end - - it "test_create_headers" do - headers = @request_obj.create_headers - expect(headers[:'Accept-Encoding']).to include("application/json") - end - - it "test_auth_headers" do - # test Auth headers working properly - auth_headers = @request_obj.auth_headers - expect(auth_headers[:Authorization]).to include("Basic") - end - - it "test_request_method_non_JSON_fail" do - response = @request_obj.request(:get, "https://www.examplenonjson.com") - expect(response).to have_key(:error) - end - - it "test_request_method_JSON_success" do - response = @request_obj.request(:get, "https://www.examplejson.com") - expect(response).to have_key(:response) - end - - it "test_request_method_404" do - response = @request_obj.request(:get, "https://www.examplenotfound.com") - expect(response).to have_key(:error) - end - - it "test_request_method_204" do - response = @request_obj.request(:get, "https://www.example204.com") - expect(response[:response]).to have_key(:success) - expect(response).to_not have_key(:error) - end - - it 'test_request_method_non_JSON_fail_with_post' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 400, body: '{"message": "Server failed"}', headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, []) - expect(response).to have_key(:error) - end - - it 'test_request_method_JSON_success_with_post' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 200, body: '{"id": "1"}', headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, []) - expect(response).to_not have_key(:error) - expect(response).to have_key(:response) - end - - it 'test_request_method_JSON_success_with_multipart_post' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 200, body: '{"id": "1"}', headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true }) - expect(response).to_not have_key(:error) - expect(response).to have_key(:response) - end - - it 'test_request_method_non_JSON_fail_with_multipart_post' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 400, body: '{"message": "Server failed"}', headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true }) - expect(response).to have_key(:error) - end - - it 'test_request_method_403' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 403, body: "{\"message\":\"Your account cannot be authenticated.\",\"help\":\"For support kindly contact us at support@imagekit.io .\"}", headers: {content_type: 'application/json'}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true }) - expect(response).to have_key(:error) - expect(response[:error]).to eq({"message"=>"Your account cannot be authenticated.", "help"=>"For support kindly contact us at support@imagekit.io ."}) - expect(response[:headers]).to eq({"content-type"=>["application/json"]}) - expect(response[:raw_body]).to eq("{\"message\":\"Your account cannot be authenticated.\",\"help\":\"For support kindly contact us at support@imagekit.io .\"}") - expect(response[:status_code]).to eq("403") - end - - it 'test_response_headers' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 200, body: "{\"message\":\"Success.\"}", headers: {"strict-transport-security"=>["max-age=15552000"], - "x-ik-requestid"=>["39e19bd4-c9c3-4025-453e-a13e6a412aa0"], - "content-type"=>["application/json; charset=utf-8"], - "x-request-id"=>["39e19bd4-c9c3-4025-a043-a13e6a412aa0"]}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: true }) - expect(response[:headers]).to eq({"strict-transport-security"=>["max-age=15552000"], - "x-ik-requestid"=>["39e19bd4-c9c3-4025-453e-a13e6a412aa0"], - "content-type"=>["application/json; charset=utf-8"], - "x-request-id"=>["39e19bd4-c9c3-4025-a043-a13e6a412aa0"]}) - end - - it 'test_response_raw_body' do - stub_request(:post, 'https://www.exampleservererror/upload').to_return(status: 200, body: "{\"message\":\"Success.\"}", headers: {"strict-transport-security"=>["max-age=15552000"], "content-type"=>["application/json; charset=utf-8"]}) - response = @request_obj.request(:post, 'https://www.exampleservererror/upload', nil, { multipart: false }) - expect(response[:raw_body]).to eq("{\"message\":\"Success.\"}") - end - end -end diff --git a/test/imagekit/spec_helper.rb b/test/imagekit/spec_helper.rb deleted file mode 100644 index 433b4162..00000000 --- a/test/imagekit/spec_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'simplecov' -SimpleCov.start 'rails' - -# require 'codecov' -# SimpleCov.formatter = SimpleCov::Formatter::Codecov - -require 'base64' -require 'rspec' -require 'webmock/rspec' -require 'carrierwave' -require 'byebug' -require 'active_storage' -require "rspec/autorun" - -require_relative '../../lib/imagekitio' diff --git a/test/imagekit/url_test.rb b/test/imagekit/url_test.rb deleted file mode 100644 index 88b6051c..00000000 --- a/test/imagekit/url_test.rb +++ /dev/null @@ -1,444 +0,0 @@ -require_relative "./spec_helper" -require "rspec/autorun" - -RSpec.describe ImageKitIo::Url do - let(:request_obj) { ImageKitIo::Request.new(@private_key, @public_key, @url_endpoint) } - let(:url_obj) { ImageKitIo::Url.new(request_obj) } - - before(:each) do - @private_key = 'private_key_xyz' - @public_key = 'public_key_xyz' - @url_endpoint = 'https://imagekit.io/your-imgekit-id' - end - describe "TestGenerateUrl" do - it "test_request_init" do - expect(request_obj.private_key).to eq(@private_key) - end - - it "test_generate_url_without_transformations" do - - options = { path: "/default-image.jpg", - url_endpoint: @url_endpoint, - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/default-image.jpg") - end - - it "test_generate_url_with_path" do - - options = { path: "/default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_with_path_with_special_characters" do - - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_without_slash" do - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_with_path_without_slash_with_special_characters" do - - options = { path: "γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_with_override_url_endpoint_without_slash" do - options = { path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_override_imagekit_id", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/your_override_imagekit_id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_with_override_url_endpoint_without_slash_with_special_characters" do - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: "https://ik.imagekit.io/your_override_imagekit_id", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/your_override_imagekit_id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_with_override_url_endpoint_with_slash" do - - options = { path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_override_imagekit_id/", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/your_override_imagekit_id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_with_override_url_endpoint_with_slash_with_special_characters" do - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: "https://ik.imagekit.io/your_override_imagekit_id/", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/your_override_imagekit_id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_with_override_url_endpoint_with_special_characters" do - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: "https://www.Fjällräven.com/your_override_imagekit_id/", - transformation: [{ height: 300, width: 400 }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://www.Fjällräven.com/your_override_imagekit_id/tr:h-300,w-400/γειασας/Fjällräven_KnSJwp87u6q.png") - end - - it "test_generate_url_with_new_transformation_parameters" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }, { new_params: 100 }], - } - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400:new_params-100/default-image.jpg") - end - - it "test_generate_url_should_have_ik_sdk_version" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 },] - } - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg") - end - - it "test_generate_url_should_have_transformation_parameters" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ - height: 300, - width: 400, - aspect_ratio: '4-3', - quality: 40, - crop: 'force', - crop_mode: '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, - color_profile: true, - default_image: "/folder/file.jpg", - dpr: 3, - effect_sharpen: 10, - effect_usm: "2-2-0.8-0.024", - effect_contrast: true, - effect_gray: true, - effect_shadow: 'bl-15_st-40_x-10_y-N5', - effect_gradient: 'from-red_to-white', - original: true, - raw: 'w-200,h-200' - },] - } - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/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,w-200,h-200/default-image.jpg") - end - - it "test_generate_url_with_chained_transformation" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }, { rotation: 90 }], - } - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400:rt-90/default-image.jpg") - end - - it "test_generate_url_transformation_parameters_setted_to_query" do - - options = { path: "default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - transformation_position: "query", - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/default-image.jpg?tr=h-300,w-400") - end - - it "test_generate_url_with_special_characters_transformation_parameters_setted_to_query" do - - options = { path: "/γειασας/Fjällräven_KnSJwp87u6q.png", - url_endpoint: @url_endpoint, - transformation: [{ height: 300, width: 400 }], - transformation_position: "query", - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/γειασας/Fjällräven_KnSJwp87u6q.png?tr=h-300,w-400") - end - - it "test_generate_url_with_query_parameters" do - - options = { path: "/default-image.jpg", - query_parameters: { "v": "123", "blank_parameter": "" }, - transformation: [{ height: 300, width: 400 }] - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg?v=123&blank_parameter") - end - - it "test_generate_url_with_query_parameters_with_special_characters" do - - options = { path: "/default-image.jpg", - query_parameters: { "γειασας": "γειασας" }, - transformation: [{ height: 300, width: 400 }] - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/default-image.jpg?γειασας=γειασας") - end - - it 'test_generate_url_with_absolute_path' do - options = { path: "https://example.com/external-image.jpg", - query_parameters: { "γειασας": "γειασας" }, - transformation: [{ height: 300, width: 400 }] - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/https%3A%2F%2Fexample.com%2Fexternal-image.jpg?γειασας=γειασας") - end - - it "test_generate_url_with_src_checking_query_param_added" do - - options = { src: "https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg?another=abc&xyz=888", - transformation: [{ height: "300", width: "400", }], - query_parameters: { "v": "123" }, - } - - url = url_obj.generate_url(options) - expect(url).to eq("https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg?another=abc&xyz=888&v=123&tr=h-300,w-400") - end - - it "test_generate_url_with_path_checking_query_param_added" do - - options = { path: "/test_YhNhoRxWt.jpg?another=abc&xyz=888", - transformation: [{ height: "300", width: "400", }], - query_parameters: { "v": "123" }, - } - - url = url_obj.generate_url(options) - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/test_YhNhoRxWt.jpg?another=abc&xyz=888&v=123") - end - - it "test_generate_url_with_src" do - # Test url generation with src param - - options = { src: "https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg", - transformation: [{ height: "300", - width: "400", - format: "jpg", - progressive: "true", - effect_sharpen: "-", - effect_contrast: "1", }, - { rotation: 90 },], - transformation_position: "query" } - - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg?tr=h-300,w-400,f-jpg,pr-true,e-sharpen,e-contrast-1:rt-90") - - end - - it "test_generate_url_with_src_with_special_characters" do - # Test url generation with src param - - options = { src: "https://www.Fjällräve.com/γειασας/Fjällräven_KnSJwp87u6q.png", - transformation: [{ height: "300", - width: "400", - format: "jpg", - progressive: "true", - effect_sharpen: "-", - effect_contrast: "1", }, - { rotation: 90 },], - transformation_position: "query" } - - url = url_obj.generate_url(options) - - expect(url).to eq("https://www.Fjällräve.com/γειασας/Fjällräven_KnSJwp87u6q.png?tr=h-300,w-400,f-jpg,pr-true,e-sharpen,e-contrast-1:rt-90") - - end - - it "test_generate_url_with_src_and_query_parameters_is_path" do - - options = { src: "https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg", - transformation: [{ height: "300", - width: "400", - format: "jpg", - progressive: "true", - effect_sharpen: "-", - effect_contrast: "1", }, - { rotation: 90 },], - transformation_position: "path" } - - url = url_obj.generate_url(options) - - expect(url).to eq("https://ik.imagekit.io/ldt7znpgpjs/test_YhNhoRxWt.jpg?tr=h-300,w-400,f-jpg,pr-true,e-sharpen,e-contrast-1:rt-90") - end - - it "test_generate_url_with_path_and_signed" do - - options = { path: "/default-image.jpg", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ height: "300", width: "400" }], - signed: true, } - - url = url_obj.generate_url(options) - - expect(url).to include("https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/default-image.jpg?ik-s=") - end - - it "test_generate_url_with_path_and_signed_with_special_characters" do - - options = { path: "/Fjällräven_KnSJwp87u6q.png", - url_endpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/", - transformation: [{ height: "300", width: "400" }], - signed: true, } - - url = url_obj.generate_url(options) - - expect(url).to include("https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400/Fjällräven_KnSJwp87u6q.png?ik-s=") - end - - it 'test_generate_url_with_absolute_path_and_signed' do - allow(url_obj).to receive(:get_signature_timestamp).with(5) { 100 } - options = { path: "https://example.com/external-image.jpg", - query_parameters: { "γειασας": "γειασας" }, - transformation: [{ height: 300, width: 400 }], - signed: true, - expire_seconds: 5 - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,w-400/https%3A%2F%2Fexample.com%2Fexternal-image.jpg?γειασας=γειασας&ik-s=44c1295edb1dbc1d59216fba8994b4d3a36c61e2&ik-t=100") - end - - it "test_url_with_invalid_args_returns_as_it_is" do - - options = { path: "/default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: "300", fake_field: "400" }], - } - url = url_obj.generate_url(options) - - expect(url).to eq("https://imagekit.io/your-imgekit-id/tr:h-300,fake_field-400/default-image.jpg") - end - - it "test_url_without_path_and_src_should_return_empty" do - - options = { url_endpoint: @url_endpoint, - transformation: { height: "300", width: 400 }, - signed: true, - } - url = url_obj.generate_url(options) - expect(url.to_s).to eq("") - end - - it "test_url_with_invalid_trans_pos" do - - options = { path: "/default-image.jpg", - url_endpoint: @url_endpoint, - transformation: [{ height: "300", fake: "400" }], - transformation_position: "fake", - signed: true, } - - expect { url_obj.generate_url(options) }.to raise_error(ArgumentError) - - end - - it "test_url_with_signed_without_seconds" do - request_obj = ImageKitIo::Request.new('private_key_test', 'public_key_test', 'https://test-domain.com/test-endpoint') - url_obj = ImageKitIo::Url.new(request_obj) - - options = { path: "/test-signed-url.png", - transformation: [{ width: 100 }], - signed: true, } - url = url_obj.generate_url(options) - - expect(url).to include("https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png?ik-s=") - end - - it "test_url_with_signed_with_seconds" do - request_obj = ImageKitIo::Request.new('private_key_test', 'public_key_test', 'https://test-domain.com/test-endpoint') - url_obj = ImageKitIo::Url.new(request_obj) - - options = { path: "/test-signed-url.png", - transformation: [{ width: 100 }], - expire_seconds: 100, - signed: true } - url = url_obj.generate_url(options) - - expect(url).to include("ik-t") - end - - it "test_get_signature_with_100_expire_seconds" do - - url = "https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png" - signature = url_obj.get_signature("private_key_test", url, "https://test-domain.com/test-endpoint/", 100) - expect(signature).to eq("5e5037a31a7121cbe2964e220b4338cc6e1ba66d") - end - - it "test_get_signature_expect_without_expire_seconds" do - - url = "https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png" - signature = url_obj.get_signature("private_key_test", url, "https://test-domain.com/test-endpoint/", 0) - - expect(signature).to eq("41b3075c40bc84147eb71b8b49ae7fbf349d0f00") - end - - it "test_get_signature_expect_without_expire_seconds_without_slash" do - - url = "https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png" - signature = url_obj.get_signature("private_key_test", url, "https://test-domain.com/test-endpoint", 0) - - expect(signature).to eq("41b3075c40bc84147eb71b8b49ae7fbf349d0f00") - end - - end -end diff --git a/test/imagekit/utils/calculation_test.rb b/test/imagekit/utils/calculation_test.rb deleted file mode 100644 index 239a53a9..00000000 --- a/test/imagekit/utils/calculation_test.rb +++ /dev/null @@ -1,68 +0,0 @@ -require_relative '../spec_helper' -require "rspec/autorun" - -RSpec.describe ImageKitIo::Utils::Calculation do - let(:subject) { described_class } - - it "is_valid_hex_with_valid_hex" do - result = subject.is_valid_hex('f06830ca9f1e3e90') - expect(true).to eq(result) - end - - it "is_valid_hex_with_invalid_hex" do - result = subject.is_valid_hex('f06830ca9f1e3e90$') - expect(false).to eq(result) - end - - it "hamming_distance_test_expect_0" do - result = subject.hamming_distance('f06830ca9f1e3e90', 'f06830ca9f1e3e90') - expect(0).to eq(result) - end - - it "hamming_distance_test_expect_17" do - result = subject.hamming_distance('2d5ad3936d2e015b', '2d6ed293db36a4fb') - expect(17).to eq(result) - end - - it "hamming_distance_test_expect_37" do - result = subject.hamming_distance('a4a65595ac94518b', '7838873e791f8400') - expect(37).to eq(result) - end - - it "get_authenticated_params_test_with_nil_expire_nill_token" do - allow(OpenSSL::HMAC).to receive(:hexdigest).and_return('my_signature') - result = subject.get_authenticated_params(nil, nil, 'private_key') - expect(nil).not_to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('my_signature').to eq(result[:signature]) - end - - it "get_authenticated_params_test_with_nil_expire" do - allow(OpenSSL::HMAC).to receive(:hexdigest).and_return('my_signature') - result = subject.get_authenticated_params('my_token', nil, 'private_key') - expect('my_token').to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('my_signature').to eq(result[:signature]) - end - - it "get_authenticated_params_test_with_hard_coded_params" do - result = subject.get_authenticated_params('your_token', 1582269249, 'private_key_test') - expect('your_token').to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('e71bcd6031016b060d349d212e23e85c791decdd').to eq(result[:signature]) - end - - it "get_authenticated_params_test_with_nil_token" do - allow(OpenSSL::HMAC).to receive(:hexdigest).and_return('my_signature') - result = subject.get_authenticated_params(nil, nil, 'private_key') - expect(nil).not_to eq(result[:token]) - expect(nil).not_to eq(result[:expire]) - expect('my_signature').to eq(result[:signature]) - end - - it "get_authenticated_params_test_with_nil_private_key" do - allow(OpenSSL::HMAC).to receive(:hexdigest).and_return('my_signature') - result = subject.get_authenticated_params('your_token', 1582269249, nil) - expect(result).to eq(nil) - end -end diff --git a/test/imagekit/utils/formatter_test.rb b/test/imagekit/utils/formatter_test.rb deleted file mode 100644 index 13a470c5..00000000 --- a/test/imagekit/utils/formatter_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../spec_helper' -require "rspec/autorun" - -RSpec.describe ImageKitIo::Utils::Formatter do - let(:subject) { described_class } - - it "snake_to_camel_test" do - result=subject.snake_to_camel('my_snake_to_camel') - expect('mySnakeToCamel').to eq(result) - end - - it "camel_to_snake_test" do - result=subject.camel_to_snake('mySnakeToCamel') - expect('my_snake_to_camel').to eq(result) - end - - it "request_formatter_test" do - result =subject.request_formatter({'my_snake' => 'test'}) - expect('mySnake').to eq(result.keys.first) - end -end diff --git a/test/imagekitio/client_test.rb b/test/imagekitio/client_test.rb new file mode 100644 index 00000000..617cd7ed --- /dev/null +++ b/test/imagekitio/client_test.rb @@ -0,0 +1,405 @@ +# frozen_string_literal: true + +require_relative "test_helper" + +class ImagekitioTest < Minitest::Test + extend Minitest::Serial + include WebMock::API + + def before_all + super + WebMock.enable! + end + + def setup + super + Thread.current.thread_variable_set(:mock_sleep, []) + end + + def teardown + Thread.current.thread_variable_set(:mock_sleep, nil) + WebMock.reset! + super + end + + def after_all + WebMock.disable! + super + end + + def test_raises_on_missing_non_nullable_opts + e = assert_raises(ArgumentError) do + Imagekitio::Client.new + end + assert_match(/is required/, e.message) + end + + def test_client_default_request_default_retry_attempts + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + end + + assert_requested(:any, /./, times: 3) + end + + def test_client_given_request_default_retry_attempts + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 3 + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + end + + assert_requested(:any, /./, times: 4) + end + + def test_client_default_request_given_retry_attempts + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {max_retries: 3} + ) + end + + assert_requested(:any, /./, times: 4) + end + + def test_client_given_request_given_retry_attempts + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 3 + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {max_retries: 4} + ) + end + + assert_requested(:any, /./, times: 5) + end + + def test_client_retry_after_seconds + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 500, + headers: {"retry-after" => "1.3"}, + body: {} + ) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 1 + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + end + + assert_requested(:any, /./, times: 2) + assert_equal(1.3, Thread.current.thread_variable_get(:mock_sleep).last) + end + + def test_client_retry_after_date + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 500, + headers: {"retry-after" => (Time.now + 10).httpdate}, + body: {} + ) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 1 + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + Thread.current.thread_variable_set(:time_now, Time.now) + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + Thread.current.thread_variable_set(:time_now, nil) + end + + assert_requested(:any, /./, times: 2) + assert_in_delta(10, Thread.current.thread_variable_get(:mock_sleep).last, 1.0) + end + + def test_client_retry_after_ms + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 500, + headers: {"retry-after-ms" => "1300"}, + body: {} + ) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password", + max_retries: 1 + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + end + + assert_requested(:any, /./, times: 2) + assert_equal(1.3, Thread.current.thread_variable_get(:mock_sleep).last) + end + + def test_retry_count_header + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + end + + 3.times do + assert_requested(:any, /./, headers: {"x-stainless-retry-count" => _1}) + end + end + + def test_omit_retry_count_header + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {"x-stainless-retry-count" => nil}} + ) + end + + assert_requested(:any, /./, times: 3) do + refute_includes(_1.headers.keys.map(&:downcase), "x-stainless-retry-count") + end + end + + def test_overwrite_retry_count_header + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 500, body: {}) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekitio::Errors::InternalServerError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {"x-stainless-retry-count" => "42"}} + ) + end + + assert_requested(:any, /./, headers: {"x-stainless-retry-count" => "42"}, times: 3) + end + + def test_client_redirect_307 + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 307, + headers: {"location" => "/redirected"}, + body: {} + ) + stub_request(:any, "http://localhost/redirected").to_return( + status: 307, + headers: {"location" => "/redirected"} + ) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekitio::Errors::APIConnectionError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {}} + ) + end + + recorded, = WebMock::RequestRegistry.instance.requested_signatures.hash.first + + assert_requested(:any, "http://localhost/redirected", times: Imagekitio::Client::MAX_REDIRECTS) do + assert_equal(recorded.method, _1.method) + assert_equal(recorded.body, _1.body) + assert_equal( + recorded.headers.transform_keys(&:downcase).fetch("content-type"), + _1.headers.transform_keys(&:downcase).fetch("content-type") + ) + end + end + + def test_client_redirect_303 + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 303, + headers: {"location" => "/redirected"}, + body: {} + ) + stub_request(:get, "http://localhost/redirected").to_return( + status: 303, + headers: {"location" => "/redirected"} + ) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekitio::Errors::APIConnectionError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {}} + ) + end + + assert_requested(:get, "http://localhost/redirected", times: Imagekitio::Client::MAX_REDIRECTS) do + headers = _1.headers.keys.map(&:downcase) + refute_includes(headers, "content-type") + assert_nil(_1.body) + end + end + + def test_client_redirect_auth_keep_same_origin + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 307, + headers: {"location" => "/redirected"}, + body: {} + ) + stub_request(:any, "http://localhost/redirected").to_return( + status: 307, + headers: {"location" => "/redirected"} + ) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekitio::Errors::APIConnectionError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {"authorization" => "Bearer xyz"}} + ) + end + + recorded, = WebMock::RequestRegistry.instance.requested_signatures.hash.first + auth_header = recorded.headers.transform_keys(&:downcase).fetch("authorization") + + assert_equal("Bearer xyz", auth_header) + assert_requested(:any, "http://localhost/redirected", times: Imagekitio::Client::MAX_REDIRECTS) do + auth_header = _1.headers.transform_keys(&:downcase).fetch("authorization") + assert_equal("Bearer xyz", auth_header) + end + end + + def test_client_redirect_auth_strip_cross_origin + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json( + status: 307, + headers: {"location" => "https://example.com/redirected"}, + body: {} + ) + stub_request(:any, "https://example.com/redirected").to_return( + status: 307, + headers: {"location" => "https://example.com/redirected"} + ) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + assert_raises(Imagekitio::Errors::APIConnectionError) do + image_kit.files.upload( + file: Pathname(__FILE__), + file_name: "fileName", + request_options: {extra_headers: {"authorization" => "Bearer xyz"}} + ) + end + + assert_requested(:any, "https://example.com/redirected", times: Imagekitio::Client::MAX_REDIRECTS) do + headers = _1.headers.keys.map(&:downcase) + refute_includes(headers, "authorization") + end + end + + def test_default_headers + stub_request(:post, "http://localhost/api/v1/files/upload").to_return_json(status: 200, body: {}) + + image_kit = + Imagekitio::Client.new( + base_url: "http://localhost", + private_key: "My Private Key", + password: "My Password" + ) + + image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + + assert_requested(:any, /./) do |req| + headers = req.headers.transform_keys(&:downcase).fetch_values("accept", "content-type") + headers.each { refute_empty(_1) } + end + end +end diff --git a/test/imagekitio/custom-tests/helper_authentication_test.rb b/test/imagekitio/custom-tests/helper_authentication_test.rb new file mode 100644 index 00000000..7acb32fe --- /dev/null +++ b/test/imagekitio/custom-tests/helper_authentication_test.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class HelperAuthenticationTest < Minitest::Test + def test_should_return_correct_authentication_parameters_with_provided_token_and_expire + private_key = "private_key_test" + client = Imagekitio::Client.new(private_key: private_key) + + token = "your_token" + expire = 1_582_269_249 + + params = client.helper.get_authentication_parameters(token: token, expire: expire) + + # Expected exact match with Node.js output + expected_signature = "e71bcd6031016b060d349d212e23e85c791decdd" + + assert_equal(token, params[:token]) + assert_equal(expire, params[:expire]) + assert_equal(expected_signature, params[:signature]) + end + + def test_should_return_authentication_parameters_with_required_properties_when_no_params_provided + private_key = "private_key_test" + client = Imagekitio::Client.new(private_key: private_key) + + params = client.helper.get_authentication_parameters + + # Check that all required properties exist + assert(params.key?(:token), "Expected token parameter") + assert(params.key?(:expire), "Expected expire parameter") + assert(params.key?(:signature), "Expected signature parameter") + + # Token should be a 32-character hex string + token = params[:token] + assert_instance_of(String, token) + assert_match(/^[0-9a-f]{32}$/, token, "Expected token to be 32-character hex format") + + # Expire should be a number greater than current time + expire = params[:expire] + assert_instance_of(Integer, expire) + current_time = Time.now.to_i + assert(expire > current_time, "Expected expire #{expire} to be greater than current time #{current_time}") + + # Signature should be a hex string (40 characters for HMAC-SHA1) + signature = params[:signature] + assert_instance_of(String, signature) + assert_match(/^[a-f0-9]{40}$/, signature, "Expected signature to be 40 character hex string") + end + + def test_should_handle_edge_case_with_expire_time_0 + private_key = "private_key_test" + client = Imagekitio::Client.new(private_key: private_key) + + token = "test-token" + expire = 0 + + params = client.helper.get_authentication_parameters(token: token, expire: expire) + + assert_equal(token, params[:token]) + + # When expire is 0 (falsy), it should use default expire time (30 minutes from now) + expire_result = params[:expire] + assert_instance_of(Integer, expire_result) + expected_expire = Time.now.to_i + (60 * 30) + # Allow a 10 second tolerance for test execution time + assert( + expire_result.between?(expected_expire - 10, expected_expire + 10), + "Expected expire to be close to #{expected_expire} (30 minutes from now), got #{expire_result}" + ) + + # Signature should be a hex string (40 characters for HMAC-SHA1) + signature = params[:signature] + assert_instance_of(String, signature) + assert_match(/^[a-f0-9]{40}$/, signature, "Expected signature to be 40 character hex string") + end + + def test_should_handle_empty_string_token + private_key = "private_key_test" + client = Imagekitio::Client.new(private_key: private_key) + + token = "" # Empty string is falsy + expire = 1_582_269_249 + + params = client.helper.get_authentication_parameters(token: token, expire: expire) + + # Since empty string is falsy, it should generate a token + token_result = params[:token] + assert_instance_of(String, token_result) + refute_empty(token_result, "Expected token to be generated when empty string is provided") + assert_match(/^[0-9a-f]{32}$/, token_result, "Expected generated token to be 32-character hex format") + + assert_equal(expire, params[:expire]) + + # Signature should be a hex string (40 characters for HMAC-SHA1) + signature = params[:signature] + assert_instance_of(String, signature) + assert_match(/^[a-f0-9]{40}$/, signature, "Expected signature to be 40 character hex string") + end + + def test_should_raise_error_when_private_key_is_not_provided + # Test with empty private key + assert_raises(ArgumentError, "Expected error when private key is empty") do + client = Imagekitio::Client.new(private_key: "") + client.helper.get_authentication_parameters(token: "test", expire: 123) + end + end + + def test_should_raise_error_when_private_key_is_nil + # Test with nil private key + assert_raises(ArgumentError, "Expected error when private key is nil") do + client = Imagekitio::Client.new(private_key: nil) + client.helper.get_authentication_parameters(token: "test", expire: 123) + end + end +end diff --git a/test/imagekitio/custom-tests/responsive_image_attributes_test.rb b/test/imagekitio/custom-tests/responsive_image_attributes_test.rb new file mode 100644 index 00000000..48fb0599 --- /dev/null +++ b/test/imagekitio/custom-tests/responsive_image_attributes_test.rb @@ -0,0 +1,306 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class ResponsiveImageAttributesTest < Minitest::Test + def setup + @client = Imagekitio::Client.new( + private_key: "private_key_test", + password: "test_password" + ) + end + + def test_bare_minimum_input + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo" + ) + + # Expected object based on default device_breakpoints and image_breakpoints + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w", + sizes: "100vw", + width: nil + } + + assert_equal(expected, result.to_h) + end + + def test_sizes_provided_100vw + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + sizes: "100vw" + ) + + # With a sizes value of "100vw", the function should use the same breakpoints as in the bare minimum case + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w", + sizes: "100vw", + width: nil + } + + assert_equal(expected, result.to_h) + end + + def test_width_only_dpr_strategy + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + width: 400 + ) + + # When width is provided without sizes attribute, the DPR strategy should be used + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 2x", + sizes: nil, + width: 400.0 + } + + assert_equal(expected, result.to_h) + end + + def test_custom_breakpoints + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + device_breakpoints: [200, 400, 800], + image_breakpoints: [100] + ) + + # For custom breakpoints, the breakpoints will be derived from the provided arrays + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=w-800,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=w-200,c-at_max 200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-400,c-at_max 400w, https://ik.imagekit.io/demo/sample.jpg?tr=w-800,c-at_max 800w", + sizes: "100vw", + width: nil + } + + assert_equal(expected, result.to_h) + end + + def test_preserves_caller_transformations + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + width: 500, + transformation: [Imagekitio::Models::Transformation.new(height: 300.0)] + ) + + # The provided transformation should be preserved in the output + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:w-1080,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=h-300:w-1080,c-at_max 2x", + sizes: nil, + width: 500.0 + } + + assert_equal(expected, result.to_h) + end + + def test_both_sizes_and_width_passed + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + sizes: "50vw", + width: 600 + ) + + # Both sizes and width are provided, so the function should apply the sizes attribute while using width for DPR strategy + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=w-384,c-at_max 384w, https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w", + sizes: "50vw", + width: 600.0 + } + + assert_equal(expected, result.to_h) + end + + def test_multiple_transformations + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + width: 450, + transformation: [ + Imagekitio::Models::Transformation.new(height: 300.0), + Imagekitio::Models::Transformation.new(ai_remove_background: true) + ] + ) + + # Multiple caller transformations should be combined appropriately + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-1080,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-1080,c-at_max 2x", + sizes: nil, + width: 450.0 + } + + assert_equal(expected, result.to_h) + end + + def test_sizes_causes_breakpoint_pruning_33vw_path + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + sizes: "(min-width: 800px) 33vw, 100vw" + ) + + # When specified with a sizes attribute that prunes breakpoints, the output should reflect the pruned values + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=w-256,c-at_max 256w, https://ik.imagekit.io/demo/sample.jpg?tr=w-384,c-at_max 384w, https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w", + sizes: "(min-width: 800px) 33vw, 100vw", + width: nil + } + + assert_equal(expected, result.to_h) + end + + def test_using_query_parameters_and_transformation_position + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + width: 450, + transformation: [ + Imagekitio::Models::Transformation.new(height: 300), + Imagekitio::Models::Transformation.new(ai_remove_background: true) + ], + query_parameters: {key: "value"}, + transformation_position: :path + ) + + # The function should respect the transformation position and query parameters + expected = { + src: "https://ik.imagekit.io/demo/tr:h-300:e-bgremove:w-1080,c-at_max/sample.jpg?key=value", + src_set: "https://ik.imagekit.io/demo/tr:h-300:e-bgremove:w-640,c-at_max/sample.jpg?key=value 1x, https://ik.imagekit.io/demo/tr:h-300:e-bgremove:w-1080,c-at_max/sample.jpg?key=value 2x", + sizes: nil, + width: 450.0 + } + + assert_equal(expected, result.to_h) + end + + # Hash-based API test - verify that plain hashes work for responsive image attributes + def test_should_work_with_plain_hashes_for_responsive_image_attributes + # Using plain hashes instead of model objects + result = @client.helper.get_responsive_image_attributes( + { + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + width: 450, + transformation: [ + { + height: 300 + }, + { + ai_remove_background: true + } + ] + } + ) + + # Multiple caller transformations should be combined appropriately + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-1080,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-1080,c-at_max 2x", + sizes: nil, + width: 450 + } + + assert_equal(expected, result.to_h) + end + + # Test to verify that srcset uses integer descriptors (640w) not float (640.0w) + # This tests both model object and hash approaches + def test_should_use_integer_descriptors_in_srcset_with_model_object + # Using GetImageAttributesOptions model with Float array (as defined in schema) + result = @client.helper.get_responsive_image_attributes( + Imagekitio::Models::GetImageAttributesOptions.new( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + device_breakpoints: [320.0, 640.0, 1280.0], # SDK converts to floats + image_breakpoints: [] + ) + ) + + src_set = result.src_set + + # Should have integer descriptors like "320w", NOT "320.0w" + assert_includes(src_set, "320w") + assert_includes(src_set, "640w") + assert_includes(src_set, "1280w") + + # Should NOT have float descriptors + refute_includes(src_set, "320.0w") + refute_includes(src_set, "640.0w") + refute_includes(src_set, "1280.0w") + end + + def test_should_use_integer_descriptors_in_srcset_with_hash + # Using plain hash with integer breakpoints + result = @client.helper.get_responsive_image_attributes( + { + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + device_breakpoints: [320, 640, 1280], + image_breakpoints: [] + } + ) + + src_set = result.src_set + + # Should have integer descriptors like "320w", NOT "320.0w" + assert_includes(src_set, "320w") + assert_includes(src_set, "640w") + assert_includes(src_set, "1280w") + + # Should NOT have float descriptors + refute_includes(src_set, "320.0w") + refute_includes(src_set, "640.0w") + refute_includes(src_set, "1280.0w") + end + + def test_fallback_when_no_usable_vw_tokens + result = @client.helper.get_responsive_image_attributes( + src: "sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + sizes: "100%" + ) + + # When sizes has no vw tokens, all breakpoints should be used + expected = { + src: "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max", + src_set: "https://ik.imagekit.io/demo/sample.jpg?tr=w-16,c-at_max 16w, https://ik.imagekit.io/demo/sample.jpg?tr=w-32,c-at_max 32w, https://ik.imagekit.io/demo/sample.jpg?tr=w-48,c-at_max 48w, https://ik.imagekit.io/demo/sample.jpg?tr=w-64,c-at_max 64w, https://ik.imagekit.io/demo/sample.jpg?tr=w-96,c-at_max 96w, https://ik.imagekit.io/demo/sample.jpg?tr=w-128,c-at_max 128w, https://ik.imagekit.io/demo/sample.jpg?tr=w-256,c-at_max 256w, https://ik.imagekit.io/demo/sample.jpg?tr=w-384,c-at_max 384w, https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w", + sizes: "100%", + width: nil + } + + assert_equal(expected, result.to_h) + end + + # Test to verify signed URLs work correctly in responsive image attributes + def test_should_generate_signed_urls_in_srcset + result = @client.helper.get_responsive_image_attributes( + { + src: "sdk-testing-files/future-search.png", + url_endpoint: "https://ik.imagekit.io/demo", + device_breakpoints: [640, 1280], + image_breakpoints: [], + signed: true + } + ) + + expected = { + src: "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?tr=w-1280,c-at_max&ik-s=cce0258e8b27bee5d4b642bcee996c5fac11a907", + src_set: "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?tr=w-640,c-at_max&ik-s=d326eadc97c62b0896dc1bb872355a47c8b71943 640w, https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?tr=w-1280,c-at_max&ik-s=cce0258e8b27bee5d4b642bcee996c5fac11a907 1280w", + sizes: "100vw", + width: nil + } + + assert_equal(expected, result.to_h) + end +end diff --git a/test/imagekitio/custom-tests/url-generation/advanced_url_generation_test.rb b/test/imagekitio/custom-tests/url-generation/advanced_url_generation_test.rb new file mode 100644 index 00000000..8cd61352 --- /dev/null +++ b/test/imagekitio/custom-tests/url-generation/advanced_url_generation_test.rb @@ -0,0 +1,478 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class AdvancedURLGenerationTest < Minitest::Test + def setup + @client = Imagekitio::Client.new( + private_key: "My Private API Key" + ) + end + + # AI Transformation Tests + def test_should_generate_the_correct_url_for_ai_background_removal_when_set_to_true + transformation = [ + Imagekitio::Models::Transformation.new( + ai_remove_background: true + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_for_external_ai_background_removal_when_set_to_true + transformation = [ + Imagekitio::Models::Transformation.new( + ai_remove_background_external: true + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-removedotbg" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_when_ai_drop_shadow_transformation_is_set_to_true + transformation = [ + Imagekitio::Models::Transformation.new( + ai_drop_shadow: true + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_when_gradient_transformation_is_set_to_true + transformation = [ + Imagekitio::Models::Transformation.new( + gradient: true + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient" + assert_equal(expected, url) + end + + def test_should_not_apply_ai_background_removal_when_value_is_not_true + transformation = [ + Imagekitio::Models::Transformation.new + # AIRemoveBackground: false, # This would be the case for false values + + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg" + assert_equal(expected, url) + end + + def test_should_not_apply_external_ai_background_removal_when_value_is_not_true + transformation = [ + Imagekitio::Models::Transformation.new + # AIRemoveBackgroundExternal: false, # This would be the case for false values + + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg" + assert_equal(expected, url) + end + + def test_should_handle_ai_transformations_with_parameters + transformation = [ + Imagekitio::Models::Transformation.new( + ai_drop_shadow: "custom-shadow-params" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow-custom-shadow-params" + assert_equal(expected, url) + end + + def test_should_handle_gradient_with_parameters + transformation = [ + Imagekitio::Models::Transformation.new( + gradient: "ld-top_from-green_to-00FF0010_sp-1" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient-ld-top_from-green_to-00FF0010_sp-1" + assert_equal(expected, url) + end + + def test_should_combine_ai_transformations_with_regular_transformations + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0, + height: 200.0, + ai_remove_background: true + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,e-bgremove" + assert_equal(expected, url) + end + + def test_should_handle_multiple_ai_transformations + transformation = [ + Imagekitio::Models::Transformation.new( + ai_remove_background: true, + ai_drop_shadow: true + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove,e-dropshadow" + assert_equal(expected, url) + end + + # Parameter-specific tests + def test_should_generate_the_correct_url_for_width_transformation_when_provided_with_a_number_value + transformation = [ + Imagekitio::Models::Transformation.new( + width: 400.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-400" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_for_height_transformation_when_provided_with_a_string_value + transformation = [ + Imagekitio::Models::Transformation.new( + height: "300" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=h-300" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_for_aspect_ratio_transformation_when_provided_with_colon_format + transformation = [ + Imagekitio::Models::Transformation.new( + aspect_ratio: "4:3" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=ar-4:3" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_for_quality_transformation_when_provided_with_a_number_value + transformation = [ + Imagekitio::Models::Transformation.new( + quality: 80.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=q-80" + assert_equal(expected, url) + end + + # Additional parameter validation tests from Node.js SDK + def test_should_skip_transformation_parameters_that_are_undefined_or_empty + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0 + # Quality is not set - should be ignored + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300" + assert_equal(expected, url) + end + + def test_should_handle_boolean_transformation_values + transformation = [ + Imagekitio::Models::Transformation.new( + trim: true + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=t-true" + assert_equal(expected, url) + end + + def test_should_handle_transformation_parameter_with_empty_string_value + transformation = [ + Imagekitio::Models::Transformation.new( + default_image: "" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg" + assert_equal(expected, url) + end + + def test_should_handle_complex_transformation_combinations + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0, + height: 200.0, + quality: 85.0, + border: "5_FF0000" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,q-85,b-5_FF0000" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_with_many_transformations_including_video_and_ai_transforms + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0, + aspect_ratio: "4-3", + quality: 40.0, + crop: :force, + crop_mode: :extract, + focus: "left", + format_: :jpeg, + radius: 50.0, + background: "A94D34", + border: "5-A94D34", + rotation: 90.0, + blur: 10.0, + named: "some_name", + progressive: true, + lossless: true, + trim: 5.0, + metadata: true, + color_profile: true, + default_image: "/folder/file.jpg/", + dpr: 3.0, + x: 10.0, + y_: 20.0, + x_center: 30.0, + y_center: 40.0, + flip: :h, + opacity: 0.8, + zoom: 2.0, + # Video transformations + video_codec: :h264, + audio_codec: :aac, + start_offset: 5.0, + end_offset: 15.0, + duration: 10.0, + streaming_resolutions: [:"1440", :"1080"], + # AI transformations + grayscale: true, + ai_upscale: true, + ai_retouch: true, + ai_variation: true, + ai_drop_shadow: true, + ai_change_background: "prompt-car", + ai_edit: "prompt-make it vintage", + ai_remove_background: true, + contrast_stretch: true, + shadow: "bl-15_st-40_x-10_y-N5", + sharpen: 10.0, + unsharp_mask: "2-2-0.8-0.024", + gradient: "from-red_to-white", + original: true, + page: "2_4", + raw: "h-200,w-300,l-image,i-logo.png,l-end" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?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,x-10,y-20,xc-30,yc-40,fl-h,o-0.8,z-2,vc-h264,ac-aac,so-5,eo-15,du-10,sr-1440_1080,e-grayscale,e-upscale,e-retouch,e-genvar,e-dropshadow,e-changebg-prompt-car,e-edit-prompt-make it vintage,e-bgremove,e-contrast,e-shadow-bl-15_st-40_x-10_y-N5,e-sharpen-10,e-usm-2-2-0.8-0.024,e-gradient-from-red_to-white,orig-true,pg-2_4,h-200,w-300,l-image,i-logo.png,l-end" + assert_equal(expected, url) + end + + # Hash-based API test - verify that plain hashes work for both transformations and options + # Developers can use hashes instead of model objects for a more concise, Ruby-idiomatic syntax + def test_should_work_with_plain_hashes_for_transformations_and_options + # Using plain hashes instead of Transformation.new and SrcOptions.new + url = @client.helper.build_url( + { + src: "/test_path1.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: [ + { + width: 300, + height: 200, + quality: 85, + border: "5_FF0000", + ai_remove_background: true, + ai_drop_shadow: true + } + ] + } + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,q-85,b-5_FF0000,e-bgremove,e-dropshadow" + assert_equal(expected, url) + end +end diff --git a/test/imagekitio/custom-tests/url-generation/basic_url_generation_test.rb b/test/imagekitio/custom-tests/url-generation/basic_url_generation_test.rb new file mode 100644 index 00000000..e414575e --- /dev/null +++ b/test/imagekitio/custom-tests/url-generation/basic_url_generation_test.rb @@ -0,0 +1,409 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class BasicURLGenerationTest < Minitest::Test + def setup + @client = Imagekitio::Client.new( + private_key: "My Private API Key" + ) + end + + def test_should_return_an_empty_string_when_src_is_not_provided + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query + ) + ) + + assert_equal("", url) + end + + def test_should_generate_a_valid_url_when_src_is_slash + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint" + assert_equal(expected, url) + end + + def test_should_generate_a_valid_url_when_src_is_provided_with_transformation + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg" + assert_equal(expected, url) + end + + def test_should_generate_a_valid_url_when_a_src_is_provided_without_transformation + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg" + assert_equal(expected, url) + end + + def test_should_generate_a_valid_url_when_undefined_transformation_parameters_are_provided_with_path + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path_alt.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg" + assert_equal(expected, url) + end + + def test_by_default_transformation_position_should_be_query + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ), + Imagekitio::Models::Transformation.new( + rotation: 90.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400:rt-90" + assert_equal(expected, url) + end + + def test_should_generate_the_url_without_sdk_version + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation: transformation, + transformation_position: :path + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/tr:h-300,w-400/test_path.jpg" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_with_a_valid_src_and_transformation + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400" + assert_equal(expected, url) + end + + def test_should_add_transformation_as_query_when_src_has_absolute_url_even_if_transformation_position_is_path + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "https://my.custom.domain.com/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://my.custom.domain.com/test_path.jpg?tr=h-300,w-400" + assert_equal(expected, url) + end + + def test_should_generate_correct_url_when_src_has_query_params + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "https://ik.imagekit.io/imagekit_id/new-endpoint/test_path.jpg?t1=v1", + url_endpoint: "https://ik.imagekit.io/imagekit_id/new-endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/imagekit_id/new-endpoint/test_path.jpg?t1=v1&tr=h-300,w-400" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_when_the_provided_path_contains_multiple_leading_slashes + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "///test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_when_the_url_endpoint_is_overridden + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint_alt", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint_alt/test_path.jpg?tr=h-300,w-400" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_with_transformation_position_as_query_parameter_when_src_is_provided + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_with_a_valid_src_parameter_and_transformation + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?tr=h-300,w-400" + assert_equal(expected, url) + end + + def test_should_merge_query_parameters_correctly_in_the_generated_url + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ) + ] + + query_parameters = { + t2: "v2", + t3: "v3" + } + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + query_parameters: query_parameters, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1&t2=v2&t3=v3&tr=h-300,w-400" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_with_chained_transformations + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ), + Imagekitio::Models::Transformation.new( + rotation: 90.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400:rt-90" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_with_chained_transformations_including_raw_transformation + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0 + ), + Imagekitio::Models::Transformation.new( + raw: "rndm_trnsf-abcd" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400:rndm_trnsf-abcd" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_when_border_transformation_is_applied + transformation = [ + Imagekitio::Models::Transformation.new( + height: 300.0, + width: 400.0, + border: "20_FF0000" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400,b-20_FF0000" + assert_equal(expected, url) + end + + def test_should_generate_the_correct_url_when_transformation_has_empty_key_and_value + transformation = [ + Imagekitio::Models::Transformation.new( + raw: "" + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/test_path.jpg" + assert_equal(expected, url) + end + + def test_should_generate_a_valid_url_when_cname_is_used + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://custom.domain.com", + transformation_position: :query + ) + ) + + expected = "https://custom.domain.com/test_path.jpg" + assert_equal(expected, url) + end + + def test_should_generate_a_valid_url_when_cname_with_path_is_used + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/test_path.jpg", + url_endpoint: "https://custom.domain.com/url-pattern", + transformation_position: :query + ) + ) + + expected = "https://custom.domain.com/url-pattern/test_path.jpg" + assert_equal(expected, url) + end +end diff --git a/test/imagekitio/custom-tests/url-generation/build_transformation_string_test.rb b/test/imagekitio/custom-tests/url-generation/build_transformation_string_test.rb new file mode 100644 index 00000000..d4726b4c --- /dev/null +++ b/test/imagekitio/custom-tests/url-generation/build_transformation_string_test.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class BuildTransformationStringTest < Minitest::Test + def setup + @client = Imagekitio::Client.new( + private_key: "test-key" + ) + end + + def test_should_return_empty_string_for_empty_transformation_array + result = @client.helper.build_transformation_string(nil) + assert_equal("", result) + + result = @client.helper.build_transformation_string([]) + assert_equal("", result) + end + + def test_should_generate_transformation_string_for_width_only + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0 + ) + ] + + result = @client.helper.build_transformation_string(transformation) + expected = "w-300" + assert_equal(expected, result) + end + + def test_should_generate_transformation_string_for_multiple_parameters + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0, + height: 200.0 + ) + ] + + result = @client.helper.build_transformation_string(transformation) + expected = "w-300,h-200" + assert_equal(expected, result) + end + + def test_should_generate_transformation_string_for_chained_transformations + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0 + ), + Imagekitio::Models::Transformation.new( + height: 200.0 + ) + ] + + result = @client.helper.build_transformation_string(transformation) + expected = "w-300:h-200" + assert_equal(expected, result) + end + + def test_should_handle_empty_transformation_object + transformation = [ + Imagekitio::Models::Transformation.new + ] + + result = @client.helper.build_transformation_string(transformation) + expected = "" + assert_equal(expected, result) + end + + def test_should_handle_transformation_with_overlay + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "Hello" + ) + ) + ] + + result = @client.helper.build_transformation_string(transformation) + expected = "l-text,i-Hello,l-end" + assert_equal(expected, result) + end + + def test_should_handle_raw_transformation_parameter + transformation = [ + Imagekitio::Models::Transformation.new( + raw: "custom-transform-123" + ) + ] + + result = @client.helper.build_transformation_string(transformation) + expected = "custom-transform-123" + assert_equal(expected, result) + end + + def test_should_handle_mixed_parameters_with_raw + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0, + raw: "custom-param-123" + ) + ] + + result = @client.helper.build_transformation_string(transformation) + expected = "w-300,custom-param-123" + assert_equal(expected, result) + end + + def test_should_handle_quality_parameter + transformation = [ + Imagekitio::Models::Transformation.new( + quality: 80.0 + ) + ] + + result = @client.helper.build_transformation_string(transformation) + expected = "q-80" + assert_equal(expected, result) + end + + def test_should_handle_aspect_ratio_parameter + transformation = [ + Imagekitio::Models::Transformation.new( + aspect_ratio: "4:3" + ) + ] + + result = @client.helper.build_transformation_string(transformation) + expected = "ar-4:3" + assert_equal(expected, result) + end +end diff --git a/test/imagekitio/custom-tests/url-generation/overlay_test.rb b/test/imagekitio/custom-tests/url-generation/overlay_test.rb new file mode 100644 index 00000000..1716ed7d --- /dev/null +++ b/test/imagekitio/custom-tests/url-generation/overlay_test.rb @@ -0,0 +1,762 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class OverlayTest < Minitest::Test + def setup + @client = Imagekitio::Client.new( + private_key: "My Private API Key" + ) + end + + # Basic overlay tests + def test_should_ignore_overlay_when_type_property_is_missing + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0 + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/tr:w-300/base-image.jpg" + assert_equal(expected, url) + end + + def test_should_ignore_text_overlay_when_text_property_is_missing + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/base-image.jpg" + assert_equal(expected, url) + end + + def test_should_ignore_image_overlay_when_input_property_is_missing + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::ImageOverlay.new( + input: "" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/base-image.jpg" + assert_equal(expected, url) + end + + def test_should_ignore_video_overlay_when_input_property_is_missing + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::VideoOverlay.new( + input: "" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/base-image.jpg" + assert_equal(expected, url) + end + + def test_should_ignore_subtitle_overlay_when_input_property_is_missing + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::SubtitleOverlay.new( + input: "" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/base-image.jpg" + assert_equal(expected, url) + end + + def test_should_ignore_solid_color_overlay_when_color_property_is_missing + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::SolidColorOverlay.new( + color: "" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/base-image.jpg" + assert_equal(expected, url) + end + + # Basic overlay functionality tests + def test_should_generate_url_with_text_overlay_using_url_encoding + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "Minimal Text" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Minimal%20Text,l-end/base-image.jpg" + assert_equal(expected, url) + end + + def test_should_generate_url_with_image_overlay_from_input_file + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::ImageOverlay.new( + input: "logo.png" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,l-end/base-image.jpg" + assert_equal(expected, url) + end + + def test_should_generate_url_with_video_overlay_from_input_file + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::VideoOverlay.new( + input: "play-pause-loop.mp4" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-video.mp4", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/tr:l-video,i-play-pause-loop.mp4,l-end/base-video.mp4" + assert_equal(expected, url) + end + + def test_should_generate_url_with_subtitle_overlay_from_input_file + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::SubtitleOverlay.new( + input: "subtitle.srt" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-video.mp4", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitle,i-subtitle.srt,l-end/base-video.mp4" + assert_equal(expected, url) + end + + def test_should_generate_url_with_solid_color_overlay_using_background_color + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::SolidColorOverlay.new( + color: "FF0000" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-ik_canvas,bg-FF0000,l-end/base-image.jpg" + assert_equal(expected, url) + end + + def test_should_generate_url_with_multiple_complex_overlays_including_nested_transformations + transformation = [ + # Text overlay + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "Every thing", + position: Imagekitio::Models::OverlayPosition.new( + x: "10", + y_: "20", + focus: :center + ), + timing: Imagekitio::Models::OverlayTiming.new( + start: 5.0, + duration: "10", + end_: 15.0 + ), + transformation: [ + Imagekitio::Models::TextOverlayTransformation.new( + width: "bw_mul_0.5", + font_size: 20.0, + font_family: "Arial", + font_color: "0000ff", + inner_alignment: :left, + padding: 5.0, + alpha: 7.0, + typography: "b", + background: "red", + radius: 10.0, + rotation: "N45", + flip: :h, + line_height: 20.0 + ) + ] + ) + ), + # Image overlay + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::ImageOverlay.new( + input: "logo.png", + position: Imagekitio::Models::OverlayPosition.new( + x: "10", + y_: "20", + focus: :center + ), + timing: Imagekitio::Models::OverlayTiming.new( + start: 5.0, + duration: "10", + end_: 15.0 + ), + transformation: [ + Imagekitio::Models::Transformation.new( + width: "bw_mul_0.5", + height: "bh_mul_0.5", + rotation: "N45", + flip: :h, + overlay: Imagekitio::Models::TextOverlay.new( + text: "Nested text overlay" + ) + ) + ] + ) + ), + # Video overlay + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::VideoOverlay.new( + input: "play-pause-loop.mp4", + position: Imagekitio::Models::OverlayPosition.new( + x: "10", + y_: "20", + focus: :center + ), + timing: Imagekitio::Models::OverlayTiming.new( + start: 5.0, + duration: "10", + end_: 15.0 + ), + transformation: [ + Imagekitio::Models::Transformation.new( + width: "bw_mul_0.5", + height: "bh_mul_0.5", + rotation: "N45", + flip: :h + ) + ] + ) + ), + # Subtitle overlay + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::SubtitleOverlay.new( + input: "subtitle.srt", + position: Imagekitio::Models::OverlayPosition.new( + x: "10", + y_: "20", + focus: :center + ), + timing: Imagekitio::Models::OverlayTiming.new( + start: 5.0, + duration: "10", + end_: 15.0 + ), + transformation: [ + Imagekitio::Models::SubtitleOverlayTransformation.new( + background: "red", + color: "0000ff", + font_family: "Arial", + font_outline: "2_A1CCDD50", + font_shadow: "A1CCDD_3" + ) + ] + ) + ), + # Solid color overlay + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::SolidColorOverlay.new( + color: "FF0000", + position: Imagekitio::Models::OverlayPosition.new( + x: "10", + y_: "20", + focus: :center + ), + timing: Imagekitio::Models::OverlayTiming.new( + start: 5.0, + duration: "10", + end_: 15.0 + ), + transformation: [ + Imagekitio::Models::SolidColorOverlayTransformation.new( + width: "bw_mul_0.5", + height: "bh_mul_0.5", + alpha: 0.5, + background: "red", + gradient: true, + radius: :max + ) + ] + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Every%20thing,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,fs-20,ff-Arial,co-0000ff,ia-left,pa-5,al-7,tg-b,bg-red,r-10,rt-N45,fl-h,lh-20,l-end:l-image,i-logo.png,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-text,i-Nested%20text%20overlay,l-end,l-end:l-video,i-play-pause-loop.mp4,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-end:l-subtitle,i-subtitle.srt,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,bg-red,co-0000ff,ff-Arial,fol-2_A1CCDD50,fsh-A1CCDD_3,l-end:l-image,i-ik_canvas,bg-FF0000,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,al-0.5,bg-red,e-gradient,r-max,l-end/base-image.jpg" + assert_equal(expected, url) + end + + # Overlay encoding tests + def test_should_use_plain_encoding_for_simple_image_paths_with_slashes_converted_to_double_at + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::ImageOverlay.new( + input: "/customer_logo/nykaa.png" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/medium_cafe_B1iTdD0C.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-image,i-customer_logo@@nykaa.png,l-end/medium_cafe_B1iTdD0C.jpg" + assert_equal(expected, url) + end + + def test_should_use_base64_encoding_for_image_paths_containing_special_characters + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::ImageOverlay.new( + input: "/customer_logo/Ñykaa.png" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/medium_cafe_B1iTdD0C.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXJfbG9nby%2FDkXlrYWEucG5n,l-end/medium_cafe_B1iTdD0C.jpg" + assert_equal(expected, url) + end + + def test_should_use_plain_encoding_for_simple_text_overlays + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "Manu" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/medium_cafe_B1iTdD0C.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-text,i-Manu,l-end/medium_cafe_B1iTdD0C.jpg" + assert_equal(expected, url) + end + + def test_should_convert_slashes_to_double_at_in_font_family_paths_for_custom_fonts + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "Manu", + transformation: [ + Imagekitio::Models::TextOverlayTransformation.new( + font_family: "nested-path/Poppins-Regular_Q15GrYWmL.ttf" + ) + ] + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/medium_cafe_B1iTdD0C.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-text,i-Manu,ff-nested-path@@Poppins-Regular_Q15GrYWmL.ttf,l-end/medium_cafe_B1iTdD0C.jpg" + assert_equal(expected, url) + end + + def test_should_use_url_encoding_for_text_overlays_with_spaces_and_safe_characters + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "alnum123-._ " + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/medium_cafe_B1iTdD0C.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-text,i-alnum123-._%20,l-end/medium_cafe_B1iTdD0C.jpg" + assert_equal(expected, url) + end + + def test_should_use_base64_encoding_for_text_overlays_with_special_unicode_characters + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "Let's use ©, ®, ™, etc" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/medium_cafe_B1iTdD0C.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-text,ie-TGV0J3MgdXNlIMKpLCDCriwg4oSiLCBldGM%3D,l-end/medium_cafe_B1iTdD0C.jpg" + assert_equal(expected, url) + end + + def test_should_use_plain_encoding_when_explicitly_specified_for_text_overlay + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "HelloWorld", + encoding: :plain + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-text,i-HelloWorld,l-end/sample.jpg" + assert_equal(expected, url) + end + + def test_should_use_base64_encoding_when_explicitly_specified_for_text_overlay + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "HelloWorld", + encoding: :base64 + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-text,ie-SGVsbG9Xb3JsZA%3D%3D,l-end/sample.jpg" + assert_equal(expected, url) + end + + def test_should_use_plain_encoding_when_explicitly_specified_for_image_overlay + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::ImageOverlay.new( + input: "/customer/logo.png", + encoding: :plain + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-image,i-customer@@logo.png,l-end/sample.jpg" + assert_equal(expected, url) + end + + def test_should_use_base64_encoding_when_explicitly_specified_for_image_overlay + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::ImageOverlay.new( + input: "/customer/logo.png", + encoding: :base64 + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXIvbG9nby5wbmc%3D,l-end/sample.jpg" + assert_equal(expected, url) + end + + def test_should_use_base64_encoding_when_explicitly_specified_for_video_overlay + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::VideoOverlay.new( + input: "/path/to/video.mp4", + encoding: :base64 + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/sample.mp4", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-video,ie-cGF0aC90by92aWRlby5tcDQ%3D,l-end/sample.mp4" + assert_equal(expected, url) + end + + def test_should_use_plain_encoding_when_explicitly_specified_for_subtitle_overlay + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::SubtitleOverlay.new( + input: "/sub.srt", + encoding: :plain + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/sample.mp4", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-subtitle,i-sub.srt,l-end/sample.mp4" + assert_equal(expected, url) + end + + def test_should_use_base64_encoding_when_explicitly_specified_for_subtitle_overlay + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::SubtitleOverlay.new( + input: "sub.srt", + encoding: :base64 + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/sample.mp4", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :path, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-subtitle,ie-c3ViLnNydA%3D%3D,l-end/sample.mp4" + assert_equal(expected, url) + end + + def test_should_properly_encode_overlay_text_when_transformations_are_in_query_parameters + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "Minimal Text" + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "/sample.jpg", + url_endpoint: "https://ik.imagekit.io/demo", + transformation_position: :query, + transformation: transformation + ) + ) + + expected = "https://ik.imagekit.io/demo/sample.jpg?tr=l-text,i-Minimal%20Text,l-end" + assert_equal(expected, url) + end + + # Hash-based API test - verify that plain hashes work for overlays + def test_should_work_with_plain_hashes_for_text_overlay + # Using plain hashes for everything including overlay + url = @client.helper.build_url( + { + src: "/base-image.jpg", + url_endpoint: "https://ik.imagekit.io/test_url_endpoint", + transformation_position: :path, + transformation: [ + { + width: 300, + height: 200, + overlay: { + type: :text, + text: "Hello World", + position: { + x: "10", + y_: "20", + focus: :center + }, + transformation: [ + { + font_size: 20, + font_color: "FF0000" + } + ] + } + } + ] + } + ) + + expected = "https://ik.imagekit.io/test_url_endpoint/tr:w-300,h-200,l-text,i-Hello%20World,lx-10,ly-20,lfo-center,fs-20,co-FF0000,l-end/base-image.jpg" + assert_equal(expected, url) + end +end diff --git a/test/imagekitio/custom-tests/url-generation/signing_test.rb b/test/imagekitio/custom-tests/url-generation/signing_test.rb new file mode 100644 index 00000000..70c4863a --- /dev/null +++ b/test/imagekitio/custom-tests/url-generation/signing_test.rb @@ -0,0 +1,235 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class SigningTest < Minitest::Test + def setup + @client = Imagekitio::Client.new( + private_key: "dummy-key" + ) + end + + def test_should_generate_a_signed_url_when_signed_is_true_without_expires_in + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/future-search.png", + url_endpoint: "https://ik.imagekit.io/demo/", + signed: true + ) + ) + + expected = "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?ik-s=32dbbbfc5f945c0403c71b54c38e76896ef2d6b0" + assert_equal(expected, url) + end + + def test_should_generate_a_signed_url_when_signed_is_true_with_expires_in + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/future-search.png", + url_endpoint: "https://ik.imagekit.io/demo/", + signed: true, + expires_in: 3600.0 + ) + ) + + # Expect ik-t exist in the URL. We don't assert signature because it will keep changing. + assert_includes(url, "ik-t") + end + + def test_should_generate_a_signed_url_when_expires_in_is_above_0_and_even_if_signed_is_false + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/future-search.png", + url_endpoint: "https://ik.imagekit.io/demo/", + signed: false, + expires_in: 3600.0 + ) + ) + + # Expect ik-t exist in the URL. We don't assert signature because it will keep changing. + assert_includes(url, "ik-t") + end + + def test_should_generate_signed_url_with_special_characters_in_filename + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/हिन्दी.png", + url_endpoint: "https://ik.imagekit.io/demo/", + signed: true + ) + ) + + expected = "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=3fff2f31da1f45e007adcdbe95f88c8c330e743c" + assert_equal(expected, url) + end + + def test_should_generate_signed_url_with_text_overlay_containing_special_characters + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "हिन्दी", + transformation: [ + Imagekitio::Models::TextOverlayTransformation.new( + font_color: "red", + font_size: "32", + font_family: "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" + ) + ] + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/हिन्दी.png", + url_endpoint: "https://ik.imagekit.io/demo/", + transformation: transformation, + signed: true + ) + ) + + expected = "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?tr=l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,co-red,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,l-end&ik-s=ac9f24a03080102555e492185533c1ae6bd93fa7" + assert_equal(expected, url) + end + + def test_should_generate_signed_url_with_text_overlay_and_special_characters_using_path_transformation_position + transformation = [ + Imagekitio::Models::Transformation.new( + overlay: Imagekitio::Models::TextOverlay.new( + text: "हिन्दी", + transformation: [ + Imagekitio::Models::TextOverlayTransformation.new( + font_color: "red", + font_size: "32", + font_family: "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" + ) + ] + ) + ) + ] + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/हिन्दी.png", + url_endpoint: "https://ik.imagekit.io/demo/", + transformation_position: :path, + transformation: transformation, + signed: true + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,co-red,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,l-end/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=69f2ecbb7364bbbad24616e1f7f1bac5a560fc71" + assert_equal(expected, url) + end + + def test_should_generate_signed_url_with_query_parameters + query_params = { + "version" => "1.0", + "cache" => "false" + } + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/future-search.png", + url_endpoint: "https://ik.imagekit.io/demo/", + query_parameters: query_params, + signed: true + ) + ) + + expected = "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?version=1.0&cache=false&ik-s=f2e5a1b8b6a0b03fd63789dfc6413a94acef9fd8" + assert_equal(expected, url) + end + + def test_should_generate_signed_url_with_transformations_and_query_parameters + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0, + height: 200.0 + ) + ] + + query_params = { + "version" => "2.0" + } + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/future-search.png", + url_endpoint: "https://ik.imagekit.io/demo/", + transformation: transformation, + query_parameters: query_params, + signed: true + ) + ) + + expected = "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?version=2.0&tr=w-300,h-200&ik-s=601d97a7834b7554f4dabf0d3fc3a219ceeb6b31" + assert_equal(expected, url) + end + + def test_should_not_sign_url_when_signed_is_false + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/future-search.png", + url_endpoint: "https://ik.imagekit.io/demo/", + signed: false + ) + ) + + expected = "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png" + assert_equal(expected, url) + refute_includes(url, "ik-s=") + refute_includes(url, "ik-t=") + end + + def test_should_generate_signed_url_with_transformations_in_path_position_and_query_parameters + transformation = [ + Imagekitio::Models::Transformation.new( + width: 300.0, + height: 200.0 + ) + ] + + query_params = { + "version" => "2.0" + } + + url = @client.helper.build_url( + Imagekitio::Models::SrcOptions.new( + src: "sdk-testing-files/future-search.png", + url_endpoint: "https://ik.imagekit.io/demo/", + transformation: transformation, + transformation_position: :path, + query_parameters: query_params, + signed: true + ) + ) + + expected = "https://ik.imagekit.io/demo/tr:w-300,h-200/sdk-testing-files/future-search.png?version=2.0&ik-s=dd1ee8f83d019bc59fd57a5fc4674a11eb8a3496" + assert_equal(expected, url) + end + + # Hash-based API test - verify that plain hashes work for signed URLs + def test_should_work_with_plain_hashes_for_signed_url_with_transformations + # Using plain hashes instead of model objects + url = @client.helper.build_url( + { + src: "sdk-testing-files/future-search.png", + url_endpoint: "https://ik.imagekit.io/demo/", + transformation: [ + { + width: 300, + height: 200 + } + ], + query_parameters: { + "version" => "2.0" + }, + signed: true + } + ) + + expected = "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?version=2.0&tr=w-300,h-200&ik-s=601d97a7834b7554f4dabf0d3fc3a219ceeb6b31" + assert_equal(expected, url) + end +end diff --git a/test/imagekitio/file_part_test.rb b/test/imagekitio/file_part_test.rb new file mode 100644 index 00000000..3e026ad2 --- /dev/null +++ b/test/imagekitio/file_part_test.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require_relative "test_helper" + +class Imagekitio::Test::FilePartTest < Minitest::Test + def test_to_json + text = "gray" + filepart = Imagekitio::FilePart.new(StringIO.new(text)) + + assert_equal(text.to_json, filepart.to_json) + assert_equal(text.to_yaml, filepart.to_yaml) + end +end diff --git a/test/imagekitio/internal/sorbet_runtime_support_test.rb b/test/imagekitio/internal/sorbet_runtime_support_test.rb new file mode 100644 index 00000000..fd7379d1 --- /dev/null +++ b/test/imagekitio/internal/sorbet_runtime_support_test.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::SorbetRuntimeSupportTest < Minitest::Test + extend Minitest::Serial + + i_suck_and_my_tests_are_order_dependent! + + module E + extend Imagekitio::Internal::Type::Enum + + define_sorbet_constant!(:TaggedSymbol) { 1 } + end + + module U + extend Imagekitio::Internal::Type::Union + + define_sorbet_constant!(:Variants) { 2 } + end + + class M < Imagekitio::Internal::Type::BaseModel + define_sorbet_constant!(:OrHash) { 3 } + end + + def test_nil_aliases + err = Imagekitio::Internal::Util::SorbetRuntimeSupport::MissingSorbetRuntimeError + + assert_raises(err) { Imagekitio::Internal::AnyHash } + assert_raises(err) { Imagekitio::Internal::FileInput } + assert_raises(err) { Imagekitio::Internal::Type::Converter::Input } + assert_raises(err) { Imagekitio::Internal::Type::Converter::CoerceState } + assert_raises(err) { Imagekitio::Internal::Type::Converter::DumpState } + assert_raises(err) { Imagekitio::Internal::Type::BaseModel::KnownField } + assert_raises(err) { Imagekitio::Internal::Util::ParsedUri } + assert_raises(err) { Imagekitio::Internal::Util::ServerSentEvent } + assert_raises(err) { Imagekitio::Internal::Transport::BaseClient::RequestComponents } + assert_raises(err) { Imagekitio::Internal::Transport::BaseClient::RequestInput } + assert_raises(err) { Imagekitio::Internal::Transport::PooledNetRequester::Request } + assert_raises(err) { E::TaggedSymbol } + assert_raises(err) { U::Variants } + assert_raises(err) { M::OrHash } + end + + def test_stubbed_aliases + Kernel.instance_eval { const_set(:T, nil) } + + assert_equal(1, E::TaggedSymbol) + assert_equal(2, U::Variants) + assert_equal(3, M::OrHash) + end +end diff --git a/test/imagekitio/internal/type/base_model_test.rb b/test/imagekitio/internal/type/base_model_test.rb new file mode 100644 index 00000000..4f59b949 --- /dev/null +++ b/test/imagekitio/internal/type/base_model_test.rb @@ -0,0 +1,727 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::PrimitiveModelTest < Minitest::Test + A = Imagekitio::Internal::Type::ArrayOf[-> { Integer }] + H = Imagekitio::Internal::Type::HashOf[-> { Integer }, nil?: true] + + module E + extend Imagekitio::Internal::Type::Enum + end + + module U + extend Imagekitio::Internal::Type::Union + end + + class B < Imagekitio::Internal::Type::BaseModel + optional :a, Integer + optional :b, B + end + + def test_typing + converters = [ + Imagekitio::Internal::Type::Unknown, + Imagekitio::Internal::Type::Boolean, + A, + H, + E, + U, + B + ] + + converters.each do |conv| + assert_pattern do + conv => Imagekitio::Internal::Type::Converter + end + end + end + + def test_coerce + cases = { + [Imagekitio::Internal::Type::Unknown, :a] => [{yes: 1}, :a], + [NilClass, :a] => [{maybe: 1}, nil], + [NilClass, nil] => [{yes: 1}, nil], + [Imagekitio::Internal::Type::Boolean, true] => [{yes: 1}, true], + [Imagekitio::Internal::Type::Boolean, "true"] => [{no: 1}, "true"], + [Integer, 1] => [{yes: 1}, 1], + [Integer, 1.0] => [{maybe: 1}, 1], + [Integer, "1"] => [{maybe: 1}, 1], + [Integer, "one"] => [{no: 1}, "one"], + [Float, 1] => [{yes: 1}, 1.0], + [Float, "1"] => [{maybe: 1}, 1.0], + [Float, :one] => [{no: 1}, :one], + [String, :str] => [{yes: 1}, "str"], + [String, "str"] => [{yes: 1}, "str"], + [String, 1] => [{maybe: 1}, "1"], + [:a, "a"] => [{yes: 1}, :a], + [Date, "1990-09-19"] => [{yes: 1}, Date.new(1990, 9, 19)], + [Date, Date.new(1990, 9, 19)] => [{yes: 1}, Date.new(1990, 9, 19)], + [Date, "one"] => [{no: 1}, "one"], + [Time, "1990-09-19"] => [{yes: 1}, Time.new(1990, 9, 19)], + [Time, Time.new(1990, 9, 19)] => [{yes: 1}, Time.new(1990, 9, 19)], + [Time, "one"] => [{no: 1}, "one"] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = Imagekitio::Internal::Type::Converter.new_coerce_state + assert_pattern do + Imagekitio::Internal::Type::Converter.coerce(target, input, state: state) => ^expect + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end + end + end + + def test_dump + cases = { + [Imagekitio::Internal::Type::Unknown, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [A, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [H, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [E, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [U, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [B, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [String, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [:b, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [nil, B.new(a: "one", b: B.new(a: 1.0))] => {a: "one", b: {a: 1}}, + [Imagekitio::Internal::Type::Boolean, true] => true, + [Imagekitio::Internal::Type::Boolean, "true"] => "true", + [Integer, "1"] => "1", + [Float, 1] => 1, + [String, "one"] => "one", + [String, :one] => :one, + [:a, :b] => :b, + [:a, "a"] => "a", + [String, StringIO.new("one")] => "one", + [String, Pathname(__FILE__)] => Imagekitio::FilePart + } + + cases.each do + target, input = _1 + expect = _2 + assert_pattern do + Imagekitio::Internal::Type::Converter.dump(target, input) => ^expect + end + end + end + + def test_coerce_errors + cases = { + [Integer, "one"] => ArgumentError, + [Float, "one"] => ArgumentError, + [String, Time] => TypeError, + [Date, "one"] => ArgumentError, + [Time, "one"] => ArgumentError + } + + cases.each do |testcase, expect| + target, input = testcase + state = Imagekitio::Internal::Type::Converter.new_coerce_state + Imagekitio::Internal::Type::Converter.coerce(target, input, state: state) + assert_pattern do + state => {error: ^expect} + end + end + end + + def test_dump_retry + types = [ + Imagekitio::Internal::Type::Unknown, + Imagekitio::Internal::Type::Boolean, + A, + H, + E, + U, + B + ] + Pathname(__FILE__).open do |fd| + cases = [ + fd, + [fd], + {a: fd}, + {a: {b: fd}} + ] + types.product(cases).each do |target, input| + state = {can_retry: true} + Imagekitio::Internal::Type::Converter.dump(target, input, state: state) + + assert_pattern do + state => {can_retry: false} + end + end + end + end +end + +class Imagekitio::Test::EnumModelTest < Minitest::Test + class E0 + include Imagekitio::Internal::Type::Enum + + attr_reader :values + + def initialize(*values) = (@values = values) + end + + module E1 + extend Imagekitio::Internal::Type::Enum + + TRUE = true + end + + module E2 + extend Imagekitio::Internal::Type::Enum + + ONE = 1 + TWO = 2 + end + + module E3 + extend Imagekitio::Internal::Type::Enum + + ONE = 1.0 + TWO = 2.0 + end + + module E4 + extend Imagekitio::Internal::Type::Enum + + ONE = :one + TWO = :two + end + + def test_coerce + cases = { + [E0.new, "one"] => [{no: 1}, "one"], + [E0.new(:one), "one"] => [{yes: 1}, :one], + [E0.new(:two), "one"] => [{maybe: 1}, "one"], + + [E1, true] => [{yes: 1}, true], + [E1, false] => [{no: 1}, false], + [E1, :true] => [{no: 1}, :true], + + [E2, 1] => [{yes: 1}, 1], + [E2, 1.0] => [{yes: 1}, 1], + [E2, 1.2] => [{no: 1}, 1.2], + [E2, "1"] => [{no: 1}, "1"], + + [E3, 1.0] => [{yes: 1}, 1.0], + [E3, 1] => [{yes: 1}, 1.0], + [E3, "one"] => [{no: 1}, "one"], + + [E4, :one] => [{yes: 1}, :one], + [E4, "one"] => [{yes: 1}, :one], + [E4, "1"] => [{maybe: 1}, "1"], + [E4, :"1"] => [{maybe: 1}, :"1"], + [E4, 1] => [{no: 1}, 1] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = Imagekitio::Internal::Type::Converter.new_coerce_state + assert_pattern do + Imagekitio::Internal::Type::Converter.coerce(target, input, state: state) => ^expect + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end + end + end + + def test_dump + cases = { + [E1, true] => true, + [E1, "true"] => "true", + + [E2, 1.0] => 1.0, + [E2, 3] => 3, + [E2, "1.0"] => "1.0", + + [E3, 1.0] => 1.0, + [E3, 3] => 3, + [E3, "1.0"] => "1.0", + + [E4, :one] => :one, + [E4, "one"] => "one", + [E4, "1.0"] => "1.0" + } + + cases.each do + target, input = _1 + expect = _2 + assert_pattern do + Imagekitio::Internal::Type::Converter.dump(target, input) => ^expect + end + end + end +end + +class Imagekitio::Test::CollectionModelTest < Minitest::Test + A1 = Imagekitio::Internal::Type::ArrayOf[-> { Integer }] + H1 = Imagekitio::Internal::Type::HashOf[Integer] + + A2 = Imagekitio::Internal::Type::ArrayOf[H1] + H2 = Imagekitio::Internal::Type::HashOf[-> { A1 }] + + A3 = Imagekitio::Internal::Type::ArrayOf[Integer, nil?: true] + H3 = Imagekitio::Internal::Type::HashOf[Integer, nil?: true] + + def test_coerce + cases = { + [A1, []] => [{yes: 1}, []], + [A1, {}] => [{no: 1}, {}], + [A1, [1, 2.0]] => [{yes: 2, maybe: 1}, [1, 2]], + [A1, ["1", 2.0]] => [{yes: 1, maybe: 2}, [1, 2]], + [H1, {}] => [{yes: 1}, {}], + [H1, []] => [{no: 1}, []], + [H1, {a: 1, b: 2}] => [{yes: 3}, {a: 1, b: 2}], + [H1, {"a" => 1, "b" => 2}] => [{yes: 3}, {a: 1, b: 2}], + [H1, {[] => 1}] => [{yes: 2, no: 1}, {[] => 1}], + [H1, {a: 1.5}] => [{yes: 1, maybe: 1}, {a: 1}], + + [A2, [{}, {"a" => 1}]] => [{yes: 4}, [{}, {a: 1}]], + [A2, [{"a" => "1"}]] => [{yes: 2, maybe: 1}, [{a: 1}]], + [H2, {a: [1, 2]}] => [{yes: 4}, {a: [1, 2]}], + [H2, {"a" => ["1", 2]}] => [{yes: 3, maybe: 1}, {a: [1, 2]}], + [H2, {"a" => ["one", 2]}] => [{yes: 3, no: 1}, {a: ["one", 2]}], + + [A3, [nil, 1]] => [{yes: 3}, [nil, 1]], + [A3, [nil, "1"]] => [{yes: 2, maybe: 1}, [nil, 1]], + [H3, {a: nil, b: "1"}] => [{yes: 2, maybe: 1}, {a: nil, b: 1}], + [H3, {a: nil}] => [{yes: 2}, {a: nil}] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = Imagekitio::Internal::Type::Converter.new_coerce_state + assert_pattern do + Imagekitio::Internal::Type::Converter.coerce(target, input, state: state) => ^expect + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end + end + end +end + +class Imagekitio::Test::BaseModelTest < Minitest::Test + class M1 < Imagekitio::Internal::Type::BaseModel + required :a, Integer + end + + class M2 < M1 + required :a, Time + required :b, Integer, nil?: true + optional :c, String + end + + class M3 < Imagekitio::Internal::Type::BaseModel + optional :c, const: :c + required :d, const: :d + end + + class M4 < M1 + request_only do + required :a, Integer + optional :b, String + end + + response_only do + required :c, Integer + optional :d, String + end + end + + class M5 < Imagekitio::Internal::Type::BaseModel + request_only do + required :c, const: :c + end + + response_only do + required :d, const: :d + end + end + + class M6 < M1 + required :a, Imagekitio::Internal::Type::ArrayOf[M6] + optional :b, M6 + end + + def test_coerce + cases = { + [M1, {}] => [{yes: 1, no: 1}, {}], + [M1, :m1] => [{no: 1}, :m1], + + [M2, {}] => [{yes: 2, no: 1, maybe: 1}, {}], + [M2, {a: "1990-09-19", b: nil}] => [{yes: 4}, {a: "1990-09-19", b: nil}], + [M2, {a: "1990-09-19", b: "1"}] => [{yes: 3, maybe: 1}, {a: "1990-09-19", b: "1"}], + [M2, {a: "1990-09-19"}] => [{yes: 3, maybe: 1}, {a: "1990-09-19"}], + [M2, {a: "1990-09-19", c: nil}] => [{yes: 2, maybe: 2}, {a: "1990-09-19", c: nil}], + + [M3, {c: "c", d: "d"}] => [{yes: 3}, {c: :c, d: :d}], + [M3, {c: "d", d: "c"}] => [{yes: 1, maybe: 2}, {c: "d", d: "c"}], + + [M4, {c: 2}] => [{yes: 5}, {c: 2}], + [M4, {a: "1", c: 2}] => [{yes: 4, maybe: 1}, {a: "1", c: 2}], + [M4, {b: nil, c: 2}] => [{yes: 4, maybe: 1}, {b: nil, c: 2}], + + [M5, {}] => [{yes: 3}, {}], + [M5, {c: "c"}] => [{yes: 3}, {c: :c}], + [M5, {d: "d"}] => [{yes: 3}, {d: :d}], + [M5, {d: nil}] => [{yes: 2, no: 1}, {d: nil}], + + [M6, {a: [{a: []}]}] => [{yes: 6}, -> { _1 in {a: [M6]} }], + [M6, {b: {a: []}}] => [{yes: 4, no: 1}, -> { _1 in {b: M6} }] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, expect = rhs + state = Imagekitio::Internal::Type::Converter.new_coerce_state + assert_pattern do + coerced = Imagekitio::Internal::Type::Converter.coerce(target, input, state: state) + assert_equal(coerced, coerced) + if coerced.is_a?(Imagekitio::Internal::Type::BaseModel) + coerced.to_h => ^expect + else + coerced => ^expect + end + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + end + end + end + + def test_dump + cases = { + [M3, M3.new] => {d: :d}, + [M3, {}] => {d: :d}, + [M3, {d: 1}] => {d: 1}, + + [M4, M4.new(a: 1, b: "b", c: 2, d: "d")] => {a: 1, b: "b"}, + [M4, {a: 1, b: "b", c: 2, d: "d"}] => {a: 1, b: "b"}, + + [M5, M5.new] => {c: :c}, + [M5, {}] => {c: :c}, + [M5, {c: 1}] => {c: 1} + } + + cases.each do + target, input = _1 + expect = _2 + assert_pattern do + Imagekitio::Internal::Type::Converter.dump(target, input) => ^expect + end + end + end + + def test_accessors + cases = { + M2.new({a: "1990-09-19", b: "1"}) => [{a: "1990-09-19", b: "1"}, {a: Time.new(1990, 9, 19), b: 1}], + M2.new(a: "one", b: "one") => [{a: "one", b: "one"}, {a: ArgumentError, b: ArgumentError}], + M2.new(a: nil, b: 2.0) => [{a: nil, b: 2.0}, {a: TypeError}], + M2.new(a: nil, b: 2.2) => [{a: nil, b: 2.2}, {a: TypeError, b: 2}], + + M3.new => [{}, {d: :d}], + M3.new(d: 1) => [{d: 1}, {d: ArgumentError}], + + M5.new => [{}, {c: :c, d: :d}] + } + + cases.each do + target = _1 + data, attributes = _2 + + assert_pattern do + target.to_h => ^data + end + + attributes.each do |accessor, expect| + case expect + in Class if expect <= StandardError + tap do + target.public_send(accessor) + flunk + rescue Imagekitio::Errors::ConversionError => e + assert_kind_of(expect, e.cause) + end + else + assert_pattern { target.public_send(accessor) => ^expect } + end + end + end + end + + def test_inplace_modification + m1 = M6.new(a: []) + m1.a << M6.new(a: []) + + m2 = M6.new(b: M6.new(a: [])) + m2.b.a << M6.new(a: []) + + m3 = M6.new(a: []) + m4 = M6.new(b: m3) + m3.a << M6.new(a: []) + + assert_pattern do + m1 => {a: [{a: []}]} + m2 => {b: {a: [{a: []}]}} + m4 => {b: {a: [{a: []}]}} + end + end +end + +class Imagekitio::Test::UnionTest < Minitest::Test + class U0 + include Imagekitio::Internal::Type::Union + + def initialize(*variants) = variants.each { variant(_1) } + end + + module U1 + extend Imagekitio::Internal::Type::Union + + variant const: :a + variant const: 2 + end + + class M1 < Imagekitio::Internal::Type::BaseModel + required :t, const: :a, api_name: :type + optional :c, String + end + + class M2 < Imagekitio::Internal::Type::BaseModel + required :type, const: :b + optional :c, String + end + + module U2 + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :a, M1 + variant :b, M2 + end + + module U3 + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant :a, M1 + variant String + end + + module U4 + extend Imagekitio::Internal::Type::Union + + discriminator :type + + variant String + variant :a, M1 + end + + class M3 < Imagekitio::Internal::Type::BaseModel + optional :recur, -> { U5 } + required :a, Integer + end + + class M4 < Imagekitio::Internal::Type::BaseModel + optional :recur, -> { U5 } + required :a, Imagekitio::Internal::Type::ArrayOf[-> { U5 }] + end + + class M5 < Imagekitio::Internal::Type::BaseModel + optional :recur, -> { U5 } + required :b, Imagekitio::Internal::Type::ArrayOf[-> { U5 }] + end + + module U5 + extend Imagekitio::Internal::Type::Union + + variant -> { M3 } + variant -> { M4 } + end + + module U6 + extend Imagekitio::Internal::Type::Union + + variant -> { M3 } + variant -> { M5 } + end + + def test_accessors + model = M3.new(recur: []) + tap do + model.recur + flunk + rescue Imagekitio::Errors::ConversionError => e + assert_kind_of(ArgumentError, e.cause) + end + end + + def test_coerce + cases = { + [U0, :""] => [{no: 1}, 0, :""], + + [U0.new(Integer, Float), "one"] => [{no: 1}, 2, "one"], + [U0.new(Integer, Float), 1.0] => [{yes: 1}, 2, 1.0], + [U0.new({const: :a}), "a"] => [{yes: 1}, 1, :a], + [U0.new({const: :a}), "2"] => [{maybe: 1}, 1, "2"], + + [U1, "a"] => [{yes: 1}, 1, :a], + [U1, "2"] => [{maybe: 1}, 2, "2"], + [U1, :b] => [{maybe: 1}, 2, :b], + + [U2, {type: :a}] => [{yes: 3}, 0, {t: :a}], + [U2, {type: "b"}] => [{yes: 3}, 0, {type: :b}], + + [U3, "one"] => [{yes: 1}, 2, "one"], + [U4, "one"] => [{yes: 1}, 1, "one"], + + [U5, {a: []}] => [{yes: 3}, 2, {a: []}], + [U6, {b: []}] => [{yes: 3}, 2, {b: []}], + + [U5, {a: [{a: []}]}] => [{yes: 6}, 4, {a: [M4.new(a: [])]}], + [U5, {a: [{a: [{a: []}]}]}] => [{yes: 9}, 6, {a: [M4.new(a: [M4.new(a: [])])]}] + } + + cases.each do |lhs, rhs| + target, input = lhs + exactness, branched, expect = rhs + state = Imagekitio::Internal::Type::Converter.new_coerce_state + assert_pattern do + coerced = Imagekitio::Internal::Type::Converter.coerce(target, input, state: state) + assert_equal(coerced, coerced) + if coerced.is_a?(Imagekitio::Internal::Type::BaseModel) + coerced.to_h => ^expect + else + coerced => ^expect + end + state.fetch(:exactness).filter { _2.nonzero? }.to_h => ^exactness + state => {branched: ^branched} + end + end + end +end + +class Imagekitio::Test::BaseModelQoLTest < Minitest::Test + class E0 + include Imagekitio::Internal::Type::Enum + + attr_reader :values + + def initialize(*values) = (@values = values) + end + + module E1 + extend Imagekitio::Internal::Type::Enum + + A = 1 + end + + module E2 + extend Imagekitio::Internal::Type::Enum + + A = 1 + end + + module E3 + extend Imagekitio::Internal::Type::Enum + + A = 2 + B = 3 + end + + class U0 + include Imagekitio::Internal::Type::Union + + def initialize(*variants) = variants.each { variant(_1) } + end + + module U1 + extend Imagekitio::Internal::Type::Union + + variant String + variant Integer + end + + module U2 + extend Imagekitio::Internal::Type::Union + + variant String + variant Integer + end + + class M1 < Imagekitio::Internal::Type::BaseModel + required :a, Integer + end + + class M2 < Imagekitio::Internal::Type::BaseModel + required :a, Integer, nil?: true + end + + class M3 < M2 + required :a, Integer + end + + def test_equality + cases = { + [Imagekitio::Internal::Type::Unknown, Imagekitio::Internal::Type::Unknown] => true, + [Imagekitio::Internal::Type::Boolean, Imagekitio::Internal::Type::Boolean] => true, + [Imagekitio::Internal::Type::Unknown, Imagekitio::Internal::Type::Boolean] => false, + [E0.new(:a, :b), E0.new(:a, :b)] => true, + [E0.new(:a, :b), E0.new(:b, :a)] => true, + [E0.new(:a, :b), E0.new(:b, :c)] => false, + [E1, E2] => true, + [E1, E3] => false, + [U0.new(String, Integer), U0.new(String, Integer)] => true, + [U0.new(String, Integer), U0.new(Integer, String)] => false, + [U0.new(String, Float), U0.new(String, Integer)] => false, + [U1, U2] => true, + [M1, M2] => false, + [M1, M3] => true, + [M1.new(a: 1), M1.new(a: 1)] => true + } + + cases.each do + if _2 + assert_equal(*_1) + assert_equal(*_1.map(&:hash)) + else + refute_equal(*_1) + refute_equal(*_1.map(&:hash)) + end + end + end +end + +class Imagekitio::Test::MetaInfoTest < Minitest::Test + A1 = Imagekitio::Internal::Type::ArrayOf[Integer, nil?: true, doc: "dog"] + H1 = Imagekitio::Internal::Type::HashOf[-> { String }, nil?: true, doc: "dawg"] + + class M1 < Imagekitio::Internal::Type::BaseModel + required :a, Integer, doc: "dog" + optional :b, -> { String }, nil?: true, doc: "dawg" + end + + module U1 + extend Imagekitio::Internal::Type::Union + + variant -> { Integer }, const: 2, doc: "dog" + variant -> { String }, doc: "dawg" + end + + def test_meta_retrieval + m1 = A1.instance_variable_get(:@meta) + m2 = H1.instance_variable_get(:@meta) + assert_equal({doc: "dog"}, m1) + assert_equal({doc: "dawg"}, m2) + + ma, mb = M1.fields.fetch_values(:a, :b) + assert_equal({doc: "dog"}, ma.fetch(:meta)) + assert_equal({doc: "dawg"}, mb.fetch(:meta)) + + ua, ub = U1.send(:known_variants).map(&:last) + assert_equal({doc: "dog"}, ua) + assert_equal({doc: "dawg"}, ub) + end +end diff --git a/test/imagekitio/internal/util_test.rb b/test/imagekitio/internal/util_test.rb new file mode 100644 index 00000000..976d5b0b --- /dev/null +++ b/test/imagekitio/internal/util_test.rb @@ -0,0 +1,673 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::UtilDataHandlingTest < Minitest::Test + def test_left_map + assert_pattern do + Imagekitio::Internal::Util.deep_merge({a: 1}, nil) => nil + end + end + + def test_right_map + assert_pattern do + Imagekitio::Internal::Util.deep_merge(nil, {a: 1}) => {a: 1} + end + end + + def test_disjoint_maps + assert_pattern do + Imagekitio::Internal::Util.deep_merge({b: 2}, {a: 1}) => {a: 1, b: 2} + end + end + + def test_overlapping_maps + assert_pattern do + Imagekitio::Internal::Util.deep_merge({b: 2, c: 3}, {a: 1, c: 4}) => {a: 1, b: 2, c: 4} + end + end + + def test_nested + assert_pattern do + Imagekitio::Internal::Util.deep_merge({b: {b2: 1}}, {b: {b2: 2}}) => {b: {b2: 2}} + end + end + + def test_nested_left_map + assert_pattern do + Imagekitio::Internal::Util.deep_merge({b: {b2: 1}}, {b: 6}) => {b: 6} + end + end + + def test_omission + merged = Imagekitio::Internal::Util.deep_merge( + {b: {b2: 1, b3: {c: 4, d: 5}}}, + {b: {b2: 1, b3: {c: Imagekitio::Internal::OMIT, d: 5}}} + ) + + assert_pattern do + merged => {b: {b2: 1, b3: {d: 5}}} + end + end + + def test_concat + merged = Imagekitio::Internal::Util.deep_merge( + {a: {b: [1, 2]}}, + {a: {b: [3, 4]}}, + concat: true + ) + + assert_pattern do + merged => {a: {b: [1, 2, 3, 4]}} + end + end + + def test_concat_false + merged = Imagekitio::Internal::Util.deep_merge( + {a: {b: [1, 2]}}, + {a: {b: [3, 4]}}, + concat: false + ) + + assert_pattern do + merged => {a: {b: [3, 4]}} + end + end + + def test_dig + assert_pattern do + Imagekitio::Internal::Util.dig(1, nil) => 1 + Imagekitio::Internal::Util.dig({a: 1}, :b) => nil + Imagekitio::Internal::Util.dig({a: 1}, :a) => 1 + Imagekitio::Internal::Util.dig({a: {b: 1}}, [:a, :b]) => 1 + + Imagekitio::Internal::Util.dig([], 1) => nil + Imagekitio::Internal::Util.dig([nil, [nil, 1]], [1, 1]) => 1 + Imagekitio::Internal::Util.dig({a: [nil, 1]}, [:a, 1]) => 1 + Imagekitio::Internal::Util.dig([], 1.0) => nil + + Imagekitio::Internal::Util.dig(Object, 1) => nil + Imagekitio::Internal::Util.dig([], 1.0) { 2 } => 2 + Imagekitio::Internal::Util.dig([], ->(_) { 2 }) => 2 + Imagekitio::Internal::Util.dig([1], -> { _1 in [1] }) => true + end + end +end + +class Imagekitio::Test::UtilUriHandlingTest < Minitest::Test + def test_parsing + %w[ + http://example.com + https://example.com/ + https://example.com:443/example?e1=e1&e2=e2&e= + ].each do |url| + parsed = Imagekitio::Internal::Util.parse_uri(url) + unparsed = Imagekitio::Internal::Util.unparse_uri(parsed).to_s + + assert_equal(url, unparsed) + assert_equal(parsed, Imagekitio::Internal::Util.parse_uri(unparsed)) + end + end + + def test_joining + cases = [ + [ + "h://a.b/c?d=e", + "h://nope/ignored", + Imagekitio::Internal::Util.parse_uri("h://a.b/c?d=e") + ], + [ + "h://a.b/c?d=e", + "h://nope", + { + host: "a.b", + path: "/c", + query: {"d" => ["e"]} + } + ], + [ + "h://a.b/c?d=e", + "h://nope", + { + path: "h://a.b/c", + query: {"d" => ["e"]} + } + ] + ] + + cases.each do |expect, lhs, rhs| + assert_equal( + URI.parse(expect), + Imagekitio::Internal::Util.join_parsed_uri( + Imagekitio::Internal::Util.parse_uri(lhs), + rhs + ) + ) + end + end + + def test_joining_queries + base_url = "h://a.b/c?d=e" + cases = { + "c2" => "h://a.b/c/c2", + "/c2?f=g" => "h://a.b/c2?f=g", + "/c?f=g" => "h://a.b/c?d=e&f=g" + } + + cases.each do |path, expected| + assert_equal( + URI.parse(expected), + Imagekitio::Internal::Util.join_parsed_uri( + Imagekitio::Internal::Util.parse_uri(base_url), + {path: path} + ) + ) + end + end +end + +class Imagekitio::Test::RegexMatchTest < Minitest::Test + def test_json_content + cases = { + "application/json" => true, + "application/jsonl" => false, + "application/vnd.github.v3+json" => true, + "application/vnd.api+json" => true + } + cases.each do |header, verdict| + assert_pattern do + Imagekitio::Internal::Util::JSON_CONTENT.match?(header) => ^verdict + end + end + end + + def test_jsonl_content + cases = { + "application/x-ndjson" => true, + "application/x-ldjson" => true, + "application/jsonl" => true, + "application/x-jsonl" => true, + "application/json" => false, + "application/vnd.api+json" => false + } + cases.each do |header, verdict| + assert_pattern do + Imagekitio::Internal::Util::JSONL_CONTENT.match?(header) => ^verdict + end + end + end +end + +class Imagekitio::Test::UtilFormDataEncodingTest < Minitest::Test + class FakeCGI < CGI + def initialize(headers, io) + encoded = io.to_a + @ctype = headers["content-type"] + # rubocop:disable Lint/EmptyBlock + @io = Imagekitio::Internal::Util::ReadIOAdapter.new(encoded.to_enum) {} + # rubocop:enable Lint/EmptyBlock + @c_len = encoded.join.bytesize.to_s + super() + end + + def stdinput = @io + + def env_table + { + "REQUEST_METHOD" => "POST", + "CONTENT_TYPE" => @ctype, + "CONTENT_LENGTH" => @c_len + } + end + end + + def test_encoding_length + headers, = Imagekitio::Internal::Util.encode_content( + {"content-type" => "multipart/form-data"}, + Pathname(__FILE__) + ) + assert_pattern do + headers.fetch("content-type") => /boundary=(.+)$/ + end + field, = Regexp.last_match.captures + assert(field.length < 70 - 6) + end + + def test_file_encode + file = Pathname(__FILE__) + fileinput = Imagekitio::Internal::Type::Converter.dump(Imagekitio::Internal::Type::FileInput, "abc") + headers = {"content-type" => "multipart/form-data"} + cases = { + "abc" => ["", "abc"], + StringIO.new("abc") => ["", "abc"], + fileinput => %w[upload abc], + Imagekitio::FilePart.new(StringIO.new("abc")) => ["", "abc"], + file => [file.basename.to_path, /^class Imagekitio/], + Imagekitio::FilePart.new(file, filename: "d o g") => ["d%20o%20g", /^class Imagekitio/] + } + cases.each do |body, testcase| + filename, val = testcase + encoded = Imagekitio::Internal::Util.encode_content(headers, body) + cgi = FakeCGI.new(*encoded) + io = cgi[""] + assert_pattern do + io.original_filename => ^filename + io.read => ^val + end + end + end + + def test_hash_encode + headers = {"content-type" => "multipart/form-data"} + cases = { + {a: 2, b: 3} => {"a" => "2", "b" => "3"}, + {a: 2, b: nil} => {"a" => "2", "b" => "null"}, + {a: 2, b: [1, 2, 3]} => {"a" => "2", "b" => "1"}, + {strio: StringIO.new("a")} => {"strio" => "a"}, + {strio: Imagekitio::FilePart.new("a")} => {"strio" => "a"}, + {pathname: Pathname(__FILE__)} => {"pathname" => -> { _1.read in /^class Imagekitio/ }}, + {pathname: Imagekitio::FilePart.new(Pathname(__FILE__))} => {"pathname" => -> { _1.read in /^class Imagekitio/ }} + } + cases.each do |body, testcase| + encoded = Imagekitio::Internal::Util.encode_content(headers, body) + cgi = FakeCGI.new(*encoded) + testcase.each do |key, val| + assert_pattern do + parsed = + case (p = cgi[key]) + in StringIO + p.read + else + p + end + parsed => ^val + end + end + end + end +end + +class Imagekitio::Test::UtilIOAdapterTest < Minitest::Test + def test_copy_read + cases = { + StringIO.new("abc") => "abc", + Enumerator.new { _1 << "abc" } => "abc" + } + cases.each do |input, expected| + io = StringIO.new + # rubocop:disable Lint/EmptyBlock + adapter = Imagekitio::Internal::Util::ReadIOAdapter.new(input) {} + # rubocop:enable Lint/EmptyBlock + IO.copy_stream(adapter, io) + assert_equal(expected, io.string) + end + end + + def test_copy_write + cases = { + StringIO.new => "", + StringIO.new("abc") => "abc" + } + cases.each do |input, expected| + enum = Imagekitio::Internal::Util.writable_enum do |y| + IO.copy_stream(input, y) + end + assert_equal(expected, enum.to_a.join) + end + end +end + +class Imagekitio::Test::UtilFusedEnumTest < Minitest::Test + def test_rewind_closing + touched = false + once = 0 + steps = 0 + enum = Enumerator.new do |y| + next if touched + + 10.times do + steps = _1 + y << _1 + end + ensure + once = once.succ + end + + fused = Imagekitio::Internal::Util.fused_enum(enum, external: true) do + touched = true + loop { enum.next } + end + Imagekitio::Internal::Util.close_fused!(fused) + + assert_equal(1, once) + assert_equal(0, steps) + end + + def test_thread_interrupts + once = 0 + que = Queue.new + enum = Enumerator.new do |y| + 10.times { y << _1 } + ensure + once = once.succ + end + + fused_1 = Imagekitio::Internal::Util.fused_enum(enum, external: true) { loop { enum.next } } + fused_2 = Imagekitio::Internal::Util.chain_fused(fused_1) { fused_1.each(&_1) } + fused_3 = Imagekitio::Internal::Util.chain_fused(fused_2) { fused_2.each(&_1) } + + th = ::Thread.new do + que << "🐶" + fused_3.each { sleep(10) } + end + + assert_equal("🐶", que.pop) + th.kill.join + assert_equal(1, once) + end + + def test_closing + arr = [1, 2, 3] + once = 0 + fused = Imagekitio::Internal::Util.fused_enum(arr.to_enum) do + once = once.succ + end + + enumerated_1 = fused.to_a + assert_equal(arr, enumerated_1) + assert_equal(1, once) + + enumerated_2 = fused.to_a + assert_equal([], enumerated_2) + assert_equal(1, once) + end + + def test_rewind_chain + once = 0 + fused = Imagekitio::Internal::Util.fused_enum([1, 2, 3].to_enum) do + once = once.succ + end + .lazy + .map(&:succ) + .filter(&:odd?) + first = fused.next + + assert_equal(3, first) + assert_equal(0, once) + assert_raises(StopIteration) { fused.rewind.next } + assert_equal(1, once) + end + + def test_external_iteration + iter = [1, 2, 3].to_enum + first = iter.next + fused = Imagekitio::Internal::Util.fused_enum(iter, external: true) + + assert_equal(1, first) + assert_equal([2, 3], fused.to_a) + end + + def test_close_fused + once = 0 + fused = Imagekitio::Internal::Util.fused_enum([1, 2, 3].to_enum) do + once = once.succ + end + + Imagekitio::Internal::Util.close_fused!(fused) + + assert_equal(1, once) + assert_equal([], fused.to_a) + assert_equal(1, once) + end + + def test_closed_fused_extern_iteration + taken = 0 + enum = [1, 2, 3].to_enum.lazy.map do + taken = taken.succ + _1 + end + fused = Imagekitio::Internal::Util.fused_enum(enum) + first = fused.next + + assert_equal(1, first) + Imagekitio::Internal::Util.close_fused!(fused) + assert_equal(1, taken) + end + + def test_closed_fused_taken_count + taken = 0 + enum = [1, 2, 3].to_enum.lazy.map do + taken = taken.succ + _1 + end + .map(&:succ) + .filter(&:odd?) + fused = Imagekitio::Internal::Util.fused_enum(enum) + + assert_equal(0, taken) + Imagekitio::Internal::Util.close_fused!(fused) + assert_equal(0, taken) + end + + def test_closed_fused_extern_iter_taken_count + taken = 0 + enum = [1, 2, 3].to_enum.lazy.map do + taken = taken.succ + _1 + end + .map(&:succ) + .filter(&:itself) + first = enum.next + assert_equal(2, first) + assert_equal(1, taken) + + fused = Imagekitio::Internal::Util.fused_enum(enum) + Imagekitio::Internal::Util.close_fused!(fused) + assert_equal(1, taken) + end + + def test_close_fused_sse_chain + taken = 0 + enum = [1, 2, 3].to_enum.lazy.map do + taken = taken.succ + _1 + end + .map(&:succ) + .filter(&:odd?) + .map(&:to_s) + + fused_1 = Imagekitio::Internal::Util.fused_enum(enum) + fused_2 = Imagekitio::Internal::Util.decode_lines(fused_1) + fused_3 = Imagekitio::Internal::Util.decode_sse(fused_2) + + assert_equal(0, taken) + Imagekitio::Internal::Util.close_fused!(fused_3) + assert_equal(0, taken) + end +end + +class Imagekitio::Test::UtilContentDecodingTest < Minitest::Test + def test_charset + cases = { + "application/json" => Encoding::BINARY, + "application/json; charset=utf-8" => Encoding::UTF_8, + "charset=uTf-8 application/json; " => Encoding::UTF_8, + "charset=UTF-8; application/json; " => Encoding::UTF_8, + "charset=ISO-8859-1 ;application/json; " => Encoding::ISO_8859_1, + "charset=EUC-KR ;application/json; " => Encoding::EUC_KR + } + text = String.new.force_encoding(Encoding::BINARY) + cases.each do |content_type, encoding| + Imagekitio::Internal::Util.force_charset!(content_type, text: text) + assert_equal(encoding, text.encoding) + end + end +end + +class Imagekitio::Test::UtilSseTest < Minitest::Test + def test_decode_lines + cases = { + %w[] => %w[], + %W[\n\n] => %W[\n \n], + %W[\n \n] => %W[\n \n], + %w[a] => %w[a], + %W[a\nb] => %W[a\n b], + %W[a\nb\n] => %W[a\n b\n], + %W[\na b\n] => %W[\n ab\n], + %W[\na b\n\n] => %W[\n ab\n \n], + %W[\na b] => %W[\n ab], + %W[\u1F62E\u200D\u1F4A8] => %W[\u1F62E\u200D\u1F4A8], + %W[\u1F62E \u200D \u1F4A8] => %W[\u1F62E\u200D\u1F4A8], + ["\xf0\x9f".b, "\xa5\xba".b] => ["\xf0\x9f\xa5\xba".b], + ["\xf0".b, "\x9f".b, "\xa5".b, "\xba".b] => ["\xf0\x9f\xa5\xba".b] + } + eols = %W[\n \r \r\n] + cases.each do |enum, expected| + eols.each do |eol| + lines = Imagekitio::Internal::Util.decode_lines(enum.map { _1.gsub("\n", eol) }) + assert_equal(expected.map { _1.gsub("\n", eol) }, lines.to_a, "eol=#{JSON.generate(eol)}") + end + end + end + + def test_mixed_decode_lines + cases = { + %w[] => %w[], + %W[\r\r] => %W[\r \r], + %W[\r \r] => %W[\r \r], + %W[\r\r\r] => %W[\r \r \r], + %W[\r\r \r] => %W[\r \r \r], + %W[\r \n] => %W[\r\n], + %W[\r\r\n] => %W[\r \r\n], + %W[\n\r] => %W[\n \r] + } + cases.each do |enum, expected| + lines = Imagekitio::Internal::Util.decode_lines(enum) + assert_equal(expected, lines.to_a) + end + end + + def test_decode_sse + cases = { + "empty input" => { + [] => [] + }, + "single data event" => { + [ + "data: hello world\n", + "\n" + ] => [ + {data: "hello world\n"} + ] + }, + "multiple data lines" => { + [ + "data: line 1\n", + "data: line 2\n", + "\n" + ] => [ + {data: "line 1\nline 2\n"} + ] + }, + "complete event" => { + [ + "id: 123\n", + "event: update\n", + "data: hello world\n", + "retry: 5000\n", + "\n" + ] => [ + { + event: "update", + id: "123", + data: "hello world\n", + retry: 5000 + } + ] + }, + "multiple events" => { + [ + "event: update\n", + "data: first\n", + "\n", + "event: message\n", + "data: second\n", + "\n" + ] => [ + {event: "update", data: "first\n"}, + {event: "message", data: "second\n"} + ] + }, + "comments" => { + [ + ": this is a comment\n", + "data: actual data\n", + "\n" + ] => [ + {data: "actual data\n"} + ] + }, + "invalid retry" => { + [ + "retry: not a number\n", + "data: hello\n", + "\n" + ] => [ + {data: "hello\n"} + ] + }, + "invalid id with null" => { + [ + "id: bad\0id\n", + "data: hello\n", + "\n" + ] => [ + {data: "hello\n"} + ] + }, + "leading space in value" => { + [ + "data: hello world\n", + "data: leading space\n", + "\n" + ] => [ + {data: "hello world\n leading space\n"} + ] + }, + "no final newline" => { + [ + "data: hello\n", + "id: 1" + ] => [ + {data: "hello\n", id: "1"} + ] + }, + "multiple empty lines" => { + [ + "data: first\n", + "\n", + "\n", + "data: second\n", + "\n" + ] => [ + {data: "first\n"}, + {data: "second\n"} + ] + }, + "multibyte unicode" => { + [ + "data: \u1F62E\u200D\u1F4A8\n" + ] => [ + {data: "\u1F62E\u200D\u1F4A8\n"} + ] + } + } + + cases.each do |name, test_cases| + test_cases.each do |input, expected| + actual = Imagekitio::Internal::Util.decode_sse(input).map(&:compact) + assert_equal(expected, actual, name) + end + end + end +end diff --git a/test/imagekitio/resource_namespaces.rb b/test/imagekitio/resource_namespaces.rb new file mode 100644 index 00000000..59132586 --- /dev/null +++ b/test/imagekitio/resource_namespaces.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Imagekitio + module Test + module Resources + module Accounts + end + + module Beta + module V2 + end + end + + module Cache + end + + module Files + end + + module Folders + end + + module V2 + end + end + end +end diff --git a/test/imagekitio/resources/accounts/origins_test.rb b/test/imagekitio/resources/accounts/origins_test.rb new file mode 100644 index 00000000..49f7a48f --- /dev/null +++ b/test/imagekitio/resources/accounts/origins_test.rb @@ -0,0 +1,347 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::Resources::Accounts::OriginsTest < Imagekitio::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = + @image_kit.accounts.origins.create( + base_url: "https://akeneo.company.com", + client_id: "akeneo-client-id", + client_secret: "akeneo-client-secret", + name: "US S3 Storage", + password: "strongpassword123", + type: :AKENEO_PIM, + username: "integration-user" + ) + + assert_pattern do + response => Imagekitio::Accounts::OriginResponse + end + + assert_pattern do + case response + in Imagekitio::Accounts::OriginResponse::S3 + in Imagekitio::Accounts::OriginResponse::S3Compatible + in Imagekitio::Accounts::OriginResponse::CloudinaryBackup + in Imagekitio::Accounts::OriginResponse::WebFolder + in Imagekitio::Accounts::OriginResponse::WebProxy + in Imagekitio::Accounts::OriginResponse::Gcs + in Imagekitio::Accounts::OriginResponse::AzureBlob + in Imagekitio::Accounts::OriginResponse::AkeneoPim + end + end + + assert_pattern do + case response + in { + type: :S3, + id: String, + bucket: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :S3_COMPATIBLE, + id: String, + bucket: String, + endpoint: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + s3_force_path_style: Imagekitio::Internal::Type::Boolean, + base_url_for_canonical_header: String | nil + } + in { + type: :CLOUDINARY_BACKUP, + id: String, + bucket: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_FOLDER, + id: String, + base_url: String, + forward_host_header_to_origin: Imagekitio::Internal::Type::Boolean, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_PROXY, + id: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :GCS, + id: String, + bucket: String, + client_email: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AZURE_BLOB, + id: String, + account_name: String, + container: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AKENEO_PIM, + id: String, + base_url: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + end + end + end + + def test_update_required_params + skip("Prism tests are disabled") + + response = + @image_kit.accounts.origins.update( + "id", + base_url: "https://akeneo.company.com", + client_id: "akeneo-client-id", + client_secret: "akeneo-client-secret", + name: "US S3 Storage", + password: "strongpassword123", + type: :AKENEO_PIM, + username: "integration-user" + ) + + assert_pattern do + response => Imagekitio::Accounts::OriginResponse + end + + assert_pattern do + case response + in Imagekitio::Accounts::OriginResponse::S3 + in Imagekitio::Accounts::OriginResponse::S3Compatible + in Imagekitio::Accounts::OriginResponse::CloudinaryBackup + in Imagekitio::Accounts::OriginResponse::WebFolder + in Imagekitio::Accounts::OriginResponse::WebProxy + in Imagekitio::Accounts::OriginResponse::Gcs + in Imagekitio::Accounts::OriginResponse::AzureBlob + in Imagekitio::Accounts::OriginResponse::AkeneoPim + end + end + + assert_pattern do + case response + in { + type: :S3, + id: String, + bucket: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :S3_COMPATIBLE, + id: String, + bucket: String, + endpoint: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + s3_force_path_style: Imagekitio::Internal::Type::Boolean, + base_url_for_canonical_header: String | nil + } + in { + type: :CLOUDINARY_BACKUP, + id: String, + bucket: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_FOLDER, + id: String, + base_url: String, + forward_host_header_to_origin: Imagekitio::Internal::Type::Boolean, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_PROXY, + id: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :GCS, + id: String, + bucket: String, + client_email: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AZURE_BLOB, + id: String, + account_name: String, + container: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AKENEO_PIM, + id: String, + base_url: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + end + end + end + + def test_list + skip("Prism tests are disabled") + + response = @image_kit.accounts.origins.list + + assert_pattern do + response => ^(Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::Accounts::OriginResponse]) + end + end + + def test_delete + skip("Prism tests are disabled") + + response = @image_kit.accounts.origins.delete("id") + + assert_pattern do + response => nil + end + end + + def test_get + skip("Prism tests are disabled") + + response = @image_kit.accounts.origins.get("id") + + assert_pattern do + response => Imagekitio::Accounts::OriginResponse + end + + assert_pattern do + case response + in Imagekitio::Accounts::OriginResponse::S3 + in Imagekitio::Accounts::OriginResponse::S3Compatible + in Imagekitio::Accounts::OriginResponse::CloudinaryBackup + in Imagekitio::Accounts::OriginResponse::WebFolder + in Imagekitio::Accounts::OriginResponse::WebProxy + in Imagekitio::Accounts::OriginResponse::Gcs + in Imagekitio::Accounts::OriginResponse::AzureBlob + in Imagekitio::Accounts::OriginResponse::AkeneoPim + end + end + + assert_pattern do + case response + in { + type: :S3, + id: String, + bucket: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :S3_COMPATIBLE, + id: String, + bucket: String, + endpoint: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + s3_force_path_style: Imagekitio::Internal::Type::Boolean, + base_url_for_canonical_header: String | nil + } + in { + type: :CLOUDINARY_BACKUP, + id: String, + bucket: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_FOLDER, + id: String, + base_url: String, + forward_host_header_to_origin: Imagekitio::Internal::Type::Boolean, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :WEB_PROXY, + id: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + in { + type: :GCS, + id: String, + bucket: String, + client_email: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AZURE_BLOB, + id: String, + account_name: String, + container: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + prefix: String, + base_url_for_canonical_header: String | nil + } + in { + type: :AKENEO_PIM, + id: String, + base_url: String, + include_canonical_header: Imagekitio::Internal::Type::Boolean, + name: String, + base_url_for_canonical_header: String | nil + } + end + end + end +end diff --git a/test/imagekitio/resources/accounts/url_endpoints_test.rb b/test/imagekitio/resources/accounts/url_endpoints_test.rb new file mode 100644 index 00000000..fa912642 --- /dev/null +++ b/test/imagekitio/resources/accounts/url_endpoints_test.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::Resources::Accounts::URLEndpointsTest < Imagekitio::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.create(description: "My custom URL endpoint") + + assert_pattern do + response => Imagekitio::Accounts::URLEndpointResponse + end + + assert_pattern do + response => { + id: String, + description: String, + origins: ^(Imagekitio::Internal::Type::ArrayOf[String]), + url_prefix: String, + url_rewriter: Imagekitio::Accounts::URLEndpointResponse::URLRewriter | nil + } + end + end + + def test_update_required_params + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.update("id", description: "My custom URL endpoint") + + assert_pattern do + response => Imagekitio::Accounts::URLEndpointResponse + end + + assert_pattern do + response => { + id: String, + description: String, + origins: ^(Imagekitio::Internal::Type::ArrayOf[String]), + url_prefix: String, + url_rewriter: Imagekitio::Accounts::URLEndpointResponse::URLRewriter | nil + } + end + end + + def test_list + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.list + + assert_pattern do + response => ^(Imagekitio::Internal::Type::ArrayOf[Imagekitio::Accounts::URLEndpointResponse]) + end + end + + def test_delete + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.delete("id") + + assert_pattern do + response => nil + end + end + + def test_get + skip("Prism tests are disabled") + + response = @image_kit.accounts.url_endpoints.get("id") + + assert_pattern do + response => Imagekitio::Accounts::URLEndpointResponse + end + + assert_pattern do + response => { + id: String, + description: String, + origins: ^(Imagekitio::Internal::Type::ArrayOf[String]), + url_prefix: String, + url_rewriter: Imagekitio::Accounts::URLEndpointResponse::URLRewriter | nil + } + end + end +end diff --git a/test/imagekitio/resources/accounts/usage_test.rb b/test/imagekitio/resources/accounts/usage_test.rb new file mode 100644 index 00000000..f928f45c --- /dev/null +++ b/test/imagekitio/resources/accounts/usage_test.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::Resources::Accounts::UsageTest < Imagekitio::Test::ResourceTest + def test_get_required_params + skip("Prism tests are disabled") + + response = @image_kit.accounts.usage.get(end_date: "2019-12-27", start_date: "2019-12-27") + + assert_pattern do + response => Imagekitio::Models::Accounts::UsageGetResponse + end + + assert_pattern do + response => { + bandwidth_bytes: Integer | nil, + extension_units_count: Integer | nil, + media_library_storage_bytes: Integer | nil, + original_cache_storage_bytes: Integer | nil, + video_processing_units_count: Integer | nil + } + end + end +end diff --git a/test/imagekitio/resources/accounts_test.rb b/test/imagekitio/resources/accounts_test.rb new file mode 100644 index 00000000..c92620cf --- /dev/null +++ b/test/imagekitio/resources/accounts_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::Resources::AccountsTest < Imagekitio::Test::ResourceTest +end diff --git a/test/imagekitio/resources/assets_test.rb b/test/imagekitio/resources/assets_test.rb new file mode 100644 index 00000000..f4b2148c --- /dev/null +++ b/test/imagekitio/resources/assets_test.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::Resources::AssetsTest < Imagekitio::Test::ResourceTest + def test_list + skip("Prism tests are disabled") + + response = @image_kit.assets.list + + assert_pattern do + response => ^(Imagekitio::Internal::Type::ArrayOf[union: Imagekitio::Models::AssetListResponseItem]) + end + end +end diff --git a/test/imagekitio/resources/beta/v2/files_test.rb b/test/imagekitio/resources/beta/v2/files_test.rb new file mode 100644 index 00000000..640bff4e --- /dev/null +++ b/test/imagekitio/resources/beta/v2/files_test.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require_relative "../../../test_helper" + +class Imagekitio::Test::Resources::Beta::V2::FilesTest < Imagekitio::Test::ResourceTest + def test_upload_required_params + skip("Prism tests are disabled") + + response = @image_kit.beta.v2.files.upload(file: Pathname(__FILE__), file_name: "fileName") + + assert_pattern do + response => Imagekitio::Models::Beta::V2::FileUploadResponse + end + + assert_pattern do + response => { + ai_tags: ^(Imagekitio::Internal::Type::ArrayOf[Imagekitio::Models::Beta::V2::FileUploadResponse::AITag]) | nil, + audio_codec: String | nil, + bit_rate: Integer | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown]) | nil, + description: String | nil, + duration: Integer | nil, + embedded_metadata: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown]) | nil, + extension_status: Imagekitio::Models::Beta::V2::FileUploadResponse::ExtensionStatus | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + height: Float | nil, + is_private_file: Imagekitio::Internal::Type::Boolean | nil, + is_published: Imagekitio::Internal::Type::Boolean | nil, + metadata: Imagekitio::Metadata | nil, + name: String | nil, + selected_fields_schema: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::Models::Beta::V2::FileUploadResponse::SelectedFieldsSchema]) | nil, + size: Float | nil, + tags: ^(Imagekitio::Internal::Type::ArrayOf[String]) | nil, + thumbnail_url: String | nil, + url: String | nil, + version_info: Imagekitio::Models::Beta::V2::FileUploadResponse::VersionInfo | nil, + video_codec: String | nil, + width: Float | nil + } + end + end +end diff --git a/test/imagekitio/resources/beta/v2_test.rb b/test/imagekitio/resources/beta/v2_test.rb new file mode 100644 index 00000000..16e52867 --- /dev/null +++ b/test/imagekitio/resources/beta/v2_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::Resources::Beta::V2Test < Imagekitio::Test::ResourceTest +end diff --git a/test/imagekitio/resources/beta_test.rb b/test/imagekitio/resources/beta_test.rb new file mode 100644 index 00000000..bdd0a2cd --- /dev/null +++ b/test/imagekitio/resources/beta_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::Resources::BetaTest < Imagekitio::Test::ResourceTest +end diff --git a/test/imagekitio/resources/cache/invalidation_test.rb b/test/imagekitio/resources/cache/invalidation_test.rb new file mode 100644 index 00000000..2d29a047 --- /dev/null +++ b/test/imagekitio/resources/cache/invalidation_test.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::Resources::Cache::InvalidationTest < Imagekitio::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = + @image_kit.cache.invalidation.create(url: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + + assert_pattern do + response => Imagekitio::Models::Cache::InvalidationCreateResponse + end + + assert_pattern do + response => { + request_id: String | nil + } + end + end + + def test_get + skip("Prism tests are disabled") + + response = @image_kit.cache.invalidation.get("requestId") + + assert_pattern do + response => Imagekitio::Models::Cache::InvalidationGetResponse + end + + assert_pattern do + response => { + status: Imagekitio::Models::Cache::InvalidationGetResponse::Status | nil + } + end + end +end diff --git a/test/imagekitio/resources/cache_test.rb b/test/imagekitio/resources/cache_test.rb new file mode 100644 index 00000000..4cfa1044 --- /dev/null +++ b/test/imagekitio/resources/cache_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::Resources::CacheTest < Imagekitio::Test::ResourceTest +end diff --git a/test/imagekitio/resources/custom_metadata_fields_test.rb b/test/imagekitio/resources/custom_metadata_fields_test.rb new file mode 100644 index 00000000..fcddba86 --- /dev/null +++ b/test/imagekitio/resources/custom_metadata_fields_test.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::Resources::CustomMetadataFieldsTest < Imagekitio::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = + @image_kit.custom_metadata_fields.create(label: "price", name: "price", schema: {type: :Number}) + + assert_pattern do + response => Imagekitio::CustomMetadataField + end + + assert_pattern do + response => { + id: String, + label: String, + name: String, + schema: Imagekitio::CustomMetadataField::Schema + } + end + end + + def test_update + skip("Prism tests are disabled") + + response = @image_kit.custom_metadata_fields.update("id") + + assert_pattern do + response => Imagekitio::CustomMetadataField + end + + assert_pattern do + response => { + id: String, + label: String, + name: String, + schema: Imagekitio::CustomMetadataField::Schema + } + end + end + + def test_list + skip("Prism tests are disabled") + + response = @image_kit.custom_metadata_fields.list + + assert_pattern do + response => ^(Imagekitio::Internal::Type::ArrayOf[Imagekitio::CustomMetadataField]) + end + end + + def test_delete + skip("Prism tests are disabled") + + response = @image_kit.custom_metadata_fields.delete("id") + + assert_pattern do + response => Imagekitio::Models::CustomMetadataFieldDeleteResponse + end + + assert_pattern do + response => { + **_ + } + end + end +end diff --git a/test/imagekitio/resources/files/bulk_test.rb b/test/imagekitio/resources/files/bulk_test.rb new file mode 100644 index 00000000..56991d88 --- /dev/null +++ b/test/imagekitio/resources/files/bulk_test.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::Resources::Files::BulkTest < Imagekitio::Test::ResourceTest + def test_delete_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.bulk.delete(file_ids: %w[598821f949c0a938d57563bd 598821f949c0a938d57563be]) + + assert_pattern do + response => Imagekitio::Models::Files::BulkDeleteResponse + end + + assert_pattern do + response => { + successfully_deleted_file_ids: ^(Imagekitio::Internal::Type::ArrayOf[String]) | nil + } + end + end + + def test_add_tags_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.bulk.add_tags( + file_ids: %w[598821f949c0a938d57563bd 598821f949c0a938d57563be], + tags: %w[t-shirt round-neck sale2019] + ) + + assert_pattern do + response => Imagekitio::Models::Files::BulkAddTagsResponse + end + + assert_pattern do + response => { + successfully_updated_file_ids: ^(Imagekitio::Internal::Type::ArrayOf[String]) | nil + } + end + end + + def test_remove_ai_tags_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.bulk.remove_ai_tags( + ai_tags: %w[t-shirt round-neck sale2019], + file_ids: %w[598821f949c0a938d57563bd 598821f949c0a938d57563be] + ) + + assert_pattern do + response => Imagekitio::Models::Files::BulkRemoveAITagsResponse + end + + assert_pattern do + response => { + successfully_updated_file_ids: ^(Imagekitio::Internal::Type::ArrayOf[String]) | nil + } + end + end + + def test_remove_tags_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.bulk.remove_tags( + file_ids: %w[598821f949c0a938d57563bd 598821f949c0a938d57563be], + tags: %w[t-shirt round-neck sale2019] + ) + + assert_pattern do + response => Imagekitio::Models::Files::BulkRemoveTagsResponse + end + + assert_pattern do + response => { + successfully_updated_file_ids: ^(Imagekitio::Internal::Type::ArrayOf[String]) | nil + } + end + end +end diff --git a/test/imagekitio/resources/files/metadata_test.rb b/test/imagekitio/resources/files/metadata_test.rb new file mode 100644 index 00000000..ce2626ce --- /dev/null +++ b/test/imagekitio/resources/files/metadata_test.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::Resources::Files::MetadataTest < Imagekitio::Test::ResourceTest + def test_get + skip("Prism tests are disabled") + + response = @image_kit.files.metadata.get("fileId") + + assert_pattern do + response => Imagekitio::Metadata + end + + assert_pattern do + response => { + audio_codec: String | nil, + bit_rate: Integer | nil, + density: Integer | nil, + duration: Integer | nil, + exif: Imagekitio::Metadata::Exif | nil, + format_: String | nil, + has_color_profile: Imagekitio::Internal::Type::Boolean | nil, + has_transparency: Imagekitio::Internal::Type::Boolean | nil, + height: Integer | nil, + p_hash: String | nil, + quality: Integer | nil, + size: Integer | nil, + video_codec: String | nil, + width: Integer | nil + } + end + end + + def test_get_from_url_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.metadata.get_from_url(url: "https://example.com") + + assert_pattern do + response => Imagekitio::Metadata + end + + assert_pattern do + response => { + audio_codec: String | nil, + bit_rate: Integer | nil, + density: Integer | nil, + duration: Integer | nil, + exif: Imagekitio::Metadata::Exif | nil, + format_: String | nil, + has_color_profile: Imagekitio::Internal::Type::Boolean | nil, + has_transparency: Imagekitio::Internal::Type::Boolean | nil, + height: Integer | nil, + p_hash: String | nil, + quality: Integer | nil, + size: Integer | nil, + video_codec: String | nil, + width: Integer | nil + } + end + end +end diff --git a/test/imagekitio/resources/files/versions_test.rb b/test/imagekitio/resources/files/versions_test.rb new file mode 100644 index 00000000..87eb6878 --- /dev/null +++ b/test/imagekitio/resources/files/versions_test.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::Resources::Files::VersionsTest < Imagekitio::Test::ResourceTest + def test_list + skip("Prism tests are disabled") + + response = @image_kit.files.versions.list("fileId") + + assert_pattern do + response => ^(Imagekitio::Internal::Type::ArrayOf[Imagekitio::File]) + end + end + + def test_delete_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.versions.delete("versionId", file_id: "fileId") + + assert_pattern do + response => Imagekitio::Models::Files::VersionDeleteResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_get_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.versions.get("versionId", file_id: "fileId") + + assert_pattern do + response => Imagekitio::File + end + + assert_pattern do + response => { + ai_tags: ^(Imagekitio::Internal::Type::ArrayOf[Imagekitio::File::AITag]) | nil, + created_at: Time | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown]) | nil, + description: String | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + has_alpha: Imagekitio::Internal::Type::Boolean | nil, + height: Float | nil, + is_private_file: Imagekitio::Internal::Type::Boolean | nil, + is_published: Imagekitio::Internal::Type::Boolean | nil, + mime: String | nil, + name: String | nil, + selected_fields_schema: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::File::SelectedFieldsSchema]) | nil, + size: Float | nil, + tags: ^(Imagekitio::Internal::Type::ArrayOf[String]) | nil, + thumbnail: String | nil, + type: Imagekitio::File::Type | nil, + updated_at: Time | nil, + url: String | nil, + version_info: Imagekitio::File::VersionInfo | nil, + width: Float | nil + } + end + end + + def test_restore_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.versions.restore("versionId", file_id: "fileId") + + assert_pattern do + response => Imagekitio::File + end + + assert_pattern do + response => { + ai_tags: ^(Imagekitio::Internal::Type::ArrayOf[Imagekitio::File::AITag]) | nil, + created_at: Time | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown]) | nil, + description: String | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + has_alpha: Imagekitio::Internal::Type::Boolean | nil, + height: Float | nil, + is_private_file: Imagekitio::Internal::Type::Boolean | nil, + is_published: Imagekitio::Internal::Type::Boolean | nil, + mime: String | nil, + name: String | nil, + selected_fields_schema: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::File::SelectedFieldsSchema]) | nil, + size: Float | nil, + tags: ^(Imagekitio::Internal::Type::ArrayOf[String]) | nil, + thumbnail: String | nil, + type: Imagekitio::File::Type | nil, + updated_at: Time | nil, + url: String | nil, + version_info: Imagekitio::File::VersionInfo | nil, + width: Float | nil + } + end + end +end diff --git a/test/imagekitio/resources/files_test.rb b/test/imagekitio/resources/files_test.rb new file mode 100644 index 00000000..21b9d8b1 --- /dev/null +++ b/test/imagekitio/resources/files_test.rb @@ -0,0 +1,153 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::Resources::FilesTest < Imagekitio::Test::ResourceTest + def test_update + skip("Prism tests are disabled") + + response = @image_kit.files.update("fileId") + + assert_pattern do + response => Imagekitio::Models::FileUpdateResponse + end + end + + def test_delete + skip("Prism tests are disabled") + + response = @image_kit.files.delete("fileId") + + assert_pattern do + response => nil + end + end + + def test_copy_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.copy(destination_path: "/folder/to/copy/into/", source_file_path: "/path/to/file.jpg") + + assert_pattern do + response => Imagekitio::Models::FileCopyResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_get + skip("Prism tests are disabled") + + response = @image_kit.files.get("fileId") + + assert_pattern do + response => Imagekitio::File + end + + assert_pattern do + response => { + ai_tags: ^(Imagekitio::Internal::Type::ArrayOf[Imagekitio::File::AITag]) | nil, + created_at: Time | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown]) | nil, + description: String | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + has_alpha: Imagekitio::Internal::Type::Boolean | nil, + height: Float | nil, + is_private_file: Imagekitio::Internal::Type::Boolean | nil, + is_published: Imagekitio::Internal::Type::Boolean | nil, + mime: String | nil, + name: String | nil, + selected_fields_schema: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::File::SelectedFieldsSchema]) | nil, + size: Float | nil, + tags: ^(Imagekitio::Internal::Type::ArrayOf[String]) | nil, + thumbnail: String | nil, + type: Imagekitio::File::Type | nil, + updated_at: Time | nil, + url: String | nil, + version_info: Imagekitio::File::VersionInfo | nil, + width: Float | nil + } + end + end + + def test_move_required_params + skip("Prism tests are disabled") + + response = + @image_kit.files.move(destination_path: "/folder/to/move/into/", source_file_path: "/path/to/file.jpg") + + assert_pattern do + response => Imagekitio::Models::FileMoveResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_rename_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.rename(file_path: "/path/to/file.jpg", new_file_name: "newFileName.jpg") + + assert_pattern do + response => Imagekitio::Models::FileRenameResponse + end + + assert_pattern do + response => { + purge_request_id: String | nil + } + end + end + + def test_upload_required_params + skip("Prism tests are disabled") + + response = @image_kit.files.upload(file: Pathname(__FILE__), file_name: "fileName") + + assert_pattern do + response => Imagekitio::Models::FileUploadResponse + end + + assert_pattern do + response => { + ai_tags: ^(Imagekitio::Internal::Type::ArrayOf[Imagekitio::Models::FileUploadResponse::AITag]) | nil, + audio_codec: String | nil, + bit_rate: Integer | nil, + custom_coordinates: String | nil, + custom_metadata: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown]) | nil, + description: String | nil, + duration: Integer | nil, + embedded_metadata: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::Internal::Type::Unknown]) | nil, + extension_status: Imagekitio::Models::FileUploadResponse::ExtensionStatus | nil, + file_id: String | nil, + file_path: String | nil, + file_type: String | nil, + height: Float | nil, + is_private_file: Imagekitio::Internal::Type::Boolean | nil, + is_published: Imagekitio::Internal::Type::Boolean | nil, + metadata: Imagekitio::Metadata | nil, + name: String | nil, + selected_fields_schema: ^(Imagekitio::Internal::Type::HashOf[Imagekitio::Models::FileUploadResponse::SelectedFieldsSchema]) | nil, + size: Float | nil, + tags: ^(Imagekitio::Internal::Type::ArrayOf[String]) | nil, + thumbnail_url: String | nil, + url: String | nil, + version_info: Imagekitio::Models::FileUploadResponse::VersionInfo | nil, + video_codec: String | nil, + width: Float | nil + } + end + end +end diff --git a/test/imagekitio/resources/folders/job_test.rb b/test/imagekitio/resources/folders/job_test.rb new file mode 100644 index 00000000..810a3c21 --- /dev/null +++ b/test/imagekitio/resources/folders/job_test.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require_relative "../../test_helper" + +class Imagekitio::Test::Resources::Folders::JobTest < Imagekitio::Test::ResourceTest + def test_get + skip("Prism tests are disabled") + + response = @image_kit.folders.job.get("jobId") + + assert_pattern do + response => Imagekitio::Models::Folders::JobGetResponse + end + + assert_pattern do + response => { + job_id: String | nil, + purge_request_id: String | nil, + status: Imagekitio::Models::Folders::JobGetResponse::Status | nil, + type: Imagekitio::Models::Folders::JobGetResponse::Type | nil + } + end + end +end diff --git a/test/imagekitio/resources/folders_test.rb b/test/imagekitio/resources/folders_test.rb new file mode 100644 index 00000000..eb4097a4 --- /dev/null +++ b/test/imagekitio/resources/folders_test.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::Resources::FoldersTest < Imagekitio::Test::ResourceTest + def test_create_required_params + skip("Prism tests are disabled") + + response = @image_kit.folders.create(folder_name: "summer", parent_folder_path: "/product/images/") + + assert_pattern do + response => Imagekitio::Models::FolderCreateResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_delete_required_params + skip("Prism tests are disabled") + + response = @image_kit.folders.delete(folder_path: "/folder/to/delete/") + + assert_pattern do + response => Imagekitio::Models::FolderDeleteResponse + end + + assert_pattern do + response => { + **_ + } + end + end + + def test_copy_required_params + skip("Prism tests are disabled") + + response = + @image_kit.folders.copy( + destination_path: "/path/of/destination/folder", + source_folder_path: "/path/of/source/folder" + ) + + assert_pattern do + response => Imagekitio::Models::FolderCopyResponse + end + + assert_pattern do + response => { + job_id: String + } + end + end + + def test_move_required_params + skip("Prism tests are disabled") + + response = + @image_kit.folders.move( + destination_path: "/path/of/destination/folder", + source_folder_path: "/path/of/source/folder" + ) + + assert_pattern do + response => Imagekitio::Models::FolderMoveResponse + end + + assert_pattern do + response => { + job_id: String + } + end + end + + def test_rename_required_params + skip("Prism tests are disabled") + + response = @image_kit.folders.rename(folder_path: "/path/of/folder", new_folder_name: "new-folder-name") + + assert_pattern do + response => Imagekitio::Models::FolderRenameResponse + end + + assert_pattern do + response => { + job_id: String + } + end + end +end diff --git a/test/imagekitio/resources/shared_test.rb b/test/imagekitio/resources/shared_test.rb new file mode 100644 index 00000000..b00609a9 --- /dev/null +++ b/test/imagekitio/resources/shared_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::Resources::SharedTest < Imagekitio::Test::ResourceTest +end diff --git a/test/imagekitio/resources/webhooks_test.rb b/test/imagekitio/resources/webhooks_test.rb new file mode 100644 index 00000000..b9735c0a --- /dev/null +++ b/test/imagekitio/resources/webhooks_test.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Imagekitio::Test::Resources::WebhooksTest < Imagekitio::Test::ResourceTest +end diff --git a/test/imagekitio/test_helper.rb b/test/imagekitio/test_helper.rb new file mode 100644 index 00000000..ec652736 --- /dev/null +++ b/test/imagekitio/test_helper.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true + +# Requiring this file from each test file ensures we always do the following, even +# when running a single-file test: +# - Load the whole gem (as one would in production) +# - Define shared testing namespace so that we don't need to indent test files as much +# - Setting up testing dependencies + +require "digest" +require "singleton" + +require "async" +require "minitest/autorun" +require "minitest/focus" +require "minitest/hooks/test" +require "minitest/proveit" +require "minitest/rg" +require "webmock" + +require_relative "../../lib/imagekitio" +require_relative "resource_namespaces" + +module Kernel + alias_method :_sleep, :sleep + + def sleep(secs) + case Thread.current.thread_variable_get(:mock_sleep) + in Array => counter + counter << secs + secs + else + _sleep(secs) + end + end +end + +class Time + class << self + alias_method :_now, :now + end + + def self.now = Thread.current.thread_variable_get(:time_now) || _now +end + +class Imagekitio::Test::SingletonClient < Imagekitio::Client + include Singleton + + TEST_API_BASE_URL = ENV.fetch("TEST_API_BASE_URL", "http://localhost:4010") + + def initialize + super( + base_url: Imagekitio::Test::SingletonClient::TEST_API_BASE_URL, + private_key: "My Private Key", + password: "My Password" + ) + end +end + +module Minitest::Serial + def test_order = :random + + def run_one_method(...) = Minitest::Runnable.run_one_method(...) +end + +class Minitest::Test + include Minitest::Hooks + + make_my_diffs_pretty! + parallelize_me! + prove_it! +end + +class Imagekitio::Test::ResourceTest < Minitest::Test + def async? + return @async unless @async.nil? + @async = Digest::SHA256.hexdigest(self.class.name).to_i(16).odd? + end + + def before_all + super + @image_kit = Imagekitio::Test::SingletonClient.instance + end + + def around_all = async? ? Sync { super } : super + + def around = async? ? Async { super }.wait : super +end + +module WebMock + AssertionFailure.error_class = Minitest::Assertion +end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index 0ea9cca7..00000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,20 +0,0 @@ -# Configure Rails Environment -ENV["RAILS_ENV"] = "test" - -require_relative "../test/dummy/config/environment" -ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] -require "rails/test_help" - -# Filter out the backtrace from minitest while preserving the one from other libraries. -Minitest.backtrace_filter = Minitest::BacktraceFilter.new - -require "rails/test_unit/reporter" -Rails::TestUnitReporter.executable = 'bin/test' - -# Load fixtures from the engine -if ActiveSupport::TestCase.respond_to?(:fixture_path=) - ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__) - ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path - ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files" - ActiveSupport::TestCase.fixtures :all -end