Built motion from commit 74d9782e.|2.6.30
[motion2.git] / server / api / voiceCallReport / voiceCallReport.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 _0x7130=['catch','CreateVoiceCallReport','UpdateVoiceCallReport','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','VoiceCallReport,\x20%s,\x20%s','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','VoiceCallReport','findAll','options','raw','where','attributes','limit','include','model','map','GetVoiceCallReport'];(function(_0x534fe9,_0x19dd75){var _0x48592c=function(_0x26a7c3){while(--_0x26a7c3){_0x534fe9['push'](_0x534fe9['shift']());}};_0x48592c(++_0x19dd75);}(_0x7130,0x72));var _0x0713=function(_0x46698a,_0x8de1e4){_0x46698a=_0x46698a-0x0;var _0x356db0=_0x7130[_0x46698a];return _0x356db0;};'use strict';var _=require(_0x0713('0x0'));var util=require(_0x0713('0x1'));var moment=require(_0x0713('0x2'));var BPromise=require('bluebird');var rs=require(_0x0713('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0713('0x4'))['db'];var utils=require(_0x0713('0x5'));var logger=require(_0x0713('0x6'))(_0x0713('0x7'));var config=require(_0x0713('0x8'));var jayson=require(_0x0713('0x9'));var client=jayson[_0x0713('0xa')][_0x0713('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1c6335,_0x358236,_0x259e6d){return new BPromise(function(_0x2d1897,_0x59cefa){return client['request'](_0x1c6335,_0x259e6d)[_0x0713('0xc')](function(_0x3f0082){logger[_0x0713('0xd')](_0x0713('0xe'),_0x358236,_0x0713('0xf'));logger[_0x0713('0x10')](_0x0713('0x11'),_0x358236,_0x0713('0xf'),JSON[_0x0713('0x12')](_0x3f0082));if(_0x3f0082['error']){if(_0x3f0082[_0x0713('0x13')][_0x0713('0x14')]===0x1f4){logger['error'](_0x0713('0xe'),_0x358236,_0x3f0082[_0x0713('0x13')][_0x0713('0x15')]);return _0x59cefa(_0x3f0082[_0x0713('0x13')][_0x0713('0x15')]);}logger['error'](_0x0713('0xe'),_0x358236,_0x3f0082[_0x0713('0x13')][_0x0713('0x15')]);return _0x2d1897(_0x3f0082[_0x0713('0x13')]['message']);}else{logger['info'](_0x0713('0xe'),_0x358236,_0x0713('0xf'));_0x2d1897(_0x3f0082[_0x0713('0x16')]['message']);}})['catch'](function(_0xbcfc20){logger[_0x0713('0x13')](_0x0713('0xe'),_0x358236,_0xbcfc20);_0x59cefa(_0xbcfc20);});});}exports['GetVoiceCallReport']=function(_0x520d70){var _0x3873ee=this;return new Promise(function(_0x5078b3,_0x265509){return db[_0x0713('0x17')][_0x0713('0x18')]({'raw':_0x520d70['options']?_0x520d70[_0x0713('0x19')][_0x0713('0x1a')]===undefined?!![]:![]:!![],'where':_0x520d70[_0x0713('0x19')]?_0x520d70[_0x0713('0x19')][_0x0713('0x1b')]||null:null,'attributes':_0x520d70['options']?_0x520d70[_0x0713('0x19')][_0x0713('0x1c')]||null:null,'limit':_0x520d70[_0x0713('0x19')]?_0x520d70[_0x0713('0x19')][_0x0713('0x1d')]||null:null,'include':_0x520d70[_0x0713('0x19')]?_0x520d70[_0x0713('0x19')][_0x0713('0x1e')]?_['map'](_0x520d70['options'][_0x0713('0x1e')],function(_0x45348a){return{'model':db[_0x45348a[_0x0713('0x1f')]],'as':_0x45348a['as'],'attributes':_0x45348a[_0x0713('0x1c')],'include':_0x45348a[_0x0713('0x1e')]?_[_0x0713('0x20')](_0x45348a[_0x0713('0x1e')],function(_0x5527e7){return{'model':db[_0x5527e7['model']],'as':_0x5527e7['as'],'attributes':_0x5527e7['attributes'],'include':_0x5527e7[_0x0713('0x1e')]?_[_0x0713('0x20')](_0x5527e7[_0x0713('0x1e')],function(_0x3f4f74){return{'model':db[_0x3f4f74[_0x0713('0x1f')]],'as':_0x3f4f74['as'],'attributes':_0x3f4f74[_0x0713('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x0713('0xc')](function(_0x2bdd13){logger['info'](_0x0713('0x21'),_0x520d70);logger['debug']('GetVoiceCallReport',_0x520d70,JSON[_0x0713('0x12')](_0x2bdd13));_0x5078b3(_0x2bdd13);})[_0x0713('0x22')](function(_0x1df5f6){logger[_0x0713('0x13')]('GetVoiceCallReport',_0x1df5f6[_0x0713('0x15')],_0x520d70);_0x265509(_0x3873ee[_0x0713('0x13')](0x1f4,_0x1df5f6['message']));});});};exports['CreateVoiceCallReport']=function(_0x4d4030){var _0x1af4ac=this;return new Promise(function(_0x3905a0,_0x4666ca){return db['VoiceCallReport']['create'](_0x4d4030['body'],{'raw':_0x4d4030[_0x0713('0x19')]?_0x4d4030[_0x0713('0x19')]['raw']===undefined?!![]:![]:!![]})[_0x0713('0xc')](function(_0x933a93){logger[_0x0713('0xd')](_0x0713('0x23'),_0x4d4030);logger[_0x0713('0x10')](_0x0713('0x23'),_0x4d4030,JSON[_0x0713('0x12')](_0x933a93));_0x3905a0(_0x933a93);})['catch'](function(_0x441b20){logger['error'](_0x0713('0x23'),_0x441b20[_0x0713('0x15')],_0x4d4030);_0x4666ca(_0x1af4ac[_0x0713('0x13')](0x1f4,_0x441b20[_0x0713('0x15')]));});});};exports['UpdateVoiceCallReport']=function(_0x3edd3e){var _0x3d257f=this;return new Promise(function(_0x4dbc73,_0x13e654){return db[_0x0713('0x17')]['update'](_0x3edd3e['body'],{'raw':_0x3edd3e['options']?_0x3edd3e['options'][_0x0713('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3edd3e['options']?_0x3edd3e['options'][_0x0713('0x1b')]||null:null,'attributes':_0x3edd3e[_0x0713('0x19')]?_0x3edd3e[_0x0713('0x19')][_0x0713('0x1c')]||null:null,'limit':_0x3edd3e['options']?_0x3edd3e[_0x0713('0x19')][_0x0713('0x1d')]||null:null})['then'](function(_0xa9a6d9){logger[_0x0713('0xd')](_0x0713('0x24'),_0x3edd3e);logger[_0x0713('0x10')](_0x0713('0x24'),_0x3edd3e,JSON[_0x0713('0x12')](_0xa9a6d9));_0x4dbc73(_0xa9a6d9);})[_0x0713('0x22')](function(_0x1375bc){logger['error'](_0x0713('0x24'),_0x1375bc[_0x0713('0x15')],_0x3edd3e);_0x13e654(_0x3d257f[_0x0713('0x13')](0x1f4,_0x1375bc[_0x0713('0x15')]));});});};