0bccb5712c280b8f44cbc997e669f783eb4bfaa6
[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 _0x5ef5=['util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','request','then','request\x20sent','debug','stringify','error','message','info','Cdr,\x20%s,\x20%s','result','catch'];(function(_0x32a1c4,_0x76aec8){var _0xa98786=function(_0x2aa09e){while(--_0x2aa09e){_0x32a1c4['push'](_0x32a1c4['shift']());}};_0xa98786(++_0x76aec8);}(_0x5ef5,0x118));var _0x55ef=function(_0x4c97b5,_0x3d3f37){_0x4c97b5=_0x4c97b5-0x0;var _0x1ab2f4=_0x5ef5[_0x4c97b5];return _0x1ab2f4;};'use strict';var _=require('lodash');var util=require(_0x55ef('0x0'));var moment=require('moment');var BPromise=require(_0x55ef('0x1'));var rs=require(_0x55ef('0x2'));var fs=require('fs');var Redis=require(_0x55ef('0x3'));var db=require(_0x55ef('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x55ef('0x5'))(_0x55ef('0x6'));var config=require(_0x55ef('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x55ef('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x470f97,_0x4439a7,_0x1be56d){return new BPromise(function(_0x194b7a,_0xf5106f){return client[_0x55ef('0x9')](_0x470f97,_0x1be56d)[_0x55ef('0xa')](function(_0xb94bc2){logger['info']('Cdr,\x20%s,\x20%s',_0x4439a7,_0x55ef('0xb'));logger[_0x55ef('0xc')]('Cdr,\x20%s,\x20%s,\x20%s',_0x4439a7,_0x55ef('0xb'),JSON[_0x55ef('0xd')](_0xb94bc2));if(_0xb94bc2[_0x55ef('0xe')]){if(_0xb94bc2[_0x55ef('0xe')]['code']===0x1f4){logger[_0x55ef('0xe')]('Cdr,\x20%s,\x20%s',_0x4439a7,_0xb94bc2[_0x55ef('0xe')][_0x55ef('0xf')]);return _0xf5106f(_0xb94bc2[_0x55ef('0xe')][_0x55ef('0xf')]);}logger[_0x55ef('0xe')]('Cdr,\x20%s,\x20%s',_0x4439a7,_0xb94bc2[_0x55ef('0xe')][_0x55ef('0xf')]);return _0x194b7a(_0xb94bc2['error'][_0x55ef('0xf')]);}else{logger[_0x55ef('0x10')](_0x55ef('0x11'),_0x4439a7,_0x55ef('0xb'));_0x194b7a(_0xb94bc2[_0x55ef('0x12')][_0x55ef('0xf')]);}})[_0x55ef('0x13')](function(_0x2db011){logger['error']('Cdr,\x20%s,\x20%s',_0x4439a7,_0x2db011);_0xf5106f(_0x2db011);});});}