314d5eda6d960f9d47e2995448ab3ba3da3a4ccf
[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 _0xd257=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','request\x20sent','debug','error','code','message','Cdr,\x20%s,\x20%s','info','catch','lodash','moment'];(function(_0x34966f,_0x132d0e){var _0x47db98=function(_0xe12a5c){while(--_0xe12a5c){_0x34966f['push'](_0x34966f['shift']());}};_0x47db98(++_0x132d0e);}(_0xd257,0xda));var _0x7d25=function(_0x26721d,_0x448ba5){_0x26721d=_0x26721d-0x0;var _0x1035c5=_0xd257[_0x26721d];return _0x1035c5;};'use strict';var _=require(_0x7d25('0x0'));var util=require('util');var moment=require(_0x7d25('0x1'));var BPromise=require(_0x7d25('0x2'));var rs=require(_0x7d25('0x3'));var fs=require('fs');var Redis=require(_0x7d25('0x4'));var db=require(_0x7d25('0x5'))['db'];var utils=require(_0x7d25('0x6'));var logger=require(_0x7d25('0x7'))(_0x7d25('0x8'));var config=require(_0x7d25('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x7d25('0xa')][_0x7d25('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x221675,_0x236db0,_0x2ccb63){return new BPromise(function(_0x1b4b3c,_0x5f4ee3){return client[_0x7d25('0xc')](_0x221675,_0x2ccb63)[_0x7d25('0xd')](function(_0x16f25b){logger['info']('Cdr,\x20%s,\x20%s',_0x236db0,_0x7d25('0xe'));logger[_0x7d25('0xf')]('Cdr,\x20%s,\x20%s,\x20%s',_0x236db0,_0x7d25('0xe'),JSON['stringify'](_0x16f25b));if(_0x16f25b[_0x7d25('0x10')]){if(_0x16f25b['error'][_0x7d25('0x11')]===0x1f4){logger['error']('Cdr,\x20%s,\x20%s',_0x236db0,_0x16f25b[_0x7d25('0x10')][_0x7d25('0x12')]);return _0x5f4ee3(_0x16f25b[_0x7d25('0x10')]['message']);}logger[_0x7d25('0x10')](_0x7d25('0x13'),_0x236db0,_0x16f25b['error']['message']);return _0x1b4b3c(_0x16f25b[_0x7d25('0x10')][_0x7d25('0x12')]);}else{logger[_0x7d25('0x14')](_0x7d25('0x13'),_0x236db0,_0x7d25('0xe'));_0x1b4b3c(_0x16f25b['result'][_0x7d25('0x12')]);}})[_0x7d25('0x15')](function(_0x41e04d){logger['error']('Cdr,\x20%s,\x20%s',_0x236db0,_0x41e04d);_0x5f4ee3(_0x41e04d);});});}