turnkey_client 0.0.9 → 0.0.12

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/turnkey_client/api/features_api.rb +4 -4
  3. data/lib/turnkey_client/api/organizations_api.rb +60 -2
  4. data/lib/turnkey_client/api/user_auth_api.rb +348 -0
  5. data/lib/turnkey_client/api/users_api.rb +0 -232
  6. data/lib/turnkey_client/api/wallets_api.rb +58 -0
  7. data/lib/turnkey_client/models/activity_type.rb +4 -0
  8. data/lib/turnkey_client/models/address_format.rb +7 -0
  9. data/lib/turnkey_client/models/create_sub_organization_intent_v7.rb +292 -0
  10. data/lib/turnkey_client/models/create_sub_organization_request.rb +2 -2
  11. data/lib/turnkey_client/models/create_sub_organization_result_v7.rb +230 -0
  12. data/lib/turnkey_client/models/credential_type.rb +1 -0
  13. data/lib/turnkey_client/models/email_auth_intent.rb +14 -4
  14. data/lib/turnkey_client/models/email_auth_intent_v2.rb +14 -4
  15. data/lib/turnkey_client/models/feature_name.rb +2 -0
  16. data/lib/turnkey_client/models/get_sub_org_ids_request.rb +1 -1
  17. data/lib/turnkey_client/models/get_verified_sub_org_ids_request.rb +240 -0
  18. data/lib/turnkey_client/models/get_verified_sub_org_ids_response.rb +213 -0
  19. data/lib/turnkey_client/models/init_otp_auth_intent.rb +264 -0
  20. data/lib/turnkey_client/models/init_otp_auth_request.rb +288 -0
  21. data/lib/turnkey_client/models/init_otp_auth_result.rb +211 -0
  22. data/lib/turnkey_client/models/intent.rb +40 -4
  23. data/lib/turnkey_client/models/otp_auth_intent.rb +266 -0
  24. data/lib/turnkey_client/models/otp_auth_request.rb +288 -0
  25. data/lib/turnkey_client/models/otp_auth_result.rb +231 -0
  26. data/lib/turnkey_client/models/result.rb +40 -4
  27. data/lib/turnkey_client/models/root_user_params_v4.rb +282 -0
  28. data/lib/turnkey_client/models/sms_customization_params.rb +206 -0
  29. data/lib/turnkey_client/models/update_user_intent.rb +14 -4
  30. data/lib/turnkey_client/models/update_wallet_intent.rb +221 -0
  31. data/lib/turnkey_client/models/update_wallet_request.rb +288 -0
  32. data/lib/turnkey_client/models/update_wallet_result.rb +211 -0
  33. data/lib/turnkey_client/models/user.rb +11 -1
  34. data/lib/turnkey_client/models/wallet_account.rb +16 -1
  35. data/lib/turnkey_client/version.rb +1 -1
  36. data/lib/turnkey_client.rb +15 -0
  37. data/turnkey_client-0.0.9.gem +0 -0
  38. metadata +18 -2
