trinsic_api 2.2.0 → 2.3.0.pre.alpha1

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/docs/AddRedirectUriResponse.md +18 -0
  3. data/docs/ContractField.md +2 -0
  4. data/docs/ContractIdentifierField.md +22 -0
  5. data/docs/CreateVerificationProfileResponse.md +18 -0
  6. data/docs/EnvironmentRedirectUrisAddRequest.md +18 -0
  7. data/docs/EnvironmentRedirectUrisApi.md +222 -0
  8. data/docs/FaydaProviderOutput.md +18 -0
  9. data/docs/Identifier.md +22 -0
  10. data/docs/IdentityData.md +5 -1
  11. data/docs/ListEnvironmentRedirectUrisResponse.md +20 -0
  12. data/docs/ListVerificationProfilesResponse.md +20 -0
  13. data/docs/MexicoCurpProviderOutput.md +18 -0
  14. data/docs/ProviderContract.md +2 -0
  15. data/docs/ProviderOutput.md +22 -0
  16. data/docs/RedirectUriResponse.md +20 -0
  17. data/docs/SpidBillingInformation.md +22 -0
  18. data/docs/SpidInput.md +3 -1
  19. data/docs/SpidProviderOutput.md +26 -0
  20. data/docs/VerificationProfileResponse.md +28 -0
  21. data/docs/VerificationProfilesApi.md +231 -0
  22. data/lib/trinsic_api/api/environment_redirect_uris_api.rb +228 -0
  23. data/lib/trinsic_api/api/verification_profiles_api.rb +273 -0
  24. data/lib/trinsic_api/models/add_redirect_uri_response.rb +237 -0
  25. data/lib/trinsic_api/models/contract_field.rb +28 -1
  26. data/lib/trinsic_api/models/contract_identifier_field.rb +315 -0
  27. data/lib/trinsic_api/models/create_verification_profile_response.rb +238 -0
  28. data/lib/trinsic_api/models/environment_redirect_uris_add_request.rb +237 -0
  29. data/lib/trinsic_api/models/fayda_provider_output.rb +222 -0
  30. data/lib/trinsic_api/models/identifier.rb +289 -0
  31. data/lib/trinsic_api/models/identity_data.rb +43 -5
  32. data/lib/trinsic_api/models/list_environment_redirect_uris_response.rb +268 -0
  33. data/lib/trinsic_api/models/list_verification_profiles_response.rb +266 -0
  34. data/lib/trinsic_api/models/mexico_curp_provider_output.rb +222 -0
  35. data/lib/trinsic_api/models/provider_contract.rb +14 -1
  36. data/lib/trinsic_api/models/provider_output.rb +241 -0
  37. data/lib/trinsic_api/models/redirect_uri_response.rb +263 -0
  38. data/lib/trinsic_api/models/spid_billing_information.rb +293 -0
  39. data/lib/trinsic_api/models/spid_input.rb +16 -5
  40. data/lib/trinsic_api/models/spid_provider_output.rb +266 -0
  41. data/lib/trinsic_api/models/verification_profile_response.rb +375 -0
  42. data/lib/trinsic_api/version.rb +1 -1
  43. data/lib/trinsic_api.rb +16 -0
  44. data/spec/api/environment_redirect_uris_api_spec.rb +72 -0
  45. data/spec/api/verification_profiles_api_spec.rb +76 -0
  46. data/spec/models/add_redirect_uri_response_spec.rb +36 -0
  47. data/spec/models/contract_field_spec.rb +6 -0
  48. data/spec/models/contract_identifier_field_spec.rb +48 -0
  49. data/spec/models/create_verification_profile_response_spec.rb +36 -0
  50. data/spec/models/environment_redirect_uris_add_request_spec.rb +36 -0
  51. data/spec/models/fayda_provider_output_spec.rb +36 -0
  52. data/spec/models/identifier_spec.rb +48 -0
  53. data/spec/models/identity_data_spec.rb +12 -0
  54. data/spec/models/list_environment_redirect_uris_response_spec.rb +42 -0
  55. data/spec/models/list_verification_profiles_response_spec.rb +42 -0
  56. data/spec/models/mexico_curp_provider_output_spec.rb +36 -0
  57. data/spec/models/provider_contract_spec.rb +6 -0
  58. data/spec/models/provider_output_spec.rb +48 -0
  59. data/spec/models/redirect_uri_response_spec.rb +42 -0
  60. data/spec/models/spid_billing_information_spec.rb +48 -0
  61. data/spec/models/spid_input_spec.rb +6 -0
  62. data/spec/models/spid_provider_output_spec.rb +60 -0
  63. data/spec/models/verification_profile_response_spec.rb +66 -0
  64. metadata +66 -2
