turnkey_client 0.0.14 → 0.0.15

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/turnkey_client/api/app_proof_api.rb +77 -0
  3. data/lib/turnkey_client/api/boot_proof_api.rb +135 -0
  4. data/lib/turnkey_client/api/default_api.rb +77 -0
  5. data/lib/turnkey_client/api/user_auth_api.rb +290 -0
  6. data/lib/turnkey_client/models/activity.rb +13 -1
  7. data/lib/turnkey_client/models/activity_type.rb +7 -0
  8. data/lib/turnkey_client/models/app_proof.rb +255 -0
  9. data/lib/turnkey_client/models/boot_proof.rb +315 -0
  10. data/lib/turnkey_client/models/boot_proof_response.rb +210 -0
  11. data/lib/turnkey_client/models/common_v1_policy_evaluation.rb +214 -0
  12. data/lib/turnkey_client/models/create_oauth2_credential_intent.rb +240 -0
  13. data/lib/turnkey_client/models/create_oauth2_credential_request.rb +288 -0
  14. data/lib/turnkey_client/models/create_oauth2_credential_result.rb +211 -0
  15. data/lib/turnkey_client/models/create_sub_organization_intent_v7.rb +16 -5
  16. data/lib/turnkey_client/models/delete_oauth2_credential_intent.rb +211 -0
  17. data/lib/turnkey_client/models/delete_oauth2_credential_request.rb +288 -0
  18. data/lib/turnkey_client/models/delete_oauth2_credential_result.rb +211 -0
  19. data/lib/turnkey_client/models/disable_auth_proxy_intent.rb +196 -0
  20. data/lib/turnkey_client/models/disable_auth_proxy_result.rb +196 -0
  21. data/lib/turnkey_client/models/enable_auth_proxy_intent.rb +196 -0
  22. data/lib/turnkey_client/models/enable_auth_proxy_result.rb +211 -0
  23. data/lib/turnkey_client/models/feature_name.rb +1 -0
  24. data/lib/turnkey_client/models/get_app_proofs_request.rb +226 -0
  25. data/lib/turnkey_client/models/get_app_proofs_response.rb +212 -0
  26. data/lib/turnkey_client/models/get_boot_proof_request.rb +226 -0
  27. data/lib/turnkey_client/models/get_latest_boot_proof_request.rb +226 -0
  28. data/lib/turnkey_client/models/get_oauth2_credential_request.rb +226 -0
  29. data/lib/turnkey_client/models/get_oauth2_credential_response.rb +210 -0
  30. data/lib/turnkey_client/models/get_wallet_accounts_request.rb +12 -1
  31. data/lib/turnkey_client/models/init_fiat_on_ramp_intent.rb +16 -5
  32. data/lib/turnkey_client/models/init_fiat_on_ramp_result.rb +14 -4
  33. data/lib/turnkey_client/models/intent.rb +67 -4
  34. data/lib/turnkey_client/models/list_oauth2_credentials_request.rb +211 -0
  35. data/lib/turnkey_client/models/list_oauth2_credentials_response.rb +212 -0
  36. data/lib/turnkey_client/models/oauth2_authenticate_intent.rb +278 -0
  37. data/lib/turnkey_client/models/oauth2_authenticate_request.rb +288 -0
  38. data/lib/turnkey_client/models/oauth2_authenticate_result.rb +211 -0
  39. data/lib/turnkey_client/models/oauth2_credential.rb +298 -0
  40. data/lib/turnkey_client/models/oauth2_provider.rb +27 -0
  41. data/lib/turnkey_client/models/otp_login_intent.rb +16 -5
  42. data/lib/turnkey_client/models/payload_encoding.rb +1 -0
  43. data/lib/turnkey_client/models/result.rb +67 -4
  44. data/lib/turnkey_client/models/signature_scheme.rb +26 -0
  45. data/lib/turnkey_client/models/smart_contract_interface.rb +329 -0
  46. data/lib/turnkey_client/models/update_auth_proxy_config_intent.rb +346 -0
  47. data/lib/turnkey_client/models/update_auth_proxy_config_result.rb +206 -0
  48. data/lib/turnkey_client/models/update_oauth2_credential_intent.rb +255 -0
  49. data/lib/turnkey_client/models/update_oauth2_credential_request.rb +288 -0
  50. data/lib/turnkey_client/models/update_oauth2_credential_result.rb +211 -0
  51. data/lib/turnkey_client/models/verify_otp_intent.rb +16 -5
  52. data/lib/turnkey_client/models/wallet_account.rb +14 -5
  53. data/lib/turnkey_client/models/wallet_kit_settings_params.rb +230 -0
  54. data/lib/turnkey_client/version.rb +1 -1
  55. data/lib/turnkey_client.rb +38 -2
  56. data/turnkey_client-0.0.14.gem +0 -0
  57. metadata +41 -2
