Class: Readiness::Pagerduty::Client
- Inherits:
-
Object
- Object
- Readiness::Pagerduty::Client
- Defined in:
- lib/support_readiness/pagerduty/client.rb
Overview
Defines the class Client within the module Readiness::Pagerduty.
Instance Attribute Summary collapse
- #connection ⇒ Object readonly
- #upload_connection ⇒ Object readonly
Instance Method Summary collapse
-
#generate_connection(config) ⇒ Object
Used to generate a Faraday connection.
-
#initialize(config = Readiness::Pagerduty::Configuration.new) ⇒ Client
constructor
Creates a new Client instance.
-
#retry_options(config) ⇒ Hash
Used to generate the retry options passed to Faraday via faraday-retry.
Constructor Details
#initialize(config = Readiness::Pagerduty::Configuration.new) ⇒ Client
Creates a new Readiness::Pagerduty::Client instance
26 27 28 |
# File 'lib/support_readiness/pagerduty/client.rb', line 26 def initialize(config = Readiness::Pagerduty::Configuration.new) @connection = generate_connection(config) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
13 14 15 |
# File 'lib/support_readiness/pagerduty/client.rb', line 13 def connection @connection end |
#upload_connection ⇒ Object (readonly)
13 14 15 |
# File 'lib/support_readiness/pagerduty/client.rb', line 13 def upload_connection @upload_connection end |
Instance Method Details
#generate_connection(config) ⇒ Object
Used to generate a Faraday connection
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/support_readiness/pagerduty/client.rb', line 54 def generate_connection(config) Faraday.new('https://api.pagerduty.com') do |c| c.request :retry, (config) c.adapter Faraday.default_adapter c.request :url_encoded c.headers['Content-Type'] = 'application/json' c.headers['Accept'] = 'application/vnd.pagerduty+json;version=2' c.headers['Authorization'] = "Token token=#{config.token}" end end |
#retry_options(config) ⇒ Hash
Used to generate the retry options passed to Faraday via faraday-retry
37 38 39 40 41 42 43 44 45 |
# File 'lib/support_readiness/pagerduty/client.rb', line 37 def (config) { max: config.retry_max, interval: config.retry_interval, interval_randomness: config.retry_randomness, backoff_factor: config.retry_backoff, exceptions: config.retry_exceptions } end |