turnkey_client 0.0.4 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/lib/turnkey_client/api/organizations_api.rb +58 -0
  3. data/lib/turnkey_client/api/policies_api.rb +58 -0
  4. data/lib/turnkey_client/api/private_keys_api.rb +58 -0
  5. data/lib/turnkey_client/api/sessions_api.rb +116 -0
  6. data/lib/turnkey_client/api/signing_api.rb +58 -0
  7. data/lib/turnkey_client/api/users_api.rb +232 -0
  8. data/lib/turnkey_client/api/wallets_api.rb +58 -0
  9. data/lib/turnkey_client/models/activity.rb +13 -4
  10. data/lib/turnkey_client/models/activity_type.rb +13 -0
  11. data/lib/turnkey_client/models/any.rb +200 -0
  12. data/lib/turnkey_client/models/api_key_curve.rb +28 -0
  13. data/lib/turnkey_client/models/api_key_params_v2.rb +250 -0
  14. data/lib/turnkey_client/models/config.rb +216 -0
  15. data/lib/turnkey_client/models/create_api_keys_intent_v2.rb +228 -0
  16. data/lib/turnkey_client/models/create_api_keys_request.rb +2 -2
  17. data/lib/turnkey_client/models/create_oauth_providers_intent.rb +228 -0
  18. data/lib/turnkey_client/models/create_oauth_providers_request.rb +288 -0
  19. data/lib/turnkey_client/models/create_oauth_providers_result.rb +213 -0
  20. data/lib/turnkey_client/models/create_policies_intent.rb +213 -0
  21. data/lib/turnkey_client/models/create_policies_request.rb +288 -0
  22. data/lib/turnkey_client/models/create_policies_result.rb +213 -0
  23. data/lib/turnkey_client/models/create_read_only_session_intent.rb +196 -0
  24. data/lib/turnkey_client/models/create_read_only_session_request.rb +288 -0
  25. data/lib/turnkey_client/models/create_read_only_session_result.rb +286 -0
  26. data/lib/turnkey_client/models/create_read_write_session_intent.rb +246 -0
  27. data/lib/turnkey_client/models/create_read_write_session_request.rb +288 -0
  28. data/lib/turnkey_client/models/create_read_write_session_result.rb +286 -0
  29. data/lib/turnkey_client/models/create_sub_organization_intent_v5.rb +272 -0
  30. data/lib/turnkey_client/models/create_sub_organization_intent_v6.rb +272 -0
  31. data/lib/turnkey_client/models/create_sub_organization_request.rb +2 -2
  32. data/lib/turnkey_client/models/create_sub_organization_result_v5.rb +230 -0
  33. data/lib/turnkey_client/models/create_sub_organization_result_v6.rb +230 -0
  34. data/lib/turnkey_client/models/credential_type.rb +3 -0
  35. data/lib/turnkey_client/models/delete_oauth_providers_intent.rb +228 -0
  36. data/lib/turnkey_client/models/delete_oauth_providers_request.rb +288 -0
  37. data/lib/turnkey_client/models/delete_oauth_providers_result.rb +213 -0
  38. data/lib/turnkey_client/models/delete_private_keys_intent.rb +223 -0
  39. data/lib/turnkey_client/models/delete_private_keys_request.rb +288 -0
  40. data/lib/turnkey_client/models/delete_private_keys_result.rb +213 -0
  41. data/lib/turnkey_client/models/delete_wallets_intent.rb +223 -0
  42. data/lib/turnkey_client/models/delete_wallets_request.rb +288 -0
  43. data/lib/turnkey_client/models/delete_wallets_result.rb +213 -0
  44. data/lib/turnkey_client/models/email_auth_intent.rb +14 -4
  45. data/lib/turnkey_client/models/email_auth_intent_v2.rb +265 -0
  46. data/lib/turnkey_client/models/email_auth_request.rb +2 -2
  47. data/lib/turnkey_client/models/email_customization_params.rb +1 -1
  48. data/lib/turnkey_client/models/external_data_v1_quorum.rb +228 -0
  49. data/lib/turnkey_client/models/get_oauth_providers_request.rb +221 -0
  50. data/lib/turnkey_client/models/get_oauth_providers_response.rb +213 -0
  51. data/lib/turnkey_client/models/get_organization_configs_request.rb +211 -0
  52. data/lib/turnkey_client/models/get_organization_configs_response.rb +210 -0
  53. data/lib/turnkey_client/models/get_sub_org_ids_request.rb +1 -1
  54. data/lib/turnkey_client/models/intent.rb +121 -9
  55. data/lib/turnkey_client/models/oauth_intent.rb +246 -0
  56. data/lib/turnkey_client/models/oauth_provider.rb +299 -0
  57. data/lib/turnkey_client/models/oauth_provider_params.rb +226 -0
  58. data/lib/turnkey_client/models/oauth_request.rb +288 -0
  59. data/lib/turnkey_client/models/oauth_result.rb +241 -0
  60. data/lib/turnkey_client/models/result.rb +103 -4
  61. data/lib/turnkey_client/models/root_user_params_v2.rb +272 -0
  62. data/lib/turnkey_client/models/root_user_params_v3.rb +272 -0
  63. data/lib/turnkey_client/models/sign_raw_payloads_intent.rb +256 -0
  64. data/lib/turnkey_client/models/sign_raw_payloads_request.rb +288 -0
  65. data/lib/turnkey_client/models/sign_raw_payloads_result.rb +207 -0
  66. data/lib/turnkey_client/models/status.rb +225 -0
  67. data/lib/turnkey_client/models/user.rb +18 -1
  68. data/lib/turnkey_client/models/wallet_account.rb +4 -19
  69. data/lib/turnkey_client/version.rb +1 -1
  70. data/lib/turnkey_client.rb +47 -0
  71. data/turnkey_client-0.0.4.gem +0 -0
  72. data/turnkey_client-0.0.7.gem +0 -0
  73. metadata +51 -2
