Class: Fittings

Fittings

An api adapter over the end points handling a character's fittings via functions in the fittings 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 Fittings 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 Fittings(agent, characterId, token)

Create a new Fittings 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 fittings are accessed

token String

The SSO access token for the character

Methods


add(fitting)

Save a new fitting for a character.

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

An example value for fitting is shown below:

{
  "description": "description string",
  "items": [
    {
      "flag": 0,
      "quantity": 0,
      "type_id": 0
    }
  ],
  "name": "name string",
  "ship_type_id": 0
}

On success, this resolves to the id of the created entity. The id is extracted from the fitting_id property of the response object.

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

  • esi-fittings.write_fittings.v1
Parameters:
Name Type Description
fitting Object

Details about the new fitting.

Returns:

A Promise that resolves to an id.

Type
Promise.<Number>

all()

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

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

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

[
  {
    "description": "Awesome Vindi fitting",
    "fitting_id": 1,
    "items": [
      {
        "flag": 12,
        "quantity": 1,
        "type_id": 1234
      }
    ],
    "name": "Best Vindicator",
    "ship_type_id": 123
  }
]

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

  • esi-fittings.read_fittings.v1
Returns:

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

Type
Promise.<Array.<Object>>

get(id)

Create a new Fitting end point targeting the particular fitting by id.

Parameters:
Name Type Description
id Number

The fitting id

Returns:
Type
Fitting