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',
|
2021-06-18 13:05:03 +00:00
|
|
|
type: 'number',
|
2020-03-24 16:32:30 +00:00
|
|
|
description: 'The geo id'
|
2021-06-18 13:05:03 +00:00
|
|
|
},
|
|
|
|
{
|
2019-11-14 13:37:18 +00:00
|
|
|
arg: 'agencyModeFk',
|
2021-06-18 13:05:03 +00:00
|
|
|
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: {
|
2021-06-18 13:05:03 +00:00
|
|
|
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};
|
2021-06-18 13:05:03 +00:00
|
|
|
|
|
|
|
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};
|
|
|
|
};
|
|
|
|
};
|