zyphr 0.1.43 → 0.1.45

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -4
  3. data/docs/ApplicationSelf.md +26 -0
  4. data/docs/ApplicationSelfResponse.md +20 -0
  5. data/docs/AuthApplicationApi.md +158 -0
  6. data/docs/AuthEmailTemplateTestRequest.md +1 -1
  7. data/docs/AuthEmailTemplatesApi.md +1 -1
  8. data/docs/AuthMethods.md +28 -0
  9. data/docs/AuthUserDirectoryApi.md +77 -0
  10. data/docs/AuthUserProfileApi.md +75 -0
  11. data/docs/ChangePasswordRequest.md +20 -0
  12. data/docs/GetEndUserAuthMethods200Response.md +20 -0
  13. data/docs/SetSelfApplicationTestRecipientsRequest.md +18 -0
  14. data/docs/WebhookDelivery.md +1 -1
  15. data/docs/WebhookDeliveryDetail.md +1 -1
  16. data/docs/WebhookEventType.md +15 -0
  17. data/docs/WebhookEventTypesResponseData.md +1 -1
  18. data/docs/WebhookTestEventResponseData.md +1 -1
  19. data/lib/zyphr/api/auth_application_api.rb +147 -0
  20. data/lib/zyphr/api/auth_email_templates_api.rb +2 -2
  21. data/lib/zyphr/api/auth_user_directory_api.rb +63 -0
  22. data/lib/zyphr/api/auth_user_profile_api.rb +68 -0
  23. data/lib/zyphr/models/application_self.rb +371 -0
  24. data/lib/zyphr/models/application_self_response.rb +229 -0
  25. data/lib/zyphr/models/auth_email_template_test_request.rb +1 -1
  26. data/lib/zyphr/models/auth_methods.rb +376 -0
  27. data/lib/zyphr/models/change_password_request.rb +265 -0
  28. data/lib/zyphr/models/get_end_user_auth_methods200_response.rb +229 -0
  29. data/lib/zyphr/models/set_self_application_test_recipients_request.rb +240 -0
  30. data/lib/zyphr/models/webhook_delivery.rb +1 -1
  31. data/lib/zyphr/models/webhook_delivery_detail.rb +1 -1
  32. data/lib/zyphr/models/webhook_event_type.rb +66 -0
  33. data/lib/zyphr/models/webhook_event_types_response_data.rb +1 -1
  34. data/lib/zyphr/models/webhook_test_event_response_data.rb +23 -1
  35. data/lib/zyphr.rb +8 -0
  36. data/spec/api/auth_application_api_spec.rb +58 -0
  37. data/spec/api/auth_email_templates_api_spec.rb +1 -1
  38. data/spec/api/auth_user_directory_api_spec.rb +12 -0
  39. data/spec/api/auth_user_profile_api_spec.rb +12 -0
  40. data/spec/models/application_self_response_spec.rb +42 -0
  41. data/spec/models/application_self_spec.rb +68 -0
  42. data/spec/models/auth_methods_spec.rb +66 -0
  43. data/spec/models/change_password_request_spec.rb +42 -0
  44. data/spec/models/get_end_user_auth_methods200_response_spec.rb +42 -0
  45. data/spec/models/set_self_application_test_recipients_request_spec.rb +36 -0
  46. data/spec/models/webhook_event_type_spec.rb +30 -0
  47. data/zyphr.gemspec +1 -1
  48. metadata +33 -1
