ff2a5224eb889d4da22e086a40d50a6a0bd27fbf
[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 _0x2ec4=['Cdr,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','lodash','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','http','request','then','info','Cdr,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x3d6cf2,_0x456384){var _0x3aa3eb=function(_0x5b685f){while(--_0x5b685f){_0x3d6cf2['push'](_0x3d6cf2['shift']());}};_0x3aa3eb(++_0x456384);}(_0x2ec4,0x1d2));var _0x42ec=function(_0x2b4411,_0x2625ed){_0x2b4411=_0x2b4411-0x0;var _0x8e41ef=_0x2ec4[_0x2b4411];return _0x8e41ef;};'use strict';var _=require(_0x42ec('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x42ec('0x1'));var fs=require('fs');var Redis=require(_0x42ec('0x2'));var db=require(_0x42ec('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x42ec('0x4'))('rpc');var config=require(_0x42ec('0x5'));var jayson=require(_0x42ec('0x6'));var client=jayson['client'][_0x42ec('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x4fb9b3,_0x4f6fcd,_0x2ab2a2){return new BPromise(function(_0x53866a,_0x74c41c){return client[_0x42ec('0x8')](_0x4fb9b3,_0x2ab2a2)[_0x42ec('0x9')](function(_0x3074a8){logger[_0x42ec('0xa')](_0x42ec('0xb'),_0x4f6fcd,_0x42ec('0xc'));logger[_0x42ec('0xd')](_0x42ec('0xe'),_0x4f6fcd,_0x42ec('0xc'),JSON[_0x42ec('0xf')](_0x3074a8));if(_0x3074a8[_0x42ec('0x10')]){if(_0x3074a8[_0x42ec('0x10')][_0x42ec('0x11')]===0x1f4){logger[_0x42ec('0x10')]('Cdr,\x20%s,\x20%s',_0x4f6fcd,_0x3074a8['error'][_0x42ec('0x12')]);return _0x74c41c(_0x3074a8[_0x42ec('0x10')][_0x42ec('0x12')]);}logger['error'](_0x42ec('0xb'),_0x4f6fcd,_0x3074a8[_0x42ec('0x10')][_0x42ec('0x12')]);return _0x53866a(_0x3074a8[_0x42ec('0x10')]['message']);}else{logger[_0x42ec('0xa')](_0x42ec('0xb'),_0x4f6fcd,_0x42ec('0xc'));_0x53866a(_0x3074a8['result']['message']);}})[_0x42ec('0x13')](function(_0x47d660){logger[_0x42ec('0x10')](_0x42ec('0xb'),_0x4f6fcd,_0x47d660);_0x74c41c(_0x47d660);});});}