Sha256: 55f3a9916add1ebc5976c2feae5bd5258791c58ed3638ddad0ce2c9763ea1246
Contents?: true
Size: 746 Bytes
Versions: 31
Compression:
Stored size: 746 Bytes
Contents
require 'faraday' module Qa::Authorities ## # Mix-in to retreive and parse JSON content from the web with Faraday. module WebServiceBase ## # @!attribute [rw] raw_response attr_accessor :raw_response ## # Make a web request & retieve a JSON response for a given URL. # # @param url [String] # @return [Hash] a parsed JSON response def json(url) Rails.logger.info "Retrieving json for url: #{url}" r = response(url).body JSON.parse(r) end ## # Make a web request and retrieve the response. # # @param url [String] # @return [Faraday::Response] def response(url) Faraday.get(url) { |req| req.headers['Accept'] = 'application/json' } end end end
Version data entries
31 entries across 31 versions & 1 rubygems