6469f2cafe295c4d725a2cfb88f11a9ed9182114
[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 _0x05e2=['error','message','info','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','request','then','Cdr,\x20%s,\x20%s','debug','Cdr,\x20%s,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0x868b7c,_0xfa438b){var _0x21683c=function(_0x21bc66){while(--_0x21bc66){_0x868b7c['push'](_0x868b7c['shift']());}};_0x21683c(++_0xfa438b);}(_0x05e2,0x1bd));var _0x205e=function(_0x408de5,_0x24fa7b){_0x408de5=_0x408de5-0x0;var _0x2015a1=_0x05e2[_0x408de5];return _0x2015a1;};'use strict';var _=require(_0x205e('0x0'));var util=require(_0x205e('0x1'));var moment=require(_0x205e('0x2'));var BPromise=require(_0x205e('0x3'));var rs=require(_0x205e('0x4'));var fs=require('fs');var Redis=require(_0x205e('0x5'));var db=require(_0x205e('0x6'))['db'];var utils=require(_0x205e('0x7'));var logger=require('../../config/logger')(_0x205e('0x8'));var config=require(_0x205e('0x9'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x55280c,_0x34ae8c,_0x19a763){return new BPromise(function(_0x331466,_0x4a322e){return client[_0x205e('0xa')](_0x55280c,_0x19a763)[_0x205e('0xb')](function(_0x5830ac){logger['info'](_0x205e('0xc'),_0x34ae8c,'request\x20sent');logger[_0x205e('0xd')](_0x205e('0xe'),_0x34ae8c,_0x205e('0xf'),JSON[_0x205e('0x10')](_0x5830ac));if(_0x5830ac[_0x205e('0x11')]){if(_0x5830ac[_0x205e('0x11')]['code']===0x1f4){logger[_0x205e('0x11')]('Cdr,\x20%s,\x20%s',_0x34ae8c,_0x5830ac[_0x205e('0x11')][_0x205e('0x12')]);return _0x4a322e(_0x5830ac[_0x205e('0x11')][_0x205e('0x12')]);}logger[_0x205e('0x11')](_0x205e('0xc'),_0x34ae8c,_0x5830ac[_0x205e('0x11')][_0x205e('0x12')]);return _0x331466(_0x5830ac[_0x205e('0x11')][_0x205e('0x12')]);}else{logger[_0x205e('0x13')](_0x205e('0xc'),_0x34ae8c,'request\x20sent');_0x331466(_0x5830ac['result'][_0x205e('0x12')]);}})[_0x205e('0x14')](function(_0x54dae7){logger[_0x205e('0x11')]('Cdr,\x20%s,\x20%s',_0x34ae8c,_0x54dae7);_0x4a322e(_0x54dae7);});});}