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