salix/modules/agency/back/methods/zone/getEvents.js

39 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-09-25 18:06:42 +00:00
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',
2019-09-25 18:06:42 +00:00
type: 'String',
2019-09-25 20:35:21 +00:00
description: 'The postcode'
2019-11-14 13:37:18 +00:00
}, {
arg: 'agencyModeFk',
type: 'Number',
description: 'The agency mode id'
2019-09-25 18:06:42 +00:00
}
],
returns: {
type: 'Object',
root: true
},
http: {
path: `/getEvents`,
verb: 'GET'
}
});
2019-11-14 13:37:18 +00:00
Self.getEvents = async(provinceFk, postCode, agencyModeFk) => {
2019-09-25 18:06:42 +00:00
let [events, exclusions] = await Self.rawSql(
`CALL zone_getEvents(?, ?, ?)`,
2019-11-14 13:37:18 +00:00
[provinceFk, postCode, agencyModeFk]
2019-09-25 18:06:42 +00:00
);
return {events, exclusions};
};
};