1 | import { AvMicroservice } from '@availity/api-core';
|
2 | import fileDownload from 'js-file-download';
|
3 |
|
4 | export default class DownloadMicroservice extends AvMicroservice {
|
5 | constructor({ http, promise, merge, config }) {
|
6 | if (!config.clientId) {
|
7 | throw new Error('[config.clientId] must be defined');
|
8 | }
|
9 |
|
10 | const options = {
|
11 | headers: { 'X-Client-ID': config.clientId },
|
12 | responseType: 'blob',
|
13 | ...config,
|
14 | };
|
15 | super({ http, promise, merge, config: options });
|
16 | }
|
17 |
|
18 | getAttachment(config) {
|
19 | return this.query(config);
|
20 | }
|
21 |
|
22 | downloadAttachment(data, filename, mime) {
|
23 | fileDownload(data, filename, mime);
|
24 | }
|
25 | }
|