393234b45d99c22977e39253d7776399d32a0199
[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 _0xb8b5=['message','info','result','catch','CreateVoiceAgentReport','create','raw','VoiceAgentReport','body','options','where','attributes','UpdateVoiceAgentReport','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','then','VoiceAgentReport,\x20%s,\x20%s','request\x20sent','debug','VoiceAgentReport,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x3b9dcf,_0xe3c1a6){var _0x3000b8=function(_0x112917){while(--_0x112917){_0x3b9dcf['push'](_0x3b9dcf['shift']());}};_0x3000b8(++_0xe3c1a6);}(_0xb8b5,0xfd));var _0x5b8b=function(_0x3b7a14,_0x1cb9f3){_0x3b7a14=_0x3b7a14-0x0;var _0x549acc=_0xb8b5[_0x3b7a14];return _0x549acc;};'use strict';var _=require(_0x5b8b('0x0'));var util=require(_0x5b8b('0x1'));var moment=require('moment');var BPromise=require(_0x5b8b('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5b8b('0x3'));var db=require(_0x5b8b('0x4'))['db'];var utils=require(_0x5b8b('0x5'));var logger=require(_0x5b8b('0x6'))(_0x5b8b('0x7'));var config=require('../../config/environment');var jayson=require(_0x5b8b('0x8'));var client=jayson['client'][_0x5b8b('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4f9b5e,_0x3d99bd,_0x1acc64){return new BPromise(function(_0x50d28f,_0x5cdc57){return client['request'](_0x4f9b5e,_0x1acc64)[_0x5b8b('0xa')](function(_0x1d5760){logger['info'](_0x5b8b('0xb'),_0x3d99bd,_0x5b8b('0xc'));logger[_0x5b8b('0xd')](_0x5b8b('0xe'),_0x3d99bd,_0x5b8b('0xc'),JSON[_0x5b8b('0xf')](_0x1d5760));if(_0x1d5760[_0x5b8b('0x10')]){if(_0x1d5760[_0x5b8b('0x10')]['code']===0x1f4){logger[_0x5b8b('0x10')](_0x5b8b('0xb'),_0x3d99bd,_0x1d5760[_0x5b8b('0x10')][_0x5b8b('0x11')]);return _0x5cdc57(_0x1d5760[_0x5b8b('0x10')][_0x5b8b('0x11')]);}logger[_0x5b8b('0x10')](_0x5b8b('0xb'),_0x3d99bd,_0x1d5760[_0x5b8b('0x10')]['message']);return _0x50d28f(_0x1d5760['error']['message']);}else{logger[_0x5b8b('0x12')](_0x5b8b('0xb'),_0x3d99bd,'request\x20sent');_0x50d28f(_0x1d5760[_0x5b8b('0x13')][_0x5b8b('0x11')]);}})[_0x5b8b('0x14')](function(_0x445e42){logger[_0x5b8b('0x10')](_0x5b8b('0xb'),_0x3d99bd,_0x445e42);_0x5cdc57(_0x445e42);});});}exports[_0x5b8b('0x15')]=function(_0x32232b){var _0x342d40=this;return new Promise(function(_0xde7452,_0x538d06){return db['VoiceAgentReport'][_0x5b8b('0x16')](_0x32232b['body'],{'raw':_0x32232b['options']?_0x32232b['options'][_0x5b8b('0x17')]===undefined?!![]:![]:!![]})[_0x5b8b('0xa')](function(_0x3c2b2f){logger[_0x5b8b('0x12')](_0x5b8b('0x15'),_0x32232b);logger[_0x5b8b('0xd')](_0x5b8b('0x15'),_0x32232b,JSON[_0x5b8b('0xf')](_0x3c2b2f));_0xde7452(_0x3c2b2f);})['catch'](function(_0xbe1abb){logger[_0x5b8b('0x10')](_0x5b8b('0x15'),_0xbe1abb[_0x5b8b('0x11')],_0x32232b);_0x538d06(_0x342d40['error'](0x1f4,_0xbe1abb[_0x5b8b('0x11')]));});});};exports['UpdateVoiceAgentReport']=function(_0x20aaf6){var _0x166580=this;return new Promise(function(_0x4acbb8,_0x507462){return db[_0x5b8b('0x18')]['update'](_0x20aaf6[_0x5b8b('0x19')],{'raw':_0x20aaf6[_0x5b8b('0x1a')]?_0x20aaf6[_0x5b8b('0x1a')][_0x5b8b('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x20aaf6[_0x5b8b('0x1a')]?_0x20aaf6['options'][_0x5b8b('0x1b')]||null:null,'attributes':_0x20aaf6[_0x5b8b('0x1a')]?_0x20aaf6[_0x5b8b('0x1a')][_0x5b8b('0x1c')]||null:null,'limit':_0x20aaf6[_0x5b8b('0x1a')]?_0x20aaf6[_0x5b8b('0x1a')]['limit']||null:null})[_0x5b8b('0xa')](function(_0x10429e){logger[_0x5b8b('0x12')](_0x5b8b('0x1d'),_0x20aaf6);logger[_0x5b8b('0xd')](_0x5b8b('0x1d'),_0x20aaf6,JSON[_0x5b8b('0xf')](_0x10429e));_0x4acbb8(_0x10429e);})[_0x5b8b('0x14')](function(_0x4c09ca){logger[_0x5b8b('0x10')](_0x5b8b('0x1d'),_0x4c09ca[_0x5b8b('0x11')],_0x20aaf6);_0x507462(_0x166580['error'](0x1f4,_0x4c09ca[_0x5b8b('0x11')]));});});};