smplkit 1.0.15 → 1.0.17

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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/smplkit/_generated/app/lib/smplkit_app_client/api/products_api.rb +2 -2
  3. data/lib/smplkit/_generated/app/lib/smplkit_app_client/models/product.rb +22 -1
  4. data/lib/smplkit/_generated/app/spec/api/products_api_spec.rb +1 -1
  5. data/lib/smplkit/_generated/app/spec/models/product_spec.rb +12 -0
  6. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api/default_api.rb +305 -0
  7. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api_client.rb +441 -0
  8. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api_error.rb +58 -0
  9. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/api_model_base.rb +88 -0
  10. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/configuration.rb +392 -0
  11. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event.rb +327 -0
  12. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event_list_links.rb +148 -0
  13. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event_list_meta.rb +164 -0
  14. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event_list_response.rb +203 -0
  15. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event_resource.rb +202 -0
  16. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/event_response.rb +165 -0
  17. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/usage_resource.rb +203 -0
  18. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/models/usage_response.rb +166 -0
  19. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client/version.rb +15 -0
  20. data/lib/smplkit/_generated/audit/lib/smplkit_audit_client.rb +49 -0
  21. data/lib/smplkit/_generated/audit/spec/api/default_api_spec.rb +91 -0
  22. data/lib/smplkit/_generated/audit/spec/models/event_list_links_spec.rb +36 -0
  23. data/lib/smplkit/_generated/audit/spec/models/event_list_meta_spec.rb +36 -0
  24. data/lib/smplkit/_generated/audit/spec/models/event_list_response_spec.rb +48 -0
  25. data/lib/smplkit/_generated/audit/spec/models/event_resource_spec.rb +48 -0
  26. data/lib/smplkit/_generated/audit/spec/models/event_response_spec.rb +36 -0
  27. data/lib/smplkit/_generated/audit/spec/models/event_spec.rb +96 -0
  28. data/lib/smplkit/_generated/audit/spec/models/usage_resource_spec.rb +48 -0
  29. data/lib/smplkit/_generated/audit/spec/models/usage_response_spec.rb +36 -0
  30. data/lib/smplkit/_generated/audit/spec/spec_helper.rb +111 -0
  31. metadata +26 -1
