gopad 1.0.0 → 1.1.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 +15 -0
- data/README.md +3 -3
- data/lib/gopad/api/auth_api.rb +177 -0
- data/lib/gopad/api/profile_api.rb +198 -0
- data/lib/gopad/api/team_api.rb +25 -25
- data/lib/gopad/api/user_api.rb +21 -21
- data/lib/gopad/configuration.rb +14 -7
- data/lib/gopad/models/auth_login.rb +231 -0
- data/lib/gopad/models/auth_token.rb +227 -0
- data/lib/gopad/models/auth_verify.rb +227 -0
- data/lib/gopad/models/profile.rb +297 -0
- data/lib/gopad/models/team_user_params.rb +5 -3
- data/lib/gopad/models/user_team.rb +5 -3
- data/lib/gopad/models/user_team_params.rb +5 -3
- data/lib/gopad/version.rb +1 -1
- data/lib/gopad.rb +5 -0
- metadata +19 -20
data/lib/gopad/api/user_api.rb
CHANGED
@@ -72,7 +72,7 @@ module Gopad
|
|
72
72
|
return_type = opts[:debug_return_type] || 'Notification'
|
73
73
|
|
74
74
|
# auth_names
|
75
|
-
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header]
|
75
|
+
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header Bearer]
|
76
76
|
|
77
77
|
new_options = opts.merge(
|
78
78
|
operation: :'UserApi.attach_user_to_team',
|
@@ -139,7 +139,7 @@ module Gopad
|
|
139
139
|
return_type = opts[:debug_return_type] || 'User'
|
140
140
|
|
141
141
|
# auth_names
|
142
|
-
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header]
|
142
|
+
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header Bearer]
|
143
143
|
|
144
144
|
new_options = opts.merge(
|
145
145
|
operation: :'UserApi.create_user',
|
@@ -201,7 +201,7 @@ module Gopad
|
|
201
201
|
return_type = opts[:debug_return_type] || 'Notification'
|
202
202
|
|
203
203
|
# auth_names
|
204
|
-
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header]
|
204
|
+
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header Bearer]
|
205
205
|
|
206
206
|
new_options = opts.merge(
|
207
207
|
operation: :'UserApi.delete_user',
|
@@ -274,7 +274,7 @@ module Gopad
|
|
274
274
|
return_type = opts[:debug_return_type] || 'Notification'
|
275
275
|
|
276
276
|
# auth_names
|
277
|
-
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header]
|
277
|
+
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header Bearer]
|
278
278
|
|
279
279
|
new_options = opts.merge(
|
280
280
|
operation: :'UserApi.delete_user_from_team',
|
@@ -297,8 +297,8 @@ module Gopad
|
|
297
297
|
# @param user_id [String] A user identifier or slug
|
298
298
|
# @param [Hash] opts the optional parameters
|
299
299
|
# @option opts [String] :search Search query
|
300
|
-
# @option opts [String] :sort Sorting column
|
301
|
-
# @option opts [String] :order Sorting order
|
300
|
+
# @option opts [String] :sort Sorting column (default to 'name')
|
301
|
+
# @option opts [String] :order Sorting order (default to 'asc')
|
302
302
|
# @option opts [Integer] :limit Paging limit
|
303
303
|
# @option opts [Integer] :offset Paging offset
|
304
304
|
# @return [UserTeams]
|
@@ -311,8 +311,8 @@ module Gopad
|
|
311
311
|
# @param user_id [String] A user identifier or slug
|
312
312
|
# @param [Hash] opts the optional parameters
|
313
313
|
# @option opts [String] :search Search query
|
314
|
-
# @option opts [String] :sort Sorting column
|
315
|
-
# @option opts [String] :order Sorting order
|
314
|
+
# @option opts [String] :sort Sorting column (default to 'name')
|
315
|
+
# @option opts [String] :order Sorting order (default to 'asc')
|
316
316
|
# @option opts [Integer] :limit Paging limit
|
317
317
|
# @option opts [Integer] :offset Paging offset
|
318
318
|
# @return [Array<(UserTeams, Integer, Hash)>] UserTeams data, response status code and response headers
|
@@ -361,7 +361,7 @@ module Gopad
|
|
361
361
|
return_type = opts[:debug_return_type] || 'UserTeams'
|
362
362
|
|
363
363
|
# auth_names
|
364
|
-
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header]
|
364
|
+
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header Bearer]
|
365
365
|
|
366
366
|
new_options = opts.merge(
|
367
367
|
operation: :'UserApi.list_user_teams',
|
@@ -383,10 +383,10 @@ module Gopad
|
|
383
383
|
# Fetch all available users
|
384
384
|
# @param [Hash] opts the optional parameters
|
385
385
|
# @option opts [String] :search Search query
|
386
|
-
# @option opts [String] :sort Sorting column
|
387
|
-
# @option opts [String] :order Sorting order
|
388
|
-
# @option opts [Integer] :limit Paging limit
|
389
|
-
# @option opts [Integer] :offset Paging offset
|
386
|
+
# @option opts [String] :sort Sorting column (default to 'username')
|
387
|
+
# @option opts [String] :order Sorting order (default to 'asc')
|
388
|
+
# @option opts [Integer] :limit Paging limit (default to 100)
|
389
|
+
# @option opts [Integer] :offset Paging offset (default to 0)
|
390
390
|
# @return [Users]
|
391
391
|
def list_users(opts = {})
|
392
392
|
data, _status_code, _headers = list_users_with_http_info(opts)
|
@@ -396,10 +396,10 @@ module Gopad
|
|
396
396
|
# Fetch all available users
|
397
397
|
# @param [Hash] opts the optional parameters
|
398
398
|
# @option opts [String] :search Search query
|
399
|
-
# @option opts [String] :sort Sorting column
|
400
|
-
# @option opts [String] :order Sorting order
|
401
|
-
# @option opts [Integer] :limit Paging limit
|
402
|
-
# @option opts [Integer] :offset Paging offset
|
399
|
+
# @option opts [String] :sort Sorting column (default to 'username')
|
400
|
+
# @option opts [String] :order Sorting order (default to 'asc')
|
401
|
+
# @option opts [Integer] :limit Paging limit (default to 100)
|
402
|
+
# @option opts [Integer] :offset Paging offset (default to 0)
|
403
403
|
# @return [Array<(Users, Integer, Hash)>] Users data, response status code and response headers
|
404
404
|
def list_users_with_http_info(opts = {})
|
405
405
|
if @api_client.config.debugging
|
@@ -441,7 +441,7 @@ module Gopad
|
|
441
441
|
return_type = opts[:debug_return_type] || 'Users'
|
442
442
|
|
443
443
|
# auth_names
|
444
|
-
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header]
|
444
|
+
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header Bearer]
|
445
445
|
|
446
446
|
new_options = opts.merge(
|
447
447
|
operation: :'UserApi.list_users',
|
@@ -514,7 +514,7 @@ module Gopad
|
|
514
514
|
return_type = opts[:debug_return_type] || 'Notification'
|
515
515
|
|
516
516
|
# auth_names
|
517
|
-
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header]
|
517
|
+
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header Bearer]
|
518
518
|
|
519
519
|
new_options = opts.merge(
|
520
520
|
operation: :'UserApi.permit_user_team',
|
@@ -576,7 +576,7 @@ module Gopad
|
|
576
576
|
return_type = opts[:debug_return_type] || 'User'
|
577
577
|
|
578
578
|
# auth_names
|
579
|
-
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header]
|
579
|
+
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header Bearer]
|
580
580
|
|
581
581
|
new_options = opts.merge(
|
582
582
|
operation: :'UserApi.show_user',
|
@@ -649,7 +649,7 @@ module Gopad
|
|
649
649
|
return_type = opts[:debug_return_type] || 'User'
|
650
650
|
|
651
651
|
# auth_names
|
652
|
-
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header]
|
652
|
+
auth_names = opts[:debug_auth_names] || %w[Cookie Basic Header Bearer]
|
653
653
|
|
654
654
|
new_options = opts.merge(
|
655
655
|
operation: :'UserApi.update_user',
|
data/lib/gopad/configuration.rb
CHANGED
@@ -234,13 +234,6 @@ module Gopad
|
|
234
234
|
# Returns Auth Settings hash for api client.
|
235
235
|
def auth_settings
|
236
236
|
{
|
237
|
-
'Cookie' =>
|
238
|
-
{
|
239
|
-
type: 'api_key',
|
240
|
-
in: 'header',
|
241
|
-
key: 'Cookie',
|
242
|
-
value: api_key_with_prefix('Cookie')
|
243
|
-
},
|
244
237
|
'Header' =>
|
245
238
|
{
|
246
239
|
type: 'api_key',
|
@@ -248,12 +241,26 @@ module Gopad
|
|
248
241
|
key: 'X-API-Key',
|
249
242
|
value: api_key_with_prefix('Header')
|
250
243
|
},
|
244
|
+
'Bearer' =>
|
245
|
+
{
|
246
|
+
type: 'bearer',
|
247
|
+
in: 'header',
|
248
|
+
key: 'Authorization',
|
249
|
+
value: "Bearer #{access_token_with_refresh}"
|
250
|
+
},
|
251
251
|
'Basic' =>
|
252
252
|
{
|
253
253
|
type: 'basic',
|
254
254
|
in: 'header',
|
255
255
|
key: 'Authorization',
|
256
256
|
value: basic_auth_token
|
257
|
+
},
|
258
|
+
'Cookie' =>
|
259
|
+
{
|
260
|
+
type: 'api_key',
|
261
|
+
in: 'header',
|
262
|
+
key: 'Cookie',
|
263
|
+
value: api_key_with_prefix('Cookie')
|
257
264
|
}
|
258
265
|
}
|
259
266
|
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
# Gopad OpenAPI
|
2
|
+
#
|
3
|
+
# API definition for Gopad, Etherpad for markdown with go
|
4
|
+
#
|
5
|
+
# The version of the OpenAPI document: 1.0.0-alpha1
|
6
|
+
# Contact: gopad@webhippie.de
|
7
|
+
# Generated by: https://openapi-generator.tech
|
8
|
+
# Generator version: 7.6.0
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'date'
|
12
|
+
require 'time'
|
13
|
+
|
14
|
+
module Gopad
|
15
|
+
class AuthLogin
|
16
|
+
attr_accessor :username, :password
|
17
|
+
|
18
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
19
|
+
def self.attribute_map
|
20
|
+
{
|
21
|
+
username: :username,
|
22
|
+
password: :password
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns all the JSON keys this model knows about
|
27
|
+
def self.acceptable_attributes
|
28
|
+
attribute_map.values
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attribute type mapping.
|
32
|
+
def self.openapi_types
|
33
|
+
{
|
34
|
+
username: :String,
|
35
|
+
password: :String
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# List of attributes with nullable: true
|
40
|
+
def self.openapi_nullable
|
41
|
+
Set.new([
|
42
|
+
])
|
43
|
+
end
|
44
|
+
|
45
|
+
# Initializes the object
|
46
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
+
def initialize(attributes = {})
|
48
|
+
unless attributes.is_a?(Hash)
|
49
|
+
raise ArgumentError, 'The input argument (attributes) must be a hash in `Gopad::AuthLogin` initialize method'
|
50
|
+
end
|
51
|
+
|
52
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
53
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
54
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
55
|
+
raise ArgumentError, "`#{k}` is not a valid attribute in `Gopad::AuthLogin`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
56
|
+
end
|
57
|
+
|
58
|
+
h[k.to_sym] = v
|
59
|
+
end
|
60
|
+
|
61
|
+
self.username = if attributes.key?(:username)
|
62
|
+
attributes[:username]
|
63
|
+
end
|
64
|
+
|
65
|
+
self.password = if attributes.key?(:password)
|
66
|
+
attributes[:password]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
71
|
+
# @return Array for valid properties with the reasons
|
72
|
+
def list_invalid_properties
|
73
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
74
|
+
invalid_properties = []
|
75
|
+
if @username.nil?
|
76
|
+
invalid_properties.push('invalid value for "username", username cannot be nil.')
|
77
|
+
end
|
78
|
+
|
79
|
+
if @password.nil?
|
80
|
+
invalid_properties.push('invalid value for "password", password cannot be nil.')
|
81
|
+
end
|
82
|
+
|
83
|
+
invalid_properties
|
84
|
+
end
|
85
|
+
|
86
|
+
# Check to see if the all the properties in the model are valid
|
87
|
+
# @return true if the model is valid
|
88
|
+
def valid?
|
89
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
90
|
+
return false if @username.nil?
|
91
|
+
return false if @password.nil?
|
92
|
+
|
93
|
+
true
|
94
|
+
end
|
95
|
+
|
96
|
+
# Checks equality by comparing each attribute.
|
97
|
+
# @param [Object] Object to be compared
|
98
|
+
def ==(other)
|
99
|
+
return true if equal?(other)
|
100
|
+
|
101
|
+
self.class == other.class &&
|
102
|
+
username == other.username &&
|
103
|
+
password == other.password
|
104
|
+
end
|
105
|
+
|
106
|
+
# @see the `==` method
|
107
|
+
# @param [Object] Object to be compared
|
108
|
+
def eql?(other)
|
109
|
+
self == other
|
110
|
+
end
|
111
|
+
|
112
|
+
# Calculates hash code according to all attributes.
|
113
|
+
# @return [Integer] Hash code
|
114
|
+
def hash
|
115
|
+
[username, password].hash
|
116
|
+
end
|
117
|
+
|
118
|
+
# Builds the object from hash
|
119
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
120
|
+
# @return [Object] Returns the model itself
|
121
|
+
def self.build_from_hash(attributes)
|
122
|
+
return nil unless attributes.is_a?(Hash)
|
123
|
+
|
124
|
+
attributes = attributes.transform_keys(&:to_sym)
|
125
|
+
transformed_hash = {}
|
126
|
+
openapi_types.each_pair do |key, type|
|
127
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
128
|
+
transformed_hash[key.to_s] = nil
|
129
|
+
elsif type =~ /\AArray<(.*)>/i
|
130
|
+
# check to ensure the input is an array given that the attribute
|
131
|
+
# is documented as an array but the input is not
|
132
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
133
|
+
transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
134
|
+
end
|
135
|
+
elsif !attributes[attribute_map[key]].nil?
|
136
|
+
transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
|
137
|
+
end
|
138
|
+
end
|
139
|
+
new(transformed_hash)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Deserializes the data based on type
|
143
|
+
# @param string type Data type
|
144
|
+
# @param string value Value to be deserialized
|
145
|
+
# @return [Object] Deserialized data
|
146
|
+
def self._deserialize(type, value)
|
147
|
+
case type.to_sym
|
148
|
+
when :Time
|
149
|
+
Time.parse(value)
|
150
|
+
when :Date
|
151
|
+
Date.parse(value)
|
152
|
+
when :String
|
153
|
+
value.to_s
|
154
|
+
when :Integer
|
155
|
+
value.to_i
|
156
|
+
when :Float
|
157
|
+
value.to_f
|
158
|
+
when :Boolean
|
159
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
160
|
+
true
|
161
|
+
else
|
162
|
+
false
|
163
|
+
end
|
164
|
+
when :Object
|
165
|
+
# generic object (usually a Hash), return directly
|
166
|
+
value
|
167
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
168
|
+
inner_type = Regexp.last_match[:inner_type]
|
169
|
+
value.map { |v| _deserialize(inner_type, v) }
|
170
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
171
|
+
k_type = Regexp.last_match[:k_type]
|
172
|
+
v_type = Regexp.last_match[:v_type]
|
173
|
+
{}.tap do |hash|
|
174
|
+
value.each do |k, v|
|
175
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
else # model
|
179
|
+
# models (e.g. Pet) or oneOf
|
180
|
+
klass = Gopad.const_get(type)
|
181
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Returns the string representation of the object
|
186
|
+
# @return [String] String presentation of the object
|
187
|
+
def to_s
|
188
|
+
to_hash.to_s
|
189
|
+
end
|
190
|
+
|
191
|
+
# to_body is an alias to to_hash (backward compatibility)
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
193
|
+
def to_body
|
194
|
+
to_hash
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the object in the form of hash
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_hash
|
200
|
+
hash = {}
|
201
|
+
self.class.attribute_map.each_pair do |attr, param|
|
202
|
+
value = send(attr)
|
203
|
+
if value.nil?
|
204
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
205
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
206
|
+
end
|
207
|
+
|
208
|
+
hash[param] = _to_hash(value)
|
209
|
+
end
|
210
|
+
hash
|
211
|
+
end
|
212
|
+
|
213
|
+
# Outputs non-array value in the form of hash
|
214
|
+
# For object, use to_hash. Otherwise, just return the value
|
215
|
+
# @param [Object] value Any valid value
|
216
|
+
# @return [Hash] Returns the value in the form of hash
|
217
|
+
def _to_hash(value)
|
218
|
+
if value.is_a?(Array)
|
219
|
+
value.compact.map { |v| _to_hash(v) }
|
220
|
+
elsif value.is_a?(Hash)
|
221
|
+
{}.tap do |hash|
|
222
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
223
|
+
end
|
224
|
+
elsif value.respond_to? :to_hash
|
225
|
+
value.to_hash
|
226
|
+
else
|
227
|
+
value
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# Gopad OpenAPI
|
2
|
+
#
|
3
|
+
# API definition for Gopad, Etherpad for markdown with go
|
4
|
+
#
|
5
|
+
# The version of the OpenAPI document: 1.0.0-alpha1
|
6
|
+
# Contact: gopad@webhippie.de
|
7
|
+
# Generated by: https://openapi-generator.tech
|
8
|
+
# Generator version: 7.6.0
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'date'
|
12
|
+
require 'time'
|
13
|
+
|
14
|
+
module Gopad
|
15
|
+
class AuthToken
|
16
|
+
attr_accessor :token, :expires_at
|
17
|
+
|
18
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
19
|
+
def self.attribute_map
|
20
|
+
{
|
21
|
+
token: :token,
|
22
|
+
expires_at: :expires_at
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns all the JSON keys this model knows about
|
27
|
+
def self.acceptable_attributes
|
28
|
+
attribute_map.values
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attribute type mapping.
|
32
|
+
def self.openapi_types
|
33
|
+
{
|
34
|
+
token: :String,
|
35
|
+
expires_at: :Time
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# List of attributes with nullable: true
|
40
|
+
def self.openapi_nullable
|
41
|
+
Set.new([
|
42
|
+
:expires_at
|
43
|
+
])
|
44
|
+
end
|
45
|
+
|
46
|
+
# Initializes the object
|
47
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
48
|
+
def initialize(attributes = {})
|
49
|
+
unless attributes.is_a?(Hash)
|
50
|
+
raise ArgumentError, 'The input argument (attributes) must be a hash in `Gopad::AuthToken` initialize method'
|
51
|
+
end
|
52
|
+
|
53
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
54
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
55
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
56
|
+
raise ArgumentError, "`#{k}` is not a valid attribute in `Gopad::AuthToken`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
57
|
+
end
|
58
|
+
|
59
|
+
h[k.to_sym] = v
|
60
|
+
end
|
61
|
+
|
62
|
+
self.token = if attributes.key?(:token)
|
63
|
+
attributes[:token]
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.key?(:expires_at)
|
67
|
+
self.expires_at = attributes[:expires_at]
|
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 = []
|
76
|
+
if @token.nil?
|
77
|
+
invalid_properties.push('invalid value for "token", token cannot be nil.')
|
78
|
+
end
|
79
|
+
|
80
|
+
invalid_properties
|
81
|
+
end
|
82
|
+
|
83
|
+
# Check to see if the all the properties in the model are valid
|
84
|
+
# @return true if the model is valid
|
85
|
+
def valid?
|
86
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
87
|
+
return false if @token.nil?
|
88
|
+
|
89
|
+
true
|
90
|
+
end
|
91
|
+
|
92
|
+
# Checks equality by comparing each attribute.
|
93
|
+
# @param [Object] Object to be compared
|
94
|
+
def ==(other)
|
95
|
+
return true if equal?(other)
|
96
|
+
|
97
|
+
self.class == other.class &&
|
98
|
+
token == other.token &&
|
99
|
+
expires_at == other.expires_at
|
100
|
+
end
|
101
|
+
|
102
|
+
# @see the `==` method
|
103
|
+
# @param [Object] Object to be compared
|
104
|
+
def eql?(other)
|
105
|
+
self == other
|
106
|
+
end
|
107
|
+
|
108
|
+
# Calculates hash code according to all attributes.
|
109
|
+
# @return [Integer] Hash code
|
110
|
+
def hash
|
111
|
+
[token, expires_at].hash
|
112
|
+
end
|
113
|
+
|
114
|
+
# Builds the object from hash
|
115
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
116
|
+
# @return [Object] Returns the model itself
|
117
|
+
def self.build_from_hash(attributes)
|
118
|
+
return nil unless attributes.is_a?(Hash)
|
119
|
+
|
120
|
+
attributes = attributes.transform_keys(&:to_sym)
|
121
|
+
transformed_hash = {}
|
122
|
+
openapi_types.each_pair do |key, type|
|
123
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
124
|
+
transformed_hash[key.to_s] = nil
|
125
|
+
elsif type =~ /\AArray<(.*)>/i
|
126
|
+
# check to ensure the input is an array given that the attribute
|
127
|
+
# is documented as an array but the input is not
|
128
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
129
|
+
transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
130
|
+
end
|
131
|
+
elsif !attributes[attribute_map[key]].nil?
|
132
|
+
transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
|
133
|
+
end
|
134
|
+
end
|
135
|
+
new(transformed_hash)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Deserializes the data based on type
|
139
|
+
# @param string type Data type
|
140
|
+
# @param string value Value to be deserialized
|
141
|
+
# @return [Object] Deserialized data
|
142
|
+
def self._deserialize(type, value)
|
143
|
+
case type.to_sym
|
144
|
+
when :Time
|
145
|
+
Time.parse(value)
|
146
|
+
when :Date
|
147
|
+
Date.parse(value)
|
148
|
+
when :String
|
149
|
+
value.to_s
|
150
|
+
when :Integer
|
151
|
+
value.to_i
|
152
|
+
when :Float
|
153
|
+
value.to_f
|
154
|
+
when :Boolean
|
155
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
156
|
+
true
|
157
|
+
else
|
158
|
+
false
|
159
|
+
end
|
160
|
+
when :Object
|
161
|
+
# generic object (usually a Hash), return directly
|
162
|
+
value
|
163
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
164
|
+
inner_type = Regexp.last_match[:inner_type]
|
165
|
+
value.map { |v| _deserialize(inner_type, v) }
|
166
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
167
|
+
k_type = Regexp.last_match[:k_type]
|
168
|
+
v_type = Regexp.last_match[:v_type]
|
169
|
+
{}.tap do |hash|
|
170
|
+
value.each do |k, v|
|
171
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
else # model
|
175
|
+
# models (e.g. Pet) or oneOf
|
176
|
+
klass = Gopad.const_get(type)
|
177
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# Returns the string representation of the object
|
182
|
+
# @return [String] String presentation of the object
|
183
|
+
def to_s
|
184
|
+
to_hash.to_s
|
185
|
+
end
|
186
|
+
|
187
|
+
# to_body is an alias to to_hash (backward compatibility)
|
188
|
+
# @return [Hash] Returns the object in the form of hash
|
189
|
+
def to_body
|
190
|
+
to_hash
|
191
|
+
end
|
192
|
+
|
193
|
+
# Returns the object in the form of hash
|
194
|
+
# @return [Hash] Returns the object in the form of hash
|
195
|
+
def to_hash
|
196
|
+
hash = {}
|
197
|
+
self.class.attribute_map.each_pair do |attr, param|
|
198
|
+
value = send(attr)
|
199
|
+
if value.nil?
|
200
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
201
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
202
|
+
end
|
203
|
+
|
204
|
+
hash[param] = _to_hash(value)
|
205
|
+
end
|
206
|
+
hash
|
207
|
+
end
|
208
|
+
|
209
|
+
# Outputs non-array value in the form of hash
|
210
|
+
# For object, use to_hash. Otherwise, just return the value
|
211
|
+
# @param [Object] value Any valid value
|
212
|
+
# @return [Hash] Returns the value in the form of hash
|
213
|
+
def _to_hash(value)
|
214
|
+
if value.is_a?(Array)
|
215
|
+
value.compact.map { |v| _to_hash(v) }
|
216
|
+
elsif value.is_a?(Hash)
|
217
|
+
{}.tap do |hash|
|
218
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
219
|
+
end
|
220
|
+
elsif value.respond_to? :to_hash
|
221
|
+
value.to_hash
|
222
|
+
else
|
223
|
+
value
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|