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