@@ -0,0 +1,230 @@
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 CreateSubOrganizationResultV7
15
+ attr_accessor :sub_organization_id
16
+
17
+ attr_accessor :wallet
18
+
19
+ attr_accessor :root_user_ids
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'sub_organization_id' => :'subOrganizationId',
25
+ :'wallet' => :'wallet',
26
+ :'root_user_ids' => :'rootUserIds'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.openapi_types
32
+ {
33
+ :'sub_organization_id' => :'Object',
34
+ :'wallet' => :'Object',
35
+ :'root_user_ids' => :'Object'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TurnkeyClient::CreateSubOrganizationResultV7` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TurnkeyClient::CreateSubOrganizationResultV7`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'sub_organization_id')
61
+ self.sub_organization_id = attributes[:'sub_organization_id']
62
+ end
63
+
64
+ if attributes.key?(:'wallet')
65
+ self.wallet = attributes[:'wallet']
66
+ end
67
+
68
+ if attributes.key?(:'root_user_ids')
69
+ if (value = attributes[:'root_user_ids']).is_a?(Array)
70
+ self.root_user_ids = value
71
+ end
72
+ end
73
+ end
74
+
75
+ # Show invalid properties with the reasons. Usually used together with valid?
76
+ # @return Array for valid properties with the reasons
77
+ def list_invalid_properties
78
+ invalid_properties = Array.new
79
+ if @sub_organization_id.nil?
80
+ invalid_properties.push('invalid value for "sub_organization_id", sub_organization_id cannot be nil.')
81
+ end
82
+
83
+ invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ return false if @sub_organization_id.nil?
90
+ true
91
+ end
92
+
93
+ # Checks equality by comparing each attribute.
94
+ # @param [Object] Object to be compared
95
+ def ==(o)
96
+ return true if self.equal?(o)
97
+ self.class == o.class &&
98
+ sub_organization_id == o.sub_organization_id &&
99
+ wallet == o.wallet &&
100
+ root_user_ids == o.root_user_ids
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Integer] Hash code
111
+ def hash
112
+ [sub_organization_id, wallet, root_user_ids].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def self.build_from_hash(attributes)
119
+ new.build_from_hash(attributes)
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ self.class.openapi_types.each_pair do |key, type|
128
+ if type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
132
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
137
+ self.send("#{key}=", nil)
138
+ end
139
+ end
140
+
141
+ self
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def _deserialize(type, value)
149
+ case type.to_sym
150
+ when :DateTime
151
+ DateTime.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :Boolean
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ TurnkeyClient.const_get(type).build_from_hash(value)
182
+ end
183
+ end
184
+
185
+ # Returns the string representation of the object
186
+ # @return [String] String presentation of the object
187
+ def to_s
188
+ to_hash.to_s
189
+ end
190
+
191
+ # to_body is an alias to to_hash (backward compatibility)
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_body
194
+ to_hash
195
+ end
196
+
197
+ # Returns the object in the form of hash
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_hash
200
+ hash = {}
201
+ self.class.attribute_map.each_pair do |attr, param|
202
+ value = self.send(attr)
203
+ if value.nil?
204
+ is_nullable = self.class.openapi_nullable.include?(attr)
205
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
206
+ end
207
+
208
+ hash[param] = _to_hash(value)
209
+ end
210
+ hash
211
+ end
212
+
213
+ # Outputs non-array value in the form of hash
214
+ # For object, use to_hash. Otherwise, just return the value
215
+ # @param [Object] value Any valid value
216
+ # @return [Hash] Returns the value in the form of hash
217
+ def _to_hash(value)
218
+ if value.is_a?(Array)
219
+ value.compact.map { |v| _to_hash(v) }
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.each { |k, v| hash[k] = _to_hash(v) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash
226
+ else
227
+ value
228
+ end
229
+ end end
230
+ end
@@ -18,6 +18,7 @@ module TurnkeyClient
18
18
  API_KEY_SECP256_K1 = 'CREDENTIAL_TYPE_API_KEY_SECP256K1'.freeze
19
19
  EMAIL_AUTH_KEY_P256 = 'CREDENTIAL_TYPE_EMAIL_AUTH_KEY_P256'.freeze
20
20
  API_KEY_ED25519 = 'CREDENTIAL_TYPE_API_KEY_ED25519'.freeze
21
+ OTP_AUTH_KEY_P256 = 'CREDENTIAL_TYPE_OTP_AUTH_KEY_P256'.freeze
21
22
 
22
23
  # Builds the enum from string
23
24
  # @param [String] The enum value in the form of the string
@@ -29,6 +29,9 @@ module TurnkeyClient
29
29
  # Invalidate all other previously generated Email Auth API keys
30
30
  attr_accessor :invalidate_existing
31
31
 
32
+ # Optional custom email address from which to send the email
33
+ attr_accessor :send_from_email_address
34
+
32
35
  # Attribute mapping from ruby-style variable name to JSON key.
33
36
  def self.attribute_map
34
37
  {
@@ -37,7 +40,8 @@ module TurnkeyClient
37
40
  :'api_key_name' => :'apiKeyName',
38
41
  :'expiration_seconds' => :'expirationSeconds',
39
42
  :'email_customization' => :'emailCustomization',
40
- :'invalidate_existing' => :'invalidateExisting'
43
+ :'invalidate_existing' => :'invalidateExisting',
44
+ :'send_from_email_address' => :'sendFromEmailAddress'
41
45
  }
42
46
  end
43
47
 
@@ -49,7 +53,8 @@ module TurnkeyClient
49
53
  :'api_key_name' => :'Object',
50
54
  :'expiration_seconds' => :'Object',
51
55
  :'email_customization' => :'Object',
52
- :'invalidate_existing' => :'Object'
56
+ :'invalidate_existing' => :'Object',
57
+ :'send_from_email_address' => :'Object'
53
58
  }
54
59
  end
55
60
 