@@ -0,0 +1,327 @@
1
+ =begin
2
+ #smplkit Audit API
3
+
4
+ #Append-only change-history substrate for smpl.* resources and customer-application events. ADR-047.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SmplkitGeneratedClient::Audit
17
+ # Public-facing event resource. Attribute set on POST /api/v1/events: - action (required) - resource_type (required) - resource_id (required) - occurred_at (optional; defaults to ``created_at``) - snapshot (optional) - data (optional; defaults to ``{}``) Attribute set on GET responses includes everything above plus the server-populated fields: ``created_at``, ``actor_type``, ``actor_id``, ``actor_label``, ``idempotency_key``.
18
+ class Event < ApiModelBase
19
+ attr_accessor :action
20
+
21
+ attr_accessor :resource_type
22
+
23
+ attr_accessor :resource_id
24
+
25
+ attr_accessor :occurred_at
26
+
27
+ attr_accessor :snapshot
28
+
29
+ attr_accessor :data
30
+
31
+ attr_accessor :created_at
32
+
33
+ attr_accessor :actor_type
34
+
35
+ attr_accessor :actor_id
36
+
37
+ attr_accessor :actor_label
38
+
39
+ attr_accessor :idempotency_key
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'action' => :'action',
45
+ :'resource_type' => :'resource_type',
46
+ :'resource_id' => :'resource_id',
47
+ :'occurred_at' => :'occurred_at',
48
+ :'snapshot' => :'snapshot',
49
+ :'data' => :'data',
50
+ :'created_at' => :'created_at',
51
+ :'actor_type' => :'actor_type',
52
+ :'actor_id' => :'actor_id',
53
+ :'actor_label' => :'actor_label',
54
+ :'idempotency_key' => :'idempotency_key'
55
+ }
56
+ end
57
+
58
+ # Returns attribute mapping this model knows about
59
+ def self.acceptable_attribute_map
60
+ attribute_map
61
+ end
62
+
63
+ # Returns all the JSON keys this model knows about
64
+ def self.acceptable_attributes
65
+ acceptable_attribute_map.values
66
+ end
67
+
68
+ # Attribute type mapping.
69
+ def self.openapi_types
70
+ {
71
+ :'action' => :'String',
72
+ :'resource_type' => :'String',
73
+ :'resource_id' => :'String',
74
+ :'occurred_at' => :'Time',
75
+ :'snapshot' => :'Hash<String, Object>',
76
+ :'data' => :'Hash<String, Object>',
77
+ :'created_at' => :'Time',
78
+ :'actor_type' => :'String',
79
+ :'actor_id' => :'String',
80
+ :'actor_label' => :'String',
81
+ :'idempotency_key' => :'String'
82
+ }
83
+ end
84
+
85
+ # List of attributes with nullable: true
86
+ def self.openapi_nullable
87
+ Set.new([
88
+ :'occurred_at',
89
+ :'snapshot',
90
+ :'created_at',
91
+ :'actor_type',
92
+ :'actor_id',
93
+ :'actor_label',
94
+ :'idempotency_key'
95
+ ])
96
+ end
97
+
98
+ # Initializes the object
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ def initialize(attributes = {})
101
+ if (!attributes.is_a?(Hash))
102
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::Audit::Event` initialize method"
103
+ end
104
+
105
+ # check to see if the attribute exists and convert string to symbol for hash key
106
+ acceptable_attribute_map = self.class.acceptable_attribute_map
107
+ attributes = attributes.each_with_object({}) { |(k, v), h|
108
+ if (!acceptable_attribute_map.key?(k.to_sym))
109
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::Audit::Event`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
110
+ end
111
+ h[k.to_sym] = v
112
+ }
113
+
114
+ if attributes.key?(:'action')
115
+ self.action = attributes[:'action']
116
+ else
117
+ self.action = nil
118
+ end
119
+
120
+ if attributes.key?(:'resource_type')
121
+ self.resource_type = attributes[:'resource_type']
122
+ else
123
+ self.resource_type = nil
124
+ end
125
+
126
+ if attributes.key?(:'resource_id')
127
+ self.resource_id = attributes[:'resource_id']
128
+ else
129
+ self.resource_id = nil
130
+ end
131
+
132
+ if attributes.key?(:'occurred_at')
133
+ self.occurred_at = attributes[:'occurred_at']
134
+ end
135
+
136
+ if attributes.key?(:'snapshot')
137
+ if (value = attributes[:'snapshot']).is_a?(Hash)
138
+ self.snapshot = value
139
+ end
140
+ end
141
+
142
+ if attributes.key?(:'data')
143
+ if (value = attributes[:'data']).is_a?(Hash)
144
+ self.data = value
145
+ end
146
+ end
147
+
148
+ if attributes.key?(:'created_at')
149
+ self.created_at = attributes[:'created_at']
150
+ end
151
+
152
+ if attributes.key?(:'actor_type')
153
+ self.actor_type = attributes[:'actor_type']
154
+ end
155
+
156
+ if attributes.key?(:'actor_id')
157
+ self.actor_id = attributes[:'actor_id']
158
+ end
159
+
160
+ if attributes.key?(:'actor_label')
161
+ self.actor_label = attributes[:'actor_label']
162
+ end
163
+
164
+ if attributes.key?(:'idempotency_key')
165
+ self.idempotency_key = attributes[:'idempotency_key']
166
+ end
167
+ end
168
+
169
+ # Show invalid properties with the reasons. Usually used together with valid?
170
+ # @return Array for valid properties with the reasons
171
+ def list_invalid_properties
172
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
173
+ invalid_properties = Array.new
174
+ if @action.nil?
175
+ invalid_properties.push('invalid value for "action", action cannot be nil.')
176
+ end
177
+
178
+ if @action.to_s.length < 1
179
+ invalid_properties.push('invalid value for "action", the character length must be greater than or equal to 1.')
180
+ end
181
+
182
+ if @resource_type.nil?
183
+ invalid_properties.push('invalid value for "resource_type", resource_type cannot be nil.')
184
+ end
185
+
186
+ if @resource_type.to_s.length < 1
187
+ invalid_properties.push('invalid value for "resource_type", the character length must be greater than or equal to 1.')
188
+ end
189
+
190
+ if @resource_id.nil?
191
+ invalid_properties.push('invalid value for "resource_id", resource_id cannot be nil.')
192
+ end
193
+
194
+ if @resource_id.to_s.length < 1
195
+ invalid_properties.push('invalid value for "resource_id", the character length must be greater than or equal to 1.')
196
+ end
197
+
198
+ invalid_properties
199
+ end
200
+
201
+ # Check to see if the all the properties in the model are valid
202
+ # @return true if the model is valid
203
+ def valid?
204
+ warn '[DEPRECATED] the `valid?` method is obsolete'
205
+ return false if @action.nil?
206
+ return false if @action.to_s.length < 1
207
+ return false if @resource_type.nil?
208
+ return false if @resource_type.to_s.length < 1
209
+ return false if @resource_id.nil?
210
+ return false if @resource_id.to_s.length < 1
211
+ true
212
+ end
213
+
214
+ # Custom attribute writer method with validation
215
+ # @param [Object] action Value to be assigned
216
+ def action=(action)
217
+ if action.nil?
218
+ fail ArgumentError, 'action cannot be nil'
219
+ end
220
+
221
+ if action.to_s.length < 1
222
+ fail ArgumentError, 'invalid value for "action", the character length must be greater than or equal to 1.'
223
+ end
224
+
225
+ @action = action
226
+ end
227
+
228
+ # Custom attribute writer method with validation
229
+ # @param [Object] resource_type Value to be assigned
230
+ def resource_type=(resource_type)
231
+ if resource_type.nil?
232
+ fail ArgumentError, 'resource_type cannot be nil'
233
+ end
234
+
235
+ if resource_type.to_s.length < 1
236
+ fail ArgumentError, 'invalid value for "resource_type", the character length must be greater than or equal to 1.'
237
+ end
238
+
239
+ @resource_type = resource_type
240
+ end
241
+
242
+ # Custom attribute writer method with validation
243
+ # @param [Object] resource_id Value to be assigned
244
+ def resource_id=(resource_id)
245
+ if resource_id.nil?
246
+ fail ArgumentError, 'resource_id cannot be nil'
247
+ end
248
+
249
+ if resource_id.to_s.length < 1
250
+ fail ArgumentError, 'invalid value for "resource_id", the character length must be greater than or equal to 1.'
251
+ end
252
+
253
+ @resource_id = resource_id
254
+ end
255
+
256
+ # Checks equality by comparing each attribute.
257
+ # @param [Object] Object to be compared
258
+ def ==(o)
259
+ return true if self.equal?(o)
260
+ self.class == o.class &&
261
+ action == o.action &&
262
+ resource_type == o.resource_type &&
263
+ resource_id == o.resource_id &&
264
+ occurred_at == o.occurred_at &&
265
+ snapshot == o.snapshot &&
266
+ data == o.data &&
267
+ created_at == o.created_at &&
268
+ actor_type == o.actor_type &&
269
+ actor_id == o.actor_id &&
270
+ actor_label == o.actor_label &&
271
+ idempotency_key == o.idempotency_key
272
+ end
273
+
274
+ # @see the `==` method
275
+ # @param [Object] Object to be compared
276
+ def eql?(o)
277
+ self == o
278
+ end
279
+
280
+ # Calculates hash code according to all attributes.
281
+ # @return [Integer] Hash code
282
+ def hash
283
+ [action, resource_type, resource_id, occurred_at, snapshot, data, created_at, actor_type, actor_id, actor_label, idempotency_key].hash
284
+ end
285
+
286
+ # Builds the object from hash
287
+ # @param [Hash] attributes Model attributes in the form of hash
288
+ # @return [Object] Returns the model itself
289
+ def self.build_from_hash(attributes)
290
+ return nil unless attributes.is_a?(Hash)
291
+ attributes = attributes.transform_keys(&:to_sym)
292
+ transformed_hash = {}
293
+ openapi_types.each_pair do |key, type|
294
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
295
+ transformed_hash["#{key}"] = nil
296
+ elsif type =~ /\AArray<(.*)>/i
297
+ # check to ensure the input is an array given that the attribute
298
+ # is documented as an array but the input is not
299
+ if attributes[attribute_map[key]].is_a?(Array)
300
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
301
+ end
302
+ elsif !attributes[attribute_map[key]].nil?
303
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
304
+ end
305
+ end
306
+ new(transformed_hash)
307
+ end
308
+
309
+ # Returns the object in the form of hash
310
+ # @return [Hash] Returns the object in the form of hash
311
+ def to_hash
312
+ hash = {}
313
+ self.class.attribute_map.each_pair do |attr, param|
314
+ value = self.send(attr)
315
+ if value.nil?
316
+ is_nullable = self.class.openapi_nullable.include?(attr)
317
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
318
+ end
319
+
320
+ hash[param] = _to_hash(value)
321
+ end
322
+ hash
323
+ end
324
+
325
+ end
326
+
327
+ end
@@ -0,0 +1,148 @@
1
+ =begin
2
+ #smplkit Audit API
3
+
4
+ #Append-only change-history substrate for smpl.* resources and customer-application events. ADR-047.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SmplkitGeneratedClient::Audit
17
+ class EventListLinks < ApiModelBase
18
+ attr_accessor :_next
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'_next' => :'next'
24
+ }
25
+ end
26
+
27
+ # Returns attribute mapping this model knows about
28
+ def self.acceptable_attribute_map
29
+ attribute_map
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ acceptable_attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'_next' => :'String'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ :'_next'
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::Audit::EventListLinks` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ acceptable_attribute_map = self.class.acceptable_attribute_map
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!acceptable_attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::Audit::EventListLinks`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'_next')
68
+ self._next = attributes[:'_next']
69
+ end
70
+ end
71
+
72
+ # Show invalid properties with the reasons. Usually used together with valid?
73
+ # @return Array for valid properties with the reasons
74
+ def list_invalid_properties
75
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
76
+ invalid_properties = Array.new
77
+ invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ warn '[DEPRECATED] the `valid?` method is obsolete'
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ _next == o._next
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [_next].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ attributes = attributes.transform_keys(&:to_sym)
113
+ transformed_hash = {}
114
+ openapi_types.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = nil
117
+ elsif type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[attribute_map[key]].is_a?(Array)
121
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
122
+ end
123
+ elsif !attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
125
+ end
126
+ end
127
+ new(transformed_hash)
128
+ end
129
+
130
+ # Returns the object in the form of hash
131
+ # @return [Hash] Returns the object in the form of hash
132
+ def to_hash
133
+ hash = {}
134
+ self.class.attribute_map.each_pair do |attr, param|
135
+ value = self.send(attr)
136
+ if value.nil?
137
+ is_nullable = self.class.openapi_nullable.include?(attr)
138
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
139
+ end
140
+
141
+ hash[param] = _to_hash(value)
142
+ end
143
+ hash
144
+ end
145
+
146
+ end
147
+
148
+ end
@@ -0,0 +1,164 @@
1
+ =begin
2
+ #smplkit Audit API
3
+
4
+ #Append-only change-history substrate for smpl.* resources and customer-application events. ADR-047.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SmplkitGeneratedClient::Audit
17
+ class EventListMeta < ApiModelBase
18
+ attr_accessor :page_size
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'page_size' => :'page_size'
24
+ }
25
+ end
26
+
27
+ # Returns attribute mapping this model knows about
28
+ def self.acceptable_attribute_map
29
+ attribute_map
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ acceptable_attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'page_size' => :'Integer'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::Audit::EventListMeta` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ acceptable_attribute_map = self.class.acceptable_attribute_map
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!acceptable_attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::Audit::EventListMeta`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'page_size')
67
+ self.page_size = attributes[:'page_size']
68
+ else
69
+ self.page_size = nil
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
77
+ invalid_properties = Array.new
78
+ if @page_size.nil?
79
+ invalid_properties.push('invalid value for "page_size", page_size cannot be nil.')
80
+ end
81
+
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ warn '[DEPRECATED] the `valid?` method is obsolete'
89
+ return false if @page_size.nil?
90
+ true
91
+ end
92
+
93
+ # Custom attribute writer method with validation
94
+ # @param [Object] page_size Value to be assigned
95
+ def page_size=(page_size)
96
+ if page_size.nil?
97
+ fail ArgumentError, 'page_size cannot be nil'
98
+ end
99
+
100
+ @page_size = page_size
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ page_size == o.page_size
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [page_size].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ attributes = attributes.transform_keys(&:to_sym)
129
+ transformed_hash = {}
130
+ openapi_types.each_pair do |key, type|
131
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = nil
133
+ elsif type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[attribute_map[key]].is_a?(Array)
137
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
138
+ end
139
+ elsif !attributes[attribute_map[key]].nil?
140
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
141
+ end
142
+ end
143
+ new(transformed_hash)
144
+ end
145
+
146
+ # Returns the object in the form of hash
147
+ # @return [Hash] Returns the object in the form of hash
148
+ def to_hash
149
+ hash = {}
150
+ self.class.attribute_map.each_pair do |attr, param|
151
+ value = self.send(attr)
152
+ if value.nil?
153
+ is_nullable = self.class.openapi_nullable.include?(attr)
154
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
155
+ end
156
+
157
+ hash[param] = _to_hash(value)
158
+ end
159
+ hash
160
+ end
161
+
162
+ end
163
+
164
+ end