1.0.0 • Published 4 years ago

eve-contract v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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.