Skip to content

Instantly share code, notes, and snippets.

@Gopikrishna19
Created September 19, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gopikrishna19/54cae057e95d280472c5 to your computer and use it in GitHub Desktop.
Save Gopikrishna19/54cae057e95d280472c5 to your computer and use it in GitHub Desktop.
(function () {
'use strict';
const angular = window.angular;
class TransactionSummarySvc {
constructor(
$translate,
$window,
RestangularSvc,
UserSvc,
UtilitiesSvc
) {
this.$translate = $translate;
this.$window = $window;
this.RestangularSvc = RestangularSvc;
this.UserSvc = UserSvc;
this.UtilitiesSvc = UtilitiesSvc;
}
exportToMultiPDFs(cartIds) {
this.requestFileData('finance/multipdf/ids/' + cartIds);
}
exportToSinglePDF(cartIds) {
this.requestFileData('finance/singlepdf/ids/' + cartIds);
}
requestFileData(url) {
this.RestangularSvc
.one(url)
.get()
.then((response) => this.requestFileDataSuccess(response))
.catch(() => this.requestFileDataError());
}
requestFileDataError() {
this.UtilitiesSvc.showMessage(this.$translate.instant('common.messages.EXPORT_FILE_ERROR'), 'error', 'account');
}
requestFileDataSuccess(response) {
this.$window.open('//localhost:5557/accounts/' + this.UserSvc.get('accountId') + '/file?fileLocation=' + response.fileLocation, '_blank');
}
}
angular.module('account')
.service('TransactionSummarySvc', [
'$translate',
'$window',
'RestangularSvc',
'UserSvc',
'UtilitiesSvc',
TransactionSummarySvc
]);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment