Created
October 26, 2012 18:56
-
-
Save cwjohnston/3960708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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