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

39 lines
999 B
JavaScript
Raw Normal View History

2019-09-25 18:06:42 +00:00
module.exports = Self => {
2023-06-01 06:32:06 +00:00
Self.remoteMethodCtx('getEvents', {
2019-09-25 18:06:42 +00:00
description: 'Returns delivery days for a postcode',
accepts: [
{
2020-03-24 16:32:30 +00:00
arg: 'geoFk',
type: 'number',
2020-03-24 16:32:30 +00:00
description: 'The geo id'
},
{
2019-11-14 13:37:18 +00:00
arg: 'agencyModeFk',
type: 'number',
2019-11-14 13:37:18 +00:00
description: 'The agency mode id'
2019-09-25 18:06:42 +00:00
}
2020-03-24 16:32:30 +00:00
2019-09-25 18:06:42 +00:00
],
returns: {
type: 'object',
2019-09-25 18:06:42 +00:00
root: true
},
http: {
path: `/getEvents`,
verb: 'GET'
}
});
2023-06-01 06:32:06 +00:00
Self.getEvents = async(ctx, geoFk, agencyModeFk, options) => {
const myOptions = {userId: ctx.req.accessToken.userId};
if (typeof options == 'object')
Object.assign(myOptions, options);
const [events, exclusions] = await Self.rawSql('CALL zone_getEvents(?, ?)', [geoFk, agencyModeFk], myOptions);
2019-09-25 18:06:42 +00:00
return {events, exclusions};
};
};