Created
September 19, 2015 14:03
-
-
Save Gopikrishna19/54cae057e95d280472c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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