Module: ApiAlerts
- Defined in:
- lib/apialerts.rb,
lib/apialerts/event.rb,
lib/apialerts/client.rb,
lib/apialerts/result.rb,
lib/apialerts/version.rb
Overview
Defined Under Namespace
Classes: Client, Event, SendResult
Constant Summary collapse
- VERSION =
'1.0.0.alpha.1'.freeze
- INTEGRATION_NAME =
'ruby'.freeze
- API_URL =
'https://api.apialerts.com/event'.freeze
- TIMEOUT_SECONDS =
30
Class Method Summary collapse
-
.configure(api_key, debug: false) ⇒ Object
Initialise the global client.
- .reset! ⇒ Object
-
.send(event, api_key: nil) ⇒ Object
Send an event - fire-and-forget.
-
.send_async(event, api_key: nil) ⇒ Object
Send an event and return a SendResult.
-
.set_overrides(integration, version, base_url) ⇒ Object
Override the integration name, version, and base URL on the global client.
Class Method Details
.configure(api_key, debug: false) ⇒ Object
Initialise the global client. Subsequent calls are no-ops.
13 14 15 |
# File 'lib/apialerts.rb', line 13 def configure(api_key, debug: false) @client ||= Client.new(api_key, debug: debug) end |
.reset! ⇒ Object
42 43 44 |
# File 'lib/apialerts.rb', line 42 def reset! @client = nil end |
.send(event, api_key: nil) ⇒ Object
Send an event - fire-and-forget. Never raises. Silently does nothing if the global client has not been initialised.
25 26 27 28 29 30 31 |
# File 'lib/apialerts.rb', line 25 def send(event, api_key: nil) unless @client warn 'x (apialerts.com) Error: client not configured' return end @client.send(event, api_key: api_key) end |
.send_async(event, api_key: nil) ⇒ Object
Send an event and return a SendResult. Never raises. Returns SendResult with success: false if not configured.
35 36 37 38 39 |
# File 'lib/apialerts.rb', line 35 def send_async(event, api_key: nil) return SendResult.new(success: false, error: 'client not configured') unless @client @client.send_async(event, api_key: api_key) end |
.set_overrides(integration, version, base_url) ⇒ Object
Override the integration name, version, and base URL on the global client. No-op if configure has not been called yet.
19 20 21 |
# File 'lib/apialerts.rb', line 19 def set_overrides(integration, version, base_url) @client&.set_overrides(integration, version, base_url) end |