dfbf044301032c4786510b2386910267cf325cc4
[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 _0xea85=['../../config/environment','jayson/promise','request','info','request\x20sent','debug','VoiceCallReport,\x20%s,\x20%s,\x20%s','error','VoiceCallReport,\x20%s,\x20%s','message','catch','GetVoiceCallReport','options','raw','where','attributes','limit','include','map','model','stringify','CreateVoiceCallReport','VoiceCallReport','body','then','UpdateVoiceCallReport','lodash','util','moment','../../config/utils','rpc'];(function(_0xebc80c,_0x18b2fa){var _0x5c60a0=function(_0x3a4258){while(--_0x3a4258){_0xebc80c['push'](_0xebc80c['shift']());}};_0x5c60a0(++_0x18b2fa);}(_0xea85,0x18e));var _0x5ea8=function(_0x5aebad,_0xa61f2e){_0x5aebad=_0x5aebad-0x0;var _0x47c1d6=_0xea85[_0x5aebad];return _0x47c1d6;};'use strict';var _=require(_0x5ea8('0x0'));var util=require(_0x5ea8('0x1'));var moment=require(_0x5ea8('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x5ea8('0x3'));var logger=require('../../config/logger')(_0x5ea8('0x4'));var config=require(_0x5ea8('0x5'));var jayson=require(_0x5ea8('0x6'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x309dc3,_0x725238,_0x5e0ed6){return new BPromise(function(_0x97daa,_0x39d258){return client[_0x5ea8('0x7')](_0x309dc3,_0x5e0ed6)['then'](function(_0x3b9b23){logger[_0x5ea8('0x8')]('VoiceCallReport,\x20%s,\x20%s',_0x725238,_0x5ea8('0x9'));logger[_0x5ea8('0xa')](_0x5ea8('0xb'),_0x725238,_0x5ea8('0x9'),JSON['stringify'](_0x3b9b23));if(_0x3b9b23[_0x5ea8('0xc')]){if(_0x3b9b23[_0x5ea8('0xc')]['code']===0x1f4){logger['error'](_0x5ea8('0xd'),_0x725238,_0x3b9b23[_0x5ea8('0xc')][_0x5ea8('0xe')]);return _0x39d258(_0x3b9b23[_0x5ea8('0xc')][_0x5ea8('0xe')]);}logger['error']('VoiceCallReport,\x20%s,\x20%s',_0x725238,_0x3b9b23['error'][_0x5ea8('0xe')]);return _0x97daa(_0x3b9b23[_0x5ea8('0xc')][_0x5ea8('0xe')]);}else{logger[_0x5ea8('0x8')](_0x5ea8('0xd'),_0x725238,_0x5ea8('0x9'));_0x97daa(_0x3b9b23['result'][_0x5ea8('0xe')]);}})[_0x5ea8('0xf')](function(_0xa81df9){logger[_0x5ea8('0xc')](_0x5ea8('0xd'),_0x725238,_0xa81df9);_0x39d258(_0xa81df9);});});}exports[_0x5ea8('0x10')]=function(_0x21fb57){var _0xfb7602=this;return new Promise(function(_0x14fa60,_0x2e5f4){return db['VoiceCallReport']['findAll']({'raw':_0x21fb57[_0x5ea8('0x11')]?_0x21fb57[_0x5ea8('0x11')][_0x5ea8('0x12')]===undefined?!![]:![]:!![],'where':_0x21fb57[_0x5ea8('0x11')]?_0x21fb57[_0x5ea8('0x11')][_0x5ea8('0x13')]||null:null,'attributes':_0x21fb57[_0x5ea8('0x11')]?_0x21fb57[_0x5ea8('0x11')][_0x5ea8('0x14')]||null:null,'limit':_0x21fb57[_0x5ea8('0x11')]?_0x21fb57[_0x5ea8('0x11')][_0x5ea8('0x15')]||null:null,'include':_0x21fb57['options']?_0x21fb57[_0x5ea8('0x11')][_0x5ea8('0x16')]?_[_0x5ea8('0x17')](_0x21fb57[_0x5ea8('0x11')]['include'],function(_0xb9db2b){return{'model':db[_0xb9db2b[_0x5ea8('0x18')]],'as':_0xb9db2b['as'],'attributes':_0xb9db2b[_0x5ea8('0x14')],'include':_0xb9db2b[_0x5ea8('0x16')]?_[_0x5ea8('0x17')](_0xb9db2b['include'],function(_0x499a02){return{'model':db[_0x499a02[_0x5ea8('0x18')]],'as':_0x499a02['as'],'attributes':_0x499a02['attributes'],'include':_0x499a02[_0x5ea8('0x16')]?_['map'](_0x499a02['include'],function(_0xa6dd8c){return{'model':db[_0xa6dd8c[_0x5ea8('0x18')]],'as':_0xa6dd8c['as'],'attributes':_0xa6dd8c['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x21d1a7){logger[_0x5ea8('0x8')](_0x5ea8('0x10'),_0x21fb57);logger[_0x5ea8('0xa')](_0x5ea8('0x10'),_0x21fb57,JSON[_0x5ea8('0x19')](_0x21d1a7));_0x14fa60(_0x21d1a7);})[_0x5ea8('0xf')](function(_0x12eda3){logger['error'](_0x5ea8('0x10'),_0x12eda3[_0x5ea8('0xe')],_0x21fb57);_0x2e5f4(_0xfb7602[_0x5ea8('0xc')](0x1f4,_0x12eda3[_0x5ea8('0xe')]));});});};exports[_0x5ea8('0x1a')]=function(_0x3ff5b2){var _0xf873f2=this;return new Promise(function(_0x1f294f,_0x44b860){return db[_0x5ea8('0x1b')]['create'](_0x3ff5b2[_0x5ea8('0x1c')],{'raw':_0x3ff5b2[_0x5ea8('0x11')]?_0x3ff5b2[_0x5ea8('0x11')][_0x5ea8('0x12')]===undefined?!![]:![]:!![]})[_0x5ea8('0x1d')](function(_0x156fb6){logger[_0x5ea8('0x8')](_0x5ea8('0x1a'),_0x3ff5b2);logger[_0x5ea8('0xa')](_0x5ea8('0x1a'),_0x3ff5b2,JSON[_0x5ea8('0x19')](_0x156fb6));_0x1f294f(_0x156fb6);})['catch'](function(_0x29a824){logger['error'](_0x5ea8('0x1a'),_0x29a824[_0x5ea8('0xe')],_0x3ff5b2);_0x44b860(_0xf873f2[_0x5ea8('0xc')](0x1f4,_0x29a824['message']));});});};exports[_0x5ea8('0x1e')]=function(_0x4077e1){var _0x1c53d4=this;return new Promise(function(_0x3767e4,_0x2faf94){return db[_0x5ea8('0x1b')]['update'](_0x4077e1['body'],{'raw':_0x4077e1['options']?_0x4077e1[_0x5ea8('0x11')][_0x5ea8('0x12')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4077e1[_0x5ea8('0x11')]?_0x4077e1[_0x5ea8('0x11')][_0x5ea8('0x13')]||null:null,'attributes':_0x4077e1['options']?_0x4077e1[_0x5ea8('0x11')][_0x5ea8('0x14')]||null:null,'limit':_0x4077e1[_0x5ea8('0x11')]?_0x4077e1['options'][_0x5ea8('0x15')]||null:null})[_0x5ea8('0x1d')](function(_0x47ff02){logger[_0x5ea8('0x8')](_0x5ea8('0x1e'),_0x4077e1);logger[_0x5ea8('0xa')](_0x5ea8('0x1e'),_0x4077e1,JSON[_0x5ea8('0x19')](_0x47ff02));_0x3767e4(_0x47ff02);})['catch'](function(_0x113384){logger[_0x5ea8('0xc')](_0x5ea8('0x1e'),_0x113384[_0x5ea8('0xe')],_0x4077e1);_0x2faf94(_0x1c53d4['error'](0x1f4,_0x113384[_0x5ea8('0xe')]));});});};