module Arthur::Api
Public Class Methods
auth_token()
click to toggle source
# File lib/arthur/api.rb, line 56 def self.auth_token @auth_token end
base_path()
click to toggle source
# File lib/arthur/api.rb, line 48 def self.base_path if @base_path @base_path else 'https://api.bugsnag.com' end end
configure(path, token)
click to toggle source
# File lib/arthur/api.rb, line 43 def self.configure(path, token) @base_path = path @auth_token = token end
full_path(path)
click to toggle source
# File lib/arthur/api.rb, line 39 def self.full_path(path) "#{base_path}#{path}" end
get(path, opts = {})
click to toggle source
return JSON parsed response
# File lib/arthur/api.rb, line 8 def self.get(path, opts = {}) all_elements = [] next_offset = nil loop do response = RestClient.get(full_path(path), 'params' => prune_options(opts.merge(offset: next_offset))) next_offset = nil if response.headers[:link] rel_next = response.headers[:link].match(/\<(.*)\>; rel=\"next\"/) if rel_next next_offset = URI.unescape(rel_next[1].match(/[&?]offset=([^&>]*)/)[1]) end end json_parsed_response = JSON.parse(response.body) if json_parsed_response.is_a?(Array) all_elements += json_parsed_response else return json_parsed_response end break unless next_offset end all_elements end
prune_options(options={})
click to toggle source
# File lib/arthur/api.rb, line 35 def self.prune_options(options={}) options.merge(auth_token: auth_token).delete_if{ |_, value| value.nil? } end