c98139586a014d6f8f3c2787cbc57fa375ce6875
[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 _0xfdab=['stringify','error','message','catch','lodash','util','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','info','Cdr,\x20%s,\x20%s','debug','Cdr,\x20%s,\x20%s,\x20%s','request\x20sent'];(function(_0x529f7e,_0x24b033){var _0x234b87=function(_0x4abefe){while(--_0x4abefe){_0x529f7e['push'](_0x529f7e['shift']());}};_0x234b87(++_0x24b033);}(_0xfdab,0x180));var _0xbfda=function(_0x525fbb,_0x25e110){_0x525fbb=_0x525fbb-0x0;var _0x402595=_0xfdab[_0x525fbb];return _0x402595;};'use strict';var _=require(_0xbfda('0x0'));var util=require(_0xbfda('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xbfda('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xbfda('0x3'))['db'];var utils=require(_0xbfda('0x4'));var logger=require(_0xbfda('0x5'))(_0xbfda('0x6'));var config=require('../../config/environment');var jayson=require(_0xbfda('0x7'));var client=jayson[_0xbfda('0x8')][_0xbfda('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x33f0ec,_0x1c4c46,_0x1f5ea3){return new BPromise(function(_0x463ff3,_0x1b191d){return client[_0xbfda('0xa')](_0x33f0ec,_0x1f5ea3)['then'](function(_0x52901f){logger[_0xbfda('0xb')](_0xbfda('0xc'),_0x1c4c46,'request\x20sent');logger[_0xbfda('0xd')](_0xbfda('0xe'),_0x1c4c46,_0xbfda('0xf'),JSON[_0xbfda('0x10')](_0x52901f));if(_0x52901f[_0xbfda('0x11')]){if(_0x52901f[_0xbfda('0x11')]['code']===0x1f4){logger['error'](_0xbfda('0xc'),_0x1c4c46,_0x52901f[_0xbfda('0x11')]['message']);return _0x1b191d(_0x52901f[_0xbfda('0x11')]['message']);}logger[_0xbfda('0x11')]('Cdr,\x20%s,\x20%s',_0x1c4c46,_0x52901f[_0xbfda('0x11')]['message']);return _0x463ff3(_0x52901f['error'][_0xbfda('0x12')]);}else{logger[_0xbfda('0xb')]('Cdr,\x20%s,\x20%s',_0x1c4c46,_0xbfda('0xf'));_0x463ff3(_0x52901f['result'][_0xbfda('0x12')]);}})[_0xbfda('0x13')](function(_0x3fab1f){logger[_0xbfda('0x11')](_0xbfda('0xc'),_0x1c4c46,_0x3fab1f);_0x1b191d(_0x3fab1f);});});}