@@ -0,0 +1,293 @@
1
+ =begin
2
+ #Trinsic API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TrinsicApi
17
+ # Billing information for a SPID Verification.
18
+ class SpidBillingInformation
19
+ # Whether this SPID verification has resulted in a billable event.
20
+ attr_accessor :is_billable
21
+
22
+ # The billable verification type for this SPID verification. Possible values: \"Authentication\" | \"Registration\"
23
+ attr_accessor :verification_type
24
+
25
+ # The billable verification level for this SPID verification. Possible values: 1 | 2 | 3
26
+ attr_accessor :verification_level
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'is_billable' => :'isBillable',
32
+ :'verification_type' => :'verificationType',
33
+ :'verification_level' => :'verificationLevel'
34
+ }
35
+ end
36
+
37
+ # Returns attribute mapping this model knows about
38
+ def self.acceptable_attribute_map
39
+ attribute_map
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ acceptable_attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'is_billable' => :'Boolean',
51
+ :'verification_type' => :'String',
52
+ :'verification_level' => :'Integer'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TrinsicApi::SpidBillingInformation` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ acceptable_attribute_map = self.class.acceptable_attribute_map
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!acceptable_attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TrinsicApi::SpidBillingInformation`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'is_billable')
79
+ self.is_billable = attributes[:'is_billable']
80
+ else
81
+ self.is_billable = nil
82
+ end
83
+
84
+ if attributes.key?(:'verification_type')
85
+ self.verification_type = attributes[:'verification_type']
86
+ else
87
+ self.verification_type = nil
88
+ end
89
+
90
+ if attributes.key?(:'verification_level')
91
+ self.verification_level = attributes[:'verification_level']
92
+ else
93
+ self.verification_level = nil
94
+ end
95
+ end
96
+
97
+ # Show invalid properties with the reasons. Usually used together with valid?
98
+ # @return Array for valid properties with the reasons
99
+ def list_invalid_properties
100
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
101
+ invalid_properties = Array.new
102
+ if @is_billable.nil?
103
+ invalid_properties.push('invalid value for "is_billable", is_billable cannot be nil.')
104
+ end
105
+
106
+ if @verification_type.nil?
107
+ invalid_properties.push('invalid value for "verification_type", verification_type cannot be nil.')
108
+ end
109
+
110
+ if @verification_level.nil?
111
+ invalid_properties.push('invalid value for "verification_level", verification_level cannot be nil.')
112
+ end
113
+
114
+ invalid_properties
115
+ end
116
+
117
+ # Check to see if the all the properties in the model are valid
118
+ # @return true if the model is valid
119
+ def valid?
120
+ warn '[DEPRECATED] the `valid?` method is obsolete'
121
+ return false if @is_billable.nil?
122
+ return false if @verification_type.nil?
123
+ return false if @verification_level.nil?
124
+ true
125
+ end
126
+
127
+ # Custom attribute writer method with validation
128
+ # @param [Object] is_billable Value to be assigned
129
+ def is_billable=(is_billable)
130
+ if is_billable.nil?
131
+ fail ArgumentError, 'is_billable cannot be nil'
132
+ end
133
+
134
+ @is_billable = is_billable
135
+ end
136
+
137
+ # Custom attribute writer method with validation
138
+ # @param [Object] verification_type Value to be assigned
139
+ def verification_type=(verification_type)
140
+ if verification_type.nil?
141
+ fail ArgumentError, 'verification_type cannot be nil'
142
+ end
143
+
144
+ @verification_type = verification_type
145
+ end
146
+
147
+ # Custom attribute writer method with validation
148
+ # @param [Object] verification_level Value to be assigned
149
+ def verification_level=(verification_level)
150
+ if verification_level.nil?
151
+ fail ArgumentError, 'verification_level cannot be nil'
152
+ end
153
+
154
+ @verification_level = verification_level
155
+ end
156
+
157
+ # Checks equality by comparing each attribute.
158
+ # @param [Object] Object to be compared
159
+ def ==(o)
160
+ return true if self.equal?(o)
161
+ self.class == o.class &&
162
+ is_billable == o.is_billable &&
163
+ verification_type == o.verification_type &&
164
+ verification_level == o.verification_level
165
+ end
166
+
167
+ # @see the `==` method
168
+ # @param [Object] Object to be compared
169
+ def eql?(o)
170
+ self == o
171
+ end
172
+
173
+ # Calculates hash code according to all attributes.
174
+ # @return [Integer] Hash code
175
+ def hash
176
+ [is_billable, verification_type, verification_level].hash
177
+ end
178
+
179
+ # Builds the object from hash
180
+ # @param [Hash] attributes Model attributes in the form of hash
181
+ # @return [Object] Returns the model itself
182
+ def self.build_from_hash(attributes)
183
+ return nil unless attributes.is_a?(Hash)
184
+ attributes = attributes.transform_keys(&:to_sym)
185
+ transformed_hash = {}
186
+ openapi_types.each_pair do |key, type|
187
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
188
+ transformed_hash["#{key}"] = nil
189
+ elsif type =~ /\AArray<(.*)>/i
190
+ # check to ensure the input is an array given that the attribute
191
+ # is documented as an array but the input is not
192
+ if attributes[attribute_map[key]].is_a?(Array)
193
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
194
+ end
195
+ elsif !attributes[attribute_map[key]].nil?
196
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
197
+ end
198
+ end
199
+ new(transformed_hash)
200
+ end
201
+
202
+ # Deserializes the data based on type
203
+ # @param string type Data type
204
+ # @param string value Value to be deserialized
205
+ # @return [Object] Deserialized data
206
+ def self._deserialize(type, value)
207
+ case type.to_sym
208
+ when :Time
209
+ Time.parse(value)
210
+ when :Date
211
+ Date.parse(value)
212
+ when :String
213
+ value.to_s
214
+ when :Integer
215
+ value.to_i
216
+ when :Float
217
+ value.to_f
218
+ when :Boolean
219
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
220
+ true
221
+ else
222
+ false
223
+ end
224
+ when :Object
225
+ # generic object (usually a Hash), return directly
226
+ value
227
+ when /\AArray<(?<inner_type>.+)>\z/
228
+ inner_type = Regexp.last_match[:inner_type]
229
+ value.map { |v| _deserialize(inner_type, v) }
230
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
231
+ k_type = Regexp.last_match[:k_type]
232
+ v_type = Regexp.last_match[:v_type]
233
+ {}.tap do |hash|
234
+ value.each do |k, v|
235
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
236
+ end
237
+ end
238
+ else # model
239
+ # models (e.g. Pet) or oneOf
240
+ klass = TrinsicApi.const_get(type)
241
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
242
+ end
243
+ end
244
+
245
+ # Returns the string representation of the object
246
+ # @return [String] String presentation of the object
247
+ def to_s
248
+ to_hash.to_s
249
+ end
250
+
251
+ # to_body is an alias to to_hash (backward compatibility)
252
+ # @return [Hash] Returns the object in the form of hash
253
+ def to_body
254
+ to_hash
255
+ end
256
+
257
+ # Returns the object in the form of hash
258
+ # @return [Hash] Returns the object in the form of hash
259
+ def to_hash
260
+ hash = {}
261
+ self.class.attribute_map.each_pair do |attr, param|
262
+ value = self.send(attr)
263
+ if value.nil?
264
+ is_nullable = self.class.openapi_nullable.include?(attr)
265
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
266
+ end
267
+
268
+ hash[param] = _to_hash(value)
269
+ end
270
+ hash
271
+ end
272
+
273
+ # Outputs non-array value in the form of hash
274
+ # For object, use to_hash. Otherwise, just return the value
275
+ # @param [Object] value Any valid value
276
+ # @return [Hash] Returns the value in the form of hash
277
+ def _to_hash(value)
278
+ if value.is_a?(Array)
279
+ value.compact.map { |v| _to_hash(v) }
280
+ elsif value.is_a?(Hash)
281
+ {}.tap do |hash|
282
+ value.each { |k, v| hash[k] = _to_hash(v) }
283
+ end
284
+ elsif value.respond_to? :to_hash
285
+ value.to_hash
286
+ else
287
+ value
288
+ end
289
+ end
290
+
291
+ end
292
+
293
+ end
@@ -18,10 +18,14 @@ module TrinsicApi
18
18
  # The ID of the specific IDP to invoke within SPID. If not specified, the user will be prompted to select an IDP.
