86e9a65e3e22b31f21dfeda48964d875ef14798d
[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 _0x028c=['../../mysqldb','../../config/utils','../../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','message','catch','GetVoiceCallReport','findAll','options','raw','where','attributes','limit','include','map','model','create','body','CreateVoiceCallReport','UpdateVoiceCallReport','VoiceCallReport','update','lodash','util','moment','bluebird','randomstring','ioredis'];(function(_0x22085a,_0x589318){var _0x528c36=function(_0x4bcd66){while(--_0x4bcd66){_0x22085a['push'](_0x22085a['shift']());}};_0x528c36(++_0x589318);}(_0x028c,0x92));var _0xc028=function(_0x21d1eb,_0x56f664){_0x21d1eb=_0x21d1eb-0x0;var _0x4cb8cd=_0x028c[_0x21d1eb];return _0x4cb8cd;};'use strict';var _=require(_0xc028('0x0'));var util=require(_0xc028('0x1'));var moment=require(_0xc028('0x2'));var BPromise=require(_0xc028('0x3'));var rs=require(_0xc028('0x4'));var fs=require('fs');var Redis=require(_0xc028('0x5'));var db=require(_0xc028('0x6'))['db'];var utils=require(_0xc028('0x7'));var logger=require('../../config/logger')('rpc');var config=require(_0xc028('0x8'));var jayson=require(_0xc028('0x9'));var client=jayson[_0xc028('0xa')][_0xc028('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x55c6e4,_0x29673c,_0x50e9bd){return new BPromise(function(_0x156906,_0x2ac6c2){return client['request'](_0x55c6e4,_0x50e9bd)[_0xc028('0xc')](function(_0x40767d){logger[_0xc028('0xd')](_0xc028('0xe'),_0x29673c,_0xc028('0xf'));logger[_0xc028('0x10')](_0xc028('0x11'),_0x29673c,_0xc028('0xf'),JSON[_0xc028('0x12')](_0x40767d));if(_0x40767d[_0xc028('0x13')]){if(_0x40767d[_0xc028('0x13')]['code']===0x1f4){logger[_0xc028('0x13')](_0xc028('0xe'),_0x29673c,_0x40767d[_0xc028('0x13')][_0xc028('0x14')]);return _0x2ac6c2(_0x40767d['error'][_0xc028('0x14')]);}logger['error'](_0xc028('0xe'),_0x29673c,_0x40767d['error'][_0xc028('0x14')]);return _0x156906(_0x40767d[_0xc028('0x13')][_0xc028('0x14')]);}else{logger['info'](_0xc028('0xe'),_0x29673c,_0xc028('0xf'));_0x156906(_0x40767d['result']['message']);}})[_0xc028('0x15')](function(_0x22f005){logger[_0xc028('0x13')](_0xc028('0xe'),_0x29673c,_0x22f005);_0x2ac6c2(_0x22f005);});});}exports[_0xc028('0x16')]=function(_0x1f921c){var _0x108f9d=this;return new Promise(function(_0x352c31,_0x2f4f71){return db['VoiceCallReport'][_0xc028('0x17')]({'raw':_0x1f921c[_0xc028('0x18')]?_0x1f921c[_0xc028('0x18')][_0xc028('0x19')]===undefined?!![]:![]:!![],'where':_0x1f921c[_0xc028('0x18')]?_0x1f921c[_0xc028('0x18')][_0xc028('0x1a')]||null:null,'attributes':_0x1f921c[_0xc028('0x18')]?_0x1f921c[_0xc028('0x18')][_0xc028('0x1b')]||null:null,'limit':_0x1f921c[_0xc028('0x18')]?_0x1f921c[_0xc028('0x18')][_0xc028('0x1c')]||null:null,'include':_0x1f921c[_0xc028('0x18')]?_0x1f921c[_0xc028('0x18')][_0xc028('0x1d')]?_[_0xc028('0x1e')](_0x1f921c['options'][_0xc028('0x1d')],function(_0x2b2aa9){return{'model':db[_0x2b2aa9[_0xc028('0x1f')]],'as':_0x2b2aa9['as'],'attributes':_0x2b2aa9[_0xc028('0x1b')],'include':_0x2b2aa9[_0xc028('0x1d')]?_[_0xc028('0x1e')](_0x2b2aa9[_0xc028('0x1d')],function(_0xea94e8){return{'model':db[_0xea94e8[_0xc028('0x1f')]],'as':_0xea94e8['as'],'attributes':_0xea94e8[_0xc028('0x1b')],'include':_0xea94e8[_0xc028('0x1d')]?_[_0xc028('0x1e')](_0xea94e8[_0xc028('0x1d')],function(_0x268b5a){return{'model':db[_0x268b5a['model']],'as':_0x268b5a['as'],'attributes':_0x268b5a[_0xc028('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xc028('0xc')](function(_0x560f09){logger[_0xc028('0xd')](_0xc028('0x16'),_0x1f921c);logger['debug'](_0xc028('0x16'),_0x1f921c,JSON[_0xc028('0x12')](_0x560f09));_0x352c31(_0x560f09);})[_0xc028('0x15')](function(_0x304127){logger['error']('GetVoiceCallReport',_0x304127[_0xc028('0x14')],_0x1f921c);_0x2f4f71(_0x108f9d[_0xc028('0x13')](0x1f4,_0x304127[_0xc028('0x14')]));});});};exports['CreateVoiceCallReport']=function(_0x154c82){var _0x19155d=this;return new Promise(function(_0x346ea5,_0x48dc69){return db['VoiceCallReport'][_0xc028('0x20')](_0x154c82[_0xc028('0x21')],{'raw':_0x154c82['options']?_0x154c82[_0xc028('0x18')][_0xc028('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x57a845){logger[_0xc028('0xd')](_0xc028('0x22'),_0x154c82);logger[_0xc028('0x10')]('CreateVoiceCallReport',_0x154c82,JSON[_0xc028('0x12')](_0x57a845));_0x346ea5(_0x57a845);})[_0xc028('0x15')](function(_0x55bdda){logger[_0xc028('0x13')](_0xc028('0x22'),_0x55bdda[_0xc028('0x14')],_0x154c82);_0x48dc69(_0x19155d['error'](0x1f4,_0x55bdda[_0xc028('0x14')]));});});};exports[_0xc028('0x23')]=function(_0x3a56e2){var _0x298d3e=this;return new Promise(function(_0x16f2ae,_0x22d7e2){return db[_0xc028('0x24')][_0xc028('0x25')](_0x3a56e2[_0xc028('0x21')],{'raw':_0x3a56e2[_0xc028('0x18')]?_0x3a56e2[_0xc028('0x18')][_0xc028('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3a56e2['options']?_0x3a56e2[_0xc028('0x18')]['where']||null:null,'attributes':_0x3a56e2[_0xc028('0x18')]?_0x3a56e2['options']['attributes']||null:null,'limit':_0x3a56e2[_0xc028('0x18')]?_0x3a56e2['options']['limit']||null:null})[_0xc028('0xc')](function(_0x23b1af){logger['info'](_0xc028('0x23'),_0x3a56e2);logger['debug'](_0xc028('0x23'),_0x3a56e2,JSON[_0xc028('0x12')](_0x23b1af));_0x16f2ae(_0x23b1af);})[_0xc028('0x15')](function(_0x55ba56){logger[_0xc028('0x13')](_0xc028('0x23'),_0x55ba56[_0xc028('0x14')],_0x3a56e2);_0x22d7e2(_0x298d3e['error'](0x1f4,_0x55ba56[_0xc028('0x14')]));});});};