c88378bfb475e4b19d710dc8b0f0e3073acd8398
[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 _0xf060=['client','http','then','request\x20sent','debug','stringify','error','code','VoiceCallReport,\x20%s,\x20%s','message','info','result','VoiceCallReport','findAll','options','raw','include','map','model','attributes','GetVoiceCallReport','CreateVoiceCallReport','create','catch','where','limit','UpdateVoiceCallReport','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise'];(function(_0x1d21c8,_0x48c93f){var _0x2bc198=function(_0x449927){while(--_0x449927){_0x1d21c8['push'](_0x1d21c8['shift']());}};_0x2bc198(++_0x48c93f);}(_0xf060,0x1d7));var _0x0f06=function(_0x2eafd5,_0x55653e){_0x2eafd5=_0x2eafd5-0x0;var _0x394c31=_0xf060[_0x2eafd5];return _0x394c31;};'use strict';var _=require(_0x0f06('0x0'));var util=require(_0x0f06('0x1'));var moment=require(_0x0f06('0x2'));var BPromise=require(_0x0f06('0x3'));var rs=require(_0x0f06('0x4'));var fs=require('fs');var Redis=require(_0x0f06('0x5'));var db=require(_0x0f06('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x0f06('0x7'));var config=require(_0x0f06('0x8'));var jayson=require(_0x0f06('0x9'));var client=jayson[_0x0f06('0xa')][_0x0f06('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x32f782,_0x4a46d5,_0x20cb34){return new BPromise(function(_0x3987fe,_0x3c85c9){return client['request'](_0x32f782,_0x20cb34)[_0x0f06('0xc')](function(_0x481ca7){logger['info']('VoiceCallReport,\x20%s,\x20%s',_0x4a46d5,_0x0f06('0xd'));logger[_0x0f06('0xe')]('VoiceCallReport,\x20%s,\x20%s,\x20%s',_0x4a46d5,_0x0f06('0xd'),JSON[_0x0f06('0xf')](_0x481ca7));if(_0x481ca7[_0x0f06('0x10')]){if(_0x481ca7[_0x0f06('0x10')][_0x0f06('0x11')]===0x1f4){logger[_0x0f06('0x10')](_0x0f06('0x12'),_0x4a46d5,_0x481ca7[_0x0f06('0x10')]['message']);return _0x3c85c9(_0x481ca7[_0x0f06('0x10')][_0x0f06('0x13')]);}logger[_0x0f06('0x10')]('VoiceCallReport,\x20%s,\x20%s',_0x4a46d5,_0x481ca7[_0x0f06('0x10')][_0x0f06('0x13')]);return _0x3987fe(_0x481ca7[_0x0f06('0x10')]['message']);}else{logger[_0x0f06('0x14')]('VoiceCallReport,\x20%s,\x20%s',_0x4a46d5,_0x0f06('0xd'));_0x3987fe(_0x481ca7[_0x0f06('0x15')][_0x0f06('0x13')]);}})['catch'](function(_0x2c986e){logger['error'](_0x0f06('0x12'),_0x4a46d5,_0x2c986e);_0x3c85c9(_0x2c986e);});});}exports['GetVoiceCallReport']=function(_0x3ff784){var _0x83b0c7=this;return new Promise(function(_0x3c7de5,_0x2a7b19){return db[_0x0f06('0x16')][_0x0f06('0x17')]({'raw':_0x3ff784[_0x0f06('0x18')]?_0x3ff784[_0x0f06('0x18')][_0x0f06('0x19')]===undefined?!![]:![]:!![],'where':_0x3ff784[_0x0f06('0x18')]?_0x3ff784[_0x0f06('0x18')]['where']||null:null,'attributes':_0x3ff784[_0x0f06('0x18')]?_0x3ff784[_0x0f06('0x18')]['attributes']||null:null,'limit':_0x3ff784[_0x0f06('0x18')]?_0x3ff784[_0x0f06('0x18')]['limit']||null:null,'include':_0x3ff784[_0x0f06('0x18')]?_0x3ff784['options'][_0x0f06('0x1a')]?_[_0x0f06('0x1b')](_0x3ff784[_0x0f06('0x18')][_0x0f06('0x1a')],function(_0xe411a3){return{'model':db[_0xe411a3[_0x0f06('0x1c')]],'as':_0xe411a3['as'],'attributes':_0xe411a3[_0x0f06('0x1d')],'include':_0xe411a3['include']?_[_0x0f06('0x1b')](_0xe411a3['include'],function(_0x117318){return{'model':db[_0x117318[_0x0f06('0x1c')]],'as':_0x117318['as'],'attributes':_0x117318[_0x0f06('0x1d')],'include':_0x117318[_0x0f06('0x1a')]?_[_0x0f06('0x1b')](_0x117318[_0x0f06('0x1a')],function(_0x1113f5){return{'model':db[_0x1113f5[_0x0f06('0x1c')]],'as':_0x1113f5['as'],'attributes':_0x1113f5[_0x0f06('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x0f06('0xc')](function(_0x36b3db){logger[_0x0f06('0x14')](_0x0f06('0x1e'),_0x3ff784);logger[_0x0f06('0xe')]('GetVoiceCallReport',_0x3ff784,JSON[_0x0f06('0xf')](_0x36b3db));_0x3c7de5(_0x36b3db);})['catch'](function(_0x14a493){logger[_0x0f06('0x10')](_0x0f06('0x1e'),_0x14a493['message'],_0x3ff784);_0x2a7b19(_0x83b0c7[_0x0f06('0x10')](0x1f4,_0x14a493[_0x0f06('0x13')]));});});};exports[_0x0f06('0x1f')]=function(_0xb5a245){var _0x497205=this;return new Promise(function(_0x2c0dee,_0x5ae866){return db[_0x0f06('0x16')][_0x0f06('0x20')](_0xb5a245['body'],{'raw':_0xb5a245[_0x0f06('0x18')]?_0xb5a245[_0x0f06('0x18')]['raw']===undefined?!![]:![]:!![]})[_0x0f06('0xc')](function(_0x16bd9f){logger[_0x0f06('0x14')](_0x0f06('0x1f'),_0xb5a245);logger[_0x0f06('0xe')](_0x0f06('0x1f'),_0xb5a245,JSON[_0x0f06('0xf')](_0x16bd9f));_0x2c0dee(_0x16bd9f);})[_0x0f06('0x21')](function(_0x1870bc){logger[_0x0f06('0x10')](_0x0f06('0x1f'),_0x1870bc['message'],_0xb5a245);_0x5ae866(_0x497205[_0x0f06('0x10')](0x1f4,_0x1870bc[_0x0f06('0x13')]));});});};exports['UpdateVoiceCallReport']=function(_0x3fb5af){var _0x17ca4f=this;return new Promise(function(_0x4ce205,_0x4f1903){return db[_0x0f06('0x16')]['update'](_0x3fb5af['body'],{'raw':_0x3fb5af[_0x0f06('0x18')]?_0x3fb5af[_0x0f06('0x18')][_0x0f06('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3fb5af[_0x0f06('0x18')]?_0x3fb5af[_0x0f06('0x18')][_0x0f06('0x22')]||null:null,'attributes':_0x3fb5af[_0x0f06('0x18')]?_0x3fb5af[_0x0f06('0x18')][_0x0f06('0x1d')]||null:null,'limit':_0x3fb5af[_0x0f06('0x18')]?_0x3fb5af[_0x0f06('0x18')][_0x0f06('0x23')]||null:null})[_0x0f06('0xc')](function(_0x2342cd){logger[_0x0f06('0x14')]('UpdateVoiceCallReport',_0x3fb5af);logger['debug'](_0x0f06('0x24'),_0x3fb5af,JSON['stringify'](_0x2342cd));_0x4ce205(_0x2342cd);})[_0x0f06('0x21')](function(_0x31ec07){logger['error'](_0x0f06('0x24'),_0x31ec07['message'],_0x3fb5af);_0x4f1903(_0x17ca4f['error'](0x1f4,_0x31ec07[_0x0f06('0x13')]));});});};