diff --git a/packages/api-core/src/ms.js b/packages/api-core/src/ms.js index 1758918e1..1922289aa 100644 --- a/packages/api-core/src/ms.js +++ b/packages/api-core/src/ms.js @@ -23,4 +23,18 @@ export default class AvMicroservice extends AvApi { .replace(/[/]+/g, '/') .replace(/\/$/, ''); } + + // make request to http + request(config, afterResponse) { + return this.http(config) + .then(response => this.onResponse(response, afterResponse)) + .catch(error => { + let response; + if (error) { + response = error; + response.error = true; + } + return afterResponse ? afterResponse(response) : response; + }); + } } diff --git a/packages/api-core/src/resources/README.md b/packages/api-core/src/resources/README.md index dfbcd6ba1..8939396ca 100644 --- a/packages/api-core/src/resources/README.md +++ b/packages/api-core/src/resources/README.md @@ -98,7 +98,7 @@ Upload a file to a bucket in the vault #### `uploadFile(data, config)` Method to upload a file. `data` contains FormData elements with a key of either `reference` (if pointed to an existing file) or `filedata` (if uploading a new file) -`config` should contain `customerId` and `id` (the bucketId) +`config` should contain `customerId`, `id` (the bucketId), and `clientId` ### AvSettings diff --git a/packages/api-core/src/resources/files.js b/packages/api-core/src/resources/files.js index 647b8af0b..a4d3d530c 100644 --- a/packages/api-core/src/resources/files.js +++ b/packages/api-core/src/resources/files.js @@ -7,7 +7,6 @@ export default class AvFiles extends AvMicroservice { name: 'core/vault/upload/v1', headers: { 'Content-Type': undefined, - 'X-App-Context': 'ecs-qa-app-context', }, }, config @@ -21,8 +20,13 @@ export default class AvFiles extends AvMicroservice { } uploadFile(data, config) { + if (!config.customerId || !config.clientId) { + throw Error('[config.customerId] and [config.clientId] must be defined'); + } config = this.config(config); config.headers['X-Availity-Customer-ID'] = config.customerId; + config.headers['X-Client-ID'] = config.clientId; + return this.create(data, config); } } diff --git a/packages/api-core/src/resources/tests/files.test.js b/packages/api-core/src/resources/tests/files.test.js index 7e4c355b9..bab80a5ab 100644 --- a/packages/api-core/src/resources/tests/files.test.js +++ b/packages/api-core/src/resources/tests/files.test.js @@ -7,6 +7,8 @@ const mockMerge = jest.fn((...args) => Object.assign(...args)); const mockConfig = { id: '123', + clientId: '123-456', + customerId: '1194', }; describe('AvFiles', () => {