(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["default~add-money-add-money-module~dashboard-dashboard-module~service-wallet-recharge-service-wallet~05c51d99"],{

/***/ "vjAt":
/*!****************************************!*\
  !*** ./src/services/wallet.service.ts ***!
  \****************************************/
/*! exports provided: WalletService */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WalletService", function() { return WalletService; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "mrSG");
/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @angular/core */ "fXoL");
/* harmony import */ var _angular_common_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @angular/common/http */ "tk/3");
/* harmony import */ var _base_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base-service */ "4YT6");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants */ "k8oS");
/* harmony import */ var _common_service__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./common.service */ "FBGF");
/* harmony import */ var _ionic_native_social_sharing_ngx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @ionic-native/social-sharing/ngx */ "/XPu");







let WalletService = class WalletService extends _base_service__WEBPACK_IMPORTED_MODULE_3__["BaseService"] {
    constructor(_httpClient, _commonService, _socialSharing) {
        super();
        this._httpClient = _httpClient;
        this._commonService = _commonService;
        this._socialSharing = _socialSharing;
        this.paramName = "walletstmt";
        this.fileName = 'wallet.service.ts';
    }
    getAllStatement(obj) {
        try {
            let filterParamData = null;
            if (obj.vrn === undefined || obj.vrn == null) {
                filterParamData = [
                    {
                        "name": "txn_date",
                        "params": [
                            {
                                "name": "txn_date",
                                "value": obj.startDate + "T00:01Z"
                            },
                            {
                                "name": "txn_date",
                                "value": obj.endDate + "T23:59Z"
                            }
                        ]
                    }
                ];
            }
            else {
                filterParamData = [
                    {
                        "name": "txn_date",
                        "params": [
                            {
                                "name": "txn_date",
                                "value": obj.startDate + "T00:01Z"
                            },
                            {
                                "name": "txn_date",
                                "value": obj.endDate + "T23:59Z"
                            }
                        ]
                    },
                    {
                        "name": "vehicle",
                        "params": [
                            {
                                "name": "vehicle",
                                "value": obj.vrn
                            }
                        ]
                    }
                ];
            }
            let paramData = null;
            if (obj.shareVia !== undefined && obj.shareVia == 'csv') {
                paramData = {
                    "name": this.paramName,
                    "format": obj === null || obj === void 0 ? void 0 : obj.shareVia,
                    "row_offset": 0,
                    "sorting": {
                        "id": "desc"
                    },
                    "filters": filterParamData
                };
            }
            else {
                paramData = {
                    "name": this.paramName,
                    "row_count": _constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].ROW_COUNT,
                    "row_offset": obj.offset,
                    "sorting": {
                        "id": "desc"
                    },
                    "filters": filterParamData
                };
            }
            let dataObj;
            dataObj = {
                offset: obj.offset,
                method: 'post',
                api_url: this.getLocalapiBaseURL() + _constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].WALLET_STATEMENT_API,
                local_json_file: 'local-wallet-statement',
                param_data: paramData,
                mapcol: true
            };
            return this._commonService.fetchData(dataObj);
        }
        catch (error) {
            let obj = {
                fileName: this.fileName,
                functionName: 'getAllStatement(obj)',
                error: error
            };
            this._commonService.systemException(obj);
        }
    }
    checkBalance(obj) {
        try {
            let data = {
                "customer_id": this.getLocalUserId(),
                "amount": "0",
                "mode": obj.mode
            };
            let dataObj = {
                offset: 0,
                method: 'post',
                api_url: this.getLocalapiBaseURL() + _constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].WALLET_TOPUP_BAL_ENQ,
                local_json_file: '',
                param_data: data,
                mapcol: false
            };
            return this._commonService.fetchData(dataObj);
        }
        catch (error) {
            let obj = {
                fileName: this.fileName,
                functionName: 'checkBalance(obj)',
                error: error
            };
            this._commonService.systemException(obj);
        }
    }
    beginPayment(obj) {
        try {
            let data = {
                "customer_id": this.getLocalUserId(),
                "amount": obj.amount,
                "mode": obj.mode
            };
            let dataObj = {
                offset: 0,
                method: 'post',
                api_url: this.getLocalapiBaseURL() + _constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].WALLET_TOPUP_BEGIN,
                local_json_file: '',
                param_data: data,
                mapcol: false
            };
            return this._commonService.fetchData(dataObj);
        }
        catch (error) {
            let obj = {
                fileName: this.fileName,
                functionName: 'beginPayment(obj)',
                error: error
            };
            this._commonService.systemException(obj);
        }
    }
    payment(obj) {
        try {
            let data = {
                "merchant_id": obj.merchant_id,
                "pg_request_enc": obj.pg_request_enc
            };
            let url = obj.pg_url;
            let dataObj = {
                offset: 0,
                method: 'post',
                api_url: url,
                local_json_file: '',
                param_data: data,
                mapcol: false
            };
            return this._commonService.fetchData(dataObj);
        }
        catch (error) {
            let obj = {
                fileName: this.fileName,
                functionName: 'payment(obj)',
                error: error
            };
            this._commonService.systemException(obj);
        }
    }
    shareFunction(messageObj) {
        return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(this, void 0, void 0, function* () {
            try {
                let data = yield this.shareMessageFormat(messageObj);
                this._socialSharing.share(data.message, data.subject, data.file, data.url).then((res) => {
                }).catch((error) => {
                    this.log('shared successfully');
                });
            }
            catch (error) {
                let obj = {
                    fileName: this.fileName,
                    functionName: 'shareFunction(messageObj)',
                    error: error
                };
                this._commonService.systemException(obj);
            }
        });
    }
    generateCSV(obj) {
        try {
            let dataObj;
            dataObj = {
                offset: 0,
                method: 'post',
                api_url: this.getLocalapiBaseURL() + _constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].WALLET_STATEMENT_API,
                local_json_file: 'local-wallet-statement',
                param_data: {
                    "name": "walletstmt",
                    "format": "csv",
                },
                mapcol: true
            };
            return this._commonService.fetchData(dataObj);
        }
        catch (error) {
            let obj = {
                fileName: this.fileName,
                functionName: 'generateCSV(obj)',
                error: error
            };
            this._commonService.systemException(obj);
        }
    }
    getTransactionStatus(obj) {
        try {
            let dataObj = {
                offset: 0,
                method: 'get',
                api_url: this.getLocalapiBaseURL() + _constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].PG_TRANSACTION_STATUS + '/' + obj.txt_id,
                local_json_file: '',
                param_data: {},
                mapcol: false
            };
            return this._commonService.fetchData(dataObj);
        }
        catch (error) {
            let obj = {
                fileName: this.fileName,
                functionName: 'getTransactionStatus(obj)',
                error: error
            };
            this._commonService.systemException(obj);
        }
    }
    shareMessageFormat(messageObj) {
        return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(this, void 0, void 0, function* () {
            try {
                let message = null;
                let subject = null;
                let file = null;
                let url = null;
                let tmp = '';
                tmp = _constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].SHARE_TOP_HEADER + '\n';
                tmp += 'Transaction Date:' + this.getDisplayDtTm(messageObj.txn_date) + '\n';
                if (messageObj.txn_type == 'DEBIT') {
                    tmp += 'Transaction Amount:' + this.currencyFormatter(messageObj.txn_amount, 'INR') + ' Dr\n';
                    tmp += 'VRN: ' + messageObj.udf5 + '\n';
                    tmp += 'Toll Plaza: ' + messageObj.udf4 + '\n';
                }
                else {
                    tmp += 'Transaction Amount:' + this.currencyFormatter(messageObj.txn_amount, 'INR') + ' Cr\n';
                    tmp += 'Ref ID: ' + messageObj.partner_ref_no + '\n';
                }
                tmp += 'Security Deposit:' + this.currencyFormatter(messageObj.security_deposit, 'INR') + '\n';
                tmp += 'Opening Balance:' + this.currencyFormatter(messageObj.opening_balance, 'INR') + '\n';
                tmp += 'Closing Balance:' + this.currencyFormatter(messageObj.closing_balance, 'INR') + '\n';
                tmp += 'Transaction ID: ' + messageObj.wallet_txn_id + '\n';
                tmp += 'Narration: ' + messageObj.narration + '\n';
                tmp += '\n' + _constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].SHARE_FOOTER_NOTE + '\n';
                message = tmp;
                return {
                    message: message,
                    subject: subject,
                    file: file,
                    url: url
                };
            }
            catch (err) {
                this.log('Error in messageGeneration ' + err);
            }
        });
    }
    shareFILE(obj) {
        console.log({
            obj: obj
        });
        try {
            // let blobObjVal = "data:application/csv;df:myOwnName.csv;base64,"+blobObj;
            this._socialSharing.share(null, null, obj.file, obj.url).then((res) => {
            }).catch((error) => {
                this.log('shared successfully');
            });
        }
        catch (error) {
            let obj = {
                fileName: this.fileName,
                functionName: 'shareFILE(messageObj)',
                error: error
            };
            this._commonService.systemException(obj);
        }
    }
};
WalletService.ctorParameters = () => [
    { type: _angular_common_http__WEBPACK_IMPORTED_MODULE_2__["HttpClient"] },
    { type: _common_service__WEBPACK_IMPORTED_MODULE_5__["CommonService"] },
    { type: _ionic_native_social_sharing_ngx__WEBPACK_IMPORTED_MODULE_6__["SocialSharing"] }
];
WalletService = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
    Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Injectable"])({
        providedIn: 'root'
    }),
    Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__metadata"])("design:paramtypes", [_angular_common_http__WEBPACK_IMPORTED_MODULE_2__["HttpClient"], _common_service__WEBPACK_IMPORTED_MODULE_5__["CommonService"], _ionic_native_social_sharing_ngx__WEBPACK_IMPORTED_MODULE_6__["SocialSharing"]])
], WalletService);



/***/ })

}]);
//# sourceMappingURL=default~add-money-add-money-module~dashboard-dashboard-module~service-wallet-recharge-service-wallet~05c51d99-es2015.js.map