class Glomper::Client

Attributes

client_id[R]

include Users include Places

client_secret[R]

include Users include Places

oauth_token[R]

include Users include Places

Public Class Methods

new(options={}) click to toggle source
# File lib/glomper/client.rb, line 12
def initialize(options={})
  @client_id = options[:client_id]
  @client_secret = options[:client_secret]
  @oauth_token = options[:oauth_token]
end

Public Instance Methods

api_url() click to toggle source
# File lib/glomper/client.rb, line 27
def api_url
  "http://glomper.com/api"
end
connection() click to toggle source
# File lib/glomper/client.rb, line 35
def connection
  params = {}
  params[:client_id] = @client_id if @client_id
  params[:client_secret] = @client_secret if @client_secret
  params[:access_token] = @oauth_token if @oauth_token
  @connection ||= Faraday::Connection.new(:url => api_url, :params => params, :headers => default_headers) do |builder|
    builder.adapter Faraday.default_adapter
    builder.use Faraday::Response::Mashify
    builder.use Faraday::Response::ParseJson
  end
end
method_missing(meth, *args, &block) click to toggle source
Calls superclass method
# File lib/glomper/client.rb, line 18
def method_missing(meth, *args, &block)
  m = meth.to_s.capitalize.to_sym
  if Glomper::API[m]
    Glomper::Request.new(self, Glomper::API[m], *args, &block)
  else
    super
  end
end
return_error_or_body(response, response_body) click to toggle source
# File lib/glomper/client.rb, line 31
def return_error_or_body(response, response_body)
  response.body.meta.code == 200 ? response_body : response.body
end

Private Instance Methods

default_headers() click to toggle source
# File lib/glomper/client.rb, line 49
def default_headers
  headers = {
    :accept =>  'application/json',
    :user_agent => 'Ruby gem'
  }
end