Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / intFreshsalesAccount / intFreshsalesAccount.controller.js
index 1ed18bd..6b241c5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2c8f=['filters','pick','filter','merge','include','findAll','rows','params','options','find','catch','create','body','destroy','findOne','FreshsalesConfiguration','length','nolimit','getConfigurations','addConfiguration','Subjects','getSubjects','type','Descriptions','getDescriptions','channel','FreshsalesField','getFields','username','remoteUri','apiKey','slice','lastIndexOf','%s%s','/api/selector/owners','Token\x20token=','users','Requested\x20Resource\x20not\x20Found','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','ejs','fs-extra','crypto','jsforce','to-csv','querystring','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/utils','../../mysqldb','../../components/integrations/configuration','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','reject','update','then','sendStatus','error','stack','name','send','index','map','FreshsalesAccount','rawAttributes','fieldName','model','query','keys','intersection','attributes','fields','hasOwnProperty','sort','where'];(function(_0x499f76,_0x32d064){var _0x378a23=function(_0x30ab96){while(--_0x30ab96){_0x499f76['push'](_0x499f76['shift']());}};_0x378a23(++_0x32d064);}(_0x2c8f,0x8a));var _0xf2c8=function(_0x19a79e,_0x46fc2b){_0x19a79e=_0x19a79e-0x0;var _0x229678=_0x2c8f[_0x19a79e];return _0x229678;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf2c8('0x0'));var zipdir=require(_0xf2c8('0x1'));var jsonpatch=require(_0xf2c8('0x2'));var rp=require(_0xf2c8('0x3'));var moment=require(_0xf2c8('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xf2c8('0x5'));var util=require(_0xf2c8('0x6'));var path=require('path');var sox=require(_0xf2c8('0x7'));var csv=require('to-csv');var ejs=require(_0xf2c8('0x8'));var fs=require('fs');var fs_extra=require(_0xf2c8('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xf2c8('0xa'));var jsforce=require(_0xf2c8('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xf2c8('0xc'));var querystring=require(_0xf2c8('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xf2c8('0xe'));var qs=require(_0xf2c8('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf2c8('0x10'));var logger=require('../../config/logger')('api');var utils=require(_0xf2c8('0x11'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xf2c8('0x12'))['db'];var integrations=require(_0xf2c8('0x13'));function respondWithStatusCode(_0x82786e,_0x4dace6){_0x4dace6=_0x4dace6||0xcc;return function(_0x4cd76f){if(_0x4cd76f){return _0x82786e['sendStatus'](_0x4dace6);}return _0x82786e[_0xf2c8('0x14')](_0x4dace6)[_0xf2c8('0x15')]();};}function respondWithResult(_0x2a2bbf,_0x5f0fdf){_0x5f0fdf=_0x5f0fdf||0xc8;return function(_0x1b7d35){if(_0x1b7d35){return _0x2a2bbf[_0xf2c8('0x14')](_0x5f0fdf)[_0xf2c8('0x16')](_0x1b7d35);}};}function respondWithFilteredResult(_0x426610,_0x36591c){return function(_0x3b8dc6){if(_0x3b8dc6){var _0x347842=typeof _0x36591c[_0xf2c8('0x17')]==='undefined'&&typeof _0x36591c[_0xf2c8('0x18')]===_0xf2c8('0x19');var _0x1103af=_0x3b8dc6[_0xf2c8('0x1a')];var _0x586867=_0x347842?0x0:_0x36591c[_0xf2c8('0x17')];var _0x52ce21=_0x347842?_0x3b8dc6[_0xf2c8('0x1a')]:_0x36591c[_0xf2c8('0x17')]+_0x36591c['limit'];var _0x3c2743;if(_0x52ce21>=_0x1103af){_0x52ce21=_0x1103af;_0x3c2743=0xc8;}else{_0x3c2743=0xce;}_0x426610['status'](_0x3c2743);return _0x426610[_0xf2c8('0x1b')](_0xf2c8('0x1c'),_0x586867+'-'+_0x52ce21+'/'+_0x1103af)[_0xf2c8('0x16')](_0x3b8dc6);}return null;};}function patchUpdates(_0x275c8e){return function(_0x32b184){try{jsonpatch[_0xf2c8('0x1d')](_0x32b184,_0x275c8e,!![]);}catch(_0x7f8a6e){return BPromise[_0xf2c8('0x1e')](_0x7f8a6e);}return _0x32b184['save']();};}function saveUpdates(_0x3e9244,_0x1bebef){return function(_0x40f5e9){if(_0x40f5e9){return _0x40f5e9[_0xf2c8('0x1f')](_0x3e9244)[_0xf2c8('0x20')](function(_0x10c03e){return _0x10c03e;});}return null;};}function removeEntity(_0x32a967,_0x44f8fb){return function(_0x4fc058){if(_0x4fc058){return _0x4fc058['destroy']()[_0xf2c8('0x20')](function(){_0x32a967[_0xf2c8('0x14')](0xcc)[_0xf2c8('0x15')]();});}};}function handleEntityNotFound(_0x4c6ae8,_0x2e7f1d){return function(_0x389c09){if(!_0x389c09){_0x4c6ae8[_0xf2c8('0x21')](0x194);}return _0x389c09;};}function handleError(_0x4d97e9,_0x5eda0e){_0x5eda0e=_0x5eda0e||0x1f4;return function(_0x409830){logger[_0xf2c8('0x22')](_0x409830[_0xf2c8('0x23')]);if(_0x409830['name']){delete _0x409830[_0xf2c8('0x24')];}_0x4d97e9['status'](_0x5eda0e)[_0xf2c8('0x25')](_0x409830);};}exports[_0xf2c8('0x26')]=function(_0x2713f6,_0x2fb36e){var _0x3027ed={},_0x27c28d={},_0x2d652c={'count':0x0,'rows':[]};var _0x305f6c=_[_0xf2c8('0x27')](db[_0xf2c8('0x28')][_0xf2c8('0x29')],function(_0xe0a3a5){return{'name':_0xe0a3a5[_0xf2c8('0x2a')],'type':_0xe0a3a5['type']['key']};});_0x27c28d[_0xf2c8('0x2b')]=_[_0xf2c8('0x27')](_0x305f6c,'name');_0x27c28d[_0xf2c8('0x2c')]=_[_0xf2c8('0x2d')](_0x2713f6[_0xf2c8('0x2c')]);_0x27c28d['filters']=_[_0xf2c8('0x2e')](_0x27c28d[_0xf2c8('0x2b')],_0x27c28d[_0xf2c8('0x2c')]);_0x3027ed[_0xf2c8('0x2f')]=_['intersection'](_0x27c28d[_0xf2c8('0x2b')],qs[_0xf2c8('0x30')](_0x2713f6[_0xf2c8('0x2c')][_0xf2c8('0x30')]));_0x3027ed[_0xf2c8('0x2f')]=_0x3027ed[_0xf2c8('0x2f')]['length']?_0x3027ed[_0xf2c8('0x2f')]:_0x27c28d[_0xf2c8('0x2b')];if(!_0x2713f6[_0xf2c8('0x2c')][_0xf2c8('0x31')]('nolimit')){_0x3027ed[_0xf2c8('0x18')]=qs['limit'](_0x2713f6[_0xf2c8('0x2c')][_0xf2c8('0x18')]);_0x3027ed['offset']=qs['offset'](_0x2713f6['query'][_0xf2c8('0x17')]);}_0x3027ed['order']=qs[_0xf2c8('0x32')](_0x2713f6[_0xf2c8('0x2c')][_0xf2c8('0x32')]);_0x3027ed[_0xf2c8('0x33')]=qs[_0xf2c8('0x34')](_[_0xf2c8('0x35')](_0x2713f6[_0xf2c8('0x2c')],_0x27c28d[_0xf2c8('0x34')]),_0x305f6c);if(_0x2713f6['query'][_0xf2c8('0x36')]){_0x3027ed[_0xf2c8('0x33')]=_[_0xf2c8('0x37')](_0x3027ed[_0xf2c8('0x33')],{'$or':_[_0xf2c8('0x27')](_0x305f6c,function(_0xb6105c){if(_0xb6105c['type']!=='VIRTUAL'){var _0x160076={};_0x160076[_0xb6105c[_0xf2c8('0x24')]]={'$like':'%'+_0x2713f6[_0xf2c8('0x2c')][_0xf2c8('0x36')]+'%'};return _0x160076;}})});}_0x3027ed=_[_0xf2c8('0x37')]({},_0x3027ed,_0x2713f6['options']);var _0x36de78={'where':_0x3027ed[_0xf2c8('0x33')]};return db[_0xf2c8('0x28')]['count'](_0x36de78)[_0xf2c8('0x20')](function(_0x3c3b53){_0x2d652c[_0xf2c8('0x1a')]=_0x3c3b53;if(_0x2713f6[_0xf2c8('0x2c')]['includeAll']){_0x3027ed[_0xf2c8('0x38')]=[{'all':!![]}];}return db[_0xf2c8('0x28')][_0xf2c8('0x39')](_0x3027ed);})[_0xf2c8('0x20')](function(_0x40e3cc){_0x2d652c[_0xf2c8('0x3a')]=_0x40e3cc;return _0x2d652c;})[_0xf2c8('0x20')](respondWithFilteredResult(_0x2fb36e,_0x3027ed))['catch'](handleError(_0x2fb36e,null));};exports['show']=function(_0x89dd66,_0x3268d7){var _0x45823e={'raw':![],'where':{'id':_0x89dd66[_0xf2c8('0x3b')]['id']}},_0x58e890={};_0x58e890[_0xf2c8('0x2b')]=_['keys'](db[_0xf2c8('0x28')][_0xf2c8('0x29')]);_0x58e890[_0xf2c8('0x2c')]=_[_0xf2c8('0x2d')](_0x89dd66['query']);_0x58e890[_0xf2c8('0x34')]=_[_0xf2c8('0x2e')](_0x58e890[_0xf2c8('0x2b')],_0x58e890[_0xf2c8('0x2c')]);_0x45823e[_0xf2c8('0x2f')]=_['intersection'](_0x58e890[_0xf2c8('0x2b')],qs['fields'](_0x89dd66[_0xf2c8('0x2c')][_0xf2c8('0x30')]));_0x45823e[_0xf2c8('0x2f')]=_0x45823e[_0xf2c8('0x2f')]['length']?_0x45823e[_0xf2c8('0x2f')]:_0x58e890[_0xf2c8('0x2b')];if(_0x89dd66[_0xf2c8('0x2c')]['includeAll']){_0x45823e[_0xf2c8('0x38')]=[{'all':!![]}];}_0x45823e=_[_0xf2c8('0x37')]({},_0x45823e,_0x89dd66[_0xf2c8('0x3c')]);return db['FreshsalesAccount'][_0xf2c8('0x3d')](_0x45823e)[_0xf2c8('0x20')](handleEntityNotFound(_0x3268d7,null))[_0xf2c8('0x20')](respondWithResult(_0x3268d7,null))[_0xf2c8('0x3e')](handleError(_0x3268d7,null));};exports[_0xf2c8('0x3f')]=function(_0x1ef6ce,_0x5990cc){return db[_0xf2c8('0x28')][_0xf2c8('0x3f')](_0x1ef6ce['body'],{})['then'](respondWithResult(_0x5990cc,0xc9))[_0xf2c8('0x3e')](handleError(_0x5990cc,null));};exports[_0xf2c8('0x1f')]=function(_0x378ee7,_0x16577f){if(_0x378ee7[_0xf2c8('0x40')]['id']){delete _0x378ee7[_0xf2c8('0x40')]['id'];}return db[_0xf2c8('0x28')][_0xf2c8('0x3d')]({'where':{'id':_0x378ee7['params']['id']}})[_0xf2c8('0x20')](handleEntityNotFound(_0x16577f,null))['then'](saveUpdates(_0x378ee7[_0xf2c8('0x40')],null))[_0xf2c8('0x20')](respondWithResult(_0x16577f,null))[_0xf2c8('0x3e')](handleError(_0x16577f,null));};exports[_0xf2c8('0x41')]=function(_0x54120c,_0x5e0b81){return db[_0xf2c8('0x28')][_0xf2c8('0x3d')]({'where':{'id':_0x54120c[_0xf2c8('0x3b')]['id']}})[_0xf2c8('0x20')](handleEntityNotFound(_0x5e0b81,null))[_0xf2c8('0x20')](removeEntity(_0x5e0b81,null))['catch'](handleError(_0x5e0b81,null));};exports['getConfigurations']=function(_0x57341b,_0x340fb7,_0x1e8004){var _0x338bb9={};var _0x2db08a={};var _0x41e4d0;var _0x588b01;return db[_0xf2c8('0x28')][_0xf2c8('0x42')]({'where':{'id':_0x57341b['params']['id']}})[_0xf2c8('0x20')](handleEntityNotFound(_0x340fb7,null))[_0xf2c8('0x20')](function(_0x2d81cc){if(_0x2d81cc){_0x41e4d0=_0x2d81cc;_0x2db08a[_0xf2c8('0x2b')]=_[_0xf2c8('0x2d')](db[_0xf2c8('0x43')][_0xf2c8('0x29')]);_0x2db08a[_0xf2c8('0x2c')]=_['keys'](_0x57341b[_0xf2c8('0x2c')]);_0x2db08a['filters']=_[_0xf2c8('0x2e')](_0x2db08a['model'],_0x2db08a[_0xf2c8('0x2c')]);_0x338bb9['attributes']=_[_0xf2c8('0x2e')](_0x2db08a['model'],qs[_0xf2c8('0x30')](_0x57341b[_0xf2c8('0x2c')][_0xf2c8('0x30')]));_0x338bb9[_0xf2c8('0x2f')]=_0x338bb9[_0xf2c8('0x2f')][_0xf2c8('0x44')]?_0x338bb9[_0xf2c8('0x2f')]:_0x2db08a[_0xf2c8('0x2b')];_0x338bb9['order']=qs[_0xf2c8('0x32')](_0x57341b['query'][_0xf2c8('0x32')]);_0x338bb9[_0xf2c8('0x33')]=qs['filters'](_['pick'](_0x57341b[_0xf2c8('0x2c')],_0x2db08a[_0xf2c8('0x34')]));if(_0x57341b[_0xf2c8('0x2c')]['filter']){_0x338bb9[_0xf2c8('0x33')]=_['merge'](_0x338bb9[_0xf2c8('0x33')],{'$or':_['map'](_0x338bb9[_0xf2c8('0x2f')],function(_0x373438){var _0x52e5bc={};_0x52e5bc[_0x373438]={'$like':'%'+_0x57341b[_0xf2c8('0x2c')][_0xf2c8('0x36')]+'%'};return _0x52e5bc;})});}_0x338bb9=_['merge']({},_0x338bb9,_0x57341b[_0xf2c8('0x3c')]);return _0x41e4d0['getConfigurations'](_0x338bb9);}})[_0xf2c8('0x20')](function(_0x23562e){if(_0x23562e){_0x588b01=_0x23562e[_0xf2c8('0x44')];if(!_0x57341b[_0xf2c8('0x2c')][_0xf2c8('0x31')](_0xf2c8('0x45'))){_0x338bb9[_0xf2c8('0x18')]=qs[_0xf2c8('0x18')](_0x57341b[_0xf2c8('0x2c')][_0xf2c8('0x18')]);_0x338bb9[_0xf2c8('0x17')]=qs[_0xf2c8('0x17')](_0x57341b[_0xf2c8('0x2c')][_0xf2c8('0x17')]);}return _0x41e4d0[_0xf2c8('0x46')](_0x338bb9);}})[_0xf2c8('0x20')](function(_0x21478e){if(_0x21478e){return _0x21478e?{'count':_0x588b01,'rows':_0x21478e}:null;}})[_0xf2c8('0x20')](respondWithResult(_0x340fb7,null))[_0xf2c8('0x3e')](handleError(_0x340fb7,null));};exports[_0xf2c8('0x47')]=function(_0x358ae7,_0x317da3,_0x1ca538){if(_0x358ae7[_0xf2c8('0x40')]['id']){delete _0x358ae7[_0xf2c8('0x40')]['id'];}return db[_0xf2c8('0x28')][_0xf2c8('0x42')]({'where':{'id':_0x358ae7['params']['id']}})['then'](handleEntityNotFound(_0x317da3,null))[_0xf2c8('0x20')](function(_0x5eedc2){if(_0x5eedc2){_0x358ae7[_0xf2c8('0x40')]['AccountId']=_0x5eedc2['id'];_0x358ae7[_0xf2c8('0x40')][_0xf2c8('0x48')]=integrations[_0xf2c8('0x49')](_0x358ae7[_0xf2c8('0x40')]['channel'],_0x358ae7[_0xf2c8('0x40')][_0xf2c8('0x4a')]);_0x358ae7['body'][_0xf2c8('0x4b')]=integrations[_0xf2c8('0x4c')](_0x358ae7[_0xf2c8('0x40')][_0xf2c8('0x4d')],_0x358ae7['body'][_0xf2c8('0x4a')]);return db['FreshsalesConfiguration'][_0xf2c8('0x3f')](_0x358ae7[_0xf2c8('0x40')],{'include':[{'model':db['FreshsalesField'],'as':_0xf2c8('0x48')},{'model':db[_0xf2c8('0x4e')],'as':_0xf2c8('0x4b')}]});}return null;})['then'](respondWithResult(_0x317da3,null))[_0xf2c8('0x3e')](handleError(_0x317da3,null));};exports[_0xf2c8('0x4f')]=function(_0x1b1e6b,_0x567045,_0xbb5d60){var _0x55f410='';var _0x5bb542='';return db[_0xf2c8('0x28')][_0xf2c8('0x42')]({'where':{'id':_0x1b1e6b[_0xf2c8('0x3b')]['id']},'attributes':['id',_0xf2c8('0x50'),_0xf2c8('0x51'),_0xf2c8('0x52')]})[_0xf2c8('0x20')](handleEntityNotFound(_0x567045,null))[_0xf2c8('0x20')](function(_0x353fb9){if(_0x353fb9){_0x5bb542=_0x353fb9[_0xf2c8('0x50')];_0x55f410=_0x353fb9[_0xf2c8('0x51')];var _0x34e1d2=_0x353fb9[_0xf2c8('0x51')][_0xf2c8('0x53')](-0x1);if(_0x34e1d2==='/'){_0x55f410=_0x55f410['substring'](0x0,_0x55f410[_0xf2c8('0x54')](_0x34e1d2));}return rp({'method':'GET','uri':util['format'](_0xf2c8('0x55'),_0x55f410,_0xf2c8('0x56')),'headers':{'Authorization':_0xf2c8('0x57')+_0x353fb9[_0xf2c8('0x52')]},'json':!![]});}})[_0xf2c8('0x20')](function(_0x274001){if(_0x274001){var _0x4306ff=_0x274001[_0xf2c8('0x58')];var _0x22e466=![];var _0x13da30=null;for(_0x13da30=0x0;_0x13da30<_0x4306ff[_0xf2c8('0x44')];_0x13da30++){if(_0x4306ff[_0x13da30]['email']===_0x5bb542){_0x22e466=!![];}}if(_0x22e466){return!![];}else{throw new Error({'statusCode':0x194,'message':_0xf2c8('0x59')});}}})[_0xf2c8('0x20')](respondWithResult(_0x567045,null))[_0xf2c8('0x3e')](function(_0x357ea2){var _0x58c407=_0x1b1e6b[_0xf2c8('0x2c')][_0xf2c8('0x5a')]?0x1f4:_0x357ea2[_0xf2c8('0x5b')]||0x1f4;logger[_0xf2c8('0x22')](_0xf2c8('0x5c'),'getFields',_0x58c407,JSON[_0xf2c8('0x5d')](_0x357ea2));delete _0x357ea2['name'];if(_0x58c407===0x191){_0x58c407=0x190;}_0x567045[_0xf2c8('0x14')](_0x58c407)[_0xf2c8('0x25')](_0x1b1e6b[_0xf2c8('0x2c')][_0xf2c8('0x5a')]?{'message':_0xf2c8('0x5e'),'statusCode':_0x357ea2['statusCode']}:_0x357ea2);});};
\ No newline at end of file
+var _0xb71c=['Subjects','getSubjects','channel','getDescriptions','Descriptions','getFields','remoteUri','substring','lastIndexOf','GET','format','%s%s','/api/selector/owners','Token\x20token=','apiKey','users','email','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','../../components/integrations/configuration','sendStatus','end','status','json','offset','limit','undefined','count','set','Content-Range','apply','error','stack','name','send','index','FreshsalesAccount','rawAttributes','model','map','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','merge','where','type','VIRTUAL','filter','includeAll','include','findAll','then','catch','show','params','options','create','body','update','find','getConfigurations','findOne','FreshsalesConfiguration','AccountId'];(function(_0x4c3c88,_0x42f102){var _0x1587d4=function(_0x521d65){while(--_0x521d65){_0x4c3c88['push'](_0x4c3c88['shift']());}};_0x1587d4(++_0x42f102);}(_0xb71c,0x151));var _0xcb71=function(_0x672fb,_0x65b172){_0x672fb=_0x672fb-0x0;var _0x43185f=_0xb71c[_0x672fb];return _0x43185f;};'use strict';var emlformat=require(_0xcb71('0x0'));var rimraf=require(_0xcb71('0x1'));var zipdir=require(_0xcb71('0x2'));var jsonpatch=require(_0xcb71('0x3'));var rp=require(_0xcb71('0x4'));var moment=require(_0xcb71('0x5'));var BPromise=require(_0xcb71('0x6'));var Mustache=require(_0xcb71('0x7'));var util=require(_0xcb71('0x8'));var path=require(_0xcb71('0x9'));var sox=require('sox');var csv=require(_0xcb71('0xa'));var ejs=require(_0xcb71('0xb'));var fs=require('fs');var fs_extra=require(_0xcb71('0xc'));var _=require(_0xcb71('0xd'));var squel=require(_0xcb71('0xe'));var crypto=require(_0xcb71('0xf'));var jsforce=require('jsforce');var deskjs=require(_0xcb71('0x10'));var toCsv=require(_0xcb71('0xa'));var querystring=require(_0xcb71('0x11'));var Papa=require(_0xcb71('0x12'));var Redis=require(_0xcb71('0x13'));var authService=require(_0xcb71('0x14'));var qs=require(_0xcb71('0x15'));var as=require(_0xcb71('0x16'));var hardwareService=require(_0xcb71('0x17'));var logger=require(_0xcb71('0x18'))(_0xcb71('0x19'));var utils=require(_0xcb71('0x1a'));var config=require(_0xcb71('0x1b'));var licenseUtil=require('../../config/license/util');var db=require(_0xcb71('0x1c'))['db'];var integrations=require(_0xcb71('0x1d'));function respondWithStatusCode(_0x546b2d,_0x5f157b){_0x5f157b=_0x5f157b||0xcc;return function(_0x13419d){if(_0x13419d){return _0x546b2d[_0xcb71('0x1e')](_0x5f157b);}return _0x546b2d['status'](_0x5f157b)[_0xcb71('0x1f')]();};}function respondWithResult(_0x2b1033,_0x3c79f5){_0x3c79f5=_0x3c79f5||0xc8;return function(_0x41d1ee){if(_0x41d1ee){return _0x2b1033[_0xcb71('0x20')](_0x3c79f5)[_0xcb71('0x21')](_0x41d1ee);}};}function respondWithFilteredResult(_0x33708c,_0x5385ca){return function(_0x5f14cc){if(_0x5f14cc){var _0x3bee6b=typeof _0x5385ca[_0xcb71('0x22')]==='undefined'&&typeof _0x5385ca[_0xcb71('0x23')]===_0xcb71('0x24');var _0x216b82=_0x5f14cc[_0xcb71('0x25')];var _0x284a83=_0x3bee6b?0x0:_0x5385ca[_0xcb71('0x22')];var _0x587dfc=_0x3bee6b?_0x5f14cc[_0xcb71('0x25')]:_0x5385ca[_0xcb71('0x22')]+_0x5385ca['limit'];var _0x566b7a;if(_0x587dfc>=_0x216b82){_0x587dfc=_0x216b82;_0x566b7a=0xc8;}else{_0x566b7a=0xce;}_0x33708c[_0xcb71('0x20')](_0x566b7a);return _0x33708c[_0xcb71('0x26')](_0xcb71('0x27'),_0x284a83+'-'+_0x587dfc+'/'+_0x216b82)[_0xcb71('0x21')](_0x5f14cc);}return null;};}function patchUpdates(_0x287b7d){return function(_0x28f5b2){try{jsonpatch[_0xcb71('0x28')](_0x28f5b2,_0x287b7d,!![]);}catch(_0x24b55f){return BPromise['reject'](_0x24b55f);}return _0x28f5b2['save']();};}function saveUpdates(_0x2e0456,_0x55f640){return function(_0xba7d3c){if(_0xba7d3c){return _0xba7d3c['update'](_0x2e0456)['then'](function(_0xb67b56){return _0xb67b56;});}return null;};}function removeEntity(_0x4401e5,_0x25ee33){return function(_0x96411){if(_0x96411){return _0x96411['destroy']()['then'](function(){_0x4401e5[_0xcb71('0x20')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4a3a7d,_0x57fa1a){return function(_0xe0ce13){if(!_0xe0ce13){_0x4a3a7d[_0xcb71('0x1e')](0x194);}return _0xe0ce13;};}function handleError(_0x58c492,_0x80eb67){_0x80eb67=_0x80eb67||0x1f4;return function(_0x20ca97){logger[_0xcb71('0x29')](_0x20ca97[_0xcb71('0x2a')]);if(_0x20ca97[_0xcb71('0x2b')]){delete _0x20ca97[_0xcb71('0x2b')];}_0x58c492[_0xcb71('0x20')](_0x80eb67)[_0xcb71('0x2c')](_0x20ca97);};}exports[_0xcb71('0x2d')]=function(_0x475861,_0x21ef09){var _0x553e7b={},_0x2550ae={},_0xe9157f={'count':0x0,'rows':[]};var _0x563f99=_['map'](db[_0xcb71('0x2e')][_0xcb71('0x2f')],function(_0x4efbcb){return{'name':_0x4efbcb['fieldName'],'type':_0x4efbcb['type']['key']};});_0x2550ae[_0xcb71('0x30')]=_[_0xcb71('0x31')](_0x563f99,'name');_0x2550ae[_0xcb71('0x32')]=_[_0xcb71('0x33')](_0x475861[_0xcb71('0x32')]);_0x2550ae[_0xcb71('0x34')]=_[_0xcb71('0x35')](_0x2550ae[_0xcb71('0x30')],_0x2550ae[_0xcb71('0x32')]);_0x553e7b[_0xcb71('0x36')]=_['intersection'](_0x2550ae[_0xcb71('0x30')],qs['fields'](_0x475861[_0xcb71('0x32')][_0xcb71('0x37')]));_0x553e7b[_0xcb71('0x36')]=_0x553e7b[_0xcb71('0x36')][_0xcb71('0x38')]?_0x553e7b[_0xcb71('0x36')]:_0x2550ae[_0xcb71('0x30')];if(!_0x475861[_0xcb71('0x32')][_0xcb71('0x39')](_0xcb71('0x3a'))){_0x553e7b[_0xcb71('0x23')]=qs[_0xcb71('0x23')](_0x475861['query'][_0xcb71('0x23')]);_0x553e7b[_0xcb71('0x22')]=qs['offset'](_0x475861['query'][_0xcb71('0x22')]);}_0x553e7b[_0xcb71('0x3b')]=qs[_0xcb71('0x3c')](_0x475861[_0xcb71('0x32')][_0xcb71('0x3c')]);_0x553e7b['where']=qs[_0xcb71('0x34')](_[_0xcb71('0x3d')](_0x475861[_0xcb71('0x32')],_0x2550ae['filters']),_0x563f99);if(_0x475861[_0xcb71('0x32')]['filter']){_0x553e7b['where']=_[_0xcb71('0x3e')](_0x553e7b[_0xcb71('0x3f')],{'$or':_[_0xcb71('0x31')](_0x563f99,function(_0x50db7d){if(_0x50db7d[_0xcb71('0x40')]!==_0xcb71('0x41')){var _0x4ff16e={};_0x4ff16e[_0x50db7d[_0xcb71('0x2b')]]={'$like':'%'+_0x475861['query'][_0xcb71('0x42')]+'%'};return _0x4ff16e;}})});}_0x553e7b=_[_0xcb71('0x3e')]({},_0x553e7b,_0x475861['options']);var _0x1c3e24={'where':_0x553e7b[_0xcb71('0x3f')]};return db[_0xcb71('0x2e')]['count'](_0x1c3e24)['then'](function(_0xa760eb){_0xe9157f[_0xcb71('0x25')]=_0xa760eb;if(_0x475861['query'][_0xcb71('0x43')]){_0x553e7b[_0xcb71('0x44')]=[{'all':!![]}];}return db[_0xcb71('0x2e')][_0xcb71('0x45')](_0x553e7b);})[_0xcb71('0x46')](function(_0x358639){_0xe9157f['rows']=_0x358639;return _0xe9157f;})[_0xcb71('0x46')](respondWithFilteredResult(_0x21ef09,_0x553e7b))[_0xcb71('0x47')](handleError(_0x21ef09,null));};exports[_0xcb71('0x48')]=function(_0x55f29a,_0x2b217f){var _0x12e5ad={'raw':![],'where':{'id':_0x55f29a[_0xcb71('0x49')]['id']}},_0x5c0b5f={};_0x5c0b5f[_0xcb71('0x30')]=_['keys'](db[_0xcb71('0x2e')][_0xcb71('0x2f')]);_0x5c0b5f[_0xcb71('0x32')]=_[_0xcb71('0x33')](_0x55f29a['query']);_0x5c0b5f[_0xcb71('0x34')]=_['intersection'](_0x5c0b5f[_0xcb71('0x30')],_0x5c0b5f[_0xcb71('0x32')]);_0x12e5ad[_0xcb71('0x36')]=_[_0xcb71('0x35')](_0x5c0b5f[_0xcb71('0x30')],qs[_0xcb71('0x37')](_0x55f29a[_0xcb71('0x32')]['fields']));_0x12e5ad[_0xcb71('0x36')]=_0x12e5ad['attributes']['length']?_0x12e5ad[_0xcb71('0x36')]:_0x5c0b5f[_0xcb71('0x30')];if(_0x55f29a[_0xcb71('0x32')][_0xcb71('0x43')]){_0x12e5ad['include']=[{'all':!![]}];}_0x12e5ad=_[_0xcb71('0x3e')]({},_0x12e5ad,_0x55f29a[_0xcb71('0x4a')]);return db[_0xcb71('0x2e')]['find'](_0x12e5ad)[_0xcb71('0x46')](handleEntityNotFound(_0x2b217f,null))[_0xcb71('0x46')](respondWithResult(_0x2b217f,null))[_0xcb71('0x47')](handleError(_0x2b217f,null));};exports[_0xcb71('0x4b')]=function(_0x3aaffd,_0x2d070c){return db[_0xcb71('0x2e')]['create'](_0x3aaffd[_0xcb71('0x4c')],{})[_0xcb71('0x46')](respondWithResult(_0x2d070c,0xc9))[_0xcb71('0x47')](handleError(_0x2d070c,null));};exports[_0xcb71('0x4d')]=function(_0x13ce8e,_0x3892e6){if(_0x13ce8e['body']['id']){delete _0x13ce8e['body']['id'];}return db[_0xcb71('0x2e')][_0xcb71('0x4e')]({'where':{'id':_0x13ce8e[_0xcb71('0x49')]['id']}})[_0xcb71('0x46')](handleEntityNotFound(_0x3892e6,null))[_0xcb71('0x46')](saveUpdates(_0x13ce8e[_0xcb71('0x4c')],null))[_0xcb71('0x46')](respondWithResult(_0x3892e6,null))[_0xcb71('0x47')](handleError(_0x3892e6,null));};exports['destroy']=function(_0x1a52ca,_0x3826fe){return db[_0xcb71('0x2e')][_0xcb71('0x4e')]({'where':{'id':_0x1a52ca[_0xcb71('0x49')]['id']}})[_0xcb71('0x46')](handleEntityNotFound(_0x3826fe,null))[_0xcb71('0x46')](removeEntity(_0x3826fe,null))[_0xcb71('0x47')](handleError(_0x3826fe,null));};exports[_0xcb71('0x4f')]=function(_0x1937bb,_0x326136,_0x62c106){var _0x4593e9={};var _0x3152f0={};var _0x5200ed;var _0x4ab509;return db[_0xcb71('0x2e')][_0xcb71('0x50')]({'where':{'id':_0x1937bb[_0xcb71('0x49')]['id']}})[_0xcb71('0x46')](handleEntityNotFound(_0x326136,null))[_0xcb71('0x46')](function(_0x25eeaf){if(_0x25eeaf){_0x5200ed=_0x25eeaf;_0x3152f0[_0xcb71('0x30')]=_[_0xcb71('0x33')](db[_0xcb71('0x51')][_0xcb71('0x2f')]);_0x3152f0[_0xcb71('0x32')]=_[_0xcb71('0x33')](_0x1937bb[_0xcb71('0x32')]);_0x3152f0[_0xcb71('0x34')]=_[_0xcb71('0x35')](_0x3152f0[_0xcb71('0x30')],_0x3152f0[_0xcb71('0x32')]);_0x4593e9[_0xcb71('0x36')]=_['intersection'](_0x3152f0['model'],qs[_0xcb71('0x37')](_0x1937bb['query'][_0xcb71('0x37')]));_0x4593e9[_0xcb71('0x36')]=_0x4593e9[_0xcb71('0x36')][_0xcb71('0x38')]?_0x4593e9[_0xcb71('0x36')]:_0x3152f0[_0xcb71('0x30')];_0x4593e9['order']=qs[_0xcb71('0x3c')](_0x1937bb[_0xcb71('0x32')][_0xcb71('0x3c')]);_0x4593e9[_0xcb71('0x3f')]=qs[_0xcb71('0x34')](_['pick'](_0x1937bb[_0xcb71('0x32')],_0x3152f0[_0xcb71('0x34')]));if(_0x1937bb[_0xcb71('0x32')][_0xcb71('0x42')]){_0x4593e9['where']=_['merge'](_0x4593e9['where'],{'$or':_['map'](_0x4593e9[_0xcb71('0x36')],function(_0xfddc12){var _0x5caf2e={};_0x5caf2e[_0xfddc12]={'$like':'%'+_0x1937bb[_0xcb71('0x32')][_0xcb71('0x42')]+'%'};return _0x5caf2e;})});}_0x4593e9=_[_0xcb71('0x3e')]({},_0x4593e9,_0x1937bb[_0xcb71('0x4a')]);return _0x5200ed[_0xcb71('0x4f')](_0x4593e9);}})[_0xcb71('0x46')](function(_0x2fc75b){if(_0x2fc75b){_0x4ab509=_0x2fc75b[_0xcb71('0x38')];if(!_0x1937bb['query'][_0xcb71('0x39')](_0xcb71('0x3a'))){_0x4593e9[_0xcb71('0x23')]=qs[_0xcb71('0x23')](_0x1937bb[_0xcb71('0x32')]['limit']);_0x4593e9[_0xcb71('0x22')]=qs[_0xcb71('0x22')](_0x1937bb[_0xcb71('0x32')][_0xcb71('0x22')]);}return _0x5200ed[_0xcb71('0x4f')](_0x4593e9);}})['then'](function(_0x15c3fb){if(_0x15c3fb){return _0x15c3fb?{'count':_0x4ab509,'rows':_0x15c3fb}:null;}})[_0xcb71('0x46')](respondWithResult(_0x326136,null))[_0xcb71('0x47')](handleError(_0x326136,null));};exports['addConfiguration']=function(_0x400ffb,_0x1b7ab6,_0xf43a4b){if(_0x400ffb[_0xcb71('0x4c')]['id']){delete _0x400ffb['body']['id'];}return db['FreshsalesAccount']['findOne']({'where':{'id':_0x400ffb['params']['id']}})[_0xcb71('0x46')](handleEntityNotFound(_0x1b7ab6,null))[_0xcb71('0x46')](function(_0x5dce97){if(_0x5dce97){_0x400ffb[_0xcb71('0x4c')][_0xcb71('0x52')]=_0x5dce97['id'];_0x400ffb[_0xcb71('0x4c')][_0xcb71('0x53')]=integrations[_0xcb71('0x54')](_0x400ffb[_0xcb71('0x4c')][_0xcb71('0x55')],_0x400ffb['body'][_0xcb71('0x40')]);_0x400ffb[_0xcb71('0x4c')]['Descriptions']=integrations[_0xcb71('0x56')](_0x400ffb[_0xcb71('0x4c')]['channel'],_0x400ffb[_0xcb71('0x4c')]['type']);return db[_0xcb71('0x51')][_0xcb71('0x4b')](_0x400ffb[_0xcb71('0x4c')],{'include':[{'model':db['FreshsalesField'],'as':_0xcb71('0x53')},{'model':db['FreshsalesField'],'as':_0xcb71('0x57')}]});}return null;})[_0xcb71('0x46')](respondWithResult(_0x1b7ab6,null))['catch'](handleError(_0x1b7ab6,null));};exports[_0xcb71('0x58')]=function(_0x4fad35,_0x3127f0,_0x2e9d63){var _0x47c306='';var _0x25796e='';return db[_0xcb71('0x2e')][_0xcb71('0x50')]({'where':{'id':_0x4fad35['params']['id']},'attributes':['id','username',_0xcb71('0x59'),'apiKey']})[_0xcb71('0x46')](handleEntityNotFound(_0x3127f0,null))[_0xcb71('0x46')](function(_0x502c22){if(_0x502c22){_0x25796e=_0x502c22['username'];_0x47c306=_0x502c22[_0xcb71('0x59')];var _0x614479=_0x502c22[_0xcb71('0x59')]['slice'](-0x1);if(_0x614479==='/'){_0x47c306=_0x47c306[_0xcb71('0x5a')](0x0,_0x47c306[_0xcb71('0x5b')](_0x614479));}return rp({'method':_0xcb71('0x5c'),'uri':util[_0xcb71('0x5d')](_0xcb71('0x5e'),_0x47c306,_0xcb71('0x5f')),'headers':{'Authorization':_0xcb71('0x60')+_0x502c22[_0xcb71('0x61')]},'json':!![]});}})[_0xcb71('0x46')](function(_0x394dfb){if(_0x394dfb){var _0x5780c6=_0x394dfb[_0xcb71('0x62')];var _0x276fe3=![];var _0x40f890=null;for(_0x40f890=0x0;_0x40f890<_0x5780c6[_0xcb71('0x38')];_0x40f890++){if(_0x5780c6[_0x40f890][_0xcb71('0x63')]===_0x25796e){_0x276fe3=!![];}}if(_0x276fe3){return!![];}else{throw new Error({'statusCode':0x194,'message':'Requested\x20Resource\x20not\x20Found'});}}})['then'](respondWithResult(_0x3127f0,null))[_0xcb71('0x47')](function(_0xcac07c){var _0x22b575=_0x4fad35[_0xcb71('0x32')][_0xcb71('0x64')]?0x1f4:_0xcac07c[_0xcb71('0x65')]||0x1f4;logger['error'](_0xcb71('0x66'),_0xcb71('0x58'),_0x22b575,JSON[_0xcb71('0x67')](_0xcac07c));delete _0xcac07c['name'];if(_0x22b575===0x191){_0x22b575=0x190;}_0x3127f0[_0xcb71('0x20')](_0x22b575)['send'](_0x4fad35[_0xcb71('0x32')]['test']?{'message':_0xcb71('0x68'),'statusCode':_0xcac07c[_0xcb71('0x65')]}:_0xcac07c);});};
\ No newline at end of file