Class: Hotchoc::Client::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/hotchoc/client/fetcher.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  headers: {
    'Accept' => 'application/json',
    'Accept-Encoding' => 'gzip',
    'User-Agent' => "Hotchoc Ruby client #{Hotchoc::Client::VERSION}"
  },
  follow_redirects: true
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get(url, opts = {}, verify = true) ⇒ Object



16
17
18
# File 'lib/hotchoc/client/fetcher.rb', line 16

def self.get(url, opts = {}, verify = true)
  new.get(url, opts, verify)
end

Instance Method Details

#get(url, opts = {}, verify = true) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/hotchoc/client/fetcher.rb', line 20

def get(url, opts = {}, verify = true)
  response = HTTParty.get(url, params(opts, verify))

  if response.success?
    JSON.parse(response.body)
  else
    fail RequestError, request_error_message(response)
  end
end