2019-04-05 13:20:12 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethodCtx('deny', {
|
2019-07-25 07:55:09 +00:00
|
|
|
description: 'sets a ticket request to denied and returns the changes',
|
2019-04-05 13:20:12 +00:00
|
|
|
accessType: 'WRITE',
|
|
|
|
accepts: [{
|
|
|
|
arg: 'id',
|
|
|
|
type: 'Integer',
|
|
|
|
required: true,
|
|
|
|
description: 'The request ID',
|
|
|
|
}, {
|
|
|
|
arg: 'observation',
|
|
|
|
type: 'String',
|
|
|
|
required: true,
|
|
|
|
description: 'The request observation',
|
|
|
|
}],
|
|
|
|
returns: {
|
|
|
|
type: 'number',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/:id/deny`,
|
|
|
|
verb: 'post'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Self.deny = async ctx => {
|
|
|
|
let userId = ctx.req.accessToken.userId;
|
|
|
|
let worker = await Self.app.models.Worker.findOne({where: {userFk: userId}});
|
|
|
|
|
|
|
|
let params = {
|
|
|
|
isOk: false,
|
|
|
|
atenderFk: worker.id,
|
2019-07-25 07:55:09 +00:00
|
|
|
response: ctx.args.observation,
|
2019-04-05 13:20:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
let request = await Self.app.models.TicketRequest.findById(ctx.args.id);
|
|
|
|
return request.updateAttributes(params);
|
|
|
|
};
|
|
|
|
};
|