module Face::Client::Utils

Constants

API_METHODS

Public Instance Methods

api_crendential() click to toggle source
# File lib/face/client/utils.rb, line 23
def api_crendential
  { :api_key => api_key, :api_secret => api_secret }
end
make_request(api_method, opts={}) click to toggle source
# File lib/face/client/utils.rb, line 27
def make_request(api_method, opts={})
  if opts[:urls].is_a? Array
    opts[:urls] = opts[:urls].join(',')
  end

  if opts[:uids].is_a? Array
    opts[:uids] = opts[:uids].join(',')
  end
  
  if opts[:tids].is_a? Array
    opts[:tids] = opts[:tids].join(',')
  end

  if opts[:pids].is_a? Array
    opts[:pids] = opts[:pids].join(',')
  end
  
  response = JSON.parse( RestClient.post(API_METHODS[ api_method ], opts.merge(api_crendential)).body )
  if %w/success partial/.include?(response['status'])
    response
  elsif response['status'] == 'failure'
    raise FaceError.new("Error: #{response['error_code']}, #{response['error_message']}")
  end
end
user_auth_param() click to toggle source
# File lib/face/client/utils.rb, line 52
def user_auth_param
  user_auth_value = []
  if twitter_credentials
    twitter_credentials.each do |k, v|
      user_auth_value << "#{k}:#{v}"
    end
  elsif twitter_oauth_credentials
    twitter_oauth_credentials.each do |k,v|
      user_auth_value << "#{k}:#{v}"
    end
  end
  if facebook_credentials
    facebook_credentials.each do |k, v|
      user_auth_value << "#{k}:#{v}"
    end
  end
  user_auth_value.size > 0 ? { :user_auth => user_auth_value.join(',') } : {}
end