pluralkit-api 1.0.0

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 (51) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +136 -0
  4. data/Rakefile +10 -0
  5. data/docs/AccountsApi.md +72 -0
  6. data/docs/FullSwitch.md +20 -0
  7. data/docs/Member.md +58 -0
  8. data/docs/MembersApi.md +353 -0
  9. data/docs/Message.md +30 -0
  10. data/docs/PrivacySetting.md +15 -0
  11. data/docs/ProxyTag.md +20 -0
  12. data/docs/ProxyingApi.md +70 -0
  13. data/docs/Switch.md +20 -0
  14. data/docs/SwitchesApi.md +208 -0
  15. data/docs/System.md +40 -0
  16. data/docs/SystemsApi.md +475 -0
  17. data/git_push.sh +58 -0
  18. data/lib/pluralkit-api.rb +51 -0
  19. data/lib/pluralkit-api/api/accounts_api.rb +98 -0
  20. data/lib/pluralkit-api/api/members_api.rb +389 -0
  21. data/lib/pluralkit-api/api/proxying_api.rb +96 -0
  22. data/lib/pluralkit-api/api/switches_api.rb +236 -0
  23. data/lib/pluralkit-api/api/systems_api.rb +525 -0
  24. data/lib/pluralkit-api/api_client.rb +390 -0
  25. data/lib/pluralkit-api/api_error.rb +57 -0
  26. data/lib/pluralkit-api/configuration.rb +277 -0
  27. data/lib/pluralkit-api/models/full_switch.rb +231 -0
  28. data/lib/pluralkit-api/models/member.rb +568 -0
  29. data/lib/pluralkit-api/models/message.rb +274 -0
  30. data/lib/pluralkit-api/models/privacy_setting.rb +37 -0
  31. data/lib/pluralkit-api/models/proxy_tag.rb +262 -0
  32. data/lib/pluralkit-api/models/switch.rb +231 -0
  33. data/lib/pluralkit-api/models/system.rb +417 -0
  34. data/lib/pluralkit-api/version.rb +15 -0
  35. data/pluralkit-api.gemspec +38 -0
  36. data/spec/api/accounts_api_spec.rb +47 -0
  37. data/spec/api/members_api_spec.rb +92 -0
  38. data/spec/api/proxying_api_spec.rb +46 -0
  39. data/spec/api/switches_api_spec.rb +70 -0
  40. data/spec/api/systems_api_spec.rb +118 -0
  41. data/spec/api_client_spec.rb +226 -0
  42. data/spec/configuration_spec.rb +42 -0
  43. data/spec/models/full_switch_spec.rb +40 -0
  44. data/spec/models/member_spec.rb +154 -0
  45. data/spec/models/message_spec.rb +70 -0
  46. data/spec/models/privacy_setting_spec.rb +28 -0
  47. data/spec/models/proxy_tag_spec.rb +40 -0
  48. data/spec/models/switch_spec.rb +40 -0
  49. data/spec/models/system_spec.rb +94 -0
  50. data/spec/spec_helper.rb +111 -0
  51. metadata +147 -0
