class Bitodeme::Conn

HTTP Connection for Bitodeme

Constants

USER_AGENT

Attributes

auth[R]

Public Class Methods

build() click to toggle source
# File lib/bitodeme/conn.rb, line 11
def self.build
  instance.send(:connection)
end
new() click to toggle source
# File lib/bitodeme/conn.rb, line 22
def initialize
  @auth = Bitodeme::Auth.build
end

Private Instance Methods

connection() click to toggle source
# File lib/bitodeme/conn.rb, line 26
def connection
  Faraday.new(faraday_opts) do |conn|
    conn.request  :oauth2, auth.token, token_type: :bearer
    conn.request  :json
    conn.response :logger if logging
    conn.response :json, content_type: /\bjson$/
    conn.adapter  Faraday.default_adapter
  end
end
faraday_opts() click to toggle source
# File lib/bitodeme/conn.rb, line 36
def faraday_opts
  @faraday_opts ||= {
    url:     "https://#{hostname}",
    headers: { 'User-Agent' => USER_AGENT }
  }
end