class Syncano::Resources::User
User
resource
Public Class Methods
count(client, scope_parameters = {}, conditions = {})
click to toggle source
Wrapper for api “count” method @param [Syncano::Clients::Base] client @param [Hash] scope_parameters @param [Hash] conditions @return [Integer]
# File lib/syncano/resources/user.rb, line 10 def self.count(client, scope_parameters = {}, conditions = {}) response = perform_count(client, scope_parameters, conditions) response.data if response.status end
login(client, username, password)
click to toggle source
Wrapper for api “login” method @param [Syncano::Clients::Base] client @param [String] username @param [String] password @return [Integer]
# File lib/syncano/resources/user.rb, line 20 def self.login(client, username, password) response = perform_login(client, user_name: username, password: password) response.data end
Private Class Methods
attributes_to_sync(attributes)
click to toggle source
Prepares hash with attributes used in synchronization with Syncano
@return [Hash]
# File lib/syncano/resources/user.rb, line 31 def self.attributes_to_sync(attributes) attributes = attributes.dup if attributes.keys.map(&:to_sym).include?(:avatar) if attributes[:avatar].blank? attributes[:avatar] = '' elsif attributes[:avatar].is_a?(String) attributes[:avatar] = Base64.encode64(File.read(attributes[:avatar])) else attributes.delete(:image) end end attributes end
perform_count(client, scope_parameters, conditions)
click to toggle source
Executes proper count request @param [Syncano::Clients::Base] client @param [Hash] scope_parameters @param [Hash] conditions @return [Syncano::Response]
# File lib/syncano/resources/user.rb, line 52 def self.perform_count(client, scope_parameters, conditions) make_request(client, nil, :count, conditions.merge(scope_parameters)) end
perform_login(client, parameters = {})
click to toggle source
Executes proper login request @param [Syncano::Clients::Base] client @param [Hash] parameters @return [Syncano::Response]
# File lib/syncano/resources/user.rb, line 60 def self.perform_login(client, parameters = {}) make_request(client, nil, :login, parameters, :auth_key) end