Module: Face::Client::Utils
- Included in:
- Base
- Defined in:
- lib/face/client/utils.rb
Defined Under Namespace
Classes: FaceError
Constant Summary collapse
- API_METHODS =
{ :faces_detect => 'http://api.skybiometry.com/fc/faces/detect.json', :faces_group => 'http://api.skybiometry.com/fc/faces/group.json', :faces_recognize => 'http://api.skybiometry.com/fc/faces/recognize.json', :faces_train => 'http://api.skybiometry.com/fc/faces/train.json', :faces_status => 'http://api.skybiometry.com/fc/faces/status.json', :tags_get => 'http://api.skybiometry.com/fc/tags/get.json', :tags_add => 'http://api.skybiometry.com/fc/tags/add.json', :tags_save => 'http://api.skybiometry.com/fc/tags/save.json', :tags_remove => 'http://api.skybiometry.com/fc/tags/remove.json', :account_limits => 'http://api.skybiometry.com/fc/account/limits.json', :account_users => 'http://api.skybiometry.com/fc/account/users.json' }
Instance Method Summary collapse
Instance Method Details
#api_crendential ⇒ Object
21 22 23 |
# File 'lib/face/client/utils.rb', line 21 def api_crendential { :api_key => api_key, :api_secret => api_secret } end |
#make_request(api_method, opts = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/face/client/utils.rb', line 25 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 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 ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/face/client/utils.rb', line 41 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 |