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 ServiceBodyUpdate
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::ServiceBodyUpdate` 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::ServiceBodyUpdate`. 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,266 @@
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 Token
18
+ attr_accessor :access_token
19
+
20
+ attr_accessor :expires_at
21
+
22
+ attr_accessor :token_type
23
+
24
+ attr_accessor :user_id
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'access_token' => :'access_token',
30
+ :'expires_at' => :'expires_at',
31
+ :'token_type' => :'token_type',
32
+ :'user_id' => :'user_id'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'access_token' => :'String',
45
+ :'expires_at' => :'Integer',
46
+ :'token_type' => :'String',
47
+ :'user_id' => :'Integer'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BmltClient::Token` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BmltClient::Token`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'access_token')
73
+ self.access_token = attributes[:'access_token']
74
+ end
75
+
76
+ if attributes.key?(:'expires_at')
77
+ self.expires_at = attributes[:'expires_at']
78
+ end
79
+
80
+ if attributes.key?(:'token_type')
81
+ self.token_type = attributes[:'token_type']
82
+ end
83
+
84
+ if attributes.key?(:'user_id')
85
+ self.user_id = attributes[:'user_id']
86
+ end
87
+ end
88
+
89
+ # Show invalid properties with the reasons. Usually used together with valid?
90
+ # @return Array for valid properties with the reasons
91
+ def list_invalid_properties
92
+ invalid_properties = Array.new
93
+ if @access_token.nil?
94
+ invalid_properties.push('invalid value for "access_token", access_token cannot be nil.')
95
+ end
96
+
97
+ if @expires_at.nil?
98
+ invalid_properties.push('invalid value for "expires_at", expires_at cannot be nil.')
99
+ end
100
+
101
+ if @token_type.nil?
102
+ invalid_properties.push('invalid value for "token_type", token_type cannot be nil.')
103
+ end
104
+
105
+ if @user_id.nil?
106
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
107
+ end
108
+
109
+ invalid_properties
110
+ end
111
+
112
+ # Check to see if the all the properties in the model are valid
113
+ # @return true if the model is valid
114
+ def valid?
115
+ return false if @access_token.nil?
116
+ return false if @expires_at.nil?
117
+ return false if @token_type.nil?
118
+ return false if @user_id.nil?
119
+ true
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ access_token == o.access_token &&
128
+ expires_at == o.expires_at &&
129
+ token_type == o.token_type &&
130
+ user_id == o.user_id
131
+ end
132
+
133
+ # @see the `==` method
134
+ # @param [Object] Object to be compared
135
+ def eql?(o)
136
+ self == o
137
+ end
138
+
139
+ # Calculates hash code according to all attributes.
140
+ # @return [Integer] Hash code
141
+ def hash
142
+ [access_token, expires_at, token_type, user_id].hash
143
+ end
144
+
145
+ # Builds the object from hash
146
+ # @param [Hash] attributes Model attributes in the form of hash
147
+ # @return [Object] Returns the model itself
148
+ def self.build_from_hash(attributes)
149
+ new.build_from_hash(attributes)
150
+ end
151
+
152
+ # Builds the object from hash
153
+ # @param [Hash] attributes Model attributes in the form of hash
154
+ # @return [Object] Returns the model itself
155
+ def build_from_hash(attributes)
156
+ return nil unless attributes.is_a?(Hash)
157
+ attributes = attributes.transform_keys(&:to_sym)
158
+ self.class.openapi_types.each_pair do |key, type|
159
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
160
+ self.send("#{key}=", nil)
161
+ elsif type =~ /\AArray<(.*)>/i
162
+ # check to ensure the input is an array given that the attribute
163
+ # is documented as an array but the input is not
164
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
165
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
166
+ end
167
+ elsif !attributes[self.class.attribute_map[key]].nil?
168
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
169
+ end
170
+ end
171
+
172
+ self
173
+ end
174
+
175
+ # Deserializes the data based on type
176
+ # @param string type Data type
177
+ # @param string value Value to be deserialized
178
+ # @return [Object] Deserialized data
179
+ def _deserialize(type, value)
180
+ case type.to_sym
181
+ when :Time
182
+ Time.parse(value)
183
+ when :Date
184
+ Date.parse(value)
185
+ when :String
186
+ value.to_s
187
+ when :Integer
188
+ value.to_i
189
+ when :Float
190
+ value.to_f
191
+ when :Boolean
192
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
193
+ true
194
+ else
195
+ false
196
+ end
197
+ when :Object
198
+ # generic object (usually a Hash), return directly
199
+ value
200
+ when /\AArray<(?<inner_type>.+)>\z/
201
+ inner_type = Regexp.last_match[:inner_type]
202
+ value.map { |v| _deserialize(inner_type, v) }
203
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
204
+ k_type = Regexp.last_match[:k_type]
205
+ v_type = Regexp.last_match[:v_type]
206
+ {}.tap do |hash|
207
+ value.each do |k, v|
208
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
209
+ end
210
+ end
211
+ else # model
212
+ # models (e.g. Pet) or oneOf
213
+ klass = BmltClient.const_get(type)
214
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
215
+ end
216
+ end
217
+
218
+ # Returns the string representation of the object
219
+ # @return [String] String presentation of the object
220
+ def to_s
221
+ to_hash.to_s
222
+ end
223
+
224
+ # to_body is an alias to to_hash (backward compatibility)
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_body
227
+ to_hash
228
+ end
229
+
230
+ # Returns the object in the form of hash
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_hash
233
+ hash = {}
234
+ self.class.attribute_map.each_pair do |attr, param|
235
+ value = self.send(attr)
236
+ if value.nil?
237
+ is_nullable = self.class.openapi_nullable.include?(attr)
238
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
239
+ end
240
+
241
+ hash[param] = _to_hash(value)
242
+ end
243
+ hash
244
+ end
245
+
246
+ # Outputs non-array value in the form of hash
247
+ # For object, use to_hash. Otherwise, just return the value
248
+ # @param [Object] value Any valid value
249
+ # @return [Hash] Returns the value in the form of hash
250
+ def _to_hash(value)
251
+ if value.is_a?(Array)
252
+ value.compact.map { |v| _to_hash(v) }
253
+ elsif value.is_a?(Hash)
254
+ {}.tap do |hash|
255
+ value.each { |k, v| hash[k] = _to_hash(v) }
256
+ end
257
+ elsif value.respond_to? :to_hash
258
+ value.to_hash
259
+ else
260
+ value
261
+ end
262
+ end
263
+
264
+ end
265
+
266
+ end