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.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +136 -0
- data/Rakefile +10 -0
- data/docs/AccountsApi.md +72 -0
- data/docs/FullSwitch.md +20 -0
- data/docs/Member.md +58 -0
- data/docs/MembersApi.md +353 -0
- data/docs/Message.md +30 -0
- data/docs/PrivacySetting.md +15 -0
- data/docs/ProxyTag.md +20 -0
- data/docs/ProxyingApi.md +70 -0
- data/docs/Switch.md +20 -0
- data/docs/SwitchesApi.md +208 -0
- data/docs/System.md +40 -0
- data/docs/SystemsApi.md +475 -0
- data/git_push.sh +58 -0
- data/lib/pluralkit-api.rb +51 -0
- data/lib/pluralkit-api/api/accounts_api.rb +98 -0
- data/lib/pluralkit-api/api/members_api.rb +389 -0
- data/lib/pluralkit-api/api/proxying_api.rb +96 -0
- data/lib/pluralkit-api/api/switches_api.rb +236 -0
- data/lib/pluralkit-api/api/systems_api.rb +525 -0
- data/lib/pluralkit-api/api_client.rb +390 -0
- data/lib/pluralkit-api/api_error.rb +57 -0
- data/lib/pluralkit-api/configuration.rb +277 -0
- data/lib/pluralkit-api/models/full_switch.rb +231 -0
- data/lib/pluralkit-api/models/member.rb +568 -0
- data/lib/pluralkit-api/models/message.rb +274 -0
- data/lib/pluralkit-api/models/privacy_setting.rb +37 -0
- data/lib/pluralkit-api/models/proxy_tag.rb +262 -0
- data/lib/pluralkit-api/models/switch.rb +231 -0
- data/lib/pluralkit-api/models/system.rb +417 -0
- data/lib/pluralkit-api/version.rb +15 -0
- data/pluralkit-api.gemspec +38 -0
- data/spec/api/accounts_api_spec.rb +47 -0
- data/spec/api/members_api_spec.rb +92 -0
- data/spec/api/proxying_api_spec.rb +46 -0
- data/spec/api/switches_api_spec.rb +70 -0
- data/spec/api/systems_api_spec.rb +118 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/full_switch_spec.rb +40 -0
- data/spec/models/member_spec.rb +154 -0
- data/spec/models/message_spec.rb +70 -0
- data/spec/models/privacy_setting_spec.rb +28 -0
- data/spec/models/proxy_tag_spec.rb +40 -0
- data/spec/models/switch_spec.rb +40 -0
- data/spec/models/system_spec.rb +94 -0
- data/spec/spec_helper.rb +111 -0
- 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 Switch
|
18
|
+
# The timestamp the switch was logged.
|
19
|
+
attr_accessor :timestamp
|
20
|
+
|
21
|
+
# A list of the IDs 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<String>'
|
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::Switch` 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::Switch`. 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,417 @@
|
|
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 System
|
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 system.
|
22
|
+
attr_accessor :name
|
23
|
+
|
24
|
+
# The user-provided system description. May contain rich text in Markdown, including standard Markdown-formatted links, or Discord-formatted emoji/user/channel references.
|
25
|
+
attr_accessor :description
|
26
|
+
|
27
|
+
# The system tag, which is appended to the names (or display names, if set) of members when proxying through the bot. A space will automatically be inserted between the name and the tag, so no need to include one at the start. The character limit here is 78, as Discord's name length limit for webhooks is 80 characters. A 78-character system tag is thus the longest tag that can still accomodate a single-letter member name and the separating space.
|
28
|
+
attr_accessor :tag
|
29
|
+
|
30
|
+
# A link to the avatar/icon of the system. 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).
|
31
|
+
attr_accessor :avatar_url
|
32
|
+
|
33
|
+
# The system's registered time zone as an Olson time zone ID. This is used in the bot to convert various time stamps in commands on behalf of this system.
|
34
|
+
attr_accessor :tz
|
35
|
+
|
36
|
+
# The creation timestamp of the system.
|
37
|
+
attr_accessor :created
|
38
|
+
|
39
|
+
attr_accessor :description_privacy
|
40
|
+
|
41
|
+
attr_accessor :member_list_privacy
|
42
|
+
|
43
|
+
attr_accessor :front_privacy
|
44
|
+
|
45
|
+
attr_accessor :front_history_privacy
|
46
|
+
|
47
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
48
|
+
def self.attribute_map
|
49
|
+
{
|
50
|
+
:'id' => :'id',
|
51
|
+
:'name' => :'name',
|
52
|
+
:'description' => :'description',
|
53
|
+
:'tag' => :'tag',
|
54
|
+
:'avatar_url' => :'avatar_url',
|
55
|
+
:'tz' => :'tz',
|
56
|
+
:'created' => :'created',
|
57
|
+
:'description_privacy' => :'description_privacy',
|
58
|
+
:'member_list_privacy' => :'member_list_privacy',
|
59
|
+
:'front_privacy' => :'front_privacy',
|
60
|
+
:'front_history_privacy' => :'front_history_privacy'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns all the JSON keys this model knows about
|
65
|
+
def self.acceptable_attributes
|
66
|
+
attribute_map.values
|
67
|
+
end
|
68
|
+
|
69
|
+
# Attribute type mapping.
|
70
|
+
def self.openapi_types
|
71
|
+
{
|
72
|
+
:'id' => :'String',
|
73
|
+
:'name' => :'String',
|
74
|
+
:'description' => :'String',
|
75
|
+
:'tag' => :'String',
|
76
|
+
:'avatar_url' => :'String',
|
77
|
+
:'tz' => :'String',
|
78
|
+
:'created' => :'Time',
|
79
|
+
:'description_privacy' => :'PrivacySetting',
|
80
|
+
:'member_list_privacy' => :'PrivacySetting',
|
81
|
+
:'front_privacy' => :'PrivacySetting',
|
82
|
+
:'front_history_privacy' => :'PrivacySetting'
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
# List of attributes with nullable: true
|
87
|
+
def self.openapi_nullable
|
88
|
+
Set.new([
|
89
|
+
:'name',
|
90
|
+
:'description',
|
91
|
+
:'tag',
|
92
|
+
:'avatar_url',
|
93
|
+
:'tz',
|
94
|
+
])
|
95
|
+
end
|
96
|
+
|
97
|
+
# Initializes the object
|
98
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
99
|
+
def initialize(attributes = {})
|
100
|
+
if (!attributes.is_a?(Hash))
|
101
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PluralKitAPI::System` initialize method"
|
102
|
+
end
|
103
|
+
|
104
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
105
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
106
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
107
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PluralKitAPI::System`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
108
|
+
end
|
109
|
+
h[k.to_sym] = v
|
110
|
+
}
|
111
|
+
|
112
|
+
if attributes.key?(:'id')
|
113
|
+
self.id = attributes[:'id']
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:'name')
|
117
|
+
self.name = attributes[:'name']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.key?(:'description')
|
121
|
+
self.description = attributes[:'description']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'tag')
|
125
|
+
self.tag = attributes[:'tag']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'avatar_url')
|
129
|
+
self.avatar_url = attributes[:'avatar_url']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.key?(:'tz')
|
133
|
+
self.tz = attributes[:'tz']
|
134
|
+
else
|
135
|
+
self.tz = 'UTC'
|
136
|
+
end
|
137
|
+
|
138
|
+
if attributes.key?(:'created')
|
139
|
+
self.created = attributes[:'created']
|
140
|
+
end
|
141
|
+
|
142
|
+
if attributes.key?(:'description_privacy')
|
143
|
+
self.description_privacy = attributes[:'description_privacy']
|
144
|
+
end
|
145
|
+
|
146
|
+
if attributes.key?(:'member_list_privacy')
|
147
|
+
self.member_list_privacy = attributes[:'member_list_privacy']
|
148
|
+
end
|
149
|
+
|
150
|
+
if attributes.key?(:'front_privacy')
|
151
|
+
self.front_privacy = attributes[:'front_privacy']
|
152
|
+
end
|
153
|
+
|
154
|
+
if attributes.key?(:'front_history_privacy')
|
155
|
+
self.front_history_privacy = attributes[:'front_history_privacy']
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
160
|
+
# @return Array for valid properties with the reasons
|
161
|
+
def list_invalid_properties
|
162
|
+
invalid_properties = Array.new
|
163
|
+
if !@id.nil? && @id.to_s.length > 5
|
164
|
+
invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 5.')
|
165
|
+
end
|
166
|
+
|
167
|
+
if !@id.nil? && @id.to_s.length < 5
|
168
|
+
invalid_properties.push('invalid value for "id", the character length must be great than or equal to 5.')
|
169
|
+
end
|
170
|
+
|
171
|
+
pattern = Regexp.new(/^[a-z]{5}$/)
|
172
|
+
if !@id.nil? && @id !~ pattern
|
173
|
+
invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
|
174
|
+
end
|
175
|
+
|
176
|
+
if !@name.nil? && @name.to_s.length > 100
|
177
|
+
invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 100.')
|
178
|
+
end
|
179
|
+
|
180
|
+
if !@description.nil? && @description.to_s.length > 1000
|
181
|
+
invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 1000.')
|
182
|
+
end
|
183
|
+
|
184
|
+
if !@tag.nil? && @tag.to_s.length > 78
|
185
|
+
invalid_properties.push('invalid value for "tag", the character length must be smaller than or equal to 78.')
|
186
|
+
end
|
187
|
+
|
188
|
+
if !@avatar_url.nil? && @avatar_url.to_s.length > 256
|
189
|
+
invalid_properties.push('invalid value for "avatar_url", the character length must be smaller than or equal to 256.')
|
190
|
+
end
|
191
|
+
|
192
|
+
invalid_properties
|
193
|
+
end
|
194
|
+
|
195
|
+
# Check to see if the all the properties in the model are valid
|
196
|
+
# @return true if the model is valid
|
197
|
+
def valid?
|
198
|
+
return false if !@id.nil? && @id.to_s.length > 5
|
199
|
+
return false if !@id.nil? && @id.to_s.length < 5
|
200
|
+
return false if !@id.nil? && @id !~ Regexp.new(/^[a-z]{5}$/)
|
201
|
+
return false if !@name.nil? && @name.to_s.length > 100
|
202
|
+
return false if !@description.nil? && @description.to_s.length > 1000
|
203
|
+
return false if !@tag.nil? && @tag.to_s.length > 78
|
204
|
+
return false if !@avatar_url.nil? && @avatar_url.to_s.length > 256
|
205
|
+
true
|
206
|
+
end
|
207
|
+
|
208
|
+
# Custom attribute writer method with validation
|
209
|
+
# @param [Object] id Value to be assigned
|
210
|
+
def id=(id)
|
211
|
+
if !id.nil? && id.to_s.length > 5
|
212
|
+
fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 5.'
|
213
|
+
end
|
214
|
+
|
215
|
+
if !id.nil? && id.to_s.length < 5
|
216
|
+
fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 5.'
|
217
|
+
end
|
218
|
+
|
219
|
+
pattern = Regexp.new(/^[a-z]{5}$/)
|
220
|
+
if !id.nil? && id !~ pattern
|
221
|
+
fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
|
222
|
+
end
|
223
|
+
|
224
|
+
@id = id
|
225
|
+
end
|
226
|
+
|
227
|
+
# Custom attribute writer method with validation
|
228
|
+
# @param [Object] name Value to be assigned
|
229
|
+
def name=(name)
|
230
|
+
if !name.nil? && name.to_s.length > 100
|
231
|
+
fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 100.'
|
232
|
+
end
|
233
|
+
|
234
|
+
@name = name
|
235
|
+
end
|
236
|
+
|
237
|
+
# Custom attribute writer method with validation
|
238
|
+
# @param [Object] description Value to be assigned
|
239
|
+
def description=(description)
|
240
|
+
if !description.nil? && description.to_s.length > 1000
|
241
|
+
fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 1000.'
|
242
|
+
end
|
243
|
+
|
244
|
+
@description = description
|
245
|
+
end
|
246
|
+
|
247
|
+
# Custom attribute writer method with validation
|
248
|
+
# @param [Object] tag Value to be assigned
|
249
|
+
def tag=(tag)
|
250
|
+
if !tag.nil? && tag.to_s.length > 78
|
251
|
+
fail ArgumentError, 'invalid value for "tag", the character length must be smaller than or equal to 78.'
|
252
|
+
end
|
253
|
+
|
254
|
+
@tag = tag
|
255
|
+
end
|
256
|
+
|
257
|
+
# Custom attribute writer method with validation
|
258
|
+
# @param [Object] avatar_url Value to be assigned
|
259
|
+
def avatar_url=(avatar_url)
|
260
|
+
if !avatar_url.nil? && avatar_url.to_s.length > 256
|
261
|
+
fail ArgumentError, 'invalid value for "avatar_url", the character length must be smaller than or equal to 256.'
|
262
|
+
end
|
263
|
+
|
264
|
+
@avatar_url = avatar_url
|
265
|
+
end
|
266
|
+
|
267
|
+
# Checks equality by comparing each attribute.
|
268
|
+
# @param [Object] Object to be compared
|
269
|
+
def ==(o)
|
270
|
+
return true if self.equal?(o)
|
271
|
+
self.class == o.class &&
|
272
|
+
id == o.id &&
|
273
|
+
name == o.name &&
|
274
|
+
description == o.description &&
|
275
|
+
tag == o.tag &&
|
276
|
+
avatar_url == o.avatar_url &&
|
277
|
+
tz == o.tz &&
|
278
|
+
created == o.created &&
|
279
|
+
description_privacy == o.description_privacy &&
|
280
|
+
member_list_privacy == o.member_list_privacy &&
|
281
|
+
front_privacy == o.front_privacy &&
|
282
|
+
front_history_privacy == o.front_history_privacy
|
283
|
+
end
|
284
|
+
|
285
|
+
# @see the `==` method
|
286
|
+
# @param [Object] Object to be compared
|
287
|
+
def eql?(o)
|
288
|
+
self == o
|
289
|
+
end
|
290
|
+
|
291
|
+
# Calculates hash code according to all attributes.
|
292
|
+
# @return [Integer] Hash code
|
293
|
+
def hash
|
294
|
+
[id, name, description, tag, avatar_url, tz, created, description_privacy, member_list_privacy, front_privacy, front_history_privacy].hash
|
295
|
+
end
|
296
|
+
|
297
|
+
# Builds the object from hash
|
298
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
299
|
+
# @return [Object] Returns the model itself
|
300
|
+
def self.build_from_hash(attributes)
|
301
|
+
new.build_from_hash(attributes)
|
302
|
+
end
|
303
|
+
|
304
|
+
# Builds the object from hash
|
305
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
306
|
+
# @return [Object] Returns the model itself
|
307
|
+
def build_from_hash(attributes)
|
308
|
+
return nil unless attributes.is_a?(Hash)
|
309
|
+
self.class.openapi_types.each_pair do |key, type|
|
310
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
311
|
+
self.send("#{key}=", nil)
|
312
|
+
elsif type =~ /\AArray<(.*)>/i
|
313
|
+
# check to ensure the input is an array given that the attribute
|
314
|
+
# is documented as an array but the input is not
|
315
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
316
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
317
|
+
end
|
318
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
319
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
self
|
324
|
+
end
|
325
|
+
|
326
|
+
# Deserializes the data based on type
|
327
|
+
# @param string type Data type
|
328
|
+
# @param string value Value to be deserialized
|
329
|
+
# @return [Object] Deserialized data
|
330
|
+
def _deserialize(type, value)
|
331
|
+
case type.to_sym
|
332
|
+
when :Time
|
333
|
+
Time.parse(value)
|
334
|
+
when :Date
|
335
|
+
Date.parse(value)
|
336
|
+
when :String
|
337
|
+
value.to_s
|
338
|
+
when :Integer
|
339
|
+
value.to_i
|
340
|
+
when :Float
|
341
|
+
value.to_f
|
342
|
+
when :Boolean
|
343
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
344
|
+
true
|
345
|
+
else
|
346
|
+
false
|
347
|
+
end
|
348
|
+
when :Object
|
349
|
+
# generic object (usually a Hash), return directly
|
350
|
+
value
|
351
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
352
|
+
inner_type = Regexp.last_match[:inner_type]
|
353
|
+
value.map { |v| _deserialize(inner_type, v) }
|
354
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
355
|
+
k_type = Regexp.last_match[:k_type]
|
356
|
+
v_type = Regexp.last_match[:v_type]
|
357
|
+
{}.tap do |hash|
|
358
|
+
value.each do |k, v|
|
359
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
else # model
|
363
|
+
# models (e.g. Pet) or oneOf
|
364
|
+
klass = PluralKitAPI.const_get(type)
|
365
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
# Returns the string representation of the object
|
370
|
+
# @return [String] String presentation of the object
|
371
|
+
def to_s
|
372
|
+
to_hash.to_s
|
373
|
+
end
|
374
|
+
|
375
|
+
# to_body is an alias to to_hash (backward compatibility)
|
376
|
+
# @return [Hash] Returns the object in the form of hash
|
377
|
+
def to_body
|
378
|
+
to_hash
|
379
|
+
end
|
380
|
+
|
381
|
+
# Returns the object in the form of hash
|
382
|
+
# @return [Hash] Returns the object in the form of hash
|
383
|
+
def to_hash
|
384
|
+
hash = {}
|
385
|
+
self.class.attribute_map.each_pair do |attr, param|
|
386
|
+
value = self.send(attr)
|
387
|
+
if value.nil?
|
388
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
389
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
390
|
+
end
|
391
|
+
|
392
|
+
hash[param] = _to_hash(value)
|
393
|
+
end
|
394
|
+
hash
|
395
|
+
end
|
396
|
+
|
397
|
+
# Outputs non-array value in the form of hash
|
398
|
+
# For object, use to_hash. Otherwise, just return the value
|
399
|
+
# @param [Object] value Any valid value
|
400
|
+
# @return [Hash] Returns the value in the form of hash
|
401
|
+
def _to_hash(value)
|
402
|
+
if value.is_a?(Array)
|
403
|
+
value.compact.map { |v| _to_hash(v) }
|
404
|
+
elsif value.is_a?(Hash)
|
405
|
+
{}.tap do |hash|
|
406
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
407
|
+
end
|
408
|
+
elsif value.respond_to? :to_hash
|
409
|
+
value.to_hash
|
410
|
+
else
|
411
|
+
value
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
end
|
416
|
+
|
417
|
+
end
|