Sha256: 108761f5e62822574e065349ba24eaabcac8d903f7751a566f67caf1cea87503
Contents?: true
Size: 985 Bytes
Versions: 2
Compression:
Stored size: 985 Bytes
Contents
# This class handles the HTTP interactions with the Yummly API calls. module Yummly class Connection class << self attr_writer :adapter def get(command, params = {}) response = self.api_connection.get(UrlBuilder.uri(command, params)) self.parse_response(response) end def api_connection adapter.connection(UrlBuilder.domain) end def adapter Yummly.configuration.http_adapter end def parse_response(response) case response.status when 409 then raise Yummly::PermissionError, response.body when 404 then nil when 200 then JSON.parse(response.body) when 501 then raise Yummly::NotImplementedError, response.body when 500 then raise Yummly::InternalServerError, "An internal error on the Yummly servers was encountered: #{response.body}" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yummly-0.0.12 | lib/yummly/connection.rb |
yummly-0.0.11 | lib/yummly/connection.rb |