Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intFreshsalesField / intFreshsalesField.controller.js
index 83d94e0..ff389c0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x43f0=['options','count','findAll','rows','params','keys','length','include','catch','create','body','find','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','Content-Range','reject','save','update','then','destroy','error','name','send','map','FreshsalesField','rawAttributes','fieldName','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','limit','order','sort','where','pick','filter','merge'];(function(_0x572ce1,_0xa27ca4){var _0x57e794=function(_0x101ff4){while(--_0x101ff4){_0x572ce1['push'](_0x572ce1['shift']());}};_0x57e794(++_0xa27ca4);}(_0x43f0,0x92));var _0x043f=function(_0x385212,_0x19b410){_0x385212=_0x385212-0x0;var _0x27174f=_0x43f0[_0x385212];return _0x27174f;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x043f('0x0'));var zipdir=require(_0x043f('0x1'));var jsonpatch=require(_0x043f('0x2'));var rp=require('request-promise');var moment=require(_0x043f('0x3'));var BPromise=require(_0x043f('0x4'));var Mustache=require('mustache');var util=require(_0x043f('0x5'));var path=require(_0x043f('0x6'));var sox=require('sox');var csv=require(_0x043f('0x7'));var ejs=require(_0x043f('0x8'));var fs=require('fs');var _=require(_0x043f('0x9'));var squel=require(_0x043f('0xa'));var crypto=require(_0x043f('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x043f('0xc'));var toCsv=require(_0x043f('0x7'));var querystring=require(_0x043f('0xd'));var Papa=require('papaparse');var Redis=require(_0x043f('0xe'));var authService=require(_0x043f('0xf'));var qs=require(_0x043f('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x043f('0x11'))(_0x043f('0x12'));var utils=require('../../config/utils');var config=require(_0x043f('0x13'));var licenseUtil=require(_0x043f('0x14'));var db=require(_0x043f('0x15'))['db'];function respondWithStatusCode(_0x5dbf5b,_0x2ebc37){_0x2ebc37=_0x2ebc37||0xcc;return function(_0x36a369){if(_0x36a369){return _0x5dbf5b[_0x043f('0x16')](_0x2ebc37);}return _0x5dbf5b[_0x043f('0x17')](_0x2ebc37)[_0x043f('0x18')]();};}function respondWithResult(_0x1642b3,_0x2ca1a3){_0x2ca1a3=_0x2ca1a3||0xc8;return function(_0x1cd40d){if(_0x1cd40d){return _0x1642b3[_0x043f('0x17')](_0x2ca1a3)[_0x043f('0x19')](_0x1cd40d);}};}function respondWithFilteredResult(_0x5286d1,_0x1e7b73){return function(_0xba2989){if(_0xba2989){var _0x1a4d38=_0xba2989['count'],_0x569dd9=_0x1e7b73[_0x043f('0x1a')],_0x3210b0=_0x1e7b73[_0x043f('0x1a')]+_0x1e7b73['limit'],_0x2bf02f;if(_0x3210b0>=_0x1a4d38){_0x3210b0=_0x1a4d38;_0x2bf02f=0xc8;}else{_0x2bf02f=0xce;}_0x5286d1['status'](_0x2bf02f);return _0x5286d1['set'](_0x043f('0x1b'),_0x569dd9+'-'+_0x3210b0+'/'+_0x1a4d38)[_0x043f('0x19')](_0xba2989);}return null;};}function patchUpdates(_0x2f67f5){return function(_0x2f72ae){try{jsonpatch['apply'](_0x2f72ae,_0x2f67f5,!![]);}catch(_0x48c4dd){return BPromise[_0x043f('0x1c')](_0x48c4dd);}return _0x2f72ae[_0x043f('0x1d')]();};}function saveUpdates(_0x14c046,_0x31a614){return function(_0x5b4521){if(_0x5b4521){return _0x5b4521[_0x043f('0x1e')](_0x14c046)[_0x043f('0x1f')](function(_0x9af1ca){return _0x9af1ca;});}return null;};}function removeEntity(_0x3f8f3a,_0x2ebcdb){return function(_0xc7986d){if(_0xc7986d){return _0xc7986d[_0x043f('0x20')]()[_0x043f('0x1f')](function(){_0x3f8f3a['status'](0xcc)[_0x043f('0x18')]();});}};}function handleEntityNotFound(_0x2ccfcb,_0x8e2812){return function(_0x29460c){if(!_0x29460c){_0x2ccfcb[_0x043f('0x16')](0x194);}return _0x29460c;};}function handleError(_0x164e08,_0x31e3c8){_0x31e3c8=_0x31e3c8||0x1f4;return function(_0x50c5f6){logger[_0x043f('0x21')](_0x50c5f6['stack']);if(_0x50c5f6[_0x043f('0x22')]){delete _0x50c5f6[_0x043f('0x22')];}_0x164e08['status'](_0x31e3c8)[_0x043f('0x23')](_0x50c5f6);};}exports['index']=function(_0x4bf954,_0x47d920){var _0x23a48b={},_0x31f866={},_0x15a74e={'count':0x0,'rows':[]};var _0x1b6490=_[_0x043f('0x24')](db[_0x043f('0x25')][_0x043f('0x26')],function(_0x1d4477){return{'name':_0x1d4477[_0x043f('0x27')],'type':_0x1d4477['type'][_0x043f('0x28')]};});_0x31f866[_0x043f('0x29')]=_[_0x043f('0x24')](_0x1b6490,_0x043f('0x22'));_0x31f866[_0x043f('0x2a')]=_['keys'](_0x4bf954['query']);_0x31f866[_0x043f('0x2b')]=_[_0x043f('0x2c')](_0x31f866[_0x043f('0x29')],_0x31f866[_0x043f('0x2a')]);_0x23a48b[_0x043f('0x2d')]=_[_0x043f('0x2c')](_0x31f866[_0x043f('0x29')],qs['fields'](_0x4bf954[_0x043f('0x2a')][_0x043f('0x2e')]));_0x23a48b[_0x043f('0x2d')]=_0x23a48b[_0x043f('0x2d')]['length']?_0x23a48b[_0x043f('0x2d')]:_0x31f866[_0x043f('0x29')];if(!_0x4bf954[_0x043f('0x2a')][_0x043f('0x2f')]('nolimit')){_0x23a48b[_0x043f('0x30')]=qs[_0x043f('0x30')](_0x4bf954[_0x043f('0x2a')]['limit']);_0x23a48b['offset']=qs[_0x043f('0x1a')](_0x4bf954[_0x043f('0x2a')][_0x043f('0x1a')]);}_0x23a48b[_0x043f('0x31')]=qs[_0x043f('0x32')](_0x4bf954['query'][_0x043f('0x32')]);_0x23a48b[_0x043f('0x33')]=qs['filters'](_[_0x043f('0x34')](_0x4bf954[_0x043f('0x2a')],_0x31f866[_0x043f('0x2b')]),_0x1b6490);if(_0x4bf954[_0x043f('0x2a')][_0x043f('0x35')]){_0x23a48b[_0x043f('0x33')]=_[_0x043f('0x36')](_0x23a48b[_0x043f('0x33')],{'$or':_[_0x043f('0x24')](_0x1b6490,function(_0x4f6fd9){if(_0x4f6fd9['type']!=='VIRTUAL'){var _0x45fd9a={};_0x45fd9a[_0x4f6fd9[_0x043f('0x22')]]={'$like':'%'+_0x4bf954[_0x043f('0x2a')][_0x043f('0x35')]+'%'};return _0x45fd9a;}})});}_0x23a48b=_[_0x043f('0x36')]({},_0x23a48b,_0x4bf954[_0x043f('0x37')]);var _0x11ca12={'where':_0x23a48b['where']};return db[_0x043f('0x25')][_0x043f('0x38')](_0x11ca12)[_0x043f('0x1f')](function(_0x3c787d){_0x15a74e[_0x043f('0x38')]=_0x3c787d;if(_0x4bf954[_0x043f('0x2a')]['includeAll']){_0x23a48b['include']=[{'all':!![]}];}return db[_0x043f('0x25')][_0x043f('0x39')](_0x23a48b);})[_0x043f('0x1f')](function(_0x31d3b4){_0x15a74e[_0x043f('0x3a')]=_0x31d3b4;return _0x15a74e;})[_0x043f('0x1f')](respondWithFilteredResult(_0x47d920,_0x23a48b))['catch'](handleError(_0x47d920,null));};exports['show']=function(_0x29a469,_0x22ec46){var _0x479b69={'raw':!![],'where':{'id':_0x29a469[_0x043f('0x3b')]['id']}},_0x28fefb={};_0x28fefb[_0x043f('0x29')]=_[_0x043f('0x3c')](db[_0x043f('0x25')][_0x043f('0x26')]);_0x28fefb[_0x043f('0x2a')]=_[_0x043f('0x3c')](_0x29a469[_0x043f('0x2a')]);_0x28fefb[_0x043f('0x2b')]=_[_0x043f('0x2c')](_0x28fefb['model'],_0x28fefb[_0x043f('0x2a')]);_0x479b69[_0x043f('0x2d')]=_['intersection'](_0x28fefb['model'],qs['fields'](_0x29a469[_0x043f('0x2a')]['fields']));_0x479b69[_0x043f('0x2d')]=_0x479b69[_0x043f('0x2d')][_0x043f('0x3d')]?_0x479b69['attributes']:_0x28fefb['model'];if(_0x29a469['query']['includeAll']){_0x479b69[_0x043f('0x3e')]=[{'all':!![]}];}_0x479b69=_[_0x043f('0x36')]({},_0x479b69,_0x29a469[_0x043f('0x37')]);return db[_0x043f('0x25')]['find'](_0x479b69)[_0x043f('0x1f')](handleEntityNotFound(_0x22ec46,null))['then'](respondWithResult(_0x22ec46,null))[_0x043f('0x3f')](handleError(_0x22ec46,null));};exports[_0x043f('0x40')]=function(_0x1c3676,_0xac0f1c){return db[_0x043f('0x25')][_0x043f('0x40')](_0x1c3676[_0x043f('0x41')],{})[_0x043f('0x1f')](respondWithResult(_0xac0f1c,0xc9))[_0x043f('0x3f')](handleError(_0xac0f1c,null));};exports[_0x043f('0x1e')]=function(_0x4f76c3,_0x308a32){if(_0x4f76c3[_0x043f('0x41')]['id']){delete _0x4f76c3['body']['id'];}return db[_0x043f('0x25')]['find']({'where':{'id':_0x4f76c3[_0x043f('0x3b')]['id']}})['then'](handleEntityNotFound(_0x308a32,null))[_0x043f('0x1f')](saveUpdates(_0x4f76c3[_0x043f('0x41')],null))[_0x043f('0x1f')](respondWithResult(_0x308a32,null))[_0x043f('0x3f')](handleError(_0x308a32,null));};exports[_0x043f('0x20')]=function(_0x1dd77b,_0x514bc0){return db[_0x043f('0x25')][_0x043f('0x42')]({'where':{'id':_0x1dd77b['params']['id']}})[_0x043f('0x1f')](handleEntityNotFound(_0x514bc0,null))['then'](removeEntity(_0x514bc0,null))[_0x043f('0x3f')](handleError(_0x514bc0,null));};
\ No newline at end of file
+var _0x3e1a=['json','offset','undefined','limit','count','set','Content-Range','apply','save','update','then','destroy','send','index','FreshsalesField','rawAttributes','fieldName','type','key','model','map','name','query','keys','intersection','length','attributes','hasOwnProperty','order','sort','where','filters','pick','filter','merge','options','includeAll','findAll','show','fields','include','create','body','find','params','catch','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','fs-extra','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end'];(function(_0x590daa,_0x28be12){var _0x30098a=function(_0x69f1c0){while(--_0x69f1c0){_0x590daa['push'](_0x590daa['shift']());}};_0x30098a(++_0x28be12);}(_0x3e1a,0xbe));var _0xa3e1=function(_0x432c3a,_0x1bae57){_0x432c3a=_0x432c3a-0x0;var _0x28b285=_0x3e1a[_0x432c3a];return _0x28b285;};'use strict';var emlformat=require(_0xa3e1('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa3e1('0x1'));var jsonpatch=require(_0xa3e1('0x2'));var rp=require(_0xa3e1('0x3'));var moment=require(_0xa3e1('0x4'));var BPromise=require(_0xa3e1('0x5'));var Mustache=require('mustache');var util=require(_0xa3e1('0x6'));var path=require(_0xa3e1('0x7'));var sox=require('sox');var csv=require(_0xa3e1('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa3e1('0x9'));var _=require('lodash');var squel=require(_0xa3e1('0xa'));var crypto=require('crypto');var jsforce=require(_0xa3e1('0xb'));var deskjs=require(_0xa3e1('0xc'));var toCsv=require(_0xa3e1('0x8'));var querystring=require(_0xa3e1('0xd'));var Papa=require(_0xa3e1('0xe'));var Redis=require(_0xa3e1('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xa3e1('0x10'));var as=require(_0xa3e1('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xa3e1('0x12'))(_0xa3e1('0x13'));var utils=require(_0xa3e1('0x14'));var config=require(_0xa3e1('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xa3e1('0x16'))['db'];function respondWithStatusCode(_0xe1a5a3,_0x431d0f){_0x431d0f=_0x431d0f||0xcc;return function(_0x363df8){if(_0x363df8){return _0xe1a5a3[_0xa3e1('0x17')](_0x431d0f);}return _0xe1a5a3[_0xa3e1('0x18')](_0x431d0f)[_0xa3e1('0x19')]();};}function respondWithResult(_0x38bc04,_0x38e2eb){_0x38e2eb=_0x38e2eb||0xc8;return function(_0x3283c7){if(_0x3283c7){return _0x38bc04[_0xa3e1('0x18')](_0x38e2eb)[_0xa3e1('0x1a')](_0x3283c7);}};}function respondWithFilteredResult(_0x38380f,_0x564f7c){return function(_0x449279){if(_0x449279){var _0x3c3c65=typeof _0x564f7c[_0xa3e1('0x1b')]===_0xa3e1('0x1c')&&typeof _0x564f7c[_0xa3e1('0x1d')]===_0xa3e1('0x1c');var _0x76e74=_0x449279[_0xa3e1('0x1e')];var _0x2fa94a=_0x3c3c65?0x0:_0x564f7c[_0xa3e1('0x1b')];var _0x42ed6e=_0x3c3c65?_0x449279[_0xa3e1('0x1e')]:_0x564f7c[_0xa3e1('0x1b')]+_0x564f7c['limit'];var _0xc91273;if(_0x42ed6e>=_0x76e74){_0x42ed6e=_0x76e74;_0xc91273=0xc8;}else{_0xc91273=0xce;}_0x38380f[_0xa3e1('0x18')](_0xc91273);return _0x38380f[_0xa3e1('0x1f')](_0xa3e1('0x20'),_0x2fa94a+'-'+_0x42ed6e+'/'+_0x76e74)['json'](_0x449279);}return null;};}function patchUpdates(_0x2f590f){return function(_0x2e602b){try{jsonpatch[_0xa3e1('0x21')](_0x2e602b,_0x2f590f,!![]);}catch(_0x3bf5d1){return BPromise['reject'](_0x3bf5d1);}return _0x2e602b[_0xa3e1('0x22')]();};}function saveUpdates(_0x385253,_0x3d450c){return function(_0x2b8d75){if(_0x2b8d75){return _0x2b8d75[_0xa3e1('0x23')](_0x385253)[_0xa3e1('0x24')](function(_0x3a1d02){return _0x3a1d02;});}return null;};}function removeEntity(_0x19ac78,_0x241c4b){return function(_0x336577){if(_0x336577){return _0x336577[_0xa3e1('0x25')]()[_0xa3e1('0x24')](function(){_0x19ac78[_0xa3e1('0x18')](0xcc)[_0xa3e1('0x19')]();});}};}function handleEntityNotFound(_0x179fb5,_0x24ec58){return function(_0x50bc8b){if(!_0x50bc8b){_0x179fb5[_0xa3e1('0x17')](0x194);}return _0x50bc8b;};}function handleError(_0x27589a,_0x41b86f){_0x41b86f=_0x41b86f||0x1f4;return function(_0xe014da){logger['error'](_0xe014da['stack']);if(_0xe014da['name']){delete _0xe014da['name'];}_0x27589a['status'](_0x41b86f)[_0xa3e1('0x26')](_0xe014da);};}exports[_0xa3e1('0x27')]=function(_0x29665a,_0x1ba483){var _0x347e7b={},_0x4667e7={},_0x425377={'count':0x0,'rows':[]};var _0x58ac26=_['map'](db[_0xa3e1('0x28')][_0xa3e1('0x29')],function(_0x26e633){return{'name':_0x26e633[_0xa3e1('0x2a')],'type':_0x26e633[_0xa3e1('0x2b')][_0xa3e1('0x2c')]};});_0x4667e7[_0xa3e1('0x2d')]=_[_0xa3e1('0x2e')](_0x58ac26,_0xa3e1('0x2f'));_0x4667e7[_0xa3e1('0x30')]=_[_0xa3e1('0x31')](_0x29665a[_0xa3e1('0x30')]);_0x4667e7['filters']=_[_0xa3e1('0x32')](_0x4667e7[_0xa3e1('0x2d')],_0x4667e7[_0xa3e1('0x30')]);_0x347e7b['attributes']=_['intersection'](_0x4667e7[_0xa3e1('0x2d')],qs['fields'](_0x29665a[_0xa3e1('0x30')]['fields']));_0x347e7b['attributes']=_0x347e7b['attributes'][_0xa3e1('0x33')]?_0x347e7b[_0xa3e1('0x34')]:_0x4667e7['model'];if(!_0x29665a['query'][_0xa3e1('0x35')]('nolimit')){_0x347e7b[_0xa3e1('0x1d')]=qs[_0xa3e1('0x1d')](_0x29665a[_0xa3e1('0x30')]['limit']);_0x347e7b[_0xa3e1('0x1b')]=qs[_0xa3e1('0x1b')](_0x29665a[_0xa3e1('0x30')][_0xa3e1('0x1b')]);}_0x347e7b[_0xa3e1('0x36')]=qs[_0xa3e1('0x37')](_0x29665a['query'][_0xa3e1('0x37')]);_0x347e7b[_0xa3e1('0x38')]=qs[_0xa3e1('0x39')](_[_0xa3e1('0x3a')](_0x29665a[_0xa3e1('0x30')],_0x4667e7[_0xa3e1('0x39')]),_0x58ac26);if(_0x29665a['query'][_0xa3e1('0x3b')]){_0x347e7b['where']=_[_0xa3e1('0x3c')](_0x347e7b[_0xa3e1('0x38')],{'$or':_[_0xa3e1('0x2e')](_0x58ac26,function(_0x187c51){if(_0x187c51[_0xa3e1('0x2b')]!=='VIRTUAL'){var _0x135cc5={};_0x135cc5[_0x187c51[_0xa3e1('0x2f')]]={'$like':'%'+_0x29665a[_0xa3e1('0x30')][_0xa3e1('0x3b')]+'%'};return _0x135cc5;}})});}_0x347e7b=_[_0xa3e1('0x3c')]({},_0x347e7b,_0x29665a[_0xa3e1('0x3d')]);var _0x7769fa={'where':_0x347e7b[_0xa3e1('0x38')]};return db[_0xa3e1('0x28')][_0xa3e1('0x1e')](_0x7769fa)[_0xa3e1('0x24')](function(_0x3d0a4a){_0x425377[_0xa3e1('0x1e')]=_0x3d0a4a;if(_0x29665a['query'][_0xa3e1('0x3e')]){_0x347e7b['include']=[{'all':!![]}];}return db['FreshsalesField'][_0xa3e1('0x3f')](_0x347e7b);})[_0xa3e1('0x24')](function(_0x26d109){_0x425377['rows']=_0x26d109;return _0x425377;})['then'](respondWithFilteredResult(_0x1ba483,_0x347e7b))['catch'](handleError(_0x1ba483,null));};exports[_0xa3e1('0x40')]=function(_0x57375d,_0x7225b8){var _0x3d57e6={'raw':!![],'where':{'id':_0x57375d['params']['id']}},_0x1b5e1b={};_0x1b5e1b[_0xa3e1('0x2d')]=_[_0xa3e1('0x31')](db[_0xa3e1('0x28')][_0xa3e1('0x29')]);_0x1b5e1b[_0xa3e1('0x30')]=_[_0xa3e1('0x31')](_0x57375d['query']);_0x1b5e1b[_0xa3e1('0x39')]=_[_0xa3e1('0x32')](_0x1b5e1b['model'],_0x1b5e1b[_0xa3e1('0x30')]);_0x3d57e6[_0xa3e1('0x34')]=_[_0xa3e1('0x32')](_0x1b5e1b[_0xa3e1('0x2d')],qs['fields'](_0x57375d[_0xa3e1('0x30')][_0xa3e1('0x41')]));_0x3d57e6['attributes']=_0x3d57e6['attributes'][_0xa3e1('0x33')]?_0x3d57e6[_0xa3e1('0x34')]:_0x1b5e1b[_0xa3e1('0x2d')];if(_0x57375d['query'][_0xa3e1('0x3e')]){_0x3d57e6[_0xa3e1('0x42')]=[{'all':!![]}];}_0x3d57e6=_['merge']({},_0x3d57e6,_0x57375d[_0xa3e1('0x3d')]);return db[_0xa3e1('0x28')]['find'](_0x3d57e6)[_0xa3e1('0x24')](handleEntityNotFound(_0x7225b8,null))[_0xa3e1('0x24')](respondWithResult(_0x7225b8,null))['catch'](handleError(_0x7225b8,null));};exports[_0xa3e1('0x43')]=function(_0x4f2c04,_0x54c3d2){return db[_0xa3e1('0x28')]['create'](_0x4f2c04[_0xa3e1('0x44')],{})[_0xa3e1('0x24')](respondWithResult(_0x54c3d2,0xc9))['catch'](handleError(_0x54c3d2,null));};exports[_0xa3e1('0x23')]=function(_0x1153e1,_0x22efac){if(_0x1153e1[_0xa3e1('0x44')]['id']){delete _0x1153e1[_0xa3e1('0x44')]['id'];}return db['FreshsalesField'][_0xa3e1('0x45')]({'where':{'id':_0x1153e1[_0xa3e1('0x46')]['id']}})[_0xa3e1('0x24')](handleEntityNotFound(_0x22efac,null))[_0xa3e1('0x24')](saveUpdates(_0x1153e1['body'],null))['then'](respondWithResult(_0x22efac,null))['catch'](handleError(_0x22efac,null));};exports[_0xa3e1('0x25')]=function(_0x531208,_0x32fec9){return db[_0xa3e1('0x28')][_0xa3e1('0x45')]({'where':{'id':_0x531208['params']['id']}})['then'](handleEntityNotFound(_0x32fec9,null))[_0xa3e1('0x24')](removeEntity(_0x32fec9,null))[_0xa3e1('0x47')](handleError(_0x32fec9,null));};
\ No newline at end of file