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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 1x 1x 1x 1x 1x 1x 1x 1x | import { inject, lifeCycleObserver, LifeCycleObserver } from '@loopback/core';
import { juggler } from '@loopback/repository';
const calistaKey = process.env.CALISTA_XBS_API_KEY;
const config = {
name: 'calista',
connector: require('loopback-connector-rest'),
options: {
headers: {
accept: 'application/json',
'content-type': 'application/json,charset=utf-8',
},
timeout: 5 * 60 * 1000,
},
operations: [
{
template: {
method: 'POST',
url: process.env.CALISTA_CREATE_EXPORT_DECLARATION_URL,
headers: {
'service-name': 'CRFDirectSubmission',
'xbs-api-key': calistaKey,
"accepts": "application/json",
"content-type": "application/json"
},
body: "{submitBody}"
},
functions: {
submitDeclaration: ['submitBody'],
},
},
{
template: {
method: 'POST',
url: process.env.CALISTA_CREATE_EXPORT_DECLARATION_URL,
headers: {
'service-name': 'CRFSupportDocsSubmission',
'xbs-api-key': calistaKey,
"accepts": "application/json",
"content-type": "application/json"
},
body: {
messageType: "DEC",
documentType: "SUPP",
routeId: "{routeId}",
attachment: {
numberOfFiles: "{numberOfFiles}",
files: "{documents}"
}
}
},
functions: {
submitDocumentForDeclaration: ['routeId', 'numberOfFiles', 'documents'],
},
},
],
};
// Observe application's life cycle to disconnect the datasource when
// application is stopped. This allows the application to be shut down
// gracefully. The `stop()` method is inherited from `juggler.DataSource`.
// Learn more at https://loopback.io/doc/en/lb4/Life-cycle.html
@lifeCycleObserver('datasource')
export class CalistaDataSource extends juggler.DataSource
implements LifeCycleObserver {
static dataSourceName = 'calista';
static readonly defaultConfig = config;
constructor(
@inject('datasources.config.calista', { optional: true })
dsConfig: object = config,
) {
super(dsConfig);
}
}
|