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,288 @@
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 CreateReadOnlySessionRequest
15
+ attr_accessor :type
16
+
17
+ # Timestamp (in milliseconds) of the request, used to verify liveness of user requests.
18
+ attr_accessor :timestamp_ms
19
+
20
+ # Unique identifier for a given Organization.
21
+ attr_accessor :organization_id
22
+
23
+ attr_accessor :parameters
24
+
25
+ class EnumAttributeValidator
26
+ attr_reader :datatype
27
+ attr_reader :allowable_values
28
+
29
+ def initialize(datatype, allowable_values)
30
+ @allowable_values = allowable_values.map do |value|
31
+ case datatype.to_s
32
+ when /Integer/i
33
+ value.to_i
34
+ when /Float/i
35
+ value.to_f
36
+ else
37
+ value
38
+ end
39
+ end
40
+ end
41
+
42
+ def valid?(value)
43
+ !value || allowable_values.include?(value)
44
+ end
45
+ end
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'type' => :'type',
51
+ :'timestamp_ms' => :'timestampMs',
52
+ :'organization_id' => :'organizationId',
53
+ :'parameters' => :'parameters'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'type' => :'Object',
61
+ :'timestamp_ms' => :'Object',
62
+ :'organization_id' => :'Object',
63
+ :'parameters' => :'Object'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TurnkeyClient::CreateReadOnlySessionRequest` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TurnkeyClient::CreateReadOnlySessionRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'type')
89
+ self.type = attributes[:'type']
90
+ end
91
+
92
+ if attributes.key?(:'timestamp_ms')
93
+ self.timestamp_ms = attributes[:'timestamp_ms']
94
+ end
95
+
96
+ if attributes.key?(:'organization_id')
97
+ self.organization_id = attributes[:'organization_id']
98
+ end
99
+
100
+ if attributes.key?(:'parameters')
101
+ self.parameters = attributes[:'parameters']
102
+ end
103
+ end
104
+
105
+ # Show invalid properties with the reasons. Usually used together with valid?
106
+ # @return Array for valid properties with the reasons
107
+ def list_invalid_properties
108
+ invalid_properties = Array.new
109
+ if @type.nil?
110
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
111
+ end
112
+
113
+ if @timestamp_ms.nil?
114
+ invalid_properties.push('invalid value for "timestamp_ms", timestamp_ms cannot be nil.')
115
+ end
116
+
117
+ if @organization_id.nil?
118
+ invalid_properties.push('invalid value for "organization_id", organization_id cannot be nil.')
119
+ end
120
+
121
+ if @parameters.nil?
122
+ invalid_properties.push('invalid value for "parameters", parameters cannot be nil.')
123
+ end
124
+
125
+ invalid_properties
126
+ end
127
+
128
+ # Check to see if the all the properties in the model are valid
129
+ # @return true if the model is valid
130
+ def valid?
131
+ return false if @type.nil?
132
+ type_validator = EnumAttributeValidator.new('Object', ['ACTIVITY_TYPE_CREATE_READ_ONLY_SESSION'])
133
+ return false unless type_validator.valid?(@type)
134
+ return false if @timestamp_ms.nil?
135
+ return false if @organization_id.nil?
136
+ return false if @parameters.nil?
137
+ true
138
+ end
139
+
140
+ # Custom attribute writer method checking allowed values (enum).
141
+ # @param [Object] type Object to be assigned
142
+ def type=(type)
143
+ validator = EnumAttributeValidator.new('Object', ['ACTIVITY_TYPE_CREATE_READ_ONLY_SESSION'])
144
+ unless validator.valid?(type)
145
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
146
+ end
147
+ @type = type
148
+ end
149
+
150
+ # Checks equality by comparing each attribute.
151
+ # @param [Object] Object to be compared
152
+ def ==(o)
153
+ return true if self.equal?(o)
154
+ self.class == o.class &&
155
+ type == o.type &&
156
+ timestamp_ms == o.timestamp_ms &&
157
+ organization_id == o.organization_id &&
158
+ parameters == o.parameters
159
+ end
160
+
161
+ # @see the `==` method
162
+ # @param [Object] Object to be compared
163
+ def eql?(o)
164
+ self == o
165
+ end
166
+
167
+ # Calculates hash code according to all attributes.
168
+ # @return [Integer] Hash code
169
+ def hash
170
+ [type, timestamp_ms, organization_id, parameters].hash
171
+ end
172
+
173
+ # Builds the object from hash
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ # @return [Object] Returns the model itself
176
+ def self.build_from_hash(attributes)
177
+ new.build_from_hash(attributes)
178
+ end
179
+
180
+ # Builds the object from hash
181
+ # @param [Hash] attributes Model attributes in the form of hash
182
+ # @return [Object] Returns the model itself
183
+ def build_from_hash(attributes)
184
+ return nil unless attributes.is_a?(Hash)
185
+ self.class.openapi_types.each_pair do |key, type|
186
+ if type =~ /\AArray<(.*)>/i
187
+ # check to ensure the input is an array given that the attribute
188
+ # is documented as an array but the input is not
189
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
190
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
191
+ end
192
+ elsif !attributes[self.class.attribute_map[key]].nil?
193
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
194
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
195
+ self.send("#{key}=", nil)
196
+ end
197
+ end
198
+
199
+ self
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 _deserialize(type, value)
207
+ case type.to_sym
208
+ when :DateTime
209
+ DateTime.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
+ TurnkeyClient.const_get(type).build_from_hash(value)
240
+ end
241
+ end
242
+
243
+ # Returns the string representation of the object
244
+ # @return [String] String presentation of the object
245
+ def to_s
246
+ to_hash.to_s
247
+ end
248
+
249
+ # to_body is an alias to to_hash (backward compatibility)
250
+ # @return [Hash] Returns the object in the form of hash
251
+ def to_body
252
+ to_hash
253
+ end
254
+
255
+ # Returns the object in the form of hash
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_hash
258
+ hash = {}
259
+ self.class.attribute_map.each_pair do |attr, param|
260
+ value = self.send(attr)
261
+ if value.nil?
262
+ is_nullable = self.class.openapi_nullable.include?(attr)
263
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
264
+ end
265
+
266
+ hash[param] = _to_hash(value)
267
+ end
268
+ hash
269
+ end
270
+
271
+ # Outputs non-array value in the form of hash
272
+ # For object, use to_hash. Otherwise, just return the value
273
+ # @param [Object] value Any valid value
274
+ # @return [Hash] Returns the value in the form of hash
275
+ def _to_hash(value)
276
+ if value.is_a?(Array)
277
+ value.compact.map { |v| _to_hash(v) }
278
+ elsif value.is_a?(Hash)
279
+ {}.tap do |hash|
280
+ value.each { |k, v| hash[k] = _to_hash(v) }
281
+ end
282
+ elsif value.respond_to? :to_hash
283
+ value.to_hash
284
+ else
285
+ value
286
+ end
287
+ end end
288
+ end
@@ -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 CreateReadOnlySessionResult
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
+ # String representing a read only session
28
+ attr_accessor :session
29
+
30
+ # UTC timestamp in seconds representing the expiry time for the read only session.
31
+ attr_accessor :session_expiry
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
+ :'session' => :'session',
41
+ :'session_expiry' => :'sessionExpiry'
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
+ :'session' => :'Object',
53
+ :'session_expiry' => :'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::CreateReadOnlySessionResult` 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::CreateReadOnlySessionResult`. 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?(:'session')
95
+ self.session = attributes[:'session']
96
+ end
97
+
98
+ if attributes.key?(:'session_expiry')
99
+ self.session_expiry = attributes[:'session_expiry']
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 @session.nil?
124
+ invalid_properties.push('invalid value for "session", session cannot be nil.')
125
+ end
126
+
127
+ if @session_expiry.nil?
128
+ invalid_properties.push('invalid value for "session_expiry", session_expiry 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 @session.nil?
142
+ return false if @session_expiry.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
+ session == o.session &&
156
+ session_expiry == o.session_expiry
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, session, session_expiry].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