zyphr 0.1.24 → 0.1.26
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.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/docs/AuthRegistrationApi.md +137 -0
- data/docs/AuthUser.md +6 -0
- data/docs/ConvertAnonymousUserRequest.md +49 -0
- data/docs/ConvertAnonymousUserRequestOneOf.md +24 -0
- data/docs/ConvertAnonymousUserRequestOneOf1.md +24 -0
- data/docs/ConvertAnonymousUserRequestOneOf1AppleUser.md +18 -0
- data/docs/ConvertAnonymousUserRequestOneOf1AppleUserName.md +20 -0
- data/docs/PayloadTooLargeError.md +20 -0
- data/docs/PayloadTooLargeErrorError.md +22 -0
- data/docs/PayloadTooLargeErrorErrorDetails.md +20 -0
- data/docs/SignInAnonymouslyRequest.md +22 -0
- data/lib/zyphr/api/auth_registration_api.rb +136 -0
- data/lib/zyphr/models/auth_user.rb +33 -1
- data/lib/zyphr/models/convert_anonymous_user_request.rb +105 -0
- data/lib/zyphr/models/convert_anonymous_user_request_one_of.rb +323 -0
- data/lib/zyphr/models/convert_anonymous_user_request_one_of1.rb +324 -0
- data/lib/zyphr/models/convert_anonymous_user_request_one_of1_apple_user.rb +221 -0
- data/lib/zyphr/models/convert_anonymous_user_request_one_of1_apple_user_name.rb +229 -0
- data/lib/zyphr/models/payload_too_large_error.rb +246 -0
- data/lib/zyphr/models/payload_too_large_error_error.rb +296 -0
- data/lib/zyphr/models/payload_too_large_error_error_details.rb +231 -0
- data/lib/zyphr/models/sign_in_anonymously_request.rb +296 -0
- data/lib/zyphr.rb +9 -0
- data/spec/api/auth_registration_api_spec.rb +24 -0
- data/spec/models/auth_user_spec.rb +18 -0
- data/spec/models/convert_anonymous_user_request_one_of1_apple_user_name_spec.rb +42 -0
- data/spec/models/convert_anonymous_user_request_one_of1_apple_user_spec.rb +36 -0
- data/spec/models/convert_anonymous_user_request_one_of1_spec.rb +58 -0
- data/spec/models/convert_anonymous_user_request_one_of_spec.rb +58 -0
- data/spec/models/convert_anonymous_user_request_spec.rb +32 -0
- data/spec/models/payload_too_large_error_error_details_spec.rb +42 -0
- data/spec/models/payload_too_large_error_error_spec.rb +52 -0
- data/spec/models/payload_too_large_error_spec.rb +42 -0
- data/spec/models/sign_in_anonymously_request_spec.rb +48 -0
- data/zyphr.gemspec +1 -1
- metadata +398 -362
|
@@ -35,6 +35,15 @@ module Zyphr
|
|
|
35
35
|
|
|
36
36
|
attr_accessor :mfa_enabled
|
|
37
37
|
|
|
38
|
+
# True if the user signed in anonymously and has not yet been converted to a full account.
|
|
39
|
+
attr_accessor :is_anonymous
|
|
40
|
+
|
|
41
|
+
# Per-device identifier supplied at anonymous sign-in. Preserved across conversion so client-side \"this device has scores from me\" detection survives the upgrade. NULL for users who never signed in anonymously.
|
|
42
|
+
attr_accessor :anonymous_device_id
|
|
43
|
+
|
|
44
|
+
# Set on the user's first authenticated request after anonymous sign-in (excluding /auth/refresh). MAU billing for anonymous-origin users keys off this timestamp instead of created_at.
|
|
45
|
+
attr_accessor :first_activity_at
|
|
46
|
+
|
|
38
47
|
attr_accessor :created_at
|
|
39
48
|
|
|
40
49
|
attr_accessor :updated_at
|
|
@@ -76,6 +85,9 @@ module Zyphr
|
|
|
76
85
|
:'phone_verified' => :'phone_verified',
|
|
77
86
|
:'status' => :'status',
|
|
78
87
|
:'mfa_enabled' => :'mfa_enabled',
|
|
88
|
+
:'is_anonymous' => :'is_anonymous',
|
|
89
|
+
:'anonymous_device_id' => :'anonymous_device_id',
|
|
90
|
+
:'first_activity_at' => :'first_activity_at',
|
|
79
91
|
:'created_at' => :'created_at',
|
|
80
92
|
:'updated_at' => :'updated_at',
|
|
81
93
|
:'last_login_at' => :'last_login_at'
|
|
@@ -105,6 +117,9 @@ module Zyphr
|
|
|
105
117
|
:'phone_verified' => :'Boolean',
|
|
106
118
|
:'status' => :'String',
|
|
107
119
|
:'mfa_enabled' => :'Boolean',
|
|
120
|
+
:'is_anonymous' => :'Boolean',
|
|
121
|
+
:'anonymous_device_id' => :'String',
|
|
122
|
+
:'first_activity_at' => :'Time',
|
|
108
123
|
:'created_at' => :'Time',
|
|
109
124
|
:'updated_at' => :'Time',
|
|
110
125
|
:'last_login_at' => :'Time'
|
|
@@ -118,6 +133,8 @@ module Zyphr
|
|
|
118
133
|
:'name',
|
|
119
134
|
:'avatar_url',
|
|
120
135
|
:'phone_number',
|
|
136
|
+
:'anonymous_device_id',
|
|
137
|
+
:'first_activity_at',
|
|
121
138
|
:'last_login_at'
|
|
122
139
|
])
|
|
123
140
|
end
|
|
@@ -180,6 +197,18 @@ module Zyphr
|
|
|
180
197
|
self.mfa_enabled = attributes[:'mfa_enabled']
|
|
181
198
|
end
|
|
182
199
|
|
|
200
|
+
if attributes.key?(:'is_anonymous')
|
|
201
|
+
self.is_anonymous = attributes[:'is_anonymous']
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
if attributes.key?(:'anonymous_device_id')
|
|
205
|
+
self.anonymous_device_id = attributes[:'anonymous_device_id']
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
if attributes.key?(:'first_activity_at')
|
|
209
|
+
self.first_activity_at = attributes[:'first_activity_at']
|
|
210
|
+
end
|
|
211
|
+
|
|
183
212
|
if attributes.key?(:'created_at')
|
|
184
213
|
self.created_at = attributes[:'created_at']
|
|
185
214
|
end
|
|
@@ -235,6 +264,9 @@ module Zyphr
|
|
|
235
264
|
phone_verified == o.phone_verified &&
|
|
236
265
|
status == o.status &&
|
|
237
266
|
mfa_enabled == o.mfa_enabled &&
|
|
267
|
+
is_anonymous == o.is_anonymous &&
|
|
268
|
+
anonymous_device_id == o.anonymous_device_id &&
|
|
269
|
+
first_activity_at == o.first_activity_at &&
|
|
238
270
|
created_at == o.created_at &&
|
|
239
271
|
updated_at == o.updated_at &&
|
|
240
272
|
last_login_at == o.last_login_at
|
|
@@ -249,7 +281,7 @@ module Zyphr
|
|
|
249
281
|
# Calculates hash code according to all attributes.
|
|
250
282
|
# @return [Integer] Hash code
|
|
251
283
|
def hash
|
|
252
|
-
[id, email, name, email_verified, avatar_url, metadata, phone_number, phone_verified, status, mfa_enabled, created_at, updated_at, last_login_at].hash
|
|
284
|
+
[id, email, name, email_verified, avatar_url, metadata, phone_number, phone_verified, status, mfa_enabled, is_anonymous, anonymous_device_id, first_activity_at, created_at, updated_at, last_login_at].hash
|
|
253
285
|
end
|
|
254
286
|
|
|
255
287
|
# Builds the object from hash
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
module ConvertAnonymousUserRequest
|
|
18
|
+
class << self
|
|
19
|
+
# List of class defined in oneOf (OpenAPI v3)
|
|
20
|
+
def openapi_one_of
|
|
21
|
+
[
|
|
22
|
+
:'ConvertAnonymousUserRequestOneOf',
|
|
23
|
+
:'ConvertAnonymousUserRequestOneOf1'
|
|
24
|
+
]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Builds the object
|
|
28
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
|
29
|
+
# @return [Object] Returns the model or the data itself
|
|
30
|
+
def build(data)
|
|
31
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
|
32
|
+
# Note:
|
|
33
|
+
# - We do not attempt to check whether exactly one item matches.
|
|
34
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
35
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
36
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
37
|
+
# - TODO: logging when debugging is set.
|
|
38
|
+
openapi_one_of.each do |klass|
|
|
39
|
+
begin
|
|
40
|
+
next if klass == :AnyType # "nullable: true"
|
|
41
|
+
typed_data = find_and_cast_into_type(klass, data)
|
|
42
|
+
return typed_data if typed_data
|
|
43
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
53
|
+
|
|
54
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
55
|
+
def find_and_cast_into_type(klass, data)
|
|
56
|
+
return if data.nil?
|
|
57
|
+
|
|
58
|
+
case klass.to_s
|
|
59
|
+
when 'Boolean'
|
|
60
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
61
|
+
when 'Float'
|
|
62
|
+
return data if data.instance_of?(Float)
|
|
63
|
+
when 'Integer'
|
|
64
|
+
return data if data.instance_of?(Integer)
|
|
65
|
+
when 'Time'
|
|
66
|
+
return Time.parse(data)
|
|
67
|
+
when 'Date'
|
|
68
|
+
return Date.parse(data)
|
|
69
|
+
when 'String'
|
|
70
|
+
return data if data.instance_of?(String)
|
|
71
|
+
when 'Object' # "type: object"
|
|
72
|
+
return data if data.instance_of?(Hash)
|
|
73
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
74
|
+
if data.instance_of?(Array)
|
|
75
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
76
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
77
|
+
end
|
|
78
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
79
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
80
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
81
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
82
|
+
end
|
|
83
|
+
else # model
|
|
84
|
+
const = Zyphr.const_get(klass)
|
|
85
|
+
if const
|
|
86
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
|
87
|
+
model = const.build(data)
|
|
88
|
+
return model if model
|
|
89
|
+
else
|
|
90
|
+
# raise if data contains keys that are not known to the model
|
|
91
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
92
|
+
model = const.build_from_hash(data)
|
|
93
|
+
return model if model
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
raise # if no match by now, raise
|
|
99
|
+
rescue
|
|
100
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
|
@@ -0,0 +1,323 @@
|
|
|
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 ConvertAnonymousUserRequestOneOf
|
|
18
|
+
attr_accessor :method
|
|
19
|
+
|
|
20
|
+
attr_accessor :email
|
|
21
|
+
|
|
22
|
+
attr_accessor :password
|
|
23
|
+
|
|
24
|
+
# Optional. Overwrites the user's existing name if provided.
|
|
25
|
+
attr_accessor :name
|
|
26
|
+
|
|
27
|
+
class EnumAttributeValidator
|
|
28
|
+
attr_reader :datatype
|
|
29
|
+
attr_reader :allowable_values
|
|
30
|
+
|
|
31
|
+
def initialize(datatype, allowable_values)
|
|
32
|
+
@allowable_values = allowable_values.map do |value|
|
|
33
|
+
case datatype.to_s
|
|
34
|
+
when /Integer/i
|
|
35
|
+
value.to_i
|
|
36
|
+
when /Float/i
|
|
37
|
+
value.to_f
|
|
38
|
+
else
|
|
39
|
+
value
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def valid?(value)
|
|
45
|
+
!value || allowable_values.include?(value)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
50
|
+
def self.attribute_map
|
|
51
|
+
{
|
|
52
|
+
:'method' => :'method',
|
|
53
|
+
:'email' => :'email',
|
|
54
|
+
:'password' => :'password',
|
|
55
|
+
:'name' => :'name'
|
|
56
|
+
}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Returns attribute mapping this model knows about
|
|
60
|
+
def self.acceptable_attribute_map
|
|
61
|
+
attribute_map
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Returns all the JSON keys this model knows about
|
|
65
|
+
def self.acceptable_attributes
|
|
66
|
+
acceptable_attribute_map.values
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Attribute type mapping.
|
|
70
|
+
def self.openapi_types
|
|
71
|
+
{
|
|
72
|
+
:'method' => :'String',
|
|
73
|
+
:'email' => :'String',
|
|
74
|
+
:'password' => :'String',
|
|
75
|
+
:'name' => :'String'
|
|
76
|
+
}
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# List of attributes with nullable: true
|
|
80
|
+
def self.openapi_nullable
|
|
81
|
+
Set.new([
|
|
82
|
+
])
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Initializes the object
|
|
86
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
87
|
+
def initialize(attributes = {})
|
|
88
|
+
if (!attributes.is_a?(Hash))
|
|
89
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::ConvertAnonymousUserRequestOneOf` initialize method"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
93
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
94
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
95
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
96
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::ConvertAnonymousUserRequestOneOf`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
97
|
+
end
|
|
98
|
+
h[k.to_sym] = v
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'method')
|
|
102
|
+
self.method = attributes[:'method']
|
|
103
|
+
else
|
|
104
|
+
self.method = nil
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
if attributes.key?(:'email')
|
|
108
|
+
self.email = attributes[:'email']
|
|
109
|
+
else
|
|
110
|
+
self.email = nil
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if attributes.key?(:'password')
|
|
114
|
+
self.password = attributes[:'password']
|
|
115
|
+
else
|
|
116
|
+
self.password = nil
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
if attributes.key?(:'name')
|
|
120
|
+
self.name = attributes[:'name']
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
125
|
+
# @return Array for valid properties with the reasons
|
|
126
|
+
def list_invalid_properties
|
|
127
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
128
|
+
invalid_properties = Array.new
|
|
129
|
+
if @method.nil?
|
|
130
|
+
invalid_properties.push('invalid value for "method", method cannot be nil.')
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
if @email.nil?
|
|
134
|
+
invalid_properties.push('invalid value for "email", email cannot be nil.')
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
if @password.nil?
|
|
138
|
+
invalid_properties.push('invalid value for "password", password cannot be nil.')
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
invalid_properties
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Check to see if the all the properties in the model are valid
|
|
145
|
+
# @return true if the model is valid
|
|
146
|
+
def valid?
|
|
147
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
148
|
+
return false if @method.nil?
|
|
149
|
+
method_validator = EnumAttributeValidator.new('String', ["password"])
|
|
150
|
+
return false unless method_validator.valid?(@method)
|
|
151
|
+
return false if @email.nil?
|
|
152
|
+
return false if @password.nil?
|
|
153
|
+
true
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
157
|
+
# @param [Object] method Object to be assigned
|
|
158
|
+
def method=(method)
|
|
159
|
+
validator = EnumAttributeValidator.new('String', ["password"])
|
|
160
|
+
unless validator.valid?(method)
|
|
161
|
+
fail ArgumentError, "invalid value for \"method\", must be one of #{validator.allowable_values}."
|
|
162
|
+
end
|
|
163
|
+
@method = method
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Custom attribute writer method with validation
|
|
167
|
+
# @param [Object] email Value to be assigned
|
|
168
|
+
def email=(email)
|
|
169
|
+
if email.nil?
|
|
170
|
+
fail ArgumentError, 'email cannot be nil'
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
@email = email
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Custom attribute writer method with validation
|
|
177
|
+
# @param [Object] password Value to be assigned
|
|
178
|
+
def password=(password)
|
|
179
|
+
if password.nil?
|
|
180
|
+
fail ArgumentError, 'password cannot be nil'
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
@password = password
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Checks equality by comparing each attribute.
|
|
187
|
+
# @param [Object] Object to be compared
|
|
188
|
+
def ==(o)
|
|
189
|
+
return true if self.equal?(o)
|
|
190
|
+
self.class == o.class &&
|
|
191
|
+
method == o.method &&
|
|
192
|
+
email == o.email &&
|
|
193
|
+
password == o.password &&
|
|
194
|
+
name == o.name
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# @see the `==` method
|
|
198
|
+
# @param [Object] Object to be compared
|
|
199
|
+
def eql?(o)
|
|
200
|
+
self == o
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Calculates hash code according to all attributes.
|
|
204
|
+
# @return [Integer] Hash code
|
|
205
|
+
def hash
|
|
206
|
+
[method, email, password, name].hash
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Builds the object from hash
|
|
210
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
211
|
+
# @return [Object] Returns the model itself
|
|
212
|
+
def self.build_from_hash(attributes)
|
|
213
|
+
return nil unless attributes.is_a?(Hash)
|
|
214
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
215
|
+
transformed_hash = {}
|
|
216
|
+
openapi_types.each_pair do |key, type|
|
|
217
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
218
|
+
transformed_hash["#{key}"] = nil
|
|
219
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
220
|
+
# check to ensure the input is an array given that the attribute
|
|
221
|
+
# is documented as an array but the input is not
|
|
222
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
223
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
224
|
+
end
|
|
225
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
226
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
new(transformed_hash)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Deserializes the data based on type
|
|
233
|
+
# @param string type Data type
|
|
234
|
+
# @param string value Value to be deserialized
|
|
235
|
+
# @return [Object] Deserialized data
|
|
236
|
+
def self._deserialize(type, value)
|
|
237
|
+
case type.to_sym
|
|
238
|
+
when :Time
|
|
239
|
+
Time.parse(value)
|
|
240
|
+
when :Date
|
|
241
|
+
Date.parse(value)
|
|
242
|
+
when :String
|
|
243
|
+
value.to_s
|
|
244
|
+
when :Integer
|
|
245
|
+
value.to_i
|
|
246
|
+
when :Float
|
|
247
|
+
value.to_f
|
|
248
|
+
when :Boolean
|
|
249
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
250
|
+
true
|
|
251
|
+
else
|
|
252
|
+
false
|
|
253
|
+
end
|
|
254
|
+
when :Object
|
|
255
|
+
# generic object (usually a Hash), return directly
|
|
256
|
+
value
|
|
257
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
258
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
259
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
260
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
261
|
+
k_type = Regexp.last_match[:k_type]
|
|
262
|
+
v_type = Regexp.last_match[:v_type]
|
|
263
|
+
{}.tap do |hash|
|
|
264
|
+
value.each do |k, v|
|
|
265
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
else # model
|
|
269
|
+
# models (e.g. Pet) or oneOf
|
|
270
|
+
klass = Zyphr.const_get(type)
|
|
271
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# Returns the string representation of the object
|
|
276
|
+
# @return [String] String presentation of the object
|
|
277
|
+
def to_s
|
|
278
|
+
to_hash.to_s
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
282
|
+
# @return [Hash] Returns the object in the form of hash
|
|
283
|
+
def to_body
|
|
284
|
+
to_hash
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Returns the object in the form of hash
|
|
288
|
+
# @return [Hash] Returns the object in the form of hash
|
|
289
|
+
def to_hash
|
|
290
|
+
hash = {}
|
|
291
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
292
|
+
value = self.send(attr)
|
|
293
|
+
if value.nil?
|
|
294
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
295
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
hash[param] = _to_hash(value)
|
|
299
|
+
end
|
|
300
|
+
hash
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Outputs non-array value in the form of hash
|
|
304
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
305
|
+
# @param [Object] value Any valid value
|
|
306
|
+
# @return [Hash] Returns the value in the form of hash
|
|
307
|
+
def _to_hash(value)
|
|
308
|
+
if value.is_a?(Array)
|
|
309
|
+
value.compact.map { |v| _to_hash(v) }
|
|
310
|
+
elsif value.is_a?(Hash)
|
|
311
|
+
{}.tap do |hash|
|
|
312
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
313
|
+
end
|
|
314
|
+
elsif value.respond_to? :to_hash
|
|
315
|
+
value.to_hash
|
|
316
|
+
else
|
|
317
|
+
value
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
end
|