Module: InterruptHelper::PagerDuty

Included in:
Lita::Handlers::Interrupt
Defined in:
lib/interrupt_helper/pager_duty.rb

Defined Under Namespace

Classes: APIError, RaiseNon202

Instance Method Summary collapse

Instance Method Details

#events_v2::Faraday

Returns:

  • (::Faraday)


17
18
19
20
21
22
23
24
25
26
# File 'lib/interrupt_helper/pager_duty.rb', line 17

def events_v2
  @events_v2_client ||= Faraday.new do |conn|
    conn.url_prefix = "https://events.pagerduty.com/v2/"
    conn.use(RaiseNon202)
    conn.request(:json)
    conn.response(:json)
    conn.headers[:accept] = "application/json"
    conn.adapter(Faraday.default_adapter)
  end
end

#pagerduty(token) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/interrupt_helper/pager_duty.rb', line 7

def pagerduty(token)
  token = token.to_s
  return nil if token.empty?
  @pagerduty_clients ||= Hash.new { |h, k|
    h[k] = ::PagerDuty::Connection.new(k)
  }
  @pagerduty_clients[token]
end