Class: Labels

Labels

An api adapter over the end points handling all labels in the character's inbox via functions in the mail ESI endpoints. You should not usually instantiate this directly as its constructor requires an internal api instance.

This is a function class so instances of Labels are functions and can be invoked directly, besides accessing its members. Its default function action is equivalent to get or all if no id is given.


new Labels(mail)

Create a new Labels function owned by the given mail.

Parameters:
Name Type Description
mail Mail

The owning mail

Methods


add(name, color)

Create a mail label.

This makes an HTTP POST request to /characters/{character_id}/mail/labels/. The route version is v2.

The route parameter, label, is built implicitly by the function. The function argument name maps to the name property of the label route parameter. The string length of name must be between 1 and 40. The function argument color maps to the color property of the label route parameter. color must be one of the following specific values or the request will fail:

  • #ffffff
  • #ffff01
  • #ff6600
  • #fe0000
  • #9a0000
  • #660066
  • #0000fe
  • #0099ff
  • #01ffff
  • #00ff33
  • #349800
  • #006634
  • #666666
  • #999999
  • #e6e6e6
  • #ffffcd
  • #99ffff
  • #ccff9a

On success, this resolves to the id of the created entity.

This function must be used with an SSO token that has the following scopes:

  • esi-mail.organize_mail.v1
Parameters:
Name Type Description
name String

Name string.

color String

Hexadecimal string representing label color, in RGB format. Defaults to white.

Returns:

A Promise that resolves to an id.

Type
Promise.<Number>

all()

Return a list of the users mail labels, unread counts for each label and a total unread count. This route is cached for up to 30 seconds.

This makes an HTTP GET request to /characters/{character_id}/mail/labels/. The route version is v3.

On success, this resolves to a list of mail labels and unread counts. An example result is:

[
  {
    "color": "color string",
    "label_id": 0,
    "name": "name string",
    "unread_count": 0
  }
]

Note that the type schema of the response is modified from what is defined in ESI. Specifically, it returns only the labels property.

This function must be used with an SSO token that has the following scopes:

  • esi-mail.read_mail.v1
Returns:

A Promise that resolves to labels array.

Type
Promise.<Array.<Object>>

get(id)

Get a Label instance corresponding to the given label id.

Parameters:
Name Type Description
id

The label id

Returns:
Type
Label