0bba02140ce5d4f563bd1e0aac9b604c378c581c
[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 _0xb197=['create','UpdateVoiceCallReport','VoiceCallReport','update','body','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','info','VoiceCallReport,\x20%s,\x20%s','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','findAll','options','raw','where','attributes','limit','include','model','map','GetVoiceCallReport','stringify','CreateVoiceCallReport'];(function(_0x2f7d61,_0x20dc7a){var _0x4dd7c2=function(_0x1ea738){while(--_0x1ea738){_0x2f7d61['push'](_0x2f7d61['shift']());}};_0x4dd7c2(++_0x20dc7a);}(_0xb197,0x176));var _0x7b19=function(_0xfc0976,_0x33776f){_0xfc0976=_0xfc0976-0x0;var _0x23579f=_0xb197[_0xfc0976];return _0x23579f;};'use strict';var _=require(_0x7b19('0x0'));var util=require(_0x7b19('0x1'));var moment=require(_0x7b19('0x2'));var BPromise=require(_0x7b19('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7b19('0x4'));var db=require(_0x7b19('0x5'))['db'];var utils=require(_0x7b19('0x6'));var logger=require(_0x7b19('0x7'))(_0x7b19('0x8'));var config=require(_0x7b19('0x9'));var jayson=require(_0x7b19('0xa'));var client=jayson[_0x7b19('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x20b522,_0xe6b22,_0x2578db){return new BPromise(function(_0x6a8fa0,_0x450d44){return client[_0x7b19('0xc')](_0x20b522,_0x2578db)[_0x7b19('0xd')](function(_0x5c2318){logger[_0x7b19('0xe')](_0x7b19('0xf'),_0xe6b22,_0x7b19('0x10'));logger[_0x7b19('0x11')](_0x7b19('0x12'),_0xe6b22,'request\x20sent',JSON['stringify'](_0x5c2318));if(_0x5c2318[_0x7b19('0x13')]){if(_0x5c2318[_0x7b19('0x13')][_0x7b19('0x14')]===0x1f4){logger[_0x7b19('0x13')]('VoiceCallReport,\x20%s,\x20%s',_0xe6b22,_0x5c2318[_0x7b19('0x13')][_0x7b19('0x15')]);return _0x450d44(_0x5c2318['error'][_0x7b19('0x15')]);}logger[_0x7b19('0x13')]('VoiceCallReport,\x20%s,\x20%s',_0xe6b22,_0x5c2318['error'][_0x7b19('0x15')]);return _0x6a8fa0(_0x5c2318[_0x7b19('0x13')][_0x7b19('0x15')]);}else{logger['info'](_0x7b19('0xf'),_0xe6b22,_0x7b19('0x10'));_0x6a8fa0(_0x5c2318[_0x7b19('0x16')]['message']);}})[_0x7b19('0x17')](function(_0x2a45bb){logger['error'](_0x7b19('0xf'),_0xe6b22,_0x2a45bb);_0x450d44(_0x2a45bb);});});}exports['GetVoiceCallReport']=function(_0x49f7ef){var _0x20122c=this;return new Promise(function(_0x1af31d,_0x10089c){return db['VoiceCallReport'][_0x7b19('0x18')]({'raw':_0x49f7ef['options']?_0x49f7ef[_0x7b19('0x19')][_0x7b19('0x1a')]===undefined?!![]:![]:!![],'where':_0x49f7ef[_0x7b19('0x19')]?_0x49f7ef[_0x7b19('0x19')][_0x7b19('0x1b')]||null:null,'attributes':_0x49f7ef[_0x7b19('0x19')]?_0x49f7ef['options'][_0x7b19('0x1c')]||null:null,'limit':_0x49f7ef[_0x7b19('0x19')]?_0x49f7ef[_0x7b19('0x19')][_0x7b19('0x1d')]||null:null,'include':_0x49f7ef[_0x7b19('0x19')]?_0x49f7ef['options'][_0x7b19('0x1e')]?_['map'](_0x49f7ef['options'][_0x7b19('0x1e')],function(_0x13ada5){return{'model':db[_0x13ada5[_0x7b19('0x1f')]],'as':_0x13ada5['as'],'attributes':_0x13ada5[_0x7b19('0x1c')],'include':_0x13ada5[_0x7b19('0x1e')]?_['map'](_0x13ada5[_0x7b19('0x1e')],function(_0x51840f){return{'model':db[_0x51840f['model']],'as':_0x51840f['as'],'attributes':_0x51840f['attributes'],'include':_0x51840f['include']?_[_0x7b19('0x20')](_0x51840f[_0x7b19('0x1e')],function(_0x1eefd7){return{'model':db[_0x1eefd7['model']],'as':_0x1eefd7['as'],'attributes':_0x1eefd7[_0x7b19('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x9629d6){logger['info'](_0x7b19('0x21'),_0x49f7ef);logger[_0x7b19('0x11')](_0x7b19('0x21'),_0x49f7ef,JSON[_0x7b19('0x22')](_0x9629d6));_0x1af31d(_0x9629d6);})[_0x7b19('0x17')](function(_0x185614){logger['error'](_0x7b19('0x21'),_0x185614[_0x7b19('0x15')],_0x49f7ef);_0x10089c(_0x20122c[_0x7b19('0x13')](0x1f4,_0x185614[_0x7b19('0x15')]));});});};exports[_0x7b19('0x23')]=function(_0x27e364){var _0x4b9813=this;return new Promise(function(_0x5551e9,_0x1e46ed){return db['VoiceCallReport'][_0x7b19('0x24')](_0x27e364['body'],{'raw':_0x27e364[_0x7b19('0x19')]?_0x27e364[_0x7b19('0x19')][_0x7b19('0x1a')]===undefined?!![]:![]:!![]})['then'](function(_0x3754c3){logger[_0x7b19('0xe')](_0x7b19('0x23'),_0x27e364);logger[_0x7b19('0x11')]('CreateVoiceCallReport',_0x27e364,JSON[_0x7b19('0x22')](_0x3754c3));_0x5551e9(_0x3754c3);})[_0x7b19('0x17')](function(_0x15e635){logger['error'](_0x7b19('0x23'),_0x15e635[_0x7b19('0x15')],_0x27e364);_0x1e46ed(_0x4b9813['error'](0x1f4,_0x15e635[_0x7b19('0x15')]));});});};exports[_0x7b19('0x25')]=function(_0x192904){var _0x5c5a4c=this;return new Promise(function(_0xe87af3,_0x384e1d){return db[_0x7b19('0x26')][_0x7b19('0x27')](_0x192904[_0x7b19('0x28')],{'raw':_0x192904[_0x7b19('0x19')]?_0x192904['options'][_0x7b19('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x192904[_0x7b19('0x19')]?_0x192904[_0x7b19('0x19')][_0x7b19('0x1b')]||null:null,'attributes':_0x192904[_0x7b19('0x19')]?_0x192904[_0x7b19('0x19')][_0x7b19('0x1c')]||null:null,'limit':_0x192904['options']?_0x192904[_0x7b19('0x19')][_0x7b19('0x1d')]||null:null})[_0x7b19('0xd')](function(_0x3c9b10){logger[_0x7b19('0xe')](_0x7b19('0x25'),_0x192904);logger[_0x7b19('0x11')](_0x7b19('0x25'),_0x192904,JSON[_0x7b19('0x22')](_0x3c9b10));_0xe87af3(_0x3c9b10);})[_0x7b19('0x17')](function(_0x45c974){logger[_0x7b19('0x13')](_0x7b19('0x25'),_0x45c974[_0x7b19('0x15')],_0x192904);_0x384e1d(_0x5c5a4c['error'](0x1f4,_0x45c974[_0x7b19('0x15')]));});});};