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