19
19
  attr_accessor :sub_provider_id
20
20
 
21
+ # Only applicable if period-based billing is enabled for your Verification Profile. Contact Trinsic to enable this. A secret UTF-8 string between 32 and 64 characters in length, used to enable privacy-preserving tracking of unique user verifications during a billing period. WARNING: This value must NOT change during the course of a billing period for a given Verification Profile, or double-billing may occur. If multiple Verification Profiles are configured to use the same Trinsic-managed SPID Service Provider, the same Billing Tracking Secret must be provided across all such Verification Profiles.
22
+ attr_accessor :billing_tracking_secret
23
+
21
24
  # Attribute mapping from ruby-style variable name to JSON key.
22
25
  def self.attribute_map
23
26
  {
24
- :'sub_provider_id' => :'subProviderId'
27
+ :'sub_provider_id' => :'subProviderId',
28
+ :'billing_tracking_secret' => :'billingTrackingSecret'
25
29
  }
26
30
  end
27
31
 
@@ -38,14 +42,16 @@ module TrinsicApi
38
42
  # Attribute type mapping.
39
43
  def self.openapi_types
40
44
  {
41
- :'sub_provider_id' => :'String'
45
+ :'sub_provider_id' => :'String',
46
+ :'billing_tracking_secret' => :'String'
42
47
  }
