ee2d7ec6784e11e334b8d0ff76e5a53abcdf0511
[motion2.git] / server / api / cdr / cdr.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x5adc=['code','Cdr,\x20%s,\x20%s','message','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','request','then','info','request\x20sent','debug','Cdr,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x4576f2,_0x242283){var _0x323dc2=function(_0x514b3a){while(--_0x514b3a){_0x4576f2['push'](_0x4576f2['shift']());}};_0x323dc2(++_0x242283);}(_0x5adc,0xf6));var _0xc5ad=function(_0x26ddb6,_0x5d5923){_0x26ddb6=_0x26ddb6-0x0;var _0x56b3af=_0x5adc[_0x26ddb6];return _0x56b3af;};'use strict';var _=require(_0xc5ad('0x0'));var util=require('util');var moment=require(_0xc5ad('0x1'));var BPromise=require(_0xc5ad('0x2'));var rs=require(_0xc5ad('0x3'));var fs=require('fs');var Redis=require(_0xc5ad('0x4'));var db=require(_0xc5ad('0x5'))['db'];var utils=require(_0xc5ad('0x6'));var logger=require('../../config/logger')(_0xc5ad('0x7'));var config=require('../../config/environment');var jayson=require(_0xc5ad('0x8'));var client=jayson[_0xc5ad('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x166cbf,_0x464770,_0x5d1e5f){return new BPromise(function(_0x412f02,_0x39b123){return client[_0xc5ad('0xa')](_0x166cbf,_0x5d1e5f)[_0xc5ad('0xb')](function(_0x5ef0ec){logger[_0xc5ad('0xc')]('Cdr,\x20%s,\x20%s',_0x464770,_0xc5ad('0xd'));logger[_0xc5ad('0xe')](_0xc5ad('0xf'),_0x464770,_0xc5ad('0xd'),JSON[_0xc5ad('0x10')](_0x5ef0ec));if(_0x5ef0ec[_0xc5ad('0x11')]){if(_0x5ef0ec[_0xc5ad('0x11')][_0xc5ad('0x12')]===0x1f4){logger['error'](_0xc5ad('0x13'),_0x464770,_0x5ef0ec[_0xc5ad('0x11')][_0xc5ad('0x14')]);return _0x39b123(_0x5ef0ec['error'][_0xc5ad('0x14')]);}logger[_0xc5ad('0x11')](_0xc5ad('0x13'),_0x464770,_0x5ef0ec['error'][_0xc5ad('0x14')]);return _0x412f02(_0x5ef0ec['error']['message']);}else{logger[_0xc5ad('0xc')]('Cdr,\x20%s,\x20%s',_0x464770,_0xc5ad('0xd'));_0x412f02(_0x5ef0ec['result'][_0xc5ad('0x14')]);}})[_0xc5ad('0x15')](function(_0x1ae2f7){logger['error'](_0xc5ad('0x13'),_0x464770,_0x1ae2f7);_0x39b123(_0x1ae2f7);});});}