Sha256: fde35515a026f4580389bac2168c422f05a32530ac478d989771c553d94cdad8
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'faraday' require 'faraday_middleware' module Beeper class Client attr_accessor :api_key, :subdomain, :requester_id def configured? !@api_key.nil? && !@subdomain.nil? end def incidents get(:incidents) end def services get(:services) end def maintenance_windows(options={}) get(:maintenance_windows, options) end def create_maintenance_window(maintenance_window) post(:maintenance_windows, maintenance_window) end private def get(collection, options={}) results = connection.get(collection.to_s, options) results.body.send(collection.to_sym) end def post(collection, options={}) options = authenticated_post_options.merge(collection.to_s[0..-2].to_sym => options) results = connection.post(collection.to_s, options) results.body end def authenticated_post_options { :requester_id => @requester_id } end def connection @connection ||= Faraday.new("https://#@subdomain.pagerduty.com/api/v1") do |conn| conn.request :json conn.token_auth @api_key conn.response :rashify conn.response :json, :content_type => /\bjson$/ conn.adapter Faraday.default_adapter end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
beeper-0.0.1 | lib/beeper/client.rb |