@@ -97,6 +102,10 @@ module TurnkeyClient
97
102
  if attributes.key?(:'invalidate_existing')
98
103
  self.invalidate_existing = attributes[:'invalidate_existing']
99
104
  end
105
+
106
+ if attributes.key?(:'send_from_email_address')
107
+ self.send_from_email_address = attributes[:'send_from_email_address']
108
+ end
100
109
  end
101
110
 
102
111
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -132,7 +141,8 @@ module TurnkeyClient
132
141
  api_key_name == o.api_key_name &&
133
142
  expiration_seconds == o.expiration_seconds &&
134
143
  email_customization == o.email_customization &&
135
- invalidate_existing == o.invalidate_existing
144
+ invalidate_existing == o.invalidate_existing &&
145
+ send_from_email_address == o.send_from_email_address
136
146
  end
137
147
 
138
148
  # @see the `==` method
@@ -144,7 +154,7 @@ module TurnkeyClient
144
154
  # Calculates hash code according to all attributes.
145
155
  # @return [Integer] Hash code
146
156
  def hash
147
- [email, target_public_key, api_key_name, expiration_seconds, email_customization, invalidate_existing].hash
157
+ [email, target_public_key, api_key_name, expiration_seconds, email_customization, invalidate_existing, send_from_email_address].hash
148
158
  end
149
159
 
150
160
  # Builds the object from hash
@@ -29,6 +29,9 @@ module TurnkeyClient
29
29
  # Invalidate all other previously generated Email Auth API keys
30
30
  attr_accessor :invalidate_existing
31
31
 
32
+ # Optional custom email address from which to send the email
33
+ attr_accessor :send_from_email_address
34
+
32
35
  # Attribute mapping from ruby-style variable name to JSON key.
33
36
  def self.attribute_map
34
37
  {
@@ -37,7 +40,8 @@ module TurnkeyClient
37
40
  :'api_key_name' => :'apiKeyName',
38
41
  :'expiration_seconds' => :'expirationSeconds',
39
42
  :'email_customization' => :'emailCustomization',
40
- :'invalidate_existing' => :'invalidateExisting'
43
+ :'invalidate_existing' => :'invalidateExisting',
44
+ :'send_from_email_address' => :'sendFromEmailAddress'
41
45
  }
42
46
  end
43
47
 
@@ -49,7 +53,8 @@ module TurnkeyClient
49
53
  :'api_key_name' => :'Object',
50
54
  :'expiration_seconds' => :'Object',
51
55
  :'email_customization' => :'Object',
52
- :'invalidate_existing' => :'Object'
56
+ :'invalidate_existing' => :'Object',
57
+ :'send_from_email_address' => :'Object'
53
58
  }
54
59
  end
55
60
 
@@ -97,6 +102,10 @@ module TurnkeyClient
97
102
  if attributes.key?(:'invalidate_existing')
98
103
  self.invalidate_existing = attributes[:'invalidate_existing']
99
104
  end
105
+
106
+ if attributes.key?(:'send_from_email_address')
107
+ self.send_from_email_address = attributes[:'send_from_email_address']
108
+ end
100
109
  end
101
110
 
102
111
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -132,7 +141,8 @@ module TurnkeyClient
132
141
  api_key_name == o.api_key_name &&
133
142
  expiration_seconds == o.expiration_seconds &&
134
143
  email_customization == o.email_customization &&
135
- invalidate_existing == o.invalidate_existing
144
+ invalidate_existing == o.invalidate_existing &&
145
+ send_from_email_address == o.send_from_email_address
136
146
  end
137
147
 
138
148
  # @see the `==` method
@@ -144,7 +154,7 @@ module TurnkeyClient
144
154
  # Calculates hash code according to all attributes.
145
155
  # @return [Integer] Hash code
146
156
  def hash
147
- [email, target_public_key, api_key_name, expiration_seconds, email_customization, invalidate_existing].hash
157
+ [email, target_public_key, api_key_name, expiration_seconds, email_customization, invalidate_existing, send_from_email_address].hash
148
158
  end
149
159
 
150
160
  # Builds the object from hash
@@ -17,6 +17,8 @@ module TurnkeyClient
17
17
  EMAIL_AUTH = 'FEATURE_NAME_EMAIL_AUTH'.freeze
18
18
  EMAIL_RECOVERY = 'FEATURE_NAME_EMAIL_RECOVERY'.freeze
19
19
  WEBHOOK = 'FEATURE_NAME_WEBHOOK'.freeze
