class Consumerable::Connection
Public Class Methods
connection()
click to toggle source
# File lib/consumerable/connection.rb, line 28 def self.connection Faraday::Connection.new( url: Consumerable.configuration.endpoint, headers: { accept: Consumerable.configuration.accept_header, content_type: Consumerable. content_type_string(Consumerable.configuration.content_type) } ) do |builder| builder.request Consumerable.configuration.content_type builder.response Consumerable.configuration.content_type builder.use Faraday::Response::Mashify builder.adapter :typhoeus end.tap do |connection| if Consumerable.configuration.basic_auth_username connection.basic_auth( Consumerable.configuration.basic_auth_username, Consumerable.configuration.basic_auth_password ) end end end
delete(path, options = {})
click to toggle source
# File lib/consumerable/connection.rb, line 23 def self.delete(path, options = {}) Consumerable.log "DELETE #{path} with #{options}" connection.delete(path, options).success? end
get(path, options = {})
click to toggle source
# File lib/consumerable/connection.rb, line 6 def self.get(path, options = {}) Consumerable.log "GET #{path} with #{options}" connection.get(path, options).body end
patch(path, options = {})
click to toggle source
# File lib/consumerable/connection.rb, line 18 def self.patch(path, options = {}) Consumerable.log "PATCH #{path} with #{options}" connection.patch(path, options).success? end
post(path, options = {})
click to toggle source
# File lib/consumerable/connection.rb, line 11 def self.post(path, options = {}) Consumerable.log "POST #{path} with #{options}" connection.post(path, options).tap do |response| Consumerable.log "RESPONDED WITH: #{response.body}" end.body end