class G5FoundationClient::Fetcher
Public Class Methods
fetch_url(url) { |body| ... }
click to toggle source
# File lib/g5_foundation_client/fetcher.rb, line 2 def self.fetch_url(url, &block) response = HTTParty.get( url, {query: {access_token: G5FoundationClient::access_token}, headers: {'Content-Type' => 'application/json', 'Accept' => 'application/json'} } ) case response.response.code.to_i when 200 yield response.body when 404 raise G5FoundationClient::RecordNotFoundException.new( "Couldn't find record at URL '#{url}'" ) else raise G5FoundationClient::Error.new( "I got an unexpected response code '#{response.response.code}'" ) end end