ff25b20c94806a1166ed08ce133b9e74dc5361f5
[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 _0xa8e5=['rpc','jayson/promise','client','http','then','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','stringify','error','code','VoiceCallReport,\x20%s,\x20%s','message','info','result','catch','GetVoiceCallReport','VoiceCallReport','findAll','options','raw','where','attributes','limit','include','model','map','CreateVoiceCallReport','create','body','update','UpdateVoiceCallReport','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger'];(function(_0x204877,_0x1f1133){var _0x34d2e2=function(_0x596518){while(--_0x596518){_0x204877['push'](_0x204877['shift']());}};_0x34d2e2(++_0x1f1133);}(_0xa8e5,0x95));var _0x5a8e=function(_0x461ba4,_0x3d3a8d){_0x461ba4=_0x461ba4-0x0;var _0x28bdfc=_0xa8e5[_0x461ba4];return _0x28bdfc;};'use strict';var _=require('lodash');var util=require(_0x5a8e('0x0'));var moment=require(_0x5a8e('0x1'));var BPromise=require(_0x5a8e('0x2'));var rs=require(_0x5a8e('0x3'));var fs=require('fs');var Redis=require(_0x5a8e('0x4'));var db=require(_0x5a8e('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x5a8e('0x6'))(_0x5a8e('0x7'));var config=require('../../config/environment');var jayson=require(_0x5a8e('0x8'));var client=jayson[_0x5a8e('0x9')][_0x5a8e('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x25b512,_0x181d80,_0x427a4d){return new BPromise(function(_0x3228cd,_0x23b65c){return client['request'](_0x25b512,_0x427a4d)[_0x5a8e('0xb')](function(_0x2e5c3d){logger['info']('VoiceCallReport,\x20%s,\x20%s',_0x181d80,_0x5a8e('0xc'));logger[_0x5a8e('0xd')](_0x5a8e('0xe'),_0x181d80,_0x5a8e('0xc'),JSON[_0x5a8e('0xf')](_0x2e5c3d));if(_0x2e5c3d[_0x5a8e('0x10')]){if(_0x2e5c3d[_0x5a8e('0x10')][_0x5a8e('0x11')]===0x1f4){logger[_0x5a8e('0x10')](_0x5a8e('0x12'),_0x181d80,_0x2e5c3d[_0x5a8e('0x10')][_0x5a8e('0x13')]);return _0x23b65c(_0x2e5c3d[_0x5a8e('0x10')][_0x5a8e('0x13')]);}logger[_0x5a8e('0x10')]('VoiceCallReport,\x20%s,\x20%s',_0x181d80,_0x2e5c3d['error'][_0x5a8e('0x13')]);return _0x3228cd(_0x2e5c3d[_0x5a8e('0x10')][_0x5a8e('0x13')]);}else{logger[_0x5a8e('0x14')](_0x5a8e('0x12'),_0x181d80,_0x5a8e('0xc'));_0x3228cd(_0x2e5c3d[_0x5a8e('0x15')][_0x5a8e('0x13')]);}})[_0x5a8e('0x16')](function(_0x2cf91e){logger['error'](_0x5a8e('0x12'),_0x181d80,_0x2cf91e);_0x23b65c(_0x2cf91e);});});}exports[_0x5a8e('0x17')]=function(_0x1f88da){var _0x163365=this;return new Promise(function(_0x268622,_0x1cb23c){return db[_0x5a8e('0x18')][_0x5a8e('0x19')]({'raw':_0x1f88da['options']?_0x1f88da[_0x5a8e('0x1a')][_0x5a8e('0x1b')]===undefined?!![]:![]:!![],'where':_0x1f88da[_0x5a8e('0x1a')]?_0x1f88da['options'][_0x5a8e('0x1c')]||null:null,'attributes':_0x1f88da['options']?_0x1f88da[_0x5a8e('0x1a')][_0x5a8e('0x1d')]||null:null,'limit':_0x1f88da['options']?_0x1f88da[_0x5a8e('0x1a')][_0x5a8e('0x1e')]||null:null,'include':_0x1f88da[_0x5a8e('0x1a')]?_0x1f88da[_0x5a8e('0x1a')][_0x5a8e('0x1f')]?_['map'](_0x1f88da[_0x5a8e('0x1a')][_0x5a8e('0x1f')],function(_0x42c496){return{'model':db[_0x42c496[_0x5a8e('0x20')]],'as':_0x42c496['as'],'attributes':_0x42c496[_0x5a8e('0x1d')],'include':_0x42c496[_0x5a8e('0x1f')]?_[_0x5a8e('0x21')](_0x42c496[_0x5a8e('0x1f')],function(_0x2e7e4a){return{'model':db[_0x2e7e4a[_0x5a8e('0x20')]],'as':_0x2e7e4a['as'],'attributes':_0x2e7e4a[_0x5a8e('0x1d')],'include':_0x2e7e4a[_0x5a8e('0x1f')]?_[_0x5a8e('0x21')](_0x2e7e4a[_0x5a8e('0x1f')],function(_0x1d2a3e){return{'model':db[_0x1d2a3e[_0x5a8e('0x20')]],'as':_0x1d2a3e['as'],'attributes':_0x1d2a3e[_0x5a8e('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x5a8e('0xb')](function(_0x1458d7){logger[_0x5a8e('0x14')](_0x5a8e('0x17'),_0x1f88da);logger[_0x5a8e('0xd')](_0x5a8e('0x17'),_0x1f88da,JSON[_0x5a8e('0xf')](_0x1458d7));_0x268622(_0x1458d7);})[_0x5a8e('0x16')](function(_0x4b8755){logger['error'](_0x5a8e('0x17'),_0x4b8755[_0x5a8e('0x13')],_0x1f88da);_0x1cb23c(_0x163365[_0x5a8e('0x10')](0x1f4,_0x4b8755[_0x5a8e('0x13')]));});});};exports[_0x5a8e('0x22')]=function(_0x4c99ba){var _0x25806c=this;return new Promise(function(_0x14ca3d,_0x4a157b){return db[_0x5a8e('0x18')][_0x5a8e('0x23')](_0x4c99ba[_0x5a8e('0x24')],{'raw':_0x4c99ba[_0x5a8e('0x1a')]?_0x4c99ba['options'][_0x5a8e('0x1b')]===undefined?!![]:![]:!![]})[_0x5a8e('0xb')](function(_0x984d64){logger[_0x5a8e('0x14')](_0x5a8e('0x22'),_0x4c99ba);logger[_0x5a8e('0xd')](_0x5a8e('0x22'),_0x4c99ba,JSON[_0x5a8e('0xf')](_0x984d64));_0x14ca3d(_0x984d64);})['catch'](function(_0x41fcbe){logger[_0x5a8e('0x10')](_0x5a8e('0x22'),_0x41fcbe[_0x5a8e('0x13')],_0x4c99ba);_0x4a157b(_0x25806c[_0x5a8e('0x10')](0x1f4,_0x41fcbe[_0x5a8e('0x13')]));});});};exports['UpdateVoiceCallReport']=function(_0x32f136){var _0x145d8d=this;return new Promise(function(_0x3cd930,_0x55d73a){return db[_0x5a8e('0x18')][_0x5a8e('0x25')](_0x32f136['body'],{'raw':_0x32f136['options']?_0x32f136['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x32f136['options']?_0x32f136['options'][_0x5a8e('0x1c')]||null:null,'attributes':_0x32f136['options']?_0x32f136[_0x5a8e('0x1a')]['attributes']||null:null,'limit':_0x32f136['options']?_0x32f136[_0x5a8e('0x1a')]['limit']||null:null})[_0x5a8e('0xb')](function(_0x70ef4b){logger['info']('UpdateVoiceCallReport',_0x32f136);logger[_0x5a8e('0xd')](_0x5a8e('0x26'),_0x32f136,JSON[_0x5a8e('0xf')](_0x70ef4b));_0x3cd930(_0x70ef4b);})['catch'](function(_0x57d4da){logger['error'](_0x5a8e('0x26'),_0x57d4da[_0x5a8e('0x13')],_0x32f136);_0x55d73a(_0x145d8d[_0x5a8e('0x10')](0x1f4,_0x57d4da['message']));});});};