@@ -0,0 +1,231 @@
1
+ =begin
2
+ #PluralKit
3
+
4
+ #This is the API for [PluralKit](https://pluralkit.me/)! :) The API itself is stable, but this document (the OpenAPI description) is still subject to change, and may be updated, corrected or restructured in the future (as long as it's still coherent with the real API). # Authentication Authentication is handled using a \"system token\". At the moment, the only way to obtain a system token is to use the `pk;token` command through the Discord bot. This will generate an opaque string you must pass as the `Authorization` header to API requests. Many API endpoints are available anonymously, but most of them will hide information from unauthenticated requests to align with the relevant privacy settings. # Errors Errors are just returned as HTTP response codes. Most error responses include a human-readable error message as the body, but this should not be relied on. Just read the response codes :) # OpenAPI version history - **1.1**: Granular member privacy - **1.0**: (initial definition version)
5
+
6
+ The version of the OpenAPI document: 1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PluralKitAPI
17
+ class FullSwitch
18
+ # The timestamp the switch was logged.
19
+ attr_accessor :timestamp
20
+
21
+ # A list of the members in this switch. The order is significant. It is valid for the switch to have no members at all.
22
+ attr_accessor :members
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'timestamp' => :'timestamp',
28
+ :'members' => :'members'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'timestamp' => :'Time',
41
+ :'members' => :'Array<Member>'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PluralKitAPI::FullSwitch` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PluralKitAPI::FullSwitch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'timestamp')
67
+ self.timestamp = attributes[:'timestamp']
68
+ end
69
+
70
+ if attributes.key?(:'members')
71
+ if (value = attributes[:'members']).is_a?(Array)
72
+ self.members = value
73
+ end
74
+ end
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properties with the reasons
79
+ def list_invalid_properties
80
+ invalid_properties = Array.new
81
+ invalid_properties
82
+ end
83
+
84
+ # Check to see if the all the properties in the model are valid
85
+ # @return true if the model is valid
86
+ def valid?
87
+ true
88
+ end
89
+
90
+ # Checks equality by comparing each attribute.
91
+ # @param [Object] Object to be compared
92
+ def ==(o)
93
+ return true if self.equal?(o)
94
+ self.class == o.class &&
95
+ timestamp == o.timestamp &&
96
+ members == o.members
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [timestamp, members].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ self.class.openapi_types.each_pair do |key, type|
124
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
125
+ self.send("#{key}=", nil)
126
+ elsif type =~ /\AArray<(.*)>/i
127
+ # check to ensure the input is an array given that the attribute
128
+ # is documented as an array but the input is not
129
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
130
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
131
+ end
132
+ elsif !attributes[self.class.attribute_map[key]].nil?
133
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
134
+ end
135
+ end
136
+
137
+ self
138
+ end
139
+
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
144
+ def _deserialize(type, value)
145
+ case type.to_sym
146
+ when :Time
147
+ Time.parse(value)
148
+ when :Date
149
+ Date.parse(value)
150
+ when :String
151
+ value.to_s
152
+ when :Integer
153
+ value.to_i
154
+ when :Float
155
+ value.to_f
156
+ when :Boolean
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ # models (e.g. Pet) or oneOf
178
+ klass = PluralKitAPI.const_get(type)
179
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
180
+ end
181
+ end
182
+
183
+ # Returns the string representation of the object
184
+ # @return [String] String presentation of the object
185
+ def to_s
186
+ to_hash.to_s
187
+ end
188
+
189
+ # to_body is an alias to to_hash (backward compatibility)
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_body
192
+ to_hash
193
+ end
194
+
195
+ # Returns the object in the form of hash
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_hash
198
+ hash = {}
199
+ self.class.attribute_map.each_pair do |attr, param|
200
+ value = self.send(attr)
201
+ if value.nil?
202
+ is_nullable = self.class.openapi_nullable.include?(attr)
203
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
204
+ end
205
+
206
+ hash[param] = _to_hash(value)
207
+ end
208
+ hash
209
+ end
210
+
211
+ # Outputs non-array value in the form of hash
212
+ # For object, use to_hash. Otherwise, just return the value
213
+ # @param [Object] value Any valid value
214
+ # @return [Hash] Returns the value in the form of hash
215
+ def _to_hash(value)
216
+ if value.is_a?(Array)
217
+ value.compact.map { |v| _to_hash(v) }
218
+ elsif value.is_a?(Hash)
219
+ {}.tap do |hash|
220
+ value.each { |k, v| hash[k] = _to_hash(v) }
221
+ end
222
+ elsif value.respond_to? :to_hash
223
+ value.to_hash
224
+ else
225
+ value
226
+ end
227
+ end
228
+
229
+ end
230
+
231
+ end
@@ -0,0 +1,568 @@
1
+ =begin
2
+ #PluralKit
3
+
4
+ #This is the API for [PluralKit](https://pluralkit.me/)! :) The API itself is stable, but this document (the OpenAPI description) is still subject to change, and may be updated, corrected or restructured in the future (as long as it's still coherent with the real API). # Authentication Authentication is handled using a \"system token\". At the moment, the only way to obtain a system token is to use the `pk;token` command through the Discord bot. This will generate an opaque string you must pass as the `Authorization` header to API requests. Many API endpoints are available anonymously, but most of them will hide information from unauthenticated requests to align with the relevant privacy settings. # Errors Errors are just returned as HTTP response codes. Most error responses include a human-readable error message as the body, but this should not be relied on. Just read the response codes :) # OpenAPI version history - **1.1**: Granular member privacy - **1.0**: (initial definition version)
5
+
6
+ The version of the OpenAPI document: 1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PluralKitAPI
17
+ class Member
18
+ # A unique identifier for a system or a member, as a randomly generated string of five lowercase letters. These IDs are guaranteed to be globally unique for the given model type (a system can have the same ID as a member, but two systems or two members can never share an ID). The IDs can on rare occasions change - eg. if a profane word is generated and later regenerated, or as a potential future Patreon perk. However, it's still reasonable to assume that the IDs are constant, and that tey won't change without the user's knowledge, so it's safe to store in things like settings menus and config files.
19
+ attr_accessor :id
20
+
21
+ # The user-provided name of the member.
22
+ attr_accessor :name
23
+
24
+ # The member's \"display name\", which will override the member's normal name when proxying.
25
+ attr_accessor :display_name
26
+
27
+ # The user-provided description of the member. May contain rich text in Markdown, including standard Markdown-formatted links, or Discord-formatted emoji/user/channel references. If this member is private, and the request is not authorized with the member's system token, this field will always be returned as `null`.
28
+ attr_accessor :description
29
+
30
+ # The member's \"color\", displayed on member cards, as a 6-character hexadecimal color code (no leading #). If this member is private, and the request is not authorized with the member's system token, this field will always be returned as `null`.
31
+ attr_accessor :color
32
+
33
+ # The user-provided birthdate of the member. \"Year-less\" birthdays are supported. In this case, the year should be set to `0004`, and that specific year should be special-cased and hidden from the user. Previous versions used the year `0001` for the same purpose, and this value may still be both read and written with the API and should be treated the same as `0004`. The year `0004` was chosen because it is a leap year in the Gregorian calendar, and thus the date `0004-02-29` can be properly represented. If this member is private, and the request is not authorized with the member's system token, this field will always be returned as `null`.
34
+ attr_accessor :birthday
35
+
36
+ # The user-provided pronouns of the member. There is no specific schema, just a freeform text field. If this member is private, and the request is not authorized with the member's system token, this field will always be returned as `null`.
37
+ attr_accessor :pronouns
38
+
39
+ # A link to the avatar/icon of the member. If used for proxying, the image must be at most 1000 pixels in width *and* height, and at most 1 MiB in size. This restriction is on Discord's end and is not verified through the API (it's simply stored as a string).
40
+ attr_accessor :avatar_url
41
+
42
+ attr_accessor :privacy
43
+
44
+ attr_accessor :visibility
45
+
46
+ attr_accessor :name_privacy
47
+
48
+ attr_accessor :description_privacy
49
+
50
+ attr_accessor :avatar_privacy
51
+
52
+ attr_accessor :pronouns_privacy
53
+
54
+ attr_accessor :birthday_privacy
55
+
56
+ attr_accessor :metadata_privacy
57
+
58
+ # An unordered list of the member's proxy tag pairs. It is valid for a member to have any number of proxy tags, including none at all.
59
+ attr_accessor :proxy_tags
60
+
61
+ # Previous versions of the API only supported a single proxy tag pair per member. This field will contain the prefix of the first proxy tag registered, or `null` if missing. Setting it will write to the first proxy tag's prefix, creating it if not present. This field is deprecated and will be removed in API v2.
62
+ attr_accessor :prefix
63
+
64
+ # Previous versions of the API only supported a single proxy tag pair per member. This field will contain the suffix of the first proxy tag registered, or `null` if missing. Setting it will write to the first proxy tag's suffix, creating it if not present. This field is deprecated and will be removed in API v2.
65
+ attr_accessor :suffix
66
+
67
+ # Whether or not to include the used proxy tags in proxied messages.
68
+ attr_accessor :keep_proxy
69
+
70
+ # The creation timestamp of the member. May be returned as `null` depending on the value of `metadata_privacy` and the request authorization.
71
+ attr_accessor :created
72
+
73
+ # Attribute mapping from ruby-style variable name to JSON key.
74
+ def self.attribute_map
75
+ {
76
+ :'id' => :'id',
77
+ :'name' => :'name',
78
+ :'display_name' => :'display_name',
79
+ :'description' => :'description',
80
+ :'color' => :'color',
81
+ :'birthday' => :'birthday',
82
+ :'pronouns' => :'pronouns',
83
+ :'avatar_url' => :'avatar_url',
84
+ :'privacy' => :'privacy',
85
+ :'visibility' => :'visibility',
86
+ :'name_privacy' => :'name_privacy',
87
+ :'description_privacy' => :'description_privacy',
88
+ :'avatar_privacy' => :'avatar_privacy',
89
+ :'pronouns_privacy' => :'pronouns_privacy',
90
+ :'birthday_privacy' => :'birthday_privacy',
91
+ :'metadata_privacy' => :'metadata_privacy',
92
+ :'proxy_tags' => :'proxy_tags',
93
+ :'prefix' => :'prefix',
94
+ :'suffix' => :'suffix',
95
+ :'keep_proxy' => :'keep_proxy',
96
+ :'created' => :'created'
97
+ }
98
+ end
99
+
100
+ # Returns all the JSON keys this model knows about
101
+ def self.acceptable_attributes
102
+ attribute_map.values
103
+ end
104
+
105
+ # Attribute type mapping.
106
+ def self.openapi_types
107
+ {
108
+ :'id' => :'String',
109
+ :'name' => :'String',
110
+ :'display_name' => :'String',
111
+ :'description' => :'String',
112
+ :'color' => :'String',
113
+ :'birthday' => :'Date',
114
+ :'pronouns' => :'String',
115
+ :'avatar_url' => :'String',
116
+ :'privacy' => :'PrivacySetting',
117
+ :'visibility' => :'PrivacySetting',
118
+ :'name_privacy' => :'PrivacySetting',
119
+ :'description_privacy' => :'PrivacySetting',
120
+ :'avatar_privacy' => :'PrivacySetting',
121
+ :'pronouns_privacy' => :'PrivacySetting',
122
+ :'birthday_privacy' => :'PrivacySetting',
123
+ :'metadata_privacy' => :'PrivacySetting',
124
+ :'proxy_tags' => :'Array<ProxyTag>',
125
+ :'prefix' => :'String',
126
+ :'suffix' => :'String',
127
+ :'keep_proxy' => :'Boolean',
128
+ :'created' => :'Time'
129
+ }
130
+ end
131
+
132
+ # List of attributes with nullable: true
133
+ def self.openapi_nullable
134
+ Set.new([
135
+ :'display_name',
136
+ :'color',
137
+ :'birthday',
138
+ :'pronouns',
139
+ :'avatar_url',
140
+ :'prefix',
141
+ :'suffix',
142
+ :'created'
143
+ ])
144
+ end
145
+
146
+ # Initializes the object
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ def initialize(attributes = {})
149
+ if (!attributes.is_a?(Hash))
150
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PluralKitAPI::Member` initialize method"
151
+ end
152
+
153
+ # check to see if the attribute exists and convert string to symbol for hash key
154
+ attributes = attributes.each_with_object({}) { |(k, v), h|
155
+ if (!self.class.attribute_map.key?(k.to_sym))
156
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PluralKitAPI::Member`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
157
+ end
158
+ h[k.to_sym] = v
159
+ }
160
+
161
+ if attributes.key?(:'id')
162
+ self.id = attributes[:'id']
163
+ end
164
+
165
+ if attributes.key?(:'name')
166
+ self.name = attributes[:'name']
167
+ end
168
+
169
+ if attributes.key?(:'display_name')
170
+ self.display_name = attributes[:'display_name']
171
+ end
172
+
173
+ if attributes.key?(:'description')
174
+ self.description = attributes[:'description']
175
+ end
176
+
177
+ if attributes.key?(:'color')
178
+ self.color = attributes[:'color']
179
+ end
180
+
181
+ if attributes.key?(:'birthday')
182
+ self.birthday = attributes[:'birthday']
183
+ end
184
+
185
+ if attributes.key?(:'pronouns')
186
+ self.pronouns = attributes[:'pronouns']
187
+ end
188
+
189
+ if attributes.key?(:'avatar_url')
190
+ self.avatar_url = attributes[:'avatar_url']
191
+ end
192
+
193
+ if attributes.key?(:'privacy')
194
+ self.privacy = attributes[:'privacy']
195
+ end
196
+
197
+ if attributes.key?(:'visibility')
198
+ self.visibility = attributes[:'visibility']
199
+ end
200
+
201
+ if attributes.key?(:'name_privacy')
202
+ self.name_privacy = attributes[:'name_privacy']
203
+ end
204
+
205
+ if attributes.key?(:'description_privacy')
206
+ self.description_privacy = attributes[:'description_privacy']
207
+ end
208
+
209
+ if attributes.key?(:'avatar_privacy')
210
+ self.avatar_privacy = attributes[:'avatar_privacy']
211
+ end
212
+
213
+ if attributes.key?(:'pronouns_privacy')
214
+ self.pronouns_privacy = attributes[:'pronouns_privacy']
215
+ end
216
+
217
+ if attributes.key?(:'birthday_privacy')
218
+ self.birthday_privacy = attributes[:'birthday_privacy']
219
+ end
220
+
221
+ if attributes.key?(:'metadata_privacy')
222
+ self.metadata_privacy = attributes[:'metadata_privacy']
223
+ end
224
+
225
+ if attributes.key?(:'proxy_tags')
226
+ if (value = attributes[:'proxy_tags']).is_a?(Array)
227
+ self.proxy_tags = value
228
+ end
229
+ end
230
+
231
+ if attributes.key?(:'prefix')
232
+ self.prefix = attributes[:'prefix']
233
+ end
234
+
235
+ if attributes.key?(:'suffix')
236
+ self.suffix = attributes[:'suffix']
237
+ end
238
+
239
+ if attributes.key?(:'keep_proxy')
240
+ self.keep_proxy = attributes[:'keep_proxy']
241
+ else
242
+ self.keep_proxy = false
243
+ end
244
+
245
+ if attributes.key?(:'created')
246
+ self.created = attributes[:'created']
247
+ end
248
+ end
249
+
250
+ # Show invalid properties with the reasons. Usually used together with valid?
251
+ # @return Array for valid properties with the reasons
252
+ def list_invalid_properties
253
+ invalid_properties = Array.new
254
+ if !@id.nil? && @id.to_s.length > 5
255
+ invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 5.')
256
+ end
257
+
258
+ if !@id.nil? && @id.to_s.length < 5
259
+ invalid_properties.push('invalid value for "id", the character length must be great than or equal to 5.')
260
+ end
261
+
262
+ pattern = Regexp.new(/^[a-z]{5}$/)
263
+ if !@id.nil? && @id !~ pattern
264
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
265
+ end
266
+
267
+ if !@name.nil? && @name.to_s.length > 100
268
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 100.')
269
+ end
270
+
271
+ if !@display_name.nil? && @display_name.to_s.length > 100
272
+ invalid_properties.push('invalid value for "display_name", the character length must be smaller than or equal to 100.')
273
+ end
274
+
275
+ if !@description.nil? && @description.to_s.length > 1000
276
+ invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 1000.')
277
+ end
278
+
279
+ if !@color.nil? && @color.to_s.length > 6
280
+ invalid_properties.push('invalid value for "color", the character length must be smaller than or equal to 6.')
281
+ end
282
+
283
+ if !@color.nil? && @color.to_s.length < 6
284
+ invalid_properties.push('invalid value for "color", the character length must be great than or equal to 6.')
285
+ end
286
+
287
+ pattern = Regexp.new(/^[0-9A-Fa-f]{6}$/)
288
+ if !@color.nil? && @color !~ pattern
289
+ invalid_properties.push("invalid value for \"color\", must conform to the pattern #{pattern}.")
290
+ end
291
+
292
+ if !@pronouns.nil? && @pronouns.to_s.length > 100
293
+ invalid_properties.push('invalid value for "pronouns", the character length must be smaller than or equal to 100.')
294
+ end
295
+
296
+ if !@avatar_url.nil? && @avatar_url.to_s.length > 256
297
+ invalid_properties.push('invalid value for "avatar_url", the character length must be smaller than or equal to 256.')
298
+ end
299
+
300
+ invalid_properties
301
+ end
302
+
303
+ # Check to see if the all the properties in the model are valid
304
+ # @return true if the model is valid
305
+ def valid?
306
+ return false if !@id.nil? && @id.to_s.length > 5
307
+ return false if !@id.nil? && @id.to_s.length < 5
308
+ return false if !@id.nil? && @id !~ Regexp.new(/^[a-z]{5}$/)
309
+ return false if !@name.nil? && @name.to_s.length > 100
310
+ return false if !@display_name.nil? && @display_name.to_s.length > 100
311
+ return false if !@description.nil? && @description.to_s.length > 1000
312
+ return false if !@color.nil? && @color.to_s.length > 6
313
+ return false if !@color.nil? && @color.to_s.length < 6
314
+ return false if !@color.nil? && @color !~ Regexp.new(/^[0-9A-Fa-f]{6}$/)
315
+ return false if !@pronouns.nil? && @pronouns.to_s.length > 100
316
+ return false if !@avatar_url.nil? && @avatar_url.to_s.length > 256
317
+ true
318
+ end
319
+
320
+ # Custom attribute writer method with validation
321
+ # @param [Object] id Value to be assigned
322
+ def id=(id)
323
+ if !id.nil? && id.to_s.length > 5
324
+ fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 5.'
325
+ end
326
+
327
+ if !id.nil? && id.to_s.length < 5
328
+ fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 5.'
329
+ end
330
+
331
+ pattern = Regexp.new(/^[a-z]{5}$/)
332
+ if !id.nil? && id !~ pattern
333
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
334
+ end
335
+
336
+ @id = id
337
+ end
338
+
339
+ # Custom attribute writer method with validation
340
+ # @param [Object] name Value to be assigned
341
+ def name=(name)
342
+ if !name.nil? && name.to_s.length > 100
343
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 100.'
344
+ end
345
+
346
+ @name = name
347
+ end
348
+
349
+ # Custom attribute writer method with validation
350
+ # @param [Object] display_name Value to be assigned
351
+ def display_name=(display_name)
352
+ if !display_name.nil? && display_name.to_s.length > 100
353
+ fail ArgumentError, 'invalid value for "display_name", the character length must be smaller than or equal to 100.'
354
+ end
355
+
356
+ @display_name = display_name
357
+ end
358
+
359
+ # Custom attribute writer method with validation
360
+ # @param [Object] description Value to be assigned
361
+ def description=(description)
362
+ if !description.nil? && description.to_s.length > 1000
363
+ fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 1000.'
364
+ end
365
+
366
+ @description = description
367
+ end
368
+
369
+ # Custom attribute writer method with validation
370
+ # @param [Object] color Value to be assigned
371
+ def color=(color)
372
+ if !color.nil? && color.to_s.length > 6
373
+ fail ArgumentError, 'invalid value for "color", the character length must be smaller than or equal to 6.'
374
+ end
375
+
376
+ if !color.nil? && color.to_s.length < 6
377
+ fail ArgumentError, 'invalid value for "color", the character length must be great than or equal to 6.'
378
+ end
379
+
380
+ pattern = Regexp.new(/^[0-9A-Fa-f]{6}$/)
381
+ if !color.nil? && color !~ pattern
382
+ fail ArgumentError, "invalid value for \"color\", must conform to the pattern #{pattern}."
383
+ end
384
+
385
+ @color = color
386
+ end
387
+
388
+ # Custom attribute writer method with validation
389
+ # @param [Object] pronouns Value to be assigned
390
+ def pronouns=(pronouns)
391
+ if !pronouns.nil? && pronouns.to_s.length > 100
392
+ fail ArgumentError, 'invalid value for "pronouns", the character length must be smaller than or equal to 100.'
393
+ end
394
+
395
+ @pronouns = pronouns
396
+ end
397
+
398
+ # Custom attribute writer method with validation
399
+ # @param [Object] avatar_url Value to be assigned
400
+ def avatar_url=(avatar_url)
401
+ if !avatar_url.nil? && avatar_url.to_s.length > 256
402
+ fail ArgumentError, 'invalid value for "avatar_url", the character length must be smaller than or equal to 256.'
403
+ end
404
+
405
+ @avatar_url = avatar_url
406
+ end
407
+
408
+ # Checks equality by comparing each attribute.
409
+ # @param [Object] Object to be compared
410
+ def ==(o)
411
+ return true if self.equal?(o)
412
+ self.class == o.class &&
413
+ id == o.id &&
414
+ name == o.name &&
415
+ display_name == o.display_name &&
416
+ description == o.description &&
417
+ color == o.color &&
418
+ birthday == o.birthday &&
419
+ pronouns == o.pronouns &&
420
+ avatar_url == o.avatar_url &&
421
+ privacy == o.privacy &&
422
+ visibility == o.visibility &&
423
+ name_privacy == o.name_privacy &&
424
+ description_privacy == o.description_privacy &&
425
+ avatar_privacy == o.avatar_privacy &&
426
+ pronouns_privacy == o.pronouns_privacy &&
427
+ birthday_privacy == o.birthday_privacy &&
428
+ metadata_privacy == o.metadata_privacy &&
429
+ proxy_tags == o.proxy_tags &&
430
+ prefix == o.prefix &&
431
+ suffix == o.suffix &&
432
+ keep_proxy == o.keep_proxy &&
433
+ created == o.created
434
+ end
435
+
436
+ # @see the `==` method
437
+ # @param [Object] Object to be compared
438
+ def eql?(o)
439
+ self == o
440
+ end
441
+
442
+ # Calculates hash code according to all attributes.
443
+ # @return [Integer] Hash code
444
+ def hash
445
+ [id, name, display_name, description, color, birthday, pronouns, avatar_url, privacy, visibility, name_privacy, description_privacy, avatar_privacy, pronouns_privacy, birthday_privacy, metadata_privacy, proxy_tags, prefix, suffix, keep_proxy, created].hash
446
+ end
447
+
448
+ # Builds the object from hash
449
+ # @param [Hash] attributes Model attributes in the form of hash
450
+ # @return [Object] Returns the model itself
451
+ def self.build_from_hash(attributes)
452
+ new.build_from_hash(attributes)
453
+ end
454
+
455
+ # Builds the object from hash
456
+ # @param [Hash] attributes Model attributes in the form of hash
457
+ # @return [Object] Returns the model itself
458
+ def build_from_hash(attributes)
459
+ return nil unless attributes.is_a?(Hash)
460
+ self.class.openapi_types.each_pair do |key, type|
461
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
462
+ self.send("#{key}=", nil)
463
+ elsif type =~ /\AArray<(.*)>/i
464
+ # check to ensure the input is an array given that the attribute
465
+ # is documented as an array but the input is not
466
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
467
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
468
+ end
469
+ elsif !attributes[self.class.attribute_map[key]].nil?
470
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
471
+ end
472
+ end
473
+
474
+ self
475
+ end
476
+
477
+ # Deserializes the data based on type
478
+ # @param string type Data type
479
+ # @param string value Value to be deserialized
480
+ # @return [Object] Deserialized data
481
+ def _deserialize(type, value)
482
+ case type.to_sym
483
+ when :Time
484
+ Time.parse(value)
485
+ when :Date
486
+ Date.parse(value)
487
+ when :String
488
+ value.to_s
489
+ when :Integer
490
+ value.to_i
491
+ when :Float
492
+ value.to_f
493
+ when :Boolean
494
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
495
+ true
496
+ else
497
+ false
498
+ end
499
+ when :Object
500
+ # generic object (usually a Hash), return directly
501
+ value
502
+ when /\AArray<(?<inner_type>.+)>\z/
503
+ inner_type = Regexp.last_match[:inner_type]
504
+ value.map { |v| _deserialize(inner_type, v) }
505
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
506
+ k_type = Regexp.last_match[:k_type]
507
+ v_type = Regexp.last_match[:v_type]
508
+ {}.tap do |hash|
509
+ value.each do |k, v|
510
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
511
+ end
512
+ end
513
+ else # model
514
+ # models (e.g. Pet) or oneOf
515
+ klass = PluralKitAPI.const_get(type)
516
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
517
+ end
518
+ end
519
+
520
+ # Returns the string representation of the object
521
+ # @return [String] String presentation of the object
522
+ def to_s
523
+ to_hash.to_s
524
+ end
525
+
526
+ # to_body is an alias to to_hash (backward compatibility)
527
+ # @return [Hash] Returns the object in the form of hash
528
+ def to_body
529
+ to_hash
530
+ end
531
+
532
+ # Returns the object in the form of hash
533
+ # @return [Hash] Returns the object in the form of hash
534
+ def to_hash
535
+ hash = {}
536
+ self.class.attribute_map.each_pair do |attr, param|
537
+ value = self.send(attr)
538
+ if value.nil?
539
+ is_nullable = self.class.openapi_nullable.include?(attr)
540
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
541
+ end
542
+
543
+ hash[param] = _to_hash(value)
544
+ end
545
+ hash
546
+ end
547
+
548
+ # Outputs non-array value in the form of hash
549
+ # For object, use to_hash. Otherwise, just return the value
550
+ # @param [Object] value Any valid value
551
+ # @return [Hash] Returns the value in the form of hash
552
+ def _to_hash(value)
553
+ if value.is_a?(Array)
554
+ value.compact.map { |v| _to_hash(v) }
555
+ elsif value.is_a?(Hash)
556
+ {}.tap do |hash|
557
+ value.each { |k, v| hash[k] = _to_hash(v) }
558
+ end
559
+ elsif value.respond_to? :to_hash
560
+ value.to_hash
561
+ else
562
+ value
563
+ end
564
+ end
565
+
566
+ end
567
+
568
+ end