stackone_hris_client 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/README.md +13 -5
- data/docs/AccountsApi.md +4 -7
- data/docs/CompaniesApi.md +13 -15
- data/docs/ConnectSession.md +1 -1
- data/docs/ConnectSessionCreate.md +3 -1
- data/docs/ConnectSessionToken.md +1 -1
- data/docs/ConnectSessionsApi.md +3 -5
- data/docs/Employee.md +8 -8
- data/docs/EmployeesApi.md +17 -15
- data/docs/Employment.md +3 -3
- data/docs/EmploymentStatusEnum.md +20 -0
- data/docs/EmploymentTypeEnum.md +20 -0
- data/docs/EmploymentsApi.md +13 -15
- data/docs/EthnicityEnum.md +20 -0
- data/docs/GenderEnum.md +20 -0
- data/docs/Location.md +1 -1
- data/docs/LocationTypeEnum.md +20 -0
- data/docs/LocationsApi.md +13 -15
- data/docs/MaritalStatusEnum.md +20 -0
- data/docs/PayFrequencyEnum.md +20 -0
- data/docs/PayPeriodEnum.md +20 -0
- data/gem-config.yml +1 -1
- data/lib/stackone_hris_client/api/companies_api.rb +12 -12
- data/lib/stackone_hris_client/api/employees_api.rb +18 -12
- data/lib/stackone_hris_client/api/employments_api.rb +12 -12
- data/lib/stackone_hris_client/api/locations_api.rb +12 -12
- data/lib/stackone_hris_client/models/connect_session_create.rb +13 -1
- data/lib/stackone_hris_client/models/employee.rb +8 -90
- data/lib/stackone_hris_client/models/employment.rb +3 -61
- data/lib/stackone_hris_client/models/employment_status_enum.rb +270 -0
- data/lib/stackone_hris_client/models/employment_type_enum.rb +270 -0
- data/lib/stackone_hris_client/models/ethnicity_enum.rb +270 -0
- data/lib/stackone_hris_client/models/gender_enum.rb +270 -0
- data/lib/stackone_hris_client/models/location.rb +1 -35
- data/lib/stackone_hris_client/models/location_type_enum.rb +270 -0
- data/lib/stackone_hris_client/models/marital_status_enum.rb +270 -0
- data/lib/stackone_hris_client/models/pay_frequency_enum.rb +270 -0
- data/lib/stackone_hris_client/models/pay_period_enum.rb +270 -0
- data/lib/stackone_hris_client/version.rb +1 -1
- data/lib/stackone_hris_client.rb +8 -0
- data/spec/configuration_spec.rb +3 -3
- data/spec/models/employment_status_enum_spec.rb +44 -0
- data/spec/models/employment_type_enum_spec.rb +44 -0
- data/spec/models/ethnicity_enum_spec.rb +44 -0
- data/spec/models/gender_enum_spec.rb +44 -0
- data/spec/models/location_type_enum_spec.rb +44 -0
- data/spec/models/marital_status_enum_spec.rb +44 -0
- data/spec/models/pay_frequency_enum_spec.rb +44 -0
- data/spec/models/pay_period_enum_spec.rb +44 -0
- metadata +34 -2
@@ -79,28 +79,6 @@ module StackOneHRIS
|
|
79
79
|
|
80
80
|
attr_accessor :employments
|
81
81
|
|
82
|
-
class EnumAttributeValidator
|
83
|
-
attr_reader :datatype
|
84
|
-
attr_reader :allowable_values
|
85
|
-
|
86
|
-
def initialize(datatype, allowable_values)
|
87
|
-
@allowable_values = allowable_values.map do |value|
|
88
|
-
case datatype.to_s
|
89
|
-
when /Integer/i
|
90
|
-
value.to_i
|
91
|
-
when /Float/i
|
92
|
-
value.to_f
|
93
|
-
else
|
94
|
-
value
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def valid?(value)
|
100
|
-
!value || allowable_values.include?(value)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
82
|
# Attribute mapping from ruby-style variable name to JSON key.
|
105
83
|
def self.attribute_map
|
106
84
|
{
|
@@ -152,11 +130,11 @@ module StackOneHRIS
|
|
152
130
|
:'last_name' => :'String',
|
153
131
|
:'name' => :'String',
|
154
132
|
:'display_name' => :'String',
|
155
|
-
:'gender' => :'
|
156
|
-
:'ethnicity' => :'
|
133
|
+
:'gender' => :'GenderEnum',
|
134
|
+
:'ethnicity' => :'EthnicityEnum',
|
157
135
|
:'date_of_birth' => :'Time',
|
158
136
|
:'birthday' => :'Time',
|
159
|
-
:'marital_status' => :'
|
137
|
+
:'marital_status' => :'MaritalStatusEnum',
|
160
138
|
:'avatar_url' => :'String',
|
161
139
|
:'personal_email' => :'String',
|
162
140
|
:'personal_phone_number' => :'String',
|
@@ -169,16 +147,16 @@ module StackOneHRIS
|
|
169
147
|
:'start_date' => :'Time',
|
170
148
|
:'tenure' => :'Float',
|
171
149
|
:'work_anniversary' => :'Time',
|
172
|
-
:'employment_type' => :'
|
173
|
-
:'employment_status' => :'
|
150
|
+
:'employment_type' => :'EmploymentTypeEnum',
|
151
|
+
:'employment_status' => :'EmploymentStatusEnum',
|
174
152
|
:'termination_date' => :'Time',
|
175
153
|
:'company_name' => :'String',
|
176
154
|
:'home_country_location' => :'String',
|
177
155
|
:'work_country_location' => :'String',
|
178
|
-
:'home_location' => :'
|
179
|
-
:'work_location' => :'
|
156
|
+
:'home_location' => :'Location',
|
157
|
+
:'work_location' => :'Location',
|
180
158
|
:'company' => :'String',
|
181
|
-
:'employments' => :'Array<
|
159
|
+
:'employments' => :'Array<Employment>'
|
182
160
|
}
|
183
161
|
end
|
184
162
|
|
@@ -390,73 +368,13 @@ module StackOneHRIS
|
|
390
368
|
return false if @name.nil?
|
391
369
|
return false if @display_name.nil?
|
392
370
|
return false if @gender.nil?
|
393
|
-
gender_validator = EnumAttributeValidator.new('String', ["male", "female", "non_binary", "other", "not_disclosed", "unmapped_value"])
|
394
|
-
return false unless gender_validator.valid?(@gender)
|
395
|
-
ethnicity_validator = EnumAttributeValidator.new('String', ["white", "black_or_african_american", "asian", "hispanic_or_latino", "american_indian_or_alaska_native", "native_hawaiian_or_pacific_islander", "two_or_more_races", "not_disclosed", "unmapped_value"])
|
396
|
-
return false unless ethnicity_validator.valid?(@ethnicity)
|
397
|
-
marital_status_validator = EnumAttributeValidator.new('String', ["single", "married", "divorced", "widowed", "domestic_partnership", "separated", "other", "unmapped_value"])
|
398
|
-
return false unless marital_status_validator.valid?(@marital_status)
|
399
371
|
return false if @personal_phone_number.nil?
|
400
372
|
return false if @work_email.nil?
|
401
373
|
return false if @work_phone_number.nil?
|
402
374
|
return false if @department.nil?
|
403
|
-
employment_type_validator = EnumAttributeValidator.new('String', ["full_time", "part_time", "contractor", "intern", "freelance", "terminated", "unmapped_value"])
|
404
|
-
return false unless employment_type_validator.valid?(@employment_type)
|
405
|
-
employment_status_validator = EnumAttributeValidator.new('String', ["active", "pending", "terminated", "unmapped_value"])
|
406
|
-
return false unless employment_status_validator.valid?(@employment_status)
|
407
375
|
true
|
408
376
|
end
|
409
377
|
|
410
|
-
# Custom attribute writer method checking allowed values (enum).
|
411
|
-
# @param [Object] gender Object to be assigned
|
412
|
-
def gender=(gender)
|
413
|
-
validator = EnumAttributeValidator.new('String', ["male", "female", "non_binary", "other", "not_disclosed", "unmapped_value"])
|
414
|
-
unless validator.valid?(gender)
|
415
|
-
fail ArgumentError, "invalid value for \"gender\", must be one of #{validator.allowable_values}."
|
416
|
-
end
|
417
|
-
@gender = gender
|
418
|
-
end
|
419
|
-
|
420
|
-
# Custom attribute writer method checking allowed values (enum).
|
421
|
-
# @param [Object] ethnicity Object to be assigned
|
422
|
-
def ethnicity=(ethnicity)
|
423
|
-
validator = EnumAttributeValidator.new('String', ["white", "black_or_african_american", "asian", "hispanic_or_latino", "american_indian_or_alaska_native", "native_hawaiian_or_pacific_islander", "two_or_more_races", "not_disclosed", "unmapped_value"])
|
424
|
-
unless validator.valid?(ethnicity)
|
425
|
-
fail ArgumentError, "invalid value for \"ethnicity\", must be one of #{validator.allowable_values}."
|
426
|
-
end
|
427
|
-
@ethnicity = ethnicity
|
428
|
-
end
|
429
|
-
|
430
|
-
# Custom attribute writer method checking allowed values (enum).
|
431
|
-
# @param [Object] marital_status Object to be assigned
|
432
|
-
def marital_status=(marital_status)
|
433
|
-
validator = EnumAttributeValidator.new('String', ["single", "married", "divorced", "widowed", "domestic_partnership", "separated", "other", "unmapped_value"])
|
434
|
-
unless validator.valid?(marital_status)
|
435
|
-
fail ArgumentError, "invalid value for \"marital_status\", must be one of #{validator.allowable_values}."
|
436
|
-
end
|
437
|
-
@marital_status = marital_status
|
438
|
-
end
|
439
|
-
|
440
|
-
# Custom attribute writer method checking allowed values (enum).
|
441
|
-
# @param [Object] employment_type Object to be assigned
|
442
|
-
def employment_type=(employment_type)
|
443
|
-
validator = EnumAttributeValidator.new('String', ["full_time", "part_time", "contractor", "intern", "freelance", "terminated", "unmapped_value"])
|
444
|
-
unless validator.valid?(employment_type)
|
445
|
-
fail ArgumentError, "invalid value for \"employment_type\", must be one of #{validator.allowable_values}."
|
446
|
-
end
|
447
|
-
@employment_type = employment_type
|
448
|
-
end
|
449
|
-
|
450
|
-
# Custom attribute writer method checking allowed values (enum).
|
451
|
-
# @param [Object] employment_status Object to be assigned
|
452
|
-
def employment_status=(employment_status)
|
453
|
-
validator = EnumAttributeValidator.new('String', ["active", "pending", "terminated", "unmapped_value"])
|
454
|
-
unless validator.valid?(employment_status)
|
455
|
-
fail ArgumentError, "invalid value for \"employment_status\", must be one of #{validator.allowable_values}."
|
456
|
-
end
|
457
|
-
@employment_status = employment_status
|
458
|
-
end
|
459
|
-
|
460
378
|
# Checks equality by comparing each attribute.
|
461
379
|
# @param [Object] Object to be compared
|
462
380
|
def ==(o)
|
@@ -33,28 +33,6 @@ module StackOneHRIS
|
|
33
33
|
|
34
34
|
attr_accessor :employment_type
|
35
35
|
|
36
|
-
class EnumAttributeValidator
|
37
|
-
attr_reader :datatype
|
38
|
-
attr_reader :allowable_values
|
39
|
-
|
40
|
-
def initialize(datatype, allowable_values)
|
41
|
-
@allowable_values = allowable_values.map do |value|
|
42
|
-
case datatype.to_s
|
43
|
-
when /Integer/i
|
44
|
-
value.to_i
|
45
|
-
when /Float/i
|
46
|
-
value.to_f
|
47
|
-
else
|
48
|
-
value
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def valid?(value)
|
54
|
-
!value || allowable_values.include?(value)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
36
|
# Attribute mapping from ruby-style variable name to JSON key.
|
59
37
|
def self.attribute_map
|
60
38
|
{
|
@@ -82,11 +60,11 @@ module StackOneHRIS
|
|
82
60
|
:'employee_id' => :'String',
|
83
61
|
:'job_title' => :'String',
|
84
62
|
:'pay_rate' => :'String',
|
85
|
-
:'pay_period' => :'
|
86
|
-
:'pay_frequency' => :'
|
63
|
+
:'pay_period' => :'PayPeriodEnum',
|
64
|
+
:'pay_frequency' => :'PayFrequencyEnum',
|
87
65
|
:'pay_currency' => :'String',
|
88
66
|
:'effective_date' => :'Time',
|
89
|
-
:'employment_type' => :'
|
67
|
+
:'employment_type' => :'EmploymentTypeEnum'
|
90
68
|
}
|
91
69
|
end
|
92
70
|
|
@@ -163,45 +141,9 @@ module StackOneHRIS
|
|
163
141
|
# @return true if the model is valid
|
164
142
|
def valid?
|
165
143
|
return false if @employee_id.nil?
|
166
|
-
pay_period_validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "every_two_weeks", "month", "quarter", "every_six_months", "year", "unmapped_value"])
|
167
|
-
return false unless pay_period_validator.valid?(@pay_period)
|
168
|
-
pay_frequency_validator = EnumAttributeValidator.new('String', ["hourly", "weekly", "bi_weekly", "monthly", "quarterly", "semi_annually", "yearly", "thirteen_monthly", "pro_rata", "unmapped_value"])
|
169
|
-
return false unless pay_frequency_validator.valid?(@pay_frequency)
|
170
|
-
employment_type_validator = EnumAttributeValidator.new('String', ["full_time", "part_time", "contractor", "intern", "freelance", "terminated", "unmapped_value"])
|
171
|
-
return false unless employment_type_validator.valid?(@employment_type)
|
172
144
|
true
|
173
145
|
end
|
174
146
|
|
175
|
-
# Custom attribute writer method checking allowed values (enum).
|
176
|
-
# @param [Object] pay_period Object to be assigned
|
177
|
-
def pay_period=(pay_period)
|
178
|
-
validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "every_two_weeks", "month", "quarter", "every_six_months", "year", "unmapped_value"])
|
179
|
-
unless validator.valid?(pay_period)
|
180
|
-
fail ArgumentError, "invalid value for \"pay_period\", must be one of #{validator.allowable_values}."
|
181
|
-
end
|
182
|
-
@pay_period = pay_period
|
183
|
-
end
|
184
|
-
|
185
|
-
# Custom attribute writer method checking allowed values (enum).
|
186
|
-
# @param [Object] pay_frequency Object to be assigned
|
187
|
-
def pay_frequency=(pay_frequency)
|
188
|
-
validator = EnumAttributeValidator.new('String', ["hourly", "weekly", "bi_weekly", "monthly", "quarterly", "semi_annually", "yearly", "thirteen_monthly", "pro_rata", "unmapped_value"])
|
189
|
-
unless validator.valid?(pay_frequency)
|
190
|
-
fail ArgumentError, "invalid value for \"pay_frequency\", must be one of #{validator.allowable_values}."
|
191
|
-
end
|
192
|
-
@pay_frequency = pay_frequency
|
193
|
-
end
|
194
|
-
|
195
|
-
# Custom attribute writer method checking allowed values (enum).
|
196
|
-
# @param [Object] employment_type Object to be assigned
|
197
|
-
def employment_type=(employment_type)
|
198
|
-
validator = EnumAttributeValidator.new('String', ["full_time", "part_time", "contractor", "intern", "freelance", "terminated", "unmapped_value"])
|
199
|
-
unless validator.valid?(employment_type)
|
200
|
-
fail ArgumentError, "invalid value for \"employment_type\", must be one of #{validator.allowable_values}."
|
201
|
-
end
|
202
|
-
@employment_type = employment_type
|
203
|
-
end
|
204
|
-
|
205
147
|
# Checks equality by comparing each attribute.
|
206
148
|
# @param [Object] Object to be compared
|
207
149
|
def ==(o)
|
@@ -0,0 +1,270 @@
|
|
1
|
+
=begin
|
2
|
+
#StackOne Unified API - HRIS
|
3
|
+
|
4
|
+
#The documentation for the StackOne Unified API - HRIS
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.5.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module StackOneHRIS
|
17
|
+
class EmploymentStatusEnum
|
18
|
+
attr_accessor :value
|
19
|
+
|
20
|
+
attr_accessor :source_value
|
21
|
+
|
22
|
+
class EnumAttributeValidator
|
23
|
+
attr_reader :datatype
|
24
|
+
attr_reader :allowable_values
|
25
|
+
|
26
|
+
def initialize(datatype, allowable_values)
|
27
|
+
@allowable_values = allowable_values.map do |value|
|
28
|
+
case datatype.to_s
|
29
|
+
when /Integer/i
|
30
|
+
value.to_i
|
31
|
+
when /Float/i
|
32
|
+
value.to_f
|
33
|
+
else
|
34
|
+
value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid?(value)
|
40
|
+
!value || allowable_values.include?(value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
45
|
+
def self.attribute_map
|
46
|
+
{
|
47
|
+
:'value' => :'value',
|
48
|
+
:'source_value' => :'source_value'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns all the JSON keys this model knows about
|
53
|
+
def self.acceptable_attributes
|
54
|
+
attribute_map.values
|
55
|
+
end
|
56
|
+
|
57
|
+
# Attribute type mapping.
|
58
|
+
def self.openapi_types
|
59
|
+
{
|
60
|
+
:'value' => :'String',
|
61
|
+
:'source_value' => :'String'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# List of attributes with nullable: true
|
66
|
+
def self.openapi_nullable
|
67
|
+
Set.new([
|
68
|
+
])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Initializes the object
|
72
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
73
|
+
def initialize(attributes = {})
|
74
|
+
if (!attributes.is_a?(Hash))
|
75
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `StackOneHRIS::EmploymentStatusEnum` initialize method"
|
76
|
+
end
|
77
|
+
|
78
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
79
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
80
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
81
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `StackOneHRIS::EmploymentStatusEnum`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
82
|
+
end
|
83
|
+
h[k.to_sym] = v
|
84
|
+
}
|
85
|
+
|
86
|
+
if attributes.key?(:'value')
|
87
|
+
self.value = attributes[:'value']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'source_value')
|
91
|
+
self.source_value = attributes[:'source_value']
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
96
|
+
# @return Array for valid properties with the reasons
|
97
|
+
def list_invalid_properties
|
98
|
+
invalid_properties = Array.new
|
99
|
+
if @value.nil?
|
100
|
+
invalid_properties.push('invalid value for "value", value cannot be nil.')
|
101
|
+
end
|
102
|
+
|
103
|
+
if @source_value.nil?
|
104
|
+
invalid_properties.push('invalid value for "source_value", source_value cannot be nil.')
|
105
|
+
end
|
106
|
+
|
107
|
+
invalid_properties
|
108
|
+
end
|
109
|
+
|
110
|
+
# Check to see if the all the properties in the model are valid
|
111
|
+
# @return true if the model is valid
|
112
|
+
def valid?
|
113
|
+
return false if @value.nil?
|
114
|
+
value_validator = EnumAttributeValidator.new('String', ["active", "pending", "terminated", "unmapped_value"])
|
115
|
+
return false unless value_validator.valid?(@value)
|
116
|
+
return false if @source_value.nil?
|
117
|
+
true
|
118
|
+
end
|
119
|
+
|
120
|
+
# Custom attribute writer method checking allowed values (enum).
|
121
|
+
# @param [Object] value Object to be assigned
|
122
|
+
def value=(value)
|
123
|
+
validator = EnumAttributeValidator.new('String', ["active", "pending", "terminated", "unmapped_value"])
|
124
|
+
unless validator.valid?(value)
|
125
|
+
fail ArgumentError, "invalid value for \"value\", must be one of #{validator.allowable_values}."
|
126
|
+
end
|
127
|
+
@value = value
|
128
|
+
end
|
129
|
+
|
130
|
+
# Checks equality by comparing each attribute.
|
131
|
+
# @param [Object] Object to be compared
|
132
|
+
def ==(o)
|
133
|
+
return true if self.equal?(o)
|
134
|
+
self.class == o.class &&
|
135
|
+
value == o.value &&
|
136
|
+
source_value == o.source_value
|
137
|
+
end
|
138
|
+
|
139
|
+
# @see the `==` method
|
140
|
+
# @param [Object] Object to be compared
|
141
|
+
def eql?(o)
|
142
|
+
self == o
|
143
|
+
end
|
144
|
+
|
145
|
+
# Calculates hash code according to all attributes.
|
146
|
+
# @return [Integer] Hash code
|
147
|
+
def hash
|
148
|
+
[value, source_value].hash
|
149
|
+
end
|
150
|
+
|
151
|
+
# Builds the object from hash
|
152
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
153
|
+
# @return [Object] Returns the model itself
|
154
|
+
def self.build_from_hash(attributes)
|
155
|
+
new.build_from_hash(attributes)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Builds the object from hash
|
159
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
160
|
+
# @return [Object] Returns the model itself
|
161
|
+
def build_from_hash(attributes)
|
162
|
+
return nil unless attributes.is_a?(Hash)
|
163
|
+
attributes = attributes.transform_keys(&:to_sym)
|
164
|
+
self.class.openapi_types.each_pair do |key, type|
|
165
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
166
|
+
self.send("#{key}=", nil)
|
167
|
+
elsif type =~ /\AArray<(.*)>/i
|
168
|
+
# check to ensure the input is an array given that the attribute
|
169
|
+
# is documented as an array but the input is not
|
170
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
171
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
172
|
+
end
|
173
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
174
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
self
|
179
|
+
end
|
180
|
+
|
181
|
+
# Deserializes the data based on type
|
182
|
+
# @param string type Data type
|
183
|
+
# @param string value Value to be deserialized
|
184
|
+
# @return [Object] Deserialized data
|
185
|
+
def _deserialize(type, value)
|
186
|
+
case type.to_sym
|
187
|
+
when :Time
|
188
|
+
Time.parse(value)
|
189
|
+
when :Date
|
190
|
+
Date.parse(value)
|
191
|
+
when :String
|
192
|
+
value.to_s
|
193
|
+
when :Integer
|
194
|
+
value.to_i
|
195
|
+
when :Float
|
196
|
+
value.to_f
|
197
|
+
when :Boolean
|
198
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
199
|
+
true
|
200
|
+
else
|
201
|
+
false
|
202
|
+
end
|
203
|
+
when :Object
|
204
|
+
# generic object (usually a Hash), return directly
|
205
|
+
value
|
206
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
207
|
+
inner_type = Regexp.last_match[:inner_type]
|
208
|
+
value.map { |v| _deserialize(inner_type, v) }
|
209
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
210
|
+
k_type = Regexp.last_match[:k_type]
|
211
|
+
v_type = Regexp.last_match[:v_type]
|
212
|
+
{}.tap do |hash|
|
213
|
+
value.each do |k, v|
|
214
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
else # model
|
218
|
+
# models (e.g. Pet) or oneOf
|
219
|
+
klass = StackOneHRIS.const_get(type)
|
220
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
# Returns the string representation of the object
|
225
|
+
# @return [String] String presentation of the object
|
226
|
+
def to_s
|
227
|
+
to_hash.to_s
|
228
|
+
end
|
229
|
+
|
230
|
+
# to_body is an alias to to_hash (backward compatibility)
|
231
|
+
# @return [Hash] Returns the object in the form of hash
|
232
|
+
def to_body
|
233
|
+
to_hash
|
234
|
+
end
|
235
|
+
|
236
|
+
# Returns the object in the form of hash
|
237
|
+
# @return [Hash] Returns the object in the form of hash
|
238
|
+
def to_hash
|
239
|
+
hash = {}
|
240
|
+
self.class.attribute_map.each_pair do |attr, param|
|
241
|
+
value = self.send(attr)
|
242
|
+
if value.nil?
|
243
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
244
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
245
|
+
end
|
246
|
+
|
247
|
+
hash[param] = _to_hash(value)
|
248
|
+
end
|
249
|
+
hash
|
250
|
+
end
|
251
|
+
|
252
|
+
# Outputs non-array value in the form of hash
|
253
|
+
# For object, use to_hash. Otherwise, just return the value
|
254
|
+
# @param [Object] value Any valid value
|
255
|
+
# @return [Hash] Returns the value in the form of hash
|
256
|
+
def _to_hash(value)
|
257
|
+
if value.is_a?(Array)
|
258
|
+
value.compact.map { |v| _to_hash(v) }
|
259
|
+
elsif value.is_a?(Hash)
|
260
|
+
{}.tap do |hash|
|
261
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
262
|
+
end
|
263
|
+
elsif value.respond_to? :to_hash
|
264
|
+
value.to_hash
|
265
|
+
else
|
266
|
+
value
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|