7d6efde3269a2d1e83fca28ee04f96342c331cd8
[motion2.git] / server / api / voiceAgentReport / voiceAgentReport.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 _0x29b0=['update','body','where','limit','UpdateVoiceAgentReport','lodash','moment','bluebird','randomstring','ioredis','rpc','../../config/environment','jayson/promise','client','http','request','then','VoiceAgentReport,\x20%s,\x20%s','debug','VoiceAgentReport,\x20%s,\x20%s,\x20%s','stringify','error','message','info','request\x20sent','CreateVoiceAgentReport','create','options','raw','catch','VoiceAgentReport'];(function(_0x4ef304,_0xc9ec3e){var _0x11422e=function(_0x1b34d3){while(--_0x1b34d3){_0x4ef304['push'](_0x4ef304['shift']());}};_0x11422e(++_0xc9ec3e);}(_0x29b0,0x11c));var _0x029b=function(_0xa15f3d,_0x14d74c){_0xa15f3d=_0xa15f3d-0x0;var _0x3f94dd=_0x29b0[_0xa15f3d];return _0x3f94dd;};'use strict';var _=require(_0x029b('0x0'));var util=require('util');var moment=require(_0x029b('0x1'));var BPromise=require(_0x029b('0x2'));var rs=require(_0x029b('0x3'));var fs=require('fs');var Redis=require(_0x029b('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x029b('0x5'));var config=require(_0x029b('0x6'));var jayson=require(_0x029b('0x7'));var client=jayson[_0x029b('0x8')][_0x029b('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x504305,_0x2144f2,_0x351168){return new BPromise(function(_0x3141cf,_0x47cffd){return client[_0x029b('0xa')](_0x504305,_0x351168)[_0x029b('0xb')](function(_0xa16244){logger['info'](_0x029b('0xc'),_0x2144f2,'request\x20sent');logger[_0x029b('0xd')](_0x029b('0xe'),_0x2144f2,'request\x20sent',JSON[_0x029b('0xf')](_0xa16244));if(_0xa16244[_0x029b('0x10')]){if(_0xa16244['error']['code']===0x1f4){logger[_0x029b('0x10')](_0x029b('0xc'),_0x2144f2,_0xa16244[_0x029b('0x10')][_0x029b('0x11')]);return _0x47cffd(_0xa16244[_0x029b('0x10')][_0x029b('0x11')]);}logger[_0x029b('0x10')](_0x029b('0xc'),_0x2144f2,_0xa16244['error'][_0x029b('0x11')]);return _0x3141cf(_0xa16244['error'][_0x029b('0x11')]);}else{logger[_0x029b('0x12')](_0x029b('0xc'),_0x2144f2,_0x029b('0x13'));_0x3141cf(_0xa16244['result'][_0x029b('0x11')]);}})['catch'](function(_0x9c1896){logger[_0x029b('0x10')](_0x029b('0xc'),_0x2144f2,_0x9c1896);_0x47cffd(_0x9c1896);});});}exports[_0x029b('0x14')]=function(_0x83561e){var _0x542ddf=this;return new Promise(function(_0xb4a881,_0x3c7b21){return db['VoiceAgentReport'][_0x029b('0x15')](_0x83561e['body'],{'raw':_0x83561e[_0x029b('0x16')]?_0x83561e[_0x029b('0x16')][_0x029b('0x17')]===undefined?!![]:![]:!![]})[_0x029b('0xb')](function(_0x59ff91){logger['info']('CreateVoiceAgentReport',_0x83561e);logger[_0x029b('0xd')](_0x029b('0x14'),_0x83561e,JSON[_0x029b('0xf')](_0x59ff91));_0xb4a881(_0x59ff91);})[_0x029b('0x18')](function(_0x417ce9){logger[_0x029b('0x10')](_0x029b('0x14'),_0x417ce9[_0x029b('0x11')],_0x83561e);_0x3c7b21(_0x542ddf[_0x029b('0x10')](0x1f4,_0x417ce9[_0x029b('0x11')]));});});};exports['UpdateVoiceAgentReport']=function(_0x4292df){var _0x48d404=this;return new Promise(function(_0x2656f4,_0x4bb4dd){return db[_0x029b('0x19')][_0x029b('0x1a')](_0x4292df[_0x029b('0x1b')],{'raw':_0x4292df[_0x029b('0x16')]?_0x4292df[_0x029b('0x16')][_0x029b('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4292df[_0x029b('0x16')]?_0x4292df[_0x029b('0x16')][_0x029b('0x1c')]||null:null,'attributes':_0x4292df[_0x029b('0x16')]?_0x4292df[_0x029b('0x16')]['attributes']||null:null,'limit':_0x4292df['options']?_0x4292df[_0x029b('0x16')][_0x029b('0x1d')]||null:null})[_0x029b('0xb')](function(_0x3df018){logger[_0x029b('0x12')](_0x029b('0x1e'),_0x4292df);logger[_0x029b('0xd')](_0x029b('0x1e'),_0x4292df,JSON[_0x029b('0xf')](_0x3df018));_0x2656f4(_0x3df018);})['catch'](function(_0x41bd84){logger[_0x029b('0x10')](_0x029b('0x1e'),_0x41bd84[_0x029b('0x11')],_0x4292df);_0x4bb4dd(_0x48d404[_0x029b('0x10')](0x1f4,_0x41bd84[_0x029b('0x11')]));});});};