Module: Kairos::Client::Utils
- Included in:
- Base
- Defined in:
- lib/kairos/client/utils.rb
Defined Under Namespace
Classes: FaceError
Constant Summary collapse
- API_METHODS =
{ :detect => 'http://api.kairos.io/detect', }
Instance Method Summary collapse
Instance Method Details
#api_crendential ⇒ Object
11 12 13 |
# File 'lib/kairos/client/utils.rb', line 11 def api_crendential { :app_id => app_id, :app_key => app_key } end |
#make_request(api_method, opts = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kairos/client/utils.rb', line 15 def make_request(api_method, opts={}) # if opts[:url].is_a? Array # opts[:url] = opts[:url].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 ) response = JSON.parse( RestClient::Request.execute( :method => :post, :url => API_METHODS[ api_method ], :headers => { "app_id" => app_id, "app_key" => app_key }, :payload => opts.to_json )) # if %w/success partial/.include?(response['status']) return response # elsif response['status'] == 'failure' # raise FaceError.new("Error: #{response['error_code']}, #{response['error_message']}") # end end |
#user_auth_param ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/kairos/client/utils.rb', line 50 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 |