Test Interface Actions
Last updated
app.post('/test-interface/actions', (req, res) => {
const actionType = req.body['@type'];
switch (actionType) {
case 'test:SellerRequestedCancellationSimulateAction':
simulateSellerRequestedCancellation(req, res);
break;
case 'test:CustomerNoticeSimulateAction':
simulateCustomerNotice(req, res);
break;
default:
res.sendStatus(404);
break;
}
});app.get('/internal-admin-api/dashboard', (req, res) => {
res.send(`<form action="cancel-order" method="POST">
<label for="orderId">Cancel Order with ID:</label>
<input type="text" id="orderId" name="orderId" required />
<input type="submit" value="Cancel" />
</form>`);
});
app.post('/internal-admin-api/cancel-order', async (req, res) => {
await cancelOrderAndUpdateOrdersFeeds(req.body.orderId);
res.send('Successfully cancelled!');
});
app.post('/test-interface/actions', (req, res) => {
const actionType = req.body['@type'];
switch (actionType) {
case 'test:SellerRequestedCancellationSimulateAction':
await cancelOrderAndUpdateOrdersFeeds(req.body.object['@id']);
res.sendStatus(204);
break;
// ... other actions
}
async function cancelOrderAndUpdateOrdersFeeds(orderId) {
// ...
}