Class: PluralKitAPI::System
- Inherits:
-
Object
- Object
- PluralKitAPI::System
- Defined in:
- lib/pluralkit-api/models/system.rb
Instance Attribute Summary collapse
-
#avatar_url ⇒ Object
A link to the avatar/icon of the system.
-
#created ⇒ Object
The creation timestamp of the system.
-
#description ⇒ Object
The user-provided system description.
-
#description_privacy ⇒ Object
Returns the value of attribute description_privacy.
-
#front_history_privacy ⇒ Object
Returns the value of attribute front_history_privacy.
-
#front_privacy ⇒ Object
Returns the value of attribute front_privacy.
-
#id ⇒ Object
A unique identifier for a system or a member, as a randomly generated string of five lowercase letters.
-
#member_list_privacy ⇒ Object
Returns the value of attribute member_list_privacy.
-
#name ⇒ Object
The user-provided name of the system.
-
#tag ⇒ Object
The system tag, which is appended to the names (or display names, if set) of members when proxying through the bot.
-
#tz ⇒ Object
The system’s registered time zone as an Olson time zone ID.
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ System
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ System
Initializes the object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/pluralkit-api/models/system.rb', line 99 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `PluralKitAPI::System` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) 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 end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] end if attributes.key?(:'name') self.name = attributes[:'name'] end if attributes.key?(:'description') self.description = attributes[:'description'] end if attributes.key?(:'tag') self.tag = attributes[:'tag'] end if attributes.key?(:'avatar_url') self.avatar_url = attributes[:'avatar_url'] end if attributes.key?(:'tz') self.tz = attributes[:'tz'] else self.tz = 'UTC' end if attributes.key?(:'created') self.created = attributes[:'created'] end if attributes.key?(:'description_privacy') self.description_privacy = attributes[:'description_privacy'] end if attributes.key?(:'member_list_privacy') self.member_list_privacy = attributes[:'member_list_privacy'] end if attributes.key?(:'front_privacy') self.front_privacy = attributes[:'front_privacy'] end if attributes.key?(:'front_history_privacy') self.front_history_privacy = attributes[:'front_history_privacy'] end end |
Instance Attribute Details
#avatar_url ⇒ Object
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 32 33 |
# File 'lib/pluralkit-api/models/system.rb', line 31 def avatar_url @avatar_url end |
#created ⇒ Object
The creation timestamp of the system.
37 38 39 |
# File 'lib/pluralkit-api/models/system.rb', line 37 def created @created end |
#description ⇒ Object
The user-provided system description. May contain rich text in Markdown, including standard Markdown-formatted links, or Discord-formatted emoji/user/channel references.
25 26 27 |
# File 'lib/pluralkit-api/models/system.rb', line 25 def description @description end |
#description_privacy ⇒ Object
Returns the value of attribute description_privacy.
39 40 41 |
# File 'lib/pluralkit-api/models/system.rb', line 39 def description_privacy @description_privacy end |
#front_history_privacy ⇒ Object
Returns the value of attribute front_history_privacy.
45 46 47 |
# File 'lib/pluralkit-api/models/system.rb', line 45 def front_history_privacy @front_history_privacy end |
#front_privacy ⇒ Object
Returns the value of attribute front_privacy.
43 44 45 |
# File 'lib/pluralkit-api/models/system.rb', line 43 def front_privacy @front_privacy end |
#id ⇒ Object
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 20 21 |
# File 'lib/pluralkit-api/models/system.rb', line 19 def id @id end |
#member_list_privacy ⇒ Object
Returns the value of attribute member_list_privacy.
41 42 43 |
# File 'lib/pluralkit-api/models/system.rb', line 41 def member_list_privacy @member_list_privacy end |
#name ⇒ Object
The user-provided name of the system.
22 23 24 |
# File 'lib/pluralkit-api/models/system.rb', line 22 def name @name end |
#tag ⇒ Object
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 29 30 |
# File 'lib/pluralkit-api/models/system.rb', line 28 def tag @tag end |
#tz ⇒ Object
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 35 36 |
# File 'lib/pluralkit-api/models/system.rb', line 34 def tz @tz end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
65 66 67 |
# File 'lib/pluralkit-api/models/system.rb', line 65 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pluralkit-api/models/system.rb', line 48 def self.attribute_map { :'id' => :'id', :'name' => :'name', :'description' => :'description', :'tag' => :'tag', :'avatar_url' => :'avatar_url', :'tz' => :'tz', :'created' => :'created', :'description_privacy' => :'description_privacy', :'member_list_privacy' => :'member_list_privacy', :'front_privacy' => :'front_privacy', :'front_history_privacy' => :'front_history_privacy' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
300 301 302 |
# File 'lib/pluralkit-api/models/system.rb', line 300 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
87 88 89 90 91 92 93 94 95 |
# File 'lib/pluralkit-api/models/system.rb', line 87 def self.openapi_nullable Set.new([ :'name', :'description', :'tag', :'avatar_url', :'tz', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/pluralkit-api/models/system.rb', line 70 def self.openapi_types { :'id' => :'String', :'name' => :'String', :'description' => :'String', :'tag' => :'String', :'avatar_url' => :'String', :'tz' => :'String', :'created' => :'Time', :'description_privacy' => :'PrivacySetting', :'member_list_privacy' => :'PrivacySetting', :'front_privacy' => :'PrivacySetting', :'front_history_privacy' => :'PrivacySetting' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/pluralkit-api/models/system.rb', line 269 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && name == o.name && description == o.description && tag == o.tag && avatar_url == o.avatar_url && tz == o.tz && created == o.created && description_privacy == o.description_privacy && member_list_privacy == o.member_list_privacy && front_privacy == o.front_privacy && front_history_privacy == o.front_history_privacy end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
# File 'lib/pluralkit-api/models/system.rb', line 330 def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = PluralKitAPI.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/pluralkit-api/models/system.rb', line 401 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/pluralkit-api/models/system.rb', line 307 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end |
#eql?(o) ⇒ Boolean
287 288 289 |
# File 'lib/pluralkit-api/models/system.rb', line 287 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
293 294 295 |
# File 'lib/pluralkit-api/models/system.rb', line 293 def hash [id, name, description, tag, avatar_url, tz, created, description_privacy, member_list_privacy, front_privacy, front_history_privacy].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/pluralkit-api/models/system.rb', line 161 def list_invalid_properties invalid_properties = Array.new if !@id.nil? && @id.to_s.length > 5 invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 5.') end if !@id.nil? && @id.to_s.length < 5 invalid_properties.push('invalid value for "id", the character length must be great than or equal to 5.') end pattern = Regexp.new(/^[a-z]{5}$/) if !@id.nil? && @id !~ pattern invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.") end if !@name.nil? && @name.to_s.length > 100 invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 100.') end if !@description.nil? && @description.to_s.length > 1000 invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 1000.') end if !@tag.nil? && @tag.to_s.length > 78 invalid_properties.push('invalid value for "tag", the character length must be smaller than or equal to 78.') end if !@avatar_url.nil? && @avatar_url.to_s.length > 256 invalid_properties.push('invalid value for "avatar_url", the character length must be smaller than or equal to 256.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
377 378 379 |
# File 'lib/pluralkit-api/models/system.rb', line 377 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/pluralkit-api/models/system.rb', line 383 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
371 372 373 |
# File 'lib/pluralkit-api/models/system.rb', line 371 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
197 198 199 200 201 202 203 204 205 206 |
# File 'lib/pluralkit-api/models/system.rb', line 197 def valid? return false if !@id.nil? && @id.to_s.length > 5 return false if !@id.nil? && @id.to_s.length < 5 return false if !@id.nil? && @id !~ Regexp.new(/^[a-z]{5}$/) return false if !@name.nil? && @name.to_s.length > 100 return false if !@description.nil? && @description.to_s.length > 1000 return false if !@tag.nil? && @tag.to_s.length > 78 return false if !@avatar_url.nil? && @avatar_url.to_s.length > 256 true end |