zyphr 0.1.34 → 0.1.35

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 (25) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -13
  3. data/docs/AuthEmailOTPApi.md +384 -0
  4. data/docs/CheckEmailOtpAvailability200Response.md +18 -0
  5. data/docs/{PhoneAuthAvailabilityResponseData.md → CheckEmailOtpAvailability200ResponseData.md} +2 -2
  6. data/docs/PhoneAuthAvailabilityResponse.md +1 -1
  7. data/docs/SendEmailOtpRegistrationRequest.md +18 -0
  8. data/docs/VerifyEmailOtpLoginRequest.md +22 -0
  9. data/docs/VerifyEmailOtpRegistrationRequest.md +24 -0
  10. data/lib/zyphr/api/auth_email_otp_api.rb +351 -0
  11. data/lib/zyphr/models/check_email_otp_availability200_response.rb +220 -0
  12. data/lib/zyphr/models/{phone_auth_availability_response_data.rb → check_email_otp_availability200_response_data.rb} +3 -3
  13. data/lib/zyphr/models/phone_auth_availability_response.rb +1 -1
  14. data/lib/zyphr/models/send_email_otp_registration_request.rb +237 -0
  15. data/lib/zyphr/models/verify_email_otp_login_request.rb +272 -0
  16. data/lib/zyphr/models/verify_email_otp_registration_request.rb +281 -0
  17. data/lib/zyphr.rb +6 -1
  18. data/spec/api/auth_email_otp_api_spec.rb +94 -0
  19. data/spec/models/{phone_auth_availability_response_data_spec.rb → check_email_otp_availability200_response_data_spec.rb} +6 -6
  20. data/spec/models/check_email_otp_availability200_response_spec.rb +36 -0
  21. data/spec/models/send_email_otp_registration_request_spec.rb +36 -0
  22. data/spec/models/verify_email_otp_login_request_spec.rb +48 -0
  23. data/spec/models/verify_email_otp_registration_request_spec.rb +54 -0
  24. data/zyphr.gemspec +1 -1
  25. metadata +441 -421
