Built motion from commit fa4c4286.|2.6.29
[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 _0x7406=['GetVoiceCallReport','options','raw','where','limit','include','map','attributes','model','stringify','CreateVoiceCallReport','VoiceCallReport','create','body','UpdateVoiceCallReport','update','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','then','info','VoiceCallReport,\x20%s,\x20%s','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','error','code','message','catch'];(function(_0x34ad72,_0x1e43f6){var _0x5c9aa8=function(_0x144388){while(--_0x144388){_0x34ad72['push'](_0x34ad72['shift']());}};_0x5c9aa8(++_0x1e43f6);}(_0x7406,0x10c));var _0x6740=function(_0x580c7f,_0x2ecf18){_0x580c7f=_0x580c7f-0x0;var _0x3b90e1=_0x7406[_0x580c7f];return _0x3b90e1;};'use strict';var _=require('lodash');var util=require(_0x6740('0x0'));var moment=require(_0x6740('0x1'));var BPromise=require('bluebird');var rs=require(_0x6740('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6740('0x3'))['db'];var utils=require(_0x6740('0x4'));var logger=require(_0x6740('0x5'))(_0x6740('0x6'));var config=require('../../config/environment');var jayson=require(_0x6740('0x7'));var client=jayson[_0x6740('0x8')][_0x6740('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4a683f,_0x3cb60b,_0x2a6a8e){return new BPromise(function(_0x5cb2be,_0x1b44c4){return client['request'](_0x4a683f,_0x2a6a8e)[_0x6740('0xa')](function(_0x25de9f){logger[_0x6740('0xb')](_0x6740('0xc'),_0x3cb60b,_0x6740('0xd'));logger[_0x6740('0xe')](_0x6740('0xf'),_0x3cb60b,_0x6740('0xd'),JSON['stringify'](_0x25de9f));if(_0x25de9f[_0x6740('0x10')]){if(_0x25de9f['error'][_0x6740('0x11')]===0x1f4){logger[_0x6740('0x10')](_0x6740('0xc'),_0x3cb60b,_0x25de9f[_0x6740('0x10')][_0x6740('0x12')]);return _0x1b44c4(_0x25de9f[_0x6740('0x10')][_0x6740('0x12')]);}logger['error'](_0x6740('0xc'),_0x3cb60b,_0x25de9f[_0x6740('0x10')]['message']);return _0x5cb2be(_0x25de9f['error']['message']);}else{logger[_0x6740('0xb')](_0x6740('0xc'),_0x3cb60b,_0x6740('0xd'));_0x5cb2be(_0x25de9f['result'][_0x6740('0x12')]);}})[_0x6740('0x13')](function(_0x4229b2){logger[_0x6740('0x10')](_0x6740('0xc'),_0x3cb60b,_0x4229b2);_0x1b44c4(_0x4229b2);});});}exports[_0x6740('0x14')]=function(_0x1eea69){var _0x30ffe0=this;return new Promise(function(_0x4b5326,_0x20738c){return db['VoiceCallReport']['findAll']({'raw':_0x1eea69[_0x6740('0x15')]?_0x1eea69['options'][_0x6740('0x16')]===undefined?!![]:![]:!![],'where':_0x1eea69[_0x6740('0x15')]?_0x1eea69[_0x6740('0x15')][_0x6740('0x17')]||null:null,'attributes':_0x1eea69[_0x6740('0x15')]?_0x1eea69['options']['attributes']||null:null,'limit':_0x1eea69['options']?_0x1eea69[_0x6740('0x15')][_0x6740('0x18')]||null:null,'include':_0x1eea69[_0x6740('0x15')]?_0x1eea69[_0x6740('0x15')][_0x6740('0x19')]?_[_0x6740('0x1a')](_0x1eea69[_0x6740('0x15')]['include'],function(_0x46881a){return{'model':db[_0x46881a['model']],'as':_0x46881a['as'],'attributes':_0x46881a[_0x6740('0x1b')],'include':_0x46881a['include']?_[_0x6740('0x1a')](_0x46881a[_0x6740('0x19')],function(_0x51c8c0){return{'model':db[_0x51c8c0[_0x6740('0x1c')]],'as':_0x51c8c0['as'],'attributes':_0x51c8c0[_0x6740('0x1b')],'include':_0x51c8c0[_0x6740('0x19')]?_[_0x6740('0x1a')](_0x51c8c0[_0x6740('0x19')],function(_0x18eb17){return{'model':db[_0x18eb17[_0x6740('0x1c')]],'as':_0x18eb17['as'],'attributes':_0x18eb17[_0x6740('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xe4d6fe){logger[_0x6740('0xb')]('GetVoiceCallReport',_0x1eea69);logger[_0x6740('0xe')]('GetVoiceCallReport',_0x1eea69,JSON[_0x6740('0x1d')](_0xe4d6fe));_0x4b5326(_0xe4d6fe);})[_0x6740('0x13')](function(_0x242ecf){logger['error'](_0x6740('0x14'),_0x242ecf[_0x6740('0x12')],_0x1eea69);_0x20738c(_0x30ffe0[_0x6740('0x10')](0x1f4,_0x242ecf[_0x6740('0x12')]));});});};exports[_0x6740('0x1e')]=function(_0x410a5d){var _0x2f99be=this;return new Promise(function(_0x398d78,_0x4cb513){return db[_0x6740('0x1f')][_0x6740('0x20')](_0x410a5d[_0x6740('0x21')],{'raw':_0x410a5d[_0x6740('0x15')]?_0x410a5d[_0x6740('0x15')][_0x6740('0x16')]===undefined?!![]:![]:!![]})[_0x6740('0xa')](function(_0x269d7a){logger['info'](_0x6740('0x1e'),_0x410a5d);logger['debug'](_0x6740('0x1e'),_0x410a5d,JSON['stringify'](_0x269d7a));_0x398d78(_0x269d7a);})[_0x6740('0x13')](function(_0x310fe7){logger[_0x6740('0x10')]('CreateVoiceCallReport',_0x310fe7[_0x6740('0x12')],_0x410a5d);_0x4cb513(_0x2f99be[_0x6740('0x10')](0x1f4,_0x310fe7[_0x6740('0x12')]));});});};exports[_0x6740('0x22')]=function(_0x272c24){var _0x1abdf2=this;return new Promise(function(_0x331731,_0x25e2ca){return db[_0x6740('0x1f')][_0x6740('0x23')](_0x272c24[_0x6740('0x21')],{'raw':_0x272c24['options']?_0x272c24['options'][_0x6740('0x16')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x272c24[_0x6740('0x15')]?_0x272c24[_0x6740('0x15')]['where']||null:null,'attributes':_0x272c24[_0x6740('0x15')]?_0x272c24[_0x6740('0x15')]['attributes']||null:null,'limit':_0x272c24[_0x6740('0x15')]?_0x272c24[_0x6740('0x15')][_0x6740('0x18')]||null:null})['then'](function(_0x14fd86){logger[_0x6740('0xb')]('UpdateVoiceCallReport',_0x272c24);logger[_0x6740('0xe')](_0x6740('0x22'),_0x272c24,JSON['stringify'](_0x14fd86));_0x331731(_0x14fd86);})[_0x6740('0x13')](function(_0x431e1c){logger['error']('UpdateVoiceCallReport',_0x431e1c['message'],_0x272c24);_0x25e2ca(_0x1abdf2[_0x6740('0x10')](0x1f4,_0x431e1c[_0x6740('0x12')]));});});};