salix/services/loopback/common/methods/client/confirmTransaction.js

33 lines
951 B
JavaScript

const UserError = require('../../../common/helpers').UserError;
module.exports = Self => {
Self.remoteMethodCtx('confirmTransaction', {
description: 'Returns last entries',
accessType: 'READ',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'Transaction id'
}],
returns: {
type: 'Object',
root: true
},
http: {
path: `/confirmTransaction`,
verb: 'POST'
}
});
Self.confirmTransaction = async(ctx, id) => {
let userId = ctx.req.accessToken.userId;
let isAdministrative = await Self.app.models.Account.hasRole(userId, 'administrative');
if (!isAdministrative)
throw new UserError(`You don't have enough privileges to do that`);
return await Self.rawSql('CALL hedera.tpvTransactionConfirmById(?)', [id]);
};
};