Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { updateTransactionSchema } from '@logchain/apidefs';
import { AuthError, HmacPrincipal } from '@logchain/auth-strategies';
import { CONTENT_TYPE } from '@logchain/configs';
import { RegulatoryDeclarationsService } from '@logchain/services';
import { AnyObject } from '@logchain/types';
import { inject, service } from '@loopback/core';
import { oas, param, patch, requestBody } from '@loopback/rest';
import { SecurityBindings } from '@loopback/security';
@oas.tags('Calista')
export class CalistaController {
@inject(SecurityBindings.USER, { optional: true })
public hmacPrincipal: HmacPrincipal;
constructor(
@service(RegulatoryDeclarationsService)
public regulatoryDeclarationsService: RegulatoryDeclarationsService,
) {
}
@patch('/logchain-regulatory/companies/{uen}/transactions/{id}', {
responses: {
'200': {
description: 'Submit the regulatory declaration',
},
},
})
async updateTransaction(
@param.header.string('x-api-key') apiKey: string,
@param.path.string('uen') uen: string,
@param.path.integer('id') id: number,
@requestBody({
required: true,
content: {
[CONTENT_TYPE.JSON]: {
schema: updateTransactionSchema,
},
},
})
body: AnyObject
) {
if (apiKey !== process.env.CALISTA_SECRET_ACCESS_KEY) {
throw new AuthError(`The api incorrect`);
}
await this.regulatoryDeclarationsService.createHistory(uen, id, body.data);
await this.regulatoryDeclarationsService.updateTransaction(uen, id, body.data);
return {
status: 'success'
}
}
}
|