import ngModule from '../module'; class Email { constructor($http, $translate, vnApp) { this.$http = $http; this.vnApp = vnApp; this.$t = $translate.instant; } /** * Sends an email displaying a notification when it's sent. * * @param {String} template The email report name * @param {Object} params The email parameters * @return {Promise} Promise resolved when it's sent */ send(template, params) { return this.$http.get(`email/${template}`, {params}) .then(() => this.vnApp.showMessage(this.$t('Notification sent!'))); } /** * Sends an email displaying a notification when it's sent. * * @param {String} template The email report name * @param {Object} params The email parameters * @return {Promise} Promise resolved when it's sent */ sendCsv(template, params) { return this.$http.get(`csv/${template}/send`, {params}) .then(() => this.vnApp.showMessage(this.$t('Notification sent!'))); } } Email.$inject = ['$http', '$translate', 'vnApp']; ngModule.service('vnEmail', Email);