Class: PreludeSDK::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- PreludeSDK::Client
- Defined in:
- lib/prelude_sdk/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
-
#api_token ⇒ String
readonly
Bearer token for authorizing API requests.
-
#lookup ⇒ PreludeSDK::Resources::Lookup
readonly
Retrieve detailed information about a phone number including carrier data, line type, and portability status.
-
#notify ⇒ PreludeSDK::Resources::Notify
readonly
Send transactional and marketing messages with compliance enforcement.
-
#transactional ⇒ PreludeSDK::Resources::Transactional
readonly
Send transactional messages (deprecated - use Notify API instead).
-
#verification ⇒ PreludeSDK::Resources::Verification
readonly
Verify phone numbers.
-
#verification_management ⇒ PreludeSDK::Resources::VerificationManagement
readonly
Verify phone numbers.
-
#watch ⇒ PreludeSDK::Resources::Watch
readonly
Evaluate email addresses and phone numbers for trustworthiness.
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_token: ENV["API_TOKEN"], base_url: ENV["PRELUDE_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_token: ENV["API_TOKEN"], base_url: ENV["PRELUDE_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.
‘“api.example.com/v2/”`. Defaults to `ENV`
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 111 112 113 114 |
# File 'lib/prelude_sdk/client.rb', line 70 def initialize( api_token: ENV["API_TOKEN"], base_url: ENV["PRELUDE_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://api.prelude.dev" if api_token.nil? raise ArgumentError.new("api_token is required, and can be set via environ: \"API_TOKEN\"") end headers = {} custom_headers_env = ENV["PRELUDE_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_token = api_token.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 ) @lookup = PreludeSDK::Resources::Lookup.new(client: self) @notify = PreludeSDK::Resources::Notify.new(client: self) @transactional = PreludeSDK::Resources::Transactional.new(client: self) @verification = PreludeSDK::Resources::Verification.new(client: self) @verification_management = PreludeSDK::Resources::VerificationManagement.new(client: self) @watch = PreludeSDK::Resources::Watch.new(client: self) end |
Instance Attribute Details
#api_token ⇒ String (readonly)
Bearer token for authorizing API requests.
20 21 22 |
# File 'lib/prelude_sdk/client.rb', line 20 def api_token @api_token end |
#lookup ⇒ PreludeSDK::Resources::Lookup (readonly)
Retrieve detailed information about a phone number including carrier data, line type, and portability status.
25 26 27 |
# File 'lib/prelude_sdk/client.rb', line 25 def lookup @lookup end |
#notify ⇒ PreludeSDK::Resources::Notify (readonly)
Send transactional and marketing messages with compliance enforcement.
29 30 31 |
# File 'lib/prelude_sdk/client.rb', line 29 def notify @notify end |
#transactional ⇒ PreludeSDK::Resources::Transactional (readonly)
Send transactional messages (deprecated - use Notify API instead).
33 34 35 |
# File 'lib/prelude_sdk/client.rb', line 33 def transactional @transactional end |
#verification ⇒ PreludeSDK::Resources::Verification (readonly)
Verify phone numbers.
37 38 39 |
# File 'lib/prelude_sdk/client.rb', line 37 def verification @verification end |
#verification_management ⇒ PreludeSDK::Resources::VerificationManagement (readonly)
Verify phone numbers.
41 42 43 |
# File 'lib/prelude_sdk/client.rb', line 41 def verification_management @verification_management end |
#watch ⇒ PreludeSDK::Resources::Watch (readonly)
Evaluate email addresses and phone numbers for trustworthiness.
45 46 47 |
# File 'lib/prelude_sdk/client.rb', line 45 def watch @watch end |