Class: Notiflows::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- Notiflows::Client
- Defined in:
- lib/notiflows/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_key ⇒ String
readonly
Your project's public API key.
- #deliveries ⇒ Notiflows::Resources::Deliveries readonly
- #notifications ⇒ Notiflows::Resources::Notifications readonly
- #notiflows ⇒ Notiflows::Resources::Notiflows readonly
-
#secret ⇒ String
readonly
Your project's secret key.
- #topics ⇒ Notiflows::Resources::Topics readonly
- #users ⇒ Notiflows::Resources::Users 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["NOTIFLOWS_SDK_API_KEY"], secret: ENV["NOTIFLOWS_SDK_SECRET"], base_url: ENV["NOTIFLOWS_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["NOTIFLOWS_SDK_API_KEY"], secret: ENV["NOTIFLOWS_SDK_SECRET"], base_url: ENV["NOTIFLOWS_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.
Defaults to ENV["NOTIFLOWS_SDK_API_KEY"]
this secret!** Defaults to ENV["NOTIFLOWS_SDK_SECRET"]
"https://api.example.com/v2/". Defaults to ENV["NOTIFLOWS_BASE_URL"]
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 115 |
# File 'lib/notiflows/client.rb', line 81 def initialize( api_key: ENV["NOTIFLOWS_SDK_API_KEY"], secret: ENV["NOTIFLOWS_SDK_SECRET"], base_url: ENV["NOTIFLOWS_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.notiflows.com/admin/v1" if api_key.nil? raise ArgumentError.new("api_key is required, and can be set via environ: \"NOTIFLOWS_SDK_API_KEY\"") end if secret.nil? raise ArgumentError.new("secret is required, and can be set via environ: \"NOTIFLOWS_SDK_SECRET\"") end @api_key = api_key.to_s @secret = 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 ) @deliveries = Notiflows::Resources::Deliveries.new(client: self) @notifications = Notiflows::Resources::Notifications.new(client: self) @notiflows = Notiflows::Resources::Notiflows.new(client: self) @topics = Notiflows::Resources::Topics.new(client: self) @users = Notiflows::Resources::Users.new(client: self) end |
Instance Attribute Details
#api_key ⇒ String (readonly)
Your project's public API key. Found in Project Settings. Starts with pk_.
20 21 22 |
# File 'lib/notiflows/client.rb', line 20 def api_key @api_key end |
#deliveries ⇒ Notiflows::Resources::Deliveries (readonly)
28 29 30 |
# File 'lib/notiflows/client.rb', line 28 def deliveries @deliveries end |
#notifications ⇒ Notiflows::Resources::Notifications (readonly)
31 32 33 |
# File 'lib/notiflows/client.rb', line 31 def notifications @notifications end |
#notiflows ⇒ Notiflows::Resources::Notiflows (readonly)
34 35 36 |
# File 'lib/notiflows/client.rb', line 34 def notiflows @notiflows end |
#secret ⇒ String (readonly)
Your project's secret key. Found in Project Settings. Starts with sk_. Keep
this secret!
25 26 27 |
# File 'lib/notiflows/client.rb', line 25 def secret @secret end |
#topics ⇒ Notiflows::Resources::Topics (readonly)
37 38 39 |
# File 'lib/notiflows/client.rb', line 37 def topics @topics end |
#users ⇒ Notiflows::Resources::Users (readonly)
40 41 42 |
# File 'lib/notiflows/client.rb', line 40 def users @users end |