Sha256: 2453e17950ed500de3da6f24277f51053cae45fc1d976c63f5b809f759698fe5
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require 'restclient' module Panda module Adapter class RestClient def initialize(api_url) @api_url = api_url end def get(request_uri, params) rescue_json_parsing do query = ApiAuthentication.hash_to_query(params) connection[request_uri + '?' + query].get end end def post(request_uri, params) rescue_json_parsing do connection[request_uri].post(params) end end def put(request_uri, params) rescue_json_parsing do connection[request_uri].put(params) end end def delete(request_uri, params) rescue_json_parsing do query = ApiAuthentication.hash_to_query(params) connection[request_uri + '?' + query].delete end end private def connection @conn ||= ::RestClient::Resource.new(@api_url) end def rescue_json_parsing(&block) begin MultiJson.decode(yield) rescue MultiJson::DecodeError => e raise(ServiceNotAvailable) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
panda-1.5.0 | lib/panda/adapters/restclient.rb |