Module: PagerDuty::Connection

Included in:
Client
Defined in:
lib/pager_duty/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#agentObject



25
26
27
28
29
30
31
32
# File 'lib/pager_duty/connection.rb', line 25

def agent
  @agent ||= Sawyer::Agent.new(endpoint, sawyer_options) do |http|
    http.headers[:accept]       = default_media_type
    http.headers[:content_type] = "application/json"
    http.headers[:user_agent]   = user_agent
    http.token_auth @api_token
  end
end

Instance Method Details

#delete(url, options = {}) ⇒ Object



21
22
23
# File 'lib/pager_duty/connection.rb', line 21

def delete(url, options = {})
  request :delete, url, options
end

#get(url, options = {}) ⇒ Object



5
6
7
# File 'lib/pager_duty/connection.rb', line 5

def get(url, options = {})
  request :get, url, options
end

#last_responseSawyer::Response

Response for last HTTP request

Returns:

  • (Sawyer::Response)


44
45
46
# File 'lib/pager_duty/connection.rb', line 44

def last_response
  @last_response if defined? @last_response
end

#patch(url, options = {}) ⇒ Object



17
18
19
# File 'lib/pager_duty/connection.rb', line 17

def patch(url, options = {})
  request :patch, url, options
end

#post(url, options = {}) ⇒ Object



9
10
11
# File 'lib/pager_duty/connection.rb', line 9

def post(url, options = {})
  request :post, url, options
end

#put(url, options = {}) ⇒ Object



13
14
15
# File 'lib/pager_duty/connection.rb', line 13

def put(url, options = {})
  request :put, url, options
end

#rootSawyer::Resource

Fetch the root resource for the API

Returns:

  • (Sawyer::Resource)


37
38
39
# File 'lib/pager_duty/connection.rb', line 37

def root
  get "/"
end