39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
|
|
module.exports = Self => {
|
|
Self.remoteMethod('getEvents', {
|
|
description: 'Returns delivery days for a postcode',
|
|
accepts: [
|
|
{
|
|
arg: 'provinceFk',
|
|
type: 'Number',
|
|
description: 'The province id',
|
|
required: true
|
|
}, {
|
|
arg: 'postCode',
|
|
type: 'String',
|
|
description: 'The postcode'
|
|
}, {
|
|
arg: 'agencyModeFk',
|
|
type: 'Number',
|
|
description: 'The agency mode id'
|
|
}
|
|
],
|
|
returns: {
|
|
type: 'Object',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/getEvents`,
|
|
verb: 'GET'
|
|
}
|
|
});
|
|
|
|
Self.getEvents = async(provinceFk, postCode, agencyModeFk) => {
|
|
let [events, exclusions] = await Self.rawSql(
|
|
`CALL zone_getEvents(?, ?, ?)`,
|
|
[provinceFk, postCode, agencyModeFk]
|
|
);
|
|
return {events, exclusions};
|
|
};
|
|
};
|