47b0e4c4655b2b419eb8b55b7310ea902b712420
[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 _0xfa19=['info','result','findAll','options','where','attributes','limit','include','map','model','GetVoiceCallReport','catch','CreateVoiceCallReport','VoiceCallReport','create','body','raw','UpdateVoiceCallReport','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','client','http','then','VoiceCallReport,\x20%s,\x20%s','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message'];(function(_0x5620bd,_0x5c2360){var _0x40890e=function(_0x351c3f){while(--_0x351c3f){_0x5620bd['push'](_0x5620bd['shift']());}};_0x40890e(++_0x5c2360);}(_0xfa19,0x12a));var _0x9fa1=function(_0x1f3b90,_0x50a2e0){_0x1f3b90=_0x1f3b90-0x0;var _0x2a07e6=_0xfa19[_0x1f3b90];return _0x2a07e6;};'use strict';var _=require('lodash');var util=require(_0x9fa1('0x0'));var moment=require('moment');var BPromise=require(_0x9fa1('0x1'));var rs=require(_0x9fa1('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x9fa1('0x3'))['db'];var utils=require(_0x9fa1('0x4'));var logger=require(_0x9fa1('0x5'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x9fa1('0x6')][_0x9fa1('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x3179ef,_0x10ada1,_0x22b4ff){return new BPromise(function(_0x114c16,_0x43555e){return client['request'](_0x3179ef,_0x22b4ff)[_0x9fa1('0x8')](function(_0x1054bc){logger['info'](_0x9fa1('0x9'),_0x10ada1,'request\x20sent');logger[_0x9fa1('0xa')](_0x9fa1('0xb'),_0x10ada1,_0x9fa1('0xc'),JSON[_0x9fa1('0xd')](_0x1054bc));if(_0x1054bc[_0x9fa1('0xe')]){if(_0x1054bc[_0x9fa1('0xe')][_0x9fa1('0xf')]===0x1f4){logger['error'](_0x9fa1('0x9'),_0x10ada1,_0x1054bc[_0x9fa1('0xe')][_0x9fa1('0x10')]);return _0x43555e(_0x1054bc['error']['message']);}logger[_0x9fa1('0xe')](_0x9fa1('0x9'),_0x10ada1,_0x1054bc[_0x9fa1('0xe')][_0x9fa1('0x10')]);return _0x114c16(_0x1054bc[_0x9fa1('0xe')][_0x9fa1('0x10')]);}else{logger[_0x9fa1('0x11')](_0x9fa1('0x9'),_0x10ada1,'request\x20sent');_0x114c16(_0x1054bc[_0x9fa1('0x12')]['message']);}})['catch'](function(_0x3e4a00){logger[_0x9fa1('0xe')](_0x9fa1('0x9'),_0x10ada1,_0x3e4a00);_0x43555e(_0x3e4a00);});});}exports['GetVoiceCallReport']=function(_0xe1ef65){var _0x2155ac=this;return new Promise(function(_0x37c13f,_0x4519a8){return db['VoiceCallReport'][_0x9fa1('0x13')]({'raw':_0xe1ef65[_0x9fa1('0x14')]?_0xe1ef65[_0x9fa1('0x14')]['raw']===undefined?!![]:![]:!![],'where':_0xe1ef65['options']?_0xe1ef65[_0x9fa1('0x14')][_0x9fa1('0x15')]||null:null,'attributes':_0xe1ef65['options']?_0xe1ef65[_0x9fa1('0x14')][_0x9fa1('0x16')]||null:null,'limit':_0xe1ef65[_0x9fa1('0x14')]?_0xe1ef65['options'][_0x9fa1('0x17')]||null:null,'include':_0xe1ef65['options']?_0xe1ef65['options'][_0x9fa1('0x18')]?_[_0x9fa1('0x19')](_0xe1ef65[_0x9fa1('0x14')][_0x9fa1('0x18')],function(_0x38d502){return{'model':db[_0x38d502[_0x9fa1('0x1a')]],'as':_0x38d502['as'],'attributes':_0x38d502[_0x9fa1('0x16')],'include':_0x38d502[_0x9fa1('0x18')]?_[_0x9fa1('0x19')](_0x38d502[_0x9fa1('0x18')],function(_0x3e631f){return{'model':db[_0x3e631f[_0x9fa1('0x1a')]],'as':_0x3e631f['as'],'attributes':_0x3e631f[_0x9fa1('0x16')],'include':_0x3e631f['include']?_['map'](_0x3e631f[_0x9fa1('0x18')],function(_0x2d2fb3){return{'model':db[_0x2d2fb3['model']],'as':_0x2d2fb3['as'],'attributes':_0x2d2fb3[_0x9fa1('0x16')]};}):[]};}):[]};}):[]:[]})[_0x9fa1('0x8')](function(_0x25fa2f){logger['info'](_0x9fa1('0x1b'),_0xe1ef65);logger[_0x9fa1('0xa')](_0x9fa1('0x1b'),_0xe1ef65,JSON[_0x9fa1('0xd')](_0x25fa2f));_0x37c13f(_0x25fa2f);})[_0x9fa1('0x1c')](function(_0x516660){logger[_0x9fa1('0xe')](_0x9fa1('0x1b'),_0x516660['message'],_0xe1ef65);_0x4519a8(_0x2155ac[_0x9fa1('0xe')](0x1f4,_0x516660[_0x9fa1('0x10')]));});});};exports[_0x9fa1('0x1d')]=function(_0x553f29){var _0x57767b=this;return new Promise(function(_0x1e8cb6,_0x2413b5){return db[_0x9fa1('0x1e')][_0x9fa1('0x1f')](_0x553f29[_0x9fa1('0x20')],{'raw':_0x553f29['options']?_0x553f29[_0x9fa1('0x14')][_0x9fa1('0x21')]===undefined?!![]:![]:!![]})[_0x9fa1('0x8')](function(_0x5dde21){logger[_0x9fa1('0x11')]('CreateVoiceCallReport',_0x553f29);logger[_0x9fa1('0xa')](_0x9fa1('0x1d'),_0x553f29,JSON[_0x9fa1('0xd')](_0x5dde21));_0x1e8cb6(_0x5dde21);})[_0x9fa1('0x1c')](function(_0x33abca){logger['error'](_0x9fa1('0x1d'),_0x33abca['message'],_0x553f29);_0x2413b5(_0x57767b[_0x9fa1('0xe')](0x1f4,_0x33abca[_0x9fa1('0x10')]));});});};exports[_0x9fa1('0x22')]=function(_0xb3af84){var _0x47a4a3=this;return new Promise(function(_0x3d8eb6,_0x2db909){return db[_0x9fa1('0x1e')]['update'](_0xb3af84[_0x9fa1('0x20')],{'raw':_0xb3af84[_0x9fa1('0x14')]?_0xb3af84['options'][_0x9fa1('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xb3af84[_0x9fa1('0x14')]?_0xb3af84[_0x9fa1('0x14')][_0x9fa1('0x15')]||null:null,'attributes':_0xb3af84[_0x9fa1('0x14')]?_0xb3af84['options']['attributes']||null:null,'limit':_0xb3af84[_0x9fa1('0x14')]?_0xb3af84['options'][_0x9fa1('0x17')]||null:null})[_0x9fa1('0x8')](function(_0x5c481c){logger['info'](_0x9fa1('0x22'),_0xb3af84);logger[_0x9fa1('0xa')](_0x9fa1('0x22'),_0xb3af84,JSON[_0x9fa1('0xd')](_0x5c481c));_0x3d8eb6(_0x5c481c);})[_0x9fa1('0x1c')](function(_0xc3fefd){logger[_0x9fa1('0xe')](_0x9fa1('0x22'),_0xc3fefd['message'],_0xb3af84);_0x2db909(_0x47a4a3[_0x9fa1('0xe')](0x1f4,_0xc3fefd[_0x9fa1('0x10')]));});});};