Class: EasyqaApi::User
Constant Summary
Constants inherited from Item
Constants included from ClassMethodsSettable
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ User
constructor
A new instance of User.
- #set_default! ⇒ Object
- #sign_in(email, password) ⇒ Object
- #sign_out ⇒ Object
Methods inherited from Item
#install_variables!, json_connection, multipart_connection, operation_status, send_request
Methods included from ClassMethodsSettable
Constructor Details
#initialize(attrs = {}) ⇒ User
Returns a new instance of User.
5 6 7 8 9 10 |
# File 'lib/easyqa_api/items/user.rb', line 5 def initialize(attrs = {}) super install_variables!( attrs[:email] && attrs[:password] ? sign_in(attrs[:email], attrs[:password]) : attrs ) end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
3 4 5 |
# File 'lib/easyqa_api/items/user.rb', line 3 def auth_token @auth_token end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/easyqa_api/items/user.rb', line 3 def name @name end |
Instance Method Details
#set_default! ⇒ Object
29 30 31 |
# File 'lib/easyqa_api/items/user.rb', line 29 def set_default! @@default_user = self end |
#sign_in(email, password) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/easyqa_api/items/user.rb', line 12 def sign_in(email, password) send_request('sign_in', :post) do |req| req.body = { user: { email: email, password: password } } end end |
#sign_out ⇒ Object
23 24 25 26 27 |
# File 'lib/easyqa_api/items/user.rb', line 23 def sign_out send_request('sign_out', :delete) do |req| req.body = { auth_token: auth_token || @auth_token } end end |