367f72350e441990fbb59ad47035b9a3fe84a59c
[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 _0x33f2=['message','info','result','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','http','request','then','Cdr,\x20%s,\x20%s','request\x20sent','debug','Cdr,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x3e5086,_0x48f4a2){var _0xfeb102=function(_0x5a945f){while(--_0x5a945f){_0x3e5086['push'](_0x3e5086['shift']());}};_0xfeb102(++_0x48f4a2);}(_0x33f2,0x76));var _0x233f=function(_0x3f2fea,_0x3c4ea8){_0x3f2fea=_0x3f2fea-0x0;var _0x69a4d5=_0x33f2[_0x3f2fea];return _0x69a4d5;};'use strict';var _=require(_0x233f('0x0'));var util=require(_0x233f('0x1'));var moment=require(_0x233f('0x2'));var BPromise=require(_0x233f('0x3'));var rs=require(_0x233f('0x4'));var fs=require('fs');var Redis=require(_0x233f('0x5'));var db=require(_0x233f('0x6'))['db'];var utils=require(_0x233f('0x7'));var logger=require(_0x233f('0x8'))('rpc');var config=require(_0x233f('0x9'));var jayson=require('jayson/promise');var client=jayson['client'][_0x233f('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x309b40,_0x38eca3,_0x13ba8a){return new BPromise(function(_0x398a7d,_0x9d9c36){return client[_0x233f('0xb')](_0x309b40,_0x13ba8a)[_0x233f('0xc')](function(_0x4d2534){logger['info'](_0x233f('0xd'),_0x38eca3,_0x233f('0xe'));logger[_0x233f('0xf')](_0x233f('0x10'),_0x38eca3,'request\x20sent',JSON[_0x233f('0x11')](_0x4d2534));if(_0x4d2534[_0x233f('0x12')]){if(_0x4d2534[_0x233f('0x12')][_0x233f('0x13')]===0x1f4){logger[_0x233f('0x12')](_0x233f('0xd'),_0x38eca3,_0x4d2534[_0x233f('0x12')][_0x233f('0x14')]);return _0x9d9c36(_0x4d2534[_0x233f('0x12')][_0x233f('0x14')]);}logger[_0x233f('0x12')](_0x233f('0xd'),_0x38eca3,_0x4d2534[_0x233f('0x12')][_0x233f('0x14')]);return _0x398a7d(_0x4d2534[_0x233f('0x12')][_0x233f('0x14')]);}else{logger[_0x233f('0x15')](_0x233f('0xd'),_0x38eca3,'request\x20sent');_0x398a7d(_0x4d2534[_0x233f('0x16')]['message']);}})['catch'](function(_0x3be1fb){logger[_0x233f('0x12')](_0x233f('0xd'),_0x38eca3,_0x3be1fb);_0x9d9c36(_0x3be1fb);});});}