BmltClient 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/BmltClient.gemspec +38 -0
  3. data/Gemfile +9 -0
  4. data/Makefile +22 -0
  5. data/README.md +157 -0
  6. data/Rakefile +10 -0
  7. data/docs/AuthenticationError.md +18 -0
  8. data/docs/AuthorizationError.md +18 -0
  9. data/docs/ErrorTest.md +22 -0
  10. data/docs/Format.md +24 -0
  11. data/docs/FormatAllOf.md +18 -0
  12. data/docs/FormatBase.md +22 -0
  13. data/docs/FormatCreate.md +22 -0
  14. data/docs/FormatPartialUpdate.md +22 -0
  15. data/docs/FormatTranslation.md +24 -0
  16. data/docs/FormatUpdate.md +22 -0
  17. data/docs/Meeting.md +90 -0
  18. data/docs/MeetingBase.md +88 -0
  19. data/docs/MeetingCreate.md +88 -0
  20. data/docs/MeetingPartialUpdate.md +88 -0
  21. data/docs/MeetingUpdate.md +88 -0
  22. data/docs/NotFoundError.md +18 -0
  23. data/docs/RootServerApi.md +1958 -0
  24. data/docs/ServerError.md +18 -0
  25. data/docs/ServiceBody.md +38 -0
  26. data/docs/ServiceBodyBase.md +36 -0
  27. data/docs/ServiceBodyCreate.md +36 -0
  28. data/docs/ServiceBodyPartialUpdate.md +36 -0
  29. data/docs/ServiceBodyUpdate.md +36 -0
  30. data/docs/Token.md +24 -0
  31. data/docs/TokenCredentials.md +20 -0
  32. data/docs/User.md +30 -0
  33. data/docs/UserBase.md +28 -0
  34. data/docs/UserCreate.md +30 -0
  35. data/docs/UserCreateAllOf.md +18 -0
  36. data/docs/UserPartialUpdate.md +30 -0
  37. data/docs/UserUpdate.md +30 -0
  38. data/docs/ValidationError.md +20 -0
  39. data/git_push.sh +57 -0
  40. data/lib/BmltClient/api/root_server_api.rb +1880 -0
  41. data/lib/BmltClient/api_client.rb +392 -0
  42. data/lib/BmltClient/api_error.rb +57 -0
  43. data/lib/BmltClient/configuration.rb +279 -0
  44. data/lib/BmltClient/models/authentication_error.rb +224 -0
  45. data/lib/BmltClient/models/authorization_error.rb +224 -0
  46. data/lib/BmltClient/models/error_test.rb +237 -0
  47. data/lib/BmltClient/models/format.rb +276 -0
  48. data/lib/BmltClient/models/format_all_of.rb +219 -0
  49. data/lib/BmltClient/models/format_base.rb +239 -0
  50. data/lib/BmltClient/models/format_create.rb +251 -0
  51. data/lib/BmltClient/models/format_partial_update.rb +246 -0
  52. data/lib/BmltClient/models/format_translation.rb +266 -0
  53. data/lib/BmltClient/models/format_update.rb +251 -0
  54. data/lib/BmltClient/models/meeting.rb +628 -0
  55. data/lib/BmltClient/models/meeting_base.rb +536 -0
  56. data/lib/BmltClient/models/meeting_create.rb +593 -0
  57. data/lib/BmltClient/models/meeting_partial_update.rb +593 -0
  58. data/lib/BmltClient/models/meeting_update.rb +593 -0
  59. data/lib/BmltClient/models/not_found_error.rb +224 -0
  60. data/lib/BmltClient/models/server_error.rb +224 -0
  61. data/lib/BmltClient/models/service_body.rb +374 -0
  62. data/lib/BmltClient/models/service_body_base.rb +302 -0
  63. data/lib/BmltClient/models/service_body_create.rb +339 -0
  64. data/lib/BmltClient/models/service_body_partial_update.rb +309 -0
  65. data/lib/BmltClient/models/service_body_update.rb +339 -0
  66. data/lib/BmltClient/models/token.rb +266 -0
  67. data/lib/BmltClient/models/token_credentials.rb +238 -0
  68. data/lib/BmltClient/models/user.rb +316 -0
  69. data/lib/BmltClient/models/user_base.rb +264 -0
  70. data/lib/BmltClient/models/user_create.rb +301 -0
  71. data/lib/BmltClient/models/user_create_all_of.rb +219 -0
  72. data/lib/BmltClient/models/user_partial_update.rb +281 -0
  73. data/lib/BmltClient/models/user_update.rb +296 -0
  74. data/lib/BmltClient/models/validation_error.rb +240 -0
  75. data/lib/BmltClient/version.rb +15 -0
  76. data/lib/BmltClient.rb +71 -0
  77. data/openapi.json +1 -0
  78. data/spec/api/root_server_api_spec.rb +377 -0
  79. data/spec/api_client_spec.rb +226 -0
  80. data/spec/configuration_spec.rb +42 -0
  81. data/spec/models/authentication_error_spec.rb +34 -0
  82. data/spec/models/authorization_error_spec.rb +34 -0
  83. data/spec/models/error_test_spec.rb +46 -0
  84. data/spec/models/format_all_of_spec.rb +34 -0
  85. data/spec/models/format_base_spec.rb +46 -0
  86. data/spec/models/format_create_spec.rb +46 -0
  87. data/spec/models/format_partial_update_spec.rb +46 -0
  88. data/spec/models/format_spec.rb +52 -0
  89. data/spec/models/format_translation_spec.rb +52 -0
  90. data/spec/models/format_update_spec.rb +46 -0
  91. data/spec/models/meeting_base_spec.rb +244 -0
  92. data/spec/models/meeting_create_spec.rb +244 -0
  93. data/spec/models/meeting_partial_update_spec.rb +244 -0
  94. data/spec/models/meeting_spec.rb +250 -0
  95. data/spec/models/meeting_update_spec.rb +244 -0
  96. data/spec/models/not_found_error_spec.rb +34 -0
  97. data/spec/models/server_error_spec.rb +34 -0
  98. data/spec/models/service_body_base_spec.rb +88 -0
  99. data/spec/models/service_body_create_spec.rb +88 -0
  100. data/spec/models/service_body_partial_update_spec.rb +88 -0
  101. data/spec/models/service_body_spec.rb +94 -0
  102. data/spec/models/service_body_update_spec.rb +88 -0
  103. data/spec/models/token_credentials_spec.rb +40 -0
  104. data/spec/models/token_spec.rb +52 -0
  105. data/spec/models/user_base_spec.rb +64 -0
  106. data/spec/models/user_create_all_of_spec.rb +34 -0
  107. data/spec/models/user_create_spec.rb +70 -0
  108. data/spec/models/user_partial_update_spec.rb +70 -0
  109. data/spec/models/user_spec.rb +70 -0
  110. data/spec/models/user_update_spec.rb +70 -0
  111. data/spec/models/validation_error_spec.rb +40 -0
  112. data/spec/spec_helper.rb +111 -0
  113. metadata +229 -0
