Parent

Tinder::Connection

Constants

HOST

Attributes

options[R]
subdomain[R]
uri[R]

Public Class Methods

connection() click to toggle source
# File lib/tinder/connection.rb, line 14
def self.connection
  @connection ||= Faraday.new do |builder|
    builder.use     FaradayMiddleware::EncodeJson
    builder.use     FaradayMiddleware::Mashify
    builder.use     FaradayMiddleware::ParseJson
    builder.use     Faraday::Response::RemoveWhitespace
    builder.use     Faraday::Response::RaiseOnAuthenticationFailure
    builder.adapter Faraday.default_adapter
  end
end
new(subdomain, options = {}) click to toggle source
# File lib/tinder/connection.rb, line 35
def initialize(subdomain, options = {})
  @subdomain = subdomain
  @options = {:ssl => true, :ssl_options => {:verify => true}, :proxy => ENV['HTTP_PROXY']}
  @options[:ssl_options][:verify] = options.delete(:ssl_verify) unless options[:ssl_verify].nil?
  @options.merge!(options)
  @uri = URI.parse("#{@options[:ssl] ? 'https' : 'http' }://#{subdomain}.#{HOST}")
  @token = options[:token]

  connection.basic_auth token, 'X'
  raw_connection.basic_auth token, 'X'
end
raw_connection() click to toggle source
# File lib/tinder/connection.rb, line 25
def self.raw_connection
  @raw_connection ||= Faraday.new do |builder|
    builder.use     FaradayMiddleware::Mashify
    builder.use     FaradayMiddleware::ParseJson
    builder.use     Faraday::Response::RemoveWhitespace
    builder.use     Faraday::Response::RaiseOnAuthenticationFailure
    builder.adapter Faraday.default_adapter
  end
end

Public Instance Methods

basic_auth_settings() click to toggle source
# File lib/tinder/connection.rb, line 47
def basic_auth_settings
  {:username => token, :password => 'X'}
end
connection() click to toggle source
# File lib/tinder/connection.rb, line 51
def connection
  @connection ||= begin
    conn = self.class.connection.dup
    set_connection_options(conn)
    conn
  end
end
get(url, *args) click to toggle source
# File lib/tinder/connection.rb, line 74
def get(url, *args)
  response = connection.get(url, *args)
  response.body
end
post(url, body = nil, *args) click to toggle source
# File lib/tinder/connection.rb, line 79
def post(url, body = nil, *args)
  response = connection.post(url, body, *args)
  response.body
end
put(url, body = nil, *args) click to toggle source
# File lib/tinder/connection.rb, line 88
def put(url, body = nil, *args)
  response = connection.put(url, body, *args)
  response.body
end
raw_connection() click to toggle source
# File lib/tinder/connection.rb, line 59
def raw_connection
  @raw_connection ||= begin
    conn = self.class.raw_connection.dup
    set_connection_options(conn)
    conn
  end
end
raw_post(url, body = nil, *args) click to toggle source
# File lib/tinder/connection.rb, line 84
def raw_post(url, body = nil, *args)
  response = raw_connection.post(url, body, *args)
end
ssl?() click to toggle source

Is the connection to campfire using ssl?

# File lib/tinder/connection.rb, line 94
def ssl?
  uri.scheme == 'https'
end
token() click to toggle source
# File lib/tinder/connection.rb, line 67
def token
  @token ||= begin
    connection.basic_auth(options[:username], options[:password])
    get('/users/me.json')['user']['api_auth_token']
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.