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_`).
- #saved_extensions ⇒ Imagekitio::Resources::SavedExtensions readonly
-
#webhook_secret ⇒ String?
readonly
Your ImageKit webhook secret for verifying webhook signatures (starts with ‘whsec_`).
- #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"), webhook_secret: , 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"), webhook_secret: , 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`
‘whsec_`). You can find this in the [ImageKit dashboard](imagekit.io/dashboard/developer/webhooks). Only required if you’re using webhooks. Defaults to ‘ENV`
‘“api.example.com/v2/”`. Defaults to `ENV`
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/imagekitio/client.rb', line 105 def initialize( private_key: ENV["IMAGEKIT_PRIVATE_KEY"], password: ENV.fetch("OPTIONAL_IMAGEKIT_IGNORES_THIS", "do_not_set"), webhook_secret: ENV["IMAGEKIT_WEBHOOK_SECRET"], 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 @webhook_secret = webhook_secret&.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) @saved_extensions = Imagekitio::Resources::SavedExtensions.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)
54 55 56 |
# File 'lib/imagekitio/client.rb', line 54 def accounts @accounts end |
#assets ⇒ Imagekitio::Resources::Assets (readonly)
45 46 47 |
# File 'lib/imagekitio/client.rb', line 45 def assets @assets end |
#beta ⇒ Imagekitio::Resources::Beta (readonly)
57 58 59 |
# File 'lib/imagekitio/client.rb', line 57 def beta @beta end |
#cache ⇒ Imagekitio::Resources::Cache (readonly)
48 49 50 |
# File 'lib/imagekitio/client.rb', line 48 def cache @cache end |
#custom_metadata_fields ⇒ Imagekitio::Resources::CustomMetadataFields (readonly)
36 37 38 |
# File 'lib/imagekitio/client.rb', line 36 def @custom_metadata_fields end |
#files ⇒ Imagekitio::Resources::Files (readonly)
39 40 41 |
# File 'lib/imagekitio/client.rb', line 39 def files @files end |
#folders ⇒ Imagekitio::Resources::Folders (readonly)
51 52 53 |
# File 'lib/imagekitio/client.rb', line 51 def folders @folders end |
#helper ⇒ Imagekitio::Helper (readonly)
63 64 65 |
# File 'lib/imagekitio/client.rb', line 63 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 |
#saved_extensions ⇒ Imagekitio::Resources::SavedExtensions (readonly)
42 43 44 |
# File 'lib/imagekitio/client.rb', line 42 def saved_extensions @saved_extensions end |
#webhook_secret ⇒ String? (readonly)
Your ImageKit webhook secret for verifying webhook signatures (starts with ‘whsec_`). You can find this in the [ImageKit dashboard](imagekit.io/dashboard/developer/webhooks). Only required if you’re using webhooks.
33 34 35 |
# File 'lib/imagekitio/client.rb', line 33 def webhook_secret @webhook_secret end |
#webhooks ⇒ Imagekitio::Resources::Webhooks (readonly)
60 61 62 |
# File 'lib/imagekitio/client.rb', line 60 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.
78 |
# File 'lib/imagekitio/client.rb', line 78 def base_url_overridden? = @base_url_overridden |