Class: Revox::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- Revox::Client
- Defined in:
- lib/revox/client.rb,
sig/revox/client.rbs
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, Internal::Transport::BaseClient::Revox
Instance Attribute Summary collapse
- #api_key ⇒ String readonly
- #assistants ⇒ Revox::Resources::Assistants readonly
- #auth_status ⇒ Revox::Resources::AuthStatus readonly
- #call ⇒ Revox::Resources::Call readonly
- #campaigns ⇒ Revox::Resources::Campaigns readonly
- #phone_numbers ⇒ Revox::Resources::PhoneNumbers readonly
- #users ⇒ Revox::Resources::Users readonly
- #voices ⇒ Revox::Resources::Voices 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
-
#initialize(api_key: ENV["REVOX_API_KEY"], base_url: ENV["REVOX_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(api_key: ENV["REVOX_API_KEY"], base_url: ENV["REVOX_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.
"https://api.example.com/v2/". Defaults to ENV["REVOX_BASE_URL"]
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/revox/client.rb', line 65 def initialize( api_key: ENV["REVOX_API_KEY"], base_url: ENV["REVOX_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 ||= "https://www.getrevox.com/api" if api_key.nil? raise ArgumentError.new("api_key is required, and can be set via environ: \"REVOX_API_KEY\"") end headers = {} custom_headers_env = ENV["REVOX_CUSTOM_HEADERS"] unless custom_headers_env.nil? parsed = {} custom_headers_env.split("\n").each do |line| colon = line.index(":") unless colon.nil? parsed[line[0...colon].strip] = line[(colon + 1)..].strip end end headers = parsed.merge(headers) end @api_key = api_key.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, headers: headers ) @auth_status = Revox::Resources::AuthStatus.new(client: self) @campaigns = Revox::Resources::Campaigns.new(client: self) @phone_numbers = Revox::Resources::PhoneNumbers.new(client: self) @assistants = Revox::Resources::Assistants.new(client: self) @call = Revox::Resources::Call.new(client: self) @voices = Revox::Resources::Voices.new(client: self) @users = Revox::Resources::Users.new(client: self) end |
Instance Attribute Details
#api_key ⇒ String (readonly)
19 20 21 |
# File 'lib/revox/client.rb', line 19 def api_key @api_key end |
#assistants ⇒ Revox::Resources::Assistants (readonly)
31 32 33 |
# File 'lib/revox/client.rb', line 31 def assistants @assistants end |
#auth_status ⇒ Revox::Resources::AuthStatus (readonly)
22 23 24 |
# File 'lib/revox/client.rb', line 22 def auth_status @auth_status end |
#call ⇒ Revox::Resources::Call (readonly)
34 35 36 |
# File 'lib/revox/client.rb', line 34 def call @call end |
#campaigns ⇒ Revox::Resources::Campaigns (readonly)
25 26 27 |
# File 'lib/revox/client.rb', line 25 def campaigns @campaigns end |
#phone_numbers ⇒ Revox::Resources::PhoneNumbers (readonly)
28 29 30 |
# File 'lib/revox/client.rb', line 28 def phone_numbers @phone_numbers end |
#users ⇒ Revox::Resources::Users (readonly)
40 41 42 |
# File 'lib/revox/client.rb', line 40 def users @users end |
#voices ⇒ Revox::Resources::Voices (readonly)
37 38 39 |
# File 'lib/revox/client.rb', line 37 def voices @voices end |