Class: EasyqaApi::User
Overview
User representation from EasyQA website
Constant Summary
Constants inherited from Item
Constants included from ClassMethodsSettable
Instance Attribute Summary collapse
-
#auth_token ⇒ String
User auth_token on EasyQA website.
-
#name ⇒ String
User name on EasyQA website.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ User
constructor
A new instance of User.
-
#set_default! ⇒ EasyqaApi::User
Set default user on EasyqaApi.
-
#sign_in(email, password) ⇒ Hash
Sign in user on EasyQA website.
-
#sign_out ⇒ Hash
Sign out user on EasyQA website.
Methods inherited from Item
#install_variables!, json_connection, multipart_connection, operation_status, send_request
Methods included from ClassMethodsSettable
Constructor Details
#initialize(attrs = {}) ⇒ User
Note:
If you give user email and password you will be already signed on EasyQA.
Returns a new instance of User.
16 17 18 19 20 21 |
# File 'lib/easyqa_api/items/user.rb', line 16 def initialize(attrs = {}) super install_variables!( attrs[:email] && attrs[:password] ? sign_in(attrs[:email], attrs[:password]) : attrs ) end |
Instance Attribute Details
#auth_token ⇒ String
Returns user auth_token on EasyQA website.
8 9 10 |
# File 'lib/easyqa_api/items/user.rb', line 8 def auth_token @auth_token end |
#name ⇒ String
Returns user name on EasyQA website.
8 |
# File 'lib/easyqa_api/items/user.rb', line 8 attr_accessor :auth_token, :name |
Instance Method Details
#set_default! ⇒ EasyqaApi::User
Set default user on EasyqaApi
51 52 53 |
# File 'lib/easyqa_api/items/user.rb', line 51 def set_default! @@default_user = self end |
#sign_in(email, password) ⇒ Hash
Sign in user on EasyQA website
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/easyqa_api/items/user.rb', line 28 def sign_in(email, password) send_request('sign_in', :post) do |req| req.body = { user: { email: email, password: password } } end end |
#sign_out ⇒ Hash
Sign out user on EasyQA website
42 43 44 45 46 |
# File 'lib/easyqa_api/items/user.rb', line 42 def sign_out send_request('sign_out', :delete) do |req| req.body = { auth_token: @auth_token } end end |