eve-contract

1.0.0 • Public • Published

Eve Contract

Module to fetch contracts from ESI. Uses eve-esi-client to manage tokens.

Example

Convoluted example to show off the contract handler. See the eve-esi-client documentation to learn about the client and token management.

import ESI from 'eve-esi-client'

import ContractHandler, {
  Source
} from 'eve-contract'

const provider = new Provider()
const esi = new ESI({ provider })

async function run () {
  // We assume the provider has a token for the given
  // character ID and scope combo
  const token = await provider.getToken(
    1234, // character ID
    'esi-contracts.read_character_contracts.v1' // scope(s)
  )
  
  const handler = new ContractHandler(
    esi,
    Source.CHARACTER, // contract source, character or corporation
    1234, // contract source ID
    {
      token // token to use
    }
  )
  
  for await (const contract of handler.fetch()) {
    console.log(contract.contract_id)
    
    if (contract.volume) {
      // Fetch all contract items
      const items = await handler.fetchItems(contract.contract_id)
    }
  }
}

License

Copyright 2020 Michiel van der Velde.

This software is licensed under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i eve-contract

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

5.21 kB

Total Files

5

Last publish

Collaborators

  • michielvdvelde