passageidentity 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +18 -61
- data/docs/custom/AuthApi.md +141 -0
- data/docs/custom/ClientApi.md +107 -0
- data/docs/custom/UserApi.md +419 -0
- data/docs/generated/AppInfo.md +94 -0
- data/docs/generated/AppResponse.md +18 -0
- data/docs/generated/AppsApi.md +77 -0
- data/docs/generated/AuthMethods.md +22 -0
- data/docs/generated/CreateMagicLinkRequest.md +36 -0
- data/docs/generated/CreateUserRequest.md +22 -0
- data/docs/generated/ElementCustomization.md +56 -0
- data/docs/generated/FontFamily.md +15 -0
- data/docs/generated/LayoutConfig.md +26 -0
- data/docs/generated/Layouts.md +20 -0
- data/docs/generated/ListDevicesResponse.md +18 -0
- data/docs/generated/MagicLink.md +36 -0
- data/docs/generated/MagicLinkAuthMethod.md +22 -0
- data/docs/generated/MagicLinkChannel.md +15 -0
- data/docs/generated/MagicLinkResponse.md +18 -0
- data/docs/generated/MagicLinkType.md +15 -0
- data/docs/generated/MagicLinksApi.md +79 -0
- data/docs/generated/Model400Error.md +20 -0
- data/docs/generated/Model401Error.md +20 -0
- data/docs/generated/Model404Error.md +20 -0
- data/docs/generated/Model500Error.md +20 -0
- data/docs/generated/OtpAuthMethod.md +22 -0
- data/docs/generated/PasskeysAuthMethod.md +18 -0
- data/docs/generated/Technologies.md +15 -0
- data/docs/generated/TokensApi.md +78 -0
- data/docs/generated/TtlDisplayUnit.md +15 -0
- data/docs/generated/UpdateMagicLinkAuthMethod.md +22 -0
- data/docs/generated/UpdateOtpAuthMethod.md +22 -0
- data/docs/generated/UpdatePasskeysAuthMethod.md +18 -0
- data/docs/generated/UpdateUserRequest.md +22 -0
- data/docs/generated/UserDevicesApi.md +152 -0
- data/docs/generated/UserEventInfo.md +26 -0
- data/docs/generated/UserInfo.md +46 -0
- data/docs/generated/UserMetadataField.md +28 -0
- data/docs/generated/UserMetadataFieldType.md +15 -0
- data/docs/generated/UserResponse.md +18 -0
- data/docs/generated/UserStatus.md +15 -0
- data/docs/generated/UsersApi.md +440 -0
- data/docs/generated/WebAuthnDevices.md +34 -0
- data/docs/generated/WebAuthnIcons.md +20 -0
- data/docs/generated/WebAuthnType.md +15 -0
- data/generate.sh +31 -0
- data/lib/openapi_client/api/apps_api.rb +85 -0
- data/lib/openapi_client/api/magic_links_api.rb +96 -0
- data/lib/openapi_client/api/tokens_api.rb +91 -0
- data/lib/openapi_client/api/user_devices_api.rb +166 -0
- data/lib/openapi_client/api/users_api.rb +452 -0
- data/lib/openapi_client/api_client.rb +431 -0
- data/lib/openapi_client/api_error.rb +58 -0
- data/lib/openapi_client/configuration.rb +383 -0
- data/lib/openapi_client/models/app_info.rb +853 -0
- data/lib/openapi_client/models/app_response.rb +221 -0
- data/lib/openapi_client/models/auth_methods.rb +254 -0
- data/lib/openapi_client/models/create_magic_link_request.rb +374 -0
- data/lib/openapi_client/models/create_user_request.rb +234 -0
- data/lib/openapi_client/models/element_customization.rb +457 -0
- data/lib/openapi_client/models/font_family.rb +58 -0
- data/lib/openapi_client/models/layout_config.rb +285 -0
- data/lib/openapi_client/models/layouts.rb +241 -0
- data/lib/openapi_client/models/list_devices_response.rb +223 -0
- data/lib/openapi_client/models/magic_link.rb +387 -0
- data/lib/openapi_client/models/magic_link_auth_method.rb +302 -0
- data/lib/openapi_client/models/magic_link_channel.rb +40 -0
- data/lib/openapi_client/models/magic_link_response.rb +221 -0
- data/lib/openapi_client/models/magic_link_type.rb +40 -0
- data/lib/openapi_client/models/model400_error.rb +271 -0
- data/lib/openapi_client/models/model401_error.rb +271 -0
- data/lib/openapi_client/models/model404_error.rb +271 -0
- data/lib/openapi_client/models/model500_error.rb +271 -0
- data/lib/openapi_client/models/otp_auth_method.rb +302 -0
- data/lib/openapi_client/models/passkeys_auth_method.rb +228 -0
- data/lib/openapi_client/models/technologies.rb +46 -0
- data/lib/openapi_client/models/ttl_display_unit.rb +42 -0
- data/lib/openapi_client/models/update_magic_link_auth_method.rb +276 -0
- data/lib/openapi_client/models/update_otp_auth_method.rb +276 -0
- data/lib/openapi_client/models/update_passkeys_auth_method.rb +216 -0
- data/lib/openapi_client/models/update_user_request.rb +232 -0
- data/lib/openapi_client/models/user_event_info.rb +285 -0
- data/lib/openapi_client/models/user_info.rb +470 -0
- data/lib/openapi_client/models/user_metadata_field.rb +323 -0
- data/lib/openapi_client/models/user_metadata_field_type.rb +44 -0
- data/lib/openapi_client/models/user_response.rb +221 -0
- data/lib/openapi_client/models/user_status.rb +41 -0
- data/lib/openapi_client/models/web_authn_devices.rb +378 -0
- data/lib/openapi_client/models/web_authn_icons.rb +230 -0
- data/lib/openapi_client/models/web_authn_type.rb +41 -0
- data/lib/openapi_client/version.rb +15 -0
- data/lib/openapi_client.rb +74 -0
- data/lib/passageidentity/auth.rb +32 -5
- data/lib/passageidentity/client.rb +17 -121
- data/lib/passageidentity/user_api.rb +29 -131
- data/lib/passageidentity/version.rb +5 -0
- data/openapitools.json +7 -0
- data/passageidentity.gemspec +3 -1
- data/tests/auth_test.rb +6 -1
- data/tests/magic_link_test.rb +5 -4
- data/tests/user_api_test.rb +2 -2
- metadata +96 -2
@@ -0,0 +1,285 @@
|
|
1
|
+
=begin
|
2
|
+
#Passage Management API
|
3
|
+
|
4
|
+
#Passage's management API to manage your Passage apps and users.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1
|
7
|
+
Contact: support@passage.id
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.1.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module OpenapiClient
|
17
|
+
class LayoutConfig
|
18
|
+
attr_accessor :h
|
19
|
+
|
20
|
+
attr_accessor :id
|
21
|
+
|
22
|
+
attr_accessor :w
|
23
|
+
|
24
|
+
attr_accessor :x
|
25
|
+
|
26
|
+
attr_accessor :y
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'h' => :'h',
|
32
|
+
:'id' => :'id',
|
33
|
+
:'w' => :'w',
|
34
|
+
:'x' => :'x',
|
35
|
+
:'y' => :'y'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns all the JSON keys this model knows about
|
40
|
+
def self.acceptable_attributes
|
41
|
+
attribute_map.values
|
42
|
+
end
|
43
|
+
|
44
|
+
# Attribute type mapping.
|
45
|
+
def self.openapi_types
|
46
|
+
{
|
47
|
+
:'h' => :'Integer',
|
48
|
+
:'id' => :'String',
|
49
|
+
:'w' => :'Integer',
|
50
|
+
:'x' => :'Integer',
|
51
|
+
:'y' => :'Integer'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# List of attributes with nullable: true
|
56
|
+
def self.openapi_nullable
|
57
|
+
Set.new([
|
58
|
+
])
|
59
|
+
end
|
60
|
+
|
61
|
+
# Initializes the object
|
62
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
63
|
+
def initialize(attributes = {})
|
64
|
+
if (!attributes.is_a?(Hash))
|
65
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::LayoutConfig` initialize method"
|
66
|
+
end
|
67
|
+
|
68
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
69
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
70
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
71
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::LayoutConfig`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
72
|
+
end
|
73
|
+
h[k.to_sym] = v
|
74
|
+
}
|
75
|
+
|
76
|
+
if attributes.key?(:'h')
|
77
|
+
self.h = attributes[:'h']
|
78
|
+
else
|
79
|
+
self.h = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'id')
|
83
|
+
self.id = attributes[:'id']
|
84
|
+
else
|
85
|
+
self.id = nil
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.key?(:'w')
|
89
|
+
self.w = attributes[:'w']
|
90
|
+
else
|
91
|
+
self.w = nil
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'x')
|
95
|
+
self.x = attributes[:'x']
|
96
|
+
else
|
97
|
+
self.x = nil
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.key?(:'y')
|
101
|
+
self.y = attributes[:'y']
|
102
|
+
else
|
103
|
+
self.y = nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
108
|
+
# @return Array for valid properties with the reasons
|
109
|
+
def list_invalid_properties
|
110
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
111
|
+
invalid_properties = Array.new
|
112
|
+
if @h.nil?
|
113
|
+
invalid_properties.push('invalid value for "h", h cannot be nil.')
|
114
|
+
end
|
115
|
+
|
116
|
+
if @id.nil?
|
117
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
118
|
+
end
|
119
|
+
|
120
|
+
if @w.nil?
|
121
|
+
invalid_properties.push('invalid value for "w", w cannot be nil.')
|
122
|
+
end
|
123
|
+
|
124
|
+
if @x.nil?
|
125
|
+
invalid_properties.push('invalid value for "x", x cannot be nil.')
|
126
|
+
end
|
127
|
+
|
128
|
+
if @y.nil?
|
129
|
+
invalid_properties.push('invalid value for "y", y cannot be nil.')
|
130
|
+
end
|
131
|
+
|
132
|
+
invalid_properties
|
133
|
+
end
|
134
|
+
|
135
|
+
# Check to see if the all the properties in the model are valid
|
136
|
+
# @return true if the model is valid
|
137
|
+
def valid?
|
138
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
139
|
+
return false if @h.nil?
|
140
|
+
return false if @id.nil?
|
141
|
+
return false if @w.nil?
|
142
|
+
return false if @x.nil?
|
143
|
+
return false if @y.nil?
|
144
|
+
true
|
145
|
+
end
|
146
|
+
|
147
|
+
# Checks equality by comparing each attribute.
|
148
|
+
# @param [Object] Object to be compared
|
149
|
+
def ==(o)
|
150
|
+
return true if self.equal?(o)
|
151
|
+
self.class == o.class &&
|
152
|
+
h == o.h &&
|
153
|
+
id == o.id &&
|
154
|
+
w == o.w &&
|
155
|
+
x == o.x &&
|
156
|
+
y == o.y
|
157
|
+
end
|
158
|
+
|
159
|
+
# @see the `==` method
|
160
|
+
# @param [Object] Object to be compared
|
161
|
+
def eql?(o)
|
162
|
+
self == o
|
163
|
+
end
|
164
|
+
|
165
|
+
# Calculates hash code according to all attributes.
|
166
|
+
# @return [Integer] Hash code
|
167
|
+
def hash
|
168
|
+
[h, id, w, x, y].hash
|
169
|
+
end
|
170
|
+
|
171
|
+
# Builds the object from hash
|
172
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
173
|
+
# @return [Object] Returns the model itself
|
174
|
+
def self.build_from_hash(attributes)
|
175
|
+
return nil unless attributes.is_a?(Hash)
|
176
|
+
attributes = attributes.transform_keys(&:to_sym)
|
177
|
+
transformed_hash = {}
|
178
|
+
openapi_types.each_pair do |key, type|
|
179
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
180
|
+
transformed_hash["#{key}"] = nil
|
181
|
+
elsif type =~ /\AArray<(.*)>/i
|
182
|
+
# check to ensure the input is an array given that the attribute
|
183
|
+
# is documented as an array but the input is not
|
184
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
185
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
186
|
+
end
|
187
|
+
elsif !attributes[attribute_map[key]].nil?
|
188
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
189
|
+
end
|
190
|
+
end
|
191
|
+
new(transformed_hash)
|
192
|
+
end
|
193
|
+
|
194
|
+
# Deserializes the data based on type
|
195
|
+
# @param string type Data type
|
196
|
+
# @param string value Value to be deserialized
|
197
|
+
# @return [Object] Deserialized data
|
198
|
+
def self._deserialize(type, value)
|
199
|
+
case type.to_sym
|
200
|
+
when :Time
|
201
|
+
Time.parse(value)
|
202
|
+
when :Date
|
203
|
+
Date.parse(value)
|
204
|
+
when :String
|
205
|
+
value.to_s
|
206
|
+
when :Integer
|
207
|
+
value.to_i
|
208
|
+
when :Float
|
209
|
+
value.to_f
|
210
|
+
when :Boolean
|
211
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
212
|
+
true
|
213
|
+
else
|
214
|
+
false
|
215
|
+
end
|
216
|
+
when :Object
|
217
|
+
# generic object (usually a Hash), return directly
|
218
|
+
value
|
219
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
220
|
+
inner_type = Regexp.last_match[:inner_type]
|
221
|
+
value.map { |v| _deserialize(inner_type, v) }
|
222
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
223
|
+
k_type = Regexp.last_match[:k_type]
|
224
|
+
v_type = Regexp.last_match[:v_type]
|
225
|
+
{}.tap do |hash|
|
226
|
+
value.each do |k, v|
|
227
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
else # model
|
231
|
+
# models (e.g. Pet) or oneOf
|
232
|
+
klass = OpenapiClient.const_get(type)
|
233
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# Returns the string representation of the object
|
238
|
+
# @return [String] String presentation of the object
|
239
|
+
def to_s
|
240
|
+
to_hash.to_s
|
241
|
+
end
|
242
|
+
|
243
|
+
# to_body is an alias to to_hash (backward compatibility)
|
244
|
+
# @return [Hash] Returns the object in the form of hash
|
245
|
+
def to_body
|
246
|
+
to_hash
|
247
|
+
end
|
248
|
+
|
249
|
+
# Returns the object in the form of hash
|
250
|
+
# @return [Hash] Returns the object in the form of hash
|
251
|
+
def to_hash
|
252
|
+
hash = {}
|
253
|
+
self.class.attribute_map.each_pair do |attr, param|
|
254
|
+
value = self.send(attr)
|
255
|
+
if value.nil?
|
256
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
257
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
258
|
+
end
|
259
|
+
|
260
|
+
hash[param] = _to_hash(value)
|
261
|
+
end
|
262
|
+
hash
|
263
|
+
end
|
264
|
+
|
265
|
+
# Outputs non-array value in the form of hash
|
266
|
+
# For object, use to_hash. Otherwise, just return the value
|
267
|
+
# @param [Object] value Any valid value
|
268
|
+
# @return [Hash] Returns the value in the form of hash
|
269
|
+
def _to_hash(value)
|
270
|
+
if value.is_a?(Array)
|
271
|
+
value.compact.map { |v| _to_hash(v) }
|
272
|
+
elsif value.is_a?(Hash)
|
273
|
+
{}.tap do |hash|
|
274
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
275
|
+
end
|
276
|
+
elsif value.respond_to? :to_hash
|
277
|
+
value.to_hash
|
278
|
+
else
|
279
|
+
value
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
=begin
|
2
|
+
#Passage Management API
|
3
|
+
|
4
|
+
#Passage's management API to manage your Passage apps and users.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1
|
7
|
+
Contact: support@passage.id
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.1.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module OpenapiClient
|
17
|
+
class Layouts
|
18
|
+
attr_accessor :profile
|
19
|
+
|
20
|
+
attr_accessor :registration
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'profile' => :'profile',
|
26
|
+
:'registration' => :'registration'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'profile' => :'Array<LayoutConfig>',
|
39
|
+
:'registration' => :'Array<LayoutConfig>'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
])
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
if (!attributes.is_a?(Hash))
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Layouts` initialize method"
|
54
|
+
end
|
55
|
+
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Layouts`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
60
|
+
end
|
61
|
+
h[k.to_sym] = v
|
62
|
+
}
|
63
|
+
|
64
|
+
if attributes.key?(:'profile')
|
65
|
+
if (value = attributes[:'profile']).is_a?(Array)
|
66
|
+
self.profile = value
|
67
|
+
end
|
68
|
+
else
|
69
|
+
self.profile = nil
|
70
|
+
end
|
71
|
+
|
72
|
+
if attributes.key?(:'registration')
|
73
|
+
if (value = attributes[:'registration']).is_a?(Array)
|
74
|
+
self.registration = value
|
75
|
+
end
|
76
|
+
else
|
77
|
+
self.registration = nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
82
|
+
# @return Array for valid properties with the reasons
|
83
|
+
def list_invalid_properties
|
84
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
85
|
+
invalid_properties = Array.new
|
86
|
+
if @profile.nil?
|
87
|
+
invalid_properties.push('invalid value for "profile", profile cannot be nil.')
|
88
|
+
end
|
89
|
+
|
90
|
+
if @registration.nil?
|
91
|
+
invalid_properties.push('invalid value for "registration", registration cannot be nil.')
|
92
|
+
end
|
93
|
+
|
94
|
+
invalid_properties
|
95
|
+
end
|
96
|
+
|
97
|
+
# Check to see if the all the properties in the model are valid
|
98
|
+
# @return true if the model is valid
|
99
|
+
def valid?
|
100
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
101
|
+
return false if @profile.nil?
|
102
|
+
return false if @registration.nil?
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
106
|
+
# Checks equality by comparing each attribute.
|
107
|
+
# @param [Object] Object to be compared
|
108
|
+
def ==(o)
|
109
|
+
return true if self.equal?(o)
|
110
|
+
self.class == o.class &&
|
111
|
+
profile == o.profile &&
|
112
|
+
registration == o.registration
|
113
|
+
end
|
114
|
+
|
115
|
+
# @see the `==` method
|
116
|
+
# @param [Object] Object to be compared
|
117
|
+
def eql?(o)
|
118
|
+
self == o
|
119
|
+
end
|
120
|
+
|
121
|
+
# Calculates hash code according to all attributes.
|
122
|
+
# @return [Integer] Hash code
|
123
|
+
def hash
|
124
|
+
[profile, registration].hash
|
125
|
+
end
|
126
|
+
|
127
|
+
# Builds the object from hash
|
128
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
129
|
+
# @return [Object] Returns the model itself
|
130
|
+
def self.build_from_hash(attributes)
|
131
|
+
return nil unless attributes.is_a?(Hash)
|
132
|
+
attributes = attributes.transform_keys(&:to_sym)
|
133
|
+
transformed_hash = {}
|
134
|
+
openapi_types.each_pair do |key, type|
|
135
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
136
|
+
transformed_hash["#{key}"] = nil
|
137
|
+
elsif type =~ /\AArray<(.*)>/i
|
138
|
+
# check to ensure the input is an array given that the attribute
|
139
|
+
# is documented as an array but the input is not
|
140
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
141
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
142
|
+
end
|
143
|
+
elsif !attributes[attribute_map[key]].nil?
|
144
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
145
|
+
end
|
146
|
+
end
|
147
|
+
new(transformed_hash)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Deserializes the data based on type
|
151
|
+
# @param string type Data type
|
152
|
+
# @param string value Value to be deserialized
|
153
|
+
# @return [Object] Deserialized data
|
154
|
+
def self._deserialize(type, value)
|
155
|
+
case type.to_sym
|
156
|
+
when :Time
|
157
|
+
Time.parse(value)
|
158
|
+
when :Date
|
159
|
+
Date.parse(value)
|
160
|
+
when :String
|
161
|
+
value.to_s
|
162
|
+
when :Integer
|
163
|
+
value.to_i
|
164
|
+
when :Float
|
165
|
+
value.to_f
|
166
|
+
when :Boolean
|
167
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
168
|
+
true
|
169
|
+
else
|
170
|
+
false
|
171
|
+
end
|
172
|
+
when :Object
|
173
|
+
# generic object (usually a Hash), return directly
|
174
|
+
value
|
175
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
176
|
+
inner_type = Regexp.last_match[:inner_type]
|
177
|
+
value.map { |v| _deserialize(inner_type, v) }
|
178
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
179
|
+
k_type = Regexp.last_match[:k_type]
|
180
|
+
v_type = Regexp.last_match[:v_type]
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each do |k, v|
|
183
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
else # model
|
187
|
+
# models (e.g. Pet) or oneOf
|
188
|
+
klass = OpenapiClient.const_get(type)
|
189
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Returns the string representation of the object
|
194
|
+
# @return [String] String presentation of the object
|
195
|
+
def to_s
|
196
|
+
to_hash.to_s
|
197
|
+
end
|
198
|
+
|
199
|
+
# to_body is an alias to to_hash (backward compatibility)
|
200
|
+
# @return [Hash] Returns the object in the form of hash
|
201
|
+
def to_body
|
202
|
+
to_hash
|
203
|
+
end
|
204
|
+
|
205
|
+
# Returns the object in the form of hash
|
206
|
+
# @return [Hash] Returns the object in the form of hash
|
207
|
+
def to_hash
|
208
|
+
hash = {}
|
209
|
+
self.class.attribute_map.each_pair do |attr, param|
|
210
|
+
value = self.send(attr)
|
211
|
+
if value.nil?
|
212
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
213
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
214
|
+
end
|
215
|
+
|
216
|
+
hash[param] = _to_hash(value)
|
217
|
+
end
|
218
|
+
hash
|
219
|
+
end
|
220
|
+
|
221
|
+
# Outputs non-array value in the form of hash
|
222
|
+
# For object, use to_hash. Otherwise, just return the value
|
223
|
+
# @param [Object] value Any valid value
|
224
|
+
# @return [Hash] Returns the value in the form of hash
|
225
|
+
def _to_hash(value)
|
226
|
+
if value.is_a?(Array)
|
227
|
+
value.compact.map { |v| _to_hash(v) }
|
228
|
+
elsif value.is_a?(Hash)
|
229
|
+
{}.tap do |hash|
|
230
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
231
|
+
end
|
232
|
+
elsif value.respond_to? :to_hash
|
233
|
+
value.to_hash
|
234
|
+
else
|
235
|
+
value
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|