Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / intZohoAccount / intZohoAccount.controller.js
index 3c4fb76..c53aa81 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa603=['find','create','body','destroy','getConfigurations','findOne','rawAttributes','nolimit','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','ZohoField','zone','https://accounts.zoho.eu','https://accounts.zoho.com.cn','POST','refreshToken','clientId','clientSecret','refresh_token','access_token','Unable\x20to\x20retrieve\x20the\x20access\x20token','getFields','host','serverUrl','code','zoho.eu','com','slice','substring','lastIndexOf','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','GET','format','https://www.zohoapis.%s/crm/v2/settings/fields','Zoho-oauthtoken\x20','response','Owner','Subject','Description','WhoId','Call_Duration','Call_Result','Call_Start_Time','includes','api_name','push','display_label','picklist','pick_list_values','getFields,\x20%s,\x20%s,\x20%s','send','test','Wrong\x20credentials','statusCode','eml-format','rimraf','fast-json-patch','request-promise','bluebird','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','json','offset','undefined','limit','count','status','set','Content-Range','apply','reject','save','update','then','error','stack','name','index','ZohoAccount','fieldName','map','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','order','sort','pick','where','merge','type','VIRTUAL','filter','options','include','rows','catch','show','params','includeAll'];(function(_0x568496,_0x565afd){var _0x26c5c1=function(_0x4d251e){while(--_0x4d251e){_0x568496['push'](_0x568496['shift']());}};_0x26c5c1(++_0x565afd);}(_0xa603,0x1b8));var _0x3a60=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0xa603[_0x122ef9];return _0x42fba0;};'use strict';var emlformat=require(_0x3a60('0x0'));var rimraf=require(_0x3a60('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x3a60('0x2'));var rp=require(_0x3a60('0x3'));var moment=require('moment');var BPromise=require(_0x3a60('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0x3a60('0x5'));var sox=require('sox');var csv=require(_0x3a60('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x3a60('0x7'));var _=require(_0x3a60('0x8'));var squel=require(_0x3a60('0x9'));var crypto=require(_0x3a60('0xa'));var jsforce=require(_0x3a60('0xb'));var deskjs=require(_0x3a60('0xc'));var toCsv=require(_0x3a60('0x6'));var querystring=require(_0x3a60('0xd'));var Papa=require(_0x3a60('0xe'));var Redis=require('ioredis');var authService=require(_0x3a60('0xf'));var qs=require(_0x3a60('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x3a60('0x11'));var logger=require(_0x3a60('0x12'))('api');var utils=require(_0x3a60('0x13'));var config=require(_0x3a60('0x14'));var licenseUtil=require(_0x3a60('0x15'));var db=require(_0x3a60('0x16'))['db'];var integrations=require(_0x3a60('0x17'));function respondWithStatusCode(_0x127c65,_0x295928){_0x295928=_0x295928||0xcc;return function(_0x153749){if(_0x153749){return _0x127c65['sendStatus'](_0x295928);}return _0x127c65['status'](_0x295928)['end']();};}function respondWithResult(_0x40a6b2,_0x5872e0){_0x5872e0=_0x5872e0||0xc8;return function(_0x17f431){if(_0x17f431){return _0x40a6b2['status'](_0x5872e0)[_0x3a60('0x18')](_0x17f431);}};}function respondWithFilteredResult(_0x59c837,_0x41e552){return function(_0x9fee32){if(_0x9fee32){var _0x42f109=typeof _0x41e552[_0x3a60('0x19')]===_0x3a60('0x1a')&&typeof _0x41e552[_0x3a60('0x1b')]===_0x3a60('0x1a');var _0x4d16ab=_0x9fee32[_0x3a60('0x1c')];var _0x449414=_0x42f109?0x0:_0x41e552[_0x3a60('0x19')];var _0x340a2c=_0x42f109?_0x9fee32[_0x3a60('0x1c')]:_0x41e552[_0x3a60('0x19')]+_0x41e552[_0x3a60('0x1b')];var _0x2d6fc0;if(_0x340a2c>=_0x4d16ab){_0x340a2c=_0x4d16ab;_0x2d6fc0=0xc8;}else{_0x2d6fc0=0xce;}_0x59c837[_0x3a60('0x1d')](_0x2d6fc0);return _0x59c837[_0x3a60('0x1e')](_0x3a60('0x1f'),_0x449414+'-'+_0x340a2c+'/'+_0x4d16ab)[_0x3a60('0x18')](_0x9fee32);}return null;};}function patchUpdates(_0xe03b75){return function(_0x520ecb){try{jsonpatch[_0x3a60('0x20')](_0x520ecb,_0xe03b75,!![]);}catch(_0x52331c){return BPromise[_0x3a60('0x21')](_0x52331c);}return _0x520ecb[_0x3a60('0x22')]();};}function saveUpdates(_0x3e3769,_0xda257d){return function(_0x4a8ca4){if(_0x4a8ca4){return _0x4a8ca4[_0x3a60('0x23')](_0x3e3769)['then'](function(_0x5916ec){return _0x5916ec;});}return null;};}function removeEntity(_0x588b71,_0x1d769e){return function(_0x207631){if(_0x207631){return _0x207631['destroy']()[_0x3a60('0x24')](function(){_0x588b71[_0x3a60('0x1d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x55818a,_0x123fe5){return function(_0xa24211){if(!_0xa24211){_0x55818a['sendStatus'](0x194);}return _0xa24211;};}function handleError(_0x19fa27,_0x20a9dd){_0x20a9dd=_0x20a9dd||0x1f4;return function(_0x217b5d){logger[_0x3a60('0x25')](_0x217b5d[_0x3a60('0x26')]);if(_0x217b5d[_0x3a60('0x27')]){delete _0x217b5d[_0x3a60('0x27')];}_0x19fa27[_0x3a60('0x1d')](_0x20a9dd)['send'](_0x217b5d);};}exports[_0x3a60('0x28')]=function(_0x321e23,_0x4e0de0){var _0x5e6eec={},_0x3fc365={},_0x176f35={'count':0x0,'rows':[]};var _0x5c455c=_['map'](db[_0x3a60('0x29')]['rawAttributes'],function(_0x1057a){return{'name':_0x1057a[_0x3a60('0x2a')],'type':_0x1057a['type']['key']};});_0x3fc365['model']=_[_0x3a60('0x2b')](_0x5c455c,_0x3a60('0x27'));_0x3fc365[_0x3a60('0x2c')]=_[_0x3a60('0x2d')](_0x321e23[_0x3a60('0x2c')]);_0x3fc365[_0x3a60('0x2e')]=_[_0x3a60('0x2f')](_0x3fc365[_0x3a60('0x30')],_0x3fc365['query']);_0x5e6eec['attributes']=_[_0x3a60('0x2f')](_0x3fc365[_0x3a60('0x30')],qs['fields'](_0x321e23[_0x3a60('0x2c')][_0x3a60('0x31')]));_0x5e6eec['attributes']=_0x5e6eec[_0x3a60('0x32')][_0x3a60('0x33')]?_0x5e6eec[_0x3a60('0x32')]:_0x3fc365[_0x3a60('0x30')];if(!_0x321e23['query'][_0x3a60('0x34')]('nolimit')){_0x5e6eec['limit']=qs['limit'](_0x321e23[_0x3a60('0x2c')][_0x3a60('0x1b')]);_0x5e6eec[_0x3a60('0x19')]=qs[_0x3a60('0x19')](_0x321e23[_0x3a60('0x2c')][_0x3a60('0x19')]);}_0x5e6eec[_0x3a60('0x35')]=qs[_0x3a60('0x36')](_0x321e23['query'][_0x3a60('0x36')]);_0x5e6eec['where']=qs[_0x3a60('0x2e')](_[_0x3a60('0x37')](_0x321e23[_0x3a60('0x2c')],_0x3fc365[_0x3a60('0x2e')]),_0x5c455c);if(_0x321e23[_0x3a60('0x2c')]['filter']){_0x5e6eec[_0x3a60('0x38')]=_[_0x3a60('0x39')](_0x5e6eec[_0x3a60('0x38')],{'$or':_['map'](_0x5c455c,function(_0x31ea0c){if(_0x31ea0c[_0x3a60('0x3a')]!==_0x3a60('0x3b')){var _0x1184b0={};_0x1184b0[_0x31ea0c[_0x3a60('0x27')]]={'$like':'%'+_0x321e23[_0x3a60('0x2c')][_0x3a60('0x3c')]+'%'};return _0x1184b0;}})});}_0x5e6eec=_[_0x3a60('0x39')]({},_0x5e6eec,_0x321e23[_0x3a60('0x3d')]);var _0x1bd911={'where':_0x5e6eec[_0x3a60('0x38')]};return db[_0x3a60('0x29')]['count'](_0x1bd911)[_0x3a60('0x24')](function(_0x3ab002){_0x176f35[_0x3a60('0x1c')]=_0x3ab002;if(_0x321e23[_0x3a60('0x2c')]['includeAll']){_0x5e6eec[_0x3a60('0x3e')]=[{'all':!![]}];}return db[_0x3a60('0x29')]['findAll'](_0x5e6eec);})[_0x3a60('0x24')](function(_0x8cba2c){_0x176f35[_0x3a60('0x3f')]=_0x8cba2c;return _0x176f35;})[_0x3a60('0x24')](respondWithFilteredResult(_0x4e0de0,_0x5e6eec))[_0x3a60('0x40')](handleError(_0x4e0de0,null));};exports[_0x3a60('0x41')]=function(_0x4a0ac2,_0x5694bf){var _0x582fed={'raw':![],'where':{'id':_0x4a0ac2[_0x3a60('0x42')]['id']}},_0x228da0={};_0x228da0[_0x3a60('0x30')]=_[_0x3a60('0x2d')](db[_0x3a60('0x29')]['rawAttributes']);_0x228da0[_0x3a60('0x2c')]=_[_0x3a60('0x2d')](_0x4a0ac2[_0x3a60('0x2c')]);_0x228da0[_0x3a60('0x2e')]=_['intersection'](_0x228da0[_0x3a60('0x30')],_0x228da0[_0x3a60('0x2c')]);_0x582fed['attributes']=_[_0x3a60('0x2f')](_0x228da0[_0x3a60('0x30')],qs[_0x3a60('0x31')](_0x4a0ac2[_0x3a60('0x2c')][_0x3a60('0x31')]));_0x582fed['attributes']=_0x582fed[_0x3a60('0x32')][_0x3a60('0x33')]?_0x582fed[_0x3a60('0x32')]:_0x228da0[_0x3a60('0x30')];if(_0x4a0ac2[_0x3a60('0x2c')][_0x3a60('0x43')]){_0x582fed[_0x3a60('0x3e')]=[{'all':!![]}];}_0x582fed=_['merge']({},_0x582fed,_0x4a0ac2['options']);return db[_0x3a60('0x29')][_0x3a60('0x44')](_0x582fed)['then'](handleEntityNotFound(_0x5694bf,null))[_0x3a60('0x24')](respondWithResult(_0x5694bf,null))[_0x3a60('0x40')](handleError(_0x5694bf,null));};exports[_0x3a60('0x45')]=function(_0x58269a,_0xbe2ff){return db[_0x3a60('0x29')][_0x3a60('0x45')](_0x58269a[_0x3a60('0x46')],{})[_0x3a60('0x24')](respondWithResult(_0xbe2ff,0xc9))[_0x3a60('0x40')](handleError(_0xbe2ff,null));};exports[_0x3a60('0x23')]=function(_0x22566f,_0x45bcd2){if(_0x22566f[_0x3a60('0x46')]['id']){delete _0x22566f[_0x3a60('0x46')]['id'];}return db['ZohoAccount']['find']({'where':{'id':_0x22566f[_0x3a60('0x42')]['id']}})[_0x3a60('0x24')](handleEntityNotFound(_0x45bcd2,null))[_0x3a60('0x24')](saveUpdates(_0x22566f[_0x3a60('0x46')],null))[_0x3a60('0x24')](respondWithResult(_0x45bcd2,null))['catch'](handleError(_0x45bcd2,null));};exports[_0x3a60('0x47')]=function(_0x1bef44,_0x48dec9){return db[_0x3a60('0x29')][_0x3a60('0x44')]({'where':{'id':_0x1bef44['params']['id']}})['then'](handleEntityNotFound(_0x48dec9,null))[_0x3a60('0x24')](removeEntity(_0x48dec9,null))[_0x3a60('0x40')](handleError(_0x48dec9,null));};exports[_0x3a60('0x48')]=function(_0x210eca,_0x4aa9c8,_0x2cae9e){var _0xbcbbdf={};var _0x4869f1={};var _0x24a6cd;var _0x135381;return db[_0x3a60('0x29')][_0x3a60('0x49')]({'where':{'id':_0x210eca[_0x3a60('0x42')]['id']}})[_0x3a60('0x24')](handleEntityNotFound(_0x4aa9c8,null))[_0x3a60('0x24')](function(_0x1d6f6c){if(_0x1d6f6c){_0x24a6cd=_0x1d6f6c;_0x4869f1[_0x3a60('0x30')]=_[_0x3a60('0x2d')](db['ZohoConfiguration'][_0x3a60('0x4a')]);_0x4869f1['query']=_['keys'](_0x210eca[_0x3a60('0x2c')]);_0x4869f1[_0x3a60('0x2e')]=_['intersection'](_0x4869f1[_0x3a60('0x30')],_0x4869f1[_0x3a60('0x2c')]);_0xbcbbdf['attributes']=_[_0x3a60('0x2f')](_0x4869f1[_0x3a60('0x30')],qs[_0x3a60('0x31')](_0x210eca['query'][_0x3a60('0x31')]));_0xbcbbdf[_0x3a60('0x32')]=_0xbcbbdf['attributes'][_0x3a60('0x33')]?_0xbcbbdf['attributes']:_0x4869f1[_0x3a60('0x30')];_0xbcbbdf[_0x3a60('0x35')]=qs[_0x3a60('0x36')](_0x210eca['query'][_0x3a60('0x36')]);_0xbcbbdf[_0x3a60('0x38')]=qs[_0x3a60('0x2e')](_['pick'](_0x210eca[_0x3a60('0x2c')],_0x4869f1[_0x3a60('0x2e')]));if(_0x210eca[_0x3a60('0x2c')][_0x3a60('0x3c')]){_0xbcbbdf[_0x3a60('0x38')]=_[_0x3a60('0x39')](_0xbcbbdf[_0x3a60('0x38')],{'$or':_[_0x3a60('0x2b')](_0xbcbbdf[_0x3a60('0x32')],function(_0xfc7513){var _0x374385={};_0x374385[_0xfc7513]={'$like':'%'+_0x210eca[_0x3a60('0x2c')][_0x3a60('0x3c')]+'%'};return _0x374385;})});}_0xbcbbdf=_[_0x3a60('0x39')]({},_0xbcbbdf,_0x210eca['options']);return _0x24a6cd[_0x3a60('0x48')](_0xbcbbdf);}})[_0x3a60('0x24')](function(_0x41e9d6){if(_0x41e9d6){_0x135381=_0x41e9d6['length'];if(!_0x210eca[_0x3a60('0x2c')][_0x3a60('0x34')](_0x3a60('0x4b'))){_0xbcbbdf[_0x3a60('0x1b')]=qs[_0x3a60('0x1b')](_0x210eca[_0x3a60('0x2c')][_0x3a60('0x1b')]);_0xbcbbdf[_0x3a60('0x19')]=qs[_0x3a60('0x19')](_0x210eca[_0x3a60('0x2c')]['offset']);}return _0x24a6cd[_0x3a60('0x48')](_0xbcbbdf);}})[_0x3a60('0x24')](function(_0xce9c2f){if(_0xce9c2f){return _0xce9c2f?{'count':_0x135381,'rows':_0xce9c2f}:null;}})[_0x3a60('0x24')](respondWithResult(_0x4aa9c8,null))['catch'](handleError(_0x4aa9c8,null));};exports[_0x3a60('0x4c')]=function(_0x563087,_0x2bfdea,_0x36c2a5){if(_0x563087[_0x3a60('0x46')]['id']){delete _0x563087[_0x3a60('0x46')]['id'];}return db[_0x3a60('0x29')][_0x3a60('0x49')]({'where':{'id':_0x563087[_0x3a60('0x42')]['id']}})[_0x3a60('0x24')](handleEntityNotFound(_0x2bfdea,null))[_0x3a60('0x24')](function(_0x23e49b){if(_0x23e49b){_0x563087[_0x3a60('0x46')][_0x3a60('0x4d')]=_0x23e49b['id'];_0x563087[_0x3a60('0x46')][_0x3a60('0x4e')]=integrations[_0x3a60('0x4f')](_0x563087[_0x3a60('0x46')][_0x3a60('0x50')],_0x563087[_0x3a60('0x46')][_0x3a60('0x3a')]);_0x563087[_0x3a60('0x46')][_0x3a60('0x51')]=integrations[_0x3a60('0x52')](_0x563087[_0x3a60('0x46')]['channel'],_0x563087[_0x3a60('0x46')][_0x3a60('0x3a')]);return db['ZohoConfiguration'][_0x3a60('0x45')](_0x563087['body'],{'include':[{'model':db['ZohoField'],'as':'Subjects'},{'model':db[_0x3a60('0x53')],'as':'Descriptions'}]});}return null;})[_0x3a60('0x24')](respondWithResult(_0x2bfdea,null))['catch'](handleError(_0x2bfdea,null));};function getAccessToken(_0x71ee17){return new Promise(function(_0x2d2b75,_0x5f03ec){var _0x64a901;switch(_0x71ee17[_0x3a60('0x54')]){case'US':_0x64a901='https://accounts.zoho.com';break;case'AU':_0x64a901='https://accounts.zoho.com.au';break;case'EU':_0x64a901=_0x3a60('0x55');break;case'IN':_0x64a901='https://accounts.zoho.in';break;case'CN':_0x64a901=_0x3a60('0x56');break;default:_0x64a901=_0x3a60('0x55');break;}var _0x91acc5={'method':_0x3a60('0x57'),'uri':_0x64a901+'/oauth/v2/token','qs':{'refresh_token':_0x71ee17[_0x3a60('0x58')],'client_id':_0x71ee17[_0x3a60('0x59')],'client_secret':_0x71ee17[_0x3a60('0x5a')],'grant_type':_0x3a60('0x5b')},'json':!![]};return rp(_0x91acc5)[_0x3a60('0x24')](function(_0x18c44c){if(_0x18c44c[_0x3a60('0x5c')]){_0x2d2b75(_0x18c44c['access_token']);}else{_0x5f03ec(_0x3a60('0x5d'));}})['catch'](function(_0x3ad67e){_0x5f03ec(_0x3ad67e);});});}exports[_0x3a60('0x5e')]=function(_0x36654f,_0x56a49b,_0x5523d1){var _0x2b3c41,_0x2a9b1a,_0x138ad5,_0x3390fc,_0x4f03a6;return db[_0x3a60('0x29')][_0x3a60('0x49')]({'where':{'id':_0x36654f['params']['id']},'attributes':['id',_0x3a60('0x5f'),_0x3a60('0x54'),_0x3a60('0x59'),_0x3a60('0x5a'),_0x3a60('0x60'),_0x3a60('0x61'),_0x3a60('0x58')]})[_0x3a60('0x24')](handleEntityNotFound(_0x56a49b,null))['then'](function(_0x2c7209){_0x4f03a6=_0x2c7209;_0x2b3c41=_0x4f03a6['host'];_0x2a9b1a=_0x2b3c41===_0x3a60('0x62')?'eu':_0x3a60('0x63');_0x138ad5=_0x4f03a6['serverUrl'];var _0x538aa9=_0x138ad5[_0x3a60('0x64')](-0x1);if(_0x538aa9==='/'||_0x538aa9==='\x5c'||_0x538aa9===':'){_0x138ad5=_0x138ad5[_0x3a60('0x65')](0x0,_0x138ad5[_0x3a60('0x66')](_0x538aa9));}if(!_0x4f03a6[_0x3a60('0x58')]){throw new Error(_0x3a60('0x67'));}return getAccessToken(_0x4f03a6);})[_0x3a60('0x24')](function(_0x10f39c){if(_0x10f39c){return rp({'method':_0x3a60('0x68'),'uri':util[_0x3a60('0x69')](_0x3a60('0x6a'),_0x2a9b1a),'qs':{'module':'Calls'},'headers':{'Authorization':_0x3a60('0x6b')+_0x10f39c},'json':!![]});}})[_0x3a60('0x24')](function(_0x1f6525){if(_0x1f6525){if(_0x1f6525['response']&&_0x1f6525[_0x3a60('0x6c')][_0x3a60('0x25')]){throw new Error(_0x1f6525['response'][_0x3a60('0x25')]['message']);}var _0xceef8c=[];var _0x522d1d=[];var _0x50a150=[_0x3a60('0x6d'),_0x3a60('0x6e'),_0x3a60('0x6f'),_0x3a60('0x70'),_0x3a60('0x71'),_0x3a60('0x72'),_0x3a60('0x73'),'Call_Type'];_0x522d1d=_['remove'](_0x1f6525[_0x3a60('0x31')],function(_0x112d91){return _0x50a150[_0x3a60('0x74')](_0x112d91[_0x3a60('0x75')]);});for(var _0x208b96=0x0;_0x208b96<_0x522d1d[_0x3a60('0x33')];_0x208b96++){if(_0x522d1d[_0x208b96]['system_mandatory']===![]){_0xceef8c[_0x3a60('0x76')]({'id':_0x522d1d[_0x208b96]['id'],'name':_0x522d1d[_0x208b96][_0x3a60('0x77')],'custom':_0x522d1d[_0x208b96]['custom_field'],'options':_0x522d1d[_0x208b96]['data_type']===_0x3a60('0x78')&&_0x522d1d[_0x208b96][_0x3a60('0x79')][_0x3a60('0x33')]>-0x1?_[_0x3a60('0x2b')](_0x522d1d[_0x208b96][_0x3a60('0x79')],function(_0x257b54){return{'name':_0x257b54,'value':_0x257b54};}):[]});}}return{'count':_0xceef8c[_0x3a60('0x33')],'rows':_0xceef8c};}else{return{'count':0x0,'rows':[]};}})[_0x3a60('0x24')](respondWithResult(_0x56a49b,null))['catch'](function(_0x18e75c){var _0x521c43=_0x36654f[_0x3a60('0x2c')]['test']?0x1f4:_0x18e75c['statusCode']||0x1f4;logger[_0x3a60('0x25')](_0x3a60('0x7a'),_0x3a60('0x5e'),_0x521c43,JSON['stringify'](_0x18e75c));delete _0x18e75c[_0x3a60('0x27')];if(_0x521c43===0x191){_0x521c43=0x190;}_0x56a49b[_0x3a60('0x1d')](_0x521c43)[_0x3a60('0x7b')](_0x36654f[_0x3a60('0x2c')][_0x3a60('0x7c')]?{'message':_0x3a60('0x7d'),'statusCode':_0x18e75c[_0x3a60('0x7e')]}:_0x18e75c);});};
\ No newline at end of file
+var _0xf605=['/oauth/v2/token','refreshToken','clientId','refresh_token','access_token','Unable\x20to\x20retrieve\x20the\x20access\x20token','getFields','host','clientSecret','code','zoho.eu','com','serverUrl','substring','lastIndexOf','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','GET','format','https://www.zohoapis.%s/crm/v2/settings/fields','Calls','Zoho-oauthtoken\x20','response','message','Description','WhoId','Call_Result','Call_Start_Time','Call_Type','includes','api_name','push','display_label','custom_field','picklist','pick_list_values','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','then','sendStatus','error','name','send','map','ZohoAccount','rawAttributes','fieldName','type','key','model','query','filters','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','options','include','findAll','rows','catch','keys','intersection','includeAll','find','create','update','body','params','destroy','findOne','filter','getConfigurations','addConfiguration','AccountId','Subjects','channel','Descriptions','getDescriptions','zone','https://accounts.zoho.com','https://accounts.zoho.in','POST'];(function(_0x248edc,_0x272d7c){var _0x26a30d=function(_0x14c96b){while(--_0x14c96b){_0x248edc['push'](_0x248edc['shift']());}};_0x26a30d(++_0x272d7c);}(_0xf605,0x129));var _0x5f60=function(_0x149c1f,_0x7b4dc6){_0x149c1f=_0x149c1f-0x0;var _0x309eeb=_0xf605[_0x149c1f];return _0x309eeb;};'use strict';var emlformat=require(_0x5f60('0x0'));var rimraf=require(_0x5f60('0x1'));var zipdir=require(_0x5f60('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5f60('0x3'));var moment=require('moment');var BPromise=require(_0x5f60('0x4'));var Mustache=require(_0x5f60('0x5'));var util=require(_0x5f60('0x6'));var path=require(_0x5f60('0x7'));var sox=require(_0x5f60('0x8'));var csv=require(_0x5f60('0x9'));var ejs=require(_0x5f60('0xa'));var fs=require('fs');var fs_extra=require(_0x5f60('0xb'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x5f60('0xc'));var jsforce=require(_0x5f60('0xd'));var deskjs=require(_0x5f60('0xe'));var toCsv=require(_0x5f60('0x9'));var querystring=require(_0x5f60('0xf'));var Papa=require(_0x5f60('0x10'));var Redis=require(_0x5f60('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x5f60('0x12'));var as=require(_0x5f60('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x5f60('0x14'))(_0x5f60('0x15'));var utils=require(_0x5f60('0x16'));var config=require(_0x5f60('0x17'));var licenseUtil=require(_0x5f60('0x18'));var db=require(_0x5f60('0x19'))['db'];var integrations=require(_0x5f60('0x1a'));function respondWithStatusCode(_0x172777,_0x31b7a7){_0x31b7a7=_0x31b7a7||0xcc;return function(_0x526ab4){if(_0x526ab4){return _0x172777['sendStatus'](_0x31b7a7);}return _0x172777[_0x5f60('0x1b')](_0x31b7a7)[_0x5f60('0x1c')]();};}function respondWithResult(_0x20f95b,_0x3bde11){_0x3bde11=_0x3bde11||0xc8;return function(_0x28f532){if(_0x28f532){return _0x20f95b['status'](_0x3bde11)[_0x5f60('0x1d')](_0x28f532);}};}function respondWithFilteredResult(_0x1ac5ad,_0x3fb4e6){return function(_0x2ffc59){if(_0x2ffc59){var _0x12171c=typeof _0x3fb4e6[_0x5f60('0x1e')]===_0x5f60('0x1f')&&typeof _0x3fb4e6[_0x5f60('0x20')]==='undefined';var _0x18f450=_0x2ffc59[_0x5f60('0x21')];var _0x31685d=_0x12171c?0x0:_0x3fb4e6[_0x5f60('0x1e')];var _0x2c3359=_0x12171c?_0x2ffc59['count']:_0x3fb4e6[_0x5f60('0x1e')]+_0x3fb4e6[_0x5f60('0x20')];var _0x26a9c1;if(_0x2c3359>=_0x18f450){_0x2c3359=_0x18f450;_0x26a9c1=0xc8;}else{_0x26a9c1=0xce;}_0x1ac5ad['status'](_0x26a9c1);return _0x1ac5ad['set'](_0x5f60('0x22'),_0x31685d+'-'+_0x2c3359+'/'+_0x18f450)[_0x5f60('0x1d')](_0x2ffc59);}return null;};}function patchUpdates(_0x3c5533){return function(_0x2751a8){try{jsonpatch[_0x5f60('0x23')](_0x2751a8,_0x3c5533,!![]);}catch(_0x163bab){return BPromise[_0x5f60('0x24')](_0x163bab);}return _0x2751a8[_0x5f60('0x25')]();};}function saveUpdates(_0x12c11c,_0x4bb345){return function(_0x517f72){if(_0x517f72){return _0x517f72['update'](_0x12c11c)[_0x5f60('0x26')](function(_0x4c1efc){return _0x4c1efc;});}return null;};}function removeEntity(_0x38f277,_0x53e768){return function(_0x287cad){if(_0x287cad){return _0x287cad['destroy']()[_0x5f60('0x26')](function(){_0x38f277['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x5a512f,_0x282eb3){return function(_0x250b35){if(!_0x250b35){_0x5a512f[_0x5f60('0x27')](0x194);}return _0x250b35;};}function handleError(_0x512e5f,_0x3a09ef){_0x3a09ef=_0x3a09ef||0x1f4;return function(_0x29c663){logger[_0x5f60('0x28')](_0x29c663['stack']);if(_0x29c663['name']){delete _0x29c663[_0x5f60('0x29')];}_0x512e5f['status'](_0x3a09ef)[_0x5f60('0x2a')](_0x29c663);};}exports['index']=function(_0x10eefa,_0x512fd7){var _0x534d9b={},_0x2710db={},_0x2ea395={'count':0x0,'rows':[]};var _0x556c8a=_[_0x5f60('0x2b')](db[_0x5f60('0x2c')][_0x5f60('0x2d')],function(_0x5a0982){return{'name':_0x5a0982[_0x5f60('0x2e')],'type':_0x5a0982[_0x5f60('0x2f')][_0x5f60('0x30')]};});_0x2710db[_0x5f60('0x31')]=_[_0x5f60('0x2b')](_0x556c8a,_0x5f60('0x29'));_0x2710db[_0x5f60('0x32')]=_['keys'](_0x10eefa['query']);_0x2710db[_0x5f60('0x33')]=_['intersection'](_0x2710db[_0x5f60('0x31')],_0x2710db[_0x5f60('0x32')]);_0x534d9b[_0x5f60('0x34')]=_['intersection'](_0x2710db[_0x5f60('0x31')],qs[_0x5f60('0x35')](_0x10eefa['query'][_0x5f60('0x35')]));_0x534d9b['attributes']=_0x534d9b[_0x5f60('0x34')][_0x5f60('0x36')]?_0x534d9b[_0x5f60('0x34')]:_0x2710db[_0x5f60('0x31')];if(!_0x10eefa[_0x5f60('0x32')][_0x5f60('0x37')](_0x5f60('0x38'))){_0x534d9b[_0x5f60('0x20')]=qs[_0x5f60('0x20')](_0x10eefa[_0x5f60('0x32')][_0x5f60('0x20')]);_0x534d9b[_0x5f60('0x1e')]=qs['offset'](_0x10eefa[_0x5f60('0x32')][_0x5f60('0x1e')]);}_0x534d9b[_0x5f60('0x39')]=qs[_0x5f60('0x3a')](_0x10eefa[_0x5f60('0x32')][_0x5f60('0x3a')]);_0x534d9b[_0x5f60('0x3b')]=qs[_0x5f60('0x33')](_[_0x5f60('0x3c')](_0x10eefa[_0x5f60('0x32')],_0x2710db[_0x5f60('0x33')]),_0x556c8a);if(_0x10eefa[_0x5f60('0x32')]['filter']){_0x534d9b['where']=_[_0x5f60('0x3d')](_0x534d9b['where'],{'$or':_['map'](_0x556c8a,function(_0x943dc0){if(_0x943dc0[_0x5f60('0x2f')]!==_0x5f60('0x3e')){var _0x18a1be={};_0x18a1be[_0x943dc0[_0x5f60('0x29')]]={'$like':'%'+_0x10eefa[_0x5f60('0x32')]['filter']+'%'};return _0x18a1be;}})});}_0x534d9b=_['merge']({},_0x534d9b,_0x10eefa[_0x5f60('0x3f')]);var _0x4d4a05={'where':_0x534d9b['where']};return db['ZohoAccount'][_0x5f60('0x21')](_0x4d4a05)[_0x5f60('0x26')](function(_0x3ac787){_0x2ea395[_0x5f60('0x21')]=_0x3ac787;if(_0x10eefa[_0x5f60('0x32')]['includeAll']){_0x534d9b[_0x5f60('0x40')]=[{'all':!![]}];}return db[_0x5f60('0x2c')][_0x5f60('0x41')](_0x534d9b);})[_0x5f60('0x26')](function(_0x52e526){_0x2ea395[_0x5f60('0x42')]=_0x52e526;return _0x2ea395;})[_0x5f60('0x26')](respondWithFilteredResult(_0x512fd7,_0x534d9b))[_0x5f60('0x43')](handleError(_0x512fd7,null));};exports['show']=function(_0x1afbf9,_0x30d60e){var _0x8f129d={'raw':![],'where':{'id':_0x1afbf9['params']['id']}},_0x3b8fad={};_0x3b8fad['model']=_['keys'](db['ZohoAccount'][_0x5f60('0x2d')]);_0x3b8fad[_0x5f60('0x32')]=_[_0x5f60('0x44')](_0x1afbf9[_0x5f60('0x32')]);_0x3b8fad[_0x5f60('0x33')]=_[_0x5f60('0x45')](_0x3b8fad[_0x5f60('0x31')],_0x3b8fad[_0x5f60('0x32')]);_0x8f129d[_0x5f60('0x34')]=_[_0x5f60('0x45')](_0x3b8fad[_0x5f60('0x31')],qs['fields'](_0x1afbf9['query']['fields']));_0x8f129d[_0x5f60('0x34')]=_0x8f129d[_0x5f60('0x34')][_0x5f60('0x36')]?_0x8f129d[_0x5f60('0x34')]:_0x3b8fad[_0x5f60('0x31')];if(_0x1afbf9[_0x5f60('0x32')][_0x5f60('0x46')]){_0x8f129d[_0x5f60('0x40')]=[{'all':!![]}];}_0x8f129d=_[_0x5f60('0x3d')]({},_0x8f129d,_0x1afbf9[_0x5f60('0x3f')]);return db[_0x5f60('0x2c')][_0x5f60('0x47')](_0x8f129d)['then'](handleEntityNotFound(_0x30d60e,null))[_0x5f60('0x26')](respondWithResult(_0x30d60e,null))['catch'](handleError(_0x30d60e,null));};exports[_0x5f60('0x48')]=function(_0x31ab74,_0x55fbb0){return db['ZohoAccount'][_0x5f60('0x48')](_0x31ab74['body'],{})['then'](respondWithResult(_0x55fbb0,0xc9))[_0x5f60('0x43')](handleError(_0x55fbb0,null));};exports[_0x5f60('0x49')]=function(_0x385f69,_0x5ab68a){if(_0x385f69[_0x5f60('0x4a')]['id']){delete _0x385f69[_0x5f60('0x4a')]['id'];}return db[_0x5f60('0x2c')][_0x5f60('0x47')]({'where':{'id':_0x385f69[_0x5f60('0x4b')]['id']}})['then'](handleEntityNotFound(_0x5ab68a,null))[_0x5f60('0x26')](saveUpdates(_0x385f69[_0x5f60('0x4a')],null))['then'](respondWithResult(_0x5ab68a,null))[_0x5f60('0x43')](handleError(_0x5ab68a,null));};exports[_0x5f60('0x4c')]=function(_0x131e65,_0x4b502b){return db['ZohoAccount'][_0x5f60('0x47')]({'where':{'id':_0x131e65['params']['id']}})['then'](handleEntityNotFound(_0x4b502b,null))['then'](removeEntity(_0x4b502b,null))[_0x5f60('0x43')](handleError(_0x4b502b,null));};exports['getConfigurations']=function(_0x3ff869,_0x14a856,_0x2f1e31){var _0x30c5c7={};var _0x22d67f={};var _0x490c52;var _0x10fd23;return db['ZohoAccount'][_0x5f60('0x4d')]({'where':{'id':_0x3ff869[_0x5f60('0x4b')]['id']}})[_0x5f60('0x26')](handleEntityNotFound(_0x14a856,null))[_0x5f60('0x26')](function(_0x53fe8a){if(_0x53fe8a){_0x490c52=_0x53fe8a;_0x22d67f[_0x5f60('0x31')]=_[_0x5f60('0x44')](db['ZohoConfiguration'][_0x5f60('0x2d')]);_0x22d67f['query']=_[_0x5f60('0x44')](_0x3ff869[_0x5f60('0x32')]);_0x22d67f[_0x5f60('0x33')]=_[_0x5f60('0x45')](_0x22d67f[_0x5f60('0x31')],_0x22d67f[_0x5f60('0x32')]);_0x30c5c7[_0x5f60('0x34')]=_[_0x5f60('0x45')](_0x22d67f[_0x5f60('0x31')],qs[_0x5f60('0x35')](_0x3ff869[_0x5f60('0x32')][_0x5f60('0x35')]));_0x30c5c7[_0x5f60('0x34')]=_0x30c5c7[_0x5f60('0x34')][_0x5f60('0x36')]?_0x30c5c7[_0x5f60('0x34')]:_0x22d67f[_0x5f60('0x31')];_0x30c5c7[_0x5f60('0x39')]=qs[_0x5f60('0x3a')](_0x3ff869['query']['sort']);_0x30c5c7[_0x5f60('0x3b')]=qs['filters'](_[_0x5f60('0x3c')](_0x3ff869[_0x5f60('0x32')],_0x22d67f['filters']));if(_0x3ff869['query']['filter']){_0x30c5c7['where']=_[_0x5f60('0x3d')](_0x30c5c7['where'],{'$or':_[_0x5f60('0x2b')](_0x30c5c7['attributes'],function(_0x478d7c){var _0x2b35da={};_0x2b35da[_0x478d7c]={'$like':'%'+_0x3ff869[_0x5f60('0x32')][_0x5f60('0x4e')]+'%'};return _0x2b35da;})});}_0x30c5c7=_[_0x5f60('0x3d')]({},_0x30c5c7,_0x3ff869[_0x5f60('0x3f')]);return _0x490c52[_0x5f60('0x4f')](_0x30c5c7);}})[_0x5f60('0x26')](function(_0xdbac41){if(_0xdbac41){_0x10fd23=_0xdbac41[_0x5f60('0x36')];if(!_0x3ff869[_0x5f60('0x32')][_0x5f60('0x37')](_0x5f60('0x38'))){_0x30c5c7['limit']=qs[_0x5f60('0x20')](_0x3ff869['query'][_0x5f60('0x20')]);_0x30c5c7[_0x5f60('0x1e')]=qs[_0x5f60('0x1e')](_0x3ff869[_0x5f60('0x32')][_0x5f60('0x1e')]);}return _0x490c52[_0x5f60('0x4f')](_0x30c5c7);}})['then'](function(_0x268d0c){if(_0x268d0c){return _0x268d0c?{'count':_0x10fd23,'rows':_0x268d0c}:null;}})[_0x5f60('0x26')](respondWithResult(_0x14a856,null))[_0x5f60('0x43')](handleError(_0x14a856,null));};exports[_0x5f60('0x50')]=function(_0x7d223d,_0x48cdf8,_0x1fe5e9){if(_0x7d223d[_0x5f60('0x4a')]['id']){delete _0x7d223d[_0x5f60('0x4a')]['id'];}return db[_0x5f60('0x2c')][_0x5f60('0x4d')]({'where':{'id':_0x7d223d[_0x5f60('0x4b')]['id']}})[_0x5f60('0x26')](handleEntityNotFound(_0x48cdf8,null))[_0x5f60('0x26')](function(_0x2bb31c){if(_0x2bb31c){_0x7d223d[_0x5f60('0x4a')][_0x5f60('0x51')]=_0x2bb31c['id'];_0x7d223d[_0x5f60('0x4a')][_0x5f60('0x52')]=integrations['getSubjects'](_0x7d223d[_0x5f60('0x4a')][_0x5f60('0x53')],_0x7d223d['body'][_0x5f60('0x2f')]);_0x7d223d[_0x5f60('0x4a')][_0x5f60('0x54')]=integrations[_0x5f60('0x55')](_0x7d223d[_0x5f60('0x4a')]['channel'],_0x7d223d[_0x5f60('0x4a')][_0x5f60('0x2f')]);return db['ZohoConfiguration'][_0x5f60('0x48')](_0x7d223d[_0x5f60('0x4a')],{'include':[{'model':db['ZohoField'],'as':_0x5f60('0x52')},{'model':db['ZohoField'],'as':_0x5f60('0x54')}]});}return null;})[_0x5f60('0x26')](respondWithResult(_0x48cdf8,null))[_0x5f60('0x43')](handleError(_0x48cdf8,null));};function getAccessToken(_0x2d14ea){return new Promise(function(_0x27940c,_0x44f198){var _0x449c2f;switch(_0x2d14ea[_0x5f60('0x56')]){case'US':_0x449c2f=_0x5f60('0x57');break;case'AU':_0x449c2f='https://accounts.zoho.com.au';break;case'EU':_0x449c2f='https://accounts.zoho.eu';break;case'IN':_0x449c2f=_0x5f60('0x58');break;case'CN':_0x449c2f='https://accounts.zoho.com.cn';break;default:_0x449c2f='https://accounts.zoho.eu';break;}var _0x4e7062={'method':_0x5f60('0x59'),'uri':_0x449c2f+_0x5f60('0x5a'),'qs':{'refresh_token':_0x2d14ea[_0x5f60('0x5b')],'client_id':_0x2d14ea[_0x5f60('0x5c')],'client_secret':_0x2d14ea['clientSecret'],'grant_type':_0x5f60('0x5d')},'json':!![]};return rp(_0x4e7062)['then'](function(_0x52b036){if(_0x52b036['access_token']){_0x27940c(_0x52b036[_0x5f60('0x5e')]);}else{_0x44f198(_0x5f60('0x5f'));}})[_0x5f60('0x43')](function(_0x38a282){_0x44f198(_0x38a282);});});}exports[_0x5f60('0x60')]=function(_0x2c9d4e,_0xd2d805,_0x14b8ac){var _0x418c10,_0x35a7b5,_0x1c635b,_0x4dd3eb,_0x23adac;return db[_0x5f60('0x2c')][_0x5f60('0x4d')]({'where':{'id':_0x2c9d4e[_0x5f60('0x4b')]['id']},'attributes':['id',_0x5f60('0x61'),_0x5f60('0x56'),_0x5f60('0x5c'),_0x5f60('0x62'),'serverUrl',_0x5f60('0x63'),_0x5f60('0x5b')]})[_0x5f60('0x26')](handleEntityNotFound(_0xd2d805,null))['then'](function(_0x5bea00){_0x23adac=_0x5bea00;_0x418c10=_0x23adac[_0x5f60('0x61')];_0x35a7b5=_0x418c10===_0x5f60('0x64')?'eu':_0x5f60('0x65');_0x1c635b=_0x23adac[_0x5f60('0x66')];var _0x3ed1e6=_0x1c635b['slice'](-0x1);if(_0x3ed1e6==='/'||_0x3ed1e6==='\x5c'||_0x3ed1e6===':'){_0x1c635b=_0x1c635b[_0x5f60('0x67')](0x0,_0x1c635b[_0x5f60('0x68')](_0x3ed1e6));}if(!_0x23adac['refreshToken']){throw new Error(_0x5f60('0x69'));}return getAccessToken(_0x23adac);})[_0x5f60('0x26')](function(_0x123146){if(_0x123146){return rp({'method':_0x5f60('0x6a'),'uri':util[_0x5f60('0x6b')](_0x5f60('0x6c'),_0x35a7b5),'qs':{'module':_0x5f60('0x6d')},'headers':{'Authorization':_0x5f60('0x6e')+_0x123146},'json':!![]});}})[_0x5f60('0x26')](function(_0x30d3bc){if(_0x30d3bc){if(_0x30d3bc[_0x5f60('0x6f')]&&_0x30d3bc['response'][_0x5f60('0x28')]){throw new Error(_0x30d3bc['response'][_0x5f60('0x28')][_0x5f60('0x70')]);}var _0x48d585=[];var _0x59293f=[];var _0x5674ce=['Owner','Subject',_0x5f60('0x71'),_0x5f60('0x72'),'Call_Duration',_0x5f60('0x73'),_0x5f60('0x74'),_0x5f60('0x75')];_0x59293f=_['remove'](_0x30d3bc[_0x5f60('0x35')],function(_0x1493d6){return _0x5674ce[_0x5f60('0x76')](_0x1493d6[_0x5f60('0x77')]);});for(var _0x29978c=0x0;_0x29978c<_0x59293f[_0x5f60('0x36')];_0x29978c++){if(_0x59293f[_0x29978c]['system_mandatory']===![]){_0x48d585[_0x5f60('0x78')]({'id':_0x59293f[_0x29978c]['id'],'name':_0x59293f[_0x29978c][_0x5f60('0x79')],'custom':_0x59293f[_0x29978c][_0x5f60('0x7a')],'options':_0x59293f[_0x29978c]['data_type']===_0x5f60('0x7b')&&_0x59293f[_0x29978c][_0x5f60('0x7c')]['length']>-0x1?_[_0x5f60('0x2b')](_0x59293f[_0x29978c][_0x5f60('0x7c')],function(_0x1d4a3b){return{'name':_0x1d4a3b,'value':_0x1d4a3b};}):[]});}}return{'count':_0x48d585[_0x5f60('0x36')],'rows':_0x48d585};}else{return{'count':0x0,'rows':[]};}})[_0x5f60('0x26')](respondWithResult(_0xd2d805,null))[_0x5f60('0x43')](function(_0x27928e){var _0x335155=_0x2c9d4e[_0x5f60('0x32')]['test']?0x1f4:_0x27928e[_0x5f60('0x7d')]||0x1f4;logger[_0x5f60('0x28')](_0x5f60('0x7e'),_0x5f60('0x60'),_0x335155,JSON[_0x5f60('0x7f')](_0x27928e));delete _0x27928e[_0x5f60('0x29')];if(_0x335155===0x191){_0x335155=0x190;}_0xd2d805[_0x5f60('0x1b')](_0x335155)[_0x5f60('0x2a')](_0x2c9d4e[_0x5f60('0x32')]['test']?{'message':_0x5f60('0x80'),'statusCode':_0x27928e[_0x5f60('0x7d')]}:_0x27928e);});};
\ No newline at end of file