Built motion from commit 3c2ce842.|2.6.31
[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 _0x9474=['http','request','info','request\x20sent','debug','Cdr,\x20%s,\x20%s,\x20%s','stringify','error','code','Cdr,\x20%s,\x20%s','message','result','catch','lodash','util','moment','randomstring','../../mysqldb','../../config/logger','rpc','jayson/promise','client'];(function(_0x43a1b8,_0x1c90c8){var _0x324ecc=function(_0x53a93b){while(--_0x53a93b){_0x43a1b8['push'](_0x43a1b8['shift']());}};_0x324ecc(++_0x1c90c8);}(_0x9474,0x141));var _0x4947=function(_0x47e549,_0x2e53d6){_0x47e549=_0x47e549-0x0;var _0x251374=_0x9474[_0x47e549];return _0x251374;};'use strict';var _=require(_0x4947('0x0'));var util=require(_0x4947('0x1'));var moment=require(_0x4947('0x2'));var BPromise=require('bluebird');var rs=require(_0x4947('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x4947('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x4947('0x5'))(_0x4947('0x6'));var config=require('../../config/environment');var jayson=require(_0x4947('0x7'));var client=jayson[_0x4947('0x8')][_0x4947('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x20ab71,_0x2067ad,_0x340706){return new BPromise(function(_0x1818cb,_0x2b1f9c){return client[_0x4947('0xa')](_0x20ab71,_0x340706)['then'](function(_0x448e7e){logger[_0x4947('0xb')]('Cdr,\x20%s,\x20%s',_0x2067ad,_0x4947('0xc'));logger[_0x4947('0xd')](_0x4947('0xe'),_0x2067ad,_0x4947('0xc'),JSON[_0x4947('0xf')](_0x448e7e));if(_0x448e7e[_0x4947('0x10')]){if(_0x448e7e[_0x4947('0x10')][_0x4947('0x11')]===0x1f4){logger['error'](_0x4947('0x12'),_0x2067ad,_0x448e7e[_0x4947('0x10')][_0x4947('0x13')]);return _0x2b1f9c(_0x448e7e[_0x4947('0x10')][_0x4947('0x13')]);}logger[_0x4947('0x10')](_0x4947('0x12'),_0x2067ad,_0x448e7e['error'][_0x4947('0x13')]);return _0x1818cb(_0x448e7e['error'][_0x4947('0x13')]);}else{logger[_0x4947('0xb')](_0x4947('0x12'),_0x2067ad,'request\x20sent');_0x1818cb(_0x448e7e[_0x4947('0x14')]['message']);}})[_0x4947('0x15')](function(_0x2277a8){logger[_0x4947('0x10')](_0x4947('0x12'),_0x2067ad,_0x2277a8);_0x2b1f9c(_0x2277a8);});});}