diff options
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) { |