Class: PluralKitAPI::Member

Inherits:
Object
  • Object
show all
Defined in:
lib/pluralkit-api/models/member.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Member

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



148
149
150
151
152
153
154
155
156
157
158
159
160
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/pluralkit-api/models/member.rb', line 148

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `PluralKitAPI::Member` 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::Member`. 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?(:'display_name')
    self.display_name = attributes[:'display_name']
  end

  if attributes.key?(:'description')
    self.description = attributes[:'description']
  end

  if attributes.key?(:'color')
    self.color = attributes[:'color']
  end

  if attributes.key?(:'birthday')
    self.birthday = attributes[:'birthday']
  end

  if attributes.key?(:'pronouns')
    self.pronouns = attributes[:'pronouns']
  end

  if attributes.key?(:'avatar_url')
    self.avatar_url = attributes[:'avatar_url']
  end

  if attributes.key?(:'privacy')
    self.privacy = attributes[:'privacy']
  end

  if attributes.key?(:'visibility')
    self.visibility = attributes[:'visibility']
  end

  if attributes.key?(:'name_privacy')
    self.name_privacy = attributes[:'name_privacy']
  end

  if attributes.key?(:'description_privacy')
    self.description_privacy = attributes[:'description_privacy']
  end

  if attributes.key?(:'avatar_privacy')
    self.avatar_privacy = attributes[:'avatar_privacy']
  end

  if attributes.key?(:'pronouns_privacy')
    self.pronouns_privacy = attributes[:'pronouns_privacy']
  end

  if attributes.key?(:'birthday_privacy')
    self.birthday_privacy = attributes[:'birthday_privacy']
  end

  if attributes.key?(:'metadata_privacy')
    self. = attributes[:'metadata_privacy']
  end

  if attributes.key?(:'proxy_tags')
    if (value = attributes[:'proxy_tags']).is_a?(Array)
      self.proxy_tags = value
    end
  end

  if attributes.key?(:'prefix')
    self.prefix = attributes[:'prefix']
  end

  if attributes.key?(:'suffix')
    self.suffix = attributes[:'suffix']
  end

  if attributes.key?(:'keep_proxy')
    self.keep_proxy = attributes[:'keep_proxy']
  else
    self.keep_proxy = false
  end

  if attributes.key?(:'created')
    self.created = attributes[:'created']
  end
end

Instance Attribute Details

#avatar_privacyObject

Returns the value of attribute avatar_privacy.



50
51
52
# File 'lib/pluralkit-api/models/member.rb', line 50

def avatar_privacy
  @avatar_privacy
end

#avatar_urlObject

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
41
42
# File 'lib/pluralkit-api/models/member.rb', line 40

def avatar_url
  @avatar_url
end

#birthdayObject

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
35
36
# File 'lib/pluralkit-api/models/member.rb', line 34

def birthday
  @birthday
end

#birthday_privacyObject

Returns the value of attribute birthday_privacy.



54
55
56
# File 'lib/pluralkit-api/models/member.rb', line 54

def birthday_privacy
  @birthday_privacy
end

#colorObject

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
32
33
# File 'lib/pluralkit-api/models/member.rb', line 31

def color
  @color
end

#createdObject

The creation timestamp of the member. May be returned as ‘null` depending on the value of `metadata_privacy` and the request authorization.



71
72
73
# File 'lib/pluralkit-api/models/member.rb', line 71

def created
  @created
end

#descriptionObject

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
29
30
# File 'lib/pluralkit-api/models/member.rb', line 28

def description
  @description
end

#description_privacyObject

Returns the value of attribute description_privacy.



48
49
50
# File 'lib/pluralkit-api/models/member.rb', line 48

def description_privacy
  @description_privacy
end

#display_nameObject

The member’s "display name", which will override the member’s normal name when proxying.



25
26
27
# File 'lib/pluralkit-api/models/member.rb', line 25

def display_name
  @display_name
end

#idObject

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/member.rb', line 19

def id
  @id
end

#keep_proxyObject

Whether or not to include the used proxy tags in proxied messages.



68
69
70
# File 'lib/pluralkit-api/models/member.rb', line 68

def keep_proxy
  @keep_proxy
end

#metadata_privacyObject

Returns the value of attribute metadata_privacy.



56
57
58
# File 'lib/pluralkit-api/models/member.rb', line 56

def 
  @metadata_privacy
end

#nameObject

The user-provided name of the member.



22
23
24
# File 'lib/pluralkit-api/models/member.rb', line 22

def name
  @name
end

#name_privacyObject

Returns the value of attribute name_privacy.



46
47
48
# File 'lib/pluralkit-api/models/member.rb', line 46

def name_privacy
  @name_privacy
end

#prefixObject

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
63
64
# File 'lib/pluralkit-api/models/member.rb', line 62

def prefix
  @prefix
end

#privacyObject

Returns the value of attribute privacy.



42
43
44
# File 'lib/pluralkit-api/models/member.rb', line 42

def privacy
  @privacy
end

#pronounsObject

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
38
39
# File 'lib/pluralkit-api/models/member.rb', line 37

def pronouns
  @pronouns
end

#pronouns_privacyObject

Returns the value of attribute pronouns_privacy.



52
53
54
# File 'lib/pluralkit-api/models/member.rb', line 52

def pronouns_privacy
  @pronouns_privacy
end

#proxy_tagsObject

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
60
61
# File 'lib/pluralkit-api/models/member.rb', line 59

def proxy_tags
  @proxy_tags
end

#suffixObject

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
66
67
# File 'lib/pluralkit-api/models/member.rb', line 65

def suffix
  @suffix
end

#visibilityObject

