1f2144f32e2e0bd881c1826c918f9b041045ce48
[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 _0xb118=['VoiceCallReport,\x20%s,\x20%s','VoiceCallReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetVoiceCallReport','findAll','options','raw','where','attributes','limit','map','model','include','debug','CreateVoiceCallReport','VoiceCallReport','create','update','body','UpdateVoiceCallReport','lodash','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','http','then','info'];(function(_0x10c51f,_0x11270f){var _0x56a0cd=function(_0x563ac6){while(--_0x563ac6){_0x10c51f['push'](_0x10c51f['shift']());}};_0x56a0cd(++_0x11270f);}(_0xb118,0xce));var _0x8b11=function(_0x24693e,_0x2ba888){_0x24693e=_0x24693e-0x0;var _0x53e672=_0xb118[_0x24693e];return _0x53e672;};'use strict';var _=require(_0x8b11('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x8b11('0x1'));var fs=require('fs');var Redis=require(_0x8b11('0x2'));var db=require(_0x8b11('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x8b11('0x4'));var config=require(_0x8b11('0x5'));var jayson=require(_0x8b11('0x6'));var client=jayson['client'][_0x8b11('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x1d7ba1,_0x3a285c,_0x489882){return new BPromise(function(_0x3927f1,_0x5ca678){return client['request'](_0x1d7ba1,_0x489882)[_0x8b11('0x8')](function(_0x1bc55f){logger[_0x8b11('0x9')](_0x8b11('0xa'),_0x3a285c,'request\x20sent');logger['debug'](_0x8b11('0xb'),_0x3a285c,_0x8b11('0xc'),JSON[_0x8b11('0xd')](_0x1bc55f));if(_0x1bc55f[_0x8b11('0xe')]){if(_0x1bc55f[_0x8b11('0xe')][_0x8b11('0xf')]===0x1f4){logger['error'](_0x8b11('0xa'),_0x3a285c,_0x1bc55f['error'][_0x8b11('0x10')]);return _0x5ca678(_0x1bc55f['error'][_0x8b11('0x10')]);}logger['error']('VoiceCallReport,\x20%s,\x20%s',_0x3a285c,_0x1bc55f[_0x8b11('0xe')][_0x8b11('0x10')]);return _0x3927f1(_0x1bc55f[_0x8b11('0xe')][_0x8b11('0x10')]);}else{logger[_0x8b11('0x9')](_0x8b11('0xa'),_0x3a285c,_0x8b11('0xc'));_0x3927f1(_0x1bc55f[_0x8b11('0x11')][_0x8b11('0x10')]);}})[_0x8b11('0x12')](function(_0x5db860){logger[_0x8b11('0xe')]('VoiceCallReport,\x20%s,\x20%s',_0x3a285c,_0x5db860);_0x5ca678(_0x5db860);});});}exports[_0x8b11('0x13')]=function(_0x1d88ea){var _0x1f3f16=this;return new Promise(function(_0x37eaf9,_0x3649c4){return db['VoiceCallReport'][_0x8b11('0x14')]({'raw':_0x1d88ea[_0x8b11('0x15')]?_0x1d88ea[_0x8b11('0x15')][_0x8b11('0x16')]===undefined?!![]:![]:!![],'where':_0x1d88ea['options']?_0x1d88ea[_0x8b11('0x15')][_0x8b11('0x17')]||null:null,'attributes':_0x1d88ea[_0x8b11('0x15')]?_0x1d88ea[_0x8b11('0x15')][_0x8b11('0x18')]||null:null,'limit':_0x1d88ea['options']?_0x1d88ea['options'][_0x8b11('0x19')]||null:null,'include':_0x1d88ea[_0x8b11('0x15')]?_0x1d88ea[_0x8b11('0x15')]['include']?_[_0x8b11('0x1a')](_0x1d88ea[_0x8b11('0x15')]['include'],function(_0x247b7c){return{'model':db[_0x247b7c[_0x8b11('0x1b')]],'as':_0x247b7c['as'],'attributes':_0x247b7c[_0x8b11('0x18')],'include':_0x247b7c['include']?_['map'](_0x247b7c[_0x8b11('0x1c')],function(_0x4de9c2){return{'model':db[_0x4de9c2[_0x8b11('0x1b')]],'as':_0x4de9c2['as'],'attributes':_0x4de9c2[_0x8b11('0x18')],'include':_0x4de9c2[_0x8b11('0x1c')]?_[_0x8b11('0x1a')](_0x4de9c2[_0x8b11('0x1c')],function(_0x31b352){return{'model':db[_0x31b352['model']],'as':_0x31b352['as'],'attributes':_0x31b352['attributes']};}):[]};}):[]};}):[]:[]})[_0x8b11('0x8')](function(_0x29a233){logger[_0x8b11('0x9')](_0x8b11('0x13'),_0x1d88ea);logger[_0x8b11('0x1d')](_0x8b11('0x13'),_0x1d88ea,JSON['stringify'](_0x29a233));_0x37eaf9(_0x29a233);})[_0x8b11('0x12')](function(_0x330c0b){logger['error']('GetVoiceCallReport',_0x330c0b['message'],_0x1d88ea);_0x3649c4(_0x1f3f16[_0x8b11('0xe')](0x1f4,_0x330c0b[_0x8b11('0x10')]));});});};exports[_0x8b11('0x1e')]=function(_0x566291){var _0x26bba6=this;return new Promise(function(_0x1b8361,_0x41f301){return db[_0x8b11('0x1f')][_0x8b11('0x20')](_0x566291['body'],{'raw':_0x566291[_0x8b11('0x15')]?_0x566291[_0x8b11('0x15')][_0x8b11('0x16')]===undefined?!![]:![]:!![]})['then'](function(_0x58d504){logger[_0x8b11('0x9')](_0x8b11('0x1e'),_0x566291);logger[_0x8b11('0x1d')](_0x8b11('0x1e'),_0x566291,JSON[_0x8b11('0xd')](_0x58d504));_0x1b8361(_0x58d504);})['catch'](function(_0x5ea5dd){logger[_0x8b11('0xe')](_0x8b11('0x1e'),_0x5ea5dd[_0x8b11('0x10')],_0x566291);_0x41f301(_0x26bba6[_0x8b11('0xe')](0x1f4,_0x5ea5dd[_0x8b11('0x10')]));});});};exports['UpdateVoiceCallReport']=function(_0x3b880f){var _0x6cee19=this;return new Promise(function(_0x53adff,_0x295d69){return db[_0x8b11('0x1f')][_0x8b11('0x21')](_0x3b880f[_0x8b11('0x22')],{'raw':_0x3b880f[_0x8b11('0x15')]?_0x3b880f[_0x8b11('0x15')][_0x8b11('0x16')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3b880f[_0x8b11('0x15')]?_0x3b880f[_0x8b11('0x15')]['where']||null:null,'attributes':_0x3b880f[_0x8b11('0x15')]?_0x3b880f['options']['attributes']||null:null,'limit':_0x3b880f[_0x8b11('0x15')]?_0x3b880f[_0x8b11('0x15')]['limit']||null:null})[_0x8b11('0x8')](function(_0x414b7e){logger[_0x8b11('0x9')](_0x8b11('0x23'),_0x3b880f);logger[_0x8b11('0x1d')]('UpdateVoiceCallReport',_0x3b880f,JSON['stringify'](_0x414b7e));_0x53adff(_0x414b7e);})[_0x8b11('0x12')](function(_0x2b1558){logger['error'](_0x8b11('0x23'),_0x2b1558[_0x8b11('0x10')],_0x3b880f);_0x295d69(_0x6cee19[_0x8b11('0xe')](0x1f4,_0x2b1558[_0x8b11('0x10')]));});});};