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,337 @@
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 ItemOrSubItemAccessLog
18
+ attr_accessor :timestamp
19
+
20
+ attr_accessor :access_type
21
+
22
+ # The ID of the system that accessed the data
23
+ attr_accessor :access_authoriser
24
+
25
+ attr_accessor :access_policies
26
+
27
+ # The policy which governed data expiry after this data access
28
+ attr_accessor :effective_expiry_policy
29
+
30
+ # The date to which this item or sub-item would be retained after this access
31
+ attr_accessor :effective_expiry_date
32
+
33
+ attr_accessor :accessed_sub_items
34
+
35
+ # Present and true only when the item expired as a result of this access
36
+ attr_accessor :expired
37
+
38
+ class EnumAttributeValidator
39
+ attr_reader :datatype
40
+ attr_reader :allowable_values
41
+
42
+ def initialize(datatype, allowable_values)
43
+ @allowable_values = allowable_values.map do |value|
44
+ case datatype.to_s
45
+ when /Integer/i
46
+ value.to_i
47
+ when /Float/i
48
+ value.to_f
49
+ else
50
+ value
51
+ end
52
+ end
53
+ end
54
+
55
+ def valid?(value)
56
+ !value || allowable_values.include?(value)
57
+ end
58
+ end
59
+
60
+ # Attribute mapping from ruby-style variable name to JSON key.
61
+ def self.attribute_map
62
+ {
63
+ :'timestamp' => :'timestamp',
64
+ :'access_type' => :'access-type',
65
+ :'access_authoriser' => :'access-authoriser',
66
+ :'access_policies' => :'access-policies',
67
+ :'effective_expiry_policy' => :'effective-expiry-policy',
68
+ :'effective_expiry_date' => :'effective-expiry-date',
69
+ :'accessed_sub_items' => :'accessed-sub-items',
70
+ :'expired' => :'expired'
71
+ }
72
+ end
73
+
74
+ # Returns all the JSON keys this model knows about
75
+ def self.acceptable_attributes
76
+ attribute_map.values
77
+ end
78
+
79
+ # Attribute type mapping.
80
+ def self.openapi_types
81
+ {
82
+ :'timestamp' => :'Time',
83
+ :'access_type' => :'AccessType',
84
+ :'access_authoriser' => :'String',
85
+ :'access_policies' => :'Array<String>',
86
+ :'effective_expiry_policy' => :'String',
87
+ :'effective_expiry_date' => :'Date',
88
+ :'accessed_sub_items' => :'Array<String>',
89
+ :'expired' => :'Boolean'
90
+ }
91
+ end
92
+
93
+ # List of attributes with nullable: true
94
+ def self.openapi_nullable
95
+ Set.new([
96
+ ])
97
+ end
98
+
99
+ # Initializes the object
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ def initialize(attributes = {})
102
+ if (!attributes.is_a?(Hash))
103
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Metronome::ItemOrSubItemAccessLog` initialize method"
104
+ end
105
+
106
+ # check to see if the attribute exists and convert string to symbol for hash key
107
+ attributes = attributes.each_with_object({}) { |(k, v), h|
108
+ if (!self.class.attribute_map.key?(k.to_sym))
109
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Metronome::ItemOrSubItemAccessLog`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
110
+ end
111
+ h[k.to_sym] = v
112
+ }
113
+
114
+ if attributes.key?(:'timestamp')
115
+ self.timestamp = attributes[:'timestamp']
116
+ end
117
+
118
+ if attributes.key?(:'access_type')
119
+ self.access_type = attributes[:'access_type']
120
+ end
121
+
122
+ if attributes.key?(:'access_authoriser')
123
+ self.access_authoriser = attributes[:'access_authoriser']
124
+ end
125
+
126
+ if attributes.key?(:'access_policies')
127
+ if (value = attributes[:'access_policies']).is_a?(Array)
128
+ self.access_policies = value
129
+ end
130
+ end
131
+
132
+ if attributes.key?(:'effective_expiry_policy')
133
+ self.effective_expiry_policy = attributes[:'effective_expiry_policy']
134
+ end
135
+
136
+ if attributes.key?(:'effective_expiry_date')
137
+ self.effective_expiry_date = attributes[:'effective_expiry_date']
138
+ end
139
+
140
+ if attributes.key?(:'accessed_sub_items')
141
+ if (value = attributes[:'accessed_sub_items']).is_a?(Array)
142
+ self.accessed_sub_items = value
143
+ end
144
+ end
145
+
146
+ if attributes.key?(:'expired')
147
+ self.expired = attributes[:'expired']
148
+ end
149
+ end
150
+
151
+ # Show invalid properties with the reasons. Usually used together with valid?
152
+ # @return Array for valid properties with the reasons
153
+ def list_invalid_properties
154
+ invalid_properties = Array.new
155
+ if @timestamp.nil?
156
+ invalid_properties.push('invalid value for "timestamp", timestamp cannot be nil.')
157
+ end
158
+
159
+ if @access_type.nil?
160
+ invalid_properties.push('invalid value for "access_type", access_type cannot be nil.')
161
+ end
162
+
163
+ if @access_authoriser.nil?
164
+ invalid_properties.push('invalid value for "access_authoriser", access_authoriser cannot be nil.')
165
+ end
166
+
167
+ if @access_policies.nil?
168
+ invalid_properties.push('invalid value for "access_policies", access_policies cannot be nil.')
169
+ end
170
+
171
+ if @effective_expiry_policy.nil?
172
+ invalid_properties.push('invalid value for "effective_expiry_policy", effective_expiry_policy cannot be nil.')
173
+ end
174
+
175
+ invalid_properties
176
+ end
177
+
178
+ # Check to see if the all the properties in the model are valid
179
+ # @return true if the model is valid
180
+ def valid?
181
+ return false if @timestamp.nil?
182
+ return false if @access_type.nil?
183
+ return false if @access_authoriser.nil?
184
+ return false if @access_policies.nil?
185
+ return false if @effective_expiry_policy.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
+ timestamp == o.timestamp &&
195
+ access_type == o.access_type &&
196
+ access_authoriser == o.access_authoriser &&
197
+ access_policies == o.access_policies &&
198
+ effective_expiry_policy == o.effective_expiry_policy &&
199
+ effective_expiry_date == o.effective_expiry_date &&
200
+ accessed_sub_items == o.accessed_sub_items &&
201
+ expired == o.expired
202
+ end
203
+
204
+ # @see the `==` method
205
+ # @param [Object] Object to be compared
206
+ def eql?(o)
207
+ self == o
208
+ end
209
+
210
+ # Calculates hash code according to all attributes.
211
+ # @return [Integer] Hash code
212
+ def hash
213
+ [timestamp, access_type, access_authoriser, access_policies, effective_expiry_policy, effective_expiry_date, accessed_sub_items, expired].hash
214
+ end
215
+
216
+ # Builds the object from hash
217
+ # @param [Hash] attributes Model attributes in the form of hash
218
+ # @return [Object] Returns the model itself
219
+ def self.build_from_hash(attributes)
220
+ new.build_from_hash(attributes)
221
+ end
222
+
223
+ # Builds the object from hash
224
+ # @param [Hash] attributes Model attributes in the form of hash
225
+ # @return [Object] Returns the model itself
226
+ def build_from_hash(attributes)
227
+ return nil unless attributes.is_a?(Hash)
228
+ attributes = attributes.transform_keys(&:to_sym)
229
+ self.class.openapi_types.each_pair do |key, type|
230
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
231
+ self.send("#{key}=", nil)
232
+ elsif type =~ /\AArray<(.*)>/i
233
+ # check to ensure the input is an array given that the attribute
234
+ # is documented as an array but the input is not
235
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
236
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
237
+ end
238
+ elsif !attributes[self.class.attribute_map[key]].nil?
239
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
240
+ end
241
+ end
242
+
243
+ self
244
+ end
245
+
246
+ # Deserializes the data based on type
247
+ # @param string type Data type
248
+ # @param string value Value to be deserialized
249
+ # @return [Object] Deserialized data
250
+ def _deserialize(type, value)
251
+ case type.to_sym
252
+ when :Time
253
+ Time.parse(value)
254
+ when :Date
255
+ Date.parse(value)
256
+ when :String
257
+ value.to_s
258
+ when :Integer
259
+ value.to_i
260
+ when :Float
261
+ value.to_f
262
+ when :Boolean
263
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
264
+ true
265
+ else
266
+ false
267
+ end
268
+ when :Object
269
+ # generic object (usually a Hash), return directly
270
+ value
271
+ when /\AArray<(?<inner_type>.+)>\z/
272
+ inner_type = Regexp.last_match[:inner_type]
273
+ value.map { |v| _deserialize(inner_type, v) }
274
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
275
+ k_type = Regexp.last_match[:k_type]
276
+ v_type = Regexp.last_match[:v_type]
277
+ {}.tap do |hash|
278
+ value.each do |k, v|
279
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
280
+ end
281
+ end
282
+ else # model
283
+ # models (e.g. Pet) or oneOf
284
+ klass = Metronome.const_get(type)
285
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
286
+ end
287
+ end
288
+
289
+ # Returns the string representation of the object
290
+ # @return [String] String presentation of the object
291
+ def to_s
292
+ to_hash.to_s
293
+ end
294
+
295
+ # to_body is an alias to to_hash (backward compatibility)
296
+ # @return [Hash] Returns the object in the form of hash
297
+ def to_body
298
+ to_hash
299
+ end
300
+
301
+ # Returns the object in the form of hash
302
+ # @return [Hash] Returns the object in the form of hash
303
+ def to_hash
304
+ hash = {}
305
+ self.class.attribute_map.each_pair do |attr, param|
306
+ value = self.send(attr)
307
+ if value.nil?
308
+ is_nullable = self.class.openapi_nullable.include?(attr)
309
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
310
+ end
311
+
312
+ hash[param] = _to_hash(value)
313
+ end
314
+ hash
315
+ end
316
+
317
+ # Outputs non-array value in the form of hash
318
+ # For object, use to_hash. Otherwise, just return the value
319
+ # @param [Object] value Any valid value
320
+ # @return [Hash] Returns the value in the form of hash
321
+ def _to_hash(value)
322
+ if value.is_a?(Array)
323
+ value.compact.map { |v| _to_hash(v) }
324
+ elsif value.is_a?(Hash)
325
+ {}.tap do |hash|
326
+ value.each { |k, v| hash[k] = _to_hash(v) }
327
+ end
328
+ elsif value.respond_to? :to_hash
329
+ value.to_hash
330
+ else
331
+ value
332
+ end
333
+ end
334
+
335
+ end
336
+
337
+ end
@@ -0,0 +1,245 @@
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 ItemOrSubItemPolicyResponse
18
+ # A policy that was applied to this item or sub-item
19
+ attr_accessor :policy_id
20
+
21
+ # The date at which this item or sub-item should expire according to this policy
22
+ attr_accessor :expiry_date
23
+
24
+ # The date at which this policy was last applied to this item or sub-item
25
+ attr_accessor :last_application_date
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'policy_id' => :'policy-id',
31
+ :'expiry_date' => :'expiry-date',
32
+ :'last_application_date' => :'last-application-date'
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
+ :'policy_id' => :'String',
45
+ :'expiry_date' => :'Date',
46
+ :'last_application_date' => :'Date'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Metronome::ItemOrSubItemPolicyResponse` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Metronome::ItemOrSubItemPolicyResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'policy_id')
72
+ self.policy_id = attributes[:'policy_id']
73
+ end
74
+
75
+ if attributes.key?(:'expiry_date')
76
+ self.expiry_date = attributes[:'expiry_date']
77
+ end
78
+
79
+ if attributes.key?(:'last_application_date')
80
+ self.last_application_date = attributes[:'last_application_date']
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 @policy_id.nil?
89
+ invalid_properties.push('invalid value for "policy_id", policy_id cannot be nil.')
90
+ end
91
+
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ return false if @policy_id.nil?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ policy_id == o.policy_id &&
108
+ expiry_date == o.expiry_date &&
109
+ last_application_date == o.last_application_date
110
+ end
111
+
112
+ # @see the `==` method
113
+ # @param [Object] Object to be compared
114
+ def eql?(o)
115
+ self == o
116
+ end
117
+
118
+ # Calculates hash code according to all attributes.
119
+ # @return [Integer] Hash code
120
+ def hash
121
+ [policy_id, expiry_date, last_application_date].hash
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def self.build_from_hash(attributes)
128
+ new.build_from_hash(attributes)
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def build_from_hash(attributes)
135
+ return nil unless attributes.is_a?(Hash)
136
+ attributes = attributes.transform_keys(&:to_sym)
137
+ self.class.openapi_types.each_pair do |key, type|
138
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
139
+ self.send("#{key}=", nil)
140
+ elsif type =~ /\AArray<(.*)>/i
141
+ # check to ensure the input is an array given that the attribute
142
+ # is documented as an array but the input is not
143
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
144
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
145
+ end
146
+ elsif !attributes[self.class.attribute_map[key]].nil?
147
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
148
+ end
149
+ end
150
+
151
+ self
152
+ end
153
+
154
+ # Deserializes the data based on type
155
+ # @param string type Data type
156
+ # @param string value Value to be deserialized
157
+ # @return [Object] Deserialized data
158
+ def _deserialize(type, value)
159
+ case type.to_sym
160
+ when :Time
161
+ Time.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :Boolean
171
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ else # model
191
+ # models (e.g. Pet) or oneOf
192
+ klass = Metronome.const_get(type)
193
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
194
+ end
195
+ end
196
+
197
+ # Returns the string representation of the object
198
+ # @return [String] String presentation of the object
199
+ def to_s
200
+ to_hash.to_s
201
+ end
202
+
203
+ # to_body is an alias to to_hash (backward compatibility)
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_body
206
+ to_hash
207
+ end
208
+
209
+ # Returns the object in the form of hash
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_hash
212
+ hash = {}
213
+ self.class.attribute_map.each_pair do |attr, param|
214
+ value = self.send(attr)
215
+ if value.nil?
216
+ is_nullable = self.class.openapi_nullable.include?(attr)
217
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
218
+ end
219
+
220
+ hash[param] = _to_hash(value)
221
+ end
222
+ hash
223
+ end
224
+
225
+ # Outputs non-array value in the form of hash
226
+ # For object, use to_hash. Otherwise, just return the value
227
+ # @param [Object] value Any valid value
228
+ # @return [Hash] Returns the value in the form of hash
229
+ def _to_hash(value)
230
+ if value.is_a?(Array)
231
+ value.compact.map { |v| _to_hash(v) }
232
+ elsif value.is_a?(Hash)
233
+ {}.tap do |hash|
234
+ value.each { |k, v| hash[k] = _to_hash(v) }
235
+ end
236
+ elsif value.respond_to? :to_hash
237
+ value.to_hash
238
+ else
239
+ value
240
+ end
241
+ end
242
+
243
+ end
244
+
245
+ end