pds-metronome 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +164 -0
  4. data/Rakefile +10 -0
  5. data/docs/AccessManagementApi.md +300 -0
  6. data/docs/AccessType.md +15 -0
  7. data/docs/AgingOffsetUnit.md +15 -0
  8. data/docs/AgingStrategy.md +15 -0
  9. data/docs/ApiKeyData.md +28 -0
  10. data/docs/ApiKeyDataListResponse.md +20 -0
  11. data/docs/ApiKeyListResponse.md +20 -0
  12. data/docs/CreateApiKeyRequest.md +22 -0
  13. data/docs/CreateOrModifyApiKeyResponse.md +22 -0
  14. data/docs/CreateOrModifyPolicyRequest.md +22 -0
  15. data/docs/CreateOrModifyPolicyResponse.md +20 -0
  16. data/docs/DataExpiryApi.md +79 -0
  17. data/docs/ExpireItemResponse.md +20 -0
  18. data/docs/ExpireSubItemResponse.md +22 -0
  19. data/docs/ExpiryResponse.md +22 -0
  20. data/docs/ExpiryResponsePendingInner.md +79 -0
  21. data/docs/GetManyApiKeys200Response.md +79 -0
  22. data/docs/GetManyPolicies200Response.md +79 -0
  23. data/docs/ItemAccessApi.md +605 -0
  24. data/docs/ItemExpiry.md +20 -0
  25. data/docs/ItemMetadataResponse.md +28 -0
  26. data/docs/ItemOrSubItemAccessLog.md +32 -0
  27. data/docs/ItemOrSubItemPolicyResponse.md +22 -0
  28. data/docs/ModifyApiKeyRequest.md +20 -0
  29. data/docs/Permission.md +15 -0
  30. data/docs/PermissionDeniedResponse.md +30 -0
  31. data/docs/PolicyData.md +26 -0
  32. data/docs/PolicyDataListResponse.md +28 -0
  33. data/docs/PolicyListResponse.md +28 -0
  34. data/docs/PolicyManagementApi.md +379 -0
  35. data/docs/PutApiKeyRequest.md +49 -0
  36. data/docs/SignupRequest.md +18 -0
  37. data/docs/SignupResponse.md +24 -0
  38. data/docs/SubItemMetadataResponse.md +22 -0
  39. data/docs/SubItemsExpiry.md +22 -0
  40. data/docs/TelemetryApi.md +80 -0
  41. data/docs/TelemetryObservation.md +20 -0
  42. data/docs/TelemetryRequest.md +22 -0
  43. data/docs/ValidationErrorResponseInner.md +22 -0
  44. data/docs/ValidationProblem.md +22 -0
  45. data/lib/metronome/api/access_management_api.rb +285 -0
  46. data/lib/metronome/api/data_expiry_api.rb +105 -0
  47. data/lib/metronome/api/item_access_api.rb +549 -0
  48. data/lib/metronome/api/policy_management_api.rb +348 -0
  49. data/lib/metronome/api/telemetry_api.rb +84 -0
  50. data/lib/metronome/api_client.rb +393 -0
  51. data/lib/metronome/api_error.rb +58 -0
  52. data/lib/metronome/configuration.rb +312 -0
  53. data/lib/metronome/models/access_type.rb +41 -0
  54. data/lib/metronome/models/aging_offset_unit.rb +41 -0
  55. data/lib/metronome/models/aging_strategy.rb +40 -0
  56. data/lib/metronome/models/api_key_data.rb +330 -0
  57. data/lib/metronome/models/api_key_data_list_response.rb +241 -0
  58. data/lib/metronome/models/api_key_list_response.rb +241 -0
  59. data/lib/metronome/models/create_api_key_request.rb +239 -0
  60. data/lib/metronome/models/create_or_modify_api_key_response.rb +255 -0
  61. data/lib/metronome/models/create_or_modify_policy_request.rb +293 -0
  62. data/lib/metronome/models/create_or_modify_policy_response.rb +240 -0
  63. data/lib/metronome/models/expire_item_response.rb +240 -0
  64. data/lib/metronome/models/expire_sub_item_response.rb +254 -0
  65. data/lib/metronome/models/expiry_response.rb +299 -0
  66. data/lib/metronome/models/expiry_response_pending_inner.rb +55 -0
  67. data/lib/metronome/models/get_many_api_keys200_response.rb +55 -0
  68. data/lib/metronome/models/get_many_policies200_response.rb +55 -0
  69. data/lib/metronome/models/item_expiry.rb +239 -0
  70. data/lib/metronome/models/item_metadata_response.rb +274 -0
  71. data/lib/metronome/models/item_or_sub_item_access_log.rb +337 -0
  72. data/lib/metronome/models/item_or_sub_item_policy_response.rb +245 -0
  73. data/lib/metronome/models/modify_api_key_request.rb +230 -0
  74. data/lib/metronome/models/permission.rb +45 -0
  75. data/lib/metronome/models/permission_denied_response.rb +338 -0
  76. data/lib/metronome/models/policy_data.rb +364 -0
  77. data/lib/metronome/models/policy_data_list_response.rb +286 -0
  78. data/lib/metronome/models/policy_list_response.rb +286 -0
  79. data/lib/metronome/models/put_api_key_request.rb +105 -0
  80. data/lib/metronome/models/signup_request.rb +225 -0
  81. data/lib/metronome/models/signup_response.rb +266 -0
  82. data/lib/metronome/models/sub_item_metadata_response.rb +245 -0
  83. data/lib/metronome/models/sub_items_expiry.rb +255 -0
  84. data/lib/metronome/models/telemetry_observation.rb +240 -0
  85. data/lib/metronome/models/telemetry_request.rb +259 -0
  86. data/lib/metronome/models/validation_error_response_inner.rb +254 -0
  87. data/lib/metronome/models/validation_problem.rb +254 -0
  88. data/lib/metronome/version.rb +15 -0
  89. data/lib/metronome.rb +80 -0
  90. data/shell.nix +6 -0
  91. data/spec/api/access_management_api_spec.rb +82 -0
  92. data/spec/api/data_expiry_api_spec.rb +46 -0
  93. data/spec/api/item_access_api_spec.rb +132 -0
  94. data/spec/api/policy_management_api_spec.rb +94 -0
  95. data/spec/api/telemetry_api_spec.rb +46 -0
  96. data/spec/api_client_spec.rb +228 -0
  97. data/spec/configuration_spec.rb +42 -0
  98. data/spec/models/access_type_spec.rb +28 -0
  99. data/spec/models/aging_offset_unit_spec.rb +28 -0
  100. data/spec/models/aging_strategy_spec.rb +28 -0
  101. data/spec/models/api_key_data_list_response_spec.rb +40 -0
  102. data/spec/models/api_key_data_spec.rb +68 -0
  103. data/spec/models/api_key_list_response_spec.rb +40 -0
  104. data/spec/models/create_api_key_request_spec.rb +46 -0
  105. data/spec/models/create_or_modify_api_key_response_spec.rb +46 -0
  106. data/spec/models/create_or_modify_policy_request_spec.rb +46 -0
  107. data/spec/models/create_or_modify_policy_response_spec.rb +40 -0
  108. data/spec/models/expire_item_response_spec.rb +40 -0
  109. data/spec/models/expire_sub_item_response_spec.rb +46 -0
  110. data/spec/models/expiry_response_pending_inner_spec.rb +43 -0
  111. data/spec/models/expiry_response_spec.rb +46 -0
  112. data/spec/models/get_many_api_keys200_response_spec.rb +43 -0
  113. data/spec/models/get_many_policies200_response_spec.rb +43 -0
  114. data/spec/models/item_expiry_spec.rb +40 -0
  115. data/spec/models/item_metadata_response_spec.rb +64 -0
  116. data/spec/models/item_or_sub_item_access_log_spec.rb +76 -0
  117. data/spec/models/item_or_sub_item_policy_response_spec.rb +46 -0
  118. data/spec/models/modify_api_key_request_spec.rb +40 -0
  119. data/spec/models/permission_denied_response_spec.rb +82 -0
  120. data/spec/models/permission_spec.rb +28 -0
  121. data/spec/models/policy_data_list_response_spec.rb +64 -0
  122. data/spec/models/policy_data_spec.rb +58 -0
  123. data/spec/models/policy_list_response_spec.rb +64 -0
  124. data/spec/models/put_api_key_request_spec.rb +31 -0
  125. data/spec/models/signup_request_spec.rb +34 -0
  126. data/spec/models/signup_response_spec.rb +52 -0
  127. data/spec/models/sub_item_metadata_response_spec.rb +46 -0
  128. data/spec/models/sub_items_expiry_spec.rb +46 -0
  129. data/spec/models/telemetry_observation_spec.rb +40 -0
  130. data/spec/models/telemetry_request_spec.rb +46 -0
  131. data/spec/models/validation_error_response_inner_spec.rb +46 -0
  132. data/spec/models/validation_problem_spec.rb +46 -0
  133. data/spec/spec_helper.rb +111 -0
  134. metadata +260 -0
