sygna-bridge-ivms-util 0.0.1

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.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +110 -0
  4. data/Rakefile +10 -0
  5. data/docs/Address.md +47 -0
  6. data/docs/AddressTypeCode.md +16 -0
  7. data/docs/Beneficiary.md +19 -0
  8. data/docs/BeneficiaryVasp.md +17 -0
  9. data/docs/DateAndPlaceOfBirth.md +19 -0
  10. data/docs/DefaultApi.md +49 -0
  11. data/docs/IdentityPayload.md +27 -0
  12. data/docs/IntermediaryVasp.md +19 -0
  13. data/docs/LegalPerson.md +25 -0
  14. data/docs/LegalPersonName.md +21 -0
  15. data/docs/LegalPersonNameId.md +19 -0
  16. data/docs/LegalPersonNameTypeCode.md +16 -0
  17. data/docs/LocalLegalPersonNameId.md +19 -0
  18. data/docs/LocalNaturalPersonNameId.md +21 -0
  19. data/docs/NationalIdentification.md +23 -0
  20. data/docs/NationalIdentifierTypeCode.md +16 -0
  21. data/docs/NaturalPerson.md +27 -0
  22. data/docs/NaturalPersonName.md +21 -0
  23. data/docs/NaturalPersonNameId.md +21 -0
  24. data/docs/NaturalPersonNameTypeCode.md +16 -0
  25. data/docs/OriginatingVasp.md +17 -0
  26. data/docs/Originator.md +19 -0
  27. data/docs/PayloadMetadata.md +17 -0
  28. data/docs/Person.md +19 -0
  29. data/docs/TransliterationMethodCode.md +16 -0
  30. data/git_push.sh +58 -0
  31. data/lib/sygna-bridge-ivms-util.rb +64 -0
  32. data/lib/sygna-bridge-ivms-util/api/default_api.rb +74 -0
  33. data/lib/sygna-bridge-ivms-util/api_client.rb +387 -0
  34. data/lib/sygna-bridge-ivms-util/api_error.rb +57 -0
  35. data/lib/sygna-bridge-ivms-util/configuration.rb +241 -0
  36. data/lib/sygna-bridge-ivms-util/models/address.rb +377 -0
  37. data/lib/sygna-bridge-ivms-util/models/address_type_code.rb +37 -0
  38. data/lib/sygna-bridge-ivms-util/models/beneficiary.rb +219 -0
  39. data/lib/sygna-bridge-ivms-util/models/beneficiary_vasp.rb +206 -0
  40. data/lib/sygna-bridge-ivms-util/models/date_and_place_of_birth.rb +215 -0
  41. data/lib/sygna-bridge-ivms-util/models/identity_payload.rb +253 -0
  42. data/lib/sygna-bridge-ivms-util/models/intermediary_vasp.rb +239 -0
  43. data/lib/sygna-bridge-ivms-util/models/legal_person.rb +244 -0
  44. data/lib/sygna-bridge-ivms-util/models/legal_person_name.rb +230 -0
  45. data/lib/sygna-bridge-ivms-util/models/legal_person_name_id.rb +249 -0
  46. data/lib/sygna-bridge-ivms-util/models/legal_person_name_type_code.rb +37 -0
  47. data/lib/sygna-bridge-ivms-util/models/local_legal_person_name_id.rb +249 -0
  48. data/lib/sygna-bridge-ivms-util/models/local_natural_person_name_id.rb +258 -0
  49. data/lib/sygna-bridge-ivms-util/models/national_identification.rb +267 -0
  50. data/lib/sygna-bridge-ivms-util/models/national_identifier_type_code.rb +44 -0
  51. data/lib/sygna-bridge-ivms-util/models/natural_person.rb +253 -0
  52. data/lib/sygna-bridge-ivms-util/models/natural_person_name.rb +230 -0
  53. data/lib/sygna-bridge-ivms-util/models/natural_person_name_id.rb +258 -0
  54. data/lib/sygna-bridge-ivms-util/models/natural_person_name_type_code.rb +39 -0
  55. data/lib/sygna-bridge-ivms-util/models/originating_vasp.rb +206 -0
  56. data/lib/sygna-bridge-ivms-util/models/originator.rb +219 -0
  57. data/lib/sygna-bridge-ivms-util/models/payload_metadata.rb +230 -0
  58. data/lib/sygna-bridge-ivms-util/models/person.rb +215 -0
  59. data/lib/sygna-bridge-ivms-util/models/transliteration_method_code.rb +47 -0
  60. data/lib/sygna-bridge-ivms-util/version.rb +15 -0
  61. data/spec/api/default_api_spec.rb +44 -0
  62. data/spec/api_client_spec.rb +226 -0
  63. data/spec/configuration_spec.rb +42 -0
  64. data/spec/models/address_spec.rb +135 -0
  65. data/spec/models/address_type_code_spec.rb +35 -0
  66. data/spec/models/beneficiary_spec.rb +47 -0
  67. data/spec/models/beneficiary_vasp_spec.rb +41 -0
  68. data/spec/models/date_and_place_of_birth_spec.rb +47 -0
  69. data/spec/models/identity_payload_spec.rb +71 -0
  70. data/spec/models/intermediary_vasp_spec.rb +47 -0
  71. data/spec/models/legal_person_name_id_spec.rb +51 -0
  72. data/spec/models/legal_person_name_spec.rb +53 -0
  73. data/spec/models/legal_person_name_type_code_spec.rb +35 -0
  74. data/spec/models/legal_person_spec.rb +65 -0
  75. data/spec/models/local_legal_person_name_id_spec.rb +51 -0
  76. data/spec/models/local_natural_person_name_id_spec.rb +57 -0
  77. data/spec/models/national_identification_spec.rb +63 -0
  78. data/spec/models/national_identifier_type_code_spec.rb +35 -0
  79. data/spec/models/natural_person_name_id_spec.rb +57 -0
  80. data/spec/models/natural_person_name_spec.rb +53 -0
  81. data/spec/models/natural_person_name_type_code_spec.rb +35 -0
  82. data/spec/models/natural_person_spec.rb +71 -0
  83. data/spec/models/originating_vasp_spec.rb +41 -0
  84. data/spec/models/originator_spec.rb +47 -0
  85. data/spec/models/payload_metadata_spec.rb +45 -0
  86. data/spec/models/person_spec.rb +47 -0
  87. data/spec/models/transliteration_method_code_spec.rb +35 -0
  88. data/spec/spec_helper.rb +111 -0
  89. data/sygna-bridge-ivms-util.gemspec +39 -0
  90. metadata +219 -0