Returns the value of attribute visibility.



44
45
46
# File 'lib/pluralkit-api/models/member.rb', line 44

def visibility
  @visibility
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



101
102
103
# File 'lib/pluralkit-api/models/member.rb', line 101

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/pluralkit-api/models/member.rb', line 74

def self.attribute_map
  {
    :'id' => :'id',
    :'name' => :'name',
    :'display_name' => :'display_name',
    :'description' => :'description',
    :'color' => :'color',
    :'birthday' => :'birthday',
    :'pronouns' => :'pronouns',
    :'avatar_url' => :'avatar_url',
    :'privacy' => :'privacy',
    :'visibility' => :'visibility',
    :'name_privacy' => :'name_privacy',
    :'description_privacy' => :'description_privacy',
    :'avatar_privacy' => :'avatar_privacy',
    :'pronouns_privacy' => :'pronouns_privacy',
    :'birthday_privacy' => :'birthday_privacy',
    :'metadata_privacy' => :'metadata_privacy',
    :'proxy_tags' => :'proxy_tags',
    :'prefix' => :'prefix',
    :'suffix' => :'suffix',
    :'keep_proxy' => :'keep_proxy',
    :'created' => :'created'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



451
452
453
# File 'lib/pluralkit-api/models/member.rb', line 451

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/pluralkit-api/models/member.rb', line 133

def self.openapi_nullable
  Set.new([
    :'display_name',
    :'color',
    :'birthday',
    :'pronouns',
    :'avatar_url',
    :'prefix',
    :'suffix',
    :'created'
  ])
end

.openapi_typesObject

Attribute type mapping.



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
# File 'lib/pluralkit-api/models/member.rb', line 106

def self.openapi_types
  {
    :'id' => :'String',
    :'name' => :'String',
    :'display_name' => :'String',
    :'description' => :'String',
    :'color' => :'String',
    :'birthday' => :'Date',
    :'pronouns' => :'String',
    :'avatar_url' => :'String',
    :'privacy' => :'PrivacySetting',
    :'visibility' => :'PrivacySetting',
    :'name_privacy' => :'PrivacySetting',
    :'description_privacy' => :'PrivacySetting',
    :'avatar_privacy' => :'PrivacySetting',
    :'pronouns_privacy' => :'PrivacySetting',
    :'birthday_privacy' => :'PrivacySetting',
    :'metadata_privacy' => :'PrivacySetting',
    :'proxy_tags' => :'Array<ProxyTag>',
    :'prefix' => :'String',
    :'suffix' => :'String',
    :'keep_proxy' => :'Boolean',
    :'created' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/pluralkit-api/models/member.rb', line 410

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      name == o.name &&
      display_name == o.display_name &&
      description == o.description &&
      color == o.color &&
      birthday == o.birthday &&
      pronouns == o.pronouns &&
      avatar_url == o.avatar_url &&
      privacy == o.privacy &&
      visibility == o.visibility &&
      name_privacy == o.name_privacy &&
      description_privacy == o.description_privacy &&
      avatar_privacy == o.avatar_privacy &&
      pronouns_privacy == o.pronouns_privacy &&
      birthday_privacy == o.birthday_privacy &&
       == o. &&
      proxy_tags == o.proxy_tags &&
      prefix == o.prefix &&
      suffix == o.suffix &&
      keep_proxy == o.keep_proxy &&
      created == o.created
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
# File 'lib/pluralkit-api/models/member.rb', line 481

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

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/pluralkit-api/models/member.rb', line 552

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

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/pluralkit-api/models/member.rb', line 458

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

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


438
439
440
# File 'lib/pluralkit-api/models/member.rb', line 438

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



444
445
446
# File 'lib/pluralkit-api/models/member.rb', line 444

def hash
  [id, name, display_name, description, color, birthday, pronouns, avatar_url, privacy, visibility, name_privacy, description_privacy, avatar_privacy, pronouns_privacy, birthday_privacy, , proxy_tags, prefix, suffix, keep_proxy, created].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/pluralkit-api/models/member.rb', line 252

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 !@display_name.nil? && @display_name.to_s.length > 100
    invalid_properties.push('invalid value for "display_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 !@color.nil? && @color.to_s.length > 6
    invalid_properties.push('invalid value for "color", the character length must be smaller than or equal to 6.')
  end

  if !@color.nil? && @color.to_s.length < 6
    invalid_properties.push('invalid value for "color", the character length must be great than or equal to 6.')
  end

  pattern = Regexp.new(/^[0-9A-Fa-f]{6}$/)
  if !@color.nil? && @color !~ pattern
    invalid_properties.push("invalid value for \"color\", must conform to the pattern #{pattern}.")
  end

  if !@pronouns.nil? && @pronouns.to_s.length > 100
    invalid_properties.push('invalid value for "pronouns", the character length must be smaller than or equal to 100.')
  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_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



528
529
530
# File 'lib/pluralkit-api/models/member.rb', line 528

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'lib/pluralkit-api/models/member.rb', line 534

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_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



522
523
524
# File 'lib/pluralkit-api/models/member.rb', line 522

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/pluralkit-api/models/member.rb', line 305

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 !@display_name.nil? && @display_name.to_s.length > 100
  return false if !@description.nil? && @description.to_s.length > 1000
  return false if !@color.nil? && @color.to_s.length > 6
  return false if !@color.nil? && @color.to_s.length < 6
  return false if !@color.nil? && @color !~ Regexp.new(/^[0-9A-Fa-f]{6}$/)
  return false if !@pronouns.nil? && @pronouns.to_s.length > 100
  return false if !@avatar_url.nil? && @avatar_url.to_s.length > 256
  true
end