Class: Contacts

Contacts

An api adapter over the end points handling a character's contacts via functions in the contacts 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 Contacts 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 provided.


new Contacts(agent, characterId, token)

Create a new Contacts function using the given agent, for the character described by characterId with SSO access from token.

Parameters:
Name Type Description
agent ESIAgent

The ESI agent

characterId Number

The character id whose contacts are accessed

token String

The SSO access token for the character

Methods


add(ids, standing, label)

Bulk add contacts with same settings.

This makes an HTTP POST request to /characters/{character_id}/contacts/. The route version is v1.

This function invokes the route with watched set to false. The array length of ids must be between 1 and 100. standing must be between -10 and 10.

On success, this resolves to the array of ids of the created entity.

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

  • esi-characters.write_contacts.v1
Parameters:
Name Type Description
ids Array.<Number>

A list of contacts to add.

standing Number

Standing for the new contact.

label Number

Add a custom label to the new contact.

Returns:

A Promise that resolves to an array of ids.

Type
Promise.<Array.<Number>>

addWatched(ids, standing, label)

Bulk add contacts with same settings.

This makes an HTTP POST request to /characters/{character_id}/contacts/. The route version is v1.

This function invokes the route with watched set to true. The array length of ids must be between 1 and 100. standing must be between -10 and 10.

On success, this resolves to the array of ids of the created entity.

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

  • esi-characters.write_contacts.v1
Parameters:
Name Type Description
ids Array.<Number>

A list of contacts to add.

standing Number

Standing for the new contact.

label Number

Add a custom label to the new contact.

Returns:

A Promise that resolves to an array of ids.

Type
Promise.<Array.<Number>>

all(page)

Return contacts of a character. This route is cached for up to 300 seconds.

This makes an HTTP GET request to /characters/{character_id}/contacts/. The route version is v1.

page must be at least 1.

On success, this resolves to a list of contacts. An example result is:

[
  {
    "contact_id": 123,
    "contact_type": "character",
    "is_blocked": false,
    "is_watched": true,
    "label_id": 0,
    "standing": 10
  }
]

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

  • esi-characters.read_contacts.v1
Parameters:
Name Type Default Description
page Number 0

Optional; page integer. If 0, all pages are returned, concatenated into a single array.

Returns:

A Promise that resolves to the parsed JSON of the response.

Type
Promise.<Array.<Object>>

get(id)

Create a new Contact end point targeting the particular contact by id.

Parameters:
Name Type Description
id Number

The contact id

Returns:
Type
Contact

labels()

Return custom labels for contacts the character defined. This route is cached for up to 300 seconds.

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

On success, this resolves to a list of contact labels. An example result is:

[
  {
    "label_id": 123,
    "label_name": "Friends"
  }
]

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

  • esi-characters.read_contacts.v1
Returns:

A Promise that resolves to the parsed JSON of the response.

Type
Promise.<Array.<Object>>