Skip to content

Commit 3dd5392

Browse files
Christie BakerChristie Baker
authored andcommitted
fix(api-core): avFiles error handling
1 parent 68ce3b2 commit 3dd5392

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

packages/api-core/src/ms.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,18 @@ export default class AvMicroservice extends AvApi {
2323
.replace(/[/]+/g, '/')
2424
.replace(/\/$/, '');
2525
}
26+
27+
// make request to http
28+
request(config, afterResponse) {
29+
return this.http(config)
30+
.then(response => this.onResponse(response, afterResponse))
31+
.catch(error => {
32+
let response;
33+
if (error) {
34+
response = error;
35+
response.error = true;
36+
}
37+
return afterResponse ? afterResponse(response) : response;
38+
});
39+
}
2640
}

packages/api-core/src/resources/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Upload a file to a bucket in the vault
9898

9999
#### `uploadFile(data, config)`
100100
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)
101-
`config` should contain `customerId` and `id` (the bucketId)
101+
`config` should contain `customerId`, `id` (the bucketId), and `clientId`
102102

103103

104104
### AvSettings

packages/api-core/src/resources/files.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export default class AvFiles extends AvMicroservice {
77
name: 'core/vault/upload/v1',
88
headers: {
99
'Content-Type': undefined,
10-
'X-App-Context': 'ecs-qa-app-context',
1110
},
1211
},
1312
config
@@ -21,8 +20,13 @@ export default class AvFiles extends AvMicroservice {
2120
}
2221

2322
uploadFile(data, config) {
23+
if (!config.customerId || !config.clientId) {
24+
throw Error('[config.customerId] and [config.clientId] must be defined');
25+
}
2426
config = this.config(config);
2527
config.headers['X-Availity-Customer-ID'] = config.customerId;
28+
config.headers['X-Client-ID'] = config.clientId;
29+
2630
return this.create(data, config);
2731
}
2832
}

packages/api-core/src/resources/tests/files.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const mockMerge = jest.fn((...args) => Object.assign(...args));
77

88
const mockConfig = {
99
id: '123',
10+
clientId: '123-456',
11+
customerId: '1194',
1012
};
1113

1214
describe('AvFiles', () => {

0 commit comments

Comments
 (0)