43
48
  end
44
49
 
45
50
  # List of attributes with nullable: true
46
51
  def self.openapi_nullable
47
52
  Set.new([
48
- :'sub_provider_id'
53
+ :'sub_provider_id',
54
+ :'billing_tracking_secret'
49
55
  ])
50
56
  end
51
57
 
@@ -68,6 +74,10 @@ module TrinsicApi
68
74
  if attributes.key?(:'sub_provider_id')
69
75
  self.sub_provider_id = attributes[:'sub_provider_id']
70
76
  end
77
+
78
+ if attributes.key?(:'billing_tracking_secret')
79
+ self.billing_tracking_secret = attributes[:'billing_tracking_secret']
80
+ end
71
81
  end
72
82
 
73
83
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -90,7 +100,8 @@ module TrinsicApi
90
100
  def ==(o)
91
101
  return true if self.equal?(o)
92
102
  self.class == o.class &&
93
- sub_provider_id == o.sub_provider_id
103
+ sub_provider_id == o.sub_provider_id &&
104
+ billing_tracking_secret == o.billing_tracking_secret
94
105
  end
95
106
 
96
107
  # @see the `==` method
@@ -102,7 +113,7 @@ module TrinsicApi
102
113
  # Calculates hash code according to all attributes.
103
114
  # @return [Integer] Hash code