@@ -0,0 +1,286 @@
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 CreateReadWriteSessionResult
15
+ # Unique identifier for a given Organization. If the request is being made by a user and their Sub-Organization ID is unknown, this can be the Parent Organization ID. However, using the Sub-Organization ID is preferred due to performance reasons.
16
+ attr_accessor :organization_id
17
+
18
+ # Human-readable name for an Organization.
19
+ attr_accessor :organization_name
20
+
21
+ # Unique identifier for a given User.
22
+ attr_accessor :user_id
23
+
24
+ # Human-readable name for a User.
25
+ attr_accessor :username
26
+
27
+ # Unique identifier for the created API key.
28
+ attr_accessor :api_key_id
29
+
30
+ # HPKE encrypted credential bundle
31
+ attr_accessor :credential_bundle
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'organization_id' => :'organizationId',
37
+ :'organization_name' => :'organizationName',
38
+ :'user_id' => :'userId',
39
+ :'username' => :'username',
40
+ :'api_key_id' => :'apiKeyId',
41
+ :'credential_bundle' => :'credentialBundle'
42
+ }
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'organization_id' => :'Object',
49
+ :'organization_name' => :'Object',
50
+ :'user_id' => :'Object',
51
+ :'username' => :'Object',
52
+ :'api_key_id' => :'Object',
53
+ :'credential_bundle' => :'Object'
54
+ }
55
+ end
56
+
57
+ # List of attributes with nullable: true
58
+ def self.openapi_nullable
59
+ Set.new([
60
+ ])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TurnkeyClient::CreateReadWriteSessionResult` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!self.class.attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TurnkeyClient::CreateReadWriteSessionResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'organization_id')
79
+ self.organization_id = attributes[:'organization_id']
80
+ end
81
+
82
+ if attributes.key?(:'organization_name')
83
+ self.organization_name = attributes[:'organization_name']
84
+ end
85
+
86
+ if attributes.key?(:'user_id')
87
+ self.user_id = attributes[:'user_id']
88
+ end
89
+
90
+ if attributes.key?(:'username')
91
+ self.username = attributes[:'username']
92
+ end
93
+
94
+ if attributes.key?(:'api_key_id')
95
+ self.api_key_id = attributes[:'api_key_id']
96
+ end
97
+
98
+ if attributes.key?(:'credential_bundle')
99
+ self.credential_bundle = attributes[:'credential_bundle']
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ invalid_properties = Array.new
107
+ if @organization_id.nil?
108
+ invalid_properties.push('invalid value for "organization_id", organization_id cannot be nil.')
109
+ end
110
+
111
+ if @organization_name.nil?
112
+ invalid_properties.push('invalid value for "organization_name", organization_name cannot be nil.')
113
+ end
114
+
115
+ if @user_id.nil?
116
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
117
+ end
118
+
119
+ if @username.nil?
120
+ invalid_properties.push('invalid value for "username", username cannot be nil.')
121
+ end
122
+
123
+ if @api_key_id.nil?
124
+ invalid_properties.push('invalid value for "api_key_id", api_key_id cannot be nil.')
125
+ end
126
+
127
+ if @credential_bundle.nil?
128
+ invalid_properties.push('invalid value for "credential_bundle", credential_bundle cannot be nil.')
129
+ end
130
+
131
+ invalid_properties
132
+ end
133
+
134
+ # Check to see if the all the properties in the model are valid
135
+ # @return true if the model is valid
136
+ def valid?
137
+ return false if @organization_id.nil?
138
+ return false if @organization_name.nil?
139
+ return false if @user_id.nil?
140
+ return false if @username.nil?
141
+ return false if @api_key_id.nil?
142
+ return false if @credential_bundle.nil?
143
+ true
144
+ end
145
+
146
+ # Checks equality by comparing each attribute.
147
+ # @param [Object] Object to be compared
148
+ def ==(o)
149
+ return true if self.equal?(o)
150
+ self.class == o.class &&
151
+ organization_id == o.organization_id &&
152
+ organization_name == o.organization_name &&
153
+ user_id == o.user_id &&
154
+ username == o.username &&
155
+ api_key_id == o.api_key_id &&
156
+ credential_bundle == o.credential_bundle
157
+ end
158
+
159
+ # @see the `==` method
160
+ # @param [Object] Object to be compared
161
+ def eql?(o)
162
+ self == o
163
+ end
164
+
165
+ # Calculates hash code according to all attributes.
166
+ # @return [Integer] Hash code
167
+ def hash
168
+ [organization_id, organization_name, user_id, username, api_key_id, credential_bundle].hash
169
+ end
170
+
171
+ # Builds the object from hash
172
+ # @param [Hash] attributes Model attributes in the form of hash
173
+ # @return [Object] Returns the model itself
174
+ def self.build_from_hash(attributes)
175
+ new.build_from_hash(attributes)
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def build_from_hash(attributes)
182
+ return nil unless attributes.is_a?(Hash)
183
+ self.class.openapi_types.each_pair do |key, type|
184
+ if type =~ /\AArray<(.*)>/i
185
+ # check to ensure the input is an array given that the attribute
186
+ # is documented as an array but the input is not
187
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
188
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
189
+ end
190
+ elsif !attributes[self.class.attribute_map[key]].nil?
191
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
192
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
193
+ self.send("#{key}=", nil)
194
+ end
195
+ end
196
+
197
+ self
198
+ end
199
+
200
+ # Deserializes the data based on type
201
+ # @param string type Data type
202
+ # @param string value Value to be deserialized
203
+ # @return [Object] Deserialized data
204
+ def _deserialize(type, value)
205
+ case type.to_sym
206
+ when :DateTime
207
+ DateTime.parse(value)
208
+ when :Date
209
+ Date.parse(value)
210
+ when :String
211
+ value.to_s
212
+ when :Integer
213
+ value.to_i
214
+ when :Float
215
+ value.to_f
216
+ when :Boolean
217
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
218
+ true
219
+ else
220
+ false
221
+ end
222
+ when :Object
223
+ # generic object (usually a Hash), return directly
224
+ value
225
+ when /\AArray<(?<inner_type>.+)>\z/
226
+ inner_type = Regexp.last_match[:inner_type]
227
+ value.map { |v| _deserialize(inner_type, v) }
228
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
229
+ k_type = Regexp.last_match[:k_type]
230
+ v_type = Regexp.last_match[:v_type]
231
+ {}.tap do |hash|
232
+ value.each do |k, v|
233
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
234
+ end
235
+ end
236
+ else # model
237
+ TurnkeyClient.const_get(type).build_from_hash(value)
238
+ end
239
+ end
240
+
241
+ # Returns the string representation of the object
242
+ # @return [String] String presentation of the object
243
+ def to_s
244
+ to_hash.to_s
245
+ end
246
+
247
+ # to_body is an alias to to_hash (backward compatibility)
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_body
250
+ to_hash
251
+ end
252
+
253
+ # Returns the object in the form of hash
254
+ # @return [Hash] Returns the object in the form of hash
255
+ def to_hash
256
+ hash = {}
257
+ self.class.attribute_map.each_pair do |attr, param|
258
+ value = self.send(attr)
259
+ if value.nil?
260
+ is_nullable = self.class.openapi_nullable.include?(attr)
261
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
262
+ end
263
+
264
+ hash[param] = _to_hash(value)
265
+ end
266
+ hash
267
+ end
268
+
269
+ # Outputs non-array value in the form of hash
270
+ # For object, use to_hash. Otherwise, just return the value
271
+ # @param [Object] value Any valid value
272
+ # @return [Hash] Returns the value in the form of hash
273
+ def _to_hash(value)
274
+ if value.is_a?(Array)
275
+ value.compact.map { |v| _to_hash(v) }
276
+ elsif value.is_a?(Hash)
277
+ {}.tap do |hash|
278
+ value.each { |k, v| hash[k] = _to_hash(v) }
279
+ end
280
+ elsif value.respond_to? :to_hash
281
+ value.to_hash
282
+ else
283
+ value
284
+ end
285
+ end end
286
+ end
@@ -0,0 +1,272 @@
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 CreateSubOrganizationIntentV5
15
+ # Name for this sub-organization
16
+ attr_accessor :sub_organization_name
17
+
18
+ # Root users to create within this sub-organization
19
+ attr_accessor :root_users
20
+
21
+ # The threshold of unique approvals to reach root quorum. This value must be less than or equal to the number of root users
22
+ attr_accessor :root_quorum_threshold
23
+
24
+ attr_accessor :wallet
25
+
26
+ # Disable email recovery for the sub-organization
27
+ attr_accessor :disable_email_recovery
28
+
29
+ # Disable email auth for the sub-organization
30
+ attr_accessor :disable_email_auth
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'sub_organization_name' => :'subOrganizationName',
36
+ :'root_users' => :'rootUsers',
37
+ :'root_quorum_threshold' => :'rootQuorumThreshold',
38
+ :'wallet' => :'wallet',
39
+ :'disable_email_recovery' => :'disableEmailRecovery',
40
+ :'disable_email_auth' => :'disableEmailAuth'
41
+ }
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'sub_organization_name' => :'Object',
48
+ :'root_users' => :'Object',
49
+ :'root_quorum_threshold' => :'Object',
50
+ :'wallet' => :'Object',
51
+ :'disable_email_recovery' => :'Object',
52
+ :'disable_email_auth' => :'Object'
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 `TurnkeyClient::CreateSubOrganizationIntentV5` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TurnkeyClient::CreateSubOrganizationIntentV5`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'sub_organization_name')
78
+ self.sub_organization_name = attributes[:'sub_organization_name']
79
+ end
80
+
81
+ if attributes.key?(:'root_users')
82
+ if (value = attributes[:'root_users']).is_a?(Array)
83
+ self.root_users = value
84
+ end
85
+ end
86
+
87
+ if attributes.key?(:'root_quorum_threshold')
88
+ self.root_quorum_threshold = attributes[:'root_quorum_threshold']
89
+ end
90
+
91
+ if attributes.key?(:'wallet')
92
+ self.wallet = attributes[:'wallet']
93
+ end
94
+
95
+ if attributes.key?(:'disable_email_recovery')
96
+ self.disable_email_recovery = attributes[:'disable_email_recovery']
97
+ end
98
+
99
+ if attributes.key?(:'disable_email_auth')
100
+ self.disable_email_auth = attributes[:'disable_email_auth']
101
+ end
102
+ end
103
+
104
+ # Show invalid properties with the reasons. Usually used together with valid?
105
+ # @return Array for valid properties with the reasons
106
+ def list_invalid_properties
107
+ invalid_properties = Array.new
108
+ if @sub_organization_name.nil?
109
+ invalid_properties.push('invalid value for "sub_organization_name", sub_organization_name cannot be nil.')
110
+ end
111
+
112
+ if @root_users.nil?
113
+ invalid_properties.push('invalid value for "root_users", root_users cannot be nil.')
114
+ end
115
+
116
+ if @root_quorum_threshold.nil?
117
+ invalid_properties.push('invalid value for "root_quorum_threshold", root_quorum_threshold cannot be nil.')
118
+ end
119
+
120
+ invalid_properties
121
+ end
122
+
123
+ # Check to see if the all the properties in the model are valid
124
+ # @return true if the model is valid
125
+ def valid?
126
+ return false if @sub_organization_name.nil?
127
+ return false if @root_users.nil?
128
+ return false if @root_quorum_threshold.nil?
129
+ true
130
+ end
131
+
132
+ # Checks equality by comparing each attribute.
133
+ # @param [Object] Object to be compared
134
+ def ==(o)
135
+ return true if self.equal?(o)
136
+ self.class == o.class &&
137
+ sub_organization_name == o.sub_organization_name &&
138
+ root_users == o.root_users &&
139
+ root_quorum_threshold == o.root_quorum_threshold &&
140
+ wallet == o.wallet &&
141
+ disable_email_recovery == o.disable_email_recovery &&
142
+ disable_email_auth == o.disable_email_auth
143
+ end
144
+
145
+ # @see the `==` method
146
+ # @param [Object] Object to be compared
147
+ def eql?(o)
148
+ self == o
149
+ end
150
+
151
+ # Calculates hash code according to all attributes.
152
+ # @return [Integer] Hash code
153
+ def hash
154
+ [sub_organization_name, root_users, root_quorum_threshold, wallet, disable_email_recovery, disable_email_auth].hash
155
+ end
156
+
157
+ # Builds the object from hash
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ # @return [Object] Returns the model itself
160
+ def self.build_from_hash(attributes)
161
+ new.build_from_hash(attributes)
162
+ end
163
+
164
+ # Builds the object from hash
165
+ # @param [Hash] attributes Model attributes in the form of hash
166
+ # @return [Object] Returns the model itself
167
+ def build_from_hash(attributes)
168
+ return nil unless attributes.is_a?(Hash)
169
+ self.class.openapi_types.each_pair do |key, type|
170
+ if type =~ /\AArray<(.*)>/i
171
+ # check to ensure the input is an array given that the attribute
172
+ # is documented as an array but the input is not
173
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
174
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
175
+ end
176
+ elsif !attributes[self.class.attribute_map[key]].nil?
177
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
178
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
179
+ self.send("#{key}=", nil)
180
+ end
181
+ end
182
+
183
+ self
184
+ end
185
+
186
+ # Deserializes the data based on type
187
+ # @param string type Data type
188
+ # @param string value Value to be deserialized
189
+ # @return [Object] Deserialized data
190
+ def _deserialize(type, value)
191
+ case type.to_sym
192
+ when :DateTime
193
+ DateTime.parse(value)
194
+ when :Date
195
+ Date.parse(value)
196
+ when :String
197
+ value.to_s
198
+ when :Integer
199
+ value.to_i
200
+ when :Float
201
+ value.to_f
202
+ when :Boolean
203
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
204
+ true
205
+ else
206
+ false
207
+ end
208
+ when :Object
209
+ # generic object (usually a Hash), return directly
210
+ value
211
+ when /\AArray<(?<inner_type>.+)>\z/
212
+ inner_type = Regexp.last_match[:inner_type]
213
+ value.map { |v| _deserialize(inner_type, v) }
214
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
215
+ k_type = Regexp.last_match[:k_type]
216
+ v_type = Regexp.last_match[:v_type]
217
+ {}.tap do |hash|
218
+ value.each do |k, v|
219
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
220
+ end
221
+ end
222
+ else # model
223
+ TurnkeyClient.const_get(type).build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = self.send(attr)
245
+ if value.nil?
246
+ is_nullable = self.class.openapi_nullable.include?(attr)
247
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
248
+ end
249
+
250
+ hash[param] = _to_hash(value)
251
+ end
252
+ hash
253
+ end
254
+
255
+ # Outputs non-array value in the form of hash
256
+ # For object, use to_hash. Otherwise, just return the value
257
+ # @param [Object] value Any valid value
258
+ # @return [Hash] Returns the value in the form of hash
259
+ def _to_hash(value)
260
+ if value.is_a?(Array)
261
+ value.compact.map { |v| _to_hash(v) }
262
+ elsif value.is_a?(Hash)
263
+ {}.tap do |hash|
264
+ value.each { |k, v| hash[k] = _to_hash(v) }
265
+ end
266
+ elsif value.respond_to? :to_hash
267
+ value.to_hash
268
+ else
269
+ value
270
+ end
271
+ end end
272
+ end