@@ -0,0 +1,339 @@
1
+ =begin
2
+ #BMLT
3
+
4
+ #BMLT Admin API Documentation
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.2.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BmltClient
17
+ class ServiceBodyCreate
18
+ attr_accessor :parent_id
19
+
20
+ attr_accessor :name
21
+
22
+ attr_accessor :description
23
+
24
+ attr_accessor :type
25
+
26
+ attr_accessor :admin_user_id
27
+
28
+ attr_accessor :assigned_user_ids
29
+
30
+ attr_accessor :url
31
+
32
+ attr_accessor :helpline
33
+
34
+ attr_accessor :email
35
+
36
+ attr_accessor :world_id
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'parent_id' => :'parentId',
42
+ :'name' => :'name',
43
+ :'description' => :'description',
44
+ :'type' => :'type',
45
+ :'admin_user_id' => :'adminUserId',
46
+ :'assigned_user_ids' => :'assignedUserIds',
47
+ :'url' => :'url',
48
+ :'helpline' => :'helpline',
49
+ :'email' => :'email',
50
+ :'world_id' => :'worldId'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'parent_id' => :'Integer',
63
+ :'name' => :'String',
64
+ :'description' => :'String',
65
+ :'type' => :'String',
66
+ :'admin_user_id' => :'Integer',
67
+ :'assigned_user_ids' => :'Array<Integer>',
68
+ :'url' => :'String',
69
+ :'helpline' => :'String',
70
+ :'email' => :'String',
71
+ :'world_id' => :'String'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.openapi_nullable
77
+ Set.new([
78
+ ])
79
+ end
80
+
81
+ # List of class defined in allOf (OpenAPI v3)
82
+ def self.openapi_all_of
83
+ [
84
+ :'ServiceBodyBase'
85
+ ]
86
+ end
87
+
88
+ # Initializes the object
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ def initialize(attributes = {})
91
+ if (!attributes.is_a?(Hash))
92
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BmltClient::ServiceBodyCreate` initialize method"
93
+ end
94
+
95
+ # check to see if the attribute exists and convert string to symbol for hash key
96
+ attributes = attributes.each_with_object({}) { |(k, v), h|
97
+ if (!self.class.attribute_map.key?(k.to_sym))
98
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BmltClient::ServiceBodyCreate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
99
+ end
100
+ h[k.to_sym] = v
101
+ }
102
+
103
+ if attributes.key?(:'parent_id')
104
+ self.parent_id = attributes[:'parent_id']
105
+ end
106
+
107
+ if attributes.key?(:'name')
108
+ self.name = attributes[:'name']
109
+ end
110
+
111
+ if attributes.key?(:'description')
112
+ self.description = attributes[:'description']
113
+ end
114
+
115
+ if attributes.key?(:'type')
116
+ self.type = attributes[:'type']
117
+ end
118
+
119
+ if attributes.key?(:'admin_user_id')
120
+ self.admin_user_id = attributes[:'admin_user_id']
121
+ end
122
+
123
+ if attributes.key?(:'assigned_user_ids')
124
+ if (value = attributes[:'assigned_user_ids']).is_a?(Array)
125
+ self.assigned_user_ids = value
126
+ end
127
+ end
128
+
129
+ if attributes.key?(:'url')
130
+ self.url = attributes[:'url']
131
+ end
132
+
133
+ if attributes.key?(:'helpline')
134
+ self.helpline = attributes[:'helpline']
135
+ end
136
+
137
+ if attributes.key?(:'email')
138
+ self.email = attributes[:'email']
139
+ end
140
+
141
+ if attributes.key?(:'world_id')
142
+ self.world_id = attributes[:'world_id']
143
+ end
144
+ end
145
+
146
+ # Show invalid properties with the reasons. Usually used together with valid?
147
+ # @return Array for valid properties with the reasons
148
+ def list_invalid_properties
149
+ invalid_properties = Array.new
150
+ if @parent_id.nil?
151
+ invalid_properties.push('invalid value for "parent_id", parent_id cannot be nil.')
152
+ end
153
+
154
+ if @name.nil?
155
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
156
+ end
157
+
158
+ if @description.nil?
159
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
160
+ end
161
+
162
+ if @type.nil?
163
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
164
+ end
165
+
166
+ if @admin_user_id.nil?
167
+ invalid_properties.push('invalid value for "admin_user_id", admin_user_id cannot be nil.')
168
+ end
169
+
170
+ if @assigned_user_ids.nil?
171
+ invalid_properties.push('invalid value for "assigned_user_ids", assigned_user_ids cannot be nil.')
172
+ end
173
+
174
+ invalid_properties
175
+ end
176
+
177
+ # Check to see if the all the properties in the model are valid
178
+ # @return true if the model is valid
179
+ def valid?
180
+ return false if @parent_id.nil?
181
+ return false if @name.nil?
182
+ return false if @description.nil?
183
+ return false if @type.nil?
184
+ return false if @admin_user_id.nil?
185
+ return false if @assigned_user_ids.nil?
186
+ true
187
+ end
188
+
189
+ # Checks equality by comparing each attribute.
190
+ # @param [Object] Object to be compared
191
+ def ==(o)
192
+ return true if self.equal?(o)
193
+ self.class == o.class &&
194
+ parent_id == o.parent_id &&
195
+ name == o.name &&
196
+ description == o.description &&
197
+ type == o.type &&
198
+ admin_user_id == o.admin_user_id &&
199
+ assigned_user_ids == o.assigned_user_ids &&
200
+ url == o.url &&
201
+ helpline == o.helpline &&
202
+ email == o.email &&
203
+ world_id == o.world_id
204
+ end
205
+
206
+ # @see the `==` method
207
+ # @param [Object] Object to be compared
208
+ def eql?(o)
209
+ self == o
210
+ end
211
+
212
+ # Calculates hash code according to all attributes.
213
+ # @return [Integer] Hash code
214
+ def hash
215
+ [parent_id, name, description, type, admin_user_id, assigned_user_ids, url, helpline, email, world_id].hash
216
+ end
217
+
218
+ # Builds the object from hash
219
+ # @param [Hash] attributes Model attributes in the form of hash
220
+ # @return [Object] Returns the model itself
221
+ def self.build_from_hash(attributes)
222
+ new.build_from_hash(attributes)
223
+ end
224
+
225
+ # Builds the object from hash
226
+ # @param [Hash] attributes Model attributes in the form of hash
227
+ # @return [Object] Returns the model itself
228
+ def build_from_hash(attributes)
229
+ return nil unless attributes.is_a?(Hash)
230
+ attributes = attributes.transform_keys(&:to_sym)
231
+ self.class.openapi_types.each_pair do |key, type|
232
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
233
+ self.send("#{key}=", nil)
234
+ elsif type =~ /\AArray<(.*)>/i
235
+ # check to ensure the input is an array given that the attribute
236
+ # is documented as an array but the input is not
237
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
238
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
239
+ end
240
+ elsif !attributes[self.class.attribute_map[key]].nil?
241
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
242
+ end
243
+ end
244
+
245
+ self
246
+ end
247
+
248
+ # Deserializes the data based on type
249
+ # @param string type Data type
250
+ # @param string value Value to be deserialized
251
+ # @return [Object] Deserialized data
252
+ def _deserialize(type, value)
253
+ case type.to_sym
254
+ when :Time
255
+ Time.parse(value)
256
+ when :Date
257
+ Date.parse(value)
258
+ when :String
259
+ value.to_s
260
+ when :Integer
261
+ value.to_i
262
+ when :Float
263
+ value.to_f
264
+ when :Boolean
265
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
266
+ true
267
+ else
268
+ false
269
+ end
270
+ when :Object
271
+ # generic object (usually a Hash), return directly
272
+ value
273
+ when /\AArray<(?<inner_type>.+)>\z/
274
+ inner_type = Regexp.last_match[:inner_type]
275
+ value.map { |v| _deserialize(inner_type, v) }
276
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
277
+ k_type = Regexp.last_match[:k_type]
278
+ v_type = Regexp.last_match[:v_type]
279
+ {}.tap do |hash|
280
+ value.each do |k, v|
281
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
282
+ end
283
+ end
284
+ else # model
285
+ # models (e.g. Pet) or oneOf
286
+ klass = BmltClient.const_get(type)
287
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
288
+ end
289
+ end
290
+
291
+ # Returns the string representation of the object
292
+ # @return [String] String presentation of the object
293
+ def to_s
294
+ to_hash.to_s
295
+ end
296
+
297
+ # to_body is an alias to to_hash (backward compatibility)
298
+ # @return [Hash] Returns the object in the form of hash
299
+ def to_body
300
+ to_hash
301
+ end
302
+
303
+ # Returns the object in the form of hash
304
+ # @return [Hash] Returns the object in the form of hash
305
+ def to_hash
306
+ hash = {}
307
+ self.class.attribute_map.each_pair do |attr, param|
308
+ value = self.send(attr)
309
+ if value.nil?
310
+ is_nullable = self.class.openapi_nullable.include?(attr)
311
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
312
+ end
313
+
314
+ hash[param] = _to_hash(value)
315
+ end
316
+ hash
317
+ end
318
+
319
+ # Outputs non-array value in the form of hash
320
+ # For object, use to_hash. Otherwise, just return the value
321
+ # @param [Object] value Any valid value
322
+ # @return [Hash] Returns the value in the form of hash
323
+ def _to_hash(value)
324
+ if value.is_a?(Array)
325
+ value.compact.map { |v| _to_hash(v) }
326
+ elsif value.is_a?(Hash)
327
+ {}.tap do |hash|
328
+ value.each { |k, v| hash[k] = _to_hash(v) }
329
+ end
330
+ elsif value.respond_to? :to_hash
331
+ value.to_hash
332
+ else
333
+ value
334
+ end
335
+ end
336
+
337
+ end
338
+
339
+ end
@@ -0,0 +1,309 @@
1
+ =begin
2
+ #BMLT
3
+
4
+ #BMLT Admin API Documentation
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.2.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BmltClient
17
+ class ServiceBodyPartialUpdate
18
+ attr_accessor :parent_id
19
+
20
+ attr_accessor :name
21
+
22
+ attr_accessor :description
23
+
24
+ attr_accessor :type
25
+
26
+ attr_accessor :admin_user_id
27
+
28
+ attr_accessor :assigned_user_ids
29
+
30
+ attr_accessor :url
31
+
32
+ attr_accessor :helpline
33
+
34
+ attr_accessor :email
35
+
36
+ attr_accessor :world_id
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'parent_id' => :'parentId',
42
+ :'name' => :'name',
43
+ :'description' => :'description',
44
+ :'type' => :'type',
45
+ :'admin_user_id' => :'adminUserId',
46
+ :'assigned_user_ids' => :'assignedUserIds',
47
+ :'url' => :'url',
48
+ :'helpline' => :'helpline',
49
+ :'email' => :'email',
50
+ :'world_id' => :'worldId'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'parent_id' => :'Integer',
63
+ :'name' => :'String',
64
+ :'description' => :'String',
65
+ :'type' => :'String',
66
+ :'admin_user_id' => :'Integer',
67
+ :'assigned_user_ids' => :'Array<Integer>',
68
+ :'url' => :'String',
69
+ :'helpline' => :'String',
70
+ :'email' => :'String',
71
+ :'world_id' => :'String'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.openapi_nullable
77
+ Set.new([
78
+ ])
79
+ end
80
+
81
+ # List of class defined in allOf (OpenAPI v3)
82
+ def self.openapi_all_of
83
+ [
84
+ :'ServiceBodyBase'
85
+ ]
86
+ end
87
+
88
+ # Initializes the object
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ def initialize(attributes = {})
91
+ if (!attributes.is_a?(Hash))
92
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BmltClient::ServiceBodyPartialUpdate` initialize method"
93
+ end
94
+
95
+ # check to see if the attribute exists and convert string to symbol for hash key
96
+ attributes = attributes.each_with_object({}) { |(k, v), h|
97
+ if (!self.class.attribute_map.key?(k.to_sym))
98
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BmltClient::ServiceBodyPartialUpdate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
99
+ end
100
+ h[k.to_sym] = v
101
+ }
102
+
103
+ if attributes.key?(:'parent_id')
104
+ self.parent_id = attributes[:'parent_id']
105
+ end
106
+
107
+ if attributes.key?(:'name')
108
+ self.name = attributes[:'name']
109
+ end
110
+
111
+ if attributes.key?(:'description')
112
+ self.description = attributes[:'description']
113
+ end
114
+
115
+ if attributes.key?(:'type')
116
+ self.type = attributes[:'type']
117
+ end
118
+
119
+ if attributes.key?(:'admin_user_id')
120
+ self.admin_user_id = attributes[:'admin_user_id']
121
+ end
122
+
123
+ if attributes.key?(:'assigned_user_ids')
124
+ if (value = attributes[:'assigned_user_ids']).is_a?(Array)
125
+ self.assigned_user_ids = value
126
+ end
127
+ end
128
+
129
+ if attributes.key?(:'url')
130
+ self.url = attributes[:'url']
131
+ end
132
+
133
+ if attributes.key?(:'helpline')
134
+ self.helpline = attributes[:'helpline']
135
+ end
136
+
137
+ if attributes.key?(:'email')
138
+ self.email = attributes[:'email']
139
+ end
140
+
141
+ if attributes.key?(:'world_id')
142
+ self.world_id = attributes[:'world_id']
143
+ end
144
+ end
145
+
146
+ # Show invalid properties with the reasons. Usually used together with valid?
147
+ # @return Array for valid properties with the reasons
148
+ def list_invalid_properties
149
+ invalid_properties = Array.new
150
+ invalid_properties
151
+ end
152
+
153
+ # Check to see if the all the properties in the model are valid
154
+ # @return true if the model is valid
155
+ def valid?
156
+ true
157
+ end
158
+
159
+ # Checks equality by comparing each attribute.
160
+ # @param [Object] Object to be compared
161
+ def ==(o)
162
+ return true if self.equal?(o)
163
+ self.class == o.class &&
164
+ parent_id == o.parent_id &&
165
+ name == o.name &&
166
+ description == o.description &&
167
+ type == o.type &&
168
+ admin_user_id == o.admin_user_id &&
169
+ assigned_user_ids == o.assigned_user_ids &&
170
+ url == o.url &&
171
+ helpline == o.helpline &&
172
+ email == o.email &&
173
+ world_id == o.world_id
174
+ end
175
+
176
+ # @see the `==` method
177
+ # @param [Object] Object to be compared
178
+ def eql?(o)
179
+ self == o
180
+ end
181
+
182
+ # Calculates hash code according to all attributes.
183
+ # @return [Integer] Hash code
184
+ def hash
185
+ [parent_id, name, description, type, admin_user_id, assigned_user_ids, url, helpline, email, world_id].hash
186
+ end
187
+
188
+ # Builds the object from hash
189
+ # @param [Hash] attributes Model attributes in the form of hash
190
+ # @return [Object] Returns the model itself
191
+ def self.build_from_hash(attributes)
192
+ new.build_from_hash(attributes)
193
+ end
194
+
195
+ # Builds the object from hash
196
+ # @param [Hash] attributes Model attributes in the form of hash
197
+ # @return [Object] Returns the model itself
198
+ def build_from_hash(attributes)
199
+ return nil unless attributes.is_a?(Hash)
200
+ attributes = attributes.transform_keys(&:to_sym)
201
+ self.class.openapi_types.each_pair do |key, type|
202
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
203
+ self.send("#{key}=", nil)
204
+ elsif type =~ /\AArray<(.*)>/i
205
+ # check to ensure the input is an array given that the attribute
206
+ # is documented as an array but the input is not
207
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
208
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
209
+ end
210
+ elsif !attributes[self.class.attribute_map[key]].nil?
211
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
212
+ end
213
+ end
214
+
215
+ self
216
+ end
217
+
218
+ # Deserializes the data based on type
219
+ # @param string type Data type
220
+ # @param string value Value to be deserialized
221
+ # @return [Object] Deserialized data
222
+ def _deserialize(type, value)
223
+ case type.to_sym
224
+ when :Time
225
+ Time.parse(value)
226
+ when :Date
227
+ Date.parse(value)
228
+ when :String
229
+ value.to_s
230
+ when :Integer
231
+ value.to_i
232
+ when :Float
233
+ value.to_f
234
+ when :Boolean
235
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
236
+ true
237
+ else
238
+ false
239
+ end
240
+ when :Object
241
+ # generic object (usually a Hash), return directly
242
+ value
243
+ when /\AArray<(?<inner_type>.+)>\z/
244
+ inner_type = Regexp.last_match[:inner_type]
245
+ value.map { |v| _deserialize(inner_type, v) }
246
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
247
+ k_type = Regexp.last_match[:k_type]
248
+ v_type = Regexp.last_match[:v_type]
249
+ {}.tap do |hash|
250
+ value.each do |k, v|
251
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
252
+ end
253
+ end
254
+ else # model
255
+ # models (e.g. Pet) or oneOf
256
+ klass = BmltClient.const_get(type)
257
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
258
+ end
259
+ end
260
+
261
+ # Returns the string representation of the object
262
+ # @return [String] String presentation of the object
263
+ def to_s
264
+ to_hash.to_s
265
+ end
266
+
267
+ # to_body is an alias to to_hash (backward compatibility)
268
+ # @return [Hash] Returns the object in the form of hash
269
+ def to_body
270
+ to_hash
271
+ end
272
+
273
+ # Returns the object in the form of hash
274
+ # @return [Hash] Returns the object in the form of hash
275
+ def to_hash
276
+ hash = {}
277
+ self.class.attribute_map.each_pair do |attr, param|
278
+ value = self.send(attr)
279
+ if value.nil?
280
+ is_nullable = self.class.openapi_nullable.include?(attr)
281
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
282
+ end
283
+
284
+ hash[param] = _to_hash(value)
285
+ end
286
+ hash
287
+ end
288
+
289
+ # Outputs non-array value in the form of hash
290
+ # For object, use to_hash. Otherwise, just return the value
291
+ # @param [Object] value Any valid value
292
+ # @return [Hash] Returns the value in the form of hash
293
+ def _to_hash(value)
294
+ if value.is_a?(Array)
295
+ value.compact.map { |v| _to_hash(v) }
296
+ elsif value.is_a?(Hash)
297
+ {}.tap do |hash|
298
+ value.each { |k, v| hash[k] = _to_hash(v) }
299
+ end
300
+ elsif value.respond_to? :to_hash
301
+ value.to_hash
302
+ else
303
+ value
304
+ end
305
+ end
306
+
307
+ end
308
+
309
+ end