tibi-docs/api/hooks/rating/get_read.js
2024-03-11 17:26:10 +00:00

45 lines
1.0 KiB
JavaScript

// @ts-check
;(function () {
/** @type {HookResponse} */
let hookResponse
let request = context.request()
if (request.query("rateIt")) {
let orderNumber
orderNumber = Number(request.query("orderNumber"))
if (isNaN(orderNumber))
throw {
status: 400,
message: "Invalid order number.",
}
/*
TODO: reprogram to bigcommerce
let order = context.db.find("order", {
filter: {
sequence: orderNumber,
},
})[0]
if (!order)
throw {
status: 400,
message: "No entry with this order number.",
}
if (order.deliveryAddress.postcode != request.query("postalcode"))
throw {
status: 403,
message: "Error",
}
hookResponse = {
filter: {
orderId: order.id,
},
}*/
return hookResponse
}
})()