Moved the nodejs agent to its own subfolder to make room for my haskell agent
This commit is contained in:
parent
0bc0df0891
commit
36cc33f9e9
22 changed files with 0 additions and 0 deletions
26
nodejs/lib/contracts.js
Normal file
26
nodejs/lib/contracts.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
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'});
|
||||
}
|
||||
|
||||
export async function contracts() {
|
||||
return await api.send({endpoint: '/my/contracts'});
|
||||
}
|
||||
|
||||
export async function deliver(ctx) {
|
||||
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) {
|
||||
return await api.send({ endpoint: `/my/contracts/${ctx.contract}/fulfill`, method: 'POST'});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue