summaryrefslogtreecommitdiff
path: root/lib/contracts.js
diff options
context:
space:
mode:
authorJulien Dessaux2023-05-25 01:20:56 +0200
committerJulien Dessaux2023-05-25 01:20:56 +0200
commitb1157af9cd66878623ad1f9fadac862e4990901c (patch)
tree3e95713b4ede9d292a2bf00af88f36e7cbe12e0d /lib/contracts.js
parentRewrote the api rate limiter with promises instead of callbacks (diff)
downloadspacetraders-b1157af9cd66878623ad1f9fadac862e4990901c.tar.gz
spacetraders-b1157af9cd66878623ad1f9fadac862e4990901c.tar.bz2
spacetraders-b1157af9cd66878623ad1f9fadac862e4990901c.zip
Updated the lib for the new api
Diffstat (limited to '')
-rw-r--r--lib/contracts.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/contracts.js b/lib/contracts.js
new file mode 100644
index 0000000..9494595
--- /dev/null
+++ b/lib/contracts.js
@@ -0,0 +1,17 @@
+import * as api from './api.js';
+
+export async function accept(ctx) {
+ return await api.send({endpoint: `/my/contracts/${ctx.id}/accept`, method: 'POST'});
+}
+
+export async function contracts() {
+ return await api.send({endpoint: '/my/contracts'});
+}
+
+export async function deliver(ctx) {
+ return await api.send({ endpoint: `/my/contracts/${ctx.contract}/deliver`, method: 'POST', payload: {
+ shipSymbol: ctx.ship,
+ tradeSymbol: ctx.good,
+ units: ctx.units,
+ }});
+}