9e69358858a8952b487fc2a23a0826fd0df82869
[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 _0x9ad8=['then','info','Cdr,\x20%s,\x20%s','request\x20sent','debug','Cdr,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request'];(function(_0x1d8c10,_0x46bc73){var _0x461513=function(_0x6cf5d9){while(--_0x6cf5d9){_0x1d8c10['push'](_0x1d8c10['shift']());}};_0x461513(++_0x46bc73);}(_0x9ad8,0x164));var _0x89ad=function(_0x205a12,_0x5d1d07){_0x205a12=_0x205a12-0x0;var _0x2ae9cc=_0x9ad8[_0x205a12];return _0x2ae9cc;};'use strict';var _=require('lodash');var util=require(_0x89ad('0x0'));var moment=require(_0x89ad('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x89ad('0x2'));var db=require(_0x89ad('0x3'))['db'];var utils=require(_0x89ad('0x4'));var logger=require(_0x89ad('0x5'))(_0x89ad('0x6'));var config=require(_0x89ad('0x7'));var jayson=require(_0x89ad('0x8'));var client=jayson[_0x89ad('0x9')][_0x89ad('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xdf6a61,_0x2397bd,_0x14253b){return new BPromise(function(_0x1024fc,_0x4ee9a4){return client[_0x89ad('0xb')](_0xdf6a61,_0x14253b)[_0x89ad('0xc')](function(_0x5ea1b6){logger[_0x89ad('0xd')](_0x89ad('0xe'),_0x2397bd,_0x89ad('0xf'));logger[_0x89ad('0x10')](_0x89ad('0x11'),_0x2397bd,_0x89ad('0xf'),JSON[_0x89ad('0x12')](_0x5ea1b6));if(_0x5ea1b6['error']){if(_0x5ea1b6['error']['code']===0x1f4){logger['error'](_0x89ad('0xe'),_0x2397bd,_0x5ea1b6[_0x89ad('0x13')]['message']);return _0x4ee9a4(_0x5ea1b6[_0x89ad('0x13')][_0x89ad('0x14')]);}logger[_0x89ad('0x13')](_0x89ad('0xe'),_0x2397bd,_0x5ea1b6[_0x89ad('0x13')][_0x89ad('0x14')]);return _0x1024fc(_0x5ea1b6[_0x89ad('0x13')][_0x89ad('0x14')]);}else{logger['info'](_0x89ad('0xe'),_0x2397bd,'request\x20sent');_0x1024fc(_0x5ea1b6[_0x89ad('0x15')]['message']);}})[_0x89ad('0x16')](function(_0x1e364d){logger[_0x89ad('0x13')](_0x89ad('0xe'),_0x2397bd,_0x1e364d);_0x4ee9a4(_0x1e364d);});});}