Class: HttpPulse::Monitor
- Inherits:
-
Object
- Object
- HttpPulse::Monitor
- Defined in:
- lib/http-pulse/request.rb
Instance Method Summary collapse
- #create(url) ⇒ Object
- #delete(url) ⇒ Object
- #get ⇒ Object
-
#initialize(token, environment = :production) ⇒ Monitor
constructor
A new instance of Monitor.
Constructor Details
#initialize(token, environment = :production) ⇒ Monitor
Returns a new instance of Monitor.
4 5 6 7 |
# File 'lib/http-pulse/request.rb', line 4 def initialize(token, environment = :production) raise RequestError, "Token not configured" if token.nil? || token.empty? @token, @environment = token, environment end |
Instance Method Details
#create(url) ⇒ Object
14 15 16 17 |
# File 'lib/http-pulse/request.rb', line 14 def create(url) response = RestClient.post(endpoint, {:url => url}, {:content_type => :json, :accept => :json}) handle_response(response) end |
#delete(url) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/http-pulse/request.rb', line 19 def delete(url) if object_id = id_for_url(url) response = RestClient.delete("#{endpoint}/#{object_id}") JSON.parse(response) == { } else false end end |
#get ⇒ Object
9 10 11 12 |
# File 'lib/http-pulse/request.rb', line 9 def get response = RestClient.get(endpoint, {:accept => :json}) handle_response(response) end |