Class: TestAsdasdasd::User

Inherits:
BaseModel show all
Defined in:
lib/test_asdasdasd/models/user.rb

Overview

User Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = nil, username = nil, first_name = nil, last_name = nil, email = nil, password = nil, phone = nil, user_status = nil) ⇒ User

Returns a new instance of User.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/test_asdasdasd/models/user.rb', line 55

def initialize(id = nil,
               username = nil,
               first_name = nil,
               last_name = nil,
               email = nil,
               password = nil,
               phone = nil,
               user_status = nil)
  @id = id
  @username = username
  @first_name = first_name
  @last_name = last_name
  @email = email
  @password = password
  @phone = phone
  @user_status = user_status
end

Instance Attribute Details

#emailString

TODO: Write general description for this method

Returns:



27
28
29
# File 'lib/test_asdasdasd/models/user.rb', line 27

def email
  @email
end

#first_nameString

TODO: Write general description for this method

Returns:



19
20
21
# File 'lib/test_asdasdasd/models/user.rb', line 19

def first_name
  @first_name
end

#idLong

TODO: Write general description for this method

Returns:

  • (Long)


11
12
13
# File 'lib/test_asdasdasd/models/user.rb', line 11

def id
  @id
end

#last_nameString

TODO: Write general description for this method

Returns:



23
24
25
# File 'lib/test_asdasdasd/models/user.rb', line 23

def last_name
  @last_name
end

#passwordString

TODO: Write general description for this method

Returns:



31
32
33
# File 'lib/test_asdasdasd/models/user.rb', line 31

def password
  @password
end

#phoneString

TODO: Write general description for this method

Returns:



35
36
37
# File 'lib/test_asdasdasd/models/user.rb', line 35

def phone
  @phone
end

#user_statusInteger

User Status

Returns:

  • (Integer)


39
40
41
# File 'lib/test_asdasdasd/models/user.rb', line 39

def user_status
  @user_status
end

#usernameString

TODO: Write general description for this method

Returns:



15
16
17
# File 'lib/test_asdasdasd/models/user.rb', line 15

def username
  @username
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/test_asdasdasd/models/user.rb', line 74

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash['id']
  username = hash['username']
  first_name = hash['firstName']
  last_name = hash['lastName']
  email = hash['email']
  password = hash['password']
  phone = hash['phone']
  user_status = hash['userStatus']

  # Create object from extracted values.
  User.new(id,
           username,
           first_name,
           last_name,
           email,
           password,
           phone,
           user_status)
end

.namesObject

A mapping from model property names to API property names.



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/test_asdasdasd/models/user.rb', line 42

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['username'] = 'username'
  @_hash['first_name'] = 'firstName'
  @_hash['last_name'] = 'lastName'
  @_hash['email'] = 'email'
  @_hash['password'] = 'password'
  @_hash['phone'] = 'phone'
  @_hash['user_status'] = 'userStatus'
  @_hash
end