20
+ SMS_AUTH = 'FEATURE_NAME_SMS_AUTH'.freeze
21
+ OTP_EMAIL_AUTH = 'FEATURE_NAME_OTP_EMAIL_AUTH'.freeze
20
22
 
21
23
  # Builds the enum from string
22
24
  # @param [String] The enum value in the form of the string
@@ -15,7 +15,7 @@ module TurnkeyClient
15
15
  # Unique identifier for the parent Organization. This is used to find sub-organizations within it.
16
16
  attr_accessor :organization_id
17
17
 
18
- # Specifies the type of filter to apply, i.e 'CREDENTIAL_ID', 'NAME', 'USERNAME', 'EMAIL', 'OIDC_TOKEN' or 'PUBLIC_KEY'
18
+ # Specifies the type of filter to apply, i.e 'CREDENTIAL_ID', 'NAME', 'USERNAME', 'EMAIL', 'PHONE_NUMBER', 'OIDC_TOKEN' or 'PUBLIC_KEY'
19
19
  attr_accessor :filter_type
20
20
 
21
21
  # The value of the filter to apply for the specified type. For example, a specific email or name string.
@@ -0,0 +1,240 @@
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 GetVerifiedSubOrgIdsRequest
15
+ # Unique identifier for the parent Organization. This is used to find sub-organizations within it.
16
+ attr_accessor :organization_id
17
+
18
+ # Specifies the type of filter to apply, i.e 'EMAIL', 'PHONE_NUMBER'
19
+ attr_accessor :filter_type
20
+
21
+ # The value of the filter to apply for the specified type. For example, a specific email or phone number string.
22
+ attr_accessor :filter_value
23
+
24
+ attr_accessor :pagination_options
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'organization_id' => :'organizationId',
30
+ :'filter_type' => :'filterType',
31
+ :'filter_value' => :'filterValue',
32
+ :'pagination_options' => :'paginationOptions'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'organization_id' => :'Object',
40
+ :'filter_type' => :'Object',
41
+ :'filter_value' => :'Object',
42
+ :'pagination_options' => :'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::GetVerifiedSubOrgIdsRequest` 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::GetVerifiedSubOrgIdsRequest`. 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?(:'organization_id')
68
+ self.organization_id = attributes[:'organization_id']
69
+ end
70
+
71
+ if attributes.key?(:'filter_type')
72
+ self.filter_type = attributes[:'filter_type']
73
+ end
74
+
75
+ if attributes.key?(:'filter_value')
76
+ self.filter_value = attributes[:'filter_value']
77
+ end
78
+
79
+ if attributes.key?(:'pagination_options')
80
+ self.pagination_options = attributes[:'pagination_options']
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 @organization_id.nil?
89
+ invalid_properties.push('invalid value for "organization_id", organization_id cannot be nil.')
90
+ end
91
+
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ return false if @organization_id.nil?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ organization_id == o.organization_id &&
108
+ filter_type == o.filter_type &&
109
+ filter_value == o.filter_value &&
110
+ pagination_options == o.pagination_options
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [organization_id, filter_type, filter_value, pagination_options].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ self.class.openapi_types.each_pair do |key, type|
138
+ if type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
147
+ self.send("#{key}=", nil)
148
+ end
149
+ end
150
+
151
+ self
152
+ end
153
+
154
+ # Deserializes the data based on type
155
+ # @param string type Data type
156
+ # @param string value Value to be deserialized
157
+ # @return [Object] Deserialized data
158
+ def _deserialize(type, value)
159
+ case type.to_sym
160
+ when :DateTime
161
+ DateTime.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :Boolean
171
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ else # model
191
+ TurnkeyClient.const_get(type).build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
218
+ hash[param] = _to_hash(value)
219
+ end
220
+ hash
221
+ end
222
+
223
+ # Outputs non-array value in the form of hash
224
+ # For object, use to_hash. Otherwise, just return the value
225
+ # @param [Object] value Any valid value
226
+ # @return [Hash] Returns the value in the form of hash
227
+ def _to_hash(value)
228
+ if value.is_a?(Array)
229
+ value.compact.map { |v| _to_hash(v) }
230
+ elsif value.is_a?(Hash)
231
+ {}.tap do |hash|
232
+ value.each { |k, v| hash[k] = _to_hash(v) }
233
+ end
234
+ elsif value.respond_to? :to_hash
235
+ value.to_hash
236
+ else
237
+ value
238
+ end
239
+ end end
240
+ end