Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / intFreshsalesAccount / intFreshsalesAccount.controller.js
index f42faa7..4297925 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x834a=['intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','merge','type','VIRTUAL','filter','options','includeAll','include','rows','catch','show','rawAttributes','find','create','body','update','params','destroy','FreshsalesConfiguration','pick','getConfigurations','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','FreshsalesField','getFields','username','remoteUri','apiKey','slice','substring','lastIndexOf','GET','format','/api/selector/owners','Token\x20token=','users','email','Requested\x20Resource\x20not\x20Found','getFields,\x20%s,\x20%s,\x20%s','test','Wrong\x20credentials','eml-format','rimraf','fast-json-patch','request-promise','bluebird','util','path','to-csv','ejs','fs-extra','lodash','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','reject','save','then','error','name','send','index','FreshsalesAccount','fieldName','model','map','query','keys','filters','attributes'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0x834a,0xfd));var _0xa834=function(_0x502dae,_0x23b6b7){_0x502dae=_0x502dae-0x0;var _0x50ecf2=_0x834a[_0x502dae];return _0x50ecf2;};'use strict';var emlformat=require(_0xa834('0x0'));var rimraf=require(_0xa834('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa834('0x2'));var rp=require(_0xa834('0x3'));var moment=require('moment');var BPromise=require(_0xa834('0x4'));var Mustache=require('mustache');var util=require(_0xa834('0x5'));var path=require(_0xa834('0x6'));var sox=require('sox');var csv=require(_0xa834('0x7'));var ejs=require(_0xa834('0x8'));var fs=require('fs');var fs_extra=require(_0xa834('0x9'));var _=require(_0xa834('0xa'));var squel=require('squel');var crypto=require(_0xa834('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xa834('0x7'));var querystring=require(_0xa834('0xc'));var Papa=require(_0xa834('0xd'));var Redis=require(_0xa834('0xe'));var authService=require(_0xa834('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xa834('0x10'));var hardwareService=require(_0xa834('0x11'));var logger=require(_0xa834('0x12'))('api');var utils=require('../../config/utils');var config=require(_0xa834('0x13'));var licenseUtil=require(_0xa834('0x14'));var db=require(_0xa834('0x15'))['db'];var integrations=require(_0xa834('0x16'));function respondWithStatusCode(_0x1c7c49,_0x70d08b){_0x70d08b=_0x70d08b||0xcc;return function(_0x1ed6fd){if(_0x1ed6fd){return _0x1c7c49[_0xa834('0x17')](_0x70d08b);}return _0x1c7c49[_0xa834('0x18')](_0x70d08b)[_0xa834('0x19')]();};}function respondWithResult(_0x1975a9,_0xfc018d){_0xfc018d=_0xfc018d||0xc8;return function(_0x398b72){if(_0x398b72){return _0x1975a9['status'](_0xfc018d)[_0xa834('0x1a')](_0x398b72);}};}function respondWithFilteredResult(_0x22f765,_0x155f5a){return function(_0x1968df){if(_0x1968df){var _0x4c331b=typeof _0x155f5a[_0xa834('0x1b')]===_0xa834('0x1c')&&typeof _0x155f5a[_0xa834('0x1d')]===_0xa834('0x1c');var _0x1c352f=_0x1968df[_0xa834('0x1e')];var _0x236c6a=_0x4c331b?0x0:_0x155f5a[_0xa834('0x1b')];var _0x26d563=_0x4c331b?_0x1968df[_0xa834('0x1e')]:_0x155f5a[_0xa834('0x1b')]+_0x155f5a['limit'];var _0x4e1b3e;if(_0x26d563>=_0x1c352f){_0x26d563=_0x1c352f;_0x4e1b3e=0xc8;}else{_0x4e1b3e=0xce;}_0x22f765['status'](_0x4e1b3e);return _0x22f765['set'](_0xa834('0x1f'),_0x236c6a+'-'+_0x26d563+'/'+_0x1c352f)['json'](_0x1968df);}return null;};}function patchUpdates(_0x9626d7){return function(_0x442074){try{jsonpatch['apply'](_0x442074,_0x9626d7,!![]);}catch(_0x4ec6dc){return BPromise[_0xa834('0x20')](_0x4ec6dc);}return _0x442074[_0xa834('0x21')]();};}function saveUpdates(_0x478ebc,_0x47a32a){return function(_0x23a534){if(_0x23a534){return _0x23a534['update'](_0x478ebc)[_0xa834('0x22')](function(_0x58848d){return _0x58848d;});}return null;};}function removeEntity(_0x14da24,_0x29867f){return function(_0x4bad96){if(_0x4bad96){return _0x4bad96['destroy']()[_0xa834('0x22')](function(){_0x14da24[_0xa834('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4337d9,_0x1657c6){return function(_0x1cf3b1){if(!_0x1cf3b1){_0x4337d9[_0xa834('0x17')](0x194);}return _0x1cf3b1;};}function handleError(_0x3bc424,_0x306261){_0x306261=_0x306261||0x1f4;return function(_0x37e16d){logger[_0xa834('0x23')](_0x37e16d['stack']);if(_0x37e16d['name']){delete _0x37e16d[_0xa834('0x24')];}_0x3bc424['status'](_0x306261)[_0xa834('0x25')](_0x37e16d);};}exports[_0xa834('0x26')]=function(_0x4f7fe0,_0x1e94d3){var _0x4b71bb={},_0x2fb8e1={},_0x59c6cb={'count':0x0,'rows':[]};var _0x4decce=_['map'](db[_0xa834('0x27')]['rawAttributes'],function(_0x36a998){return{'name':_0x36a998[_0xa834('0x28')],'type':_0x36a998['type']['key']};});_0x2fb8e1[_0xa834('0x29')]=_[_0xa834('0x2a')](_0x4decce,_0xa834('0x24'));_0x2fb8e1[_0xa834('0x2b')]=_[_0xa834('0x2c')](_0x4f7fe0[_0xa834('0x2b')]);_0x2fb8e1[_0xa834('0x2d')]=_['intersection'](_0x2fb8e1['model'],_0x2fb8e1[_0xa834('0x2b')]);_0x4b71bb[_0xa834('0x2e')]=_[_0xa834('0x2f')](_0x2fb8e1['model'],qs[_0xa834('0x30')](_0x4f7fe0[_0xa834('0x2b')][_0xa834('0x30')]));_0x4b71bb['attributes']=_0x4b71bb['attributes'][_0xa834('0x31')]?_0x4b71bb[_0xa834('0x2e')]:_0x2fb8e1['model'];if(!_0x4f7fe0[_0xa834('0x2b')][_0xa834('0x32')](_0xa834('0x33'))){_0x4b71bb[_0xa834('0x1d')]=qs[_0xa834('0x1d')](_0x4f7fe0[_0xa834('0x2b')][_0xa834('0x1d')]);_0x4b71bb['offset']=qs[_0xa834('0x1b')](_0x4f7fe0[_0xa834('0x2b')]['offset']);}_0x4b71bb[_0xa834('0x34')]=qs['sort'](_0x4f7fe0[_0xa834('0x2b')][_0xa834('0x35')]);_0x4b71bb[_0xa834('0x36')]=qs[_0xa834('0x2d')](_['pick'](_0x4f7fe0['query'],_0x2fb8e1[_0xa834('0x2d')]),_0x4decce);if(_0x4f7fe0[_0xa834('0x2b')]['filter']){_0x4b71bb[_0xa834('0x36')]=_[_0xa834('0x37')](_0x4b71bb['where'],{'$or':_[_0xa834('0x2a')](_0x4decce,function(_0x3f6fd5){if(_0x3f6fd5[_0xa834('0x38')]!==_0xa834('0x39')){var _0x3c3c1b={};_0x3c3c1b[_0x3f6fd5[_0xa834('0x24')]]={'$like':'%'+_0x4f7fe0[_0xa834('0x2b')][_0xa834('0x3a')]+'%'};return _0x3c3c1b;}})});}_0x4b71bb=_['merge']({},_0x4b71bb,_0x4f7fe0[_0xa834('0x3b')]);var _0x5e80ab={'where':_0x4b71bb[_0xa834('0x36')]};return db['FreshsalesAccount'][_0xa834('0x1e')](_0x5e80ab)[_0xa834('0x22')](function(_0x5bfa29){_0x59c6cb[_0xa834('0x1e')]=_0x5bfa29;if(_0x4f7fe0[_0xa834('0x2b')][_0xa834('0x3c')]){_0x4b71bb[_0xa834('0x3d')]=[{'all':!![]}];}return db[_0xa834('0x27')]['findAll'](_0x4b71bb);})[_0xa834('0x22')](function(_0x7571c7){_0x59c6cb[_0xa834('0x3e')]=_0x7571c7;return _0x59c6cb;})[_0xa834('0x22')](respondWithFilteredResult(_0x1e94d3,_0x4b71bb))[_0xa834('0x3f')](handleError(_0x1e94d3,null));};exports[_0xa834('0x40')]=function(_0x179bfb,_0x392bfc){var _0x5c979f={'raw':![],'where':{'id':_0x179bfb['params']['id']}},_0x2b41c9={};_0x2b41c9[_0xa834('0x29')]=_[_0xa834('0x2c')](db[_0xa834('0x27')][_0xa834('0x41')]);_0x2b41c9[_0xa834('0x2b')]=_[_0xa834('0x2c')](_0x179bfb[_0xa834('0x2b')]);_0x2b41c9['filters']=_[_0xa834('0x2f')](_0x2b41c9[_0xa834('0x29')],_0x2b41c9[_0xa834('0x2b')]);_0x5c979f[_0xa834('0x2e')]=_[_0xa834('0x2f')](_0x2b41c9[_0xa834('0x29')],qs[_0xa834('0x30')](_0x179bfb['query']['fields']));_0x5c979f['attributes']=_0x5c979f[_0xa834('0x2e')][_0xa834('0x31')]?_0x5c979f[_0xa834('0x2e')]:_0x2b41c9[_0xa834('0x29')];if(_0x179bfb[_0xa834('0x2b')][_0xa834('0x3c')]){_0x5c979f[_0xa834('0x3d')]=[{'all':!![]}];}_0x5c979f=_[_0xa834('0x37')]({},_0x5c979f,_0x179bfb[_0xa834('0x3b')]);return db[_0xa834('0x27')][_0xa834('0x42')](_0x5c979f)[_0xa834('0x22')](handleEntityNotFound(_0x392bfc,null))[_0xa834('0x22')](respondWithResult(_0x392bfc,null))[_0xa834('0x3f')](handleError(_0x392bfc,null));};exports[_0xa834('0x43')]=function(_0x411e96,_0x49e629){return db[_0xa834('0x27')][_0xa834('0x43')](_0x411e96[_0xa834('0x44')],{})[_0xa834('0x22')](respondWithResult(_0x49e629,0xc9))[_0xa834('0x3f')](handleError(_0x49e629,null));};exports[_0xa834('0x45')]=function(_0x5df594,_0x53cf50){if(_0x5df594[_0xa834('0x44')]['id']){delete _0x5df594['body']['id'];}return db[_0xa834('0x27')][_0xa834('0x42')]({'where':{'id':_0x5df594[_0xa834('0x46')]['id']}})[_0xa834('0x22')](handleEntityNotFound(_0x53cf50,null))[_0xa834('0x22')](saveUpdates(_0x5df594[_0xa834('0x44')],null))[_0xa834('0x22')](respondWithResult(_0x53cf50,null))[_0xa834('0x3f')](handleError(_0x53cf50,null));};exports[_0xa834('0x47')]=function(_0x59a15e,_0x570428){return db[_0xa834('0x27')][_0xa834('0x42')]({'where':{'id':_0x59a15e[_0xa834('0x46')]['id']}})[_0xa834('0x22')](handleEntityNotFound(_0x570428,null))[_0xa834('0x22')](removeEntity(_0x570428,null))[_0xa834('0x3f')](handleError(_0x570428,null));};exports['getConfigurations']=function(_0x7d7e14,_0x3f103e,_0x3a717c){var _0x9e28b7={};var _0x11e1d6={};var _0x15da7c;var _0x32fb39;return db[_0xa834('0x27')]['findOne']({'where':{'id':_0x7d7e14[_0xa834('0x46')]['id']}})[_0xa834('0x22')](handleEntityNotFound(_0x3f103e,null))[_0xa834('0x22')](function(_0x292585){if(_0x292585){_0x15da7c=_0x292585;_0x11e1d6['model']=_['keys'](db[_0xa834('0x48')][_0xa834('0x41')]);_0x11e1d6[_0xa834('0x2b')]=_[_0xa834('0x2c')](_0x7d7e14[_0xa834('0x2b')]);_0x11e1d6[_0xa834('0x2d')]=_[_0xa834('0x2f')](_0x11e1d6[_0xa834('0x29')],_0x11e1d6[_0xa834('0x2b')]);_0x9e28b7[_0xa834('0x2e')]=_[_0xa834('0x2f')](_0x11e1d6[_0xa834('0x29')],qs[_0xa834('0x30')](_0x7d7e14[_0xa834('0x2b')]['fields']));_0x9e28b7[_0xa834('0x2e')]=_0x9e28b7[_0xa834('0x2e')][_0xa834('0x31')]?_0x9e28b7[_0xa834('0x2e')]:_0x11e1d6[_0xa834('0x29')];_0x9e28b7[_0xa834('0x34')]=qs[_0xa834('0x35')](_0x7d7e14[_0xa834('0x2b')][_0xa834('0x35')]);_0x9e28b7['where']=qs[_0xa834('0x2d')](_[_0xa834('0x49')](_0x7d7e14['query'],_0x11e1d6[_0xa834('0x2d')]));if(_0x7d7e14[_0xa834('0x2b')][_0xa834('0x3a')]){_0x9e28b7[_0xa834('0x36')]=_[_0xa834('0x37')](_0x9e28b7[_0xa834('0x36')],{'$or':_[_0xa834('0x2a')](_0x9e28b7[_0xa834('0x2e')],function(_0x19498d){var _0x2c01f4={};_0x2c01f4[_0x19498d]={'$like':'%'+_0x7d7e14['query'][_0xa834('0x3a')]+'%'};return _0x2c01f4;})});}_0x9e28b7=_[_0xa834('0x37')]({},_0x9e28b7,_0x7d7e14[_0xa834('0x3b')]);return _0x15da7c[_0xa834('0x4a')](_0x9e28b7);}})[_0xa834('0x22')](function(_0x449c71){if(_0x449c71){_0x32fb39=_0x449c71[_0xa834('0x31')];if(!_0x7d7e14[_0xa834('0x2b')][_0xa834('0x32')](_0xa834('0x33'))){_0x9e28b7[_0xa834('0x1d')]=qs['limit'](_0x7d7e14[_0xa834('0x2b')]['limit']);_0x9e28b7[_0xa834('0x1b')]=qs[_0xa834('0x1b')](_0x7d7e14[_0xa834('0x2b')][_0xa834('0x1b')]);}return _0x15da7c[_0xa834('0x4a')](_0x9e28b7);}})['then'](function(_0x1f02af){if(_0x1f02af){return _0x1f02af?{'count':_0x32fb39,'rows':_0x1f02af}:null;}})[_0xa834('0x22')](respondWithResult(_0x3f103e,null))[_0xa834('0x3f')](handleError(_0x3f103e,null));};exports[_0xa834('0x4b')]=function(_0x959031,_0x502480,_0x4c8f71){if(_0x959031[_0xa834('0x44')]['id']){delete _0x959031['body']['id'];}return db[_0xa834('0x27')]['findOne']({'where':{'id':_0x959031['params']['id']}})['then'](handleEntityNotFound(_0x502480,null))[_0xa834('0x22')](function(_0x48c4c6){if(_0x48c4c6){_0x959031[_0xa834('0x44')][_0xa834('0x4c')]=_0x48c4c6['id'];_0x959031[_0xa834('0x44')][_0xa834('0x4d')]=integrations[_0xa834('0x4e')](_0x959031['body'][_0xa834('0x4f')],_0x959031[_0xa834('0x44')][_0xa834('0x38')]);_0x959031['body'][_0xa834('0x50')]=integrations[_0xa834('0x51')](_0x959031[_0xa834('0x44')][_0xa834('0x4f')],_0x959031[_0xa834('0x44')][_0xa834('0x38')]);return db[_0xa834('0x48')][_0xa834('0x43')](_0x959031[_0xa834('0x44')],{'include':[{'model':db[_0xa834('0x52')],'as':_0xa834('0x4d')},{'model':db['FreshsalesField'],'as':_0xa834('0x50')}]});}return null;})[_0xa834('0x22')](respondWithResult(_0x502480,null))[_0xa834('0x3f')](handleError(_0x502480,null));};exports[_0xa834('0x53')]=function(_0x42c753,_0x1a995d,_0x5d8558){var _0x43976f='';var _0x35abb6='';return db[_0xa834('0x27')]['findOne']({'where':{'id':_0x42c753[_0xa834('0x46')]['id']},'attributes':['id',_0xa834('0x54'),_0xa834('0x55'),_0xa834('0x56')]})[_0xa834('0x22')](handleEntityNotFound(_0x1a995d,null))[_0xa834('0x22')](function(_0x4f93a0){if(_0x4f93a0){_0x35abb6=_0x4f93a0[_0xa834('0x54')];_0x43976f=_0x4f93a0[_0xa834('0x55')];var _0x155a40=_0x4f93a0[_0xa834('0x55')][_0xa834('0x57')](-0x1);if(_0x155a40==='/'){_0x43976f=_0x43976f[_0xa834('0x58')](0x0,_0x43976f[_0xa834('0x59')](_0x155a40));}return rp({'method':_0xa834('0x5a'),'uri':util[_0xa834('0x5b')]('%s%s',_0x43976f,_0xa834('0x5c')),'headers':{'Authorization':_0xa834('0x5d')+_0x4f93a0[_0xa834('0x56')]},'json':!![]});}})[_0xa834('0x22')](function(_0x4218ee){if(_0x4218ee){var _0x4860e4=_0x4218ee[_0xa834('0x5e')];var _0x3d2c8a=![];var _0x1df43f=null;for(_0x1df43f=0x0;_0x1df43f<_0x4860e4[_0xa834('0x31')];_0x1df43f++){if(_0x4860e4[_0x1df43f][_0xa834('0x5f')]===_0x35abb6){_0x3d2c8a=!![];}}if(_0x3d2c8a){return!![];}else{throw new Error({'statusCode':0x194,'message':_0xa834('0x60')});}}})[_0xa834('0x22')](respondWithResult(_0x1a995d,null))[_0xa834('0x3f')](function(_0x2f02a6){var _0x41b925=_0x42c753[_0xa834('0x2b')]['test']?0x1f4:_0x2f02a6['statusCode']||0x1f4;logger[_0xa834('0x23')](_0xa834('0x61'),_0xa834('0x53'),_0x41b925,JSON['stringify'](_0x2f02a6));delete _0x2f02a6[_0xa834('0x24')];if(_0x41b925===0x191){_0x41b925=0x190;}_0x1a995d[_0xa834('0x18')](_0x41b925)[_0xa834('0x25')](_0x42c753[_0xa834('0x2b')][_0xa834('0x62')]?{'message':_0xa834('0x63'),'statusCode':_0x2f02a6['statusCode']}:_0x2f02a6);});};
\ No newline at end of file
+var _0x4c6f=['options','findAll','rows','catch','show','params','includeAll','find','create','body','findOne','FreshsalesConfiguration','order','getConfigurations','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','FreshsalesField','username','apiKey','remoteUri','slice','substring','lastIndexOf','format','/api/selector/owners','Token\x20token=','users','email','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','getFields','stringify','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','status','json','offset','undefined','limit','count','apply','reject','save','update','destroy','then','sendStatus','error','stack','name','send','index','map','FreshsalesAccount','rawAttributes','type','key','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL'];(function(_0x47df54,_0x1aeb61){var _0x261b87=function(_0x54bc77){while(--_0x54bc77){_0x47df54['push'](_0x47df54['shift']());}};_0x261b87(++_0x1aeb61);}(_0x4c6f,0x157));var _0xf4c6=function(_0x5e1e25,_0xdc1421){_0x5e1e25=_0x5e1e25-0x0;var _0x548e5f=_0x4c6f[_0x5e1e25];return _0x548e5f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf4c6('0x0'));var zipdir=require(_0xf4c6('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf4c6('0x2'));var moment=require(_0xf4c6('0x3'));var BPromise=require(_0xf4c6('0x4'));var Mustache=require(_0xf4c6('0x5'));var util=require(_0xf4c6('0x6'));var path=require(_0xf4c6('0x7'));var sox=require('sox');var csv=require(_0xf4c6('0x8'));var ejs=require(_0xf4c6('0x9'));var fs=require('fs');var fs_extra=require(_0xf4c6('0xa'));var _=require(_0xf4c6('0xb'));var squel=require(_0xf4c6('0xc'));var crypto=require('crypto');var jsforce=require(_0xf4c6('0xd'));var deskjs=require(_0xf4c6('0xe'));var toCsv=require(_0xf4c6('0x8'));var querystring=require('querystring');var Papa=require(_0xf4c6('0xf'));var Redis=require(_0xf4c6('0x10'));var authService=require(_0xf4c6('0x11'));var qs=require(_0xf4c6('0x12'));var as=require(_0xf4c6('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xf4c6('0x14'));var utils=require(_0xf4c6('0x15'));var config=require(_0xf4c6('0x16'));var licenseUtil=require(_0xf4c6('0x17'));var db=require(_0xf4c6('0x18'))['db'];var integrations=require(_0xf4c6('0x19'));function respondWithStatusCode(_0x2b3fc5,_0x391c8f){_0x391c8f=_0x391c8f||0xcc;return function(_0x13fd11){if(_0x13fd11){return _0x2b3fc5['sendStatus'](_0x391c8f);}return _0x2b3fc5[_0xf4c6('0x1a')](_0x391c8f)['end']();};}function respondWithResult(_0xe0f86b,_0x5edec9){_0x5edec9=_0x5edec9||0xc8;return function(_0x5cde4a){if(_0x5cde4a){return _0xe0f86b[_0xf4c6('0x1a')](_0x5edec9)[_0xf4c6('0x1b')](_0x5cde4a);}};}function respondWithFilteredResult(_0x466a66,_0x30fd34){return function(_0x290b98){if(_0x290b98){var _0x5582fa=typeof _0x30fd34[_0xf4c6('0x1c')]===_0xf4c6('0x1d')&&typeof _0x30fd34[_0xf4c6('0x1e')]==='undefined';var _0x180003=_0x290b98[_0xf4c6('0x1f')];var _0x271c45=_0x5582fa?0x0:_0x30fd34['offset'];var _0x3740b3=_0x5582fa?_0x290b98[_0xf4c6('0x1f')]:_0x30fd34[_0xf4c6('0x1c')]+_0x30fd34[_0xf4c6('0x1e')];var _0x1b9279;if(_0x3740b3>=_0x180003){_0x3740b3=_0x180003;_0x1b9279=0xc8;}else{_0x1b9279=0xce;}_0x466a66[_0xf4c6('0x1a')](_0x1b9279);return _0x466a66['set']('Content-Range',_0x271c45+'-'+_0x3740b3+'/'+_0x180003)['json'](_0x290b98);}return null;};}function patchUpdates(_0x24e5f4){return function(_0x160394){try{jsonpatch[_0xf4c6('0x20')](_0x160394,_0x24e5f4,!![]);}catch(_0x4dc258){return BPromise[_0xf4c6('0x21')](_0x4dc258);}return _0x160394[_0xf4c6('0x22')]();};}function saveUpdates(_0x5e79ab,_0x6b20b){return function(_0xd5691a){if(_0xd5691a){return _0xd5691a[_0xf4c6('0x23')](_0x5e79ab)['then'](function(_0x5c7fbd){return _0x5c7fbd;});}return null;};}function removeEntity(_0x1453c,_0x126c33){return function(_0x3ac0e9){if(_0x3ac0e9){return _0x3ac0e9[_0xf4c6('0x24')]()[_0xf4c6('0x25')](function(){_0x1453c[_0xf4c6('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x21d260,_0x45f678){return function(_0x50f16f){if(!_0x50f16f){_0x21d260[_0xf4c6('0x26')](0x194);}return _0x50f16f;};}function handleError(_0x31874d,_0x30f0db){_0x30f0db=_0x30f0db||0x1f4;return function(_0xde436a){logger[_0xf4c6('0x27')](_0xde436a[_0xf4c6('0x28')]);if(_0xde436a[_0xf4c6('0x29')]){delete _0xde436a[_0xf4c6('0x29')];}_0x31874d[_0xf4c6('0x1a')](_0x30f0db)[_0xf4c6('0x2a')](_0xde436a);};}exports[_0xf4c6('0x2b')]=function(_0x18ac4c,_0xdde7d8){var _0x1d03e2={},_0x1a6235={},_0x2dc0b1={'count':0x0,'rows':[]};var _0x4afc82=_[_0xf4c6('0x2c')](db[_0xf4c6('0x2d')][_0xf4c6('0x2e')],function(_0x339762){return{'name':_0x339762['fieldName'],'type':_0x339762[_0xf4c6('0x2f')][_0xf4c6('0x30')]};});_0x1a6235[_0xf4c6('0x31')]=_[_0xf4c6('0x2c')](_0x4afc82,_0xf4c6('0x29'));_0x1a6235['query']=_[_0xf4c6('0x32')](_0x18ac4c[_0xf4c6('0x33')]);_0x1a6235[_0xf4c6('0x34')]=_['intersection'](_0x1a6235[_0xf4c6('0x31')],_0x1a6235[_0xf4c6('0x33')]);_0x1d03e2[_0xf4c6('0x35')]=_[_0xf4c6('0x36')](_0x1a6235[_0xf4c6('0x31')],qs['fields'](_0x18ac4c['query'][_0xf4c6('0x37')]));_0x1d03e2[_0xf4c6('0x35')]=_0x1d03e2[_0xf4c6('0x35')][_0xf4c6('0x38')]?_0x1d03e2[_0xf4c6('0x35')]:_0x1a6235['model'];if(!_0x18ac4c[_0xf4c6('0x33')][_0xf4c6('0x39')](_0xf4c6('0x3a'))){_0x1d03e2['limit']=qs['limit'](_0x18ac4c[_0xf4c6('0x33')][_0xf4c6('0x1e')]);_0x1d03e2[_0xf4c6('0x1c')]=qs[_0xf4c6('0x1c')](_0x18ac4c[_0xf4c6('0x33')]['offset']);}_0x1d03e2['order']=qs[_0xf4c6('0x3b')](_0x18ac4c[_0xf4c6('0x33')]['sort']);_0x1d03e2[_0xf4c6('0x3c')]=qs[_0xf4c6('0x34')](_[_0xf4c6('0x3d')](_0x18ac4c['query'],_0x1a6235[_0xf4c6('0x34')]),_0x4afc82);if(_0x18ac4c['query'][_0xf4c6('0x3e')]){_0x1d03e2[_0xf4c6('0x3c')]=_[_0xf4c6('0x3f')](_0x1d03e2[_0xf4c6('0x3c')],{'$or':_[_0xf4c6('0x2c')](_0x4afc82,function(_0x14f3e6){if(_0x14f3e6[_0xf4c6('0x2f')]!==_0xf4c6('0x40')){var _0x216017={};_0x216017[_0x14f3e6[_0xf4c6('0x29')]]={'$like':'%'+_0x18ac4c[_0xf4c6('0x33')][_0xf4c6('0x3e')]+'%'};return _0x216017;}})});}_0x1d03e2=_[_0xf4c6('0x3f')]({},_0x1d03e2,_0x18ac4c[_0xf4c6('0x41')]);var _0x301417={'where':_0x1d03e2[_0xf4c6('0x3c')]};return db[_0xf4c6('0x2d')][_0xf4c6('0x1f')](_0x301417)[_0xf4c6('0x25')](function(_0xe6773b){_0x2dc0b1[_0xf4c6('0x1f')]=_0xe6773b;if(_0x18ac4c[_0xf4c6('0x33')]['includeAll']){_0x1d03e2['include']=[{'all':!![]}];}return db[_0xf4c6('0x2d')][_0xf4c6('0x42')](_0x1d03e2);})['then'](function(_0x3f18b0){_0x2dc0b1[_0xf4c6('0x43')]=_0x3f18b0;return _0x2dc0b1;})['then'](respondWithFilteredResult(_0xdde7d8,_0x1d03e2))[_0xf4c6('0x44')](handleError(_0xdde7d8,null));};exports[_0xf4c6('0x45')]=function(_0x355bcc,_0x38329a){var _0x33b292={'raw':![],'where':{'id':_0x355bcc[_0xf4c6('0x46')]['id']}},_0x2ef48f={};_0x2ef48f[_0xf4c6('0x31')]=_[_0xf4c6('0x32')](db[_0xf4c6('0x2d')][_0xf4c6('0x2e')]);_0x2ef48f['query']=_['keys'](_0x355bcc['query']);_0x2ef48f[_0xf4c6('0x34')]=_['intersection'](_0x2ef48f[_0xf4c6('0x31')],_0x2ef48f[_0xf4c6('0x33')]);_0x33b292[_0xf4c6('0x35')]=_[_0xf4c6('0x36')](_0x2ef48f[_0xf4c6('0x31')],qs[_0xf4c6('0x37')](_0x355bcc[_0xf4c6('0x33')]['fields']));_0x33b292[_0xf4c6('0x35')]=_0x33b292[_0xf4c6('0x35')][_0xf4c6('0x38')]?_0x33b292[_0xf4c6('0x35')]:_0x2ef48f[_0xf4c6('0x31')];if(_0x355bcc[_0xf4c6('0x33')][_0xf4c6('0x47')]){_0x33b292['include']=[{'all':!![]}];}_0x33b292=_[_0xf4c6('0x3f')]({},_0x33b292,_0x355bcc[_0xf4c6('0x41')]);return db[_0xf4c6('0x2d')][_0xf4c6('0x48')](_0x33b292)[_0xf4c6('0x25')](handleEntityNotFound(_0x38329a,null))[_0xf4c6('0x25')](respondWithResult(_0x38329a,null))[_0xf4c6('0x44')](handleError(_0x38329a,null));};exports['create']=function(_0x34a7c0,_0x59b09){return db[_0xf4c6('0x2d')][_0xf4c6('0x49')](_0x34a7c0['body'],{})['then'](respondWithResult(_0x59b09,0xc9))[_0xf4c6('0x44')](handleError(_0x59b09,null));};exports[_0xf4c6('0x23')]=function(_0x128e34,_0x10ecd6){if(_0x128e34[_0xf4c6('0x4a')]['id']){delete _0x128e34['body']['id'];}return db['FreshsalesAccount'][_0xf4c6('0x48')]({'where':{'id':_0x128e34[_0xf4c6('0x46')]['id']}})[_0xf4c6('0x25')](handleEntityNotFound(_0x10ecd6,null))['then'](saveUpdates(_0x128e34[_0xf4c6('0x4a')],null))[_0xf4c6('0x25')](respondWithResult(_0x10ecd6,null))[_0xf4c6('0x44')](handleError(_0x10ecd6,null));};exports['destroy']=function(_0x17469f,_0x5b607c){return db[_0xf4c6('0x2d')][_0xf4c6('0x48')]({'where':{'id':_0x17469f['params']['id']}})[_0xf4c6('0x25')](handleEntityNotFound(_0x5b607c,null))['then'](removeEntity(_0x5b607c,null))[_0xf4c6('0x44')](handleError(_0x5b607c,null));};exports['getConfigurations']=function(_0xc1651d,_0x26b971,_0x362d05){var _0x1c37c0={};var _0x264085={};var _0x313e94;var _0x154f7c;return db['FreshsalesAccount'][_0xf4c6('0x4b')]({'where':{'id':_0xc1651d[_0xf4c6('0x46')]['id']}})[_0xf4c6('0x25')](handleEntityNotFound(_0x26b971,null))[_0xf4c6('0x25')](function(_0x1e7fdb){if(_0x1e7fdb){_0x313e94=_0x1e7fdb;_0x264085['model']=_['keys'](db[_0xf4c6('0x4c')][_0xf4c6('0x2e')]);_0x264085[_0xf4c6('0x33')]=_['keys'](_0xc1651d[_0xf4c6('0x33')]);_0x264085[_0xf4c6('0x34')]=_['intersection'](_0x264085[_0xf4c6('0x31')],_0x264085[_0xf4c6('0x33')]);_0x1c37c0['attributes']=_[_0xf4c6('0x36')](_0x264085[_0xf4c6('0x31')],qs[_0xf4c6('0x37')](_0xc1651d['query']['fields']));_0x1c37c0['attributes']=_0x1c37c0[_0xf4c6('0x35')][_0xf4c6('0x38')]?_0x1c37c0[_0xf4c6('0x35')]:_0x264085[_0xf4c6('0x31')];_0x1c37c0[_0xf4c6('0x4d')]=qs[_0xf4c6('0x3b')](_0xc1651d[_0xf4c6('0x33')][_0xf4c6('0x3b')]);_0x1c37c0[_0xf4c6('0x3c')]=qs[_0xf4c6('0x34')](_[_0xf4c6('0x3d')](_0xc1651d[_0xf4c6('0x33')],_0x264085['filters']));if(_0xc1651d[_0xf4c6('0x33')][_0xf4c6('0x3e')]){_0x1c37c0[_0xf4c6('0x3c')]=_[_0xf4c6('0x3f')](_0x1c37c0[_0xf4c6('0x3c')],{'$or':_[_0xf4c6('0x2c')](_0x1c37c0[_0xf4c6('0x35')],function(_0x804bfa){var _0x119235={};_0x119235[_0x804bfa]={'$like':'%'+_0xc1651d['query'][_0xf4c6('0x3e')]+'%'};return _0x119235;})});}_0x1c37c0=_[_0xf4c6('0x3f')]({},_0x1c37c0,_0xc1651d[_0xf4c6('0x41')]);return _0x313e94['getConfigurations'](_0x1c37c0);}})[_0xf4c6('0x25')](function(_0x233417){if(_0x233417){_0x154f7c=_0x233417['length'];if(!_0xc1651d[_0xf4c6('0x33')][_0xf4c6('0x39')](_0xf4c6('0x3a'))){_0x1c37c0[_0xf4c6('0x1e')]=qs['limit'](_0xc1651d['query'][_0xf4c6('0x1e')]);_0x1c37c0['offset']=qs[_0xf4c6('0x1c')](_0xc1651d['query'][_0xf4c6('0x1c')]);}return _0x313e94[_0xf4c6('0x4e')](_0x1c37c0);}})['then'](function(_0x5ca79a){if(_0x5ca79a){return _0x5ca79a?{'count':_0x154f7c,'rows':_0x5ca79a}:null;}})['then'](respondWithResult(_0x26b971,null))[_0xf4c6('0x44')](handleError(_0x26b971,null));};exports[_0xf4c6('0x4f')]=function(_0x47a5b9,_0x51609f,_0x473aad){if(_0x47a5b9[_0xf4c6('0x4a')]['id']){delete _0x47a5b9[_0xf4c6('0x4a')]['id'];}return db[_0xf4c6('0x2d')][_0xf4c6('0x4b')]({'where':{'id':_0x47a5b9[_0xf4c6('0x46')]['id']}})['then'](handleEntityNotFound(_0x51609f,null))[_0xf4c6('0x25')](function(_0x452bdf){if(_0x452bdf){_0x47a5b9[_0xf4c6('0x4a')][_0xf4c6('0x50')]=_0x452bdf['id'];_0x47a5b9[_0xf4c6('0x4a')][_0xf4c6('0x51')]=integrations[_0xf4c6('0x52')](_0x47a5b9[_0xf4c6('0x4a')][_0xf4c6('0x53')],_0x47a5b9['body'][_0xf4c6('0x2f')]);_0x47a5b9[_0xf4c6('0x4a')][_0xf4c6('0x54')]=integrations['getDescriptions'](_0x47a5b9[_0xf4c6('0x4a')]['channel'],_0x47a5b9['body'][_0xf4c6('0x2f')]);return db[_0xf4c6('0x4c')][_0xf4c6('0x49')](_0x47a5b9['body'],{'include':[{'model':db['FreshsalesField'],'as':_0xf4c6('0x51')},{'model':db[_0xf4c6('0x55')],'as':_0xf4c6('0x54')}]});}return null;})[_0xf4c6('0x25')](respondWithResult(_0x51609f,null))['catch'](handleError(_0x51609f,null));};exports['getFields']=function(_0x79a3b2,_0x3b7599,_0x4a476b){var _0xa5df3c='';var _0x2da35a='';return db[_0xf4c6('0x2d')][_0xf4c6('0x4b')]({'where':{'id':_0x79a3b2[_0xf4c6('0x46')]['id']},'attributes':['id',_0xf4c6('0x56'),'remoteUri',_0xf4c6('0x57')]})[_0xf4c6('0x25')](handleEntityNotFound(_0x3b7599,null))[_0xf4c6('0x25')](function(_0x3694b3){if(_0x3694b3){_0x2da35a=_0x3694b3['username'];_0xa5df3c=_0x3694b3[_0xf4c6('0x58')];var _0x1e9e92=_0x3694b3[_0xf4c6('0x58')][_0xf4c6('0x59')](-0x1);if(_0x1e9e92==='/'){_0xa5df3c=_0xa5df3c[_0xf4c6('0x5a')](0x0,_0xa5df3c[_0xf4c6('0x5b')](_0x1e9e92));}return rp({'method':'GET','uri':util[_0xf4c6('0x5c')]('%s%s',_0xa5df3c,_0xf4c6('0x5d')),'headers':{'Authorization':_0xf4c6('0x5e')+_0x3694b3[_0xf4c6('0x57')]},'json':!![]});}})[_0xf4c6('0x25')](function(_0x291894){if(_0x291894){var _0x5bbfb7=_0x291894[_0xf4c6('0x5f')];var _0x463ae1=![];var _0x18f8ac=null;for(_0x18f8ac=0x0;_0x18f8ac<_0x5bbfb7[_0xf4c6('0x38')];_0x18f8ac++){if(_0x5bbfb7[_0x18f8ac][_0xf4c6('0x60')]===_0x2da35a){_0x463ae1=!![];}}if(_0x463ae1){return!![];}else{throw new Error({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}})['then'](respondWithResult(_0x3b7599,null))[_0xf4c6('0x44')](function(_0x20753f){var _0x38d4ca=_0x79a3b2[_0xf4c6('0x33')][_0xf4c6('0x61')]?0x1f4:_0x20753f[_0xf4c6('0x62')]||0x1f4;logger['error'](_0xf4c6('0x63'),_0xf4c6('0x64'),_0x38d4ca,JSON[_0xf4c6('0x65')](_0x20753f));delete _0x20753f[_0xf4c6('0x29')];if(_0x38d4ca===0x191){_0x38d4ca=0x190;}_0x3b7599[_0xf4c6('0x1a')](_0x38d4ca)['send'](_0x79a3b2[_0xf4c6('0x33')][_0xf4c6('0x61')]?{'message':'Wrong\x20credentials','statusCode':_0x20753f[_0xf4c6('0x62')]}:_0x20753f);});};
\ No newline at end of file