104
115
  def hash
105
- [sub_provider_id].hash
116
+ [sub_provider_id, billing_tracking_secret].hash
106
117
  end
107
118
 
108
119
  # Builds the object from hash
@@ -0,0 +1,266 @@
1
+ =begin
2
+ #Trinsic API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TrinsicApi
17
+ class SpidProviderOutput
18
+ # Information about the billable status of this SPID Verification. Present only if your account has period-based billing enabled for SPID. Contact Trinsic to enable this.
19
+ attr_accessor :billing_information
20
+
21
+ # Fiscal tax number for the subject.
22
+ attr_accessor :fiscal_number
23
+
24
+ # Unique user identifier contained within the SPID identity.
25
+ attr_accessor :spid_code
26
+
27
+ # VAT number for the subject.
28
+ attr_accessor :iva_code
29
+
30
+ # Expiration date of the user's SPID credential. This is not the same as the expiration date of the underlying identity document (such as a passport) which was used to create the SPID identity.
31
+ attr_accessor :spid_credential_expiration_date
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'billing_information' => :'billingInformation',
37
+ :'fiscal_number' => :'fiscalNumber',
38
+ :'spid_code' => :'spidCode',
39
+ :'iva_code' => :'ivaCode',
40
+ :'spid_credential_expiration_date' => :'spidCredentialExpirationDate'
41
+ }
42
+ end
43
+
44
+ # Returns attribute mapping this model knows about
45
+ def self.acceptable_attribute_map
46
+ attribute_map
47
+ end
48
+
49
+ # Returns all the JSON keys this model knows about
50
+ def self.acceptable_attributes
51
+ acceptable_attribute_map.values
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'billing_information' => :'SpidBillingInformation',
58
+ :'fiscal_number' => :'String',
59
+ :'spid_code' => :'String',
60
+ :'iva_code' => :'String',
61
+ :'spid_credential_expiration_date' => :'Date'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ :'billing_information',
69
+ :'fiscal_number',
70
+ :'spid_code',
71
+ :'iva_code',
72
+ :'spid_credential_expiration_date'
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TrinsicApi::SpidProviderOutput` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ acceptable_attribute_map = self.class.acceptable_attribute_map
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!acceptable_attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TrinsicApi::SpidProviderOutput`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'billing_information')
93
+ self.billing_information = attributes[:'billing_information']
94
+ end
95
+
96
+ if attributes.key?(:'fiscal_number')
97
+ self.fiscal_number = attributes[:'fiscal_number']
98
+ end
99
+
100
+ if attributes.key?(:'spid_code')
101
+ self.spid_code = attributes[:'spid_code']
102
+ end
103
+
104
+ if attributes.key?(:'iva_code')
105
+ self.iva_code = attributes[:'iva_code']
106
+ end
107
+
108
+ if attributes.key?(:'spid_credential_expiration_date')
109
+ self.spid_credential_expiration_date = attributes[:'spid_credential_expiration_date']
110
+ end
111
+ end
112
+
113
+ # Show invalid properties with the reasons. Usually used together with valid?
114
+ # @return Array for valid properties with the reasons
115
+ def list_invalid_properties
116
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
117
+ invalid_properties = Array.new
118
+ invalid_properties
119
+ end
120
+
121
+ # Check to see if the all the properties in the model are valid
122
+ # @return true if the model is valid
123
+ def valid?
124
+ warn '[DEPRECATED] the `valid?` method is obsolete'
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
+ billing_information == o.billing_information &&
134
+ fiscal_number == o.fiscal_number &&
135
+ spid_code == o.spid_code &&
136
+ iva_code == o.iva_code &&
137
+ spid_credential_expiration_date == o.spid_credential_expiration_date
138
+ end
139
+
140
+ # @see the `==` method
141
+ # @param [Object] Object to be compared
142
+ def eql?(o)
143
+ self == o
144
+ end
145
+
146
+ # Calculates hash code according to all attributes.
147
+ # @return [Integer] Hash code
148
+ def hash
149
+ [billing_information, fiscal_number, spid_code, iva_code, spid_credential_expiration_date].hash
150
+ end
151
+
152
+ # Builds the object from hash
153
+ # @param [Hash] attributes Model attributes in the form of hash
154
+ # @return [Object] Returns the model itself
155
+ def self.build_from_hash(attributes)
156
+ return nil unless attributes.is_a?(Hash)
157
+ attributes = attributes.transform_keys(&:to_sym)
158
+ transformed_hash = {}
159
+ openapi_types.each_pair do |key, type|
160
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
161
+ transformed_hash["#{key}"] = nil
162
+ elsif type =~ /\AArray<(.*)>/i
163
+ # check to ensure the input is an array given that the attribute
164
+ # is documented as an array but the input is not
165
+ if attributes[attribute_map[key]].is_a?(Array)
166
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
167
+ end
168
+ elsif !attributes[attribute_map[key]].nil?
169
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
170
+ end
171
+ end
172
+ new(transformed_hash)
173
+ end
174
+
175
+ # Deserializes the data based on type
176
+ # @param string type Data type
177
+ # @param string value Value to be deserialized
178
+ # @return [Object] Deserialized data
179
+ def self._deserialize(type, value)
180
+ case type.to_sym
181
+ when :Time
182
+ Time.parse(value)
183
+ when :Date
184
+ Date.parse(value)
185
+ when :String
186
+ value.to_s
187
+ when :Integer
188
+ value.to_i
189
+ when :Float
190
+ value.to_f
191
+ when :Boolean
192
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
193
+ true
194
+ else
195
+ false
196
+ end
197
+ when :Object
198
+ # generic object (usually a Hash), return directly
199
+ value
200
+ when /\AArray<(?<inner_type>.+)>\z/
201
+ inner_type = Regexp.last_match[:inner_type]
202
+ value.map { |v| _deserialize(inner_type, v) }
203
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
204
+ k_type = Regexp.last_match[:k_type]
205
+ v_type = Regexp.last_match[:v_type]
206
+ {}.tap do |hash|
207
+ value.each do |k, v|
208
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
209
+ end
210
+ end
211
+ else # model
212
+ # models (e.g. Pet) or oneOf
213
+ klass = TrinsicApi.const_get(type)
214
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
215
+ end
216
+ end
217
+
218
+ # Returns the string representation of the object
219
+ # @return [String] String presentation of the object
220
+ def to_s
221
+ to_hash.to_s
222
+ end
223
+
224
+ # to_body is an alias to to_hash (backward compatibility)
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_body
227
+ to_hash
228
+ end
229
+
230
+ # Returns the object in the form of hash
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_hash
233
+ hash = {}
234
+ self.class.attribute_map.each_pair do |attr, param|
235
+ value = self.send(attr)
236
+ if value.nil?
237
+ is_nullable = self.class.openapi_nullable.include?(attr)
238
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
239
+ end
240
+
241
+ hash[param] = _to_hash(value)
242
+ end
243
+ hash
244
+ end
245
+
246
+ # Outputs non-array value in the form of hash
247
+ # For object, use to_hash. Otherwise, just return the value
248
+ # @param [Object] value Any valid value
249
+ # @return [Hash] Returns the value in the form of hash
250
+ def _to_hash(value)
251
+ if value.is_a?(Array)
252
+ value.compact.map { |v| _to_hash(v) }
253
+ elsif value.is_a?(Hash)
254
+ {}.tap do |hash|
255
+ value.each { |k, v| hash[k] = _to_hash(v) }
256
+ end
257
+ elsif value.respond_to? :to_hash
258
+ value.to_hash
259
+ else
260
+ value
261
+ end
262
+ end
263
+
264
+ end
265
+
266
+ end