39 lines
999 B
JavaScript
39 lines
999 B
JavaScript
|
|
module.exports = Self => {
|
|
Self.remoteMethodCtx('getEvents', {
|
|
description: 'Returns delivery days for a postcode',
|
|
accepts: [
|
|
{
|
|
arg: 'geoFk',
|
|
type: 'number',
|
|
description: 'The geo id'
|
|
},
|
|
{
|
|
arg: 'agencyModeFk',
|
|
type: 'number',
|
|
description: 'The agency mode id'
|
|
}
|
|
|
|
],
|
|
returns: {
|
|
type: 'object',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/getEvents`,
|
|
verb: 'GET'
|
|
}
|
|
});
|
|
|
|
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);
|
|
|
|
return {events, exclusions};
|
|
};
|
|
};
|