Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / intFreshsalesAccount / intFreshsalesAccount.controller.js
index 205c476..2e7d486 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xffa9=['../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../components/integrations/configuration','status','end','json','offset','limit','undefined','count','set','Content-Range','reject','save','update','then','error','stack','name','index','map','FreshsalesAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','pick','filter','where','VIRTUAL','merge','includeAll','include','findAll','rows','catch','show','params','options','find','create','body','destroy','getConfigurations','FreshsalesConfiguration','sort','hasOwnProperty','addConfiguration','findOne','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','FreshsalesField','getFields','username','apiKey','remoteUri','slice','substring','lastIndexOf','GET','format','Token\x20token=','users','email','Requested\x20Resource\x20not\x20Found','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','send','Wrong\x20credentials','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse'];(function(_0x4f80a7,_0x40d48e){var _0x57f272=function(_0x578773){while(--_0x578773){_0x4f80a7['push'](_0x4f80a7['shift']());}};_0x57f272(++_0x40d48e);}(_0xffa9,0xbf));var _0x9ffa=function(_0x20bbe5,_0x189723){_0x20bbe5=_0x20bbe5-0x0;var _0x1d94c7=_0xffa9[_0x20bbe5];return _0x1d94c7;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x9ffa('0x0'));var zipdir=require(_0x9ffa('0x1'));var jsonpatch=require(_0x9ffa('0x2'));var rp=require(_0x9ffa('0x3'));var moment=require(_0x9ffa('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x9ffa('0x5'));var util=require(_0x9ffa('0x6'));var path=require(_0x9ffa('0x7'));var sox=require(_0x9ffa('0x8'));var csv=require(_0x9ffa('0x9'));var ejs=require(_0x9ffa('0xa'));var fs=require('fs');var fs_extra=require(_0x9ffa('0xb'));var _=require('lodash');var squel=require(_0x9ffa('0xc'));var crypto=require(_0x9ffa('0xd'));var jsforce=require(_0x9ffa('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x9ffa('0x9'));var querystring=require(_0x9ffa('0xf'));var Papa=require(_0x9ffa('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x9ffa('0x11'));var as=require(_0x9ffa('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9ffa('0x13'))(_0x9ffa('0x14'));var utils=require('../../config/utils');var config=require(_0x9ffa('0x15'));var licenseUtil=require(_0x9ffa('0x16'));var db=require('../../mysqldb')['db'];var integrations=require(_0x9ffa('0x17'));function respondWithStatusCode(_0x558540,_0x249b40){_0x249b40=_0x249b40||0xcc;return function(_0x32a2d7){if(_0x32a2d7){return _0x558540['sendStatus'](_0x249b40);}return _0x558540[_0x9ffa('0x18')](_0x249b40)[_0x9ffa('0x19')]();};}function respondWithResult(_0x53d9db,_0x13811d){_0x13811d=_0x13811d||0xc8;return function(_0x4e266e){if(_0x4e266e){return _0x53d9db[_0x9ffa('0x18')](_0x13811d)[_0x9ffa('0x1a')](_0x4e266e);}};}function respondWithFilteredResult(_0x4696a0,_0x460948){return function(_0x32896d){if(_0x32896d){var _0x5c2cd2=typeof _0x460948[_0x9ffa('0x1b')]==='undefined'&&typeof _0x460948[_0x9ffa('0x1c')]===_0x9ffa('0x1d');var _0x14f19e=_0x32896d['count'];var _0x1ad353=_0x5c2cd2?0x0:_0x460948[_0x9ffa('0x1b')];var _0x4c81bb=_0x5c2cd2?_0x32896d[_0x9ffa('0x1e')]:_0x460948[_0x9ffa('0x1b')]+_0x460948[_0x9ffa('0x1c')];var _0x2b43b5;if(_0x4c81bb>=_0x14f19e){_0x4c81bb=_0x14f19e;_0x2b43b5=0xc8;}else{_0x2b43b5=0xce;}_0x4696a0['status'](_0x2b43b5);return _0x4696a0[_0x9ffa('0x1f')](_0x9ffa('0x20'),_0x1ad353+'-'+_0x4c81bb+'/'+_0x14f19e)[_0x9ffa('0x1a')](_0x32896d);}return null;};}function patchUpdates(_0x5f106f){return function(_0x29613e){try{jsonpatch['apply'](_0x29613e,_0x5f106f,!![]);}catch(_0x3ec5d4){return BPromise[_0x9ffa('0x21')](_0x3ec5d4);}return _0x29613e[_0x9ffa('0x22')]();};}function saveUpdates(_0x477c3b,_0x55f6d6){return function(_0x41e6b5){if(_0x41e6b5){return _0x41e6b5[_0x9ffa('0x23')](_0x477c3b)[_0x9ffa('0x24')](function(_0x205c1c){return _0x205c1c;});}return null;};}function removeEntity(_0x32d3fa,_0x52f95c){return function(_0x4cfbde){if(_0x4cfbde){return _0x4cfbde['destroy']()[_0x9ffa('0x24')](function(){_0x32d3fa[_0x9ffa('0x18')](0xcc)[_0x9ffa('0x19')]();});}};}function handleEntityNotFound(_0x495ad0,_0x3781e2){return function(_0x1f97fb){if(!_0x1f97fb){_0x495ad0['sendStatus'](0x194);}return _0x1f97fb;};}function handleError(_0xab5ca0,_0xabebe6){_0xabebe6=_0xabebe6||0x1f4;return function(_0x156a82){logger[_0x9ffa('0x25')](_0x156a82[_0x9ffa('0x26')]);if(_0x156a82[_0x9ffa('0x27')]){delete _0x156a82[_0x9ffa('0x27')];}_0xab5ca0[_0x9ffa('0x18')](_0xabebe6)['send'](_0x156a82);};}exports[_0x9ffa('0x28')]=function(_0xe928b3,_0x4bdba1){var _0x185abf={},_0x128560={},_0x5ca942={'count':0x0,'rows':[]};var _0x5ea141=_[_0x9ffa('0x29')](db[_0x9ffa('0x2a')][_0x9ffa('0x2b')],function(_0x5f1c7f){return{'name':_0x5f1c7f[_0x9ffa('0x2c')],'type':_0x5f1c7f[_0x9ffa('0x2d')][_0x9ffa('0x2e')]};});_0x128560[_0x9ffa('0x2f')]=_['map'](_0x5ea141,_0x9ffa('0x27'));_0x128560[_0x9ffa('0x30')]=_[_0x9ffa('0x31')](_0xe928b3[_0x9ffa('0x30')]);_0x128560[_0x9ffa('0x32')]=_[_0x9ffa('0x33')](_0x128560['model'],_0x128560[_0x9ffa('0x30')]);_0x185abf[_0x9ffa('0x34')]=_['intersection'](_0x128560[_0x9ffa('0x2f')],qs[_0x9ffa('0x35')](_0xe928b3[_0x9ffa('0x30')][_0x9ffa('0x35')]));_0x185abf[_0x9ffa('0x34')]=_0x185abf[_0x9ffa('0x34')][_0x9ffa('0x36')]?_0x185abf[_0x9ffa('0x34')]:_0x128560[_0x9ffa('0x2f')];if(!_0xe928b3[_0x9ffa('0x30')]['hasOwnProperty'](_0x9ffa('0x37'))){_0x185abf[_0x9ffa('0x1c')]=qs[_0x9ffa('0x1c')](_0xe928b3[_0x9ffa('0x30')]['limit']);_0x185abf[_0x9ffa('0x1b')]=qs[_0x9ffa('0x1b')](_0xe928b3[_0x9ffa('0x30')][_0x9ffa('0x1b')]);}_0x185abf['order']=qs['sort'](_0xe928b3['query']['sort']);_0x185abf['where']=qs[_0x9ffa('0x32')](_[_0x9ffa('0x38')](_0xe928b3[_0x9ffa('0x30')],_0x128560[_0x9ffa('0x32')]),_0x5ea141);if(_0xe928b3[_0x9ffa('0x30')][_0x9ffa('0x39')]){_0x185abf['where']=_['merge'](_0x185abf[_0x9ffa('0x3a')],{'$or':_[_0x9ffa('0x29')](_0x5ea141,function(_0x55a017){if(_0x55a017['type']!==_0x9ffa('0x3b')){var _0x33b8b1={};_0x33b8b1[_0x55a017[_0x9ffa('0x27')]]={'$like':'%'+_0xe928b3['query'][_0x9ffa('0x39')]+'%'};return _0x33b8b1;}})});}_0x185abf=_[_0x9ffa('0x3c')]({},_0x185abf,_0xe928b3['options']);var _0x51dfe1={'where':_0x185abf[_0x9ffa('0x3a')]};return db[_0x9ffa('0x2a')][_0x9ffa('0x1e')](_0x51dfe1)[_0x9ffa('0x24')](function(_0x559291){_0x5ca942['count']=_0x559291;if(_0xe928b3['query'][_0x9ffa('0x3d')]){_0x185abf[_0x9ffa('0x3e')]=[{'all':!![]}];}return db[_0x9ffa('0x2a')][_0x9ffa('0x3f')](_0x185abf);})['then'](function(_0x250128){_0x5ca942[_0x9ffa('0x40')]=_0x250128;return _0x5ca942;})[_0x9ffa('0x24')](respondWithFilteredResult(_0x4bdba1,_0x185abf))[_0x9ffa('0x41')](handleError(_0x4bdba1,null));};exports[_0x9ffa('0x42')]=function(_0x22a5d4,_0xb837ec){var _0x59fcf5={'raw':![],'where':{'id':_0x22a5d4[_0x9ffa('0x43')]['id']}},_0x48b171={};_0x48b171[_0x9ffa('0x2f')]=_[_0x9ffa('0x31')](db[_0x9ffa('0x2a')]['rawAttributes']);_0x48b171[_0x9ffa('0x30')]=_[_0x9ffa('0x31')](_0x22a5d4[_0x9ffa('0x30')]);_0x48b171[_0x9ffa('0x32')]=_[_0x9ffa('0x33')](_0x48b171[_0x9ffa('0x2f')],_0x48b171[_0x9ffa('0x30')]);_0x59fcf5[_0x9ffa('0x34')]=_[_0x9ffa('0x33')](_0x48b171['model'],qs['fields'](_0x22a5d4[_0x9ffa('0x30')]['fields']));_0x59fcf5['attributes']=_0x59fcf5[_0x9ffa('0x34')][_0x9ffa('0x36')]?_0x59fcf5[_0x9ffa('0x34')]:_0x48b171[_0x9ffa('0x2f')];if(_0x22a5d4['query'][_0x9ffa('0x3d')]){_0x59fcf5[_0x9ffa('0x3e')]=[{'all':!![]}];}_0x59fcf5=_[_0x9ffa('0x3c')]({},_0x59fcf5,_0x22a5d4[_0x9ffa('0x44')]);return db[_0x9ffa('0x2a')][_0x9ffa('0x45')](_0x59fcf5)[_0x9ffa('0x24')](handleEntityNotFound(_0xb837ec,null))[_0x9ffa('0x24')](respondWithResult(_0xb837ec,null))[_0x9ffa('0x41')](handleError(_0xb837ec,null));};exports[_0x9ffa('0x46')]=function(_0xbf2799,_0x3a6309){return db[_0x9ffa('0x2a')]['create'](_0xbf2799[_0x9ffa('0x47')],{})['then'](respondWithResult(_0x3a6309,0xc9))[_0x9ffa('0x41')](handleError(_0x3a6309,null));};exports[_0x9ffa('0x23')]=function(_0x82ac89,_0x4d8b80){if(_0x82ac89[_0x9ffa('0x47')]['id']){delete _0x82ac89[_0x9ffa('0x47')]['id'];}return db[_0x9ffa('0x2a')][_0x9ffa('0x45')]({'where':{'id':_0x82ac89[_0x9ffa('0x43')]['id']}})['then'](handleEntityNotFound(_0x4d8b80,null))[_0x9ffa('0x24')](saveUpdates(_0x82ac89[_0x9ffa('0x47')],null))[_0x9ffa('0x24')](respondWithResult(_0x4d8b80,null))[_0x9ffa('0x41')](handleError(_0x4d8b80,null));};exports[_0x9ffa('0x48')]=function(_0x550d5c,_0x10e67b){return db[_0x9ffa('0x2a')][_0x9ffa('0x45')]({'where':{'id':_0x550d5c[_0x9ffa('0x43')]['id']}})[_0x9ffa('0x24')](handleEntityNotFound(_0x10e67b,null))[_0x9ffa('0x24')](removeEntity(_0x10e67b,null))[_0x9ffa('0x41')](handleError(_0x10e67b,null));};exports[_0x9ffa('0x49')]=function(_0x5524a1,_0x115fe2,_0x539a6){var _0x542cc6={};var _0x59f526={};var _0x3f1ae2;var _0x360e78;return db['FreshsalesAccount']['findOne']({'where':{'id':_0x5524a1[_0x9ffa('0x43')]['id']}})[_0x9ffa('0x24')](handleEntityNotFound(_0x115fe2,null))[_0x9ffa('0x24')](function(_0x4d9123){if(_0x4d9123){_0x3f1ae2=_0x4d9123;_0x59f526[_0x9ffa('0x2f')]=_[_0x9ffa('0x31')](db[_0x9ffa('0x4a')]['rawAttributes']);_0x59f526[_0x9ffa('0x30')]=_[_0x9ffa('0x31')](_0x5524a1[_0x9ffa('0x30')]);_0x59f526['filters']=_[_0x9ffa('0x33')](_0x59f526['model'],_0x59f526['query']);_0x542cc6[_0x9ffa('0x34')]=_[_0x9ffa('0x33')](_0x59f526[_0x9ffa('0x2f')],qs['fields'](_0x5524a1[_0x9ffa('0x30')][_0x9ffa('0x35')]));_0x542cc6[_0x9ffa('0x34')]=_0x542cc6[_0x9ffa('0x34')][_0x9ffa('0x36')]?_0x542cc6[_0x9ffa('0x34')]:_0x59f526[_0x9ffa('0x2f')];_0x542cc6['order']=qs[_0x9ffa('0x4b')](_0x5524a1[_0x9ffa('0x30')][_0x9ffa('0x4b')]);_0x542cc6[_0x9ffa('0x3a')]=qs[_0x9ffa('0x32')](_[_0x9ffa('0x38')](_0x5524a1['query'],_0x59f526[_0x9ffa('0x32')]));if(_0x5524a1[_0x9ffa('0x30')][_0x9ffa('0x39')]){_0x542cc6['where']=_[_0x9ffa('0x3c')](_0x542cc6['where'],{'$or':_[_0x9ffa('0x29')](_0x542cc6[_0x9ffa('0x34')],function(_0x259aab){var _0x5571f5={};_0x5571f5[_0x259aab]={'$like':'%'+_0x5524a1[_0x9ffa('0x30')][_0x9ffa('0x39')]+'%'};return _0x5571f5;})});}_0x542cc6=_[_0x9ffa('0x3c')]({},_0x542cc6,_0x5524a1[_0x9ffa('0x44')]);return _0x3f1ae2[_0x9ffa('0x49')](_0x542cc6);}})[_0x9ffa('0x24')](function(_0xd82512){if(_0xd82512){_0x360e78=_0xd82512[_0x9ffa('0x36')];if(!_0x5524a1[_0x9ffa('0x30')][_0x9ffa('0x4c')]('nolimit')){_0x542cc6[_0x9ffa('0x1c')]=qs['limit'](_0x5524a1[_0x9ffa('0x30')]['limit']);_0x542cc6[_0x9ffa('0x1b')]=qs['offset'](_0x5524a1['query'][_0x9ffa('0x1b')]);}return _0x3f1ae2['getConfigurations'](_0x542cc6);}})['then'](function(_0x11be97){if(_0x11be97){return _0x11be97?{'count':_0x360e78,'rows':_0x11be97}:null;}})['then'](respondWithResult(_0x115fe2,null))[_0x9ffa('0x41')](handleError(_0x115fe2,null));};exports[_0x9ffa('0x4d')]=function(_0x540d8b,_0x4b8c24,_0x97ec5e){if(_0x540d8b[_0x9ffa('0x47')]['id']){delete _0x540d8b[_0x9ffa('0x47')]['id'];}return db[_0x9ffa('0x2a')][_0x9ffa('0x4e')]({'where':{'id':_0x540d8b[_0x9ffa('0x43')]['id']}})[_0x9ffa('0x24')](handleEntityNotFound(_0x4b8c24,null))[_0x9ffa('0x24')](function(_0x4f8df0){if(_0x4f8df0){_0x540d8b[_0x9ffa('0x47')][_0x9ffa('0x4f')]=_0x4f8df0['id'];_0x540d8b[_0x9ffa('0x47')][_0x9ffa('0x50')]=integrations[_0x9ffa('0x51')](_0x540d8b[_0x9ffa('0x47')][_0x9ffa('0x52')],_0x540d8b[_0x9ffa('0x47')][_0x9ffa('0x2d')]);_0x540d8b[_0x9ffa('0x47')][_0x9ffa('0x53')]=integrations[_0x9ffa('0x54')](_0x540d8b[_0x9ffa('0x47')][_0x9ffa('0x52')],_0x540d8b[_0x9ffa('0x47')][_0x9ffa('0x2d')]);return db[_0x9ffa('0x4a')]['create'](_0x540d8b[_0x9ffa('0x47')],{'include':[{'model':db[_0x9ffa('0x55')],'as':_0x9ffa('0x50')},{'model':db['FreshsalesField'],'as':_0x9ffa('0x53')}]});}return null;})[_0x9ffa('0x24')](respondWithResult(_0x4b8c24,null))[_0x9ffa('0x41')](handleError(_0x4b8c24,null));};exports[_0x9ffa('0x56')]=function(_0x552abf,_0x394be4,_0x4994c8){var _0x3113d9='';var _0x390cde='';return db[_0x9ffa('0x2a')]['findOne']({'where':{'id':_0x552abf[_0x9ffa('0x43')]['id']},'attributes':['id',_0x9ffa('0x57'),'remoteUri',_0x9ffa('0x58')]})[_0x9ffa('0x24')](handleEntityNotFound(_0x394be4,null))[_0x9ffa('0x24')](function(_0xa95a38){if(_0xa95a38){_0x390cde=_0xa95a38[_0x9ffa('0x57')];_0x3113d9=_0xa95a38[_0x9ffa('0x59')];var _0x5ac240=_0xa95a38[_0x9ffa('0x59')][_0x9ffa('0x5a')](-0x1);if(_0x5ac240==='/'){_0x3113d9=_0x3113d9[_0x9ffa('0x5b')](0x0,_0x3113d9[_0x9ffa('0x5c')](_0x5ac240));}return rp({'method':_0x9ffa('0x5d'),'uri':util[_0x9ffa('0x5e')]('%s%s',_0x3113d9,'/api/selector/owners'),'headers':{'Authorization':_0x9ffa('0x5f')+_0xa95a38[_0x9ffa('0x58')]},'json':!![]});}})[_0x9ffa('0x24')](function(_0x5b2e91){if(_0x5b2e91){var _0x37fb62=_0x5b2e91[_0x9ffa('0x60')];var _0x526482=![];var _0x3a2a79=null;for(_0x3a2a79=0x0;_0x3a2a79<_0x37fb62['length'];_0x3a2a79++){if(_0x37fb62[_0x3a2a79][_0x9ffa('0x61')]===_0x390cde){_0x526482=!![];}}if(_0x526482){return!![];}else{throw new Error({'statusCode':0x194,'message':_0x9ffa('0x62')});}}})[_0x9ffa('0x24')](respondWithResult(_0x394be4,null))[_0x9ffa('0x41')](function(_0x50715c){var _0xe95be6=_0x552abf[_0x9ffa('0x30')][_0x9ffa('0x63')]?0x1f4:_0x50715c[_0x9ffa('0x64')]||0x1f4;logger[_0x9ffa('0x25')](_0x9ffa('0x65'),_0x9ffa('0x56'),_0xe95be6,JSON['stringify'](_0x50715c));delete _0x50715c[_0x9ffa('0x27')];if(_0xe95be6===0x191){_0xe95be6=0x190;}_0x394be4[_0x9ffa('0x18')](_0xe95be6)[_0x9ffa('0x66')](_0x552abf[_0x9ffa('0x30')][_0x9ffa('0x63')]?{'message':_0x9ffa('0x67'),'statusCode':_0x50715c[_0x9ffa('0x64')]}:_0x50715c);});};
\ No newline at end of file
+var _0x7bc1=['nolimit','order','sort','where','filters','pick','filter','VIRTUAL','merge','FreshsalesAccount','includeAll','include','rows','catch','show','options','find','create','body','params','findOne','rawAttributes','length','getConfigurations','addConfiguration','getSubjects','Descriptions','getDescriptions','channel','FreshsalesConfiguration','FreshsalesField','getFields','username','apiKey','remoteUri','slice','substring','GET','format','%s%s','Token\x20token=','email','Requested\x20Resource\x20not\x20Found','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','end','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','sendStatus','error','stack','name','send','index','map','fieldName','type','key','model','query','keys','intersection','attributes','fields','hasOwnProperty'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x7bc1,0x104));var _0x17bc=function(_0x1308b8,_0x52ab7d){_0x1308b8=_0x1308b8-0x0;var _0x391a9a=_0x7bc1[_0x1308b8];return _0x391a9a;};'use strict';var emlformat=require(_0x17bc('0x0'));var rimraf=require(_0x17bc('0x1'));var zipdir=require(_0x17bc('0x2'));var jsonpatch=require(_0x17bc('0x3'));var rp=require(_0x17bc('0x4'));var moment=require('moment');var BPromise=require(_0x17bc('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x17bc('0x6'));var ejs=require(_0x17bc('0x7'));var fs=require('fs');var fs_extra=require(_0x17bc('0x8'));var _=require(_0x17bc('0x9'));var squel=require(_0x17bc('0xa'));var crypto=require(_0x17bc('0xb'));var jsforce=require(_0x17bc('0xc'));var deskjs=require(_0x17bc('0xd'));var toCsv=require(_0x17bc('0x6'));var querystring=require(_0x17bc('0xe'));var Papa=require(_0x17bc('0xf'));var Redis=require(_0x17bc('0x10'));var authService=require(_0x17bc('0x11'));var qs=require(_0x17bc('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x17bc('0x13'));var logger=require(_0x17bc('0x14'))(_0x17bc('0x15'));var utils=require(_0x17bc('0x16'));var config=require(_0x17bc('0x17'));var licenseUtil=require(_0x17bc('0x18'));var db=require(_0x17bc('0x19'))['db'];var integrations=require(_0x17bc('0x1a'));function respondWithStatusCode(_0x54e83d,_0x3df50b){_0x3df50b=_0x3df50b||0xcc;return function(_0x48f3e3){if(_0x48f3e3){return _0x54e83d['sendStatus'](_0x3df50b);}return _0x54e83d['status'](_0x3df50b)[_0x17bc('0x1b')]();};}function respondWithResult(_0x5e3597,_0x5a960e){_0x5a960e=_0x5a960e||0xc8;return function(_0xb7ff31){if(_0xb7ff31){return _0x5e3597[_0x17bc('0x1c')](_0x5a960e)[_0x17bc('0x1d')](_0xb7ff31);}};}function respondWithFilteredResult(_0x5b5ea8,_0x19677d){return function(_0xdd82be){if(_0xdd82be){var _0x205ef2=typeof _0x19677d['offset']===_0x17bc('0x1e')&&typeof _0x19677d[_0x17bc('0x1f')]===_0x17bc('0x1e');var _0x52f1a6=_0xdd82be[_0x17bc('0x20')];var _0x3e0c5e=_0x205ef2?0x0:_0x19677d[_0x17bc('0x21')];var _0x5c9cff=_0x205ef2?_0xdd82be[_0x17bc('0x20')]:_0x19677d[_0x17bc('0x21')]+_0x19677d[_0x17bc('0x1f')];var _0x3e8043;if(_0x5c9cff>=_0x52f1a6){_0x5c9cff=_0x52f1a6;_0x3e8043=0xc8;}else{_0x3e8043=0xce;}_0x5b5ea8[_0x17bc('0x1c')](_0x3e8043);return _0x5b5ea8[_0x17bc('0x22')](_0x17bc('0x23'),_0x3e0c5e+'-'+_0x5c9cff+'/'+_0x52f1a6)[_0x17bc('0x1d')](_0xdd82be);}return null;};}function patchUpdates(_0x268bd9){return function(_0x1f4092){try{jsonpatch[_0x17bc('0x24')](_0x1f4092,_0x268bd9,!![]);}catch(_0x41e0b3){return BPromise[_0x17bc('0x25')](_0x41e0b3);}return _0x1f4092[_0x17bc('0x26')]();};}function saveUpdates(_0x200a61,_0x10f4c2){return function(_0x3401eb){if(_0x3401eb){return _0x3401eb[_0x17bc('0x27')](_0x200a61)[_0x17bc('0x28')](function(_0x38616d){return _0x38616d;});}return null;};}function removeEntity(_0x3a0831,_0x583065){return function(_0x27a84c){if(_0x27a84c){return _0x27a84c['destroy']()[_0x17bc('0x28')](function(){_0x3a0831[_0x17bc('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2e1446,_0x3762c8){return function(_0xe4c7ba){if(!_0xe4c7ba){_0x2e1446[_0x17bc('0x29')](0x194);}return _0xe4c7ba;};}function handleError(_0x5807b8,_0x1487ea){_0x1487ea=_0x1487ea||0x1f4;return function(_0x5b9add){logger[_0x17bc('0x2a')](_0x5b9add[_0x17bc('0x2b')]);if(_0x5b9add[_0x17bc('0x2c')]){delete _0x5b9add[_0x17bc('0x2c')];}_0x5807b8[_0x17bc('0x1c')](_0x1487ea)[_0x17bc('0x2d')](_0x5b9add);};}exports[_0x17bc('0x2e')]=function(_0x1c0e02,_0x36bede){var _0x53108b={},_0x6f123={},_0x5a68b2={'count':0x0,'rows':[]};var _0x5bb6ea=_[_0x17bc('0x2f')](db['FreshsalesAccount']['rawAttributes'],function(_0x177cfb){return{'name':_0x177cfb[_0x17bc('0x30')],'type':_0x177cfb[_0x17bc('0x31')][_0x17bc('0x32')]};});_0x6f123[_0x17bc('0x33')]=_[_0x17bc('0x2f')](_0x5bb6ea,_0x17bc('0x2c'));_0x6f123[_0x17bc('0x34')]=_[_0x17bc('0x35')](_0x1c0e02[_0x17bc('0x34')]);_0x6f123['filters']=_[_0x17bc('0x36')](_0x6f123[_0x17bc('0x33')],_0x6f123[_0x17bc('0x34')]);_0x53108b[_0x17bc('0x37')]=_[_0x17bc('0x36')](_0x6f123['model'],qs[_0x17bc('0x38')](_0x1c0e02[_0x17bc('0x34')][_0x17bc('0x38')]));_0x53108b[_0x17bc('0x37')]=_0x53108b[_0x17bc('0x37')]['length']?_0x53108b[_0x17bc('0x37')]:_0x6f123[_0x17bc('0x33')];if(!_0x1c0e02['query'][_0x17bc('0x39')](_0x17bc('0x3a'))){_0x53108b[_0x17bc('0x1f')]=qs[_0x17bc('0x1f')](_0x1c0e02[_0x17bc('0x34')][_0x17bc('0x1f')]);_0x53108b[_0x17bc('0x21')]=qs[_0x17bc('0x21')](_0x1c0e02[_0x17bc('0x34')][_0x17bc('0x21')]);}_0x53108b[_0x17bc('0x3b')]=qs[_0x17bc('0x3c')](_0x1c0e02[_0x17bc('0x34')][_0x17bc('0x3c')]);_0x53108b[_0x17bc('0x3d')]=qs[_0x17bc('0x3e')](_[_0x17bc('0x3f')](_0x1c0e02['query'],_0x6f123['filters']),_0x5bb6ea);if(_0x1c0e02['query'][_0x17bc('0x40')]){_0x53108b[_0x17bc('0x3d')]=_['merge'](_0x53108b[_0x17bc('0x3d')],{'$or':_[_0x17bc('0x2f')](_0x5bb6ea,function(_0x464c87){if(_0x464c87[_0x17bc('0x31')]!==_0x17bc('0x41')){var _0x5bdb9f={};_0x5bdb9f[_0x464c87[_0x17bc('0x2c')]]={'$like':'%'+_0x1c0e02['query'][_0x17bc('0x40')]+'%'};return _0x5bdb9f;}})});}_0x53108b=_[_0x17bc('0x42')]({},_0x53108b,_0x1c0e02['options']);var _0xd3b777={'where':_0x53108b[_0x17bc('0x3d')]};return db[_0x17bc('0x43')][_0x17bc('0x20')](_0xd3b777)[_0x17bc('0x28')](function(_0x14933f){_0x5a68b2['count']=_0x14933f;if(_0x1c0e02[_0x17bc('0x34')][_0x17bc('0x44')]){_0x53108b[_0x17bc('0x45')]=[{'all':!![]}];}return db[_0x17bc('0x43')]['findAll'](_0x53108b);})[_0x17bc('0x28')](function(_0x2b4d5a){_0x5a68b2[_0x17bc('0x46')]=_0x2b4d5a;return _0x5a68b2;})[_0x17bc('0x28')](respondWithFilteredResult(_0x36bede,_0x53108b))[_0x17bc('0x47')](handleError(_0x36bede,null));};exports[_0x17bc('0x48')]=function(_0xeeb338,_0x3629b3){var _0x308a33={'raw':![],'where':{'id':_0xeeb338['params']['id']}},_0x1acdf6={};_0x1acdf6['model']=_[_0x17bc('0x35')](db[_0x17bc('0x43')]['rawAttributes']);_0x1acdf6[_0x17bc('0x34')]=_['keys'](_0xeeb338['query']);_0x1acdf6[_0x17bc('0x3e')]=_[_0x17bc('0x36')](_0x1acdf6[_0x17bc('0x33')],_0x1acdf6['query']);_0x308a33[_0x17bc('0x37')]=_[_0x17bc('0x36')](_0x1acdf6[_0x17bc('0x33')],qs['fields'](_0xeeb338[_0x17bc('0x34')][_0x17bc('0x38')]));_0x308a33['attributes']=_0x308a33[_0x17bc('0x37')]['length']?_0x308a33['attributes']:_0x1acdf6[_0x17bc('0x33')];if(_0xeeb338[_0x17bc('0x34')][_0x17bc('0x44')]){_0x308a33[_0x17bc('0x45')]=[{'all':!![]}];}_0x308a33=_[_0x17bc('0x42')]({},_0x308a33,_0xeeb338[_0x17bc('0x49')]);return db[_0x17bc('0x43')][_0x17bc('0x4a')](_0x308a33)[_0x17bc('0x28')](handleEntityNotFound(_0x3629b3,null))['then'](respondWithResult(_0x3629b3,null))[_0x17bc('0x47')](handleError(_0x3629b3,null));};exports[_0x17bc('0x4b')]=function(_0x568a57,_0x1b7311){return db[_0x17bc('0x43')][_0x17bc('0x4b')](_0x568a57['body'],{})[_0x17bc('0x28')](respondWithResult(_0x1b7311,0xc9))[_0x17bc('0x47')](handleError(_0x1b7311,null));};exports['update']=function(_0x15041,_0x28cab7){if(_0x15041[_0x17bc('0x4c')]['id']){delete _0x15041['body']['id'];}return db[_0x17bc('0x43')][_0x17bc('0x4a')]({'where':{'id':_0x15041[_0x17bc('0x4d')]['id']}})['then'](handleEntityNotFound(_0x28cab7,null))[_0x17bc('0x28')](saveUpdates(_0x15041['body'],null))[_0x17bc('0x28')](respondWithResult(_0x28cab7,null))[_0x17bc('0x47')](handleError(_0x28cab7,null));};exports['destroy']=function(_0x21ef8d,_0x59e3ad){return db[_0x17bc('0x43')]['find']({'where':{'id':_0x21ef8d[_0x17bc('0x4d')]['id']}})[_0x17bc('0x28')](handleEntityNotFound(_0x59e3ad,null))['then'](removeEntity(_0x59e3ad,null))[_0x17bc('0x47')](handleError(_0x59e3ad,null));};exports['getConfigurations']=function(_0x2cf2c7,_0x26e011,_0x42070f){var _0x284d59={};var _0x3dd492={};var _0xba6c2b;var _0x2bc503;return db[_0x17bc('0x43')][_0x17bc('0x4e')]({'where':{'id':_0x2cf2c7['params']['id']}})[_0x17bc('0x28')](handleEntityNotFound(_0x26e011,null))[_0x17bc('0x28')](function(_0x7e04dd){if(_0x7e04dd){_0xba6c2b=_0x7e04dd;_0x3dd492[_0x17bc('0x33')]=_['keys'](db['FreshsalesConfiguration'][_0x17bc('0x4f')]);_0x3dd492[_0x17bc('0x34')]=_[_0x17bc('0x35')](_0x2cf2c7[_0x17bc('0x34')]);_0x3dd492['filters']=_[_0x17bc('0x36')](_0x3dd492[_0x17bc('0x33')],_0x3dd492[_0x17bc('0x34')]);_0x284d59[_0x17bc('0x37')]=_[_0x17bc('0x36')](_0x3dd492[_0x17bc('0x33')],qs[_0x17bc('0x38')](_0x2cf2c7[_0x17bc('0x34')][_0x17bc('0x38')]));_0x284d59['attributes']=_0x284d59[_0x17bc('0x37')][_0x17bc('0x50')]?_0x284d59['attributes']:_0x3dd492[_0x17bc('0x33')];_0x284d59[_0x17bc('0x3b')]=qs[_0x17bc('0x3c')](_0x2cf2c7[_0x17bc('0x34')][_0x17bc('0x3c')]);_0x284d59[_0x17bc('0x3d')]=qs[_0x17bc('0x3e')](_[_0x17bc('0x3f')](_0x2cf2c7[_0x17bc('0x34')],_0x3dd492['filters']));if(_0x2cf2c7[_0x17bc('0x34')][_0x17bc('0x40')]){_0x284d59[_0x17bc('0x3d')]=_['merge'](_0x284d59[_0x17bc('0x3d')],{'$or':_['map'](_0x284d59[_0x17bc('0x37')],function(_0x29369a){var _0x358128={};_0x358128[_0x29369a]={'$like':'%'+_0x2cf2c7[_0x17bc('0x34')][_0x17bc('0x40')]+'%'};return _0x358128;})});}_0x284d59=_[_0x17bc('0x42')]({},_0x284d59,_0x2cf2c7[_0x17bc('0x49')]);return _0xba6c2b[_0x17bc('0x51')](_0x284d59);}})[_0x17bc('0x28')](function(_0x46e864){if(_0x46e864){_0x2bc503=_0x46e864['length'];if(!_0x2cf2c7[_0x17bc('0x34')][_0x17bc('0x39')](_0x17bc('0x3a'))){_0x284d59[_0x17bc('0x1f')]=qs[_0x17bc('0x1f')](_0x2cf2c7[_0x17bc('0x34')]['limit']);_0x284d59[_0x17bc('0x21')]=qs['offset'](_0x2cf2c7[_0x17bc('0x34')][_0x17bc('0x21')]);}return _0xba6c2b[_0x17bc('0x51')](_0x284d59);}})['then'](function(_0x44b0bd){if(_0x44b0bd){return _0x44b0bd?{'count':_0x2bc503,'rows':_0x44b0bd}:null;}})[_0x17bc('0x28')](respondWithResult(_0x26e011,null))[_0x17bc('0x47')](handleError(_0x26e011,null));};exports[_0x17bc('0x52')]=function(_0x5e6114,_0x34b669,_0x3fb0f3){if(_0x5e6114[_0x17bc('0x4c')]['id']){delete _0x5e6114[_0x17bc('0x4c')]['id'];}return db[_0x17bc('0x43')][_0x17bc('0x4e')]({'where':{'id':_0x5e6114[_0x17bc('0x4d')]['id']}})['then'](handleEntityNotFound(_0x34b669,null))[_0x17bc('0x28')](function(_0x2df9eb){if(_0x2df9eb){_0x5e6114[_0x17bc('0x4c')]['AccountId']=_0x2df9eb['id'];_0x5e6114[_0x17bc('0x4c')]['Subjects']=integrations[_0x17bc('0x53')](_0x5e6114['body']['channel'],_0x5e6114['body'][_0x17bc('0x31')]);_0x5e6114[_0x17bc('0x4c')][_0x17bc('0x54')]=integrations[_0x17bc('0x55')](_0x5e6114[_0x17bc('0x4c')][_0x17bc('0x56')],_0x5e6114['body'][_0x17bc('0x31')]);return db[_0x17bc('0x57')][_0x17bc('0x4b')](_0x5e6114['body'],{'include':[{'model':db[_0x17bc('0x58')],'as':'Subjects'},{'model':db[_0x17bc('0x58')],'as':_0x17bc('0x54')}]});}return null;})[_0x17bc('0x28')](respondWithResult(_0x34b669,null))[_0x17bc('0x47')](handleError(_0x34b669,null));};exports[_0x17bc('0x59')]=function(_0x36fef3,_0x3a21db,_0x1168ab){var _0x3c1f10='';var _0x1b0e77='';return db[_0x17bc('0x43')]['findOne']({'where':{'id':_0x36fef3[_0x17bc('0x4d')]['id']},'attributes':['id',_0x17bc('0x5a'),'remoteUri',_0x17bc('0x5b')]})[_0x17bc('0x28')](handleEntityNotFound(_0x3a21db,null))[_0x17bc('0x28')](function(_0x247e51){if(_0x247e51){_0x1b0e77=_0x247e51[_0x17bc('0x5a')];_0x3c1f10=_0x247e51[_0x17bc('0x5c')];var _0x57ffe7=_0x247e51['remoteUri'][_0x17bc('0x5d')](-0x1);if(_0x57ffe7==='/'){_0x3c1f10=_0x3c1f10[_0x17bc('0x5e')](0x0,_0x3c1f10['lastIndexOf'](_0x57ffe7));}return rp({'method':_0x17bc('0x5f'),'uri':util[_0x17bc('0x60')](_0x17bc('0x61'),_0x3c1f10,'/api/selector/owners'),'headers':{'Authorization':_0x17bc('0x62')+_0x247e51[_0x17bc('0x5b')]},'json':!![]});}})['then'](function(_0x3bd3fc){if(_0x3bd3fc){var _0x5e4550=_0x3bd3fc['users'];var _0x461cc=![];var _0x190c56=null;for(_0x190c56=0x0;_0x190c56<_0x5e4550['length'];_0x190c56++){if(_0x5e4550[_0x190c56][_0x17bc('0x63')]===_0x1b0e77){_0x461cc=!![];}}if(_0x461cc){return!![];}else{throw new Error({'statusCode':0x194,'message':_0x17bc('0x64')});}}})[_0x17bc('0x28')](respondWithResult(_0x3a21db,null))[_0x17bc('0x47')](function(_0x53e1bc){var _0x318fc0=_0x36fef3['query'][_0x17bc('0x65')]?0x1f4:_0x53e1bc[_0x17bc('0x66')]||0x1f4;logger[_0x17bc('0x2a')](_0x17bc('0x67'),_0x17bc('0x59'),_0x318fc0,JSON[_0x17bc('0x68')](_0x53e1bc));delete _0x53e1bc['name'];if(_0x318fc0===0x191){_0x318fc0=0x190;}_0x3a21db[_0x17bc('0x1c')](_0x318fc0)[_0x17bc('0x2d')](_0x36fef3[_0x17bc('0x34')][_0x17bc('0x65')]?{'message':_0x17bc('0x69'),'statusCode':_0x53e1bc[_0x17bc('0x66')]}:_0x53e1bc);});};
\ No newline at end of file