class PluralKitAPI::Member

Attributes

avatar_privacy[RW]
avatar_url[RW]

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).

birthday[RW]

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`.

birthday_privacy[RW]
color[RW]

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`.

created[RW]

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

description[RW]

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`.

description_privacy[RW]
display_name[RW]

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

id[RW]

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.

keep_proxy[RW]

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

metadata_privacy[RW]
name[RW]

The user-provided name of the member.

name_privacy[RW]
prefix[RW]

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.

privacy[RW]
pronouns[RW]

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`.

pronouns_privacy[RW]
proxy_tags[RW]

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.

suffix[RW]

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.

visibility[RW]

Public Class Methods

acceptable_attributes() click to toggle source

Returns all the JSON keys this model knows about

# File lib/pluralkit-api/models/member.rb, line 101
def self.acceptable_attributes
  attribute_map.values
end
attribute_map() click to toggle source

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

# 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) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/pluralkit-api/models/member.rb, line 451
def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# 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.metadata_privacy = 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
openapi_nullable() click to toggle source

List of attributes with nullable: true

# 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_types() click to toggle source

Attribute type mapping.

# 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

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute. @param [Object] Object to be compared

# 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 &&
      metadata_privacy == o.metadata_privacy &&
      proxy_tags == o.proxy_tags &&
      prefix == o.prefix &&
      suffix == o.suffix &&
      keep_proxy == o.keep_proxy &&
      created == o.created
end
_deserialize(type, value) click to toggle source

Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data

# 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) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# 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
avatar_url=(avatar_url) click to toggle source

Custom attribute writer method with validation @param [Object] avatar_url Value to be assigned

# File lib/pluralkit-api/models/member.rb, line 400
def avatar_url=(avatar_url)
  if !avatar_url.nil? && avatar_url.to_s.length > 256
    fail ArgumentError, 'invalid value for "avatar_url", the character length must be smaller than or equal to 256.'
  end

  @avatar_url = avatar_url
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# 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
color=(color) click to toggle source

Custom attribute writer method with validation @param [Object] color Value to be assigned

# File lib/pluralkit-api/models/member.rb, line 371
def color=(color)
  if !color.nil? && color.to_s.length > 6
    fail ArgumentError, 'invalid value for "color", the character length must be smaller than or equal to 6.'
  end

  if !color.nil? && color.to_s.length < 6
    fail ArgumentError, '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
    fail ArgumentError, "invalid value for \"color\", must conform to the pattern #{pattern}."
  end

  @color = color
end
description=(description) click to toggle source

Custom attribute writer method with validation @param [Object] description Value to be assigned

# File lib/pluralkit-api/models/member.rb, line 361
def description=(description)
  if !description.nil? && description.to_s.length > 1000
    fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 1000.'
  end

  @description = description
end
display_name=(display_name) click to toggle source

Custom attribute writer method with validation @param [Object] display_name Value to be assigned

# File lib/pluralkit-api/models/member.rb, line 351
def display_name=(display_name)
  if !display_name.nil? && display_name.to_s.length > 100
    fail ArgumentError, 'invalid value for "display_name", the character length must be smaller than or equal to 100.'
  end

  @display_name = display_name
end
eql?(o) click to toggle source

@see the `==` method @param [Object] Object to be compared

# File lib/pluralkit-api/models/member.rb, line 438
def eql?(o)
  self == o
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Integer] Hash code

# 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, metadata_privacy, proxy_tags, prefix, suffix, keep_proxy, created].hash
end
id=(id) click to toggle source

Custom attribute writer method with validation @param [Object] id Value to be assigned

# File lib/pluralkit-api/models/member.rb, line 322
def id=(id)
  if !id.nil? && id.to_s.length > 5
    fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 5.'
  end

  if !id.nil? && id.to_s.length < 5
    fail ArgumentError, '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
    fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
  end

  @id = id
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

# 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
name=(name) click to toggle source

Custom attribute writer method with validation @param [Object] name Value to be assigned

# File lib/pluralkit-api/models/member.rb, line 341
def name=(name)
  if !name.nil? && name.to_s.length > 100
    fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 100.'
  end

  @name = name
end
pronouns=(pronouns) click to toggle source

Custom attribute writer method with validation @param [Object] pronouns Value to be assigned

# File lib/pluralkit-api/models/member.rb, line 390
def pronouns=(pronouns)
  if !pronouns.nil? && pronouns.to_s.length > 100
    fail ArgumentError, 'invalid value for "pronouns", the character length must be smaller than or equal to 100.'
  end

  @pronouns = pronouns
end
to_body() click to toggle source

to_body is an alias to to_hash (backward compatibility) @return [Hash] Returns the object in the form of hash

# File lib/pluralkit-api/models/member.rb, line 528
def to_body
  to_hash
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# 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_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/pluralkit-api/models/member.rb, line 522
def to_s
  to_hash.to_s
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# 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