Class: EasyqaApi::User

Inherits:
Item
  • Object
show all
Defined in:
lib/easyqa_api/items/user.rb

Overview

User representation from EasyQA website

Constant Summary

Constants inherited from Item

Item::CONNECTION

Constants included from ClassMethodsSettable

ClassMethodsSettable::METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Item

#install_variables!, json_connection, multipart_connection, operation_status, send_request

Methods included from ClassMethodsSettable

#install_class_methods!

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.

Parameters:

  • attrs (Hash) (defaults to: {})

    param for action

Options Hash (attrs):

  • :email (String)

    user email

  • :password (String)

    user password

See Also:



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] ? (attrs[:email], attrs[:password]) : attrs
  )
end

Instance Attribute Details

#auth_tokenString

Returns user auth_token on EasyQA website.

Returns:

  • (String)

    user auth_token on EasyQA website



8
9
10
# File 'lib/easyqa_api/items/user.rb', line 8

def auth_token
  @auth_token
end

#nameString

Returns user name on EasyQA website.

Returns:

  • (String)

    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

Returns:

See Also:



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

Parameters:

  • email (String)

    Email user on EasyQA

  • password (String)

    password user on EasyQA

Returns:

  • (Hash)

    user attributes on EasyQA webiste

See Also:



28
29
30
31
32
33
34
35
36
37
# File 'lib/easyqa_api/items/user.rb', line 28

def (email, password)
  send_request('sign_in', :post) do |req|
    req.body = {
      user: {
        email: email,
        password: password
      }
    }
  end
end

#sign_outHash

Sign out user on EasyQA website

Returns:

  • (Hash)

    user attributes on EasyQA webiste

See Also:



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