Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / intFreshsalesField / intFreshsalesField.controller.js
index 617a891..c8bfdcc 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x30fb=['Content-Range','reject','then','destroy','sendStatus','error','stack','name','send','fieldName','key','model','map','query','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','FreshsalesField','count','includeAll','include','findAll','catch','params','keys','rawAttributes','options','create','body','update','find','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','json','offset','limit','status','set'];(function(_0x46c7c0,_0x132f69){var _0x5b5ed6=function(_0x31dc99){while(--_0x31dc99){_0x46c7c0['push'](_0x46c7c0['shift']());}};_0x5b5ed6(++_0x132f69);}(_0x30fb,0x14a));var _0xb30f=function(_0x537fd3,_0x120947){_0x537fd3=_0x537fd3-0x0;var _0x163abe=_0x30fb[_0x537fd3];return _0x163abe;};'use strict';var pdf=require(_0xb30f('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xb30f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb30f('0x2'));var rp=require(_0xb30f('0x3'));var moment=require(_0xb30f('0x4'));var BPromise=require(_0xb30f('0x5'));var Mustache=require(_0xb30f('0x6'));var util=require(_0xb30f('0x7'));var path=require(_0xb30f('0x8'));var sox=require('sox');var csv=require(_0xb30f('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xb30f('0xa'));var jsforce=require(_0xb30f('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xb30f('0x9'));var querystring=require('querystring');var Papa=require(_0xb30f('0xc'));var Redis=require(_0xb30f('0xd'));var authService=require(_0xb30f('0xe'));var qs=require(_0xb30f('0xf'));var as=require(_0xb30f('0x10'));var hardwareService=require(_0xb30f('0x11'));var logger=require(_0xb30f('0x12'))(_0xb30f('0x13'));var utils=require(_0xb30f('0x14'));var config=require(_0xb30f('0x15'));var licenseUtil=require(_0xb30f('0x16'));var db=require(_0xb30f('0x17'))['db'];function respondWithStatusCode(_0x3f1b22,_0x32b2d2){_0x32b2d2=_0x32b2d2||0xcc;return function(_0x2fc62c){if(_0x2fc62c){return _0x3f1b22['sendStatus'](_0x32b2d2);}return _0x3f1b22['status'](_0x32b2d2)[_0xb30f('0x18')]();};}function respondWithResult(_0x3f2179,_0x70c23f){_0x70c23f=_0x70c23f||0xc8;return function(_0x434b98){if(_0x434b98){return _0x3f2179['status'](_0x70c23f)[_0xb30f('0x19')](_0x434b98);}};}function respondWithFilteredResult(_0x5c5347,_0xba586e){return function(_0x777854){if(_0x777854){var _0x166918=_0x777854['count'],_0x2a279b=_0xba586e[_0xb30f('0x1a')],_0x501702=_0xba586e[_0xb30f('0x1a')]+_0xba586e[_0xb30f('0x1b')],_0x467fa5;if(_0x501702>=_0x166918){_0x501702=_0x166918;_0x467fa5=0xc8;}else{_0x467fa5=0xce;}_0x5c5347[_0xb30f('0x1c')](_0x467fa5);return _0x5c5347[_0xb30f('0x1d')](_0xb30f('0x1e'),_0x2a279b+'-'+_0x501702+'/'+_0x166918)[_0xb30f('0x19')](_0x777854);}return null;};}function patchUpdates(_0x58e3b3){return function(_0x3f668b){try{jsonpatch['apply'](_0x3f668b,_0x58e3b3,!![]);}catch(_0x1618d0){return BPromise[_0xb30f('0x1f')](_0x1618d0);}return _0x3f668b['save']();};}function saveUpdates(_0x3ed044,_0x58633e){return function(_0x2a6cb0){if(_0x2a6cb0){return _0x2a6cb0['update'](_0x3ed044)[_0xb30f('0x20')](function(_0x5e1ba6){return _0x5e1ba6;});}return null;};}function removeEntity(_0x5be864,_0x30f597){return function(_0x53ce7d){if(_0x53ce7d){return _0x53ce7d[_0xb30f('0x21')]()[_0xb30f('0x20')](function(){_0x5be864[_0xb30f('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5bf3dc,_0x573d69){return function(_0x289f7d){if(!_0x289f7d){_0x5bf3dc[_0xb30f('0x22')](0x194);}return _0x289f7d;};}function handleError(_0xb614ca,_0x55910d){_0x55910d=_0x55910d||0x1f4;return function(_0x90810a){logger[_0xb30f('0x23')](_0x90810a[_0xb30f('0x24')]);if(_0x90810a[_0xb30f('0x25')]){delete _0x90810a[_0xb30f('0x25')];}_0xb614ca['status'](_0x55910d)[_0xb30f('0x26')](_0x90810a);};}exports['index']=function(_0x39c146,_0x57a245){var _0x583b77={},_0x236a1a={},_0x10425a={'count':0x0,'rows':[]};var _0x4684b5=_['map'](db['FreshsalesField']['rawAttributes'],function(_0x519f4c){return{'name':_0x519f4c[_0xb30f('0x27')],'type':_0x519f4c['type'][_0xb30f('0x28')]};});_0x236a1a[_0xb30f('0x29')]=_[_0xb30f('0x2a')](_0x4684b5,_0xb30f('0x25'));_0x236a1a[_0xb30f('0x2b')]=_['keys'](_0x39c146[_0xb30f('0x2b')]);_0x236a1a[_0xb30f('0x2c')]=_[_0xb30f('0x2d')](_0x236a1a['model'],_0x236a1a[_0xb30f('0x2b')]);_0x583b77['attributes']=_[_0xb30f('0x2d')](_0x236a1a['model'],qs[_0xb30f('0x2e')](_0x39c146[_0xb30f('0x2b')]['fields']));_0x583b77[_0xb30f('0x2f')]=_0x583b77[_0xb30f('0x2f')]['length']?_0x583b77[_0xb30f('0x2f')]:_0x236a1a[_0xb30f('0x29')];if(!_0x39c146[_0xb30f('0x2b')][_0xb30f('0x30')](_0xb30f('0x31'))){_0x583b77[_0xb30f('0x1b')]=qs[_0xb30f('0x1b')](_0x39c146[_0xb30f('0x2b')][_0xb30f('0x1b')]);_0x583b77['offset']=qs[_0xb30f('0x1a')](_0x39c146[_0xb30f('0x2b')][_0xb30f('0x1a')]);}_0x583b77[_0xb30f('0x32')]=qs[_0xb30f('0x33')](_0x39c146[_0xb30f('0x2b')]['sort']);_0x583b77[_0xb30f('0x34')]=qs['filters'](_[_0xb30f('0x35')](_0x39c146[_0xb30f('0x2b')],_0x236a1a[_0xb30f('0x2c')]),_0x4684b5);if(_0x39c146[_0xb30f('0x2b')][_0xb30f('0x36')]){_0x583b77[_0xb30f('0x34')]=_[_0xb30f('0x37')](_0x583b77[_0xb30f('0x34')],{'$or':_[_0xb30f('0x2a')](_0x4684b5,function(_0x10a00c){if(_0x10a00c[_0xb30f('0x38')]!==_0xb30f('0x39')){var _0x406fc8={};_0x406fc8[_0x10a00c[_0xb30f('0x25')]]={'$like':'%'+_0x39c146[_0xb30f('0x2b')]['filter']+'%'};return _0x406fc8;}})});}_0x583b77=_[_0xb30f('0x37')]({},_0x583b77,_0x39c146['options']);var _0x4f5b07={'where':_0x583b77[_0xb30f('0x34')]};return db[_0xb30f('0x3a')][_0xb30f('0x3b')](_0x4f5b07)[_0xb30f('0x20')](function(_0x3e0bc2){_0x10425a[_0xb30f('0x3b')]=_0x3e0bc2;if(_0x39c146[_0xb30f('0x2b')][_0xb30f('0x3c')]){_0x583b77[_0xb30f('0x3d')]=[{'all':!![]}];}return db['FreshsalesField'][_0xb30f('0x3e')](_0x583b77);})[_0xb30f('0x20')](function(_0x471b48){_0x10425a['rows']=_0x471b48;return _0x10425a;})[_0xb30f('0x20')](respondWithFilteredResult(_0x57a245,_0x583b77))[_0xb30f('0x3f')](handleError(_0x57a245,null));};exports['show']=function(_0x2e88d6,_0x20a146){var _0x8c3586={'raw':!![],'where':{'id':_0x2e88d6[_0xb30f('0x40')]['id']}},_0x892d87={};_0x892d87[_0xb30f('0x29')]=_[_0xb30f('0x41')](db[_0xb30f('0x3a')][_0xb30f('0x42')]);_0x892d87['query']=_[_0xb30f('0x41')](_0x2e88d6[_0xb30f('0x2b')]);_0x892d87[_0xb30f('0x2c')]=_[_0xb30f('0x2d')](_0x892d87[_0xb30f('0x29')],_0x892d87[_0xb30f('0x2b')]);_0x8c3586[_0xb30f('0x2f')]=_[_0xb30f('0x2d')](_0x892d87[_0xb30f('0x29')],qs[_0xb30f('0x2e')](_0x2e88d6[_0xb30f('0x2b')]['fields']));_0x8c3586[_0xb30f('0x2f')]=_0x8c3586[_0xb30f('0x2f')]['length']?_0x8c3586['attributes']:_0x892d87[_0xb30f('0x29')];if(_0x2e88d6[_0xb30f('0x2b')][_0xb30f('0x3c')]){_0x8c3586[_0xb30f('0x3d')]=[{'all':!![]}];}_0x8c3586=_[_0xb30f('0x37')]({},_0x8c3586,_0x2e88d6[_0xb30f('0x43')]);return db['FreshsalesField']['find'](_0x8c3586)[_0xb30f('0x20')](handleEntityNotFound(_0x20a146,null))['then'](respondWithResult(_0x20a146,null))['catch'](handleError(_0x20a146,null));};exports[_0xb30f('0x44')]=function(_0x4b2b31,_0xad7c95){return db[_0xb30f('0x3a')][_0xb30f('0x44')](_0x4b2b31[_0xb30f('0x45')],{})[_0xb30f('0x20')](respondWithResult(_0xad7c95,0xc9))[_0xb30f('0x3f')](handleError(_0xad7c95,null));};exports[_0xb30f('0x46')]=function(_0x2d2243,_0x1ffea4){if(_0x2d2243[_0xb30f('0x45')]['id']){delete _0x2d2243[_0xb30f('0x45')]['id'];}return db[_0xb30f('0x3a')][_0xb30f('0x47')]({'where':{'id':_0x2d2243[_0xb30f('0x40')]['id']}})['then'](handleEntityNotFound(_0x1ffea4,null))[_0xb30f('0x20')](saveUpdates(_0x2d2243[_0xb30f('0x45')],null))[_0xb30f('0x20')](respondWithResult(_0x1ffea4,null))[_0xb30f('0x3f')](handleError(_0x1ffea4,null));};exports[_0xb30f('0x21')]=function(_0x442149,_0x1c40c2){return db[_0xb30f('0x3a')][_0xb30f('0x47')]({'where':{'id':_0x442149['params']['id']}})['then'](handleEntityNotFound(_0x1c40c2,null))[_0xb30f('0x20')](removeEntity(_0x1c40c2,null))[_0xb30f('0x3f')](handleError(_0x1c40c2,null));};
\ No newline at end of file
+var _0xcda8=['limit','count','set','Content-Range','apply','reject','destroy','end','error','stack','send','index','map','FreshsalesField','rawAttributes','fieldName','type','key','model','name','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','filter','where','merge','VIRTUAL','options','includeAll','then','rows','catch','params','keys','find','create','body','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','ejs','fs-extra','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined'];(function(_0x44f65c,_0x55e30c){var _0x4d9573=function(_0x2055cf){while(--_0x2055cf){_0x44f65c['push'](_0x44f65c['shift']());}};_0x4d9573(++_0x55e30c);}(_0xcda8,0x10a));var _0x8cda=function(_0x1952e6,_0x20b617){_0x1952e6=_0x1952e6-0x0;var _0x5d8f9d=_0xcda8[_0x1952e6];return _0x5d8f9d;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x8cda('0x0'));var zipdir=require(_0x8cda('0x1'));var jsonpatch=require(_0x8cda('0x2'));var rp=require(_0x8cda('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x8cda('0x4'));var util=require(_0x8cda('0x5'));var path=require(_0x8cda('0x6'));var sox=require(_0x8cda('0x7'));var csv=require(_0x8cda('0x8'));var ejs=require(_0x8cda('0x9'));var fs=require('fs');var fs_extra=require(_0x8cda('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x8cda('0xb'));var jsforce=require(_0x8cda('0xc'));var deskjs=require(_0x8cda('0xd'));var toCsv=require(_0x8cda('0x8'));var querystring=require('querystring');var Papa=require(_0x8cda('0xe'));var Redis=require(_0x8cda('0xf'));var authService=require(_0x8cda('0x10'));var qs=require(_0x8cda('0x11'));var as=require(_0x8cda('0x12'));var hardwareService=require(_0x8cda('0x13'));var logger=require(_0x8cda('0x14'))(_0x8cda('0x15'));var utils=require(_0x8cda('0x16'));var config=require(_0x8cda('0x17'));var licenseUtil=require(_0x8cda('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x36c364,_0x205498){_0x205498=_0x205498||0xcc;return function(_0x365a04){if(_0x365a04){return _0x36c364[_0x8cda('0x19')](_0x205498);}return _0x36c364[_0x8cda('0x1a')](_0x205498)['end']();};}function respondWithResult(_0x5905ae,_0x191910){_0x191910=_0x191910||0xc8;return function(_0x4b8b08){if(_0x4b8b08){return _0x5905ae['status'](_0x191910)[_0x8cda('0x1b')](_0x4b8b08);}};}function respondWithFilteredResult(_0x20c83a,_0x513b04){return function(_0x50562a){if(_0x50562a){var _0x345e73=typeof _0x513b04[_0x8cda('0x1c')]===_0x8cda('0x1d')&&typeof _0x513b04[_0x8cda('0x1e')]===_0x8cda('0x1d');var _0x38c502=_0x50562a[_0x8cda('0x1f')];var _0xd723=_0x345e73?0x0:_0x513b04['offset'];var _0xa73631=_0x345e73?_0x50562a['count']:_0x513b04[_0x8cda('0x1c')]+_0x513b04[_0x8cda('0x1e')];var _0x4f7aa6;if(_0xa73631>=_0x38c502){_0xa73631=_0x38c502;_0x4f7aa6=0xc8;}else{_0x4f7aa6=0xce;}_0x20c83a['status'](_0x4f7aa6);return _0x20c83a[_0x8cda('0x20')](_0x8cda('0x21'),_0xd723+'-'+_0xa73631+'/'+_0x38c502)[_0x8cda('0x1b')](_0x50562a);}return null;};}function patchUpdates(_0xd35b31){return function(_0x4761f4){try{jsonpatch[_0x8cda('0x22')](_0x4761f4,_0xd35b31,!![]);}catch(_0x3e7d4e){return BPromise[_0x8cda('0x23')](_0x3e7d4e);}return _0x4761f4['save']();};}function saveUpdates(_0x519542,_0x5a064d){return function(_0x4efbdd){if(_0x4efbdd){return _0x4efbdd['update'](_0x519542)['then'](function(_0x21c4a5){return _0x21c4a5;});}return null;};}function removeEntity(_0x174543,_0x2e9476){return function(_0x3e0361){if(_0x3e0361){return _0x3e0361[_0x8cda('0x24')]()['then'](function(){_0x174543[_0x8cda('0x1a')](0xcc)[_0x8cda('0x25')]();});}};}function handleEntityNotFound(_0xa29f17,_0x44dd67){return function(_0x28d246){if(!_0x28d246){_0xa29f17[_0x8cda('0x19')](0x194);}return _0x28d246;};}function handleError(_0x4abff6,_0x10ebaf){_0x10ebaf=_0x10ebaf||0x1f4;return function(_0x541053){logger[_0x8cda('0x26')](_0x541053[_0x8cda('0x27')]);if(_0x541053['name']){delete _0x541053['name'];}_0x4abff6[_0x8cda('0x1a')](_0x10ebaf)[_0x8cda('0x28')](_0x541053);};}exports[_0x8cda('0x29')]=function(_0x5e174b,_0x2a1a81){var _0x81f55e={},_0x24db6e={},_0x5881e3={'count':0x0,'rows':[]};var _0x87882c=_[_0x8cda('0x2a')](db[_0x8cda('0x2b')][_0x8cda('0x2c')],function(_0x5d46ae){return{'name':_0x5d46ae[_0x8cda('0x2d')],'type':_0x5d46ae[_0x8cda('0x2e')][_0x8cda('0x2f')]};});_0x24db6e[_0x8cda('0x30')]=_['map'](_0x87882c,_0x8cda('0x31'));_0x24db6e[_0x8cda('0x32')]=_['keys'](_0x5e174b[_0x8cda('0x32')]);_0x24db6e[_0x8cda('0x33')]=_['intersection'](_0x24db6e[_0x8cda('0x30')],_0x24db6e[_0x8cda('0x32')]);_0x81f55e['attributes']=_[_0x8cda('0x34')](_0x24db6e[_0x8cda('0x30')],qs[_0x8cda('0x35')](_0x5e174b[_0x8cda('0x32')][_0x8cda('0x35')]));_0x81f55e[_0x8cda('0x36')]=_0x81f55e[_0x8cda('0x36')][_0x8cda('0x37')]?_0x81f55e[_0x8cda('0x36')]:_0x24db6e[_0x8cda('0x30')];if(!_0x5e174b[_0x8cda('0x32')][_0x8cda('0x38')](_0x8cda('0x39'))){_0x81f55e[_0x8cda('0x1e')]=qs[_0x8cda('0x1e')](_0x5e174b[_0x8cda('0x32')]['limit']);_0x81f55e[_0x8cda('0x1c')]=qs['offset'](_0x5e174b[_0x8cda('0x32')][_0x8cda('0x1c')]);}_0x81f55e[_0x8cda('0x3a')]=qs['sort'](_0x5e174b[_0x8cda('0x32')][_0x8cda('0x3b')]);_0x81f55e['where']=qs[_0x8cda('0x33')](_['pick'](_0x5e174b[_0x8cda('0x32')],_0x24db6e[_0x8cda('0x33')]),_0x87882c);if(_0x5e174b[_0x8cda('0x32')][_0x8cda('0x3c')]){_0x81f55e[_0x8cda('0x3d')]=_[_0x8cda('0x3e')](_0x81f55e[_0x8cda('0x3d')],{'$or':_[_0x8cda('0x2a')](_0x87882c,function(_0x53935d){if(_0x53935d['type']!==_0x8cda('0x3f')){var _0xf35344={};_0xf35344[_0x53935d[_0x8cda('0x31')]]={'$like':'%'+_0x5e174b[_0x8cda('0x32')][_0x8cda('0x3c')]+'%'};return _0xf35344;}})});}_0x81f55e=_[_0x8cda('0x3e')]({},_0x81f55e,_0x5e174b[_0x8cda('0x40')]);var _0x3b5073={'where':_0x81f55e[_0x8cda('0x3d')]};return db['FreshsalesField'][_0x8cda('0x1f')](_0x3b5073)['then'](function(_0x4a32bb){_0x5881e3[_0x8cda('0x1f')]=_0x4a32bb;if(_0x5e174b[_0x8cda('0x32')][_0x8cda('0x41')]){_0x81f55e['include']=[{'all':!![]}];}return db[_0x8cda('0x2b')]['findAll'](_0x81f55e);})[_0x8cda('0x42')](function(_0x25aeb8){_0x5881e3[_0x8cda('0x43')]=_0x25aeb8;return _0x5881e3;})[_0x8cda('0x42')](respondWithFilteredResult(_0x2a1a81,_0x81f55e))[_0x8cda('0x44')](handleError(_0x2a1a81,null));};exports['show']=function(_0x2e5c0f,_0x598403){var _0xb6619a={'raw':!![],'where':{'id':_0x2e5c0f[_0x8cda('0x45')]['id']}},_0x194bc9={};_0x194bc9[_0x8cda('0x30')]=_[_0x8cda('0x46')](db['FreshsalesField'][_0x8cda('0x2c')]);_0x194bc9['query']=_[_0x8cda('0x46')](_0x2e5c0f[_0x8cda('0x32')]);_0x194bc9[_0x8cda('0x33')]=_[_0x8cda('0x34')](_0x194bc9['model'],_0x194bc9[_0x8cda('0x32')]);_0xb6619a[_0x8cda('0x36')]=_['intersection'](_0x194bc9[_0x8cda('0x30')],qs['fields'](_0x2e5c0f[_0x8cda('0x32')][_0x8cda('0x35')]));_0xb6619a[_0x8cda('0x36')]=_0xb6619a[_0x8cda('0x36')][_0x8cda('0x37')]?_0xb6619a['attributes']:_0x194bc9[_0x8cda('0x30')];if(_0x2e5c0f[_0x8cda('0x32')][_0x8cda('0x41')]){_0xb6619a['include']=[{'all':!![]}];}_0xb6619a=_[_0x8cda('0x3e')]({},_0xb6619a,_0x2e5c0f[_0x8cda('0x40')]);return db[_0x8cda('0x2b')][_0x8cda('0x47')](_0xb6619a)['then'](handleEntityNotFound(_0x598403,null))['then'](respondWithResult(_0x598403,null))['catch'](handleError(_0x598403,null));};exports[_0x8cda('0x48')]=function(_0x420fa1,_0x5b8dab){return db[_0x8cda('0x2b')]['create'](_0x420fa1['body'],{})[_0x8cda('0x42')](respondWithResult(_0x5b8dab,0xc9))[_0x8cda('0x44')](handleError(_0x5b8dab,null));};exports['update']=function(_0x24649b,_0x32d92f){if(_0x24649b[_0x8cda('0x49')]['id']){delete _0x24649b['body']['id'];}return db[_0x8cda('0x2b')][_0x8cda('0x47')]({'where':{'id':_0x24649b[_0x8cda('0x45')]['id']}})[_0x8cda('0x42')](handleEntityNotFound(_0x32d92f,null))[_0x8cda('0x42')](saveUpdates(_0x24649b[_0x8cda('0x49')],null))[_0x8cda('0x42')](respondWithResult(_0x32d92f,null))[_0x8cda('0x44')](handleError(_0x32d92f,null));};exports['destroy']=function(_0x50b796,_0x470421){return db[_0x8cda('0x2b')][_0x8cda('0x47')]({'where':{'id':_0x50b796[_0x8cda('0x45')]['id']}})[_0x8cda('0x42')](handleEntityNotFound(_0x470421,null))['then'](removeEntity(_0x470421,null))[_0x8cda('0x44')](handleError(_0x470421,null));};
\ No newline at end of file