module Graham::API::Connection

Public Instance Methods

delete(url, option = nil) { |res, body| ... } click to toggle source
# File lib/graham/api/connection.rb, line 22
def delete(url, option = nil)
  options                = prepareOption(option)
  res                    = config.conn.delete(url, options)
  body                   = JSON.parse res.body
  yield(res, body) if block_given?
  res
end
get(url, option = nil) { |res, body| ... } click to toggle source
# File lib/graham/api/connection.rb, line 14
def get(url, option = nil)
  options                = prepareOption(option)
  res                    = config.conn.get(url, options)
  body                   = JSON.parse res.body
  yield(res, body) if block_given?
  res
end
post(url, option = nil) { |res, body| ... } click to toggle source
# File lib/graham/api/connection.rb, line 6
def post(url, option = nil)
  options                = prepareOption(option)
  res                    = config.conn.post(url, options)
  body                   = JSON.parse res.body
  yield(res, body) if block_given?
  res
end

Private Instance Methods

prepareOption(option = nil) click to toggle source
# File lib/graham/api/connection.rb, line 32
def prepareOption(option = nil)
  options                = {}
  options["access_token"] = config.access_token if config.access_token
  options["client_id"] = config.client_id unless config.access_token
  unless option.nil?
    option.each do |key, value|
      options[key]       = value
    end
  end
  options
end