@@ -0,0 +1,377 @@
1
+ =begin
2
+ #Bridge
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SygnaBridgeIvmsUtil
16
+ class Address
17
+ attr_accessor :address_type
18
+
19
+ attr_accessor :department
20
+
21
+ attr_accessor :sub_department
22
+
23
+ attr_accessor :street_name
24
+
25
+ attr_accessor :building_number
26
+
27
+ attr_accessor :building_name
28
+
29
+ attr_accessor :floor
30
+
31
+ attr_accessor :post_box
32
+
33
+ attr_accessor :room
34
+
35
+ attr_accessor :post_code
36
+
37
+ attr_accessor :town_name
38
+
39
+ attr_accessor :town_location_name
40
+
41
+ attr_accessor :district_name
42
+
43
+ attr_accessor :country_sub_division
44
+
45
+ attr_accessor :address_line
46
+
47
+ attr_accessor :country
48
+
49
+ class EnumAttributeValidator
50
+ attr_reader :datatype
51
+ attr_reader :allowable_values
52
+
53
+ def initialize(datatype, allowable_values)
54
+ @allowable_values = allowable_values.map do |value|
55
+ case datatype.to_s
56
+ when /Integer/i
57
+ value.to_i
58
+ when /Float/i
59
+ value.to_f
60
+ else
61
+ value
62
+ end
63
+ end
64
+ end
65
+
66
+ def valid?(value)
67
+ !value || allowable_values.include?(value)
68
+ end
69
+ end
70
+
71
+ # Attribute mapping from ruby-style variable name to JSON key.
72
+ def self.attribute_map
73
+ {
74
+ :'address_type' => :'address_type',
75
+ :'department' => :'department',
76
+ :'sub_department' => :'sub_department',
77
+ :'street_name' => :'street_name',
78
+ :'building_number' => :'building_number',
79
+ :'building_name' => :'building_name',
80
+ :'floor' => :'floor',
81
+ :'post_box' => :'post_box',
82
+ :'room' => :'room',
83
+ :'post_code' => :'post_code',
84
+ :'town_name' => :'town_name',
85
+ :'town_location_name' => :'town_location_name',
86
+ :'district_name' => :'district_name',
87
+ :'country_sub_division' => :'country_sub_division',
88
+ :'address_line' => :'address_line',
89
+ :'country' => :'country'
90
+ }
91
+ end
92
+
93
+ # Attribute type mapping.
94
+ def self.openapi_types
95
+ {
96
+ :'address_type' => :'String',
97
+ :'department' => :'String',
98
+ :'sub_department' => :'String',
99
+ :'street_name' => :'String',
100
+ :'building_number' => :'String',
101
+ :'building_name' => :'String',
102
+ :'floor' => :'String',
103
+ :'post_box' => :'String',
104
+ :'room' => :'String',
105
+ :'post_code' => :'String',
106
+ :'town_name' => :'String',
107
+ :'town_location_name' => :'String',
108
+ :'district_name' => :'String',
109
+ :'country_sub_division' => :'String',
110
+ :'address_line' => :'Array<String>',
111
+ :'country' => :'String'
112
+ }
113
+ end
114
+
115
+ # List of attributes with nullable: true
116
+ def self.openapi_nullable
117
+ Set.new([
118
+ ])
119
+ end
120
+
121
+ # Initializes the object
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ def initialize(attributes = {})
124
+ if (!attributes.is_a?(Hash))
125
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SygnaBridgeIvmsUtil::Address` initialize method"
126
+ end
127
+
128
+ # check to see if the attribute exists and convert string to symbol for hash key
129
+ attributes = attributes.each_with_object({}) { |(k, v), h|
130
+ if (!self.class.attribute_map.key?(k.to_sym))
131
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SygnaBridgeIvmsUtil::Address`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
132
+ end
133
+ h[k.to_sym] = v
134
+ }
135
+
136
+ if attributes.key?(:'address_type')
137
+ self.address_type = attributes[:'address_type']
138
+ end
139
+
140
+ if attributes.key?(:'department')
141
+ self.department = attributes[:'department']
142
+ end
143
+
144
+ if attributes.key?(:'sub_department')
145
+ self.sub_department = attributes[:'sub_department']
146
+ end
147
+
148
+ if attributes.key?(:'street_name')
149
+ self.street_name = attributes[:'street_name']
150
+ end
151
+
152
+ if attributes.key?(:'building_number')
153
+ self.building_number = attributes[:'building_number']
154
+ end
155
+
156
+ if attributes.key?(:'building_name')
157
+ self.building_name = attributes[:'building_name']
158
+ end
159
+
160
+ if attributes.key?(:'floor')
161
+ self.floor = attributes[:'floor']
162
+ end
163
+
164
+ if attributes.key?(:'post_box')
165
+ self.post_box = attributes[:'post_box']
166
+ end
167
+
168
+ if attributes.key?(:'room')
169
+ self.room = attributes[:'room']
170
+ end
171
+
172
+ if attributes.key?(:'post_code')
173
+ self.post_code = attributes[:'post_code']
174
+ end
175
+
176
+ if attributes.key?(:'town_name')
177
+ self.town_name = attributes[:'town_name']
178
+ end
179
+
180
+ if attributes.key?(:'town_location_name')
181
+ self.town_location_name = attributes[:'town_location_name']
182
+ end
183
+
184
+ if attributes.key?(:'district_name')
185
+ self.district_name = attributes[:'district_name']
186
+ end
187
+
188
+ if attributes.key?(:'country_sub_division')
189
+ self.country_sub_division = attributes[:'country_sub_division']
190
+ end
191
+
192
+ if attributes.key?(:'address_line')
193
+ if (value = attributes[:'address_line']).is_a?(Array)
194
+ self.address_line = value
195
+ end
196
+ end
197
+
198
+ if attributes.key?(:'country')
199
+ self.country = attributes[:'country']
200
+ end
201
+ end
202
+
203
+ # Show invalid properties with the reasons. Usually used together with valid?
204
+ # @return Array for valid properties with the reasons
205
+ def list_invalid_properties
206
+ invalid_properties = Array.new
207
+ invalid_properties
208
+ end
209
+
210
+ # Check to see if the all the properties in the model are valid
211
+ # @return true if the model is valid
212
+ def valid?
213
+ address_type_validator = EnumAttributeValidator.new('String', ["HOME", "BIZZ", "GEOG"])
214
+ return false unless address_type_validator.valid?(@address_type)
215
+ true
216
+ end
217
+
218
+ # Custom attribute writer method checking allowed values (enum).
219
+ # @param [Object] address_type Object to be assigned
220
+ def address_type=(address_type)
221
+ validator = EnumAttributeValidator.new('String', ["HOME", "BIZZ", "GEOG"])
222
+ unless validator.valid?(address_type)
223
+ fail ArgumentError, "invalid value for \"address_type\", must be one of #{validator.allowable_values}."
224
+ end
225
+ @address_type = address_type
226
+ end
227
+
228
+ # Checks equality by comparing each attribute.
229
+ # @param [Object] Object to be compared
230
+ def ==(o)
231
+ return true if self.equal?(o)
232
+ self.class == o.class &&
233
+ address_type == o.address_type &&
234
+ department == o.department &&
235
+ sub_department == o.sub_department &&
236
+ street_name == o.street_name &&
237
+ building_number == o.building_number &&
238
+ building_name == o.building_name &&
239
+ floor == o.floor &&
240
+ post_box == o.post_box &&
241
+ room == o.room &&
242
+ post_code == o.post_code &&
243
+ town_name == o.town_name &&
244
+ town_location_name == o.town_location_name &&
245
+ district_name == o.district_name &&
246
+ country_sub_division == o.country_sub_division &&
247
+ address_line == o.address_line &&
248
+ country == o.country
249
+ end
250
+
251
+ # @see the `==` method
252
+ # @param [Object] Object to be compared
253
+ def eql?(o)
254
+ self == o
255
+ end
256
+
257
+ # Calculates hash code according to all attributes.
258
+ # @return [Integer] Hash code
259
+ def hash
260
+ [address_type, department, sub_department, street_name, building_number, building_name, floor, post_box, room, post_code, town_name, town_location_name, district_name, country_sub_division, address_line, country].hash
261
+ end
262
+
263
+ # Builds the object from hash
264
+ # @param [Hash] attributes Model attributes in the form of hash
265
+ # @return [Object] Returns the model itself
266
+ def self.build_from_hash(attributes)
267
+ new.build_from_hash(attributes)
268
+ end
269
+
270
+ # Builds the object from hash
271
+ # @param [Hash] attributes Model attributes in the form of hash
272
+ # @return [Object] Returns the model itself
273
+ def build_from_hash(attributes)
274
+ return nil unless attributes.is_a?(Hash)
275
+ self.class.openapi_types.each_pair do |key, type|
276
+ if type =~ /\AArray<(.*)>/i
277
+ # check to ensure the input is an array given that the attribute
278
+ # is documented as an array but the input is not
279
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
280
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
281
+ end
282
+ elsif !attributes[self.class.attribute_map[key]].nil?
283
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
284
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
285
+ end
286
+
287
+ self
288
+ end
289
+
290
+ # Deserializes the data based on type
291
+ # @param string type Data type
292
+ # @param string value Value to be deserialized
293
+ # @return [Object] Deserialized data
294
+ def _deserialize(type, value)
295
+ case type.to_sym
296
+ when :DateTime
297
+ DateTime.parse(value)
298
+ when :Date
299
+ Date.parse(value)
300
+ when :String
301
+ value.to_s
302
+ when :Integer
303
+ value.to_i
304
+ when :Float
305
+ value.to_f
306
+ when :Boolean
307
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
308
+ true
309
+ else
310
+ false
311
+ end
312
+ when :Object
313
+ # generic object (usually a Hash), return directly
314
+ value
315
+ when /\AArray<(?<inner_type>.+)>\z/
316
+ inner_type = Regexp.last_match[:inner_type]
317
+ value.map { |v| _deserialize(inner_type, v) }
318
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
319
+ k_type = Regexp.last_match[:k_type]
320
+ v_type = Regexp.last_match[:v_type]
321
+ {}.tap do |hash|
322
+ value.each do |k, v|
323
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
324
+ end
325
+ end
326
+ else # model
327
+ SygnaBridgeIvmsUtil.const_get(type).build_from_hash(value)
328
+ end
329
+ end
330
+
331
+ # Returns the string representation of the object
332
+ # @return [String] String presentation of the object
333
+ def to_s
334
+ to_hash.to_s
335
+ end
336
+
337
+ # to_body is an alias to to_hash (backward compatibility)
338
+ # @return [Hash] Returns the object in the form of hash
339
+ def to_body
340
+ to_hash
341
+ end
342
+
343
+ # Returns the object in the form of hash
344
+ # @return [Hash] Returns the object in the form of hash
345
+ def to_hash
346
+ hash = {}
347
+ self.class.attribute_map.each_pair do |attr, param|
348
+ value = self.send(attr)
349
+ if value.nil?
350
+ is_nullable = self.class.openapi_nullable.include?(attr)
351
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
352
+ end
353
+
354
+ hash[param] = _to_hash(value)
355
+ end
356
+ hash
357
+ end
358
+
359
+ # Outputs non-array value in the form of hash
360
+ # For object, use to_hash. Otherwise, just return the value
361
+ # @param [Object] value Any valid value
362
+ # @return [Hash] Returns the value in the form of hash
363
+ def _to_hash(value)
364
+ if value.is_a?(Array)
365
+ value.compact.map { |v| _to_hash(v) }
366
+ elsif value.is_a?(Hash)
367
+ {}.tap do |hash|
368
+ value.each { |k, v| hash[k] = _to_hash(v) }
369
+ end
370
+ elsif value.respond_to? :to_hash
371
+ value.to_hash
372
+ else
373
+ value
374
+ end
375
+ end
376
+ end
377
+ end
@@ -0,0 +1,37 @@
1
+ =begin
2
+ #Bridge
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SygnaBridgeIvmsUtil
16
+ class AddressTypeCode
17
+ HOME = "HOME".freeze
18
+ BIZZ = "BIZZ".freeze
19
+ GEOG = "GEOG".freeze
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ constantValues = AddressTypeCode.constants.select { |c| AddressTypeCode::const_get(c) == value }
33
+ raise "Invalid ENUM value #{value} for class #AddressTypeCode" if constantValues.empty?
34
+ value
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,219 @@
1
+ =begin
2
+ #Bridge
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SygnaBridgeIvmsUtil
16
+ class Beneficiary
17
+ attr_accessor :beneficiary_persons
18
+
19
+ attr_accessor :account_numbers
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'beneficiary_persons' => :'beneficiary_persons',
25
+ :'account_numbers' => :'account_numbers'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.openapi_types
31
+ {
32
+ :'beneficiary_persons' => :'Array<Person>',
33
+ :'account_numbers' => :'Array<String>'
34
+ }
35
+ end
36
+
37
+ # List of attributes with nullable: true
38
+ def self.openapi_nullable
39
+ Set.new([
40
+ ])
41
+ end
42
+
43
+ # Initializes the object
44
+ # @param [Hash] attributes Model attributes in the form of hash
45
+ def initialize(attributes = {})
46
+ if (!attributes.is_a?(Hash))
47
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SygnaBridgeIvmsUtil::Beneficiary` initialize method"
48
+ end
49
+
50
+ # check to see if the attribute exists and convert string to symbol for hash key
51
+ attributes = attributes.each_with_object({}) { |(k, v), h|
52
+ if (!self.class.attribute_map.key?(k.to_sym))
53
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SygnaBridgeIvmsUtil::Beneficiary`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
54
+ end
55
+ h[k.to_sym] = v
56
+ }
57
+
58
+ if attributes.key?(:'beneficiary_persons')
59
+ if (value = attributes[:'beneficiary_persons']).is_a?(Array)
60
+ self.beneficiary_persons = value
61
+ end
62
+ end
63
+
64
+ if attributes.key?(:'account_numbers')
65
+ if (value = attributes[:'account_numbers']).is_a?(Array)
66
+ self.account_numbers = value
67
+ end
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ invalid_properties = Array.new
75
+ invalid_properties
76
+ end
77
+
78
+ # Check to see if the all the properties in the model are valid
79
+ # @return true if the model is valid
80
+ def valid?
81
+ true
82
+ end
83
+
84
+ # Checks equality by comparing each attribute.
85
+ # @param [Object] Object to be compared
86
+ def ==(o)
87
+ return true if self.equal?(o)
88
+ self.class == o.class &&
89
+ beneficiary_persons == o.beneficiary_persons &&
90
+ account_numbers == o.account_numbers
91
+ end
92
+
93
+ # @see the `==` method
94
+ # @param [Object] Object to be compared
95
+ def eql?(o)
96
+ self == o
97
+ end
98
+
99
+ # Calculates hash code according to all attributes.
100
+ # @return [Integer] Hash code
101
+ def hash
102
+ [beneficiary_persons, account_numbers].hash
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def self.build_from_hash(attributes)
109
+ new.build_from_hash(attributes)
110
+ end
111
+
112
+ # Builds the object from hash
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ # @return [Object] Returns the model itself
115
+ def build_from_hash(attributes)
116
+ return nil unless attributes.is_a?(Hash)
117
+ self.class.openapi_types.each_pair do |key, type|
118
+ if type =~ /\AArray<(.*)>/i
119
+ # check to ensure the input is an array given that the attribute
120
+ # is documented as an array but the input is not
121
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
122
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
123
+ end
124
+ elsif !attributes[self.class.attribute_map[key]].nil?
125
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
126
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
127
+ end
128
+
129
+ self
130
+ end
131
+
132
+ # Deserializes the data based on type
133
+ # @param string type Data type
134
+ # @param string value Value to be deserialized
135
+ # @return [Object] Deserialized data
136
+ def _deserialize(type, value)
137
+ case type.to_sym
138
+ when :DateTime
139
+ DateTime.parse(value)
140
+ when :Date
141
+ Date.parse(value)
142
+ when :String
143
+ value.to_s
144
+ when :Integer
145
+ value.to_i
146
+ when :Float
147
+ value.to_f
148
+ when :Boolean
149
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
150
+ true
151
+ else
152
+ false
153
+ end
154
+ when :Object
155
+ # generic object (usually a Hash), return directly
156
+ value
157
+ when /\AArray<(?<inner_type>.+)>\z/
158
+ inner_type = Regexp.last_match[:inner_type]
159
+ value.map { |v| _deserialize(inner_type, v) }
160
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
161
+ k_type = Regexp.last_match[:k_type]
162
+ v_type = Regexp.last_match[:v_type]
163
+ {}.tap do |hash|
164
+ value.each do |k, v|
165
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
166
+ end
167
+ end
168
+ else # model
169
+ SygnaBridgeIvmsUtil.const_get(type).build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ if value.nil?
192
+ is_nullable = self.class.openapi_nullable.include?(attr)
193
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
194
+ end
195
+
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+ end
219
+ end