Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 10ea6be..01d7ad2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7fbe=['model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','VIRTUAL','filter','merge','options','include','findAll','params','includeAll','find','catch','update','body','getSubjects','findOne','FreshsalesField','pick','getDescriptions','getFields','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','FreshsalesConfiguration,\x20%s,\x20%s','request\x20sent','debug','FreshsalesConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','end','status','json','count','offset','set','Content-Range','apply','save','then','destroy','stack','name','send','map','FreshsalesConfiguration','rawAttributes','fieldName','type','key'];(function(_0x334b41,_0x36d415){var _0x21daa0=function(_0x42785f){while(--_0x42785f){_0x334b41['push'](_0x334b41['shift']());}};_0x21daa0(++_0x36d415);}(_0x7fbe,0x1ec));var _0xe7fb=function(_0x4571ae,_0x5309bf){_0x4571ae=_0x4571ae-0x0;var _0x52b48b=_0x7fbe[_0x4571ae];return _0x52b48b;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xe7fb('0x0'));var zipdir=require(_0xe7fb('0x1'));var jsonpatch=require(_0xe7fb('0x2'));var rp=require(_0xe7fb('0x3'));var moment=require(_0xe7fb('0x4'));var BPromise=require(_0xe7fb('0x5'));var Mustache=require(_0xe7fb('0x6'));var util=require(_0xe7fb('0x7'));var path=require(_0xe7fb('0x8'));var sox=require(_0xe7fb('0x9'));var csv=require(_0xe7fb('0xa'));var ejs=require(_0xe7fb('0xb'));var fs=require('fs');var _=require(_0xe7fb('0xc'));var squel=require(_0xe7fb('0xd'));var crypto=require('crypto');var jsforce=require(_0xe7fb('0xe'));var deskjs=require(_0xe7fb('0xf'));var toCsv=require(_0xe7fb('0xa'));var querystring=require(_0xe7fb('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xe7fb('0x11'));var qs=require(_0xe7fb('0x12'));var as=require(_0xe7fb('0x13'));var hardwareService=require(_0xe7fb('0x14'));var logger=require(_0xe7fb('0x15'))(_0xe7fb('0x16'));var utils=require(_0xe7fb('0x17'));var config=require(_0xe7fb('0x18'));var licenseUtil=require(_0xe7fb('0x19'));var db=require(_0xe7fb('0x1a'))['db'];var jayson=require(_0xe7fb('0x1b'));var client=jayson[_0xe7fb('0x1c')][_0xe7fb('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x45fe75,_0x7fe4d3,_0x598729,_0x278b75){return new BPromise(function(_0x2225e5,_0x5573ab){var _0x30015a=_0x278b75||client;return _0x30015a[_0xe7fb('0x1e')](_0x45fe75,_0x598729)['then'](function(_0xa76acf){logger['info'](_0xe7fb('0x1f'),_0x7fe4d3,_0xe7fb('0x20'));logger[_0xe7fb('0x21')](_0xe7fb('0x22'),_0x7fe4d3,'request\x20sent',JSON[_0xe7fb('0x23')](_0xa76acf));if(_0xa76acf['error']){if(_0xa76acf[_0xe7fb('0x24')]['code']===0x1f4){logger[_0xe7fb('0x24')](_0xe7fb('0x1f'),_0x7fe4d3,_0xa76acf[_0xe7fb('0x24')][_0xe7fb('0x25')]);return _0x5573ab(_0xa76acf['error'][_0xe7fb('0x25')]);}logger['error'](_0xe7fb('0x1f'),_0x7fe4d3,_0xa76acf['error'][_0xe7fb('0x25')]);return _0x2225e5(_0xa76acf['error'][_0xe7fb('0x25')]);}else{logger[_0xe7fb('0x26')]('FreshsalesConfiguration,\x20%s,\x20%s',_0x7fe4d3,_0xe7fb('0x20'));_0x2225e5(_0xa76acf[_0xe7fb('0x27')][_0xe7fb('0x25')]);}})['catch'](function(_0x469d50){logger[_0xe7fb('0x24')]('FreshsalesConfiguration,\x20%s,\x20%s',_0x7fe4d3,_0x469d50);_0x5573ab(_0x469d50);});});}function respondWithStatusCode(_0x5bea27,_0x52f08b){_0x52f08b=_0x52f08b||0xcc;return function(_0x35e4db){if(_0x35e4db){return _0x5bea27['sendStatus'](_0x52f08b);}return _0x5bea27['status'](_0x52f08b)[_0xe7fb('0x28')]();};}function respondWithResult(_0x32e8b2,_0x2996ae){_0x2996ae=_0x2996ae||0xc8;return function(_0x4f6c73){if(_0x4f6c73){return _0x32e8b2[_0xe7fb('0x29')](_0x2996ae)[_0xe7fb('0x2a')](_0x4f6c73);}};}function respondWithFilteredResult(_0x390f32,_0x1ceed8){return function(_0x392d75){if(_0x392d75){var _0x16237a=_0x392d75[_0xe7fb('0x2b')],_0x380130=_0x1ceed8[_0xe7fb('0x2c')],_0x59e015=_0x1ceed8[_0xe7fb('0x2c')]+_0x1ceed8['limit'],_0x5df9f2;if(_0x59e015>=_0x16237a){_0x59e015=_0x16237a;_0x5df9f2=0xc8;}else{_0x5df9f2=0xce;}_0x390f32[_0xe7fb('0x29')](_0x5df9f2);return _0x390f32[_0xe7fb('0x2d')](_0xe7fb('0x2e'),_0x380130+'-'+_0x59e015+'/'+_0x16237a)[_0xe7fb('0x2a')](_0x392d75);}return null;};}function patchUpdates(_0x219554){return function(_0x1256d4){try{jsonpatch[_0xe7fb('0x2f')](_0x1256d4,_0x219554,!![]);}catch(_0x3dd0be){return BPromise['reject'](_0x3dd0be);}return _0x1256d4[_0xe7fb('0x30')]();};}function saveUpdates(_0x1742f3,_0x29d1ca){return function(_0x547a04){if(_0x547a04){return _0x547a04['update'](_0x1742f3)[_0xe7fb('0x31')](function(_0x4a9fea){return _0x4a9fea;});}return null;};}function removeEntity(_0xac56b4,_0x2f8774){return function(_0xe49053){if(_0xe49053){return _0xe49053[_0xe7fb('0x32')]()['then'](function(){_0xac56b4[_0xe7fb('0x29')](0xcc)[_0xe7fb('0x28')]();});}};}function handleEntityNotFound(_0x18ed83,_0x2f8818){return function(_0x2d650d){if(!_0x2d650d){_0x18ed83['sendStatus'](0x194);}return _0x2d650d;};}function handleError(_0x256694,_0x121d19){_0x121d19=_0x121d19||0x1f4;return function(_0x209eaa){logger[_0xe7fb('0x24')](_0x209eaa[_0xe7fb('0x33')]);if(_0x209eaa[_0xe7fb('0x34')]){delete _0x209eaa[_0xe7fb('0x34')];}_0x256694[_0xe7fb('0x29')](_0x121d19)[_0xe7fb('0x35')](_0x209eaa);};}exports['index']=function(_0x44d8cf,_0x29ef52){var _0x2593e3={},_0x56e17b={},_0x1de75a={'count':0x0,'rows':[]};var _0x3502dc=_[_0xe7fb('0x36')](db[_0xe7fb('0x37')][_0xe7fb('0x38')],function(_0x35b828){return{'name':_0x35b828[_0xe7fb('0x39')],'type':_0x35b828[_0xe7fb('0x3a')][_0xe7fb('0x3b')]};});_0x56e17b[_0xe7fb('0x3c')]=_[_0xe7fb('0x36')](_0x3502dc,_0xe7fb('0x34'));_0x56e17b[_0xe7fb('0x3d')]=_[_0xe7fb('0x3e')](_0x44d8cf[_0xe7fb('0x3d')]);_0x56e17b[_0xe7fb('0x3f')]=_[_0xe7fb('0x40')](_0x56e17b[_0xe7fb('0x3c')],_0x56e17b[_0xe7fb('0x3d')]);_0x2593e3['attributes']=_[_0xe7fb('0x40')](_0x56e17b[_0xe7fb('0x3c')],qs[_0xe7fb('0x41')](_0x44d8cf[_0xe7fb('0x3d')]['fields']));_0x2593e3[_0xe7fb('0x42')]=_0x2593e3[_0xe7fb('0x42')][_0xe7fb('0x43')]?_0x2593e3[_0xe7fb('0x42')]:_0x56e17b['model'];if(!_0x44d8cf[_0xe7fb('0x3d')][_0xe7fb('0x44')](_0xe7fb('0x45'))){_0x2593e3[_0xe7fb('0x46')]=qs[_0xe7fb('0x46')](_0x44d8cf[_0xe7fb('0x3d')]['limit']);_0x2593e3[_0xe7fb('0x2c')]=qs[_0xe7fb('0x2c')](_0x44d8cf[_0xe7fb('0x3d')]['offset']);}_0x2593e3[_0xe7fb('0x47')]=qs[_0xe7fb('0x48')](_0x44d8cf['query']['sort']);_0x2593e3['where']=qs['filters'](_['pick'](_0x44d8cf[_0xe7fb('0x3d')],_0x56e17b[_0xe7fb('0x3f')]),_0x3502dc);if(_0x44d8cf[_0xe7fb('0x3d')]['filter']){_0x2593e3[_0xe7fb('0x49')]=_['merge'](_0x2593e3[_0xe7fb('0x49')],{'$or':_[_0xe7fb('0x36')](_0x3502dc,function(_0x4d29d3){if(_0x4d29d3[_0xe7fb('0x3a')]!==_0xe7fb('0x4a')){var _0x240efa={};_0x240efa[_0x4d29d3[_0xe7fb('0x34')]]={'$like':'%'+_0x44d8cf['query'][_0xe7fb('0x4b')]+'%'};return _0x240efa;}})});}_0x2593e3=_[_0xe7fb('0x4c')]({},_0x2593e3,_0x44d8cf[_0xe7fb('0x4d')]);var _0x56a84f={'where':_0x2593e3[_0xe7fb('0x49')]};return db[_0xe7fb('0x37')][_0xe7fb('0x2b')](_0x56a84f)[_0xe7fb('0x31')](function(_0xc07c40){_0x1de75a['count']=_0xc07c40;if(_0x44d8cf[_0xe7fb('0x3d')]['includeAll']){_0x2593e3[_0xe7fb('0x4e')]=[{'all':!![]}];}return db[_0xe7fb('0x37')][_0xe7fb('0x4f')](_0x2593e3);})[_0xe7fb('0x31')](function(_0x15cec3){_0x1de75a['rows']=_0x15cec3;return _0x1de75a;})[_0xe7fb('0x31')](respondWithFilteredResult(_0x29ef52,_0x2593e3))['catch'](handleError(_0x29ef52,null));};exports['show']=function(_0x12c828,_0x3d740f){var _0x16327f={'raw':![],'where':{'id':_0x12c828[_0xe7fb('0x50')]['id']}},_0x589555={};_0x589555[_0xe7fb('0x3c')]=_['keys'](db['FreshsalesConfiguration'][_0xe7fb('0x38')]);_0x589555[_0xe7fb('0x3d')]=_[_0xe7fb('0x3e')](_0x12c828[_0xe7fb('0x3d')]);_0x589555[_0xe7fb('0x3f')]=_[_0xe7fb('0x40')](_0x589555[_0xe7fb('0x3c')],_0x589555[_0xe7fb('0x3d')]);_0x16327f['attributes']=_[_0xe7fb('0x40')](_0x589555['model'],qs[_0xe7fb('0x41')](_0x12c828[_0xe7fb('0x3d')]['fields']));_0x16327f[_0xe7fb('0x42')]=_0x16327f['attributes'][_0xe7fb('0x43')]?_0x16327f['attributes']:_0x589555[_0xe7fb('0x3c')];if(_0x12c828['query'][_0xe7fb('0x51')]){_0x16327f['include']=[{'all':!![]}];}_0x16327f=_[_0xe7fb('0x4c')]({},_0x16327f,_0x12c828[_0xe7fb('0x4d')]);return db[_0xe7fb('0x37')][_0xe7fb('0x52')](_0x16327f)[_0xe7fb('0x31')](handleEntityNotFound(_0x3d740f,null))[_0xe7fb('0x31')](respondWithResult(_0x3d740f,null))[_0xe7fb('0x53')](handleError(_0x3d740f,null));};exports['create']=function(_0x5d20dc,_0x20aa55){return db['FreshsalesConfiguration']['create'](_0x5d20dc['body'],{})['then'](respondWithResult(_0x20aa55,0xc9))['catch'](handleError(_0x20aa55,null));};exports[_0xe7fb('0x54')]=function(_0x34dd69,_0xd2fd76){if(_0x34dd69[_0xe7fb('0x55')]['id']){delete _0x34dd69['body']['id'];}return db[_0xe7fb('0x37')][_0xe7fb('0x52')]({'where':{'id':_0x34dd69[_0xe7fb('0x50')]['id']}})['then'](handleEntityNotFound(_0xd2fd76,null))['then'](saveUpdates(_0x34dd69[_0xe7fb('0x55')],null))[_0xe7fb('0x31')](respondWithResult(_0xd2fd76,null))[_0xe7fb('0x53')](handleError(_0xd2fd76,null));};exports['destroy']=function(_0x27f860,_0x3d946b){return db[_0xe7fb('0x37')][_0xe7fb('0x52')]({'where':{'id':_0x27f860['params']['id']}})['then'](handleEntityNotFound(_0x3d946b,null))[_0xe7fb('0x31')](removeEntity(_0x3d946b,null))[_0xe7fb('0x53')](handleError(_0x3d946b,null));};exports[_0xe7fb('0x56')]=function(_0x2f61b1,_0x3b0147,_0x5dd7c8){var _0x9c45a={};var _0x349a2a={};var _0x23755b;var _0x590d7a;return db['FreshsalesConfiguration'][_0xe7fb('0x57')]({'where':{'id':_0x2f61b1[_0xe7fb('0x50')]['id']}})[_0xe7fb('0x31')](handleEntityNotFound(_0x3b0147,null))[_0xe7fb('0x31')](function(_0x40f546){if(_0x40f546){_0x23755b=_0x40f546;_0x349a2a[_0xe7fb('0x3c')]=_['keys'](db[_0xe7fb('0x58')][_0xe7fb('0x38')]);_0x349a2a[_0xe7fb('0x3d')]=_[_0xe7fb('0x3e')](_0x2f61b1[_0xe7fb('0x3d')]);_0x349a2a[_0xe7fb('0x3f')]=_['intersection'](_0x349a2a[_0xe7fb('0x3c')],_0x349a2a['query']);_0x9c45a[_0xe7fb('0x42')]=_[_0xe7fb('0x40')](_0x349a2a[_0xe7fb('0x3c')],qs[_0xe7fb('0x41')](_0x2f61b1['query']['fields']));_0x9c45a[_0xe7fb('0x42')]=_0x9c45a[_0xe7fb('0x42')][_0xe7fb('0x43')]?_0x9c45a[_0xe7fb('0x42')]:_0x349a2a[_0xe7fb('0x3c')];_0x9c45a['order']=qs[_0xe7fb('0x48')](_0x2f61b1['query'][_0xe7fb('0x48')]);_0x9c45a['where']=qs['filters'](_[_0xe7fb('0x59')](_0x2f61b1[_0xe7fb('0x3d')],_0x349a2a[_0xe7fb('0x3f')]));if(_0x2f61b1['query'][_0xe7fb('0x4b')]){_0x9c45a[_0xe7fb('0x49')]=_[_0xe7fb('0x4c')](_0x9c45a[_0xe7fb('0x49')],{'$or':_[_0xe7fb('0x36')](_0x9c45a['attributes'],function(_0x404498){var _0x3c153a={};_0x3c153a[_0x404498]={'$like':'%'+_0x2f61b1['query'][_0xe7fb('0x4b')]+'%'};return _0x3c153a;})});}_0x9c45a=_[_0xe7fb('0x4c')]({},_0x9c45a,_0x2f61b1['options']);return _0x23755b[_0xe7fb('0x56')](_0x9c45a);}})['then'](function(_0x2705ef){if(_0x2705ef){_0x590d7a=_0x2705ef[_0xe7fb('0x43')];if(!_0x2f61b1[_0xe7fb('0x3d')]['hasOwnProperty'](_0xe7fb('0x45'))){_0x9c45a[_0xe7fb('0x46')]=qs[_0xe7fb('0x46')](_0x2f61b1[_0xe7fb('0x3d')][_0xe7fb('0x46')]);_0x9c45a[_0xe7fb('0x2c')]=qs[_0xe7fb('0x2c')](_0x2f61b1[_0xe7fb('0x3d')]['offset']);}return _0x23755b['getSubjects'](_0x9c45a);}})[_0xe7fb('0x31')](function(_0x3a674e){if(_0x3a674e){return _0x3a674e?{'count':_0x590d7a,'rows':_0x3a674e}:null;}})[_0xe7fb('0x31')](respondWithResult(_0x3b0147,null))['catch'](handleError(_0x3b0147,null));};exports['getDescriptions']=function(_0x1ac1fd,_0x2b071c,_0xad7c53){var _0x1df857={};var _0x2d558c={};var _0x336fd3;var _0x188e57;return db[_0xe7fb('0x37')][_0xe7fb('0x57')]({'where':{'id':_0x1ac1fd[_0xe7fb('0x50')]['id']}})[_0xe7fb('0x31')](handleEntityNotFound(_0x2b071c,null))[_0xe7fb('0x31')](function(_0x12b91f){if(_0x12b91f){_0x336fd3=_0x12b91f;_0x2d558c['model']=_['keys'](db[_0xe7fb('0x58')][_0xe7fb('0x38')]);_0x2d558c[_0xe7fb('0x3d')]=_[_0xe7fb('0x3e')](_0x1ac1fd[_0xe7fb('0x3d')]);_0x2d558c['filters']=_[_0xe7fb('0x40')](_0x2d558c[_0xe7fb('0x3c')],_0x2d558c[_0xe7fb('0x3d')]);_0x1df857[_0xe7fb('0x42')]=_[_0xe7fb('0x40')](_0x2d558c[_0xe7fb('0x3c')],qs[_0xe7fb('0x41')](_0x1ac1fd[_0xe7fb('0x3d')][_0xe7fb('0x41')]));_0x1df857['attributes']=_0x1df857[_0xe7fb('0x42')]['length']?_0x1df857[_0xe7fb('0x42')]:_0x2d558c[_0xe7fb('0x3c')];_0x1df857[_0xe7fb('0x47')]=qs[_0xe7fb('0x48')](_0x1ac1fd[_0xe7fb('0x3d')]['sort']);_0x1df857[_0xe7fb('0x49')]=qs[_0xe7fb('0x3f')](_[_0xe7fb('0x59')](_0x1ac1fd[_0xe7fb('0x3d')],_0x2d558c[_0xe7fb('0x3f')]));if(_0x1ac1fd[_0xe7fb('0x3d')][_0xe7fb('0x4b')]){_0x1df857[_0xe7fb('0x49')]=_[_0xe7fb('0x4c')](_0x1df857[_0xe7fb('0x49')],{'$or':_[_0xe7fb('0x36')](_0x1df857[_0xe7fb('0x42')],function(_0x3a68c0){var _0x300a7c={};_0x300a7c[_0x3a68c0]={'$like':'%'+_0x1ac1fd['query']['filter']+'%'};return _0x300a7c;})});}_0x1df857=_['merge']({},_0x1df857,_0x1ac1fd[_0xe7fb('0x4d')]);return _0x336fd3[_0xe7fb('0x5a')](_0x1df857);}})[_0xe7fb('0x31')](function(_0x2789f0){if(_0x2789f0){_0x188e57=_0x2789f0['length'];if(!_0x1ac1fd[_0xe7fb('0x3d')][_0xe7fb('0x44')](_0xe7fb('0x45'))){_0x1df857[_0xe7fb('0x46')]=qs['limit'](_0x1ac1fd[_0xe7fb('0x3d')]['limit']);_0x1df857[_0xe7fb('0x2c')]=qs[_0xe7fb('0x2c')](_0x1ac1fd[_0xe7fb('0x3d')][_0xe7fb('0x2c')]);}return _0x336fd3[_0xe7fb('0x5a')](_0x1df857);}})['then'](function(_0x3ffd6c){if(_0x3ffd6c){return _0x3ffd6c?{'count':_0x188e57,'rows':_0x3ffd6c}:null;}})['then'](respondWithResult(_0x2b071c,null))[_0xe7fb('0x53')](handleError(_0x2b071c,null));};exports['getFields']=function(_0x2aeeed,_0x38f52c,_0x4c37cd){var _0x2b6d69={};var _0x31642f={};var _0xb19e94;var _0x4181fd;return db['FreshsalesConfiguration'][_0xe7fb('0x57')]({'where':{'id':_0x2aeeed[_0xe7fb('0x50')]['id']}})[_0xe7fb('0x31')](handleEntityNotFound(_0x38f52c,null))['then'](function(_0x11d5b6){if(_0x11d5b6){_0xb19e94=_0x11d5b6;_0x31642f['model']=_['keys'](db['FreshsalesField'][_0xe7fb('0x38')]);_0x31642f[_0xe7fb('0x3d')]=_['keys'](_0x2aeeed[_0xe7fb('0x3d')]);_0x31642f[_0xe7fb('0x3f')]=_[_0xe7fb('0x40')](_0x31642f[_0xe7fb('0x3c')],_0x31642f[_0xe7fb('0x3d')]);_0x2b6d69[_0xe7fb('0x42')]=_[_0xe7fb('0x40')](_0x31642f[_0xe7fb('0x3c')],qs[_0xe7fb('0x41')](_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x41')]));_0x2b6d69[_0xe7fb('0x42')]=_0x2b6d69[_0xe7fb('0x42')][_0xe7fb('0x43')]?_0x2b6d69[_0xe7fb('0x42')]:_0x31642f[_0xe7fb('0x3c')];_0x2b6d69[_0xe7fb('0x47')]=qs[_0xe7fb('0x48')](_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x48')]);_0x2b6d69['where']=qs[_0xe7fb('0x3f')](_[_0xe7fb('0x59')](_0x2aeeed[_0xe7fb('0x3d')],_0x31642f[_0xe7fb('0x3f')]));if(_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x4b')]){_0x2b6d69[_0xe7fb('0x49')]=_['merge'](_0x2b6d69['where'],{'$or':_[_0xe7fb('0x36')](_0x2b6d69['attributes'],function(_0x2f486){var _0x496205={};_0x496205[_0x2f486]={'$like':'%'+_0x2aeeed['query'][_0xe7fb('0x4b')]+'%'};return _0x496205;})});}_0x2b6d69=_[_0xe7fb('0x4c')]({},_0x2b6d69,_0x2aeeed[_0xe7fb('0x4d')]);return _0xb19e94[_0xe7fb('0x5b')](_0x2b6d69);}})[_0xe7fb('0x31')](function(_0x38cc9e){if(_0x38cc9e){_0x4181fd=_0x38cc9e['length'];if(!_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x44')](_0xe7fb('0x45'))){_0x2b6d69[_0xe7fb('0x46')]=qs[_0xe7fb('0x46')](_0x2aeeed[_0xe7fb('0x3d')]['limit']);_0x2b6d69['offset']=qs['offset'](_0x2aeeed[_0xe7fb('0x3d')][_0xe7fb('0x2c')]);}return _0xb19e94[_0xe7fb('0x5b')](_0x2b6d69);}})['then'](function(_0xfa895b){if(_0xfa895b){return _0xfa895b?{'count':_0x4181fd,'rows':_0xfa895b}:null;}})['then'](respondWithResult(_0x38f52c,null))[_0xe7fb('0x53')](handleError(_0x38f52c,null));};
\ No newline at end of file
+var _0x033e=['end','status','json','offset','undefined','count','Content-Range','apply','reject','save','update','then','destroy','error','stack','send','index','rawAttributes','fieldName','type','key','map','name','keys','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','merge','filter','options','FreshsalesConfiguration','includeAll','include','findAll','rows','show','find','create','body','catch','params','getSubjects','getDescriptions','findOne','getFields','FreshsalesField','rimraf','zip-dir','fast-json-patch','request-promise','util','path','sox','to-csv','fs-extra','lodash','crypto','desk.js','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','sendStatus'];(function(_0x2f21cf,_0x21b265){var _0x140461=function(_0x5a0ea5){while(--_0x5a0ea5){_0x2f21cf['push'](_0x2f21cf['shift']());}};_0x140461(++_0x21b265);}(_0x033e,0x87));var _0xe033=function(_0x41dcd2,_0x21abc9){_0x41dcd2=_0x41dcd2-0x0;var _0x3a0604=_0x033e[_0x41dcd2];return _0x3a0604;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xe033('0x0'));var zipdir=require(_0xe033('0x1'));var jsonpatch=require(_0xe033('0x2'));var rp=require(_0xe033('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xe033('0x4'));var path=require(_0xe033('0x5'));var sox=require(_0xe033('0x6'));var csv=require(_0xe033('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xe033('0x8'));var _=require(_0xe033('0x9'));var squel=require('squel');var crypto=require(_0xe033('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xe033('0xb'));var toCsv=require('to-csv');var querystring=require(_0xe033('0xc'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xe033('0xd'));var qs=require(_0xe033('0xe'));var as=require(_0xe033('0xf'));var hardwareService=require(_0xe033('0x10'));var logger=require('../../config/logger')('api');var utils=require(_0xe033('0x11'));var config=require(_0xe033('0x12'));var licenseUtil=require(_0xe033('0x13'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5c9e98,_0x3eaf45){_0x3eaf45=_0x3eaf45||0xcc;return function(_0xdbdfc8){if(_0xdbdfc8){return _0x5c9e98[_0xe033('0x14')](_0x3eaf45);}return _0x5c9e98['status'](_0x3eaf45)[_0xe033('0x15')]();};}function respondWithResult(_0x1e7494,_0x2cb37d){_0x2cb37d=_0x2cb37d||0xc8;return function(_0x260124){if(_0x260124){return _0x1e7494[_0xe033('0x16')](_0x2cb37d)[_0xe033('0x17')](_0x260124);}};}function respondWithFilteredResult(_0x35f136,_0x312d0d){return function(_0x16e442){if(_0x16e442){var _0x33c72a=typeof _0x312d0d[_0xe033('0x18')]==='undefined'&&typeof _0x312d0d['limit']===_0xe033('0x19');var _0xa98e22=_0x16e442[_0xe033('0x1a')];var _0x52272b=_0x33c72a?0x0:_0x312d0d['offset'];var _0x28329b=_0x33c72a?_0x16e442[_0xe033('0x1a')]:_0x312d0d[_0xe033('0x18')]+_0x312d0d['limit'];var _0x4faf03;if(_0x28329b>=_0xa98e22){_0x28329b=_0xa98e22;_0x4faf03=0xc8;}else{_0x4faf03=0xce;}_0x35f136[_0xe033('0x16')](_0x4faf03);return _0x35f136['set'](_0xe033('0x1b'),_0x52272b+'-'+_0x28329b+'/'+_0xa98e22)[_0xe033('0x17')](_0x16e442);}return null;};}function patchUpdates(_0x3049fb){return function(_0x3dfcd4){try{jsonpatch[_0xe033('0x1c')](_0x3dfcd4,_0x3049fb,!![]);}catch(_0x881642){return BPromise[_0xe033('0x1d')](_0x881642);}return _0x3dfcd4[_0xe033('0x1e')]();};}function saveUpdates(_0x3bd381,_0x114436){return function(_0x3ef474){if(_0x3ef474){return _0x3ef474[_0xe033('0x1f')](_0x3bd381)[_0xe033('0x20')](function(_0x28bac4){return _0x28bac4;});}return null;};}function removeEntity(_0x4b22b8,_0x23f4d8){return function(_0x44cc45){if(_0x44cc45){return _0x44cc45[_0xe033('0x21')]()['then'](function(){_0x4b22b8[_0xe033('0x16')](0xcc)[_0xe033('0x15')]();});}};}function handleEntityNotFound(_0x16dd5e,_0x24e8f5){return function(_0x1197be){if(!_0x1197be){_0x16dd5e[_0xe033('0x14')](0x194);}return _0x1197be;};}function handleError(_0x53dd26,_0x21aeb6){_0x21aeb6=_0x21aeb6||0x1f4;return function(_0x405ac3){logger[_0xe033('0x22')](_0x405ac3[_0xe033('0x23')]);if(_0x405ac3['name']){delete _0x405ac3['name'];}_0x53dd26[_0xe033('0x16')](_0x21aeb6)[_0xe033('0x24')](_0x405ac3);};}exports[_0xe033('0x25')]=function(_0x4cecf9,_0x52d194){var _0x44e63f={},_0x112aa8={},_0x59971f={'count':0x0,'rows':[]};var _0x4e5157=_['map'](db['FreshsalesConfiguration'][_0xe033('0x26')],function(_0x20a708){return{'name':_0x20a708[_0xe033('0x27')],'type':_0x20a708[_0xe033('0x28')][_0xe033('0x29')]};});_0x112aa8['model']=_[_0xe033('0x2a')](_0x4e5157,_0xe033('0x2b'));_0x112aa8['query']=_[_0xe033('0x2c')](_0x4cecf9[_0xe033('0x2d')]);_0x112aa8[_0xe033('0x2e')]=_[_0xe033('0x2f')](_0x112aa8[_0xe033('0x30')],_0x112aa8[_0xe033('0x2d')]);_0x44e63f['attributes']=_[_0xe033('0x2f')](_0x112aa8[_0xe033('0x30')],qs[_0xe033('0x31')](_0x4cecf9[_0xe033('0x2d')][_0xe033('0x31')]));_0x44e63f['attributes']=_0x44e63f[_0xe033('0x32')][_0xe033('0x33')]?_0x44e63f[_0xe033('0x32')]:_0x112aa8[_0xe033('0x30')];if(!_0x4cecf9[_0xe033('0x2d')][_0xe033('0x34')](_0xe033('0x35'))){_0x44e63f['limit']=qs[_0xe033('0x36')](_0x4cecf9[_0xe033('0x2d')][_0xe033('0x36')]);_0x44e63f[_0xe033('0x18')]=qs[_0xe033('0x18')](_0x4cecf9['query'][_0xe033('0x18')]);}_0x44e63f[_0xe033('0x37')]=qs[_0xe033('0x38')](_0x4cecf9['query'][_0xe033('0x38')]);_0x44e63f[_0xe033('0x39')]=qs[_0xe033('0x2e')](_[_0xe033('0x3a')](_0x4cecf9['query'],_0x112aa8[_0xe033('0x2e')]),_0x4e5157);if(_0x4cecf9[_0xe033('0x2d')]['filter']){_0x44e63f[_0xe033('0x39')]=_[_0xe033('0x3b')](_0x44e63f[_0xe033('0x39')],{'$or':_['map'](_0x4e5157,function(_0x388043){if(_0x388043[_0xe033('0x28')]!=='VIRTUAL'){var _0x52dde6={};_0x52dde6[_0x388043[_0xe033('0x2b')]]={'$like':'%'+_0x4cecf9[_0xe033('0x2d')][_0xe033('0x3c')]+'%'};return _0x52dde6;}})});}_0x44e63f=_[_0xe033('0x3b')]({},_0x44e63f,_0x4cecf9[_0xe033('0x3d')]);var _0x323873={'where':_0x44e63f[_0xe033('0x39')]};return db[_0xe033('0x3e')][_0xe033('0x1a')](_0x323873)['then'](function(_0x3daa9c){_0x59971f['count']=_0x3daa9c;if(_0x4cecf9[_0xe033('0x2d')][_0xe033('0x3f')]){_0x44e63f[_0xe033('0x40')]=[{'all':!![]}];}return db[_0xe033('0x3e')][_0xe033('0x41')](_0x44e63f);})[_0xe033('0x20')](function(_0x336cb7){_0x59971f[_0xe033('0x42')]=_0x336cb7;return _0x59971f;})[_0xe033('0x20')](respondWithFilteredResult(_0x52d194,_0x44e63f))['catch'](handleError(_0x52d194,null));};exports[_0xe033('0x43')]=function(_0x5df62b,_0x223066){var _0x10c64b={'raw':![],'where':{'id':_0x5df62b['params']['id']}},_0x4a4d1d={};_0x4a4d1d[_0xe033('0x30')]=_['keys'](db[_0xe033('0x3e')][_0xe033('0x26')]);_0x4a4d1d['query']=_[_0xe033('0x2c')](_0x5df62b[_0xe033('0x2d')]);_0x4a4d1d[_0xe033('0x2e')]=_['intersection'](_0x4a4d1d['model'],_0x4a4d1d['query']);_0x10c64b['attributes']=_['intersection'](_0x4a4d1d[_0xe033('0x30')],qs[_0xe033('0x31')](_0x5df62b[_0xe033('0x2d')][_0xe033('0x31')]));_0x10c64b['attributes']=_0x10c64b[_0xe033('0x32')][_0xe033('0x33')]?_0x10c64b[_0xe033('0x32')]:_0x4a4d1d['model'];if(_0x5df62b[_0xe033('0x2d')][_0xe033('0x3f')]){_0x10c64b[_0xe033('0x40')]=[{'all':!![]}];}_0x10c64b=_[_0xe033('0x3b')]({},_0x10c64b,_0x5df62b[_0xe033('0x3d')]);return db[_0xe033('0x3e')][_0xe033('0x44')](_0x10c64b)[_0xe033('0x20')](handleEntityNotFound(_0x223066,null))[_0xe033('0x20')](respondWithResult(_0x223066,null))['catch'](handleError(_0x223066,null));};exports[_0xe033('0x45')]=function(_0x1113a8,_0x1716c9){return db[_0xe033('0x3e')]['create'](_0x1113a8['body'],{})[_0xe033('0x20')](respondWithResult(_0x1716c9,0xc9))['catch'](handleError(_0x1716c9,null));};exports[_0xe033('0x1f')]=function(_0x2e41ed,_0x5228c5){if(_0x2e41ed[_0xe033('0x46')]['id']){delete _0x2e41ed[_0xe033('0x46')]['id'];}return db[_0xe033('0x3e')]['find']({'where':{'id':_0x2e41ed['params']['id']}})[_0xe033('0x20')](handleEntityNotFound(_0x5228c5,null))[_0xe033('0x20')](saveUpdates(_0x2e41ed[_0xe033('0x46')],null))[_0xe033('0x20')](respondWithResult(_0x5228c5,null))[_0xe033('0x47')](handleError(_0x5228c5,null));};exports[_0xe033('0x21')]=function(_0x5dee2c,_0x258701){return db[_0xe033('0x3e')][_0xe033('0x44')]({'where':{'id':_0x5dee2c['params']['id']}})[_0xe033('0x20')](handleEntityNotFound(_0x258701,null))[_0xe033('0x20')](removeEntity(_0x258701,null))[_0xe033('0x47')](handleError(_0x258701,null));};exports['getSubjects']=function(_0x54ce89,_0x3bbe94,_0x2e8c2f){var _0x333715={};var _0x4a7ac7={};var _0x3d95d5;var _0x52c2b1;return db['FreshsalesConfiguration']['findOne']({'where':{'id':_0x54ce89[_0xe033('0x48')]['id']}})[_0xe033('0x20')](handleEntityNotFound(_0x3bbe94,null))[_0xe033('0x20')](function(_0x131e8f){if(_0x131e8f){_0x3d95d5=_0x131e8f;_0x4a7ac7['model']=_[_0xe033('0x2c')](db['FreshsalesField'][_0xe033('0x26')]);_0x4a7ac7['query']=_[_0xe033('0x2c')](_0x54ce89[_0xe033('0x2d')]);_0x4a7ac7[_0xe033('0x2e')]=_[_0xe033('0x2f')](_0x4a7ac7[_0xe033('0x30')],_0x4a7ac7['query']);_0x333715[_0xe033('0x32')]=_[_0xe033('0x2f')](_0x4a7ac7[_0xe033('0x30')],qs[_0xe033('0x31')](_0x54ce89['query'][_0xe033('0x31')]));_0x333715[_0xe033('0x32')]=_0x333715[_0xe033('0x32')][_0xe033('0x33')]?_0x333715[_0xe033('0x32')]:_0x4a7ac7[_0xe033('0x30')];_0x333715['order']=qs['sort'](_0x54ce89[_0xe033('0x2d')]['sort']);_0x333715[_0xe033('0x39')]=qs[_0xe033('0x2e')](_[_0xe033('0x3a')](_0x54ce89[_0xe033('0x2d')],_0x4a7ac7['filters']));if(_0x54ce89['query']['filter']){_0x333715[_0xe033('0x39')]=_['merge'](_0x333715[_0xe033('0x39')],{'$or':_[_0xe033('0x2a')](_0x333715[_0xe033('0x32')],function(_0x5a34b9){var _0x44be9d={};_0x44be9d[_0x5a34b9]={'$like':'%'+_0x54ce89[_0xe033('0x2d')]['filter']+'%'};return _0x44be9d;})});}_0x333715=_['merge']({},_0x333715,_0x54ce89[_0xe033('0x3d')]);return _0x3d95d5[_0xe033('0x49')](_0x333715);}})[_0xe033('0x20')](function(_0x39c235){if(_0x39c235){_0x52c2b1=_0x39c235[_0xe033('0x33')];if(!_0x54ce89['query'][_0xe033('0x34')](_0xe033('0x35'))){_0x333715[_0xe033('0x36')]=qs[_0xe033('0x36')](_0x54ce89[_0xe033('0x2d')][_0xe033('0x36')]);_0x333715['offset']=qs['offset'](_0x54ce89[_0xe033('0x2d')][_0xe033('0x18')]);}return _0x3d95d5[_0xe033('0x49')](_0x333715);}})[_0xe033('0x20')](function(_0x357134){if(_0x357134){return _0x357134?{'count':_0x52c2b1,'rows':_0x357134}:null;}})[_0xe033('0x20')](respondWithResult(_0x3bbe94,null))[_0xe033('0x47')](handleError(_0x3bbe94,null));};exports[_0xe033('0x4a')]=function(_0x291f3a,_0x5b803e,_0x5c6334){var _0x4b5a47={};var _0x34af84={};var _0x2fe2ba;var _0x139ad0;return db[_0xe033('0x3e')][_0xe033('0x4b')]({'where':{'id':_0x291f3a['params']['id']}})[_0xe033('0x20')](handleEntityNotFound(_0x5b803e,null))['then'](function(_0x2d2982){if(_0x2d2982){_0x2fe2ba=_0x2d2982;_0x34af84[_0xe033('0x30')]=_[_0xe033('0x2c')](db['FreshsalesField'][_0xe033('0x26')]);_0x34af84[_0xe033('0x2d')]=_[_0xe033('0x2c')](_0x291f3a[_0xe033('0x2d')]);_0x34af84['filters']=_[_0xe033('0x2f')](_0x34af84[_0xe033('0x30')],_0x34af84[_0xe033('0x2d')]);_0x4b5a47[_0xe033('0x32')]=_[_0xe033('0x2f')](_0x34af84[_0xe033('0x30')],qs[_0xe033('0x31')](_0x291f3a[_0xe033('0x2d')][_0xe033('0x31')]));_0x4b5a47[_0xe033('0x32')]=_0x4b5a47[_0xe033('0x32')]['length']?_0x4b5a47['attributes']:_0x34af84[_0xe033('0x30')];_0x4b5a47[_0xe033('0x37')]=qs['sort'](_0x291f3a[_0xe033('0x2d')][_0xe033('0x38')]);_0x4b5a47[_0xe033('0x39')]=qs[_0xe033('0x2e')](_[_0xe033('0x3a')](_0x291f3a['query'],_0x34af84['filters']));if(_0x291f3a[_0xe033('0x2d')]['filter']){_0x4b5a47[_0xe033('0x39')]=_[_0xe033('0x3b')](_0x4b5a47['where'],{'$or':_[_0xe033('0x2a')](_0x4b5a47[_0xe033('0x32')],function(_0x547bd0){var _0x22d39a={};_0x22d39a[_0x547bd0]={'$like':'%'+_0x291f3a[_0xe033('0x2d')][_0xe033('0x3c')]+'%'};return _0x22d39a;})});}_0x4b5a47=_[_0xe033('0x3b')]({},_0x4b5a47,_0x291f3a['options']);return _0x2fe2ba[_0xe033('0x4a')](_0x4b5a47);}})[_0xe033('0x20')](function(_0x210ba7){if(_0x210ba7){_0x139ad0=_0x210ba7['length'];if(!_0x291f3a[_0xe033('0x2d')][_0xe033('0x34')](_0xe033('0x35'))){_0x4b5a47[_0xe033('0x36')]=qs[_0xe033('0x36')](_0x291f3a['query'][_0xe033('0x36')]);_0x4b5a47[_0xe033('0x18')]=qs[_0xe033('0x18')](_0x291f3a['query'][_0xe033('0x18')]);}return _0x2fe2ba[_0xe033('0x4a')](_0x4b5a47);}})['then'](function(_0x23656a){if(_0x23656a){return _0x23656a?{'count':_0x139ad0,'rows':_0x23656a}:null;}})[_0xe033('0x20')](respondWithResult(_0x5b803e,null))['catch'](handleError(_0x5b803e,null));};exports[_0xe033('0x4c')]=function(_0x4c6482,_0x338fa7,_0x39a029){var _0x27b717={};var _0x120f4e={};var _0x4afd1c;var _0x4cd845;return db[_0xe033('0x3e')][_0xe033('0x4b')]({'where':{'id':_0x4c6482[_0xe033('0x48')]['id']}})[_0xe033('0x20')](handleEntityNotFound(_0x338fa7,null))[_0xe033('0x20')](function(_0x26eed7){if(_0x26eed7){_0x4afd1c=_0x26eed7;_0x120f4e[_0xe033('0x30')]=_[_0xe033('0x2c')](db[_0xe033('0x4d')][_0xe033('0x26')]);_0x120f4e[_0xe033('0x2d')]=_[_0xe033('0x2c')](_0x4c6482['query']);_0x120f4e[_0xe033('0x2e')]=_[_0xe033('0x2f')](_0x120f4e['model'],_0x120f4e[_0xe033('0x2d')]);_0x27b717[_0xe033('0x32')]=_[_0xe033('0x2f')](_0x120f4e[_0xe033('0x30')],qs[_0xe033('0x31')](_0x4c6482[_0xe033('0x2d')][_0xe033('0x31')]));_0x27b717[_0xe033('0x32')]=_0x27b717[_0xe033('0x32')][_0xe033('0x33')]?_0x27b717[_0xe033('0x32')]:_0x120f4e['model'];_0x27b717['order']=qs[_0xe033('0x38')](_0x4c6482[_0xe033('0x2d')]['sort']);_0x27b717[_0xe033('0x39')]=qs[_0xe033('0x2e')](_[_0xe033('0x3a')](_0x4c6482[_0xe033('0x2d')],_0x120f4e[_0xe033('0x2e')]));if(_0x4c6482[_0xe033('0x2d')]['filter']){_0x27b717['where']=_[_0xe033('0x3b')](_0x27b717[_0xe033('0x39')],{'$or':_[_0xe033('0x2a')](_0x27b717[_0xe033('0x32')],function(_0x1b84e3){var _0x50d3b1={};_0x50d3b1[_0x1b84e3]={'$like':'%'+_0x4c6482['query'][_0xe033('0x3c')]+'%'};return _0x50d3b1;})});}_0x27b717=_[_0xe033('0x3b')]({},_0x27b717,_0x4c6482[_0xe033('0x3d')]);return _0x4afd1c[_0xe033('0x4c')](_0x27b717);}})['then'](function(_0x311a40){if(_0x311a40){_0x4cd845=_0x311a40[_0xe033('0x33')];if(!_0x4c6482[_0xe033('0x2d')]['hasOwnProperty']('nolimit')){_0x27b717['limit']=qs[_0xe033('0x36')](_0x4c6482[_0xe033('0x2d')][_0xe033('0x36')]);_0x27b717['offset']=qs['offset'](_0x4c6482['query']['offset']);}return _0x4afd1c[_0xe033('0x4c')](_0x27b717);}})[_0xe033('0x20')](function(_0x5e201d){if(_0x5e201d){return _0x5e201d?{'count':_0x4cd845,'rows':_0x5e201d}:null;}})['then'](respondWithResult(_0x338fa7,null))[_0xe033('0x47')](handleError(_0x338fa7,null));};
\ No newline at end of file