@@ -0,0 +1,351 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module Zyphr
16
+ class AuthEmailOTPApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Check email OTP availability
23
+ # Check if numeric email OTP authentication is available for this application. Requires a verified sending domain on the project.
24
+ # @param [Hash] opts the optional parameters
25
+ # @return [CheckEmailOtpAvailability200Response]
26
+ def check_email_otp_availability(opts = {})
27
+ data, _status_code, _headers = check_email_otp_availability_with_http_info(opts)
28
+ data
29
+ end
30
+
31
+ # Check email OTP availability
32
+ # Check if numeric email OTP authentication is available for this application. Requires a verified sending domain on the project.
33
+ # @param [Hash] opts the optional parameters
34
+ # @return [Array<(CheckEmailOtpAvailability200Response, Integer, Hash)>] CheckEmailOtpAvailability200Response data, response status code and response headers
35
+ def check_email_otp_availability_with_http_info(opts = {})
36
+ if @api_client.config.debugging
37
+ @api_client.config.logger.debug 'Calling API: AuthEmailOTPApi.check_email_otp_availability ...'
38
+ end
39
+ # resource path
40
+ local_var_path = '/auth/email-otp/available'
41
+
42
+ # query parameters
43
+ query_params = opts[:query_params] || {}
44
+
45
+ # header parameters
46
+ header_params = opts[:header_params] || {}
47
+ # HTTP header 'Accept' (if needed)
48
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
49
+
50
+ # form parameters
51
+ form_params = opts[:form_params] || {}
52
+
53
+ # http body (model)
54
+ post_body = opts[:debug_body]
55
+
56
+ # return_type
57
+ return_type = opts[:debug_return_type] || 'CheckEmailOtpAvailability200Response'
58
+
59
+ # auth_names
60
+ auth_names = opts[:debug_auth_names] || ['ApplicationPublicKey']
61
+
62
+ new_options = opts.merge(
63
+ :operation => :"AuthEmailOTPApi.check_email_otp_availability",
64
+ :header_params => header_params,
65
+ :query_params => query_params,
66
+ :form_params => form_params,
67
+ :body => post_body,
68
+ :auth_names => auth_names,
69
+ :return_type => return_type
70
+ )
71
+
72
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
73
+ if @api_client.config.debugging
74
+ @api_client.config.logger.debug "API called: AuthEmailOTPApi#check_email_otp_availability\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
75
+ end
76
+ return data, status_code, headers
77
+ end
78
+
79
+ # Send email OTP for login
80
+ # Send a numeric verification code to an existing user's email address for login.
81
+ # @param send_email_otp_registration_request [SendEmailOtpRegistrationRequest]
82
+ # @param [Hash] opts the optional parameters
83
+ # @return [PhoneOtpSentResponse]
84
+ def send_email_otp_login(send_email_otp_registration_request, opts = {})
85
+ data, _status_code, _headers = send_email_otp_login_with_http_info(send_email_otp_registration_request, opts)
86
+ data
87
+ end
88
+
89
+ # Send email OTP for login
90
+ # Send a numeric verification code to an existing user&#39;s email address for login.
91
+ # @param send_email_otp_registration_request [SendEmailOtpRegistrationRequest]
92
+ # @param [Hash] opts the optional parameters
93
+ # @return [Array<(PhoneOtpSentResponse, Integer, Hash)>] PhoneOtpSentResponse data, response status code and response headers
94
+ def send_email_otp_login_with_http_info(send_email_otp_registration_request, opts = {})
95
+ if @api_client.config.debugging
96
+ @api_client.config.logger.debug 'Calling API: AuthEmailOTPApi.send_email_otp_login ...'
97
+ end
98
+ # verify the required parameter 'send_email_otp_registration_request' is set
99
+ if @api_client.config.client_side_validation && send_email_otp_registration_request.nil?
100
+ fail ArgumentError, "Missing the required parameter 'send_email_otp_registration_request' when calling AuthEmailOTPApi.send_email_otp_login"
101
+ end
102
+ # resource path
103
+ local_var_path = '/auth/email-otp/login/send'
104
+
105
+ # query parameters
106
+ query_params = opts[:query_params] || {}
107
+
108
+ # header parameters
109
+ header_params = opts[:header_params] || {}
110
+ # HTTP header 'Accept' (if needed)
111
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
112
+ # HTTP header 'Content-Type'
113
+ content_type = @api_client.select_header_content_type(['application/json'])
114
+ if !content_type.nil?
115
+ header_params['Content-Type'] = content_type
116
+ end
117
+
118
+ # form parameters
119
+ form_params = opts[:form_params] || {}
120
+
121
+ # http body (model)
122
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(send_email_otp_registration_request)
123
+
124
+ # return_type
125
+ return_type = opts[:debug_return_type] || 'PhoneOtpSentResponse'
126
+
127
+ # auth_names
128
+ auth_names = opts[:debug_auth_names] || ['ApplicationSecret', 'ApplicationPublicKey']
129
+
130
+ new_options = opts.merge(
131
+ :operation => :"AuthEmailOTPApi.send_email_otp_login",
132
+ :header_params => header_params,
133
+ :query_params => query_params,
134
+ :form_params => form_params,
135
+ :body => post_body,
136
+ :auth_names => auth_names,
137
+ :return_type => return_type
138
+ )
139
+
140
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
141
+ if @api_client.config.debugging
142
+ @api_client.config.logger.debug "API called: AuthEmailOTPApi#send_email_otp_login\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
143
+ end
144
+ return data, status_code, headers
145
+ end
146
+
147
+ # Send email OTP for registration
148
+ # Send a numeric verification code to an email address for new user registration.
149
+ # @param send_email_otp_registration_request [SendEmailOtpRegistrationRequest]
150
+ # @param [Hash] opts the optional parameters
151
+ # @return [PhoneOtpSentResponse]
152
+ def send_email_otp_registration(send_email_otp_registration_request, opts = {})
153
+ data, _status_code, _headers = send_email_otp_registration_with_http_info(send_email_otp_registration_request, opts)
154
+ data
155
+ end
156
+
157
+ # Send email OTP for registration
158
+ # Send a numeric verification code to an email address for new user registration.
159
+ # @param send_email_otp_registration_request [SendEmailOtpRegistrationRequest]
160
+ # @param [Hash] opts the optional parameters
161
+ # @return [Array<(PhoneOtpSentResponse, Integer, Hash)>] PhoneOtpSentResponse data, response status code and response headers
162
+ def send_email_otp_registration_with_http_info(send_email_otp_registration_request, opts = {})
163
+ if @api_client.config.debugging
164
+ @api_client.config.logger.debug 'Calling API: AuthEmailOTPApi.send_email_otp_registration ...'
165
+ end
166
+ # verify the required parameter 'send_email_otp_registration_request' is set
167
+ if @api_client.config.client_side_validation && send_email_otp_registration_request.nil?
168
+ fail ArgumentError, "Missing the required parameter 'send_email_otp_registration_request' when calling AuthEmailOTPApi.send_email_otp_registration"
169
+ end
170
+ # resource path
171
+ local_var_path = '/auth/email-otp/register/send'
172
+
173
+ # query parameters
174
+ query_params = opts[:query_params] || {}
175
+
176
+ # header parameters
177
+ header_params = opts[:header_params] || {}
178
+ # HTTP header 'Accept' (if needed)
179
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
180
+ # HTTP header 'Content-Type'
181
+ content_type = @api_client.select_header_content_type(['application/json'])
182
+ if !content_type.nil?
183
+ header_params['Content-Type'] = content_type
184
+ end
185
+
186
+ # form parameters
187
+ form_params = opts[:form_params] || {}
188
+
189
+ # http body (model)
190
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(send_email_otp_registration_request)
191
+
192
+ # return_type
193
+ return_type = opts[:debug_return_type] || 'PhoneOtpSentResponse'
194
+
195
+ # auth_names
196
+ auth_names = opts[:debug_auth_names] || ['ApplicationSecret', 'ApplicationPublicKey']
197
+
198
+ new_options = opts.merge(
199
+ :operation => :"AuthEmailOTPApi.send_email_otp_registration",
200
+ :header_params => header_params,
201
+ :query_params => query_params,
202
+ :form_params => form_params,
203
+ :body => post_body,
204
+ :auth_names => auth_names,
205
+ :return_type => return_type
206
+ )
207
+
208
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
209
+ if @api_client.config.debugging
210
+ @api_client.config.logger.debug "API called: AuthEmailOTPApi#send_email_otp_registration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
211
+ end
212
+ return data, status_code, headers
213
+ end
214
+
215
+ # Verify email OTP login
216
+ # Verify the numeric code and login an existing user. If MFA is enabled, returns mfa_required with a challenge token.
217
+ # @param verify_email_otp_login_request [VerifyEmailOtpLoginRequest]
218
+ # @param [Hash] opts the optional parameters
219
+ # @return [AuthLoginResponse]
220
+ def verify_email_otp_login(verify_email_otp_login_request, opts = {})
221
+ data, _status_code, _headers = verify_email_otp_login_with_http_info(verify_email_otp_login_request, opts)
222
+ data
223
+ end
224
+
225
+ # Verify email OTP login
226
+ # Verify the numeric code and login an existing user. If MFA is enabled, returns mfa_required with a challenge token.
227
+ # @param verify_email_otp_login_request [VerifyEmailOtpLoginRequest]
228
+ # @param [Hash] opts the optional parameters
229
+ # @return [Array<(AuthLoginResponse, Integer, Hash)>] AuthLoginResponse data, response status code and response headers
230
+ def verify_email_otp_login_with_http_info(verify_email_otp_login_request, opts = {})
231
+ if @api_client.config.debugging
232
+ @api_client.config.logger.debug 'Calling API: AuthEmailOTPApi.verify_email_otp_login ...'
233
+ end
234
+ # verify the required parameter 'verify_email_otp_login_request' is set
235
+ if @api_client.config.client_side_validation && verify_email_otp_login_request.nil?
236
+ fail ArgumentError, "Missing the required parameter 'verify_email_otp_login_request' when calling AuthEmailOTPApi.verify_email_otp_login"
237
+ end
238
+ # resource path
239
+ local_var_path = '/auth/email-otp/login/verify'
240
+
241
+ # query parameters
242
+ query_params = opts[:query_params] || {}
243
+
244
+ # header parameters
245
+ header_params = opts[:header_params] || {}
246
+ # HTTP header 'Accept' (if needed)
247
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
248
+ # HTTP header 'Content-Type'
249
+ content_type = @api_client.select_header_content_type(['application/json'])
250
+ if !content_type.nil?
251
+ header_params['Content-Type'] = content_type
252
+ end
253
+
254
+ # form parameters
255
+ form_params = opts[:form_params] || {}
256
+
257
+ # http body (model)
258
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(verify_email_otp_login_request)
259
+
260
+ # return_type
261
+ return_type = opts[:debug_return_type] || 'AuthLoginResponse'
262
+
263
+ # auth_names
264
+ auth_names = opts[:debug_auth_names] || ['ApplicationSecret', 'ApplicationPublicKey']
265
+
266
+ new_options = opts.merge(
267
+ :operation => :"AuthEmailOTPApi.verify_email_otp_login",
268
+ :header_params => header_params,
269
+ :query_params => query_params,
270
+ :form_params => form_params,
271
+ :body => post_body,
272
+ :auth_names => auth_names,
273
+ :return_type => return_type
274
+ )
275
+
276
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
277
+ if @api_client.config.debugging
278
+ @api_client.config.logger.debug "API called: AuthEmailOTPApi#verify_email_otp_login\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
279
+ end
280
+ return data, status_code, headers
281
+ end
282
+
283
+ # Verify email OTP registration
284
+ # Verify the numeric code and create a new user account with the email address.
285
+ # @param verify_email_otp_registration_request [VerifyEmailOtpRegistrationRequest]
286
+ # @param [Hash] opts the optional parameters
287
+ # @return [AuthResultResponse]
288
+ def verify_email_otp_registration(verify_email_otp_registration_request, opts = {})
289
+ data, _status_code, _headers = verify_email_otp_registration_with_http_info(verify_email_otp_registration_request, opts)
290
+ data
291
+ end
292
+
293
+ # Verify email OTP registration
294
+ # Verify the numeric code and create a new user account with the email address.
295
+ # @param verify_email_otp_registration_request [VerifyEmailOtpRegistrationRequest]
296
+ # @param [Hash] opts the optional parameters
297
+ # @return [Array<(AuthResultResponse, Integer, Hash)>] AuthResultResponse data, response status code and response headers
298
+ def verify_email_otp_registration_with_http_info(verify_email_otp_registration_request, opts = {})
299
+ if @api_client.config.debugging
300
+ @api_client.config.logger.debug 'Calling API: AuthEmailOTPApi.verify_email_otp_registration ...'
301
+ end
302
+ # verify the required parameter 'verify_email_otp_registration_request' is set
303
+ if @api_client.config.client_side_validation && verify_email_otp_registration_request.nil?
304
+ fail ArgumentError, "Missing the required parameter 'verify_email_otp_registration_request' when calling AuthEmailOTPApi.verify_email_otp_registration"
305
+ end
306
+ # resource path
307
+ local_var_path = '/auth/email-otp/register/verify'
308
+
309
+ # query parameters
310
+ query_params = opts[:query_params] || {}
311
+
312
+ # header parameters
313
+ header_params = opts[:header_params] || {}
314
+ # HTTP header 'Accept' (if needed)
315
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
316
+ # HTTP header 'Content-Type'
317
+ content_type = @api_client.select_header_content_type(['application/json'])
318
+ if !content_type.nil?
319
+ header_params['Content-Type'] = content_type
320
+ end
321
+
322
+ # form parameters
323
+ form_params = opts[:form_params] || {}
324
+
325
+ # http body (model)
326
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(verify_email_otp_registration_request)
327
+
328
+ # return_type
329
+ return_type = opts[:debug_return_type] || 'AuthResultResponse'
330
+
331
+ # auth_names
332
+ auth_names = opts[:debug_auth_names] || ['ApplicationSecret', 'ApplicationPublicKey']
333
+
334
+ new_options = opts.merge(
335
+ :operation => :"AuthEmailOTPApi.verify_email_otp_registration",
336
+ :header_params => header_params,
337
+ :query_params => query_params,
338
+ :form_params => form_params,
339
+ :body => post_body,
340
+ :auth_names => auth_names,
341
+ :return_type => return_type
342
+ )
343
+
344
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
345
+ if @api_client.config.debugging
346
+ @api_client.config.logger.debug "API called: AuthEmailOTPApi#verify_email_otp_registration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
347
+ end
348
+ return data, status_code, headers
349
+ end
350
+ end
351
+ end
@@ -0,0 +1,220 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class CheckEmailOtpAvailability200Response
18
+ attr_accessor :data
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'data' => :'data'
24
+ }
25
+ end
26
+
27
+ # Returns attribute mapping this model knows about
28
+ def self.acceptable_attribute_map
29
+ attribute_map
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ acceptable_attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'data' => :'CheckEmailOtpAvailability200ResponseData'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::CheckEmailOtpAvailability200Response` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ acceptable_attribute_map = self.class.acceptable_attribute_map
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!acceptable_attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::CheckEmailOtpAvailability200Response`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'data')
67
+ self.data = attributes[:'data']
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
75
+ invalid_properties = Array.new
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ warn '[DEPRECATED] the `valid?` method is obsolete'
83
+ true
84
+ end
85
+
86
+ # Checks equality by comparing each attribute.
87
+ # @param [Object] Object to be compared
88
+ def ==(o)
89
+ return true if self.equal?(o)
90
+ self.class == o.class &&
91
+ data == o.data
92
+ end
93
+
94
+ # @see the `==` method
95
+ # @param [Object] Object to be compared
96
+ def eql?(o)
97
+ self == o
98
+ end
99
+
100
+ # Calculates hash code according to all attributes.
101
+ # @return [Integer] Hash code
102
+ def hash
103
+ [data].hash
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def self.build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ attributes = attributes.transform_keys(&:to_sym)
112
+ transformed_hash = {}
113
+ openapi_types.each_pair do |key, type|
114
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
115
+ transformed_hash["#{key}"] = nil
116
+ elsif type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[attribute_map[key]].is_a?(Array)
120
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
121
+ end
122
+ elsif !attributes[attribute_map[key]].nil?
123
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
124
+ end
125
+ end
126
+ new(transformed_hash)
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def self._deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ # models (e.g. Pet) or oneOf
167
+ klass = Zyphr.const_get(type)
168
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Zyphr
17
- class PhoneAuthAvailabilityResponseData
17
+ class CheckEmailOtpAvailability200ResponseData
18
18
  attr_accessor :available
