module Subordinate::Connection

Public Instance Methods

connection(options = {}) click to toggle source
# File lib/subordinate/connection.rb, line 8
def connection(options = {})
  options = {
    :ssl              => { :verify => false }
  }.merge(options)

  connection = Faraday.new(options) do |build|
    build.request :url_encoded
    if authenticated?
      build.request :basic_auth, self.username, self.api_token
    end
    build.response :mashify
    build.response :json, :content_type => /\bjson$/
    build.use ErrorMiddleware
    build.adapter  Faraday.default_adapter
  end

  connection
end