@@ -0,0 +1,376 @@
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 ## Account Sending Status Every authenticated response carries the account's current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## 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
+ # Aggregate view of the sign-in methods configured for a single end user, for building a customer \"sign-in methods\" screen.
18
+ class AuthMethods
19
+ # True if the user has a password credential (false for OAuth-only / passwordless users).
20
+ attr_accessor :has_password
21
+
22
+ # Distinct OAuth providers linked to the user (e.g. google, apple).
23
+ attr_accessor :oauth_providers
24
+
25
+ # True if the user has multi-factor authentication enabled.
26
+ attr_accessor :mfa_enabled
27
+
28
+ # True if the user's email address has been verified.
29
+ attr_accessor :email_verified
30
+
31
+ # True if the user's phone number has been verified.
32
+ attr_accessor :phone_verified
33
+
34
+ # Number of WebAuthn passkeys registered for the user.
35
+ attr_accessor :passkeys
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'has_password' => :'has_password',
41
+ :'oauth_providers' => :'oauth_providers',
42
+ :'mfa_enabled' => :'mfa_enabled',
43
+ :'email_verified' => :'email_verified',
44
+ :'phone_verified' => :'phone_verified',
45
+ :'passkeys' => :'passkeys'
46
+ }
47
+ end
48
+
49
+ # Returns attribute mapping this model knows about
50
+ def self.acceptable_attribute_map
51
+ attribute_map
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ acceptable_attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'has_password' => :'Boolean',
63
+ :'oauth_providers' => :'Array<String>',
64
+ :'mfa_enabled' => :'Boolean',
65
+ :'email_verified' => :'Boolean',
66
+ :'phone_verified' => :'Boolean',
67
+ :'passkeys' => :'Integer'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ ])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::AuthMethods` initialize method"
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ acceptable_attribute_map = self.class.acceptable_attribute_map
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!acceptable_attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::AuthMethods`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'has_password')
94
+ self.has_password = attributes[:'has_password']
95
+ else
96
+ self.has_password = nil
97
+ end
98
+
99
+ if attributes.key?(:'oauth_providers')
100
+ if (value = attributes[:'oauth_providers']).is_a?(Array)
101
+ self.oauth_providers = value
102
+ end
103
+ else
104
+ self.oauth_providers = nil
105
+ end
106
+
107
+ if attributes.key?(:'mfa_enabled')
108
+ self.mfa_enabled = attributes[:'mfa_enabled']
109
+ else
110
+ self.mfa_enabled = nil
111
+ end
112
+
113
+ if attributes.key?(:'email_verified')
114
+ self.email_verified = attributes[:'email_verified']
115
+ else
116
+ self.email_verified = nil
117
+ end
118
+
119
+ if attributes.key?(:'phone_verified')
120
+ self.phone_verified = attributes[:'phone_verified']
121
+ else
122
+ self.phone_verified = nil
123
+ end
124
+
125
+ if attributes.key?(:'passkeys')
126
+ self.passkeys = attributes[:'passkeys']
127
+ else
128
+ self.passkeys = nil
129
+ end
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properties with the reasons
134
+ def list_invalid_properties
135
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
136
+ invalid_properties = Array.new
137
+ if @has_password.nil?
138
+ invalid_properties.push('invalid value for "has_password", has_password cannot be nil.')
139
+ end
140
+
141
+ if @oauth_providers.nil?
142
+ invalid_properties.push('invalid value for "oauth_providers", oauth_providers cannot be nil.')
143
+ end
144
+
145
+ if @mfa_enabled.nil?
146
+ invalid_properties.push('invalid value for "mfa_enabled", mfa_enabled cannot be nil.')
147
+ end
148
+
149
+ if @email_verified.nil?
150
+ invalid_properties.push('invalid value for "email_verified", email_verified cannot be nil.')
151
+ end
152
+
153
+ if @phone_verified.nil?
154
+ invalid_properties.push('invalid value for "phone_verified", phone_verified cannot be nil.')
155
+ end
156
+
157
+ if @passkeys.nil?
158
+ invalid_properties.push('invalid value for "passkeys", passkeys cannot be nil.')
159
+ end
160
+
161
+ invalid_properties
162
+ end
163
+
164
+ # Check to see if the all the properties in the model are valid
165
+ # @return true if the model is valid
166
+ def valid?
167
+ warn '[DEPRECATED] the `valid?` method is obsolete'
168
+ return false if @has_password.nil?
169
+ return false if @oauth_providers.nil?
170
+ return false if @mfa_enabled.nil?
171
+ return false if @email_verified.nil?
172
+ return false if @phone_verified.nil?
173
+ return false if @passkeys.nil?
174
+ true
175
+ end
176
+
177
+ # Custom attribute writer method with validation
178
+ # @param [Object] has_password Value to be assigned
179
+ def has_password=(has_password)
180
+ if has_password.nil?
181
+ fail ArgumentError, 'has_password cannot be nil'
182
+ end
183
+
184
+ @has_password = has_password
185
+ end
186
+
187
+ # Custom attribute writer method with validation
188
+ # @param [Object] oauth_providers Value to be assigned
189
+ def oauth_providers=(oauth_providers)
190
+ if oauth_providers.nil?
191
+ fail ArgumentError, 'oauth_providers cannot be nil'
192
+ end
193
+
194
+ @oauth_providers = oauth_providers
195
+ end
196
+
197
+ # Custom attribute writer method with validation
198
+ # @param [Object] mfa_enabled Value to be assigned
199
+ def mfa_enabled=(mfa_enabled)
200
+ if mfa_enabled.nil?
201
+ fail ArgumentError, 'mfa_enabled cannot be nil'
202
+ end
203
+
204
+ @mfa_enabled = mfa_enabled
205
+ end
206
+
207
+ # Custom attribute writer method with validation
208
+ # @param [Object] email_verified Value to be assigned
209
+ def email_verified=(email_verified)
210
+ if email_verified.nil?
211
+ fail ArgumentError, 'email_verified cannot be nil'
212
+ end
213
+
214
+ @email_verified = email_verified
215
+ end
216
+
217
+ # Custom attribute writer method with validation
218
+ # @param [Object] phone_verified Value to be assigned
219
+ def phone_verified=(phone_verified)
220
+ if phone_verified.nil?
221
+ fail ArgumentError, 'phone_verified cannot be nil'
222
+ end
223
+
224
+ @phone_verified = phone_verified
225
+ end
226
+
227
+ # Custom attribute writer method with validation
228
+ # @param [Object] passkeys Value to be assigned
229
+ def passkeys=(passkeys)
230
+ if passkeys.nil?
231
+ fail ArgumentError, 'passkeys cannot be nil'
232
+ end
233
+
234
+ @passkeys = passkeys
235
+ end
236
+
237
+ # Checks equality by comparing each attribute.
238
+ # @param [Object] Object to be compared
239
+ def ==(o)
240
+ return true if self.equal?(o)
241
+ self.class == o.class &&
242
+ has_password == o.has_password &&
243
+ oauth_providers == o.oauth_providers &&
244
+ mfa_enabled == o.mfa_enabled &&
245
+ email_verified == o.email_verified &&
246
+ phone_verified == o.phone_verified &&
247
+ passkeys == o.passkeys
248
+ end
249
+
250
+ # @see the `==` method
251
+ # @param [Object] Object to be compared
252
+ def eql?(o)
253
+ self == o
254
+ end
255
+
256
+ # Calculates hash code according to all attributes.
257
+ # @return [Integer] Hash code
258
+ def hash
259
+ [has_password, oauth_providers, mfa_enabled, email_verified, phone_verified, passkeys].hash
260
+ end
261
+
262
+ # Builds the object from hash
263
+ # @param [Hash] attributes Model attributes in the form of hash
264
+ # @return [Object] Returns the model itself
265
+ def self.build_from_hash(attributes)
266
+ return nil unless attributes.is_a?(Hash)
267
+ attributes = attributes.transform_keys(&:to_sym)
268
+ transformed_hash = {}
269
+ openapi_types.each_pair do |key, type|
270
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
271
+ transformed_hash["#{key}"] = nil
272
+ elsif type =~ /\AArray<(.*)>/i
273
+ # check to ensure the input is an array given that the attribute
274
+ # is documented as an array but the input is not
275
+ if attributes[attribute_map[key]].is_a?(Array)
276
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
277
+ end
278
+ elsif !attributes[attribute_map[key]].nil?
279
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
280
+ end
281
+ end
282
+ new(transformed_hash)
283
+ end
284
+
285
+ # Deserializes the data based on type
286
+ # @param string type Data type
287
+ # @param string value Value to be deserialized
288
+ # @return [Object] Deserialized data
289
+ def self._deserialize(type, value)
290
+ case type.to_sym
291
+ when :Time
292
+ Time.parse(value)
293
+ when :Date
294
+ Date.parse(value)
295
+ when :String
296
+ value.to_s
297
+ when :Integer
298
+ value.to_i
299
+ when :Float
300
+ value.to_f
301
+ when :Boolean
302
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
303
+ true
304
+ else
305
+ false
306
+ end
307
+ when :Object
308
+ # generic object (usually a Hash), return directly
309
+ value
310
+ when /\AArray<(?<inner_type>.+)>\z/
311
+ inner_type = Regexp.last_match[:inner_type]
312
+ value.map { |v| _deserialize(inner_type, v) }
313
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
314
+ k_type = Regexp.last_match[:k_type]
315
+ v_type = Regexp.last_match[:v_type]
316
+ {}.tap do |hash|
317
+ value.each do |k, v|
318
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
319
+ end
320
+ end
321
+ else # model
322
+ # models (e.g. Pet) or oneOf
323
+ klass = Zyphr.const_get(type)
324
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
325
+ end
326
+ end
327
+
328
+ # Returns the string representation of the object
329
+ # @return [String] String presentation of the object
330
+ def to_s
331
+ to_hash.to_s
332
+ end
333
+
334
+ # to_body is an alias to to_hash (backward compatibility)
335
+ # @return [Hash] Returns the object in the form of hash
336
+ def to_body
337
+ to_hash
338
+ end
339
+
340
+ # Returns the object in the form of hash
341
+ # @return [Hash] Returns the object in the form of hash
342
+ def to_hash
343
+ hash = {}
344
+ self.class.attribute_map.each_pair do |attr, param|
345
+ value = self.send(attr)
346
+ if value.nil?
347
+ is_nullable = self.class.openapi_nullable.include?(attr)
348
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
349
+ end
350
+
351
+ hash[param] = _to_hash(value)
352
+ end
353
+ hash
354
+ end
355
+
356
+ # Outputs non-array value in the form of hash
357
+ # For object, use to_hash. Otherwise, just return the value
358
+ # @param [Object] value Any valid value
359
+ # @return [Hash] Returns the value in the form of hash
360
+ def _to_hash(value)
361
+ if value.is_a?(Array)
362
+ value.compact.map { |v| _to_hash(v) }
363
+ elsif value.is_a?(Hash)
364
+ {}.tap do |hash|
365
+ value.each { |k, v| hash[k] = _to_hash(v) }
366
+ end
367
+ elsif value.respond_to? :to_hash
368
+ value.to_hash
369
+ else
370
+ value
371
+ end
372
+ end
373
+
374
+ end
375
+
376
+ end
@@ -0,0 +1,265 @@
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 ## Account Sending Status Every authenticated response carries the account's current sending state so you can surface it in your own tooling without a separate call: - `X-Account-Sending-Status`: `active`, `throttled`, or `frozen` - `X-Account-Sending-Status-Reason`: human-readable reason (present only when the status is `throttled` or `frozen`) This header is informational and non-blocking on non-send endpoints (reads, billing, and deliverability stay available). Send-capable endpoints additionally enforce the state: a frozen account receives `403 account_frozen` and a throttled account receives `429 account_throttled`, both with the reason in the error message. ## 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 ChangePasswordRequest
18
+ # The user's current password, for verification.
19
+ attr_accessor :current_password
20
+
21
+ # The new password. Must satisfy the application's password policy.
22
+ attr_accessor :new_password
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'current_password' => :'current_password',
28
+ :'new_password' => :'new_password'
29
+ }
30
+ end
31
+
32
+ # Returns attribute mapping this model knows about
33
+ def self.acceptable_attribute_map
34
+ attribute_map
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ acceptable_attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'current_password' => :'String',
46
+ :'new_password' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::ChangePasswordRequest` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ acceptable_attribute_map = self.class.acceptable_attribute_map
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!acceptable_attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::ChangePasswordRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'current_password')
73
+ self.current_password = attributes[:'current_password']
74
+ else
75
+ self.current_password = nil
76
+ end
77
+
78
+ if attributes.key?(:'new_password')
79
+ self.new_password = attributes[:'new_password']
80
+ else
81
+ self.new_password = nil
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
89
+ invalid_properties = Array.new
90
+ if @current_password.nil?
91
+ invalid_properties.push('invalid value for "current_password", current_password cannot be nil.')
92
+ end
93
+
94
+ if @new_password.nil?
95
+ invalid_properties.push('invalid value for "new_password", new_password cannot be nil.')
96
+ end
97
+
98
+ invalid_properties
99
+ end
100
+
101
+ # Check to see if the all the properties in the model are valid
102
+ # @return true if the model is valid
103
+ def valid?
104
+ warn '[DEPRECATED] the `valid?` method is obsolete'
105
+ return false if @current_password.nil?
106
+ return false if @new_password.nil?
107
+ true
108
+ end
109
+
110
+ # Custom attribute writer method with validation
111
+ # @param [Object] current_password Value to be assigned
112
+ def current_password=(current_password)
113
+ if current_password.nil?
114
+ fail ArgumentError, 'current_password cannot be nil'
115
+ end
116
+
117
+ @current_password = current_password
118
+ end
119
+
120
+ # Custom attribute writer method with validation
121
+ # @param [Object] new_password Value to be assigned
122
+ def new_password=(new_password)
123
+ if new_password.nil?
124
+ fail ArgumentError, 'new_password cannot be nil'
125
+ end
126
+
127
+ @new_password = new_password
128
+ end
129
+
130
+ # Checks equality by comparing each attribute.
131
+ # @param [Object] Object to be compared
132
+ def ==(o)
133
+ return true if self.equal?(o)
134
+ self.class == o.class &&
135
+ current_password == o.current_password &&
136
+ new_password == o.new_password
137
+ end
138
+
139
+ # @see the `==` method
140
+ # @param [Object] Object to be compared
141
+ def eql?(o)
142
+ self == o
143
+ end
144
+
145
+ # Calculates hash code according to all attributes.
146
+ # @return [Integer] Hash code
147
+ def hash
148
+ [current_password, new_password].hash
149
+ end
150
+
151
+ # Builds the object from hash
152
+ # @param [Hash] attributes Model attributes in the form of hash
153
+ # @return [Object] Returns the model itself
154
+ def self.build_from_hash(attributes)
155
+ return nil unless attributes.is_a?(Hash)
156
+ attributes = attributes.transform_keys(&:to_sym)
157
+ transformed_hash = {}
158
+ openapi_types.each_pair do |key, type|
159
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = nil
161
+ elsif type =~ /\AArray<(.*)>/i
162
+ # check to ensure the input is an array given that the attribute
163
+ # is documented as an array but the input is not
164
+ if attributes[attribute_map[key]].is_a?(Array)
165
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
166
+ end
167
+ elsif !attributes[attribute_map[key]].nil?
168
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
169
+ end
170
+ end
171
+ new(transformed_hash)
172
+ end
173
+
174
+ # Deserializes the data based on type
175
+ # @param string type Data type
176
+ # @param string value Value to be deserialized
177
+ # @return [Object] Deserialized data
178
+ def self._deserialize(type, value)
179
+ case type.to_sym
180
+ when :Time
181
+ Time.parse(value)
182
+ when :Date
183
+ Date.parse(value)
184
+ when :String
185
+ value.to_s
186
+ when :Integer
187
+ value.to_i
188
+ when :Float
189
+ value.to_f
190
+ when :Boolean
191
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
192
+ true
193
+ else
194
+ false
195
+ end
196
+ when :Object
197
+ # generic object (usually a Hash), return directly
198
+ value
199
+ when /\AArray<(?<inner_type>.+)>\z/
200
+ inner_type = Regexp.last_match[:inner_type]
201
+ value.map { |v| _deserialize(inner_type, v) }
202
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
203
+ k_type = Regexp.last_match[:k_type]
204
+ v_type = Regexp.last_match[:v_type]
205
+ {}.tap do |hash|
206
+ value.each do |k, v|
207
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
208
+ end
209
+ end
210
+ else # model
211
+ # models (e.g. Pet) or oneOf
212
+ klass = Zyphr.const_get(type)
213
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ if value.nil?
236
+ is_nullable = self.class.openapi_nullable.include?(attr)
237
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
238
+ end
239
+
240
+ hash[param] = _to_hash(value)
241
+ end
242
+ hash
243
+ end
244
+
245
+ # Outputs non-array value in the form of hash
246
+ # For object, use to_hash. Otherwise, just return the value
247
+ # @param [Object] value Any valid value
248
+ # @return [Hash] Returns the value in the form of hash
249
+ def _to_hash(value)
250
+ if value.is_a?(Array)
251
+ value.compact.map { |v| _to_hash(v) }
252
+ elsif value.is_a?(Hash)
253
+ {}.tap do |hash|
254
+ value.each { |k, v| hash[k] = _to_hash(v) }
255
+ end
256
+ elsif value.respond_to? :to_hash
257
+ value.to_hash
258
+ else
259
+ value
260
+ end
261
+ end
262
+
263
+ end
264
+
265
+ end