@@ -106,6 +106,13 @@ module TurnkeyClient
106
106
  INIT_FIAT_ON_RAMP = 'ACTIVITY_TYPE_INIT_FIAT_ON_RAMP'.freeze
107
107
  CREATE_SMART_CONTRACT_INTERFACE = 'ACTIVITY_TYPE_CREATE_SMART_CONTRACT_INTERFACE'.freeze
108
108
  DELETE_SMART_CONTRACT_INTERFACE = 'ACTIVITY_TYPE_DELETE_SMART_CONTRACT_INTERFACE'.freeze
109
+ ENABLE_AUTH_PROXY = 'ACTIVITY_TYPE_ENABLE_AUTH_PROXY'.freeze
110
+ DISABLE_AUTH_PROXY = 'ACTIVITY_TYPE_DISABLE_AUTH_PROXY'.freeze
111
+ UPDATE_AUTH_PROXY_CONFIG = 'ACTIVITY_TYPE_UPDATE_AUTH_PROXY_CONFIG'.freeze
112
+ CREATE_OAUTH2_CREDENTIAL = 'ACTIVITY_TYPE_CREATE_OAUTH2_CREDENTIAL'.freeze
113
+ UPDATE_OAUTH2_CREDENTIAL = 'ACTIVITY_TYPE_UPDATE_OAUTH2_CREDENTIAL'.freeze
114
+ DELETE_OAUTH2_CREDENTIAL = 'ACTIVITY_TYPE_DELETE_OAUTH2_CREDENTIAL'.freeze
115
+ OAUTH2_AUTHENTICATE = 'ACTIVITY_TYPE_OAUTH2_AUTHENTICATE'.freeze
109
116
 
110
117
  # Builds the enum from string
111
118
  # @param [String] The enum value in the form of the string
