import fileDownload from  'js-file-download';
import HtmlClient from './HtmlClient';

const htmlClient = new HtmlClient();

class FileDownloader {
    download(fileUrl, fileName){
        htmlClient.fetch({
                url: fileUrl,
                responseType: 'arraybuffer'
            })
            .then((response) => {
                fileDownload(response.data, fileName);
            })
            .catch(error => {
                htmlClient.onError(error);
            })
    }
}

export default FileDownloader;
