Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index ea3fe0d..0ea432c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x91a7=['result','catch','status','end','json','undefined','limit','count','offset','set','apply','reject','save','update','then','destroy','sendStatus','stack','send','index','SalesforceAccount','fieldName','key','model','name','query','keys','filters','intersection','attributes','fields','hasOwnProperty','order','sort','where','filter','merge','type','VIRTUAL','include','findAll','rows','show','params','rawAttributes','length','includeAll','options','find','create','body','getConfigurations','findOne','SalesforceConfiguration','map','nolimit','addConfiguration','AccountId','Subjects','getSubjects','Descriptions','getDescriptions','SalesforceField','getFields','Task','remoteUri','clientId','clientSecret','username','password','securityToken','slice','substring','Connection','login','concat','isNil','ticketType','sobject','IsRecurrence','Subject','Description','int','picklist','email','textarea','phone','includes','label','custom','picklistValues','value','boolean','True','true','False','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','rimraf','zip-dir','fast-json-patch','moment','mustache','sox','to-csv','fs-extra','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','client','http','request','SalesforceAccount,\x20%s,\x20%s','request\x20sent','SalesforceAccount,\x20%s,\x20%s,\x20%s','stringify','error','message'];(function(_0x4da62b,_0x5bf170){var _0x35656d=function(_0x8b573a){while(--_0x8b573a){_0x4da62b['push'](_0x4da62b['shift']());}};_0x35656d(++_0x5bf170);}(_0x91a7,0xe7));var _0x791a=function(_0x6edf33,_0x5721fb){_0x6edf33=_0x6edf33-0x0;var _0x2c8e32=_0x91a7[_0x6edf33];return _0x2c8e32;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x791a('0x0'));var zipdir=require(_0x791a('0x1'));var jsonpatch=require(_0x791a('0x2'));var rp=require('request-promise');var moment=require(_0x791a('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x791a('0x4'));var util=require('util');var path=require('path');var sox=require(_0x791a('0x5'));var csv=require(_0x791a('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x791a('0x7'));var _=require('lodash');var squel=require(_0x791a('0x8'));var crypto=require(_0x791a('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x791a('0xa'));var toCsv=require(_0x791a('0x6'));var querystring=require(_0x791a('0xb'));var Papa=require(_0x791a('0xc'));var Redis=require(_0x791a('0xd'));var authService=require('../../components/auth/service');var qs=require(_0x791a('0xe'));var as=require(_0x791a('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x791a('0x10'))(_0x791a('0x11'));var utils=require(_0x791a('0x12'));var config=require(_0x791a('0x13'));var licenseUtil=require(_0x791a('0x14'));var db=require(_0x791a('0x15'))['db'];var integrations=require('../../components/integrations/configuration');var jayson=require('jayson/promise');var client=jayson[_0x791a('0x16')][_0x791a('0x17')]({'port':0x232a});function respondWithRpcPromise(_0x4c56f0,_0x346c44,_0x3a2ec6,_0x5d5b11){return new BPromise(function(_0x2887f0,_0x31b86d){var _0x2ef5c5=_0x5d5b11||client;return _0x2ef5c5[_0x791a('0x18')](_0x4c56f0,_0x3a2ec6)['then'](function(_0x2ce2e0){logger['info'](_0x791a('0x19'),_0x346c44,_0x791a('0x1a'));logger['debug'](_0x791a('0x1b'),_0x346c44,'request\x20sent',JSON[_0x791a('0x1c')](_0x2ce2e0));if(_0x2ce2e0['error']){if(_0x2ce2e0['error']['code']===0x1f4){logger[_0x791a('0x1d')]('SalesforceAccount,\x20%s,\x20%s',_0x346c44,_0x2ce2e0['error'][_0x791a('0x1e')]);return _0x31b86d(_0x2ce2e0[_0x791a('0x1d')][_0x791a('0x1e')]);}logger[_0x791a('0x1d')]('SalesforceAccount,\x20%s,\x20%s',_0x346c44,_0x2ce2e0[_0x791a('0x1d')][_0x791a('0x1e')]);return _0x2887f0(_0x2ce2e0[_0x791a('0x1d')][_0x791a('0x1e')]);}else{logger['info'](_0x791a('0x19'),_0x346c44,_0x791a('0x1a'));_0x2887f0(_0x2ce2e0[_0x791a('0x1f')][_0x791a('0x1e')]);}})[_0x791a('0x20')](function(_0x1091af){logger[_0x791a('0x1d')](_0x791a('0x19'),_0x346c44,_0x1091af);_0x31b86d(_0x1091af);});});}function respondWithStatusCode(_0x323c6a,_0xe8e452){_0xe8e452=_0xe8e452||0xcc;return function(_0x137992){if(_0x137992){return _0x323c6a['sendStatus'](_0xe8e452);}return _0x323c6a[_0x791a('0x21')](_0xe8e452)[_0x791a('0x22')]();};}function respondWithResult(_0x380329,_0x2966b8){_0x2966b8=_0x2966b8||0xc8;return function(_0x4d748a){if(_0x4d748a){return _0x380329[_0x791a('0x21')](_0x2966b8)[_0x791a('0x23')](_0x4d748a);}};}function respondWithFilteredResult(_0x51dcca,_0xdfa84f){return function(_0x1785f5){if(_0x1785f5){var _0x16dbaf=typeof _0xdfa84f['offset']===_0x791a('0x24')&&typeof _0xdfa84f[_0x791a('0x25')]===_0x791a('0x24');var _0x395376=_0x1785f5[_0x791a('0x26')];var _0x1a9c6b=_0x16dbaf?0x0:_0xdfa84f[_0x791a('0x27')];var _0x889534=_0x16dbaf?_0x1785f5['count']:_0xdfa84f[_0x791a('0x27')]+_0xdfa84f[_0x791a('0x25')];var _0x1b10a7;if(_0x889534>=_0x395376){_0x889534=_0x395376;_0x1b10a7=0xc8;}else{_0x1b10a7=0xce;}_0x51dcca['status'](_0x1b10a7);return _0x51dcca[_0x791a('0x28')]('Content-Range',_0x1a9c6b+'-'+_0x889534+'/'+_0x395376)[_0x791a('0x23')](_0x1785f5);}return null;};}function patchUpdates(_0x2e4ec8){return function(_0xcde862){try{jsonpatch[_0x791a('0x29')](_0xcde862,_0x2e4ec8,!![]);}catch(_0x6f7624){return BPromise[_0x791a('0x2a')](_0x6f7624);}return _0xcde862[_0x791a('0x2b')]();};}function saveUpdates(_0x4f5506,_0x3662c6){return function(_0x401069){if(_0x401069){return _0x401069[_0x791a('0x2c')](_0x4f5506)[_0x791a('0x2d')](function(_0x7d5dd0){return _0x7d5dd0;});}return null;};}function removeEntity(_0x53c5b4,_0x42d650){return function(_0x8e7002){if(_0x8e7002){return _0x8e7002[_0x791a('0x2e')]()[_0x791a('0x2d')](function(){_0x53c5b4[_0x791a('0x21')](0xcc)['end']();});}};}function handleEntityNotFound(_0x305836,_0x1f28af){return function(_0x33f998){if(!_0x33f998){_0x305836[_0x791a('0x2f')](0x194);}return _0x33f998;};}function handleError(_0x321648,_0x52104d){_0x52104d=_0x52104d||0x1f4;return function(_0xd5609){logger['error'](_0xd5609[_0x791a('0x30')]);if(_0xd5609['name']){delete _0xd5609['name'];}_0x321648[_0x791a('0x21')](_0x52104d)[_0x791a('0x31')](_0xd5609);};}exports[_0x791a('0x32')]=function(_0xff5b3c,_0x18e1f5){var _0x3f46be={},_0x29762d={},_0x5ac4c7={'count':0x0,'rows':[]};var _0x37a090=_['map'](db[_0x791a('0x33')]['rawAttributes'],function(_0x25e8cc){return{'name':_0x25e8cc[_0x791a('0x34')],'type':_0x25e8cc['type'][_0x791a('0x35')]};});_0x29762d[_0x791a('0x36')]=_['map'](_0x37a090,_0x791a('0x37'));_0x29762d[_0x791a('0x38')]=_[_0x791a('0x39')](_0xff5b3c[_0x791a('0x38')]);_0x29762d[_0x791a('0x3a')]=_[_0x791a('0x3b')](_0x29762d[_0x791a('0x36')],_0x29762d[_0x791a('0x38')]);_0x3f46be[_0x791a('0x3c')]=_[_0x791a('0x3b')](_0x29762d['model'],qs[_0x791a('0x3d')](_0xff5b3c[_0x791a('0x38')][_0x791a('0x3d')]));_0x3f46be['attributes']=_0x3f46be[_0x791a('0x3c')]['length']?_0x3f46be['attributes']:_0x29762d['model'];if(!_0xff5b3c[_0x791a('0x38')][_0x791a('0x3e')]('nolimit')){_0x3f46be[_0x791a('0x25')]=qs[_0x791a('0x25')](_0xff5b3c[_0x791a('0x38')][_0x791a('0x25')]);_0x3f46be['offset']=qs['offset'](_0xff5b3c['query'][_0x791a('0x27')]);}_0x3f46be[_0x791a('0x3f')]=qs['sort'](_0xff5b3c[_0x791a('0x38')][_0x791a('0x40')]);_0x3f46be[_0x791a('0x41')]=qs[_0x791a('0x3a')](_['pick'](_0xff5b3c[_0x791a('0x38')],_0x29762d['filters']),_0x37a090);if(_0xff5b3c[_0x791a('0x38')][_0x791a('0x42')]){_0x3f46be[_0x791a('0x41')]=_[_0x791a('0x43')](_0x3f46be[_0x791a('0x41')],{'$or':_['map'](_0x37a090,function(_0x21ef06){if(_0x21ef06[_0x791a('0x44')]!==_0x791a('0x45')){var _0x1a5cac={};_0x1a5cac[_0x21ef06[_0x791a('0x37')]]={'$like':'%'+_0xff5b3c['query'][_0x791a('0x42')]+'%'};return _0x1a5cac;}})});}_0x3f46be=_[_0x791a('0x43')]({},_0x3f46be,_0xff5b3c['options']);var _0x5b039e={'where':_0x3f46be[_0x791a('0x41')]};return db[_0x791a('0x33')][_0x791a('0x26')](_0x5b039e)['then'](function(_0x5d1343){_0x5ac4c7[_0x791a('0x26')]=_0x5d1343;if(_0xff5b3c[_0x791a('0x38')]['includeAll']){_0x3f46be[_0x791a('0x46')]=[{'all':!![]}];}return db[_0x791a('0x33')][_0x791a('0x47')](_0x3f46be);})['then'](function(_0x5a30a6){_0x5ac4c7[_0x791a('0x48')]=_0x5a30a6;return _0x5ac4c7;})[_0x791a('0x2d')](respondWithFilteredResult(_0x18e1f5,_0x3f46be))[_0x791a('0x20')](handleError(_0x18e1f5,null));};exports[_0x791a('0x49')]=function(_0x50e52f,_0x2d7c7d){var _0x9f768a={'raw':![],'where':{'id':_0x50e52f[_0x791a('0x4a')]['id']}},_0x4e6d0d={};_0x4e6d0d['model']=_[_0x791a('0x39')](db[_0x791a('0x33')][_0x791a('0x4b')]);_0x4e6d0d[_0x791a('0x38')]=_[_0x791a('0x39')](_0x50e52f[_0x791a('0x38')]);_0x4e6d0d[_0x791a('0x3a')]=_['intersection'](_0x4e6d0d[_0x791a('0x36')],_0x4e6d0d[_0x791a('0x38')]);_0x9f768a['attributes']=_[_0x791a('0x3b')](_0x4e6d0d[_0x791a('0x36')],qs['fields'](_0x50e52f[_0x791a('0x38')][_0x791a('0x3d')]));_0x9f768a[_0x791a('0x3c')]=_0x9f768a[_0x791a('0x3c')][_0x791a('0x4c')]?_0x9f768a['attributes']:_0x4e6d0d['model'];if(_0x50e52f['query'][_0x791a('0x4d')]){_0x9f768a['include']=[{'all':!![]}];}_0x9f768a=_['merge']({},_0x9f768a,_0x50e52f[_0x791a('0x4e')]);return db['SalesforceAccount'][_0x791a('0x4f')](_0x9f768a)[_0x791a('0x2d')](handleEntityNotFound(_0x2d7c7d,null))['then'](respondWithResult(_0x2d7c7d,null))['catch'](handleError(_0x2d7c7d,null));};exports[_0x791a('0x50')]=function(_0x597df2,_0x3bd422){return db[_0x791a('0x33')][_0x791a('0x50')](_0x597df2['body'],{})[_0x791a('0x2d')](respondWithResult(_0x3bd422,0xc9))[_0x791a('0x20')](handleError(_0x3bd422,null));};exports['update']=function(_0x2a2b95,_0x550ebb){if(_0x2a2b95[_0x791a('0x51')]['id']){delete _0x2a2b95[_0x791a('0x51')]['id'];}return db[_0x791a('0x33')][_0x791a('0x4f')]({'where':{'id':_0x2a2b95['params']['id']}})['then'](handleEntityNotFound(_0x550ebb,null))[_0x791a('0x2d')](saveUpdates(_0x2a2b95['body'],null))[_0x791a('0x2d')](respondWithResult(_0x550ebb,null))[_0x791a('0x20')](handleError(_0x550ebb,null));};exports[_0x791a('0x2e')]=function(_0xf11dea,_0x3b760c){return db[_0x791a('0x33')][_0x791a('0x4f')]({'where':{'id':_0xf11dea['params']['id']}})[_0x791a('0x2d')](handleEntityNotFound(_0x3b760c,null))[_0x791a('0x2d')](removeEntity(_0x3b760c,null))[_0x791a('0x20')](handleError(_0x3b760c,null));};exports[_0x791a('0x52')]=function(_0x2d671f,_0xe062f1,_0x182b3a){var _0x5b97e0={};var _0x178cdb={};var _0x575373;var _0x4c4fc5;return db[_0x791a('0x33')][_0x791a('0x53')]({'where':{'id':_0x2d671f[_0x791a('0x4a')]['id']}})[_0x791a('0x2d')](handleEntityNotFound(_0xe062f1,null))[_0x791a('0x2d')](function(_0x129d60){if(_0x129d60){_0x575373=_0x129d60;_0x178cdb[_0x791a('0x36')]=_[_0x791a('0x39')](db[_0x791a('0x54')][_0x791a('0x4b')]);_0x178cdb[_0x791a('0x38')]=_[_0x791a('0x39')](_0x2d671f[_0x791a('0x38')]);_0x178cdb[_0x791a('0x3a')]=_[_0x791a('0x3b')](_0x178cdb[_0x791a('0x36')],_0x178cdb[_0x791a('0x38')]);_0x5b97e0[_0x791a('0x3c')]=_[_0x791a('0x3b')](_0x178cdb[_0x791a('0x36')],qs['fields'](_0x2d671f[_0x791a('0x38')][_0x791a('0x3d')]));_0x5b97e0[_0x791a('0x3c')]=_0x5b97e0[_0x791a('0x3c')][_0x791a('0x4c')]?_0x5b97e0['attributes']:_0x178cdb[_0x791a('0x36')];_0x5b97e0[_0x791a('0x3f')]=qs[_0x791a('0x40')](_0x2d671f[_0x791a('0x38')]['sort']);_0x5b97e0[_0x791a('0x41')]=qs['filters'](_['pick'](_0x2d671f['query'],_0x178cdb['filters']));if(_0x2d671f[_0x791a('0x38')][_0x791a('0x42')]){_0x5b97e0[_0x791a('0x41')]=_[_0x791a('0x43')](_0x5b97e0[_0x791a('0x41')],{'$or':_[_0x791a('0x55')](_0x5b97e0[_0x791a('0x3c')],function(_0x5dca78){var _0x522cb8={};_0x522cb8[_0x5dca78]={'$like':'%'+_0x2d671f[_0x791a('0x38')][_0x791a('0x42')]+'%'};return _0x522cb8;})});}_0x5b97e0=_['merge']({},_0x5b97e0,_0x2d671f['options']);return _0x575373[_0x791a('0x52')](_0x5b97e0);}})[_0x791a('0x2d')](function(_0x4c1c35){if(_0x4c1c35){_0x4c4fc5=_0x4c1c35[_0x791a('0x4c')];if(!_0x2d671f[_0x791a('0x38')][_0x791a('0x3e')](_0x791a('0x56'))){_0x5b97e0['limit']=qs['limit'](_0x2d671f[_0x791a('0x38')][_0x791a('0x25')]);_0x5b97e0['offset']=qs[_0x791a('0x27')](_0x2d671f[_0x791a('0x38')][_0x791a('0x27')]);}return _0x575373[_0x791a('0x52')](_0x5b97e0);}})['then'](function(_0x24efc2){if(_0x24efc2){return _0x24efc2?{'count':_0x4c4fc5,'rows':_0x24efc2}:null;}})[_0x791a('0x2d')](respondWithResult(_0xe062f1,null))[_0x791a('0x20')](handleError(_0xe062f1,null));};exports[_0x791a('0x57')]=function(_0x372abb,_0x2ee8b9,_0xe7bc82){if(_0x372abb[_0x791a('0x51')]['id']){delete _0x372abb['body']['id'];}return db['SalesforceAccount']['findOne']({'where':{'id':_0x372abb[_0x791a('0x4a')]['id']}})[_0x791a('0x2d')](handleEntityNotFound(_0x2ee8b9,null))[_0x791a('0x2d')](function(_0x427765){if(_0x427765){_0x372abb[_0x791a('0x51')][_0x791a('0x58')]=_0x427765['id'];_0x372abb[_0x791a('0x51')][_0x791a('0x59')]=integrations[_0x791a('0x5a')](_0x372abb[_0x791a('0x51')]['channel'],_0x372abb[_0x791a('0x51')][_0x791a('0x44')]);_0x372abb['body'][_0x791a('0x5b')]=integrations[_0x791a('0x5c')](_0x372abb['body']['channel'],_0x372abb[_0x791a('0x51')][_0x791a('0x44')]);return db['SalesforceConfiguration']['create'](_0x372abb[_0x791a('0x51')],{'include':[{'model':db[_0x791a('0x5d')],'as':_0x791a('0x59')},{'model':db['SalesforceField'],'as':_0x791a('0x5b')}]});}return null;})['then'](respondWithResult(_0x2ee8b9,null))[_0x791a('0x20')](handleError(_0x2ee8b9,null));};exports[_0x791a('0x5e')]=function(_0x1d20a9,_0x4072d0,_0x1de053){var _0x20df0a;var _0x4b7e47='';var _0x936ebe=_0x791a('0x5f');return db[_0x791a('0x33')][_0x791a('0x53')]({'where':{'id':_0x1d20a9[_0x791a('0x4a')]['id']},'attributes':['id',_0x791a('0x60'),_0x791a('0x61'),_0x791a('0x62'),_0x791a('0x63'),_0x791a('0x64'),_0x791a('0x65')]})[_0x791a('0x2d')](handleEntityNotFound(_0x4072d0,null))[_0x791a('0x2d')](function(_0x4bf05f){if(_0x4bf05f){_0x4b7e47=_0x4bf05f[_0x791a('0x60')];var _0x1f5ec6=_0x4b7e47[_0x791a('0x66')](-0x1);if(_0x1f5ec6==='/'){_0x4b7e47=_0x4b7e47[_0x791a('0x67')](0x0,_0x4b7e47['lastIndexOf'](_0x1f5ec6));}_0x20df0a=new jsforce[(_0x791a('0x68'))]({'oauth2':{'loginUrl':_0x4b7e47,'clientId':_0x4bf05f[_0x791a('0x61')],'clientSecret':_0x4bf05f[_0x791a('0x62')]}});return _0x20df0a[_0x791a('0x69')](_0x4bf05f[_0x791a('0x63')],_0x4bf05f['password'][_0x791a('0x6a')](_0x4bf05f['securityToken']));}})[_0x791a('0x2d')](function(_0x48b8dc){if(_0x48b8dc){if(!_[_0x791a('0x6b')](_0x1d20a9[_0x791a('0x38')]['ticketType'])){_0x936ebe=_0x1d20a9[_0x791a('0x38')][_0x791a('0x6c')];}return _0x20df0a[_0x791a('0x6d')](_0x936ebe)['describe']();}})[_0x791a('0x2d')](function(_0x57b1b8){var _0x28d7da=['OwnerId','ActivityDate','IsReminderSet',_0x791a('0x6e'),_0x791a('0x6f'),_0x791a('0x70')];var _0xbcb58a=['string',_0x791a('0x71'),_0x791a('0x72'),'boolean',_0x791a('0x73'),_0x791a('0x74'),_0x791a('0x75')];if(_0x57b1b8){_['remove'](_0x57b1b8['fields'],function(_0x2ae2af){return _0x28d7da[_0x791a('0x76')](_0x2ae2af[_0x791a('0x37')])||!_0xbcb58a[_0x791a('0x76')](_0x2ae2af[_0x791a('0x44')]);});return{'count':_0x57b1b8[_0x791a('0x3d')][_0x791a('0x4c')],'rows':_[_0x791a('0x55')](_0x57b1b8['fields'],function(_0x3604cd){return{'id':_0x3604cd[_0x791a('0x37')],'name':_0x3604cd[_0x791a('0x77')],'custom':_0x3604cd[_0x791a('0x78')],'options':_0x3604cd['picklistValues']['length']>0x0?_[_0x791a('0x55')](_0x3604cd[_0x791a('0x79')],function(_0x350d64){return{'name':_0x350d64[_0x791a('0x77')],'value':_0x350d64[_0x791a('0x7a')]};}):_0x3604cd[_0x791a('0x44')]==_0x791a('0x7b')?[{'name':_0x791a('0x7c'),'value':_0x791a('0x7d')},{'name':_0x791a('0x7e'),'value':_0x791a('0x7f')}]:[]};})};}})[_0x791a('0x2d')](respondWithResult(_0x4072d0,null))[_0x791a('0x20')](function(_0x5dc17a){var _0xa8912=_0x1d20a9[_0x791a('0x38')][_0x791a('0x80')]?0x1f4:_0x5dc17a[_0x791a('0x81')]||0x1f4;logger[_0x791a('0x1d')](_0x791a('0x82'),_0x791a('0x5e'),_0xa8912,JSON[_0x791a('0x1c')](_0x5dc17a));delete _0x5dc17a[_0x791a('0x37')];if(_0xa8912===0x191){_0xa8912=0x190;}_0x4072d0[_0x791a('0x21')](_0xa8912)['send'](_0x1d20a9[_0x791a('0x38')][_0x791a('0x80')]?{'message':'Wrong\x20credentials','statusCode':_0x5dc17a[_0x791a('0x81')]}:_0x5dc17a);});};
\ No newline at end of file
+var _0x21f2=['querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','destroy','then','end','sendStatus','stack','name','send','SalesforceAccount','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','pick','filter','where','merge','map','type','VIRTUAL','options','includeAll','findAll','rows','rawAttributes','find','catch','create','body','params','getConfigurations','findOne','SalesforceConfiguration','nolimit','addConfiguration','AccountId','Subjects','channel','SalesforceField','Descriptions','Task','remoteUri','clientId','clientSecret','username','password','substring','lastIndexOf','Connection','login','concat','securityToken','ticketType','describe','OwnerId','IsReminderSet','IsRecurrence','Subject','Description','string','picklist','boolean','textarea','phone','includes','label','custom','picklistValues','value','true','False','false','test','statusCode','error','stringify','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','sox','fs-extra','lodash','squel','jsforce'];(function(_0x29ce14,_0x334166){var _0x48f289=function(_0x288d11){while(--_0x288d11){_0x29ce14['push'](_0x29ce14['shift']());}};_0x48f289(++_0x334166);}(_0x21f2,0x6a));var _0x221f=function(_0x204e4c,_0x2d36a5){_0x204e4c=_0x204e4c-0x0;var _0x3684a7=_0x21f2[_0x204e4c];return _0x3684a7;};'use strict';var emlformat=require(_0x221f('0x0'));var rimraf=require(_0x221f('0x1'));var zipdir=require(_0x221f('0x2'));var jsonpatch=require(_0x221f('0x3'));var rp=require(_0x221f('0x4'));var moment=require('moment');var BPromise=require(_0x221f('0x5'));var Mustache=require(_0x221f('0x6'));var util=require(_0x221f('0x7'));var path=require('path');var sox=require(_0x221f('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x221f('0x9'));var _=require(_0x221f('0xa'));var squel=require(_0x221f('0xb'));var crypto=require('crypto');var jsforce=require(_0x221f('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x221f('0xd'));var Papa=require(_0x221f('0xe'));var Redis=require(_0x221f('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x221f('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x221f('0x11'));var logger=require(_0x221f('0x12'))('api');var utils=require(_0x221f('0x13'));var config=require(_0x221f('0x14'));var licenseUtil=require(_0x221f('0x15'));var db=require(_0x221f('0x16'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x254a21,_0x254c8f){_0x254c8f=_0x254c8f||0xcc;return function(_0x4d550c){if(_0x4d550c){return _0x254a21['sendStatus'](_0x254c8f);}return _0x254a21[_0x221f('0x17')](_0x254c8f)['end']();};}function respondWithResult(_0x16ed3f,_0x4d435f){_0x4d435f=_0x4d435f||0xc8;return function(_0x5d309a){if(_0x5d309a){return _0x16ed3f['status'](_0x4d435f)[_0x221f('0x18')](_0x5d309a);}};}function respondWithFilteredResult(_0x2c2a97,_0x38b37c){return function(_0x155848){if(_0x155848){var _0x4864b4=typeof _0x38b37c[_0x221f('0x19')]===_0x221f('0x1a')&&typeof _0x38b37c[_0x221f('0x1b')]===_0x221f('0x1a');var _0x580c29=_0x155848[_0x221f('0x1c')];var _0x1f9c70=_0x4864b4?0x0:_0x38b37c[_0x221f('0x19')];var _0x349855=_0x4864b4?_0x155848['count']:_0x38b37c[_0x221f('0x19')]+_0x38b37c[_0x221f('0x1b')];var _0x24d2be;if(_0x349855>=_0x580c29){_0x349855=_0x580c29;_0x24d2be=0xc8;}else{_0x24d2be=0xce;}_0x2c2a97['status'](_0x24d2be);return _0x2c2a97[_0x221f('0x1d')](_0x221f('0x1e'),_0x1f9c70+'-'+_0x349855+'/'+_0x580c29)['json'](_0x155848);}return null;};}function patchUpdates(_0x4aa913){return function(_0x1465ac){try{jsonpatch[_0x221f('0x1f')](_0x1465ac,_0x4aa913,!![]);}catch(_0x1936e0){return BPromise[_0x221f('0x20')](_0x1936e0);}return _0x1465ac['save']();};}function saveUpdates(_0x53584f,_0x32d89f){return function(_0x2fee88){if(_0x2fee88){return _0x2fee88[_0x221f('0x21')](_0x53584f)['then'](function(_0x5ab49f){return _0x5ab49f;});}return null;};}function removeEntity(_0x57fec4,_0x1ad962){return function(_0x3be249){if(_0x3be249){return _0x3be249[_0x221f('0x22')]()[_0x221f('0x23')](function(){_0x57fec4['status'](0xcc)[_0x221f('0x24')]();});}};}function handleEntityNotFound(_0x288ac5,_0xb23e5c){return function(_0x5af112){if(!_0x5af112){_0x288ac5[_0x221f('0x25')](0x194);}return _0x5af112;};}function handleError(_0x6e5c55,_0x10d09d){_0x10d09d=_0x10d09d||0x1f4;return function(_0x2887e7){logger['error'](_0x2887e7[_0x221f('0x26')]);if(_0x2887e7[_0x221f('0x27')]){delete _0x2887e7[_0x221f('0x27')];}_0x6e5c55[_0x221f('0x17')](_0x10d09d)[_0x221f('0x28')](_0x2887e7);};}exports['index']=function(_0xbd6496,_0x560bbc){var _0x589f65={},_0x13b239={},_0xb53624={'count':0x0,'rows':[]};var _0x20f2b3=_['map'](db[_0x221f('0x29')]['rawAttributes'],function(_0x437c74){return{'name':_0x437c74[_0x221f('0x2a')],'type':_0x437c74['type'][_0x221f('0x2b')]};});_0x13b239[_0x221f('0x2c')]=_['map'](_0x20f2b3,_0x221f('0x27'));_0x13b239[_0x221f('0x2d')]=_[_0x221f('0x2e')](_0xbd6496[_0x221f('0x2d')]);_0x13b239[_0x221f('0x2f')]=_[_0x221f('0x30')](_0x13b239[_0x221f('0x2c')],_0x13b239[_0x221f('0x2d')]);_0x589f65[_0x221f('0x31')]=_[_0x221f('0x30')](_0x13b239[_0x221f('0x2c')],qs[_0x221f('0x32')](_0xbd6496[_0x221f('0x2d')][_0x221f('0x32')]));_0x589f65[_0x221f('0x31')]=_0x589f65[_0x221f('0x31')][_0x221f('0x33')]?_0x589f65[_0x221f('0x31')]:_0x13b239['model'];if(!_0xbd6496['query'][_0x221f('0x34')]('nolimit')){_0x589f65['limit']=qs[_0x221f('0x1b')](_0xbd6496[_0x221f('0x2d')]['limit']);_0x589f65[_0x221f('0x19')]=qs[_0x221f('0x19')](_0xbd6496[_0x221f('0x2d')][_0x221f('0x19')]);}_0x589f65[_0x221f('0x35')]=qs['sort'](_0xbd6496['query'][_0x221f('0x36')]);_0x589f65['where']=qs['filters'](_[_0x221f('0x37')](_0xbd6496['query'],_0x13b239[_0x221f('0x2f')]),_0x20f2b3);if(_0xbd6496[_0x221f('0x2d')][_0x221f('0x38')]){_0x589f65[_0x221f('0x39')]=_[_0x221f('0x3a')](_0x589f65[_0x221f('0x39')],{'$or':_[_0x221f('0x3b')](_0x20f2b3,function(_0x55dee4){if(_0x55dee4[_0x221f('0x3c')]!==_0x221f('0x3d')){var _0x34e7af={};_0x34e7af[_0x55dee4['name']]={'$like':'%'+_0xbd6496['query']['filter']+'%'};return _0x34e7af;}})});}_0x589f65=_['merge']({},_0x589f65,_0xbd6496[_0x221f('0x3e')]);var _0x4037a1={'where':_0x589f65[_0x221f('0x39')]};return db[_0x221f('0x29')][_0x221f('0x1c')](_0x4037a1)['then'](function(_0x4216c8){_0xb53624[_0x221f('0x1c')]=_0x4216c8;if(_0xbd6496[_0x221f('0x2d')][_0x221f('0x3f')]){_0x589f65['include']=[{'all':!![]}];}return db['SalesforceAccount'][_0x221f('0x40')](_0x589f65);})[_0x221f('0x23')](function(_0x5370b8){_0xb53624[_0x221f('0x41')]=_0x5370b8;return _0xb53624;})['then'](respondWithFilteredResult(_0x560bbc,_0x589f65))['catch'](handleError(_0x560bbc,null));};exports['show']=function(_0x11da66,_0x1ecc5a){var _0xad48fc={'raw':![],'where':{'id':_0x11da66['params']['id']}},_0x408e11={};_0x408e11[_0x221f('0x2c')]=_[_0x221f('0x2e')](db[_0x221f('0x29')][_0x221f('0x42')]);_0x408e11[_0x221f('0x2d')]=_[_0x221f('0x2e')](_0x11da66[_0x221f('0x2d')]);_0x408e11[_0x221f('0x2f')]=_[_0x221f('0x30')](_0x408e11[_0x221f('0x2c')],_0x408e11[_0x221f('0x2d')]);_0xad48fc[_0x221f('0x31')]=_['intersection'](_0x408e11[_0x221f('0x2c')],qs[_0x221f('0x32')](_0x11da66[_0x221f('0x2d')][_0x221f('0x32')]));_0xad48fc[_0x221f('0x31')]=_0xad48fc['attributes']['length']?_0xad48fc[_0x221f('0x31')]:_0x408e11[_0x221f('0x2c')];if(_0x11da66[_0x221f('0x2d')]['includeAll']){_0xad48fc['include']=[{'all':!![]}];}_0xad48fc=_[_0x221f('0x3a')]({},_0xad48fc,_0x11da66['options']);return db[_0x221f('0x29')][_0x221f('0x43')](_0xad48fc)[_0x221f('0x23')](handleEntityNotFound(_0x1ecc5a,null))[_0x221f('0x23')](respondWithResult(_0x1ecc5a,null))[_0x221f('0x44')](handleError(_0x1ecc5a,null));};exports[_0x221f('0x45')]=function(_0x26d465,_0x126706){return db[_0x221f('0x29')]['create'](_0x26d465[_0x221f('0x46')],{})[_0x221f('0x23')](respondWithResult(_0x126706,0xc9))[_0x221f('0x44')](handleError(_0x126706,null));};exports['update']=function(_0x34465c,_0x2b3621){if(_0x34465c[_0x221f('0x46')]['id']){delete _0x34465c[_0x221f('0x46')]['id'];}return db[_0x221f('0x29')][_0x221f('0x43')]({'where':{'id':_0x34465c['params']['id']}})[_0x221f('0x23')](handleEntityNotFound(_0x2b3621,null))['then'](saveUpdates(_0x34465c[_0x221f('0x46')],null))[_0x221f('0x23')](respondWithResult(_0x2b3621,null))[_0x221f('0x44')](handleError(_0x2b3621,null));};exports[_0x221f('0x22')]=function(_0x4bdff9,_0xb40c65){return db[_0x221f('0x29')][_0x221f('0x43')]({'where':{'id':_0x4bdff9[_0x221f('0x47')]['id']}})[_0x221f('0x23')](handleEntityNotFound(_0xb40c65,null))[_0x221f('0x23')](removeEntity(_0xb40c65,null))['catch'](handleError(_0xb40c65,null));};exports[_0x221f('0x48')]=function(_0x3d6017,_0x1537fe,_0x51c825){var _0x29b8b8={};var _0x50a5e9={};var _0x15cdf8;var _0x49e546;return db[_0x221f('0x29')][_0x221f('0x49')]({'where':{'id':_0x3d6017[_0x221f('0x47')]['id']}})[_0x221f('0x23')](handleEntityNotFound(_0x1537fe,null))[_0x221f('0x23')](function(_0xb981f1){if(_0xb981f1){_0x15cdf8=_0xb981f1;_0x50a5e9['model']=_[_0x221f('0x2e')](db[_0x221f('0x4a')]['rawAttributes']);_0x50a5e9[_0x221f('0x2d')]=_[_0x221f('0x2e')](_0x3d6017['query']);_0x50a5e9['filters']=_[_0x221f('0x30')](_0x50a5e9['model'],_0x50a5e9[_0x221f('0x2d')]);_0x29b8b8['attributes']=_[_0x221f('0x30')](_0x50a5e9[_0x221f('0x2c')],qs['fields'](_0x3d6017[_0x221f('0x2d')][_0x221f('0x32')]));_0x29b8b8[_0x221f('0x31')]=_0x29b8b8[_0x221f('0x31')][_0x221f('0x33')]?_0x29b8b8['attributes']:_0x50a5e9[_0x221f('0x2c')];_0x29b8b8[_0x221f('0x35')]=qs[_0x221f('0x36')](_0x3d6017[_0x221f('0x2d')][_0x221f('0x36')]);_0x29b8b8[_0x221f('0x39')]=qs[_0x221f('0x2f')](_[_0x221f('0x37')](_0x3d6017['query'],_0x50a5e9[_0x221f('0x2f')]));if(_0x3d6017[_0x221f('0x2d')][_0x221f('0x38')]){_0x29b8b8[_0x221f('0x39')]=_[_0x221f('0x3a')](_0x29b8b8[_0x221f('0x39')],{'$or':_[_0x221f('0x3b')](_0x29b8b8[_0x221f('0x31')],function(_0x397416){var _0x4e5d64={};_0x4e5d64[_0x397416]={'$like':'%'+_0x3d6017[_0x221f('0x2d')][_0x221f('0x38')]+'%'};return _0x4e5d64;})});}_0x29b8b8=_[_0x221f('0x3a')]({},_0x29b8b8,_0x3d6017[_0x221f('0x3e')]);return _0x15cdf8['getConfigurations'](_0x29b8b8);}})[_0x221f('0x23')](function(_0x592442){if(_0x592442){_0x49e546=_0x592442[_0x221f('0x33')];if(!_0x3d6017[_0x221f('0x2d')][_0x221f('0x34')](_0x221f('0x4b'))){_0x29b8b8[_0x221f('0x1b')]=qs[_0x221f('0x1b')](_0x3d6017['query']['limit']);_0x29b8b8['offset']=qs['offset'](_0x3d6017[_0x221f('0x2d')][_0x221f('0x19')]);}return _0x15cdf8['getConfigurations'](_0x29b8b8);}})['then'](function(_0x24bdaa){if(_0x24bdaa){return _0x24bdaa?{'count':_0x49e546,'rows':_0x24bdaa}:null;}})[_0x221f('0x23')](respondWithResult(_0x1537fe,null))[_0x221f('0x44')](handleError(_0x1537fe,null));};exports[_0x221f('0x4c')]=function(_0x33bd12,_0x38985d,_0x1704f3){if(_0x33bd12[_0x221f('0x46')]['id']){delete _0x33bd12[_0x221f('0x46')]['id'];}return db['SalesforceAccount']['findOne']({'where':{'id':_0x33bd12[_0x221f('0x47')]['id']}})[_0x221f('0x23')](handleEntityNotFound(_0x38985d,null))[_0x221f('0x23')](function(_0x589f15){if(_0x589f15){_0x33bd12[_0x221f('0x46')][_0x221f('0x4d')]=_0x589f15['id'];_0x33bd12[_0x221f('0x46')][_0x221f('0x4e')]=integrations['getSubjects'](_0x33bd12[_0x221f('0x46')][_0x221f('0x4f')],_0x33bd12['body'][_0x221f('0x3c')]);_0x33bd12[_0x221f('0x46')]['Descriptions']=integrations['getDescriptions'](_0x33bd12[_0x221f('0x46')][_0x221f('0x4f')],_0x33bd12['body'][_0x221f('0x3c')]);return db['SalesforceConfiguration'][_0x221f('0x45')](_0x33bd12[_0x221f('0x46')],{'include':[{'model':db[_0x221f('0x50')],'as':_0x221f('0x4e')},{'model':db[_0x221f('0x50')],'as':_0x221f('0x51')}]});}return null;})[_0x221f('0x23')](respondWithResult(_0x38985d,null))[_0x221f('0x44')](handleError(_0x38985d,null));};exports['getFields']=function(_0x1050e,_0x310454,_0x220b53){var _0x2a17ce;var _0x35d3b8='';var _0x363cde=_0x221f('0x52');return db['SalesforceAccount'][_0x221f('0x49')]({'where':{'id':_0x1050e[_0x221f('0x47')]['id']},'attributes':['id',_0x221f('0x53'),_0x221f('0x54'),_0x221f('0x55'),_0x221f('0x56'),_0x221f('0x57'),'securityToken']})[_0x221f('0x23')](handleEntityNotFound(_0x310454,null))['then'](function(_0x2483d6){if(_0x2483d6){_0x35d3b8=_0x2483d6['remoteUri'];var _0x425b1e=_0x35d3b8['slice'](-0x1);if(_0x425b1e==='/'){_0x35d3b8=_0x35d3b8[_0x221f('0x58')](0x0,_0x35d3b8[_0x221f('0x59')](_0x425b1e));}_0x2a17ce=new jsforce[(_0x221f('0x5a'))]({'oauth2':{'loginUrl':_0x35d3b8,'clientId':_0x2483d6[_0x221f('0x54')],'clientSecret':_0x2483d6[_0x221f('0x55')]}});return _0x2a17ce[_0x221f('0x5b')](_0x2483d6[_0x221f('0x56')],_0x2483d6[_0x221f('0x57')][_0x221f('0x5c')](_0x2483d6[_0x221f('0x5d')]));}})['then'](function(_0x44ae0){if(_0x44ae0){if(!_['isNil'](_0x1050e['query'][_0x221f('0x5e')])){_0x363cde=_0x1050e[_0x221f('0x2d')][_0x221f('0x5e')];}return _0x2a17ce['sobject'](_0x363cde)[_0x221f('0x5f')]();}})[_0x221f('0x23')](function(_0x280176){var _0x68d877=[_0x221f('0x60'),'ActivityDate',_0x221f('0x61'),_0x221f('0x62'),_0x221f('0x63'),_0x221f('0x64')];var _0x369d9b=[_0x221f('0x65'),'int',_0x221f('0x66'),_0x221f('0x67'),'email',_0x221f('0x68'),_0x221f('0x69')];if(_0x280176){_['remove'](_0x280176[_0x221f('0x32')],function(_0x566232){return _0x68d877[_0x221f('0x6a')](_0x566232[_0x221f('0x27')])||!_0x369d9b[_0x221f('0x6a')](_0x566232[_0x221f('0x3c')]);});return{'count':_0x280176[_0x221f('0x32')][_0x221f('0x33')],'rows':_[_0x221f('0x3b')](_0x280176[_0x221f('0x32')],function(_0x2cd955){return{'id':_0x2cd955[_0x221f('0x27')],'name':_0x2cd955[_0x221f('0x6b')],'custom':_0x2cd955[_0x221f('0x6c')],'options':_0x2cd955[_0x221f('0x6d')][_0x221f('0x33')]>0x0?_[_0x221f('0x3b')](_0x2cd955[_0x221f('0x6d')],function(_0x21b87e){return{'name':_0x21b87e[_0x221f('0x6b')],'value':_0x21b87e[_0x221f('0x6e')]};}):_0x2cd955[_0x221f('0x3c')]=='boolean'?[{'name':'True','value':_0x221f('0x6f')},{'name':_0x221f('0x70'),'value':_0x221f('0x71')}]:[]};})};}})[_0x221f('0x23')](respondWithResult(_0x310454,null))[_0x221f('0x44')](function(_0x4d346d){var _0x3ff350=_0x1050e[_0x221f('0x2d')][_0x221f('0x72')]?0x1f4:_0x4d346d[_0x221f('0x73')]||0x1f4;logger[_0x221f('0x74')]('getFields,\x20%s,\x20%s,\x20%s','getFields',_0x3ff350,JSON[_0x221f('0x75')](_0x4d346d));delete _0x4d346d[_0x221f('0x27')];if(_0x3ff350===0x191){_0x3ff350=0x190;}_0x310454[_0x221f('0x17')](_0x3ff350)[_0x221f('0x28')](_0x1050e[_0x221f('0x2d')][_0x221f('0x72')]?{'message':_0x221f('0x76'),'statusCode':_0x4d346d[_0x221f('0x73')]}:_0x4d346d);});};
\ No newline at end of file