module.exports = Self => { Self.remoteMethod('updateFiscalData', { description: 'Updates fiscal data of a supplier', accessType: 'WRITE', accepts: [{ arg: 'ctx', type: 'Object', http: {source: 'context'} }, { arg: 'id', type: 'Number', description: 'The supplier id', http: {source: 'path'} }, { arg: 'name', type: 'string' }, { arg: 'nif', type: 'string' }, { arg: 'account', type: 'any' }, { arg: 'sageTaxTypeFk', type: 'any' }, { arg: 'sageWithholdingFk', type: 'any' }, { arg: 'sageTransactionTypeFk', type: 'any' }, { arg: 'postCode', type: 'any' }, { arg: 'street', type: 'any' }, { arg: 'city', type: 'string' }, { arg: 'provinceFk', type: 'any' }, { arg: 'countryFk', type: 'any' }], returns: { arg: 'res', type: 'string', root: true }, http: { path: `/:id/updateFiscalData`, verb: 'PATCH' } }); Self.updateFiscalData = async(ctx, supplierId) => { const models = Self.app.models; const args = ctx.args; const supplier = await models.Supplier.findById(supplierId); // Remove unwanted properties delete args.ctx; delete args.id; return supplier.updateAttributes(args); }; };