Class: Imagekitio::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- Imagekitio::Client
- Defined in:
- lib/imagekitio/client.rb
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
- #accounts ⇒ Imagekitio::Resources::Accounts readonly
- #assets ⇒ Imagekitio::Resources::Assets readonly
- #beta ⇒ Imagekitio::Resources::Beta readonly
- #cache ⇒ Imagekitio::Resources::Cache readonly
- #custom_metadata_fields ⇒ Imagekitio::Resources::CustomMetadataFields readonly
- #files ⇒ Imagekitio::Resources::Files readonly
- #folders ⇒ Imagekitio::Resources::Folders readonly
- #helper ⇒ Imagekitio::Helper readonly
-
#password ⇒ String?
readonly
ImageKit uses your API key as username and ignores the password.
-
#private_key ⇒ String
readonly
Your ImageKit private API key (starts with ‘private_`).
- #webhooks ⇒ Imagekitio::Resources::Webhooks readonly
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
- #base_url_overridden? ⇒ Boolean private
-
#initialize(private_key: , password: ENV.fetch("OPTIONAL_IMAGEKIT_IGNORES_THIS", "do_not_set"), 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) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(private_key: , password: ENV.fetch("OPTIONAL_IMAGEKIT_IGNORES_THIS", "do_not_set"), 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) ⇒ Client
Creates and returns a new client for interacting with the API.
[ImageKit dashboard](imagekit.io/dashboard/developer/api-keys). Defaults to ‘ENV`
dummy value. You can ignore this field. Defaults to ‘ENV`
‘“api.example.com/v2/”`. Defaults to `ENV`
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/imagekitio/client.rb', line 90 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 @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 |
Instance Attribute Details
#accounts ⇒ Imagekitio::Resources::Accounts (readonly)
44 45 46 |
# File 'lib/imagekitio/client.rb', line 44 def accounts @accounts end |
#assets ⇒ Imagekitio::Resources::Assets (readonly)
35 36 37 |
# File 'lib/imagekitio/client.rb', line 35 def assets @assets end |
#beta ⇒ Imagekitio::Resources::Beta (readonly)
47 48 49 |
# File 'lib/imagekitio/client.rb', line 47 def beta @beta end |
#cache ⇒ Imagekitio::Resources::Cache (readonly)
38 39 40 |
# File 'lib/imagekitio/client.rb', line 38 def cache @cache end |
#custom_metadata_fields ⇒ Imagekitio::Resources::CustomMetadataFields (readonly)
29 30 31 |
# File 'lib/imagekitio/client.rb', line 29 def @custom_metadata_fields end |
#files ⇒ Imagekitio::Resources::Files (readonly)
32 33 34 |
# File 'lib/imagekitio/client.rb', line 32 def files @files end |
#folders ⇒ Imagekitio::Resources::Folders (readonly)
41 42 43 |
# File 'lib/imagekitio/client.rb', line 41 def folders @folders end |
#helper ⇒ Imagekitio::Helper (readonly)
53 54 55 |
# File 'lib/imagekitio/client.rb', line 53 def helper @helper end |
#password ⇒ String? (readonly)
ImageKit uses your API key as username and ignores the password. The SDK sets a dummy value. You can ignore this field.
26 27 28 |
# File 'lib/imagekitio/client.rb', line 26 def password @password end |
#private_key ⇒ String (readonly)
Your ImageKit private API key (starts with ‘private_`). You can find this in the [ImageKit dashboard](imagekit.io/dashboard/developer/api-keys).
21 22 23 |
# File 'lib/imagekitio/client.rb', line 21 def private_key @private_key end |
#webhooks ⇒ Imagekitio::Resources::Webhooks (readonly)
50 51 52 |
# File 'lib/imagekitio/client.rb', line 50 def webhooks @webhooks end |
Instance Method Details
#base_url_overridden? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 |
# File 'lib/imagekitio/client.rb', line 68 def base_url_overridden? = @base_url_overridden |