Class: Amiando::User
Overview
Instance Attribute Summary
Attributes inherited from Resource
#attributes, #request, #response, #success
Class Method Summary (collapse)
-
+ (Object) create(attributes)
Creates a user.
-
+ (Object) delete(user_id)
Deletes a user Returns a Boolean with the result of the operation.
-
+ (Boolean) exists?(username)
Will return a Boolean deferred object containing the result.
-
+ (Object) find(user_id)
Find a user.
-
+ (Result) find_by_username(username)
Find a user given the username (email).
-
+ (Object) logout(user_id)
Tries to log out the user_id.
-
+ (Object) request_permission(user_id, password)
Request permission to use and api key on behalf of a user.
-
+ (Object) update(user_id, attributes)
Updates a user.
Instance Method Summary (collapse)
Methods inherited from Resource
#[], #extract_attributes_from, #id, #initialize, map, map_params, mapping, method_missing, #method_missing, #populate_create, reverse_map_params, typecasting
Methods included from Autorun
Constructor Details
This class inherits a constructor from Amiando::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Amiando::Resource
Class Method Details
+ (Object) create(attributes)
Creates a user. It will not return the full user and only the id attribute will be available.
42 43 44 45 46 47 48 49 |
# File 'lib/amiando/user.rb', line 42 def self.create(attributes) object = new post object, '/api/user/create', :params => map_params(attributes), :populate_method => :populate_create object end |
+ (Object) delete(user_id)
Deletes a user Returns a Boolean with the result of the operation
81 82 83 84 85 86 |
# File 'lib/amiando/user.rb', line 81 def self.delete(user_id) object = Boolean.new('deleted') do_request object, :delete, "/api/user/#{user_id}" object end |
+ (Boolean) exists?(username)
Will return a Boolean deferred object containing the result
13 14 15 16 17 18 19 |
# File 'lib/amiando/user.rb', line 13 def self.exists?(username) object = Boolean.new('exists') get object, "api/user/exists", :params => { :username => username } object end |
+ (Object) find(user_id)
Find a user. Will return a user
69 70 71 72 73 74 |
# File 'lib/amiando/user.rb', line 69 def self.find(user_id) object = new get object, "api/user/#{user_id}" object end |
+ (Result) find_by_username(username)
Find a user given the username (email)
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/amiando/user.rb', line 26 def self.find_by_username(username) object = Result.new do |response_body| response_body['ids'].first end get object, "api/user/find", :params => { :username => username } object end |
+ (Object) logout(user_id)
Tries to log out the user_id. Will raise Error::NotAuthorized if trying to logout a user you don't have permission for.
104 105 106 107 108 109 |
# File 'lib/amiando/user.rb', line 104 def self.logout(user_id) object = Boolean.new('success') post object, "/api/user/#{user_id}/logout" object end |
+ (Object) request_permission(user_id, password)
Request permission to use and api key on behalf of a user
92 93 94 95 96 97 |
# File 'lib/amiando/user.rb', line 92 def self.(user_id, password) object = Result.new post object, "api/user/#{user_id}/requestPermission", :params => { :password => password } object end |
+ (Object) update(user_id, attributes)
Updates a user. Will return a Boolean deferred object indicating the result of the update
57 58 59 60 61 62 |
# File 'lib/amiando/user.rb', line 57 def self.update(user_id, attributes) object = Boolean.new('success') post object, "/api/user/#{user_id}", :params => map_params(attributes) object end |
Instance Method Details
- (Object) ==(user)
111 112 113 |
# File 'lib/amiando/user.rb', line 111 def ==(user) id == user.id end |