module Qa::Authorities::WebServiceBase

Mix-in to retreive and parse JSON content from the web with Faraday.

Attributes

raw_response[RW]

@!attribute [rw] raw_response

Public Instance Methods

json(url) click to toggle source

Make a web request & retieve a JSON response for a given URL.

@param url [String] @return [Hash] a parsed JSON response

# File lib/qa/authorities/web_service_base.rb, line 16
def json(url)
  Rails.logger.info "Retrieving json for url: #{url}"
  r = response(url).body
  JSON.parse(r)
end
response(url) click to toggle source

Make a web request and retrieve the response.

@param url [String] @return [Faraday::Response]

# File lib/qa/authorities/web_service_base.rb, line 27
def response(url)
  Faraday.get(url) { |req| req.headers['Accept'] = 'application/json' }
end