gopad 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,299 @@
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
+ # Model to represent user
16
+ class User
17
+ attr_accessor :id, :username, :password, :email, :fullname, :profile, :admin, :active, :created_at, :updated_at, :auths, :teams
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ id: :id,
23
+ username: :username,
24
+ password: :password,
25
+ email: :email,
26
+ fullname: :fullname,
27
+ profile: :profile,
28
+ admin: :admin,
29
+ active: :active,
30
+ created_at: :created_at,
31
+ updated_at: :updated_at,
32
+ auths: :auths,
33
+ teams: :teams
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ id: :String,
46
+ username: :String,
47
+ password: :String,
48
+ email: :String,
49
+ fullname: :String,
50
+ profile: :String,
51
+ admin: :Boolean,
52
+ active: :Boolean,
53
+ created_at: :Time,
54
+ updated_at: :Time,
55
+ auths: :'Array<UserAuth>',
56
+ teams: :'Array<UserTeam>'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new(%i[
63
+ username
64
+ password
65
+ email
66
+ fullname
67
+ profile
68
+ admin
69
+ active
70
+ auths
71
+ teams
72
+ ])
73
+ end
74
+
75
+ # Initializes the object
76
+ # @param [Hash] attributes Model attributes in the form of hash
77
+ def initialize(attributes = {})
78
+ unless attributes.is_a?(Hash)
79
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Gopad::User` initialize method'
80
+ end
81
+
82
+ # check to see if the attribute exists and convert string to symbol for hash key
83
+ attributes = attributes.each_with_object({}) do |(k, v), h|
84
+ unless self.class.attribute_map.key?(k.to_sym)
85
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Gopad::User`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
86
+ end
87
+
88
+ h[k.to_sym] = v
89
+ end
90
+
91
+ if attributes.key?(:id)
92
+ self.id = attributes[:id]
93
+ end
94
+
95
+ if attributes.key?(:username)
96
+ self.username = attributes[:username]
97
+ end
98
+
99
+ if attributes.key?(:password)
100
+ self.password = attributes[:password]
101
+ end
102
+
103
+ if attributes.key?(:email)
104
+ self.email = attributes[:email]
105
+ end
106
+
107
+ if attributes.key?(:fullname)
108
+ self.fullname = attributes[:fullname]
109
+ end
110
+
111
+ if attributes.key?(:profile)
112
+ self.profile = attributes[:profile]
113
+ end
114
+
115
+ if attributes.key?(:admin)
116
+ self.admin = attributes[:admin]
117
+ end
118
+
119
+ if attributes.key?(:active)
120
+ self.active = attributes[:active]
121
+ end
122
+
123
+ if attributes.key?(:created_at)
124
+ self.created_at = attributes[:created_at]
125
+ end
126
+
127
+ if attributes.key?(:updated_at)
128
+ self.updated_at = attributes[:updated_at]
129
+ end
130
+
131
+ if attributes.key?(:auths) && (value = attributes[:auths]).is_a?(Array)
132
+ self.auths = value
133
+ end
134
+
135
+ if attributes.key?(:teams) && (value = attributes[:teams]).is_a?(Array)
136
+ self.teams = value
137
+ end
138
+ end
139
+
140
+ # Show invalid properties with the reasons. Usually used together with valid?
141
+ # @return Array for valid properties with the reasons
142
+ def list_invalid_properties
143
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
144
+ []
145
+ end
146
+
147
+ # Check to see if the all the properties in the model are valid
148
+ # @return true if the model is valid
149
+ def valid?
150
+ warn '[DEPRECATED] the `valid?` method is obsolete'
151
+ true
152
+ end
153
+
154
+ # Checks equality by comparing each attribute.
155
+ # @param [Object] Object to be compared
156
+ def ==(other)
157
+ return true if equal?(other)
158
+
159
+ self.class == other.class &&
160
+ id == other.id &&
161
+ username == other.username &&
162
+ password == other.password &&
163
+ email == other.email &&
164
+ fullname == other.fullname &&
165
+ profile == other.profile &&
166
+ admin == other.admin &&
167
+ active == other.active &&
168
+ created_at == other.created_at &&
169
+ updated_at == other.updated_at &&
170
+ auths == other.auths &&
171
+ teams == other.teams
172
+ end
173
+
174
+ # @see the `==` method
175
+ # @param [Object] Object to be compared
176
+ def eql?(other)
177
+ self == other
178
+ end
179
+
180
+ # Calculates hash code according to all attributes.
181
+ # @return [Integer] Hash code
182
+ def hash
183
+ [id, username, password, email, fullname, profile, admin, active, created_at, updated_at, auths, teams].hash
184
+ end
185
+
186
+ # Builds the object from hash
187
+ # @param [Hash] attributes Model attributes in the form of hash
188
+ # @return [Object] Returns the model itself
189
+ def self.build_from_hash(attributes)
190
+ return nil unless attributes.is_a?(Hash)
191
+
192
+ attributes = attributes.transform_keys(&:to_sym)
193
+ transformed_hash = {}
194
+ openapi_types.each_pair do |key, type|
195
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
196
+ transformed_hash[key.to_s] = nil
197
+ elsif type =~ /\AArray<(.*)>/i
198
+ # check to ensure the input is an array given that the attribute
199
+ # is documented as an array but the input is not
200
+ if attributes[attribute_map[key]].is_a?(Array)
201
+ transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
202
+ end
203
+ elsif !attributes[attribute_map[key]].nil?
204
+ transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
205
+ end
206
+ end
207
+ new(transformed_hash)
208
+ end
209
+
210
+ # Deserializes the data based on type
211
+ # @param string type Data type
212
+ # @param string value Value to be deserialized
213
+ # @return [Object] Deserialized data
214
+ def self._deserialize(type, value)
215
+ case type.to_sym
216
+ when :Time
217
+ Time.parse(value)
218
+ when :Date
219
+ Date.parse(value)
220
+ when :String
221
+ value.to_s
222
+ when :Integer
223
+ value.to_i
224
+ when :Float
225
+ value.to_f
226
+ when :Boolean
227
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
228
+ true
229
+ else
230
+ false
231
+ end
232
+ when :Object
233
+ # generic object (usually a Hash), return directly
234
+ value
235
+ when /\AArray<(?<inner_type>.+)>\z/
236
+ inner_type = Regexp.last_match[:inner_type]
237
+ value.map { |v| _deserialize(inner_type, v) }
238
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
239
+ k_type = Regexp.last_match[:k_type]
240
+ v_type = Regexp.last_match[:v_type]
241
+ {}.tap do |hash|
242
+ value.each do |k, v|
243
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
244
+ end
245
+ end
246
+ else # model
247
+ # models (e.g. Pet) or oneOf
248
+ klass = Gopad.const_get(type)
249
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
250
+ end
251
+ end
252
+
253
+ # Returns the string representation of the object
254
+ # @return [String] String presentation of the object
255
+ def to_s
256
+ to_hash.to_s
257
+ end
258
+
259
+ # to_body is an alias to to_hash (backward compatibility)
260
+ # @return [Hash] Returns the object in the form of hash
261
+ def to_body
262
+ to_hash
263
+ end
264
+
265
+ # Returns the object in the form of hash
266
+ # @return [Hash] Returns the object in the form of hash
267
+ def to_hash
268
+ hash = {}
269
+ self.class.attribute_map.each_pair do |attr, param|
270
+ value = send(attr)
271
+ if value.nil?
272
+ is_nullable = self.class.openapi_nullable.include?(attr)
273
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
274
+ end
275
+
276
+ hash[param] = _to_hash(value)
277
+ end
278
+ hash
279
+ end
280
+
281
+ # Outputs non-array value in the form of hash
282
+ # For object, use to_hash. Otherwise, just return the value
283
+ # @param [Object] value Any valid value
284
+ # @return [Hash] Returns the value in the form of hash
285
+ def _to_hash(value)
286
+ if value.is_a?(Array)
287
+ value.compact.map { |v| _to_hash(v) }
288
+ elsif value.is_a?(Hash)
289
+ {}.tap do |hash|
290
+ value.each { |k, v| hash[k] = _to_hash(v) }
291
+ end
292
+ elsif value.respond_to? :to_hash
293
+ value.to_hash
294
+ else
295
+ value
296
+ end
297
+ end
298
+ end
299
+ end
@@ -0,0 +1,234 @@
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
+ # Model to represent user auth
16
+ class UserAuth
17
+ attr_accessor :provider, :ref, :created_at, :updated_at
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ provider: :provider,
23
+ ref: :ref,
24
+ created_at: :created_at,
25
+ updated_at: :updated_at
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ provider: :String,
38
+ ref: :String,
39
+ created_at: :Time,
40
+ updated_at: :Time
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ unless attributes.is_a?(Hash)
54
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Gopad::UserAuth` initialize method'
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) do |(k, v), h|
59
+ unless self.class.attribute_map.key?(k.to_sym)
60
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Gopad::UserAuth`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+
63
+ h[k.to_sym] = v
64
+ end
65
+
66
+ if attributes.key?(:provider)
67
+ self.provider = attributes[:provider]
68
+ end
69
+
70
+ if attributes.key?(:ref)
71
+ self.ref = attributes[:ref]
72
+ end
73
+
74
+ if attributes.key?(:created_at)
75
+ self.created_at = attributes[:created_at]
76
+ end
77
+
78
+ if attributes.key?(:updated_at)
79
+ self.updated_at = attributes[:updated_at]
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
87
+ []
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ warn '[DEPRECATED] the `valid?` method is obsolete'
94
+ true
95
+ end
96
+
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
99
+ def ==(other)
100
+ return true if equal?(other)
101
+
102
+ self.class == other.class &&
103
+ provider == other.provider &&
104
+ ref == other.ref &&
105
+ created_at == other.created_at &&
106
+ updated_at == other.updated_at
107
+ end
108
+
109
+ # @see the `==` method
110
+ # @param [Object] Object to be compared
111
+ def eql?(other)
112
+ self == other
113
+ end
114
+
115
+ # Calculates hash code according to all attributes.
116
+ # @return [Integer] Hash code
117
+ def hash
118
+ [provider, ref, created_at, updated_at].hash
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def self.build_from_hash(attributes)
125
+ return nil unless attributes.is_a?(Hash)
126
+
127
+ attributes = attributes.transform_keys(&:to_sym)
128
+ transformed_hash = {}
129
+ openapi_types.each_pair do |key, type|
130
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
131
+ transformed_hash[key.to_s] = nil
132
+ elsif type =~ /\AArray<(.*)>/i
133
+ # check to ensure the input is an array given that the attribute
134
+ # is documented as an array but the input is not
135
+ if attributes[attribute_map[key]].is_a?(Array)
136
+ transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
137
+ end
138
+ elsif !attributes[attribute_map[key]].nil?
139
+ transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
140
+ end
141
+ end
142
+ new(transformed_hash)
143
+ end
144
+
145
+ # Deserializes the data based on type
146
+ # @param string type Data type
147
+ # @param string value Value to be deserialized
148
+ # @return [Object] Deserialized data
149
+ def self._deserialize(type, value)
150
+ case type.to_sym
151
+ when :Time
152
+ Time.parse(value)
153
+ when :Date
154
+ Date.parse(value)
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :Boolean
162
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+ when :Object
168
+ # generic object (usually a Hash), return directly
169
+ value
170
+ when /\AArray<(?<inner_type>.+)>\z/
171
+ inner_type = Regexp.last_match[:inner_type]
172
+ value.map { |v| _deserialize(inner_type, v) }
173
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
174
+ k_type = Regexp.last_match[:k_type]
175
+ v_type = Regexp.last_match[:v_type]
176
+ {}.tap do |hash|
177
+ value.each do |k, v|
178
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
179
+ end
180
+ end
181
+ else # model
182
+ # models (e.g. Pet) or oneOf
183
+ klass = Gopad.const_get(type)
184
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
185
+ end
186
+ end
187
+
188
+ # Returns the string representation of the object
189
+ # @return [String] String presentation of the object
190
+ def to_s
191
+ to_hash.to_s
192
+ end
193
+
194
+ # to_body is an alias to to_hash (backward compatibility)
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_body
197
+ to_hash
198
+ end
199
+
200
+ # Returns the object in the form of hash
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_hash
203
+ hash = {}
204
+ self.class.attribute_map.each_pair do |attr, param|
205
+ value = send(attr)
206
+ if value.nil?
207
+ is_nullable = self.class.openapi_nullable.include?(attr)
208
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
209
+ end
210
+
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+ end
234
+ end