Class: PagerDuty::Full
- Inherits:
-
Object
- Object
- PagerDuty::Full
- Defined in:
- lib/pagerduty/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#apikey ⇒ Object
readonly
Returns the value of attribute apikey.
-
#subdomain ⇒ Object
readonly
Returns the value of attribute subdomain.
Instance Method Summary collapse
- #api_call(path, params) ⇒ Object
- #Incident ⇒ Object
-
#initialize(apikey, subdomain) ⇒ Full
constructor
A new instance of Full.
- #Schedule ⇒ Object
Constructor Details
#initialize(apikey, subdomain) ⇒ Full
Returns a new instance of Full.
10 11 12 13 |
# File 'lib/pagerduty/base.rb', line 10 def initialize(apikey, subdomain) @apikey = apikey @subdomain = subdomain end |
Instance Attribute Details
#apikey ⇒ Object (readonly)
Returns the value of attribute apikey.
8 9 10 |
# File 'lib/pagerduty/base.rb', line 8 def apikey @apikey end |
#subdomain ⇒ Object (readonly)
Returns the value of attribute subdomain.
8 9 10 |
# File 'lib/pagerduty/base.rb', line 8 def subdomain @subdomain end |
Instance Method Details
#api_call(path, params) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pagerduty/base.rb', line 15 def api_call(path, params) uri = URI.parse("https://#{@subdomain}.pagerduty.com/api/v1/#{path}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE # This is probably stupid query_string = "" params.each do |key, val| next unless val != nil query_string << '&' unless key == params.keys.first query_string << "#{URI.encode(key.to_s)}=#{URI.encode(params[key])}" end uri.query = query_string req = Net::HTTP::Get.new(uri.request_uri) res = http.get(uri.to_s, { 'Content-type' => 'application/json', 'Authorization' => "Token token=#{@apikey}" }) end |