diff options
author | Julien Dessaux | 2023-06-12 23:40:07 +0200 |
---|---|---|
committer | Julien Dessaux | 2023-06-12 23:40:07 +0200 |
commit | 28b3a695dce34b5adafb0139978de63271f75180 (patch) | |
tree | b7d1df0ef4d8cb2b5e910bc8e14c2f4045e95a1e /lib | |
parent | Take requests time in consideration for rate limiting calculations (diff) | |
download | spacetraders-28b3a695dce34b5adafb0139978de63271f75180.tar.gz spacetraders-28b3a695dce34b5adafb0139978de63271f75180.tar.bz2 spacetraders-28b3a695dce34b5adafb0139978de63271f75180.zip |
Use the database cache for mining and contracting automations
Diffstat (limited to 'lib')
-rw-r--r-- | lib/contracts.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/contracts.js b/lib/contracts.js index abf32b3..316e181 100644 --- a/lib/contracts.js +++ b/lib/contracts.js @@ -1,4 +1,5 @@ import * as api from './api.js'; +import * as dbShips from '../database/ships.js'; export async function accept(ctx) { return await api.send({endpoint: `/my/contracts/${ctx.contract}/accept`, method: 'POST'}); @@ -9,11 +10,15 @@ export async function contracts() { } export async function deliver(ctx) { - return await api.send({ endpoint: `/my/contracts/${ctx.contract}/deliver`, method: 'POST', payload: { + const response = await api.send({ endpoint: `/my/contracts/${ctx.contract}/deliver`, method: 'POST', payload: { shipSymbol: ctx.symbol, tradeSymbol: ctx.good, units: ctx.units, }}); + if (response.error !== undefined) { + throw response; + } + dbShips.setShipCargo(ctx.symbol, response.data.cargo); } export async function fulfill(ctx) { |