Class: TestApi::UsersRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/test_api/models/users_request.rb

Overview

UsersRequest Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(age = nil, signup_date = nil, username = SKIP, is_active = SKIP, rating = SKIP) ⇒ UsersRequest

Returns a new instance of UsersRequest.



57
58
59
60
61
62
63
64
# File 'lib/test_api/models/users_request.rb', line 57

def initialize(age = nil,  = nil, username = SKIP,
               is_active = SKIP, rating = SKIP)
  @username = username unless username == SKIP
  @age = age
  @is_active = is_active unless is_active == SKIP
  @rating = rating unless rating == SKIP
  @signup_date = 
end

Instance Attribute Details

#ageInteger

User’s age

Returns:

  • (Integer)


18
19
20
# File 'lib/test_api/models/users_request.rb', line 18

def age
  @age
end

#is_activeTrueClass | FalseClass

Whether the user is active

Returns:

  • (TrueClass | FalseClass)


22
23
24
# File 'lib/test_api/models/users_request.rb', line 22

def is_active
  @is_active
end

#ratingFloat

User’s rating

Returns:

  • (Float)


26
27
28
# File 'lib/test_api/models/users_request.rb', line 26

def rating
  @rating
end

#signup_dateDate

Signup date

Returns:

  • (Date)


30
31
32
# File 'lib/test_api/models/users_request.rb', line 30

def 
  @signup_date
end

#usernameString

User’s username

Returns:

  • (String)


14
15
16
# File 'lib/test_api/models/users_request.rb', line 14

def username
  @username
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/test_api/models/users_request.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  age = hash.key?('age') ? hash['age'] : nil
   = hash.key?('signupDate') ? hash['signupDate'] : nil
  username = hash.key?('username') ? hash['username'] : SKIP
  is_active = hash.key?('isActive') ? hash['isActive'] : SKIP
  rating = hash.key?('rating') ? hash['rating'] : SKIP

  # Create object from extracted values.
  UsersRequest.new(age,
                   ,
                   username,
                   is_active,
                   rating)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/test_api/models/users_request.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['username'] = 'username'
  @_hash['age'] = 'age'
  @_hash['is_active'] = 'isActive'
  @_hash['rating'] = 'rating'
  @_hash['signup_date'] = 'signupDate'
  @_hash
end

.nullablesObject

An array for nullable fields



53
54
55
# File 'lib/test_api/models/users_request.rb', line 53

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
# File 'lib/test_api/models/users_request.rb', line 44

def self.optionals
  %w[
    username
    is_active
    rating
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



93
94
95
96
97
# File 'lib/test_api/models/users_request.rb', line 93

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} username: #{@username.inspect}, age: #{@age.inspect}, is_active:"\
  " #{@is_active.inspect}, rating: #{@rating.inspect}, signup_date: #{@signup_date.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



86
87
88
89
90
# File 'lib/test_api/models/users_request.rb', line 86

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} username: #{@username}, age: #{@age}, is_active: #{@is_active}, rating:"\
  " #{@rating}, signup_date: #{@signup_date}>"
end