f0ca06c9725afea31ca103e0e755b2a8a7d8c900
[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 _0x644d=['catch','util','moment','bluebird','ioredis','../../config/utils','../../config/logger','../../config/environment','http','request','then','request\x20sent','debug','Cdr,\x20%s,\x20%s,\x20%s','stringify','error','code','Cdr,\x20%s,\x20%s','message','info','result'];(function(_0x4b0935,_0x4093f0){var _0x3f83f6=function(_0x8482f1){while(--_0x8482f1){_0x4b0935['push'](_0x4b0935['shift']());}};_0x3f83f6(++_0x4093f0);}(_0x644d,0x112));var _0xd644=function(_0x3b150c,_0x2f93f8){_0x3b150c=_0x3b150c-0x0;var _0x5cd414=_0x644d[_0x3b150c];return _0x5cd414;};'use strict';var _=require('lodash');var util=require(_0xd644('0x0'));var moment=require(_0xd644('0x1'));var BPromise=require(_0xd644('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xd644('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0xd644('0x4'));var logger=require(_0xd644('0x5'))('rpc');var config=require(_0xd644('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0xd644('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x484f8a,_0x4e01ac,_0x1373ea){return new BPromise(function(_0x45fd4f,_0x12702f){return client[_0xd644('0x8')](_0x484f8a,_0x1373ea)[_0xd644('0x9')](function(_0x56e19b){logger['info']('Cdr,\x20%s,\x20%s',_0x4e01ac,_0xd644('0xa'));logger[_0xd644('0xb')](_0xd644('0xc'),_0x4e01ac,_0xd644('0xa'),JSON[_0xd644('0xd')](_0x56e19b));if(_0x56e19b[_0xd644('0xe')]){if(_0x56e19b[_0xd644('0xe')][_0xd644('0xf')]===0x1f4){logger[_0xd644('0xe')](_0xd644('0x10'),_0x4e01ac,_0x56e19b['error']['message']);return _0x12702f(_0x56e19b[_0xd644('0xe')][_0xd644('0x11')]);}logger['error'](_0xd644('0x10'),_0x4e01ac,_0x56e19b[_0xd644('0xe')][_0xd644('0x11')]);return _0x45fd4f(_0x56e19b[_0xd644('0xe')]['message']);}else{logger[_0xd644('0x12')](_0xd644('0x10'),_0x4e01ac,_0xd644('0xa'));_0x45fd4f(_0x56e19b[_0xd644('0x13')][_0xd644('0x11')]);}})[_0xd644('0x14')](function(_0x6c635b){logger[_0xd644('0xe')](_0xd644('0x10'),_0x4e01ac,_0x6c635b);_0x12702f(_0x6c635b);});});}