Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / intFreshsalesAccount / intFreshsalesAccount.controller.js
index 2e43a4e..a6794f7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3140=['sendStatus','status','end','json','count','offset','limit','apply','reject','update','destroy','stack','name','send','FreshsalesAccount','type','query','keys','filters','model','attributes','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','params','intersection','fields','length','find','create','body','getConfigurations','FreshsalesConfiguration','rawAttributes','nolimit','findOne','Subjects','channel','Descriptions','getDescriptions','FreshsalesField','getFields','username','remoteUri','apiKey','slice','lastIndexOf','GET','format','%s%s','/api/selector/owners','Token\x20token=','users','email','Requested\x20Resource\x20not\x20Found','stringify','test','statusCode','html-pdf','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','http','request','then','FreshsalesAccount,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch'];(function(_0xfadc1a,_0xc6a189){var _0x1be3a4=function(_0x1a9107){while(--_0x1a9107){_0xfadc1a['push'](_0xfadc1a['shift']());}};_0x1be3a4(++_0xc6a189);}(_0x3140,0xaf));var _0x0314=function(_0x8d5de5,_0x143d83){_0x8d5de5=_0x8d5de5-0x0;var _0x400b7d=_0x3140[_0x8d5de5];return _0x400b7d;};'use strict';var pdf=require(_0x0314('0x0'));var emlformat=require(_0x0314('0x1'));var rimraf=require(_0x0314('0x2'));var zipdir=require(_0x0314('0x3'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x0314('0x4'));var BPromise=require(_0x0314('0x5'));var Mustache=require(_0x0314('0x6'));var util=require(_0x0314('0x7'));var path=require(_0x0314('0x8'));var sox=require(_0x0314('0x9'));var csv=require(_0x0314('0xa'));var ejs=require(_0x0314('0xb'));var fs=require('fs');var _=require(_0x0314('0xc'));var squel=require(_0x0314('0xd'));var crypto=require(_0x0314('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x0314('0xf'));var toCsv=require(_0x0314('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x0314('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x0314('0x11'));var as=require(_0x0314('0x12'));var hardwareService=require(_0x0314('0x13'));var logger=require(_0x0314('0x14'))(_0x0314('0x15'));var utils=require(_0x0314('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x0314('0x17'));var db=require(_0x0314('0x18'))['db'];var integrations=require(_0x0314('0x19'));var jayson=require(_0x0314('0x1a'));var client=jayson[_0x0314('0x1b')][_0x0314('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x149b67,_0x53e271,_0x1c26ff,_0xbe0b07){return new BPromise(function(_0x1316a0,_0x12d026){var _0x40566e=_0xbe0b07||client;return _0x40566e[_0x0314('0x1d')](_0x149b67,_0x1c26ff)[_0x0314('0x1e')](function(_0x3ea356){logger['info'](_0x0314('0x1f'),_0x53e271,_0x0314('0x20'));logger[_0x0314('0x21')]('FreshsalesAccount,\x20%s,\x20%s,\x20%s',_0x53e271,_0x0314('0x20'),JSON['stringify'](_0x3ea356));if(_0x3ea356['error']){if(_0x3ea356[_0x0314('0x22')][_0x0314('0x23')]===0x1f4){logger['error'](_0x0314('0x1f'),_0x53e271,_0x3ea356[_0x0314('0x22')]['message']);return _0x12d026(_0x3ea356[_0x0314('0x22')]['message']);}logger[_0x0314('0x22')](_0x0314('0x1f'),_0x53e271,_0x3ea356[_0x0314('0x22')][_0x0314('0x24')]);return _0x1316a0(_0x3ea356[_0x0314('0x22')][_0x0314('0x24')]);}else{logger['info']('FreshsalesAccount,\x20%s,\x20%s',_0x53e271,_0x0314('0x20'));_0x1316a0(_0x3ea356[_0x0314('0x25')][_0x0314('0x24')]);}})[_0x0314('0x26')](function(_0x3ec03d){logger[_0x0314('0x22')]('FreshsalesAccount,\x20%s,\x20%s',_0x53e271,_0x3ec03d);_0x12d026(_0x3ec03d);});});}function respondWithStatusCode(_0x3c743e,_0x43fb0e){_0x43fb0e=_0x43fb0e||0xcc;return function(_0x590e94){if(_0x590e94){return _0x3c743e[_0x0314('0x27')](_0x43fb0e);}return _0x3c743e[_0x0314('0x28')](_0x43fb0e)[_0x0314('0x29')]();};}function respondWithResult(_0x26c6a4,_0x867cf7){_0x867cf7=_0x867cf7||0xc8;return function(_0x3af9d3){if(_0x3af9d3){return _0x26c6a4['status'](_0x867cf7)[_0x0314('0x2a')](_0x3af9d3);}};}function respondWithFilteredResult(_0x2e0c77,_0x2d636b){return function(_0x47c2d1){if(_0x47c2d1){var _0x29b4b5=_0x47c2d1[_0x0314('0x2b')],_0x5e3eba=_0x2d636b[_0x0314('0x2c')],_0x47c102=_0x2d636b['offset']+_0x2d636b[_0x0314('0x2d')],_0x5da2c7;if(_0x47c102>=_0x29b4b5){_0x47c102=_0x29b4b5;_0x5da2c7=0xc8;}else{_0x5da2c7=0xce;}_0x2e0c77[_0x0314('0x28')](_0x5da2c7);return _0x2e0c77['set']('Content-Range',_0x5e3eba+'-'+_0x47c102+'/'+_0x29b4b5)[_0x0314('0x2a')](_0x47c2d1);}return null;};}function patchUpdates(_0x345cef){return function(_0x4e34a1){try{jsonpatch[_0x0314('0x2e')](_0x4e34a1,_0x345cef,!![]);}catch(_0x16e74a){return BPromise[_0x0314('0x2f')](_0x16e74a);}return _0x4e34a1['save']();};}function saveUpdates(_0x5b82b2,_0x37ab90){return function(_0x2ce20c){if(_0x2ce20c){return _0x2ce20c[_0x0314('0x30')](_0x5b82b2)['then'](function(_0x1d01b5){return _0x1d01b5;});}return null;};}function removeEntity(_0x554109,_0x52700f){return function(_0x127927){if(_0x127927){return _0x127927[_0x0314('0x31')]()[_0x0314('0x1e')](function(){_0x554109['status'](0xcc)[_0x0314('0x29')]();});}};}function handleEntityNotFound(_0x4a110d,_0x21d907){return function(_0x5a0767){if(!_0x5a0767){_0x4a110d['sendStatus'](0x194);}return _0x5a0767;};}function handleError(_0x2559b2,_0x5d3b0e){_0x5d3b0e=_0x5d3b0e||0x1f4;return function(_0x3e587d){logger[_0x0314('0x22')](_0x3e587d[_0x0314('0x32')]);if(_0x3e587d[_0x0314('0x33')]){delete _0x3e587d[_0x0314('0x33')];}_0x2559b2[_0x0314('0x28')](_0x5d3b0e)[_0x0314('0x34')](_0x3e587d);};}exports['index']=function(_0xf52c24,_0x28c6d0){var _0x292c10={},_0x2cd9d6={},_0x3cab24={'count':0x0,'rows':[]};var _0x26515e=_['map'](db[_0x0314('0x35')]['rawAttributes'],function(_0x22f9f4){return{'name':_0x22f9f4['fieldName'],'type':_0x22f9f4[_0x0314('0x36')]['key']};});_0x2cd9d6['model']=_['map'](_0x26515e,_0x0314('0x33'));_0x2cd9d6[_0x0314('0x37')]=_[_0x0314('0x38')](_0xf52c24[_0x0314('0x37')]);_0x2cd9d6[_0x0314('0x39')]=_['intersection'](_0x2cd9d6[_0x0314('0x3a')],_0x2cd9d6[_0x0314('0x37')]);_0x292c10[_0x0314('0x3b')]=_['intersection'](_0x2cd9d6[_0x0314('0x3a')],qs['fields'](_0xf52c24[_0x0314('0x37')]['fields']));_0x292c10[_0x0314('0x3b')]=_0x292c10['attributes']['length']?_0x292c10[_0x0314('0x3b')]:_0x2cd9d6[_0x0314('0x3a')];if(!_0xf52c24['query'][_0x0314('0x3c')]('nolimit')){_0x292c10[_0x0314('0x2d')]=qs[_0x0314('0x2d')](_0xf52c24[_0x0314('0x37')][_0x0314('0x2d')]);_0x292c10[_0x0314('0x2c')]=qs['offset'](_0xf52c24[_0x0314('0x37')][_0x0314('0x2c')]);}_0x292c10[_0x0314('0x3d')]=qs['sort'](_0xf52c24[_0x0314('0x37')][_0x0314('0x3e')]);_0x292c10[_0x0314('0x3f')]=qs['filters'](_[_0x0314('0x40')](_0xf52c24['query'],_0x2cd9d6[_0x0314('0x39')]),_0x26515e);if(_0xf52c24[_0x0314('0x37')][_0x0314('0x41')]){_0x292c10['where']=_[_0x0314('0x42')](_0x292c10[_0x0314('0x3f')],{'$or':_['map'](_0x26515e,function(_0x48965e){if(_0x48965e['type']!==_0x0314('0x43')){var _0x70bcd={};_0x70bcd[_0x48965e[_0x0314('0x33')]]={'$like':'%'+_0xf52c24['query'][_0x0314('0x41')]+'%'};return _0x70bcd;}})});}_0x292c10=_[_0x0314('0x42')]({},_0x292c10,_0xf52c24[_0x0314('0x44')]);var _0xff99de={'where':_0x292c10[_0x0314('0x3f')]};return db['FreshsalesAccount'][_0x0314('0x2b')](_0xff99de)[_0x0314('0x1e')](function(_0xaa427b){_0x3cab24[_0x0314('0x2b')]=_0xaa427b;if(_0xf52c24[_0x0314('0x37')][_0x0314('0x45')]){_0x292c10[_0x0314('0x46')]=[{'all':!![]}];}return db['FreshsalesAccount'][_0x0314('0x47')](_0x292c10);})[_0x0314('0x1e')](function(_0x539d2c){_0x3cab24[_0x0314('0x48')]=_0x539d2c;return _0x3cab24;})[_0x0314('0x1e')](respondWithFilteredResult(_0x28c6d0,_0x292c10))[_0x0314('0x26')](handleError(_0x28c6d0,null));};exports['show']=function(_0x4a1850,_0x128889){var _0x1a4033={'raw':![],'where':{'id':_0x4a1850[_0x0314('0x49')]['id']}},_0x2cbed3={};_0x2cbed3[_0x0314('0x3a')]=_[_0x0314('0x38')](db[_0x0314('0x35')]['rawAttributes']);_0x2cbed3[_0x0314('0x37')]=_['keys'](_0x4a1850[_0x0314('0x37')]);_0x2cbed3[_0x0314('0x39')]=_[_0x0314('0x4a')](_0x2cbed3[_0x0314('0x3a')],_0x2cbed3[_0x0314('0x37')]);_0x1a4033['attributes']=_['intersection'](_0x2cbed3[_0x0314('0x3a')],qs[_0x0314('0x4b')](_0x4a1850[_0x0314('0x37')][_0x0314('0x4b')]));_0x1a4033['attributes']=_0x1a4033[_0x0314('0x3b')][_0x0314('0x4c')]?_0x1a4033[_0x0314('0x3b')]:_0x2cbed3[_0x0314('0x3a')];if(_0x4a1850[_0x0314('0x37')][_0x0314('0x45')]){_0x1a4033[_0x0314('0x46')]=[{'all':!![]}];}_0x1a4033=_['merge']({},_0x1a4033,_0x4a1850[_0x0314('0x44')]);return db[_0x0314('0x35')][_0x0314('0x4d')](_0x1a4033)['then'](handleEntityNotFound(_0x128889,null))[_0x0314('0x1e')](respondWithResult(_0x128889,null))[_0x0314('0x26')](handleError(_0x128889,null));};exports['create']=function(_0x92cb75,_0xfb5170){return db[_0x0314('0x35')][_0x0314('0x4e')](_0x92cb75['body'],{})[_0x0314('0x1e')](respondWithResult(_0xfb5170,0xc9))[_0x0314('0x26')](handleError(_0xfb5170,null));};exports[_0x0314('0x30')]=function(_0x2903c1,_0x227ee1){if(_0x2903c1[_0x0314('0x4f')]['id']){delete _0x2903c1[_0x0314('0x4f')]['id'];}return db[_0x0314('0x35')][_0x0314('0x4d')]({'where':{'id':_0x2903c1[_0x0314('0x49')]['id']}})['then'](handleEntityNotFound(_0x227ee1,null))[_0x0314('0x1e')](saveUpdates(_0x2903c1[_0x0314('0x4f')],null))[_0x0314('0x1e')](respondWithResult(_0x227ee1,null))[_0x0314('0x26')](handleError(_0x227ee1,null));};exports[_0x0314('0x31')]=function(_0x39bc9,_0x40a8e1){return db['FreshsalesAccount']['find']({'where':{'id':_0x39bc9['params']['id']}})[_0x0314('0x1e')](handleEntityNotFound(_0x40a8e1,null))[_0x0314('0x1e')](removeEntity(_0x40a8e1,null))['catch'](handleError(_0x40a8e1,null));};exports[_0x0314('0x50')]=function(_0x35c961,_0x2ef23f,_0x4b35d8){var _0x50e8dc={};var _0x2e29ce={};var _0x40a4d8;var _0x4df44b;return db[_0x0314('0x35')]['findOne']({'where':{'id':_0x35c961[_0x0314('0x49')]['id']}})[_0x0314('0x1e')](handleEntityNotFound(_0x2ef23f,null))[_0x0314('0x1e')](function(_0x37764f){if(_0x37764f){_0x40a4d8=_0x37764f;_0x2e29ce['model']=_[_0x0314('0x38')](db[_0x0314('0x51')][_0x0314('0x52')]);_0x2e29ce['query']=_[_0x0314('0x38')](_0x35c961[_0x0314('0x37')]);_0x2e29ce[_0x0314('0x39')]=_[_0x0314('0x4a')](_0x2e29ce[_0x0314('0x3a')],_0x2e29ce[_0x0314('0x37')]);_0x50e8dc[_0x0314('0x3b')]=_['intersection'](_0x2e29ce[_0x0314('0x3a')],qs['fields'](_0x35c961['query'][_0x0314('0x4b')]));_0x50e8dc['attributes']=_0x50e8dc[_0x0314('0x3b')][_0x0314('0x4c')]?_0x50e8dc[_0x0314('0x3b')]:_0x2e29ce[_0x0314('0x3a')];_0x50e8dc[_0x0314('0x3d')]=qs[_0x0314('0x3e')](_0x35c961[_0x0314('0x37')][_0x0314('0x3e')]);_0x50e8dc['where']=qs['filters'](_[_0x0314('0x40')](_0x35c961[_0x0314('0x37')],_0x2e29ce[_0x0314('0x39')]));if(_0x35c961['query']['filter']){_0x50e8dc['where']=_[_0x0314('0x42')](_0x50e8dc[_0x0314('0x3f')],{'$or':_['map'](_0x50e8dc[_0x0314('0x3b')],function(_0x3befab){var _0x405be8={};_0x405be8[_0x3befab]={'$like':'%'+_0x35c961[_0x0314('0x37')][_0x0314('0x41')]+'%'};return _0x405be8;})});}_0x50e8dc=_[_0x0314('0x42')]({},_0x50e8dc,_0x35c961['options']);return _0x40a4d8[_0x0314('0x50')](_0x50e8dc);}})[_0x0314('0x1e')](function(_0x15b523){if(_0x15b523){_0x4df44b=_0x15b523['length'];if(!_0x35c961[_0x0314('0x37')][_0x0314('0x3c')](_0x0314('0x53'))){_0x50e8dc['limit']=qs[_0x0314('0x2d')](_0x35c961[_0x0314('0x37')]['limit']);_0x50e8dc[_0x0314('0x2c')]=qs[_0x0314('0x2c')](_0x35c961[_0x0314('0x37')][_0x0314('0x2c')]);}return _0x40a4d8[_0x0314('0x50')](_0x50e8dc);}})['then'](function(_0x296579){if(_0x296579){return _0x296579?{'count':_0x4df44b,'rows':_0x296579}:null;}})[_0x0314('0x1e')](respondWithResult(_0x2ef23f,null))['catch'](handleError(_0x2ef23f,null));};exports['addConfiguration']=function(_0x186dde,_0x381a5d,_0x30726f){if(_0x186dde[_0x0314('0x4f')]['id']){delete _0x186dde[_0x0314('0x4f')]['id'];}return db[_0x0314('0x35')][_0x0314('0x54')]({'where':{'id':_0x186dde['params']['id']}})[_0x0314('0x1e')](handleEntityNotFound(_0x381a5d,null))[_0x0314('0x1e')](function(_0x1cbdd7){if(_0x1cbdd7){_0x186dde[_0x0314('0x4f')]['AccountId']=_0x1cbdd7['id'];_0x186dde[_0x0314('0x4f')][_0x0314('0x55')]=integrations['getSubjects'](_0x186dde[_0x0314('0x4f')][_0x0314('0x56')],_0x186dde['body']['type']);_0x186dde[_0x0314('0x4f')][_0x0314('0x57')]=integrations[_0x0314('0x58')](_0x186dde['body']['channel'],_0x186dde[_0x0314('0x4f')][_0x0314('0x36')]);return db[_0x0314('0x51')][_0x0314('0x4e')](_0x186dde[_0x0314('0x4f')],{'include':[{'model':db['FreshsalesField'],'as':_0x0314('0x55')},{'model':db[_0x0314('0x59')],'as':_0x0314('0x57')}]});}return null;})[_0x0314('0x1e')](respondWithResult(_0x381a5d,null))[_0x0314('0x26')](handleError(_0x381a5d,null));};exports[_0x0314('0x5a')]=function(_0x144929,_0x68ac7f,_0x2d00ab){var _0x4ed0ed='';var _0x907195='';return db[_0x0314('0x35')][_0x0314('0x54')]({'where':{'id':_0x144929[_0x0314('0x49')]['id']},'attributes':['id',_0x0314('0x5b'),_0x0314('0x5c'),_0x0314('0x5d')]})[_0x0314('0x1e')](handleEntityNotFound(_0x68ac7f,null))[_0x0314('0x1e')](function(_0x875ca2){if(_0x875ca2){_0x907195=_0x875ca2[_0x0314('0x5b')];_0x4ed0ed=_0x875ca2['remoteUri'];var _0x2238e8=_0x875ca2[_0x0314('0x5c')][_0x0314('0x5e')](-0x1);if(_0x2238e8==='/'){_0x4ed0ed=_0x4ed0ed['substring'](0x0,_0x4ed0ed[_0x0314('0x5f')](_0x2238e8));}return rp({'method':_0x0314('0x60'),'uri':util[_0x0314('0x61')](_0x0314('0x62'),_0x4ed0ed,_0x0314('0x63')),'headers':{'Authorization':_0x0314('0x64')+_0x875ca2[_0x0314('0x5d')]},'json':!![]});}})[_0x0314('0x1e')](function(_0xb220cf){if(_0xb220cf){var _0x1c7120=_0xb220cf[_0x0314('0x65')];var _0x54e58a=![];var _0x23515e=null;for(_0x23515e=0x0;_0x23515e<_0x1c7120[_0x0314('0x4c')];_0x23515e++){if(_0x1c7120[_0x23515e][_0x0314('0x66')]===_0x907195){_0x54e58a=!![];}}if(_0x54e58a){return!![];}else{throw new Error({'statusCode':0x194,'message':_0x0314('0x67')});}}})[_0x0314('0x1e')](respondWithResult(_0x68ac7f,null))['catch'](function(_0x3bbd81){var _0x59e223=_0x144929[_0x0314('0x37')]['test']?0x1f4:_0x3bbd81['statusCode']||0x1f4;logger[_0x0314('0x22')]('getFields,\x20%s,\x20%s,\x20%s',_0x0314('0x5a'),_0x59e223,JSON[_0x0314('0x68')](_0x3bbd81));delete _0x3bbd81[_0x0314('0x33')];if(_0x59e223===0x191){_0x59e223=0x190;}_0x68ac7f[_0x0314('0x28')](_0x59e223)['send'](_0x144929[_0x0314('0x37')][_0x0314('0x69')]?{'message':'Wrong\x20credentials','statusCode':_0x3bbd81[_0x0314('0x6a')]}:_0x3bbd81);});};
\ No newline at end of file
+var _0xfe35=['lodash','squel','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../components/integrations/configuration','sendStatus','status','json','undefined','limit','count','offset','Content-Range','save','update','then','end','stack','name','send','index','map','FreshsalesAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','sort','filter','where','merge','VIRTUAL','options','findAll','show','params','length','includeAll','include','find','catch','create','body','destroy','getConfigurations','findOne','FreshsalesConfiguration','order','pick','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','FreshsalesField','getFields','username','remoteUri','slice','substring','lastIndexOf','/api/selector/owners','Token\x20token=','apiKey','users','Requested\x20Resource\x20not\x20Found','test','stringify','statusCode','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','util','path','sox','to-csv','ejs','fs-extra'];(function(_0x2c9717,_0x28ddfd){var _0x416560=function(_0x443410){while(--_0x443410){_0x2c9717['push'](_0x2c9717['shift']());}};_0x416560(++_0x28ddfd);}(_0xfe35,0x188));var _0x5fe3=function(_0x32502e,_0x4d8bf4){_0x32502e=_0x32502e-0x0;var _0x38d43b=_0xfe35[_0x32502e];return _0x38d43b;};'use strict';var emlformat=require(_0x5fe3('0x0'));var rimraf=require(_0x5fe3('0x1'));var zipdir=require(_0x5fe3('0x2'));var jsonpatch=require(_0x5fe3('0x3'));var rp=require('request-promise');var moment=require(_0x5fe3('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x5fe3('0x5'));var util=require(_0x5fe3('0x6'));var path=require(_0x5fe3('0x7'));var sox=require(_0x5fe3('0x8'));var csv=require(_0x5fe3('0x9'));var ejs=require(_0x5fe3('0xa'));var fs=require('fs');var fs_extra=require(_0x5fe3('0xb'));var _=require(_0x5fe3('0xc'));var squel=require(_0x5fe3('0xd'));var crypto=require(_0x5fe3('0xe'));var jsforce=require(_0x5fe3('0xf'));var deskjs=require(_0x5fe3('0x10'));var toCsv=require(_0x5fe3('0x9'));var querystring=require('querystring');var Papa=require(_0x5fe3('0x11'));var Redis=require('ioredis');var authService=require(_0x5fe3('0x12'));var qs=require(_0x5fe3('0x13'));var as=require(_0x5fe3('0x14'));var hardwareService=require(_0x5fe3('0x15'));var logger=require(_0x5fe3('0x16'))('api');var utils=require(_0x5fe3('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x5fe3('0x18'));var db=require('../../mysqldb')['db'];var integrations=require(_0x5fe3('0x19'));function respondWithStatusCode(_0x4dff30,_0xf8cfe8){_0xf8cfe8=_0xf8cfe8||0xcc;return function(_0x24feaf){if(_0x24feaf){return _0x4dff30[_0x5fe3('0x1a')](_0xf8cfe8);}return _0x4dff30[_0x5fe3('0x1b')](_0xf8cfe8)['end']();};}function respondWithResult(_0x153a5a,_0x57258f){_0x57258f=_0x57258f||0xc8;return function(_0x45369e){if(_0x45369e){return _0x153a5a[_0x5fe3('0x1b')](_0x57258f)[_0x5fe3('0x1c')](_0x45369e);}};}function respondWithFilteredResult(_0xef0f13,_0x39c79f){return function(_0x1d851d){if(_0x1d851d){var _0x585524=typeof _0x39c79f['offset']===_0x5fe3('0x1d')&&typeof _0x39c79f[_0x5fe3('0x1e')]===_0x5fe3('0x1d');var _0x2801d1=_0x1d851d[_0x5fe3('0x1f')];var _0x14ada0=_0x585524?0x0:_0x39c79f[_0x5fe3('0x20')];var _0x4819ec=_0x585524?_0x1d851d['count']:_0x39c79f['offset']+_0x39c79f[_0x5fe3('0x1e')];var _0x6bae4a;if(_0x4819ec>=_0x2801d1){_0x4819ec=_0x2801d1;_0x6bae4a=0xc8;}else{_0x6bae4a=0xce;}_0xef0f13['status'](_0x6bae4a);return _0xef0f13['set'](_0x5fe3('0x21'),_0x14ada0+'-'+_0x4819ec+'/'+_0x2801d1)['json'](_0x1d851d);}return null;};}function patchUpdates(_0x1048e8){return function(_0x2cea7b){try{jsonpatch['apply'](_0x2cea7b,_0x1048e8,!![]);}catch(_0x15f19a){return BPromise['reject'](_0x15f19a);}return _0x2cea7b[_0x5fe3('0x22')]();};}function saveUpdates(_0x55c032,_0x2b7cf2){return function(_0x2dd870){if(_0x2dd870){return _0x2dd870[_0x5fe3('0x23')](_0x55c032)[_0x5fe3('0x24')](function(_0x12def3){return _0x12def3;});}return null;};}function removeEntity(_0x15b3d0,_0x9626b0){return function(_0x388c56){if(_0x388c56){return _0x388c56['destroy']()[_0x5fe3('0x24')](function(){_0x15b3d0['status'](0xcc)[_0x5fe3('0x25')]();});}};}function handleEntityNotFound(_0x241fde,_0x9dcad){return function(_0x447535){if(!_0x447535){_0x241fde[_0x5fe3('0x1a')](0x194);}return _0x447535;};}function handleError(_0x3b13f6,_0x5e1a5f){_0x5e1a5f=_0x5e1a5f||0x1f4;return function(_0x474961){logger['error'](_0x474961[_0x5fe3('0x26')]);if(_0x474961['name']){delete _0x474961[_0x5fe3('0x27')];}_0x3b13f6[_0x5fe3('0x1b')](_0x5e1a5f)[_0x5fe3('0x28')](_0x474961);};}exports[_0x5fe3('0x29')]=function(_0x118f20,_0x467d06){var _0x1c4407={},_0x423d6d={},_0xfdeb56={'count':0x0,'rows':[]};var _0x4529f0=_[_0x5fe3('0x2a')](db[_0x5fe3('0x2b')][_0x5fe3('0x2c')],function(_0x2b0d7b){return{'name':_0x2b0d7b[_0x5fe3('0x2d')],'type':_0x2b0d7b[_0x5fe3('0x2e')][_0x5fe3('0x2f')]};});_0x423d6d[_0x5fe3('0x30')]=_[_0x5fe3('0x2a')](_0x4529f0,_0x5fe3('0x27'));_0x423d6d[_0x5fe3('0x31')]=_[_0x5fe3('0x32')](_0x118f20[_0x5fe3('0x31')]);_0x423d6d[_0x5fe3('0x33')]=_[_0x5fe3('0x34')](_0x423d6d['model'],_0x423d6d[_0x5fe3('0x31')]);_0x1c4407['attributes']=_[_0x5fe3('0x34')](_0x423d6d[_0x5fe3('0x30')],qs['fields'](_0x118f20['query'][_0x5fe3('0x35')]));_0x1c4407[_0x5fe3('0x36')]=_0x1c4407[_0x5fe3('0x36')]['length']?_0x1c4407[_0x5fe3('0x36')]:_0x423d6d[_0x5fe3('0x30')];if(!_0x118f20['query'][_0x5fe3('0x37')](_0x5fe3('0x38'))){_0x1c4407[_0x5fe3('0x1e')]=qs[_0x5fe3('0x1e')](_0x118f20['query'][_0x5fe3('0x1e')]);_0x1c4407['offset']=qs['offset'](_0x118f20[_0x5fe3('0x31')][_0x5fe3('0x20')]);}_0x1c4407['order']=qs['sort'](_0x118f20['query'][_0x5fe3('0x39')]);_0x1c4407['where']=qs[_0x5fe3('0x33')](_['pick'](_0x118f20['query'],_0x423d6d[_0x5fe3('0x33')]),_0x4529f0);if(_0x118f20['query'][_0x5fe3('0x3a')]){_0x1c4407[_0x5fe3('0x3b')]=_[_0x5fe3('0x3c')](_0x1c4407[_0x5fe3('0x3b')],{'$or':_[_0x5fe3('0x2a')](_0x4529f0,function(_0x58ce7b){if(_0x58ce7b['type']!==_0x5fe3('0x3d')){var _0x1b79fa={};_0x1b79fa[_0x58ce7b[_0x5fe3('0x27')]]={'$like':'%'+_0x118f20['query'][_0x5fe3('0x3a')]+'%'};return _0x1b79fa;}})});}_0x1c4407=_['merge']({},_0x1c4407,_0x118f20[_0x5fe3('0x3e')]);var _0x136536={'where':_0x1c4407['where']};return db[_0x5fe3('0x2b')][_0x5fe3('0x1f')](_0x136536)[_0x5fe3('0x24')](function(_0x115ec1){_0xfdeb56[_0x5fe3('0x1f')]=_0x115ec1;if(_0x118f20[_0x5fe3('0x31')]['includeAll']){_0x1c4407['include']=[{'all':!![]}];}return db[_0x5fe3('0x2b')][_0x5fe3('0x3f')](_0x1c4407);})[_0x5fe3('0x24')](function(_0x5ebb75){_0xfdeb56['rows']=_0x5ebb75;return _0xfdeb56;})['then'](respondWithFilteredResult(_0x467d06,_0x1c4407))['catch'](handleError(_0x467d06,null));};exports[_0x5fe3('0x40')]=function(_0x5dcd21,_0x22f6c6){var _0x4f73c8={'raw':![],'where':{'id':_0x5dcd21[_0x5fe3('0x41')]['id']}},_0x1821f7={};_0x1821f7[_0x5fe3('0x30')]=_[_0x5fe3('0x32')](db[_0x5fe3('0x2b')]['rawAttributes']);_0x1821f7[_0x5fe3('0x31')]=_['keys'](_0x5dcd21[_0x5fe3('0x31')]);_0x1821f7[_0x5fe3('0x33')]=_[_0x5fe3('0x34')](_0x1821f7[_0x5fe3('0x30')],_0x1821f7['query']);_0x4f73c8[_0x5fe3('0x36')]=_[_0x5fe3('0x34')](_0x1821f7[_0x5fe3('0x30')],qs['fields'](_0x5dcd21[_0x5fe3('0x31')][_0x5fe3('0x35')]));_0x4f73c8[_0x5fe3('0x36')]=_0x4f73c8[_0x5fe3('0x36')][_0x5fe3('0x42')]?_0x4f73c8['attributes']:_0x1821f7[_0x5fe3('0x30')];if(_0x5dcd21[_0x5fe3('0x31')][_0x5fe3('0x43')]){_0x4f73c8[_0x5fe3('0x44')]=[{'all':!![]}];}_0x4f73c8=_['merge']({},_0x4f73c8,_0x5dcd21[_0x5fe3('0x3e')]);return db[_0x5fe3('0x2b')][_0x5fe3('0x45')](_0x4f73c8)[_0x5fe3('0x24')](handleEntityNotFound(_0x22f6c6,null))[_0x5fe3('0x24')](respondWithResult(_0x22f6c6,null))[_0x5fe3('0x46')](handleError(_0x22f6c6,null));};exports[_0x5fe3('0x47')]=function(_0x47185c,_0x1aae00){return db[_0x5fe3('0x2b')][_0x5fe3('0x47')](_0x47185c[_0x5fe3('0x48')],{})[_0x5fe3('0x24')](respondWithResult(_0x1aae00,0xc9))[_0x5fe3('0x46')](handleError(_0x1aae00,null));};exports[_0x5fe3('0x23')]=function(_0x563086,_0x3ed019){if(_0x563086['body']['id']){delete _0x563086['body']['id'];}return db['FreshsalesAccount'][_0x5fe3('0x45')]({'where':{'id':_0x563086[_0x5fe3('0x41')]['id']}})[_0x5fe3('0x24')](handleEntityNotFound(_0x3ed019,null))[_0x5fe3('0x24')](saveUpdates(_0x563086[_0x5fe3('0x48')],null))[_0x5fe3('0x24')](respondWithResult(_0x3ed019,null))[_0x5fe3('0x46')](handleError(_0x3ed019,null));};exports[_0x5fe3('0x49')]=function(_0x45911f,_0x2941e6){return db['FreshsalesAccount']['find']({'where':{'id':_0x45911f[_0x5fe3('0x41')]['id']}})['then'](handleEntityNotFound(_0x2941e6,null))[_0x5fe3('0x24')](removeEntity(_0x2941e6,null))[_0x5fe3('0x46')](handleError(_0x2941e6,null));};exports[_0x5fe3('0x4a')]=function(_0x31aae5,_0x23f416,_0x326d57){var _0x330678={};var _0x5cba6={};var _0x5c4b11;var _0x3c95fe;return db[_0x5fe3('0x2b')][_0x5fe3('0x4b')]({'where':{'id':_0x31aae5[_0x5fe3('0x41')]['id']}})['then'](handleEntityNotFound(_0x23f416,null))[_0x5fe3('0x24')](function(_0x535afc){if(_0x535afc){_0x5c4b11=_0x535afc;_0x5cba6[_0x5fe3('0x30')]=_[_0x5fe3('0x32')](db[_0x5fe3('0x4c')][_0x5fe3('0x2c')]);_0x5cba6['query']=_[_0x5fe3('0x32')](_0x31aae5[_0x5fe3('0x31')]);_0x5cba6['filters']=_[_0x5fe3('0x34')](_0x5cba6[_0x5fe3('0x30')],_0x5cba6[_0x5fe3('0x31')]);_0x330678[_0x5fe3('0x36')]=_[_0x5fe3('0x34')](_0x5cba6['model'],qs['fields'](_0x31aae5[_0x5fe3('0x31')]['fields']));_0x330678[_0x5fe3('0x36')]=_0x330678['attributes'][_0x5fe3('0x42')]?_0x330678[_0x5fe3('0x36')]:_0x5cba6[_0x5fe3('0x30')];_0x330678[_0x5fe3('0x4d')]=qs[_0x5fe3('0x39')](_0x31aae5[_0x5fe3('0x31')][_0x5fe3('0x39')]);_0x330678[_0x5fe3('0x3b')]=qs['filters'](_[_0x5fe3('0x4e')](_0x31aae5['query'],_0x5cba6[_0x5fe3('0x33')]));if(_0x31aae5[_0x5fe3('0x31')][_0x5fe3('0x3a')]){_0x330678[_0x5fe3('0x3b')]=_[_0x5fe3('0x3c')](_0x330678[_0x5fe3('0x3b')],{'$or':_[_0x5fe3('0x2a')](_0x330678[_0x5fe3('0x36')],function(_0x1806c8){var _0xec3fd2={};_0xec3fd2[_0x1806c8]={'$like':'%'+_0x31aae5['query'][_0x5fe3('0x3a')]+'%'};return _0xec3fd2;})});}_0x330678=_[_0x5fe3('0x3c')]({},_0x330678,_0x31aae5[_0x5fe3('0x3e')]);return _0x5c4b11['getConfigurations'](_0x330678);}})[_0x5fe3('0x24')](function(_0x230ade){if(_0x230ade){_0x3c95fe=_0x230ade[_0x5fe3('0x42')];if(!_0x31aae5['query']['hasOwnProperty'](_0x5fe3('0x38'))){_0x330678[_0x5fe3('0x1e')]=qs[_0x5fe3('0x1e')](_0x31aae5[_0x5fe3('0x31')][_0x5fe3('0x1e')]);_0x330678[_0x5fe3('0x20')]=qs['offset'](_0x31aae5[_0x5fe3('0x31')]['offset']);}return _0x5c4b11[_0x5fe3('0x4a')](_0x330678);}})[_0x5fe3('0x24')](function(_0x572936){if(_0x572936){return _0x572936?{'count':_0x3c95fe,'rows':_0x572936}:null;}})['then'](respondWithResult(_0x23f416,null))[_0x5fe3('0x46')](handleError(_0x23f416,null));};exports[_0x5fe3('0x4f')]=function(_0x14472d,_0x38dc43,_0x1538cc){if(_0x14472d[_0x5fe3('0x48')]['id']){delete _0x14472d['body']['id'];}return db[_0x5fe3('0x2b')][_0x5fe3('0x4b')]({'where':{'id':_0x14472d[_0x5fe3('0x41')]['id']}})['then'](handleEntityNotFound(_0x38dc43,null))[_0x5fe3('0x24')](function(_0x5d175e){if(_0x5d175e){_0x14472d['body'][_0x5fe3('0x50')]=_0x5d175e['id'];_0x14472d[_0x5fe3('0x48')][_0x5fe3('0x51')]=integrations[_0x5fe3('0x52')](_0x14472d['body'][_0x5fe3('0x53')],_0x14472d[_0x5fe3('0x48')][_0x5fe3('0x2e')]);_0x14472d[_0x5fe3('0x48')][_0x5fe3('0x54')]=integrations[_0x5fe3('0x55')](_0x14472d['body'][_0x5fe3('0x53')],_0x14472d[_0x5fe3('0x48')][_0x5fe3('0x2e')]);return db['FreshsalesConfiguration'][_0x5fe3('0x47')](_0x14472d[_0x5fe3('0x48')],{'include':[{'model':db[_0x5fe3('0x56')],'as':_0x5fe3('0x51')},{'model':db['FreshsalesField'],'as':_0x5fe3('0x54')}]});}return null;})[_0x5fe3('0x24')](respondWithResult(_0x38dc43,null))[_0x5fe3('0x46')](handleError(_0x38dc43,null));};exports[_0x5fe3('0x57')]=function(_0x34dd22,_0x11a7c1,_0x451260){var _0x2877cb='';var _0x5021c0='';return db['FreshsalesAccount']['findOne']({'where':{'id':_0x34dd22[_0x5fe3('0x41')]['id']},'attributes':['id',_0x5fe3('0x58'),_0x5fe3('0x59'),'apiKey']})[_0x5fe3('0x24')](handleEntityNotFound(_0x11a7c1,null))['then'](function(_0x3b945c){if(_0x3b945c){_0x5021c0=_0x3b945c[_0x5fe3('0x58')];_0x2877cb=_0x3b945c[_0x5fe3('0x59')];var _0xe3764c=_0x3b945c[_0x5fe3('0x59')][_0x5fe3('0x5a')](-0x1);if(_0xe3764c==='/'){_0x2877cb=_0x2877cb[_0x5fe3('0x5b')](0x0,_0x2877cb[_0x5fe3('0x5c')](_0xe3764c));}return rp({'method':'GET','uri':util['format']('%s%s',_0x2877cb,_0x5fe3('0x5d')),'headers':{'Authorization':_0x5fe3('0x5e')+_0x3b945c[_0x5fe3('0x5f')]},'json':!![]});}})[_0x5fe3('0x24')](function(_0x1463bb){if(_0x1463bb){var _0x2fa2cc=_0x1463bb[_0x5fe3('0x60')];var _0x3ead4b=![];var _0x3c6b2b=null;for(_0x3c6b2b=0x0;_0x3c6b2b<_0x2fa2cc[_0x5fe3('0x42')];_0x3c6b2b++){if(_0x2fa2cc[_0x3c6b2b]['email']===_0x5021c0){_0x3ead4b=!![];}}if(_0x3ead4b){return!![];}else{throw new Error({'statusCode':0x194,'message':_0x5fe3('0x61')});}}})[_0x5fe3('0x24')](respondWithResult(_0x11a7c1,null))['catch'](function(_0x1f04c0){var _0x2b5048=_0x34dd22['query'][_0x5fe3('0x62')]?0x1f4:_0x1f04c0['statusCode']||0x1f4;logger['error']('getFields,\x20%s,\x20%s,\x20%s',_0x5fe3('0x57'),_0x2b5048,JSON[_0x5fe3('0x63')](_0x1f04c0));delete _0x1f04c0[_0x5fe3('0x27')];if(_0x2b5048===0x191){_0x2b5048=0x190;}_0x11a7c1['status'](_0x2b5048)['send'](_0x34dd22[_0x5fe3('0x31')][_0x5fe3('0x62')]?{'message':'Wrong\x20credentials','statusCode':_0x1f04c0[_0x5fe3('0x64')]}:_0x1f04c0);});};
\ No newline at end of file