-
-
Save dolzenko/1639418 to your computer and use it in GitHub Desktop.
Access the Hoptoad (http://hoptoadapp.com) API with Ruby's ActiveResource
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 Hoptoad < ActiveResource::Base | |
self.site = "https://your_account.airbrake.io" | |
class << self | |
@@auth_token = 'your_auth_token' | |
def find(*arguments) | |
arguments = append_auth_token_to_params(*arguments) | |
super(*arguments) | |
end | |
def append_auth_token_to_params(*arguments) | |
opts = arguments.last.is_a?(Hash) ? arguments.pop : {} | |
opts = opts.has_key?(:params) ? opts : opts.merge(:params => {}) | |
opts[:params] = opts[:params].merge(:auth_token => @@auth_token) | |
arguments << opts | |
arguments | |
end | |
end | |
end | |
class Error < Hoptoad | |
end | |
class Notice < Airbrake | |
self.prefix = "/errors/:error_id/" | |
self.format = :xml # Errors are only available in XML, WTF??? | |
end | |
# Errors are paginated. You get 30 at a time. | |
@errors = Error.find :all | |
@errors = Error.find :all, :params => { :page => 2 } | |
@notices = Notice.find :all, :params => { :error_id => 123 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment