40 lines
1001 B
JavaScript
40 lines
1001 B
JavaScript
|
|
module.exports = Self => {
|
|
Self.remoteMethodCtx('updateClaimAction', {
|
|
description: 'Update a claim with privileges',
|
|
accessType: 'WRITE',
|
|
accepts: [{
|
|
arg: 'id',
|
|
type: 'number',
|
|
required: true,
|
|
description: 'Claim id',
|
|
http: {source: 'path'}
|
|
}, {
|
|
arg: 'responsibility',
|
|
type: 'number',
|
|
required: false
|
|
}, {
|
|
arg: 'isChargedToMana',
|
|
type: 'boolean',
|
|
required: false
|
|
}],
|
|
returns: {
|
|
type: 'object',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/:id/updateClaimAction`,
|
|
verb: 'patch'
|
|
}
|
|
});
|
|
|
|
Self.updateClaimAction = async(ctx, id) => {
|
|
const models = Self.app.models;
|
|
const claim = await models.Claim.findById(id);
|
|
const args = ctx.args;
|
|
delete args.ctx;
|
|
|
|
return await claim.updateAttributes(args);
|
|
};
|
|
};
|