@@ -0,0 +1,255 @@
1
+ =begin
2
+ #Metronome API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: info@privatedataservices.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Metronome
17
+ class SubItemsExpiry
18
+ # Always the value \"SubItemsExpiry\"
19
+ attr_accessor :expiry_type
20
+
21
+ attr_accessor :parent_item_id
22
+
23
+ attr_accessor :sub_items
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'expiry_type' => :'expiry-type',
29
+ :'parent_item_id' => :'parent-item-id',
30
+ :'sub_items' => :'sub-items'
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'expiry_type' => :'String',
43
+ :'parent_item_id' => :'String',
44
+ :'sub_items' => :'Array<String>'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Metronome::SubItemsExpiry` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Metronome::SubItemsExpiry`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'expiry_type')
70
+ self.expiry_type = attributes[:'expiry_type']
71
+ end
72
+
73
+ if attributes.key?(:'parent_item_id')
74
+ self.parent_item_id = attributes[:'parent_item_id']
75
+ end
76
+
77
+ if attributes.key?(:'sub_items')
78
+ if (value = attributes[:'sub_items']).is_a?(Array)
79
+ self.sub_items = value
80
+ end
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ if @expiry_type.nil?
89
+ invalid_properties.push('invalid value for "expiry_type", expiry_type cannot be nil.')
90
+ end
91
+
92
+ if @parent_item_id.nil?
93
+ invalid_properties.push('invalid value for "parent_item_id", parent_item_id cannot be nil.')
94
+ end
95
+
96
+ if @sub_items.nil?
97
+ invalid_properties.push('invalid value for "sub_items", sub_items cannot be nil.')
98
+ end
99
+
100
+ invalid_properties
101
+ end
102
+
103
+ # Check to see if the all the properties in the model are valid
104
+ # @return true if the model is valid
105
+ def valid?
106
+ return false if @expiry_type.nil?
107
+ return false if @parent_item_id.nil?
108
+ return false if @sub_items.nil?
109
+ true
110
+ end
111
+
112
+ # Checks equality by comparing each attribute.
113
+ # @param [Object] Object to be compared
114
+ def ==(o)
115
+ return true if self.equal?(o)
116
+ self.class == o.class &&
117
+ expiry_type == o.expiry_type &&
118
+ parent_item_id == o.parent_item_id &&
119
+ sub_items == o.sub_items
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [expiry_type, parent_item_id, sub_items].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ attributes = attributes.transform_keys(&:to_sym)
147
+ self.class.openapi_types.each_pair do |key, type|
148
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
149
+ self.send("#{key}=", nil)
150
+ elsif type =~ /\AArray<(.*)>/i
151
+ # check to ensure the input is an array given that the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
154
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
155
+ end
156
+ elsif !attributes[self.class.attribute_map[key]].nil?
157
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
158
+ end
159
+ end
160
+
161
+ self
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def _deserialize(type, value)
169
+ case type.to_sym
170
+ when :Time
171
+ Time.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :Boolean
181
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ # models (e.g. Pet) or oneOf
202
+ klass = Metronome.const_get(type)
203
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
204
+ end
205
+ end
206
+
207
+ # Returns the string representation of the object
208
+ # @return [String] String presentation of the object
209
+ def to_s
210
+ to_hash.to_s
211
+ end
212
+
213
+ # to_body is an alias to to_hash (backward compatibility)
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_body
216
+ to_hash
217
+ end
218
+
219
+ # Returns the object in the form of hash
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_hash
222
+ hash = {}
223
+ self.class.attribute_map.each_pair do |attr, param|
224
+ value = self.send(attr)
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ # Outputs non-array value in the form of hash
236
+ # For object, use to_hash. Otherwise, just return the value
237
+ # @param [Object] value Any valid value
238
+ # @return [Hash] Returns the value in the form of hash
239
+ def _to_hash(value)
240
+ if value.is_a?(Array)
241
+ value.compact.map { |v| _to_hash(v) }
242
+ elsif value.is_a?(Hash)
243
+ {}.tap do |hash|
244
+ value.each { |k, v| hash[k] = _to_hash(v) }
245
+ end
246
+ elsif value.respond_to? :to_hash
247
+ value.to_hash
248
+ else
249
+ value
250
+ end
251
+ end
252
+
253
+ end
254
+
255
+ end
@@ -0,0 +1,240 @@
1
+ =begin
2
+ #Metronome API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: info@privatedataservices.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Metronome
17
+ class TelemetryObservation
18
+ attr_accessor :item_id
19
+
20
+ attr_accessor :sub_item_ids
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'item_id' => :'item-id',
26
+ :'sub_item_ids' => :'sub-item-ids'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'item_id' => :'String',
39
+ :'sub_item_ids' => :'Array<String>'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Metronome::TelemetryObservation` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Metronome::TelemetryObservation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'item_id')
65
+ self.item_id = attributes[:'item_id']
66
+ end
67
+
68
+ if attributes.key?(:'sub_item_ids')
69
+ if (value = attributes[:'sub_item_ids']).is_a?(Array)
70
+ self.sub_item_ids = value
71
+ end
72
+ end
73
+ end
74
+
75
+ # Show invalid properties with the reasons. Usually used together with valid?
76
+ # @return Array for valid properties with the reasons
77
+ def list_invalid_properties
78
+ invalid_properties = Array.new
79
+ if @item_id.nil?
80
+ invalid_properties.push('invalid value for "item_id", item_id cannot be nil.')
81
+ end
82
+
83
+ if @sub_item_ids.nil?
84
+ invalid_properties.push('invalid value for "sub_item_ids", sub_item_ids cannot be nil.')
85
+ end
86
+
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ return false if @item_id.nil?
94
+ return false if @sub_item_ids.nil?
95
+ true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ item_id == o.item_id &&
104
+ sub_item_ids == o.sub_item_ids
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(o)
110
+ self == o
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Integer] Hash code
115
+ def hash
116
+ [item_id, sub_item_ids].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def self.build_from_hash(attributes)
123
+ new.build_from_hash(attributes)
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ attributes = attributes.transform_keys(&:to_sym)
132
+ self.class.openapi_types.each_pair do |key, type|
133
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
134
+ self.send("#{key}=", nil)
135
+ elsif type =~ /\AArray<(.*)>/i
136
+ # check to ensure the input is an array given that the attribute
137
+ # is documented as an array but the input is not
138
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
139
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
140
+ end
141
+ elsif !attributes[self.class.attribute_map[key]].nil?
142
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
143
+ end
144
+ end
145
+
146
+ self
147
+ end
148
+
149
+ # Deserializes the data based on type
150
+ # @param string type Data type
151
+ # @param string value Value to be deserialized
152
+ # @return [Object] Deserialized data
153
+ def _deserialize(type, value)
154
+ case type.to_sym
155
+ when :Time
156
+ Time.parse(value)
157
+ when :Date
158
+ Date.parse(value)
159
+ when :String
160
+ value.to_s
161
+ when :Integer
162
+ value.to_i
163
+ when :Float
164
+ value.to_f
165
+ when :Boolean
166
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
167
+ true
168
+ else
169
+ false
170
+ end
171
+ when :Object
172
+ # generic object (usually a Hash), return directly
173
+ value
174
+ when /\AArray<(?<inner_type>.+)>\z/
175
+ inner_type = Regexp.last_match[:inner_type]
176
+ value.map { |v| _deserialize(inner_type, v) }
177
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
178
+ k_type = Regexp.last_match[:k_type]
179
+ v_type = Regexp.last_match[:v_type]
180
+ {}.tap do |hash|
181
+ value.each do |k, v|
182
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
183
+ end
184
+ end
185
+ else # model
186
+ # models (e.g. Pet) or oneOf
187
+ klass = Metronome.const_get(type)
188
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
189
+ end
190
+ end
191
+
192
+ # Returns the string representation of the object
193
+ # @return [String] String presentation of the object
194
+ def to_s
195
+ to_hash.to_s
196
+ end
197
+
198
+ # to_body is an alias to to_hash (backward compatibility)
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_body
201
+ to_hash
202
+ end
203
+
204
+ # Returns the object in the form of hash
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_hash
207
+ hash = {}
208
+ self.class.attribute_map.each_pair do |attr, param|
209
+ value = self.send(attr)
210
+ if value.nil?
211
+ is_nullable = self.class.openapi_nullable.include?(attr)
212
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
213
+ end
214
+
215
+ hash[param] = _to_hash(value)
216
+ end
217
+ hash
218
+ end
219
+
220
+ # Outputs non-array value in the form of hash
221
+ # For object, use to_hash. Otherwise, just return the value
222
+ # @param [Object] value Any valid value
223
+ # @return [Hash] Returns the value in the form of hash
224
+ def _to_hash(value)
225
+ if value.is_a?(Array)
226
+ value.compact.map { |v| _to_hash(v) }
227
+ elsif value.is_a?(Hash)
228
+ {}.tap do |hash|
229
+ value.each { |k, v| hash[k] = _to_hash(v) }
230
+ end
231
+ elsif value.respond_to? :to_hash
232
+ value.to_hash
233
+ else
234
+ value
235
+ end
236
+ end
237
+
238
+ end
239
+
240
+ end