module Qa::Authorities::WebServiceBase
Mix-in to retreive and parse JSON content from the web with Faraday.
Attributes
@!attribute [rw] raw_response
Public Instance Methods
Source
# 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
Make a web request & retieve a JSON response for a given URL.
@param url [String] @return [Hash] a parsed JSON response
Source
# File lib/qa/authorities/web_service_base.rb, line 27 def response(url) Faraday.get(url) { |req| req.headers['Accept'] = 'application/json' } end
Make a web request and retrieve the response.
@param url [String] @return [Faraday::Response]