15655d8b7eec4107e81f9340fe0c76cbc97804f2
[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 _0x0817=['limit','map','include','model','GetVoiceCallReport','debug','create','body','CreateVoiceCallReport','UpdateVoiceCallReport','update','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','request','then','info','request\x20sent','VoiceCallReport,\x20%s,\x20%s,\x20%s','stringify','error','VoiceCallReport,\x20%s,\x20%s','message','result','catch','VoiceCallReport','findAll','options','raw','where','attributes'];(function(_0xc46059,_0x3ad831){var _0x2139a2=function(_0x53b184){while(--_0x53b184){_0xc46059['push'](_0xc46059['shift']());}};_0x2139a2(++_0x3ad831);}(_0x0817,0x143));var _0x7081=function(_0x18625a,_0x22bf58){_0x18625a=_0x18625a-0x0;var _0x4e0fa3=_0x0817[_0x18625a];return _0x4e0fa3;};'use strict';var _=require(_0x7081('0x0'));var util=require(_0x7081('0x1'));var moment=require(_0x7081('0x2'));var BPromise=require('bluebird');var rs=require(_0x7081('0x3'));var fs=require('fs');var Redis=require(_0x7081('0x4'));var db=require(_0x7081('0x5'))['db'];var utils=require(_0x7081('0x6'));var logger=require('../../config/logger')(_0x7081('0x7'));var config=require(_0x7081('0x8'));var jayson=require(_0x7081('0x9'));var client=jayson['client'][_0x7081('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x41eeb8,_0x4245ca,_0x15f22c){return new BPromise(function(_0x5b17b5,_0x5e9b59){return client[_0x7081('0xb')](_0x41eeb8,_0x15f22c)[_0x7081('0xc')](function(_0x373514){logger[_0x7081('0xd')]('VoiceCallReport,\x20%s,\x20%s',_0x4245ca,_0x7081('0xe'));logger['debug'](_0x7081('0xf'),_0x4245ca,_0x7081('0xe'),JSON[_0x7081('0x10')](_0x373514));if(_0x373514[_0x7081('0x11')]){if(_0x373514[_0x7081('0x11')]['code']===0x1f4){logger[_0x7081('0x11')](_0x7081('0x12'),_0x4245ca,_0x373514[_0x7081('0x11')][_0x7081('0x13')]);return _0x5e9b59(_0x373514['error'][_0x7081('0x13')]);}logger[_0x7081('0x11')](_0x7081('0x12'),_0x4245ca,_0x373514['error']['message']);return _0x5b17b5(_0x373514[_0x7081('0x11')][_0x7081('0x13')]);}else{logger[_0x7081('0xd')]('VoiceCallReport,\x20%s,\x20%s',_0x4245ca,_0x7081('0xe'));_0x5b17b5(_0x373514[_0x7081('0x14')][_0x7081('0x13')]);}})[_0x7081('0x15')](function(_0xee432f){logger[_0x7081('0x11')]('VoiceCallReport,\x20%s,\x20%s',_0x4245ca,_0xee432f);_0x5e9b59(_0xee432f);});});}exports['GetVoiceCallReport']=function(_0x337baf){var _0x45ef8b=this;return new Promise(function(_0x5e7474,_0x4c71d7){return db[_0x7081('0x16')][_0x7081('0x17')]({'raw':_0x337baf[_0x7081('0x18')]?_0x337baf[_0x7081('0x18')][_0x7081('0x19')]===undefined?!![]:![]:!![],'where':_0x337baf[_0x7081('0x18')]?_0x337baf[_0x7081('0x18')][_0x7081('0x1a')]||null:null,'attributes':_0x337baf[_0x7081('0x18')]?_0x337baf[_0x7081('0x18')][_0x7081('0x1b')]||null:null,'limit':_0x337baf['options']?_0x337baf[_0x7081('0x18')][_0x7081('0x1c')]||null:null,'include':_0x337baf[_0x7081('0x18')]?_0x337baf[_0x7081('0x18')]['include']?_[_0x7081('0x1d')](_0x337baf[_0x7081('0x18')][_0x7081('0x1e')],function(_0x206ef2){return{'model':db[_0x206ef2[_0x7081('0x1f')]],'as':_0x206ef2['as'],'attributes':_0x206ef2['attributes'],'include':_0x206ef2['include']?_[_0x7081('0x1d')](_0x206ef2[_0x7081('0x1e')],function(_0x39bd83){return{'model':db[_0x39bd83[_0x7081('0x1f')]],'as':_0x39bd83['as'],'attributes':_0x39bd83[_0x7081('0x1b')],'include':_0x39bd83[_0x7081('0x1e')]?_['map'](_0x39bd83[_0x7081('0x1e')],function(_0x566040){return{'model':db[_0x566040[_0x7081('0x1f')]],'as':_0x566040['as'],'attributes':_0x566040[_0x7081('0x1b')]};}):[]};}):[]};}):[]:[]})[_0x7081('0xc')](function(_0x1c2e5c){logger[_0x7081('0xd')](_0x7081('0x20'),_0x337baf);logger[_0x7081('0x21')](_0x7081('0x20'),_0x337baf,JSON[_0x7081('0x10')](_0x1c2e5c));_0x5e7474(_0x1c2e5c);})[_0x7081('0x15')](function(_0x12e92c){logger[_0x7081('0x11')](_0x7081('0x20'),_0x12e92c['message'],_0x337baf);_0x4c71d7(_0x45ef8b[_0x7081('0x11')](0x1f4,_0x12e92c[_0x7081('0x13')]));});});};exports['CreateVoiceCallReport']=function(_0x52704d){var _0x25b1b9=this;return new Promise(function(_0x24f6e8,_0x52531){return db[_0x7081('0x16')][_0x7081('0x22')](_0x52704d[_0x7081('0x23')],{'raw':_0x52704d[_0x7081('0x18')]?_0x52704d[_0x7081('0x18')][_0x7081('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x156f51){logger[_0x7081('0xd')](_0x7081('0x24'),_0x52704d);logger['debug'](_0x7081('0x24'),_0x52704d,JSON['stringify'](_0x156f51));_0x24f6e8(_0x156f51);})['catch'](function(_0x49c02e){logger[_0x7081('0x11')](_0x7081('0x24'),_0x49c02e[_0x7081('0x13')],_0x52704d);_0x52531(_0x25b1b9[_0x7081('0x11')](0x1f4,_0x49c02e['message']));});});};exports[_0x7081('0x25')]=function(_0x3246c5){var _0x3315ae=this;return new Promise(function(_0x2f00d9,_0x5457cf){return db[_0x7081('0x16')][_0x7081('0x26')](_0x3246c5[_0x7081('0x23')],{'raw':_0x3246c5[_0x7081('0x18')]?_0x3246c5[_0x7081('0x18')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3246c5['options']?_0x3246c5[_0x7081('0x18')]['where']||null:null,'attributes':_0x3246c5['options']?_0x3246c5[_0x7081('0x18')][_0x7081('0x1b')]||null:null,'limit':_0x3246c5[_0x7081('0x18')]?_0x3246c5[_0x7081('0x18')][_0x7081('0x1c')]||null:null})['then'](function(_0x2607d9){logger[_0x7081('0xd')](_0x7081('0x25'),_0x3246c5);logger[_0x7081('0x21')]('UpdateVoiceCallReport',_0x3246c5,JSON[_0x7081('0x10')](_0x2607d9));_0x2f00d9(_0x2607d9);})[_0x7081('0x15')](function(_0x3e5cf0){logger[_0x7081('0x11')]('UpdateVoiceCallReport',_0x3e5cf0[_0x7081('0x13')],_0x3246c5);_0x5457cf(_0x3315ae[_0x7081('0x11')](0x1f4,_0x3e5cf0[_0x7081('0x13')]));});});};