Class: Pagerdupi::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/pagerdupi/common.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_token) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pagerdupi/common.rb', line 7

def initialize(api_token)
  @api_token = api_token
  @options = {
    headers: {
      'Authorization' => "Token token=#{@api_token}",
      'Content-type' => 'application/json',
      'Accept' => 'application/vnd.pagerduty+json;version=2'
    },
    output: 'json'
  }
end

Instance Method Details

#delete(req, opts = {}) ⇒ Object



39
40
41
42
# File 'lib/pagerdupi/common.rb', line 39

def delete(req, opts = {})
  opts = opts.merge(@options)
  self.class.delete("#{req}", opts)
end

#get(req, opts = {}) ⇒ Object



19
20
21
22
# File 'lib/pagerdupi/common.rb', line 19

def get(req, opts = {})
  opts = opts.merge(@options)
  self.class.get("#{req}", opts)
end

#patch(req, opts = {}) ⇒ Object



29
30
31
32
# File 'lib/pagerdupi/common.rb', line 29

def patch(req, opts = {})
  opts = opts.merge(@options)
  self.class.patch("#{req}", opts)
end

#post(req, opts = {}) ⇒ Object



24
25
26
27
# File 'lib/pagerdupi/common.rb', line 24

def post(req, opts = {})
  opts = opts.merge(@options)
  self.class.post("#{req}", opts)
end

#put(req, opts = {}) ⇒ Object



34
35
36
37
# File 'lib/pagerdupi/common.rb', line 34

def put(req, opts = {})
  opts = opts.merge(@options)
  self.class.put("#{req}", opts)
end