Built motion from commit f861bcb808219e66da88ba48b61bddb35224a65e. Version 3.0.0...
[motion-next.git] / server / api / intZohoAccount / intZohoAccount.controller.js
index 6a01b53..fe32a1b 100644 (file)
@@ -1 +1 @@
-'use strict';const a416_0x43ec=['lastIndexOf','Content-Range','merge','480587jVZtKt','response','31yeCKnB','114469sMtKED','map','pick_list_values','findOne','663373syChfa','system_mandatory','status','error','getFields','format','create','@components/parsers/qs','getDescriptions','clientId','update','order','custom_field','/oauth/v2/token','set','catch','nolimit','6359UdmoMM','getFields,\x20%s,\x20%s,\x20%s','refresh_token','request-promise-native','count','attributes','https://accounts.zoho.com.au','addConfiguration','@utils/filter-attributes','@components/integrations/configuration','findAll','filter','ZohoConfiguration','getConfigurations','450721UBhJDl','keys','then','Calls','host','substring','statusCode','model','length','where','Subject','Descriptions','offset','@config/logger','https://www.zohoapis.%s/crm/v2/settings/fields','Zoho-oauthtoken\x20','send','rawAttributes','util','Call_Result','params','show','channel','includeAll','key','limit','api_name','intersection','picklist','Owner','query','options','display_label','ZohoAccount','Description','json','type','3KMIXoz','stringify','fieldName','GET','Call_Duration','data_type','remove','body','zoho.eu','destroy','1JrfGth','name','refreshToken','slice','ZohoField','Refresh\x20Token\x20not\x20available\x20for\x20the\x20account','rows','@mysqldb','lodash','fields','test','810890MCUyoi','POST','AccountId','WhoId','Subjects','end','message','include','1113065fVndKZ','Unable\x20to\x20retrieve\x20the\x20access\x20token','sort','zone','clientSecret','access_token','https://accounts.zoho.eu','filters','serverUrl','2TnDYZf','stack'];const a416_0x480b=function(_0x5af20d,_0x13d1db){_0x5af20d=_0x5af20d-0x74;let _0x43ec26=a416_0x43ec[_0x5af20d];return _0x43ec26;};const a416_0x4b667d=a416_0x480b;(function(_0xf7368f,_0xd8c813){const _0x2d626a=a416_0x480b;while(!![]){try{const _0x420810=parseInt(_0x2d626a(0xad))*-parseInt(_0x2d626a(0xc3))+parseInt(_0x2d626a(0xb2))*-parseInt(_0x2d626a(0x8a))+-parseInt(_0x2d626a(0xae))+parseInt(_0x2d626a(0x9d))+-parseInt(_0x2d626a(0xab))*-parseInt(_0x2d626a(0xa6))+parseInt(_0x2d626a(0x95))+-parseInt(_0x2d626a(0x80))*parseInt(_0x2d626a(0xd1));if(_0x420810===_0xd8c813)break;else _0xf7368f['push'](_0xf7368f['shift']());}catch(_0x31e57c){_0xf7368f['push'](_0xf7368f['shift']());}}}(a416_0x43ec,0x883ab));const rp=require(a416_0x4b667d(0xc6)),util=require(a416_0x4b667d(0xe3)),_=require(a416_0x4b667d(0x92)),qs=require(a416_0x4b667d(0xb9)),logger=require(a416_0x4b667d(0xde))('api'),{db}=require(a416_0x4b667d(0x91)),{filterAttributes}=require(a416_0x4b667d(0xcb)),integrations=require(a416_0x4b667d(0xcc));function respondWithResult(_0x2b955c,_0x369ac3){return _0x369ac3=_0x369ac3||0xc8,function(_0x5174bd){const _0x4f4850=a416_0x480b;if(_0x5174bd)return _0x2b955c[_0x4f4850(0xb4)](_0x369ac3)['json'](_0x5174bd);};}function respondWithFilteredResult(_0x2150ed,_0x20b45a){return function(_0x30b559){const _0x107f32=a416_0x480b;if(_0x30b559){const _0x1fb27f=_0x30b559[_0x107f32(0xc7)],_0x239433=_0x20b45a['offset'];let _0x593359=_0x20b45a['offset']+_0x20b45a[_0x107f32(0x74)],_0x54957a;return _0x593359>=_0x1fb27f?(_0x593359=_0x1fb27f,_0x54957a=0xc8):_0x54957a=0xce,_0x2150ed['status'](_0x54957a),_0x2150ed[_0x107f32(0xc0)](_0x107f32(0xa9),_0x239433+'-'+_0x593359+'/'+_0x1fb27f)[_0x107f32(0x7e)](_0x30b559);}return null;};}function saveUpdates(_0x94c01){return function(_0x572316){const _0xd196ba=a416_0x480b;if(_0x572316)return _0x572316[_0xd196ba(0xbc)](_0x94c01)[_0xd196ba(0xd3)](function(_0x3c9aa3){return _0x3c9aa3;});return null;};}function removeEntity(_0x4783fa){return function(_0x5015a8){const _0x28cea0=a416_0x480b;if(_0x5015a8)return _0x5015a8[_0x28cea0(0x89)]()[_0x28cea0(0xd3)](function(){const _0x41f269=_0x28cea0;_0x4783fa[_0x41f269(0xb4)](0xcc)[_0x41f269(0x9a)]();});};}function handleEntityNotFound(_0x102567){return function(_0x4d80a5){return!_0x4d80a5&&_0x102567['sendStatus'](0x194),_0x4d80a5;};}function handleError(_0x5a3791,_0x2beef5){return _0x2beef5=_0x2beef5||0x1f4,function(_0x4d4cd0){const _0x4f71e9=a416_0x480b;logger[_0x4f71e9(0xb5)](_0x4d4cd0[_0x4f71e9(0xa7)]),_0x4d4cd0[_0x4f71e9(0x8b)]&&delete _0x4d4cd0[_0x4f71e9(0x8b)],_0x5a3791[_0x4f71e9(0xb4)](_0x2beef5)[_0x4f71e9(0xe1)](_0x4d4cd0);};}exports['index']=function(_0xc1bfe,_0x451fa8){const _0x22835a=a416_0x4b667d;let _0x59a3f9={};const _0x5a4b5f={},_0x5209eb={'count':0x0,'rows':[]},_0x46b0e1=_['map'](db['ZohoAccount'][_0x22835a(0xe2)],function(_0x45e7cb){const _0x203db2=_0x22835a;return{'name':_0x45e7cb[_0x203db2(0x82)],'type':_0x45e7cb[_0x203db2(0x7f)][_0x203db2(0xe9)]};});_0x5a4b5f[_0x22835a(0xd8)]=_[_0x22835a(0xaf)](_0x46b0e1,'name'),_0x5a4b5f['query']=_['keys'](_0xc1bfe[_0x22835a(0x79)]),_0x5a4b5f[_0x22835a(0xa4)]=_[_0x22835a(0x76)](_0x5a4b5f[_0x22835a(0xd8)],_0x5a4b5f[_0x22835a(0x79)]),_0x59a3f9[_0x22835a(0xc8)]=_[_0x22835a(0x76)](_0x5a4b5f['model'],qs[_0x22835a(0x93)](_0xc1bfe['query']['fields'])),_0x59a3f9[_0x22835a(0xc8)]=_0x59a3f9['attributes']['length']?_0x59a3f9[_0x22835a(0xc8)]:_0x5a4b5f[_0x22835a(0xd8)];typeof _0xc1bfe[_0x22835a(0x79)][_0x22835a(0xc2)]==='undefined'&&(_0x59a3f9['limit']=qs[_0x22835a(0x74)](_0xc1bfe[_0x22835a(0x79)][_0x22835a(0x74)]),_0x59a3f9['offset']=qs[_0x22835a(0xdd)](_0xc1bfe[_0x22835a(0x79)][_0x22835a(0xdd)]));_0x59a3f9['order']=qs[_0x22835a(0x9f)](_0xc1bfe[_0x22835a(0x79)][_0x22835a(0x9f)]),_0x59a3f9['where']=qs[_0x22835a(0xa4)](_['pick'](_0xc1bfe[_0x22835a(0x79)],_0x5a4b5f[_0x22835a(0xa4)]),_0x46b0e1),_0x59a3f9=filterAttributes(_0x59a3f9,_0xc1bfe[_0x22835a(0x79)][_0x22835a(0xce)],_0x46b0e1,_0xc1bfe['options']);const _0xbb17a3={'where':_0x59a3f9[_0x22835a(0xda)]};return db[_0x22835a(0x7c)][_0x22835a(0xc7)](_0xbb17a3)['then'](function(_0x5704a4){const _0x249b4a=_0x22835a;return _0x5209eb[_0x249b4a(0xc7)]=_0x5704a4,_0xc1bfe[_0x249b4a(0x79)][_0x249b4a(0xe8)]&&(_0x59a3f9['include']=[{'all':!![]}]),db[_0x249b4a(0x7c)][_0x249b4a(0xcd)](_0x59a3f9);})[_0x22835a(0xd3)](function(_0x1916e5){const _0x34655d=_0x22835a;return _0x5209eb[_0x34655d(0x90)]=_0x1916e5,_0x5209eb;})[_0x22835a(0xd3)](respondWithFilteredResult(_0x451fa8,_0x59a3f9))[_0x22835a(0xc1)](handleError(_0x451fa8,null));},exports[a416_0x4b667d(0xe6)]=function(_0x294885,_0x259e7b){const _0x591933=a416_0x4b667d;let _0x15b2b8={'raw':![],'where':{'id':_0x294885['params']['id']}};const _0x216ede={};return _0x216ede[_0x591933(0xd8)]=_[_0x591933(0xd2)](db[_0x591933(0x7c)]['rawAttributes']),_0x216ede[_0x591933(0x79)]=_[_0x591933(0xd2)](_0x294885[_0x591933(0x79)]),_0x216ede[_0x591933(0xa4)]=_[_0x591933(0x76)](_0x216ede[_0x591933(0xd8)],_0x216ede['query']),_0x15b2b8[_0x591933(0xc8)]=_['intersection'](_0x216ede[_0x591933(0xd8)],qs[_0x591933(0x93)](_0x294885[_0x591933(0x79)]['fields'])),_0x15b2b8[_0x591933(0xc8)]=_0x15b2b8[_0x591933(0xc8)][_0x591933(0xd9)]?_0x15b2b8[_0x591933(0xc8)]:_0x216ede[_0x591933(0xd8)],_0x294885[_0x591933(0x79)][_0x591933(0xe8)]&&(_0x15b2b8[_0x591933(0x9c)]=[{'all':!![]}]),_0x15b2b8=_[_0x591933(0xaa)]({},_0x15b2b8,_0x294885['options']),db[_0x591933(0x7c)][_0x591933(0xb1)](_0x15b2b8)['then'](handleEntityNotFound(_0x259e7b,null))['then'](respondWithResult(_0x259e7b,null))['catch'](handleError(_0x259e7b,null));},exports[a416_0x4b667d(0xb8)]=function(_0xd497fc,_0x32df91){const _0x38e5a2=a416_0x4b667d;return db['ZohoAccount'][_0x38e5a2(0xb8)](_0xd497fc[_0x38e5a2(0x87)],{})[_0x38e5a2(0xd3)](respondWithResult(_0x32df91,0xc9))['catch'](handleError(_0x32df91,null));},exports[a416_0x4b667d(0xbc)]=function(_0x4dc41f,_0x2494c0){const _0x917866=a416_0x4b667d;return _0x4dc41f[_0x917866(0x87)]['id']&&delete _0x4dc41f[_0x917866(0x87)]['id'],db['ZohoAccount'][_0x917866(0xb1)]({'where':{'id':_0x4dc41f[_0x917866(0xe5)]['id']}})[_0x917866(0xd3)](handleEntityNotFound(_0x2494c0,null))[_0x917866(0xd3)](saveUpdates(_0x4dc41f['body'],null))[_0x917866(0xd3)](respondWithResult(_0x2494c0,null))[_0x917866(0xc1)](handleError(_0x2494c0,null));},exports[a416_0x4b667d(0x89)]=function(_0x4a02d5,_0x38166d){const _0x3139ff=a416_0x4b667d;return db[_0x3139ff(0x7c)]['findOne']({'where':{'id':_0x4a02d5['params']['id']}})[_0x3139ff(0xd3)](handleEntityNotFound(_0x38166d,null))[_0x3139ff(0xd3)](removeEntity(_0x38166d,null))[_0x3139ff(0xc1)](handleError(_0x38166d,null));},exports[a416_0x4b667d(0xd0)]=function(_0x200c83,_0x6af3b1){const _0x319281=a416_0x4b667d;let _0x5e533c={};const _0x45eee4={};let _0x3c0b3e,_0x5b11aa;return db[_0x319281(0x7c)][_0x319281(0xb1)]({'where':{'id':_0x200c83[_0x319281(0xe5)]['id']}})[_0x319281(0xd3)](handleEntityNotFound(_0x6af3b1,null))['then'](function(_0x2d3889){const _0x53e940=_0x319281;if(_0x2d3889)return _0x3c0b3e=_0x2d3889,_0x45eee4['model']=_[_0x53e940(0xd2)](db[_0x53e940(0xcf)][_0x53e940(0xe2)]),_0x45eee4['query']=_[_0x53e940(0xd2)](_0x200c83['query']),_0x45eee4['filters']=_['intersection'](_0x45eee4[_0x53e940(0xd8)],_0x45eee4[_0x53e940(0x79)]),_0x5e533c['attributes']=_[_0x53e940(0x76)](_0x45eee4[_0x53e940(0xd8)],qs[_0x53e940(0x93)](_0x200c83[_0x53e940(0x79)]['fields'])),_0x5e533c['attributes']=_0x5e533c[_0x53e940(0xc8)][_0x53e940(0xd9)]?_0x5e533c[_0x53e940(0xc8)]:_0x45eee4[_0x53e940(0xd8)],_0x5e533c[_0x53e940(0xbd)]=qs['sort'](_0x200c83[_0x53e940(0x79)][_0x53e940(0x9f)]),_0x5e533c[_0x53e940(0xda)]=qs['filters'](_['pick'](_0x200c83[_0x53e940(0x79)],_0x45eee4[_0x53e940(0xa4)])),_0x5e533c=filterAttributes(_0x5e533c,_0x200c83['query'][_0x53e940(0xce)],_0x5e533c[_0x53e940(0xc8)],_0x200c83[_0x53e940(0x7a)],![]),_0x3c0b3e[_0x53e940(0xd0)](_0x5e533c);})[_0x319281(0xd3)](function(_0x2501ab){const _0x889d2e=_0x319281;if(_0x2501ab)return _0x5b11aa=_0x2501ab[_0x889d2e(0xd9)],typeof _0x200c83[_0x889d2e(0x79)]['nolimit']==='undefined'&&(_0x5e533c[_0x889d2e(0x74)]=qs[_0x889d2e(0x74)](_0x200c83[_0x889d2e(0x79)][_0x889d2e(0x74)]),_0x5e533c['offset']=qs[_0x889d2e(0xdd)](_0x200c83[_0x889d2e(0x79)]['offset'])),_0x3c0b3e[_0x889d2e(0xd0)](_0x5e533c);})[_0x319281(0xd3)](function(_0x518397){if(_0x518397)return _0x518397?{'count':_0x5b11aa,'rows':_0x518397}:null;})[_0x319281(0xd3)](respondWithResult(_0x6af3b1,null))[_0x319281(0xc1)](handleError(_0x6af3b1,null));},exports[a416_0x4b667d(0xca)]=function(_0x428ebd,_0x4802bd){const _0xa9695=a416_0x4b667d;return _0x428ebd[_0xa9695(0x87)]['id']&&delete _0x428ebd[_0xa9695(0x87)]['id'],db[_0xa9695(0x7c)][_0xa9695(0xb1)]({'where':{'id':_0x428ebd[_0xa9695(0xe5)]['id']}})['then'](handleEntityNotFound(_0x4802bd,null))['then'](function(_0x6b7fa7){const _0x63d6c1=_0xa9695;if(_0x6b7fa7)return _0x428ebd[_0x63d6c1(0x87)][_0x63d6c1(0x97)]=_0x6b7fa7['id'],_0x428ebd[_0x63d6c1(0x87)][_0x63d6c1(0x99)]=integrations['getSubjects'](_0x428ebd['body'][_0x63d6c1(0xe7)],_0x428ebd[_0x63d6c1(0x87)][_0x63d6c1(0x7f)]),_0x428ebd[_0x63d6c1(0x87)][_0x63d6c1(0xdc)]=integrations[_0x63d6c1(0xba)](_0x428ebd[_0x63d6c1(0x87)]['channel'],_0x428ebd[_0x63d6c1(0x87)][_0x63d6c1(0x7f)]),db[_0x63d6c1(0xcf)][_0x63d6c1(0xb8)](_0x428ebd['body'],{'include':[{'model':db[_0x63d6c1(0x8e)],'as':_0x63d6c1(0x99)},{'model':db[_0x63d6c1(0x8e)],'as':_0x63d6c1(0xdc)}]});return null;})['then'](respondWithResult(_0x4802bd,null))['catch'](handleError(_0x4802bd,null));};function getAccessToken(_0x1fcfa1){return new Promise(function(_0x4bddb9,_0x1cb41a){const _0x2b80c7=a416_0x480b;let _0xe1bb97;switch(_0x1fcfa1['zone']){case'US':_0xe1bb97='https://accounts.zoho.com';break;case'AU':_0xe1bb97=_0x2b80c7(0xc9);break;case'EU':_0xe1bb97='https://accounts.zoho.eu';break;case'IN':_0xe1bb97='https://accounts.zoho.in';break;case'CN':_0xe1bb97='https://accounts.zoho.com.cn';break;default:_0xe1bb97=_0x2b80c7(0xa3);break;}const _0x48adb5={'method':_0x2b80c7(0x96),'uri':_0xe1bb97+_0x2b80c7(0xbf),'qs':{'refresh_token':_0x1fcfa1['refreshToken'],'client_id':_0x1fcfa1[_0x2b80c7(0xbb)],'client_secret':_0x1fcfa1['clientSecret'],'grant_type':_0x2b80c7(0xc5)},'json':!![]};return rp(_0x48adb5)[_0x2b80c7(0xd3)](function(_0x3e7e96){const _0x362062=_0x2b80c7;_0x3e7e96[_0x362062(0xa2)]?_0x4bddb9(_0x3e7e96[_0x362062(0xa2)]):_0x1cb41a(_0x362062(0x9e));})[_0x2b80c7(0xc1)](function(_0x52be6f){_0x1cb41a(_0x52be6f);});});}exports[a416_0x4b667d(0xb6)]=function(_0x28ea5b,_0x4ddc1c){const _0x30006f=a416_0x4b667d;let _0x421e1e,_0x3f5daf,_0x4e539d,_0x75142a;return db[_0x30006f(0x7c)][_0x30006f(0xb1)]({'where':{'id':_0x28ea5b[_0x30006f(0xe5)]['id']},'attributes':['id',_0x30006f(0xd5),_0x30006f(0xa0),'clientId',_0x30006f(0xa1),'serverUrl','code',_0x30006f(0x8c)]})['then'](handleEntityNotFound(_0x4ddc1c,null))[_0x30006f(0xd3)](function(_0x2256b3){const _0x2140fd=_0x30006f;_0x75142a=_0x2256b3,_0x421e1e=_0x75142a[_0x2140fd(0xd5)],_0x3f5daf=_0x421e1e===_0x2140fd(0x88)?'eu':'com',_0x4e539d=_0x75142a[_0x2140fd(0xa5)];const _0x15b9ff=_0x4e539d[_0x2140fd(0x8d)](-0x1);(_0x15b9ff==='/'||_0x15b9ff==='\x5c'||_0x15b9ff===':')&&(_0x4e539d=_0x4e539d[_0x2140fd(0xd6)](0x0,_0x4e539d[_0x2140fd(0xa8)](_0x15b9ff)));if(!_0x75142a[_0x2140fd(0x8c)])throw new Error(_0x2140fd(0x8f));return getAccessToken(_0x75142a);})['then'](function(_0x46e7fc){const _0x536915=_0x30006f;if(_0x46e7fc)return rp({'method':_0x536915(0x83),'uri':util[_0x536915(0xb7)](_0x536915(0xdf),_0x3f5daf),'qs':{'module':_0x536915(0xd4)},'headers':{'Authorization':_0x536915(0xe0)+_0x46e7fc},'json':!![]});})[_0x30006f(0xd3)](function(_0x36e84b){const _0x5d20d8=_0x30006f;if(_0x36e84b){if(_0x36e84b[_0x5d20d8(0xac)]&&_0x36e84b[_0x5d20d8(0xac)]['error'])throw new Error(_0x36e84b[_0x5d20d8(0xac)][_0x5d20d8(0xb5)][_0x5d20d8(0x9b)]);const _0x227e6a=[];let _0xefe410=[];const _0x63b4e8=[_0x5d20d8(0x78),_0x5d20d8(0xdb),_0x5d20d8(0x7d),_0x5d20d8(0x98),_0x5d20d8(0x84),_0x5d20d8(0xe4),'Call_Start_Time','Call_Type'];_0xefe410=_[_0x5d20d8(0x86)](_0x36e84b[_0x5d20d8(0x93)],function(_0x2fb1bb){const _0x16a23a=_0x5d20d8;return _0x63b4e8['includes'](_0x2fb1bb[_0x16a23a(0x75)]);});for(let _0x722a51=0x0;_0x722a51<_0xefe410['length'];_0x722a51++){_0xefe410[_0x722a51][_0x5d20d8(0xb3)]===![]&&_0x227e6a['push']({'id':_0xefe410[_0x722a51]['id'],'name':_0xefe410[_0x722a51][_0x5d20d8(0x7b)],'custom':_0xefe410[_0x722a51][_0x5d20d8(0xbe)],'options':_0xefe410[_0x722a51][_0x5d20d8(0x85)]===_0x5d20d8(0x77)&&_0xefe410[_0x722a51][_0x5d20d8(0xb0)][_0x5d20d8(0xd9)]>-0x1?_[_0x5d20d8(0xaf)](_0xefe410[_0x722a51][_0x5d20d8(0xb0)],function(_0x94edde){return{'name':_0x94edde,'value':_0x94edde};}):[]});}return{'count':_0x227e6a[_0x5d20d8(0xd9)],'rows':_0x227e6a};}else return{'count':0x0,'rows':[]};})[_0x30006f(0xd3)](respondWithResult(_0x4ddc1c,null))[_0x30006f(0xc1)](function(_0x41dcdc){const _0x32b00b=_0x30006f;let _0x2882e6=_0x28ea5b[_0x32b00b(0x79)][_0x32b00b(0x94)]?0x1f4:_0x41dcdc[_0x32b00b(0xd7)]||0x1f4;logger[_0x32b00b(0xb5)](_0x32b00b(0xc4),_0x32b00b(0xb6),_0x2882e6,JSON[_0x32b00b(0x81)](_0x41dcdc)),delete _0x41dcdc[_0x32b00b(0x8b)],_0x2882e6===0x191&&(_0x2882e6=0x190),_0x4ddc1c[_0x32b00b(0xb4)](_0x2882e6)[_0x32b00b(0xe1)](_0x28ea5b[_0x32b00b(0x79)][_0x32b00b(0x94)]?{'message':'Wrong\x20credentials','statusCode':_0x41dcdc['statusCode']}:_0x41dcdc);});};
\ No newline at end of file
+'use strict';const a416_0x4224=['pick_list_values','1526237FxTEif','show','5693JMGgrr','rows','format','destroy','1215044FmGhVM','@components/parsers/qs','remove','system_mandatory','rawAttributes','length','channel','Unable\x20to\x20retrieve\x20the\x20access\x20token','error','zone','fieldName','/oauth/v2/token','getFields','include','keys','655104PQHiwY','https://accounts.zoho.com','status','Wrong\x20credentials','@components/integrations/configuration','sort','api_name','access_token','custom_field','https://accounts.zoho.in','send','host','nolimit','https://accounts.zoho.eu','then','body','options','Call_Duration','name','Call_Type','Calls','ZohoField','query','limit','refreshToken','intersection','Zoho-oauthtoken\x20','pick','zoho.eu','catch','filter','getSubjects','serverUrl','statusCode','Description','1210396jhxshS','includeAll','json','2139575jDxcXN','findAll','ZohoAccount','util','Subjects','undefined','offset','map','api','create','fields','20BeRboC','code','params','filters','clientId','https://accounts.zoho.com.cn','getConfigurations','com','Descriptions','ZohoConfiguration','https://www.zohoapis.%s/crm/v2/settings/fields','index','display_label','WhoId','@mysqldb','findOne','type','order','lodash','key','update','response','871633QuXjlq','request-promise-native','Subject','merge','count','clientSecret','getDescriptions','substring','AccountId','Owner','set','https://accounts.zoho.com.au','attributes','model'];const a416_0xc24b=function(_0x511619,_0x5bc591){_0x511619=_0x511619-0x176;let _0x422469=a416_0x4224[_0x511619];return _0x422469;};const a416_0x12b93f=a416_0xc24b;(function(_0x3dafb8,_0x340c76){const _0x1c8715=a416_0xc24b;while(!![]){try{const _0xeebb57=parseInt(_0x1c8715(0x1b5))+-parseInt(_0x1c8715(0x1ca))+parseInt(_0x1c8715(0x1c4))+parseInt(_0x1c8715(0x1d9))+parseInt(_0x1c8715(0x191))+parseInt(_0x1c8715(0x1c6))*-parseInt(_0x1c8715(0x19f))+-parseInt(_0x1c8715(0x194));if(_0xeebb57===_0x340c76)break;else _0x3dafb8['push'](_0x3dafb8['shift']());}catch(_0x260a5f){_0x3dafb8['push'](_0x3dafb8['shift']());}}}(a416_0x4224,0xc210b));const rp=require(a416_0x12b93f(0x1b6)),util=require(a416_0x12b93f(0x197)),_=require(a416_0x12b93f(0x1b1)),qs=require(a416_0x12b93f(0x1cb)),logger=require('@config/logger')(a416_0x12b93f(0x19c)),{db}=require(a416_0x12b93f(0x1ad)),{filterAttributes}=require('@utils/filter-attributes'),integrations=require(a416_0x12b93f(0x1dd));function respondWithResult(_0x3324aa,_0x32a9bc){return _0x32a9bc=_0x32a9bc||0xc8,function(_0x5d2a3d){const _0x554bf5=a416_0xc24b;if(_0x5d2a3d)return _0x3324aa[_0x554bf5(0x1db)](_0x32a9bc)[_0x554bf5(0x193)](_0x5d2a3d);};}function respondWithFilteredResult(_0x37216f,_0x3935dd){return function(_0xf8b13f){const _0x2c4a43=a416_0xc24b;if(_0xf8b13f){const _0x1464e9=_0xf8b13f[_0x2c4a43(0x1b9)],_0x35c5a0=_0x3935dd[_0x2c4a43(0x19a)];let _0x569f24=_0x3935dd[_0x2c4a43(0x19a)]+_0x3935dd[_0x2c4a43(0x185)],_0x23e6f1;return _0x569f24>=_0x1464e9?(_0x569f24=_0x1464e9,_0x23e6f1=0xc8):_0x23e6f1=0xce,_0x37216f[_0x2c4a43(0x1db)](_0x23e6f1),_0x37216f[_0x2c4a43(0x1bf)]('Content-Range',_0x35c5a0+'-'+_0x569f24+'/'+_0x1464e9)['json'](_0xf8b13f);}return null;};}function saveUpdates(_0x611353){return function(_0x418b8f){const _0xe88778=a416_0xc24b;if(_0x418b8f)return _0x418b8f[_0xe88778(0x1b3)](_0x611353)[_0xe88778(0x17c)](function(_0xd59dc1){return _0xd59dc1;});return null;};}function removeEntity(_0x3d1b41){return function(_0xb6a9a){const _0x2853df=a416_0xc24b;if(_0xb6a9a)return _0xb6a9a[_0x2853df(0x1c9)]()['then'](function(){const _0x5d210b=_0x2853df;_0x3d1b41[_0x5d210b(0x1db)](0xcc)['end']();});};}function handleEntityNotFound(_0x59fe96){return function(_0x12d6bf){return!_0x12d6bf&&_0x59fe96['sendStatus'](0x194),_0x12d6bf;};}function handleError(_0x38816c,_0x4140cd){return _0x4140cd=_0x4140cd||0x1f4,function(_0x136ce8){const _0x49d658=a416_0xc24b;logger[_0x49d658(0x1d2)](_0x136ce8['stack']),_0x136ce8[_0x49d658(0x180)]&&delete _0x136ce8[_0x49d658(0x180)],_0x38816c[_0x49d658(0x1db)](_0x4140cd)[_0x49d658(0x178)](_0x136ce8);};}exports[a416_0x12b93f(0x1aa)]=function(_0x60679d,_0x4226e1){const _0x354adb=a416_0x12b93f;let _0x5c0332={};const _0x3cb1c0={},_0x507624={'count':0x0,'rows':[]},_0x2d8b6b=_[_0x354adb(0x19b)](db[_0x354adb(0x196)][_0x354adb(0x1ce)],function(_0x14cec2){const _0x5c27a8=_0x354adb;return{'name':_0x14cec2[_0x5c27a8(0x1d4)],'type':_0x14cec2[_0x5c27a8(0x1af)][_0x5c27a8(0x1b2)]};});_0x3cb1c0[_0x354adb(0x1c2)]=_[_0x354adb(0x19b)](_0x2d8b6b,_0x354adb(0x180)),_0x3cb1c0[_0x354adb(0x184)]=_[_0x354adb(0x1d8)](_0x60679d['query']),_0x3cb1c0[_0x354adb(0x1a2)]=_[_0x354adb(0x187)](_0x3cb1c0['model'],_0x3cb1c0[_0x354adb(0x184)]),_0x5c0332[_0x354adb(0x1c1)]=_[_0x354adb(0x187)](_0x3cb1c0[_0x354adb(0x1c2)],qs[_0x354adb(0x19e)](_0x60679d[_0x354adb(0x184)][_0x354adb(0x19e)])),_0x5c0332[_0x354adb(0x1c1)]=_0x5c0332[_0x354adb(0x1c1)][_0x354adb(0x1cf)]?_0x5c0332[_0x354adb(0x1c1)]:_0x3cb1c0['model'];typeof _0x60679d[_0x354adb(0x184)]['nolimit']===_0x354adb(0x199)&&(_0x5c0332[_0x354adb(0x185)]=qs[_0x354adb(0x185)](_0x60679d[_0x354adb(0x184)][_0x354adb(0x185)]),_0x5c0332[_0x354adb(0x19a)]=qs['offset'](_0x60679d['query'][_0x354adb(0x19a)]));_0x5c0332[_0x354adb(0x1b0)]=qs[_0x354adb(0x1de)](_0x60679d[_0x354adb(0x184)]['sort']),_0x5c0332['where']=qs['filters'](_[_0x354adb(0x189)](_0x60679d[_0x354adb(0x184)],_0x3cb1c0[_0x354adb(0x1a2)]),_0x2d8b6b),_0x5c0332=filterAttributes(_0x5c0332,_0x60679d[_0x354adb(0x184)][_0x354adb(0x18c)],_0x2d8b6b,_0x60679d['options']);const _0x50c627={'where':_0x5c0332['where']};return db['ZohoAccount'][_0x354adb(0x1b9)](_0x50c627)[_0x354adb(0x17c)](function(_0x4baf5b){const _0x388e0e=_0x354adb;return _0x507624['count']=_0x4baf5b,_0x60679d['query'][_0x388e0e(0x192)]&&(_0x5c0332[_0x388e0e(0x1d7)]=[{'all':!![]}]),db['ZohoAccount'][_0x388e0e(0x195)](_0x5c0332);})['then'](function(_0x2e1928){const _0x2f2eb2=_0x354adb;return _0x507624[_0x2f2eb2(0x1c7)]=_0x2e1928,_0x507624;})[_0x354adb(0x17c)](respondWithFilteredResult(_0x4226e1,_0x5c0332))[_0x354adb(0x18b)](handleError(_0x4226e1,null));},exports[a416_0x12b93f(0x1c5)]=function(_0x80ae7c,_0x5059ca){const _0x49f59e=a416_0x12b93f;let _0x31691d={'raw':![],'where':{'id':_0x80ae7c[_0x49f59e(0x1a1)]['id']}};const _0x27a2a7={};return _0x27a2a7[_0x49f59e(0x1c2)]=_[_0x49f59e(0x1d8)](db[_0x49f59e(0x196)][_0x49f59e(0x1ce)]),_0x27a2a7[_0x49f59e(0x184)]=_[_0x49f59e(0x1d8)](_0x80ae7c[_0x49f59e(0x184)]),_0x27a2a7['filters']=_[_0x49f59e(0x187)](_0x27a2a7['model'],_0x27a2a7[_0x49f59e(0x184)]),_0x31691d[_0x49f59e(0x1c1)]=_[_0x49f59e(0x187)](_0x27a2a7[_0x49f59e(0x1c2)],qs[_0x49f59e(0x19e)](_0x80ae7c[_0x49f59e(0x184)]['fields'])),_0x31691d[_0x49f59e(0x1c1)]=_0x31691d[_0x49f59e(0x1c1)][_0x49f59e(0x1cf)]?_0x31691d[_0x49f59e(0x1c1)]:_0x27a2a7['model'],_0x80ae7c[_0x49f59e(0x184)][_0x49f59e(0x192)]&&(_0x31691d[_0x49f59e(0x1d7)]=[{'all':!![]}]),_0x31691d=_[_0x49f59e(0x1b8)]({},_0x31691d,_0x80ae7c[_0x49f59e(0x17e)]),db[_0x49f59e(0x196)][_0x49f59e(0x1ae)](_0x31691d)[_0x49f59e(0x17c)](handleEntityNotFound(_0x5059ca,null))['then'](respondWithResult(_0x5059ca,null))[_0x49f59e(0x18b)](handleError(_0x5059ca,null));},exports[a416_0x12b93f(0x19d)]=function(_0x465af8,_0xed6ca8){const _0xd3626a=a416_0x12b93f;return db[_0xd3626a(0x196)][_0xd3626a(0x19d)](_0x465af8[_0xd3626a(0x17d)],{})[_0xd3626a(0x17c)](respondWithResult(_0xed6ca8,0xc9))[_0xd3626a(0x18b)](handleError(_0xed6ca8,null));},exports[a416_0x12b93f(0x1b3)]=function(_0x390492,_0x12e01c){const _0x30d8ea=a416_0x12b93f;return _0x390492[_0x30d8ea(0x17d)]['id']&&delete _0x390492[_0x30d8ea(0x17d)]['id'],db[_0x30d8ea(0x196)][_0x30d8ea(0x1ae)]({'where':{'id':_0x390492[_0x30d8ea(0x1a1)]['id']}})[_0x30d8ea(0x17c)](handleEntityNotFound(_0x12e01c,null))[_0x30d8ea(0x17c)](saveUpdates(_0x390492[_0x30d8ea(0x17d)],null))[_0x30d8ea(0x17c)](respondWithResult(_0x12e01c,null))['catch'](handleError(_0x12e01c,null));},exports['destroy']=function(_0x4387e9,_0x5f4774){const _0x3b5cb6=a416_0x12b93f;return db[_0x3b5cb6(0x196)][_0x3b5cb6(0x1ae)]({'where':{'id':_0x4387e9[_0x3b5cb6(0x1a1)]['id']}})[_0x3b5cb6(0x17c)](handleEntityNotFound(_0x5f4774,null))[_0x3b5cb6(0x17c)](removeEntity(_0x5f4774,null))['catch'](handleError(_0x5f4774,null));},exports[a416_0x12b93f(0x1a5)]=function(_0x1f6b9c,_0x3db667){const _0x4abe64=a416_0x12b93f;let _0x38d533={};const _0x507ba2={};let _0xae6674,_0x4231b7;return db[_0x4abe64(0x196)][_0x4abe64(0x1ae)]({'where':{'id':_0x1f6b9c[_0x4abe64(0x1a1)]['id']}})[_0x4abe64(0x17c)](handleEntityNotFound(_0x3db667,null))['then'](function(_0x4a664a){const _0x693501=_0x4abe64;if(_0x4a664a)return _0xae6674=_0x4a664a,_0x507ba2['model']=_['keys'](db[_0x693501(0x1a8)]['rawAttributes']),_0x507ba2[_0x693501(0x184)]=_['keys'](_0x1f6b9c[_0x693501(0x184)]),_0x507ba2[_0x693501(0x1a2)]=_[_0x693501(0x187)](_0x507ba2[_0x693501(0x1c2)],_0x507ba2['query']),_0x38d533[_0x693501(0x1c1)]=_[_0x693501(0x187)](_0x507ba2[_0x693501(0x1c2)],qs[_0x693501(0x19e)](_0x1f6b9c[_0x693501(0x184)][_0x693501(0x19e)])),_0x38d533[_0x693501(0x1c1)]=_0x38d533[_0x693501(0x1c1)]['length']?_0x38d533['attributes']:_0x507ba2[_0x693501(0x1c2)],_0x38d533['order']=qs[_0x693501(0x1de)](_0x1f6b9c['query'][_0x693501(0x1de)]),_0x38d533['where']=qs[_0x693501(0x1a2)](_[_0x693501(0x189)](_0x1f6b9c[_0x693501(0x184)],_0x507ba2[_0x693501(0x1a2)])),_0x38d533=filterAttributes(_0x38d533,_0x1f6b9c[_0x693501(0x184)][_0x693501(0x18c)],_0x38d533[_0x693501(0x1c1)],_0x1f6b9c[_0x693501(0x17e)],![]),_0xae6674['getConfigurations'](_0x38d533);})['then'](function(_0x1824a7){const _0x8b4d18=_0x4abe64;if(_0x1824a7)return _0x4231b7=_0x1824a7[_0x8b4d18(0x1cf)],typeof _0x1f6b9c[_0x8b4d18(0x184)][_0x8b4d18(0x17a)]===_0x8b4d18(0x199)&&(_0x38d533[_0x8b4d18(0x185)]=qs[_0x8b4d18(0x185)](_0x1f6b9c[_0x8b4d18(0x184)]['limit']),_0x38d533[_0x8b4d18(0x19a)]=qs[_0x8b4d18(0x19a)](_0x1f6b9c[_0x8b4d18(0x184)][_0x8b4d18(0x19a)])),_0xae6674[_0x8b4d18(0x1a5)](_0x38d533);})[_0x4abe64(0x17c)](function(_0x4a319f){if(_0x4a319f)return _0x4a319f?{'count':_0x4231b7,'rows':_0x4a319f}:null;})[_0x4abe64(0x17c)](respondWithResult(_0x3db667,null))[_0x4abe64(0x18b)](handleError(_0x3db667,null));},exports['addConfiguration']=function(_0x5cc975,_0x36a129){const _0x1765ad=a416_0x12b93f;return _0x5cc975['body']['id']&&delete _0x5cc975[_0x1765ad(0x17d)]['id'],db[_0x1765ad(0x196)][_0x1765ad(0x1ae)]({'where':{'id':_0x5cc975['params']['id']}})['then'](handleEntityNotFound(_0x36a129,null))['then'](function(_0x52a582){const _0xd77a3f=_0x1765ad;if(_0x52a582)return _0x5cc975[_0xd77a3f(0x17d)][_0xd77a3f(0x1bd)]=_0x52a582['id'],_0x5cc975[_0xd77a3f(0x17d)][_0xd77a3f(0x198)]=integrations[_0xd77a3f(0x18d)](_0x5cc975[_0xd77a3f(0x17d)]['channel'],_0x5cc975[_0xd77a3f(0x17d)][_0xd77a3f(0x1af)]),_0x5cc975[_0xd77a3f(0x17d)][_0xd77a3f(0x1a7)]=integrations[_0xd77a3f(0x1bb)](_0x5cc975[_0xd77a3f(0x17d)][_0xd77a3f(0x1d0)],_0x5cc975['body'][_0xd77a3f(0x1af)]),db[_0xd77a3f(0x1a8)][_0xd77a3f(0x19d)](_0x5cc975[_0xd77a3f(0x17d)],{'include':[{'model':db[_0xd77a3f(0x183)],'as':_0xd77a3f(0x198)},{'model':db[_0xd77a3f(0x183)],'as':_0xd77a3f(0x1a7)}]});return null;})[_0x1765ad(0x17c)](respondWithResult(_0x36a129,null))[_0x1765ad(0x18b)](handleError(_0x36a129,null));};function getAccessToken(_0x3cd203){return new Promise(function(_0x4fb6b3,_0x2076a9){const _0x9285ba=a416_0xc24b;let _0x11d092;switch(_0x3cd203[_0x9285ba(0x1d3)]){case'US':_0x11d092=_0x9285ba(0x1da);break;case'AU':_0x11d092=_0x9285ba(0x1c0);break;case'EU':_0x11d092='https://accounts.zoho.eu';break;case'IN':_0x11d092=_0x9285ba(0x177);break;case'CN':_0x11d092=_0x9285ba(0x1a4);break;default:_0x11d092=_0x9285ba(0x17b);break;}const _0x173fbd={'method':'POST','uri':_0x11d092+_0x9285ba(0x1d5),'qs':{'refresh_token':_0x3cd203[_0x9285ba(0x186)],'client_id':_0x3cd203['clientId'],'client_secret':_0x3cd203['clientSecret'],'grant_type':'refresh_token'},'json':!![]};return rp(_0x173fbd)[_0x9285ba(0x17c)](function(_0x5d5e40){const _0x31c6a1=_0x9285ba;_0x5d5e40[_0x31c6a1(0x1e0)]?_0x4fb6b3(_0x5d5e40[_0x31c6a1(0x1e0)]):_0x2076a9(_0x31c6a1(0x1d1));})[_0x9285ba(0x18b)](function(_0x56a95f){_0x2076a9(_0x56a95f);});});}exports[a416_0x12b93f(0x1d6)]=function(_0x42cffd,_0x393d09){const _0x87a165=a416_0x12b93f;let _0x1e2ec6,_0x183ecc,_0x2bd969,_0x3c5bb1;return db[_0x87a165(0x196)][_0x87a165(0x1ae)]({'where':{'id':_0x42cffd[_0x87a165(0x1a1)]['id']},'attributes':['id',_0x87a165(0x179),_0x87a165(0x1d3),_0x87a165(0x1a3),_0x87a165(0x1ba),_0x87a165(0x18e),_0x87a165(0x1a0),'refreshToken']})['then'](handleEntityNotFound(_0x393d09,null))[_0x87a165(0x17c)](function(_0x60bad6){const _0x45d62e=_0x87a165;_0x3c5bb1=_0x60bad6,_0x1e2ec6=_0x3c5bb1['host'],_0x183ecc=_0x1e2ec6===_0x45d62e(0x18a)?'eu':_0x45d62e(0x1a6),_0x2bd969=_0x3c5bb1['serverUrl'];const _0x45ff41=_0x2bd969['slice'](-0x1);(_0x45ff41==='/'||_0x45ff41==='\x5c'||_0x45ff41===':')&&(_0x2bd969=_0x2bd969[_0x45d62e(0x1bc)](0x0,_0x2bd969['lastIndexOf'](_0x45ff41)));if(!_0x3c5bb1[_0x45d62e(0x186)])throw new Error('Refresh\x20Token\x20not\x20available\x20for\x20the\x20account');return getAccessToken(_0x3c5bb1);})['then'](function(_0x27f8d6){const _0x26fe48=_0x87a165;if(_0x27f8d6)return rp({'method':'GET','uri':util[_0x26fe48(0x1c8)](_0x26fe48(0x1a9),_0x183ecc),'qs':{'module':_0x26fe48(0x182)},'headers':{'Authorization':_0x26fe48(0x188)+_0x27f8d6},'json':!![]});})['then'](function(_0x2b9a9a){const _0x478374=_0x87a165;if(_0x2b9a9a){if(_0x2b9a9a['response']&&_0x2b9a9a[_0x478374(0x1b4)]['error'])throw new Error(_0x2b9a9a[_0x478374(0x1b4)][_0x478374(0x1d2)]['message']);const _0x2dafc9=[];let _0x2e8253=[];const _0x11c624=[_0x478374(0x1be),_0x478374(0x1b7),_0x478374(0x190),_0x478374(0x1ac),_0x478374(0x17f),'Call_Result','Call_Start_Time',_0x478374(0x181)];_0x2e8253=_[_0x478374(0x1cc)](_0x2b9a9a['fields'],function(_0x5586de){const _0x2c9492=_0x478374;return _0x11c624['includes'](_0x5586de[_0x2c9492(0x1df)]);});for(let _0x55fa52=0x0;_0x55fa52<_0x2e8253[_0x478374(0x1cf)];_0x55fa52++){_0x2e8253[_0x55fa52][_0x478374(0x1cd)]===![]&&_0x2dafc9['push']({'id':_0x2e8253[_0x55fa52]['id'],'name':_0x2e8253[_0x55fa52][_0x478374(0x1ab)],'custom':_0x2e8253[_0x55fa52][_0x478374(0x176)],'options':_0x2e8253[_0x55fa52]['data_type']==='picklist'&&_0x2e8253[_0x55fa52][_0x478374(0x1c3)]['length']>-0x1?_[_0x478374(0x19b)](_0x2e8253[_0x55fa52][_0x478374(0x1c3)],function(_0x5a8516){return{'name':_0x5a8516,'value':_0x5a8516};}):[]});}return{'count':_0x2dafc9[_0x478374(0x1cf)],'rows':_0x2dafc9};}else return{'count':0x0,'rows':[]};})['then'](respondWithResult(_0x393d09,null))[_0x87a165(0x18b)](function(_0x5f1ba8){const _0x2a3b66=_0x87a165;let _0x46a28e=_0x42cffd[_0x2a3b66(0x184)]['test']?0x1f4:_0x5f1ba8['statusCode']||0x1f4;logger[_0x2a3b66(0x1d2)]('getFields,\x20%s,\x20%s,\x20%s',_0x2a3b66(0x1d6),_0x46a28e,JSON['stringify'](_0x5f1ba8)),delete _0x5f1ba8[_0x2a3b66(0x180)],_0x46a28e===0x191&&(_0x46a28e=0x190),_0x393d09['status'](_0x46a28e)['send'](_0x42cffd[_0x2a3b66(0x184)]['test']?{'message':_0x2a3b66(0x1dc),'statusCode':_0x5f1ba8[_0x2a3b66(0x18f)]}:_0x5f1ba8);});};
\ No newline at end of file