Skip to content

Instantly share code, notes, and snippets.

@cwjohnston
Created October 26, 2012 18:56
Show Gist options
  • Save cwjohnston/3960708 to your computer and use it in GitHub Desktop.
Save cwjohnston/3960708 to your computer and use it in GitHub Desktop.
class PingdomClient
def initialize(u,p,k)
require 'httparty'
include HTTParty
self.class.base_uri 'https://api.pingdom.com/api/2.0/'
@auth = {:username => u, :password => p}
@headers = {'App-Key' => k}
end
def get(uri, options={})
options.merge!({:basic_auth => @auth})
options.merge!({:headers => @headers})
response = self.class.get(uri, options)
end
def put(uri, options={})
options.merge!({:basic_auth => @auth})
options.merge!({:headers => @headers})
response = self.class.put(uri, options)
end
def post(uri, options={})
options.merge!({:basic_auth => @auth})
options.merge!({:headers => @headers})
response = self.class.post(uri, options)
end
def delete(uri, options={})
options.merge!({:basic_auth => @auth})
options.merge!({:headers => @headers})
response = self.class.delete(uri, options)
end
def checks(options={})
options.merge!({:basic_auth => @auth})
options.merge!({:headers => @headers})
response = self.class.get('/checks', options).parsed_response
checks = response['checks']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment