Sha256: e0fd133407801daacb5b3fdcf8e57c05e44a778a55876c91a669e28c9bc2e9e3
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
module AgraApi class Client < Vertebrae::API def organisation @organisation ||= AgraApi::Organisation.new(client: self) end def signature(petition_id) @signature ||= AgraApi::Signature.new(client: self, petition_id: petition_id) end def default_options { user_agent: 'AgraApi Gem', prefix: '', content_type: 'application/json' } end def request(method, path, params, options) # :nodoc: if !::Vertebrae::Request::METHODS.include?(method) raise ArgumentError, "unknown http method: #{method}" end path = connection.configuration.prefix + '/' + path ::Vertebrae::Base.logger.debug "EXECUTED: #{method} - #{path} with #{params} and #{options}" connection.connection.send(method) do |request| case method.to_sym when *(::Vertebrae::Request::METHODS - ::Vertebrae::Request::METHODS_WITH_BODIES) request.url(path, params) when *::Vertebrae::Request::METHODS_WITH_BODIES request.path = path request.body = extract_data_from_params(params) unless params.empty? end end end def setup connection.stack do |builder| builder.use Faraday::Request::Multipart builder.use Faraday::Request::UrlEncoded builder.use Vertebrae::Request::BasicAuth, connection.configuration.authentication if connection.configuration.authenticated? builder.use Faraday::Response::Logger if ENV['DEBUG'] builder.use FaradayMiddleware::Mashify builder.use FaradayMiddleware::ParseJson builder.use Vertebrae::Response::RaiseError builder.adapter connection.configuration.adapter end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
agra_api-0.2.0 | lib/agra_api/client.rb |