19
19
 
20
20
  attr_accessor :message
@@ -55,14 +55,14 @@ module Zyphr
55
55
  # @param [Hash] attributes Model attributes in the form of hash
56
56
  def initialize(attributes = {})
57
57
  if (!attributes.is_a?(Hash))
58
- fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::PhoneAuthAvailabilityResponseData` initialize method"
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::CheckEmailOtpAvailability200ResponseData` initialize method"
59
59
  end
60
60
 
61
61
  # check to see if the attribute exists and convert string to symbol for hash key
62
62
  acceptable_attribute_map = self.class.acceptable_attribute_map
63
63
  attributes = attributes.each_with_object({}) { |(k, v), h|
64
64
  if (!acceptable_attribute_map.key?(k.to_sym))
65
- fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::PhoneAuthAvailabilityResponseData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::CheckEmailOtpAvailability200ResponseData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
66
66
  end
67
67
  h[k.to_sym] = v
68
68
  }
@@ -40,7 +40,7 @@ module Zyphr
40
40
  # Attribute type mapping.
41
41
  def self.openapi_types
42
42
  {
43
- :'data' => :'PhoneAuthAvailabilityResponseData',
43
+ :'data' => :'CheckEmailOtpAvailability200ResponseData',
44
44
  :'meta' => :'RequestMeta'
45
45
  }
46
46
  end