@@ -0,0 +1,255 @@
1
+ =begin
2
+ #API Reference
3
+
4
+ #Review our [API Introduction](../api-introduction) to get started.
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module TurnkeyClient
14
+ class AppProof
15
+ attr_accessor :scheme
16
+
17
+ # Ephemeral public key.
18
+ attr_accessor :public_key
19
+
20
+ # JSON serialized AppProofPayload.
21
+ attr_accessor :proof_payload
22
+
23
+ # Signature over hashed proof_payload.
24
+ attr_accessor :signature
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'scheme' => :'scheme',
30
+ :'public_key' => :'publicKey',
31
+ :'proof_payload' => :'proofPayload',
32
+ :'signature' => :'signature'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'scheme' => :'Object',
40
+ :'public_key' => :'Object',
41
+ :'proof_payload' => :'Object',
42
+ :'signature' => :'Object'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TurnkeyClient::AppProof` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TurnkeyClient::AppProof`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'scheme')
68
+ self.scheme = attributes[:'scheme']
69
+ end
70
+
71
+ if attributes.key?(:'public_key')
72
+ self.public_key = attributes[:'public_key']
73
+ end
74
+
75
+ if attributes.key?(:'proof_payload')
76
+ self.proof_payload = attributes[:'proof_payload']
77
+ end
78
+
79
+ if attributes.key?(:'signature')
80
+ self.signature = attributes[:'signature']
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 @scheme.nil?
89
+ invalid_properties.push('invalid value for "scheme", scheme cannot be nil.')
90
+ end
91
+
92
+ if @public_key.nil?
93
+ invalid_properties.push('invalid value for "public_key", public_key cannot be nil.')
94
+ end
95
+
96
+ if @proof_payload.nil?
97
+ invalid_properties.push('invalid value for "proof_payload", proof_payload cannot be nil.')
98
+ end
99
+
100
+ if @signature.nil?
101
+ invalid_properties.push('invalid value for "signature", signature cannot be nil.')
102
+ end
103
+
104
+ invalid_properties
105
+ end
106
+
107
+ # Check to see if the all the properties in the model are valid
108
+ # @return true if the model is valid
109
+ def valid?
110
+ return false if @scheme.nil?
111
+ return false if @public_key.nil?
112
+ return false if @proof_payload.nil?
113
+ return false if @signature.nil?
114
+ true
115
+ end
116
+
117
+ # Checks equality by comparing each attribute.
118
+ # @param [Object] Object to be compared
119
+ def ==(o)
120
+ return true if self.equal?(o)
121
+ self.class == o.class &&
122
+ scheme == o.scheme &&
123
+ public_key == o.public_key &&
124
+ proof_payload == o.proof_payload &&
125
+ signature == o.signature
126
+ end
127
+
128
+ # @see the `==` method
129
+ # @param [Object] Object to be compared
130
+ def eql?(o)
131
+ self == o
132
+ end
133
+
134
+ # Calculates hash code according to all attributes.
135
+ # @return [Integer] Hash code
136
+ def hash
137
+ [scheme, public_key, proof_payload, signature].hash
138
+ end
139
+
140
+ # Builds the object from hash
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ # @return [Object] Returns the model itself
143
+ def self.build_from_hash(attributes)
144
+ new.build_from_hash(attributes)
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def build_from_hash(attributes)
151
+ return nil unless attributes.is_a?(Hash)
152
+ self.class.openapi_types.each_pair do |key, type|
153
+ if type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
157
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
158
+ end
159
+ elsif !attributes[self.class.attribute_map[key]].nil?
160
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
161
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
162
+ self.send("#{key}=", nil)
163
+ end
164
+ end
165
+
166
+ self
167
+ end
168
+
169
+ # Deserializes the data based on type
170
+ # @param string type Data type
171
+ # @param string value Value to be deserialized
172
+ # @return [Object] Deserialized data
173
+ def _deserialize(type, value)
174
+ case type.to_sym
175
+ when :DateTime
176
+ DateTime.parse(value)
177
+ when :Date
178
+ Date.parse(value)
179
+ when :String
180
+ value.to_s
181
+ when :Integer
182
+ value.to_i
183
+ when :Float
184
+ value.to_f
185
+ when :Boolean
186
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
187
+ true
188
+ else
189
+ false
190
+ end
191
+ when :Object
192
+ # generic object (usually a Hash), return directly
193
+ value
194
+ when /\AArray<(?<inner_type>.+)>\z/
195
+ inner_type = Regexp.last_match[:inner_type]
196
+ value.map { |v| _deserialize(inner_type, v) }
197
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
198
+ k_type = Regexp.last_match[:k_type]
199
+ v_type = Regexp.last_match[:v_type]
200
+ {}.tap do |hash|
201
+ value.each do |k, v|
202
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
203
+ end
204
+ end
205
+ else # model
206
+ TurnkeyClient.const_get(type).build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end end
255
+ end
@@ -0,0 +1,315 @@
1
+ =begin
2
+ #API Reference
3
+
4
+ #Review our [API Introduction](../api-introduction) to get started.
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module TurnkeyClient
14
+ class BootProof
15
+ # The hex encoded Ephemeral Public Key.
16
+ attr_accessor :ephemeral_public_key_hex
17
+
18
+ # The DER encoded COSE Sign1 struct Attestation doc.
19
+ attr_accessor :aws_attestation_doc_b64
20
+
21
+ # The borsch serialized base64 encoded Manifest.
22
+ attr_accessor :qos_manifest_b64
23
+
24
+ # The borsch serialized base64 encoded Manifest Envelope.
25
+ attr_accessor :qos_manifest_envelope_b64
26
+
27
+ # The label under which the enclave app was deployed.
28
+ attr_accessor :deployment_label
29
+
30
+ # Name of the enclave app
31
+ attr_accessor :enclave_app
32
+
33
+ # Owner of the app i.e. 'tkhq'
34
+ attr_accessor :owner
35
+
36
+ attr_accessor :created_at
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'ephemeral_public_key_hex' => :'ephemeralPublicKeyHex',
42
+ :'aws_attestation_doc_b64' => :'awsAttestationDocB64',
43
+ :'qos_manifest_b64' => :'qosManifestB64',
44
+ :'qos_manifest_envelope_b64' => :'qosManifestEnvelopeB64',
45
+ :'deployment_label' => :'deploymentLabel',
46
+ :'enclave_app' => :'enclaveApp',
47
+ :'owner' => :'owner',
48
+ :'created_at' => :'createdAt'
49
+ }
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'ephemeral_public_key_hex' => :'Object',
56
+ :'aws_attestation_doc_b64' => :'Object',
57
+ :'qos_manifest_b64' => :'Object',
58
+ :'qos_manifest_envelope_b64' => :'Object',
59
+ :'deployment_label' => :'Object',
60
+ :'enclave_app' => :'Object',
61
+ :'owner' => :'Object',
62
+ :'created_at' => :'Object'
63
+ }
64
+ end
65
+
66
+ # List of attributes with nullable: true
67
+ def self.openapi_nullable
68
+ Set.new([
69
+ ])
70
+ end
71
+
72
+ # Initializes the object
73
+ # @param [Hash] attributes Model attributes in the form of hash
74
+ def initialize(attributes = {})
75
+ if (!attributes.is_a?(Hash))
76
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TurnkeyClient::BootProof` initialize method"
77
+ end
78
+
79
+ # check to see if the attribute exists and convert string to symbol for hash key
80
+ attributes = attributes.each_with_object({}) { |(k, v), h|
81
+ if (!self.class.attribute_map.key?(k.to_sym))
82
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TurnkeyClient::BootProof`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
83
+ end
84
+ h[k.to_sym] = v
85
+ }
86
+
87
+ if attributes.key?(:'ephemeral_public_key_hex')
88
+ self.ephemeral_public_key_hex = attributes[:'ephemeral_public_key_hex']
89
+ end
90
+
91
+ if attributes.key?(:'aws_attestation_doc_b64')
92
+ self.aws_attestation_doc_b64 = attributes[:'aws_attestation_doc_b64']
93
+ end
94
+
95
+ if attributes.key?(:'qos_manifest_b64')
96
+ self.qos_manifest_b64 = attributes[:'qos_manifest_b64']
97
+ end
98
+
99
+ if attributes.key?(:'qos_manifest_envelope_b64')
100
+ self.qos_manifest_envelope_b64 = attributes[:'qos_manifest_envelope_b64']
101
+ end
102
+
103
+ if attributes.key?(:'deployment_label')
104
+ self.deployment_label = attributes[:'deployment_label']
105
+ end
106
+
107
+ if attributes.key?(:'enclave_app')
108
+ self.enclave_app = attributes[:'enclave_app']
109
+ end
110
+
111
+ if attributes.key?(:'owner')
112
+ self.owner = attributes[:'owner']
113
+ end
114
+
115
+ if attributes.key?(:'created_at')
116
+ self.created_at = attributes[:'created_at']
117
+ end
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ invalid_properties = Array.new
124
+ if @ephemeral_public_key_hex.nil?
125
+ invalid_properties.push('invalid value for "ephemeral_public_key_hex", ephemeral_public_key_hex cannot be nil.')
126
+ end
127
+
128
+ if @aws_attestation_doc_b64.nil?
129
+ invalid_properties.push('invalid value for "aws_attestation_doc_b64", aws_attestation_doc_b64 cannot be nil.')
130
+ end
131
+
132
+ if @qos_manifest_b64.nil?
133
+ invalid_properties.push('invalid value for "qos_manifest_b64", qos_manifest_b64 cannot be nil.')
134
+ end
135
+
136
+ if @qos_manifest_envelope_b64.nil?
137
+ invalid_properties.push('invalid value for "qos_manifest_envelope_b64", qos_manifest_envelope_b64 cannot be nil.')
138
+ end
139
+
140
+ if @deployment_label.nil?
141
+ invalid_properties.push('invalid value for "deployment_label", deployment_label cannot be nil.')
142
+ end
143
+
144
+ if @enclave_app.nil?
145
+ invalid_properties.push('invalid value for "enclave_app", enclave_app cannot be nil.')
146
+ end
147
+
148
+ if @owner.nil?
149
+ invalid_properties.push('invalid value for "owner", owner cannot be nil.')
150
+ end
151
+
152
+ if @created_at.nil?
153
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
154
+ end
155
+
156
+ invalid_properties
157
+ end
158
+
159
+ # Check to see if the all the properties in the model are valid
160
+ # @return true if the model is valid
161
+ def valid?
162
+ return false if @ephemeral_public_key_hex.nil?
163
+ return false if @aws_attestation_doc_b64.nil?
164
+ return false if @qos_manifest_b64.nil?
165
+ return false if @qos_manifest_envelope_b64.nil?
166
+ return false if @deployment_label.nil?
167
+ return false if @enclave_app.nil?
168
+ return false if @owner.nil?
169
+ return false if @created_at.nil?
170
+ true
171
+ end
172
+
173
+ # Checks equality by comparing each attribute.
174
+ # @param [Object] Object to be compared
175
+ def ==(o)
176
+ return true if self.equal?(o)
177
+ self.class == o.class &&
178
+ ephemeral_public_key_hex == o.ephemeral_public_key_hex &&
179
+ aws_attestation_doc_b64 == o.aws_attestation_doc_b64 &&
180
+ qos_manifest_b64 == o.qos_manifest_b64 &&
181
+ qos_manifest_envelope_b64 == o.qos_manifest_envelope_b64 &&
182
+ deployment_label == o.deployment_label &&
183
+ enclave_app == o.enclave_app &&
184
+ owner == o.owner &&
185
+ created_at == o.created_at
186
+ end
187
+
188
+ # @see the `==` method
189
+ # @param [Object] Object to be compared
190
+ def eql?(o)
191
+ self == o
192
+ end
193
+
194
+ # Calculates hash code according to all attributes.
195
+ # @return [Integer] Hash code
196
+ def hash
197
+ [ephemeral_public_key_hex, aws_attestation_doc_b64, qos_manifest_b64, qos_manifest_envelope_b64, deployment_label, enclave_app, owner, created_at].hash
198
+ end
199
+
200
+ # Builds the object from hash
201
+ # @param [Hash] attributes Model attributes in the form of hash
202
+ # @return [Object] Returns the model itself
203
+ def self.build_from_hash(attributes)
204
+ new.build_from_hash(attributes)
205
+ end
206
+
207
+ # Builds the object from hash
208
+ # @param [Hash] attributes Model attributes in the form of hash
209
+ # @return [Object] Returns the model itself
210
+ def build_from_hash(attributes)
211
+ return nil unless attributes.is_a?(Hash)
212
+ self.class.openapi_types.each_pair do |key, type|
213
+ if type =~ /\AArray<(.*)>/i
214
+ # check to ensure the input is an array given that the attribute
215
+ # is documented as an array but the input is not
216
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
217
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
218
+ end
219
+ elsif !attributes[self.class.attribute_map[key]].nil?
220
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
221
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
222
+ self.send("#{key}=", nil)
223
+ end
224
+ end
225
+
226
+ self
227
+ end
228
+
229
+ # Deserializes the data based on type
230
+ # @param string type Data type
231
+ # @param string value Value to be deserialized
232
+ # @return [Object] Deserialized data
233
+ def _deserialize(type, value)
234
+ case type.to_sym
235
+ when :DateTime
236
+ DateTime.parse(value)
237
+ when :Date
238
+ Date.parse(value)
239
+ when :String
240
+ value.to_s
241
+ when :Integer
242
+ value.to_i
243
+ when :Float
244
+ value.to_f
245
+ when :Boolean
246
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
247
+ true
248
+ else
249
+ false
250
+ end
251
+ when :Object
252
+ # generic object (usually a Hash), return directly
253
+ value
254
+ when /\AArray<(?<inner_type>.+)>\z/
255
+ inner_type = Regexp.last_match[:inner_type]
256
+ value.map { |v| _deserialize(inner_type, v) }
257
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
258
+ k_type = Regexp.last_match[:k_type]
259
+ v_type = Regexp.last_match[:v_type]
260
+ {}.tap do |hash|
261
+ value.each do |k, v|
262
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
263
+ end
264
+ end
265
+ else # model
266
+ TurnkeyClient.const_get(type).build_from_hash(value)
267
+ end
268
+ end
269
+
270
+ # Returns the string representation of the object
271
+ # @return [String] String presentation of the object
272
+ def to_s
273
+ to_hash.to_s
274
+ end
275
+
276
+ # to_body is an alias to to_hash (backward compatibility)
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_body
279
+ to_hash
280
+ end
281
+
282
+ # Returns the object in the form of hash
283
+ # @return [Hash] Returns the object in the form of hash
284
+ def to_hash
285
+ hash = {}
286
+ self.class.attribute_map.each_pair do |attr, param|
287
+ value = self.send(attr)
288
+ if value.nil?
289
+ is_nullable = self.class.openapi_nullable.include?(attr)
290
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
291
+ end
292
+
293
+ hash[param] = _to_hash(value)
294
+ end
295
+ hash
296
+ end
297
+
298
+ # Outputs non-array value in the form of hash
299
+ # For object, use to_hash. Otherwise, just return the value
300
+ # @param [Object] value Any valid value
301
+ # @return [Hash] Returns the value in the form of hash
302
+ def _to_hash(value)
303
+ if value.is_a?(Array)
304
+ value.compact.map { |v| _to_hash(v) }
305
+ elsif value.is_a?(Hash)
306
+ {}.tap do |hash|
307
+ value.each { |k, v| hash[k] = _to_hash(v) }
308
+ end
309
+ elsif value.respond_to? :to_hash
310
+ value.to_hash
311
+ else
312
+ value
313
+ end
314
+ end end
315
+ end