2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# 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
|