Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index 54043ee..62d0876 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x91f6=['stringify','test','Wrong\x20credentials','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','update','then','destroy','error','stack','name','map','rawAttributes','fieldName','type','query','keys','model','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','filters','pick','filter','where','VIRTUAL','merge','options','SalesforceAccount','includeAll','include','findAll','rows','catch','length','find','create','body','params','findOne','SalesforceConfiguration','getConfigurations','addConfiguration','AccountId','Subjects','getSubjects','getDescriptions','SalesforceField','Descriptions','getFields','remoteUri','clientId','clientSecret','username','password','securityToken','substring','lastIndexOf','Connection','login','concat','ticketType','describe','OwnerId','ActivityDate','IsReminderSet','IsRecurrence','Description','string','picklist','boolean','textarea','label','picklistValues','value','true','False','false','statusCode'];(function(_0x199caf,_0x257250){var _0x4b3648=function(_0x3f2115){while(--_0x3f2115){_0x199caf['push'](_0x199caf['shift']());}};_0x4b3648(++_0x257250);}(_0x91f6,0x168));var _0x691f=function(_0x10038b,_0x3308d5){_0x10038b=_0x10038b-0x0;var _0x392a8d=_0x91f6[_0x10038b];return _0x392a8d;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x691f('0x0'));var zipdir=require(_0x691f('0x1'));var jsonpatch=require(_0x691f('0x2'));var rp=require(_0x691f('0x3'));var moment=require(_0x691f('0x4'));var BPromise=require(_0x691f('0x5'));var Mustache=require(_0x691f('0x6'));var util=require(_0x691f('0x7'));var path=require('path');var sox=require(_0x691f('0x8'));var csv=require(_0x691f('0x9'));var ejs=require(_0x691f('0xa'));var fs=require('fs');var fs_extra=require(_0x691f('0xb'));var _=require(_0x691f('0xc'));var squel=require(_0x691f('0xd'));var crypto=require(_0x691f('0xe'));var jsforce=require(_0x691f('0xf'));var deskjs=require(_0x691f('0x10'));var toCsv=require('to-csv');var querystring=require(_0x691f('0x11'));var Papa=require(_0x691f('0x12'));var Redis=require('ioredis');var authService=require(_0x691f('0x13'));var qs=require(_0x691f('0x14'));var as=require(_0x691f('0x15'));var hardwareService=require(_0x691f('0x16'));var logger=require('../../config/logger')(_0x691f('0x17'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x691f('0x18'));var db=require(_0x691f('0x19'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x5d8856,_0x3fc391){_0x3fc391=_0x3fc391||0xcc;return function(_0x1b46e2){if(_0x1b46e2){return _0x5d8856[_0x691f('0x1a')](_0x3fc391);}return _0x5d8856[_0x691f('0x1b')](_0x3fc391)[_0x691f('0x1c')]();};}function respondWithResult(_0x5990e2,_0x194b66){_0x194b66=_0x194b66||0xc8;return function(_0x2a2453){if(_0x2a2453){return _0x5990e2['status'](_0x194b66)[_0x691f('0x1d')](_0x2a2453);}};}function respondWithFilteredResult(_0x1b3cdc,_0xf474d2){return function(_0x4c4171){if(_0x4c4171){var _0x4d4bbb=typeof _0xf474d2[_0x691f('0x1e')]==='undefined'&&typeof _0xf474d2['limit']===_0x691f('0x1f');var _0x47e0cc=_0x4c4171[_0x691f('0x20')];var _0x2b7c0c=_0x4d4bbb?0x0:_0xf474d2[_0x691f('0x1e')];var _0x4b7601=_0x4d4bbb?_0x4c4171[_0x691f('0x20')]:_0xf474d2[_0x691f('0x1e')]+_0xf474d2[_0x691f('0x21')];var _0x110941;if(_0x4b7601>=_0x47e0cc){_0x4b7601=_0x47e0cc;_0x110941=0xc8;}else{_0x110941=0xce;}_0x1b3cdc[_0x691f('0x1b')](_0x110941);return _0x1b3cdc[_0x691f('0x22')](_0x691f('0x23'),_0x2b7c0c+'-'+_0x4b7601+'/'+_0x47e0cc)[_0x691f('0x1d')](_0x4c4171);}return null;};}function patchUpdates(_0x4fb708){return function(_0x1b7c36){try{jsonpatch[_0x691f('0x24')](_0x1b7c36,_0x4fb708,!![]);}catch(_0x15ad9e){return BPromise[_0x691f('0x25')](_0x15ad9e);}return _0x1b7c36['save']();};}function saveUpdates(_0x40956a,_0x4440cf){return function(_0x5f0dee){if(_0x5f0dee){return _0x5f0dee[_0x691f('0x26')](_0x40956a)[_0x691f('0x27')](function(_0x47e18c){return _0x47e18c;});}return null;};}function removeEntity(_0x2bab09,_0x1a3312){return function(_0x41d958){if(_0x41d958){return _0x41d958[_0x691f('0x28')]()[_0x691f('0x27')](function(){_0x2bab09[_0x691f('0x1b')](0xcc)[_0x691f('0x1c')]();});}};}function handleEntityNotFound(_0x27a30d,_0x1778a7){return function(_0x20d62f){if(!_0x20d62f){_0x27a30d[_0x691f('0x1a')](0x194);}return _0x20d62f;};}function handleError(_0x14d0e5,_0x3c2b2c){_0x3c2b2c=_0x3c2b2c||0x1f4;return function(_0x43d8ee){logger[_0x691f('0x29')](_0x43d8ee[_0x691f('0x2a')]);if(_0x43d8ee[_0x691f('0x2b')]){delete _0x43d8ee[_0x691f('0x2b')];}_0x14d0e5[_0x691f('0x1b')](_0x3c2b2c)['send'](_0x43d8ee);};}exports['index']=function(_0xa222a7,_0x5d570e){var _0x234175={},_0x389998={},_0x658592={'count':0x0,'rows':[]};var _0x5582f9=_[_0x691f('0x2c')](db['SalesforceAccount'][_0x691f('0x2d')],function(_0x4e1dc3){return{'name':_0x4e1dc3[_0x691f('0x2e')],'type':_0x4e1dc3[_0x691f('0x2f')]['key']};});_0x389998['model']=_[_0x691f('0x2c')](_0x5582f9,_0x691f('0x2b'));_0x389998[_0x691f('0x30')]=_[_0x691f('0x31')](_0xa222a7[_0x691f('0x30')]);_0x389998['filters']=_['intersection'](_0x389998[_0x691f('0x32')],_0x389998[_0x691f('0x30')]);_0x234175[_0x691f('0x33')]=_[_0x691f('0x34')](_0x389998[_0x691f('0x32')],qs[_0x691f('0x35')](_0xa222a7['query'][_0x691f('0x35')]));_0x234175['attributes']=_0x234175['attributes']['length']?_0x234175[_0x691f('0x33')]:_0x389998[_0x691f('0x32')];if(!_0xa222a7[_0x691f('0x30')][_0x691f('0x36')](_0x691f('0x37'))){_0x234175[_0x691f('0x21')]=qs[_0x691f('0x21')](_0xa222a7[_0x691f('0x30')][_0x691f('0x21')]);_0x234175[_0x691f('0x1e')]=qs[_0x691f('0x1e')](_0xa222a7['query'][_0x691f('0x1e')]);}_0x234175[_0x691f('0x38')]=qs['sort'](_0xa222a7['query'][_0x691f('0x39')]);_0x234175['where']=qs[_0x691f('0x3a')](_[_0x691f('0x3b')](_0xa222a7[_0x691f('0x30')],_0x389998[_0x691f('0x3a')]),_0x5582f9);if(_0xa222a7['query'][_0x691f('0x3c')]){_0x234175['where']=_['merge'](_0x234175[_0x691f('0x3d')],{'$or':_[_0x691f('0x2c')](_0x5582f9,function(_0x5308e7){if(_0x5308e7[_0x691f('0x2f')]!==_0x691f('0x3e')){var _0x33b7f5={};_0x33b7f5[_0x5308e7[_0x691f('0x2b')]]={'$like':'%'+_0xa222a7[_0x691f('0x30')][_0x691f('0x3c')]+'%'};return _0x33b7f5;}})});}_0x234175=_[_0x691f('0x3f')]({},_0x234175,_0xa222a7[_0x691f('0x40')]);var _0x43ee7c={'where':_0x234175['where']};return db[_0x691f('0x41')]['count'](_0x43ee7c)[_0x691f('0x27')](function(_0x106011){_0x658592['count']=_0x106011;if(_0xa222a7[_0x691f('0x30')][_0x691f('0x42')]){_0x234175[_0x691f('0x43')]=[{'all':!![]}];}return db['SalesforceAccount'][_0x691f('0x44')](_0x234175);})['then'](function(_0x15582e){_0x658592[_0x691f('0x45')]=_0x15582e;return _0x658592;})[_0x691f('0x27')](respondWithFilteredResult(_0x5d570e,_0x234175))[_0x691f('0x46')](handleError(_0x5d570e,null));};exports['show']=function(_0x3ce0a0,_0x2e0007){var _0x9f8d6b={'raw':![],'where':{'id':_0x3ce0a0['params']['id']}},_0x254af2={};_0x254af2['model']=_['keys'](db[_0x691f('0x41')][_0x691f('0x2d')]);_0x254af2['query']=_[_0x691f('0x31')](_0x3ce0a0[_0x691f('0x30')]);_0x254af2['filters']=_[_0x691f('0x34')](_0x254af2[_0x691f('0x32')],_0x254af2[_0x691f('0x30')]);_0x9f8d6b[_0x691f('0x33')]=_[_0x691f('0x34')](_0x254af2[_0x691f('0x32')],qs[_0x691f('0x35')](_0x3ce0a0[_0x691f('0x30')]['fields']));_0x9f8d6b[_0x691f('0x33')]=_0x9f8d6b[_0x691f('0x33')][_0x691f('0x47')]?_0x9f8d6b[_0x691f('0x33')]:_0x254af2[_0x691f('0x32')];if(_0x3ce0a0['query'][_0x691f('0x42')]){_0x9f8d6b[_0x691f('0x43')]=[{'all':!![]}];}_0x9f8d6b=_[_0x691f('0x3f')]({},_0x9f8d6b,_0x3ce0a0[_0x691f('0x40')]);return db[_0x691f('0x41')][_0x691f('0x48')](_0x9f8d6b)['then'](handleEntityNotFound(_0x2e0007,null))['then'](respondWithResult(_0x2e0007,null))[_0x691f('0x46')](handleError(_0x2e0007,null));};exports['create']=function(_0x27e9ab,_0x42cf34){return db['SalesforceAccount'][_0x691f('0x49')](_0x27e9ab[_0x691f('0x4a')],{})[_0x691f('0x27')](respondWithResult(_0x42cf34,0xc9))[_0x691f('0x46')](handleError(_0x42cf34,null));};exports[_0x691f('0x26')]=function(_0x3a6bc2,_0x435bcb){if(_0x3a6bc2[_0x691f('0x4a')]['id']){delete _0x3a6bc2[_0x691f('0x4a')]['id'];}return db['SalesforceAccount'][_0x691f('0x48')]({'where':{'id':_0x3a6bc2[_0x691f('0x4b')]['id']}})[_0x691f('0x27')](handleEntityNotFound(_0x435bcb,null))[_0x691f('0x27')](saveUpdates(_0x3a6bc2[_0x691f('0x4a')],null))[_0x691f('0x27')](respondWithResult(_0x435bcb,null))[_0x691f('0x46')](handleError(_0x435bcb,null));};exports[_0x691f('0x28')]=function(_0x11934e,_0x39a6df){return db[_0x691f('0x41')][_0x691f('0x48')]({'where':{'id':_0x11934e[_0x691f('0x4b')]['id']}})[_0x691f('0x27')](handleEntityNotFound(_0x39a6df,null))[_0x691f('0x27')](removeEntity(_0x39a6df,null))[_0x691f('0x46')](handleError(_0x39a6df,null));};exports['getConfigurations']=function(_0x23635b,_0x124823,_0x349998){var _0x3f4b1d={};var _0x305587={};var _0x219356;var _0x4b7868;return db['SalesforceAccount'][_0x691f('0x4c')]({'where':{'id':_0x23635b[_0x691f('0x4b')]['id']}})[_0x691f('0x27')](handleEntityNotFound(_0x124823,null))['then'](function(_0x2343b1){if(_0x2343b1){_0x219356=_0x2343b1;_0x305587[_0x691f('0x32')]=_[_0x691f('0x31')](db[_0x691f('0x4d')][_0x691f('0x2d')]);_0x305587['query']=_[_0x691f('0x31')](_0x23635b[_0x691f('0x30')]);_0x305587[_0x691f('0x3a')]=_['intersection'](_0x305587[_0x691f('0x32')],_0x305587[_0x691f('0x30')]);_0x3f4b1d[_0x691f('0x33')]=_[_0x691f('0x34')](_0x305587[_0x691f('0x32')],qs['fields'](_0x23635b[_0x691f('0x30')][_0x691f('0x35')]));_0x3f4b1d[_0x691f('0x33')]=_0x3f4b1d[_0x691f('0x33')][_0x691f('0x47')]?_0x3f4b1d[_0x691f('0x33')]:_0x305587[_0x691f('0x32')];_0x3f4b1d['order']=qs[_0x691f('0x39')](_0x23635b[_0x691f('0x30')][_0x691f('0x39')]);_0x3f4b1d['where']=qs[_0x691f('0x3a')](_[_0x691f('0x3b')](_0x23635b[_0x691f('0x30')],_0x305587[_0x691f('0x3a')]));if(_0x23635b[_0x691f('0x30')][_0x691f('0x3c')]){_0x3f4b1d[_0x691f('0x3d')]=_[_0x691f('0x3f')](_0x3f4b1d[_0x691f('0x3d')],{'$or':_[_0x691f('0x2c')](_0x3f4b1d['attributes'],function(_0x36772e){var _0x57b061={};_0x57b061[_0x36772e]={'$like':'%'+_0x23635b[_0x691f('0x30')][_0x691f('0x3c')]+'%'};return _0x57b061;})});}_0x3f4b1d=_[_0x691f('0x3f')]({},_0x3f4b1d,_0x23635b[_0x691f('0x40')]);return _0x219356['getConfigurations'](_0x3f4b1d);}})[_0x691f('0x27')](function(_0x13d362){if(_0x13d362){_0x4b7868=_0x13d362[_0x691f('0x47')];if(!_0x23635b[_0x691f('0x30')]['hasOwnProperty'](_0x691f('0x37'))){_0x3f4b1d['limit']=qs[_0x691f('0x21')](_0x23635b[_0x691f('0x30')][_0x691f('0x21')]);_0x3f4b1d[_0x691f('0x1e')]=qs[_0x691f('0x1e')](_0x23635b[_0x691f('0x30')][_0x691f('0x1e')]);}return _0x219356[_0x691f('0x4e')](_0x3f4b1d);}})[_0x691f('0x27')](function(_0x679050){if(_0x679050){return _0x679050?{'count':_0x4b7868,'rows':_0x679050}:null;}})['then'](respondWithResult(_0x124823,null))[_0x691f('0x46')](handleError(_0x124823,null));};exports[_0x691f('0x4f')]=function(_0x395bc9,_0x41c418,_0x2da655){if(_0x395bc9[_0x691f('0x4a')]['id']){delete _0x395bc9[_0x691f('0x4a')]['id'];}return db[_0x691f('0x41')][_0x691f('0x4c')]({'where':{'id':_0x395bc9[_0x691f('0x4b')]['id']}})[_0x691f('0x27')](handleEntityNotFound(_0x41c418,null))[_0x691f('0x27')](function(_0x82cc98){if(_0x82cc98){_0x395bc9[_0x691f('0x4a')][_0x691f('0x50')]=_0x82cc98['id'];_0x395bc9[_0x691f('0x4a')][_0x691f('0x51')]=integrations[_0x691f('0x52')](_0x395bc9[_0x691f('0x4a')]['channel'],_0x395bc9[_0x691f('0x4a')]['type']);_0x395bc9['body']['Descriptions']=integrations[_0x691f('0x53')](_0x395bc9['body']['channel'],_0x395bc9['body'][_0x691f('0x2f')]);return db[_0x691f('0x4d')][_0x691f('0x49')](_0x395bc9[_0x691f('0x4a')],{'include':[{'model':db[_0x691f('0x54')],'as':_0x691f('0x51')},{'model':db[_0x691f('0x54')],'as':_0x691f('0x55')}]});}return null;})[_0x691f('0x27')](respondWithResult(_0x41c418,null))[_0x691f('0x46')](handleError(_0x41c418,null));};exports[_0x691f('0x56')]=function(_0x352086,_0x4cfa59,_0xb1a5c3){var _0x488c9c;var _0x3b7633='';var _0x485dda='Task';return db[_0x691f('0x41')][_0x691f('0x4c')]({'where':{'id':_0x352086[_0x691f('0x4b')]['id']},'attributes':['id',_0x691f('0x57'),_0x691f('0x58'),_0x691f('0x59'),_0x691f('0x5a'),_0x691f('0x5b'),_0x691f('0x5c')]})[_0x691f('0x27')](handleEntityNotFound(_0x4cfa59,null))[_0x691f('0x27')](function(_0x32d106){if(_0x32d106){_0x3b7633=_0x32d106[_0x691f('0x57')];var _0x4c510e=_0x3b7633['slice'](-0x1);if(_0x4c510e==='/'){_0x3b7633=_0x3b7633[_0x691f('0x5d')](0x0,_0x3b7633[_0x691f('0x5e')](_0x4c510e));}_0x488c9c=new jsforce[(_0x691f('0x5f'))]({'oauth2':{'loginUrl':_0x3b7633,'clientId':_0x32d106[_0x691f('0x58')],'clientSecret':_0x32d106[_0x691f('0x59')]}});return _0x488c9c[_0x691f('0x60')](_0x32d106[_0x691f('0x5a')],_0x32d106[_0x691f('0x5b')][_0x691f('0x61')](_0x32d106[_0x691f('0x5c')]));}})[_0x691f('0x27')](function(_0x5df99c){if(_0x5df99c){if(!_['isNil'](_0x352086['query'][_0x691f('0x62')])){_0x485dda=_0x352086[_0x691f('0x30')][_0x691f('0x62')];}return _0x488c9c['sobject'](_0x485dda)[_0x691f('0x63')]();}})[_0x691f('0x27')](function(_0x573f8d){var _0x192b07=[_0x691f('0x64'),_0x691f('0x65'),_0x691f('0x66'),_0x691f('0x67'),'Subject',_0x691f('0x68')];var _0x489337=[_0x691f('0x69'),'int',_0x691f('0x6a'),_0x691f('0x6b'),'email',_0x691f('0x6c'),'phone'];if(_0x573f8d){_['remove'](_0x573f8d['fields'],function(_0x259156){return _0x192b07['includes'](_0x259156[_0x691f('0x2b')])||!_0x489337['includes'](_0x259156[_0x691f('0x2f')]);});return{'count':_0x573f8d['fields'][_0x691f('0x47')],'rows':_['map'](_0x573f8d[_0x691f('0x35')],function(_0x3ec1a2){return{'id':_0x3ec1a2[_0x691f('0x2b')],'name':_0x3ec1a2[_0x691f('0x6d')],'custom':_0x3ec1a2['custom'],'options':_0x3ec1a2[_0x691f('0x6e')][_0x691f('0x47')]>0x0?_[_0x691f('0x2c')](_0x3ec1a2[_0x691f('0x6e')],function(_0x38b3e8){return{'name':_0x38b3e8[_0x691f('0x6d')],'value':_0x38b3e8[_0x691f('0x6f')]};}):_0x3ec1a2[_0x691f('0x2f')]==_0x691f('0x6b')?[{'name':'True','value':_0x691f('0x70')},{'name':_0x691f('0x71'),'value':_0x691f('0x72')}]:[]};})};}})[_0x691f('0x27')](respondWithResult(_0x4cfa59,null))[_0x691f('0x46')](function(_0x5b1340){var _0x26ec61=_0x352086[_0x691f('0x30')]['test']?0x1f4:_0x5b1340[_0x691f('0x73')]||0x1f4;logger[_0x691f('0x29')]('getFields,\x20%s,\x20%s,\x20%s','getFields',_0x26ec61,JSON[_0x691f('0x74')](_0x5b1340));delete _0x5b1340[_0x691f('0x2b')];if(_0x26ec61===0x191){_0x26ec61=0x190;}_0x4cfa59[_0x691f('0x1b')](_0x26ec61)['send'](_0x352086[_0x691f('0x30')][_0x691f('0x75')]?{'message':_0x691f('0x76'),'statusCode':_0x5b1340[_0x691f('0x73')]}:_0x5b1340);});};
\ No newline at end of file
+var _0x85fc=['test','Wrong\x20credentials','eml-format','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/environment','../../components/integrations/configuration','sendStatus','status','end','offset','undefined','limit','count','json','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','merge','VIRTUAL','options','SalesforceAccount','includeAll','findAll','rows','catch','show','length','find','create','body','params','getConfigurations','findOne','SalesforceConfiguration','filter','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','SalesforceField','getFields','Task','remoteUri','clientSecret','username','password','securityToken','substring','lastIndexOf','Connection','concat','isNil','ticketType','describe','OwnerId','ActivityDate','IsRecurrence','Subject','Description','string','int','picklist','email','textarea','phone','remove','includes','label','custom','picklistValues','value','boolean','true','False','false','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x457e20,_0x3985ac){var _0x1f920b=function(_0x3804e4){while(--_0x3804e4){_0x457e20['push'](_0x457e20['shift']());}};_0x1f920b(++_0x3985ac);}(_0x85fc,0x7b));var _0xc85f=function(_0x52f3,_0x1ac14f){_0x52f3=_0x52f3-0x0;var _0x266655=_0x85fc[_0x52f3];return _0x266655;};'use strict';var emlformat=require(_0xc85f('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xc85f('0x1'));var rp=require(_0xc85f('0x2'));var moment=require(_0xc85f('0x3'));var BPromise=require(_0xc85f('0x4'));var Mustache=require('mustache');var util=require(_0xc85f('0x5'));var path=require(_0xc85f('0x6'));var sox=require('sox');var csv=require(_0xc85f('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xc85f('0x8'));var crypto=require('crypto');var jsforce=require(_0xc85f('0x9'));var deskjs=require(_0xc85f('0xa'));var toCsv=require(_0xc85f('0x7'));var querystring=require(_0xc85f('0xb'));var Papa=require(_0xc85f('0xc'));var Redis=require(_0xc85f('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xc85f('0xe'));var as=require(_0xc85f('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xc85f('0x10'));var utils=require('../../config/utils');var config=require(_0xc85f('0x11'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var integrations=require(_0xc85f('0x12'));function respondWithStatusCode(_0x2b0fc1,_0x467812){_0x467812=_0x467812||0xcc;return function(_0x17da98){if(_0x17da98){return _0x2b0fc1[_0xc85f('0x13')](_0x467812);}return _0x2b0fc1[_0xc85f('0x14')](_0x467812)[_0xc85f('0x15')]();};}function respondWithResult(_0x43e98e,_0x1878d0){_0x1878d0=_0x1878d0||0xc8;return function(_0x27dc90){if(_0x27dc90){return _0x43e98e[_0xc85f('0x14')](_0x1878d0)['json'](_0x27dc90);}};}function respondWithFilteredResult(_0x4d0964,_0x419e6b){return function(_0x305246){if(_0x305246){var _0x2d1bec=typeof _0x419e6b[_0xc85f('0x16')]===_0xc85f('0x17')&&typeof _0x419e6b[_0xc85f('0x18')]==='undefined';var _0x4bad59=_0x305246[_0xc85f('0x19')];var _0x32f15f=_0x2d1bec?0x0:_0x419e6b[_0xc85f('0x16')];var _0x25d89c=_0x2d1bec?_0x305246[_0xc85f('0x19')]:_0x419e6b[_0xc85f('0x16')]+_0x419e6b[_0xc85f('0x18')];var _0x5281f6;if(_0x25d89c>=_0x4bad59){_0x25d89c=_0x4bad59;_0x5281f6=0xc8;}else{_0x5281f6=0xce;}_0x4d0964[_0xc85f('0x14')](_0x5281f6);return _0x4d0964['set']('Content-Range',_0x32f15f+'-'+_0x25d89c+'/'+_0x4bad59)[_0xc85f('0x1a')](_0x305246);}return null;};}function patchUpdates(_0x316bac){return function(_0x4f7404){try{jsonpatch[_0xc85f('0x1b')](_0x4f7404,_0x316bac,!![]);}catch(_0x4868f1){return BPromise[_0xc85f('0x1c')](_0x4868f1);}return _0x4f7404[_0xc85f('0x1d')]();};}function saveUpdates(_0x5768d2,_0x836571){return function(_0x13647c){if(_0x13647c){return _0x13647c[_0xc85f('0x1e')](_0x5768d2)[_0xc85f('0x1f')](function(_0x1ac15d){return _0x1ac15d;});}return null;};}function removeEntity(_0xfcbf2e,_0x1c2749){return function(_0x579b1c){if(_0x579b1c){return _0x579b1c[_0xc85f('0x20')]()['then'](function(){_0xfcbf2e[_0xc85f('0x14')](0xcc)[_0xc85f('0x15')]();});}};}function handleEntityNotFound(_0x240e92,_0x379160){return function(_0x528fd0){if(!_0x528fd0){_0x240e92['sendStatus'](0x194);}return _0x528fd0;};}function handleError(_0x2bdb8b,_0x9c7b9c){_0x9c7b9c=_0x9c7b9c||0x1f4;return function(_0x464225){logger[_0xc85f('0x21')](_0x464225[_0xc85f('0x22')]);if(_0x464225[_0xc85f('0x23')]){delete _0x464225['name'];}_0x2bdb8b[_0xc85f('0x14')](_0x9c7b9c)[_0xc85f('0x24')](_0x464225);};}exports[_0xc85f('0x25')]=function(_0x23894c,_0x1af152){var _0x3ec423={},_0x50699c={},_0x5f43ff={'count':0x0,'rows':[]};var _0x2e41fe=_[_0xc85f('0x26')](db['SalesforceAccount'][_0xc85f('0x27')],function(_0x520c37){return{'name':_0x520c37[_0xc85f('0x28')],'type':_0x520c37[_0xc85f('0x29')][_0xc85f('0x2a')]};});_0x50699c['model']=_['map'](_0x2e41fe,_0xc85f('0x23'));_0x50699c['query']=_[_0xc85f('0x2b')](_0x23894c[_0xc85f('0x2c')]);_0x50699c[_0xc85f('0x2d')]=_[_0xc85f('0x2e')](_0x50699c[_0xc85f('0x2f')],_0x50699c[_0xc85f('0x2c')]);_0x3ec423[_0xc85f('0x30')]=_[_0xc85f('0x2e')](_0x50699c[_0xc85f('0x2f')],qs[_0xc85f('0x31')](_0x23894c[_0xc85f('0x2c')][_0xc85f('0x31')]));_0x3ec423['attributes']=_0x3ec423[_0xc85f('0x30')]['length']?_0x3ec423[_0xc85f('0x30')]:_0x50699c[_0xc85f('0x2f')];if(!_0x23894c[_0xc85f('0x2c')][_0xc85f('0x32')](_0xc85f('0x33'))){_0x3ec423[_0xc85f('0x18')]=qs[_0xc85f('0x18')](_0x23894c[_0xc85f('0x2c')][_0xc85f('0x18')]);_0x3ec423['offset']=qs[_0xc85f('0x16')](_0x23894c[_0xc85f('0x2c')][_0xc85f('0x16')]);}_0x3ec423[_0xc85f('0x34')]=qs[_0xc85f('0x35')](_0x23894c[_0xc85f('0x2c')][_0xc85f('0x35')]);_0x3ec423[_0xc85f('0x36')]=qs['filters'](_['pick'](_0x23894c[_0xc85f('0x2c')],_0x50699c[_0xc85f('0x2d')]),_0x2e41fe);if(_0x23894c[_0xc85f('0x2c')]['filter']){_0x3ec423[_0xc85f('0x36')]=_[_0xc85f('0x37')](_0x3ec423[_0xc85f('0x36')],{'$or':_['map'](_0x2e41fe,function(_0x71fb8c){if(_0x71fb8c[_0xc85f('0x29')]!==_0xc85f('0x38')){var _0x45df31={};_0x45df31[_0x71fb8c[_0xc85f('0x23')]]={'$like':'%'+_0x23894c[_0xc85f('0x2c')]['filter']+'%'};return _0x45df31;}})});}_0x3ec423=_[_0xc85f('0x37')]({},_0x3ec423,_0x23894c[_0xc85f('0x39')]);var _0x44b4b0={'where':_0x3ec423[_0xc85f('0x36')]};return db[_0xc85f('0x3a')][_0xc85f('0x19')](_0x44b4b0)[_0xc85f('0x1f')](function(_0x59f45d){_0x5f43ff['count']=_0x59f45d;if(_0x23894c[_0xc85f('0x2c')][_0xc85f('0x3b')]){_0x3ec423['include']=[{'all':!![]}];}return db[_0xc85f('0x3a')][_0xc85f('0x3c')](_0x3ec423);})[_0xc85f('0x1f')](function(_0x3ab966){_0x5f43ff[_0xc85f('0x3d')]=_0x3ab966;return _0x5f43ff;})[_0xc85f('0x1f')](respondWithFilteredResult(_0x1af152,_0x3ec423))[_0xc85f('0x3e')](handleError(_0x1af152,null));};exports[_0xc85f('0x3f')]=function(_0x5ab810,_0x2d4307){var _0x47b1f8={'raw':![],'where':{'id':_0x5ab810['params']['id']}},_0x1842ae={};_0x1842ae[_0xc85f('0x2f')]=_[_0xc85f('0x2b')](db['SalesforceAccount'][_0xc85f('0x27')]);_0x1842ae[_0xc85f('0x2c')]=_[_0xc85f('0x2b')](_0x5ab810[_0xc85f('0x2c')]);_0x1842ae[_0xc85f('0x2d')]=_['intersection'](_0x1842ae[_0xc85f('0x2f')],_0x1842ae[_0xc85f('0x2c')]);_0x47b1f8['attributes']=_[_0xc85f('0x2e')](_0x1842ae[_0xc85f('0x2f')],qs['fields'](_0x5ab810['query']['fields']));_0x47b1f8[_0xc85f('0x30')]=_0x47b1f8[_0xc85f('0x30')][_0xc85f('0x40')]?_0x47b1f8['attributes']:_0x1842ae[_0xc85f('0x2f')];if(_0x5ab810[_0xc85f('0x2c')]['includeAll']){_0x47b1f8['include']=[{'all':!![]}];}_0x47b1f8=_[_0xc85f('0x37')]({},_0x47b1f8,_0x5ab810[_0xc85f('0x39')]);return db[_0xc85f('0x3a')][_0xc85f('0x41')](_0x47b1f8)[_0xc85f('0x1f')](handleEntityNotFound(_0x2d4307,null))[_0xc85f('0x1f')](respondWithResult(_0x2d4307,null))[_0xc85f('0x3e')](handleError(_0x2d4307,null));};exports[_0xc85f('0x42')]=function(_0x3a118f,_0x171677){return db[_0xc85f('0x3a')][_0xc85f('0x42')](_0x3a118f['body'],{})[_0xc85f('0x1f')](respondWithResult(_0x171677,0xc9))[_0xc85f('0x3e')](handleError(_0x171677,null));};exports['update']=function(_0x17c280,_0x3e0c00){if(_0x17c280[_0xc85f('0x43')]['id']){delete _0x17c280[_0xc85f('0x43')]['id'];}return db[_0xc85f('0x3a')]['find']({'where':{'id':_0x17c280[_0xc85f('0x44')]['id']}})[_0xc85f('0x1f')](handleEntityNotFound(_0x3e0c00,null))['then'](saveUpdates(_0x17c280['body'],null))[_0xc85f('0x1f')](respondWithResult(_0x3e0c00,null))[_0xc85f('0x3e')](handleError(_0x3e0c00,null));};exports[_0xc85f('0x20')]=function(_0x263a9a,_0x191d04){return db['SalesforceAccount'][_0xc85f('0x41')]({'where':{'id':_0x263a9a[_0xc85f('0x44')]['id']}})[_0xc85f('0x1f')](handleEntityNotFound(_0x191d04,null))[_0xc85f('0x1f')](removeEntity(_0x191d04,null))[_0xc85f('0x3e')](handleError(_0x191d04,null));};exports[_0xc85f('0x45')]=function(_0x4e2290,_0x598e73,_0x148e30){var _0x19add8={};var _0x5ce7e2={};var _0x19968c;var _0x282afc;return db['SalesforceAccount'][_0xc85f('0x46')]({'where':{'id':_0x4e2290[_0xc85f('0x44')]['id']}})['then'](handleEntityNotFound(_0x598e73,null))[_0xc85f('0x1f')](function(_0x17b44c){if(_0x17b44c){_0x19968c=_0x17b44c;_0x5ce7e2[_0xc85f('0x2f')]=_['keys'](db[_0xc85f('0x47')]['rawAttributes']);_0x5ce7e2['query']=_[_0xc85f('0x2b')](_0x4e2290[_0xc85f('0x2c')]);_0x5ce7e2[_0xc85f('0x2d')]=_[_0xc85f('0x2e')](_0x5ce7e2[_0xc85f('0x2f')],_0x5ce7e2['query']);_0x19add8[_0xc85f('0x30')]=_[_0xc85f('0x2e')](_0x5ce7e2[_0xc85f('0x2f')],qs[_0xc85f('0x31')](_0x4e2290['query'][_0xc85f('0x31')]));_0x19add8[_0xc85f('0x30')]=_0x19add8[_0xc85f('0x30')][_0xc85f('0x40')]?_0x19add8[_0xc85f('0x30')]:_0x5ce7e2[_0xc85f('0x2f')];_0x19add8[_0xc85f('0x34')]=qs[_0xc85f('0x35')](_0x4e2290['query'][_0xc85f('0x35')]);_0x19add8['where']=qs['filters'](_['pick'](_0x4e2290[_0xc85f('0x2c')],_0x5ce7e2[_0xc85f('0x2d')]));if(_0x4e2290['query'][_0xc85f('0x48')]){_0x19add8[_0xc85f('0x36')]=_[_0xc85f('0x37')](_0x19add8[_0xc85f('0x36')],{'$or':_[_0xc85f('0x26')](_0x19add8[_0xc85f('0x30')],function(_0x33317a){var _0x3244ad={};_0x3244ad[_0x33317a]={'$like':'%'+_0x4e2290[_0xc85f('0x2c')][_0xc85f('0x48')]+'%'};return _0x3244ad;})});}_0x19add8=_[_0xc85f('0x37')]({},_0x19add8,_0x4e2290[_0xc85f('0x39')]);return _0x19968c[_0xc85f('0x45')](_0x19add8);}})[_0xc85f('0x1f')](function(_0x14c9b6){if(_0x14c9b6){_0x282afc=_0x14c9b6[_0xc85f('0x40')];if(!_0x4e2290['query'][_0xc85f('0x32')](_0xc85f('0x33'))){_0x19add8['limit']=qs[_0xc85f('0x18')](_0x4e2290[_0xc85f('0x2c')]['limit']);_0x19add8[_0xc85f('0x16')]=qs[_0xc85f('0x16')](_0x4e2290[_0xc85f('0x2c')][_0xc85f('0x16')]);}return _0x19968c[_0xc85f('0x45')](_0x19add8);}})[_0xc85f('0x1f')](function(_0x8cf4cf){if(_0x8cf4cf){return _0x8cf4cf?{'count':_0x282afc,'rows':_0x8cf4cf}:null;}})[_0xc85f('0x1f')](respondWithResult(_0x598e73,null))[_0xc85f('0x3e')](handleError(_0x598e73,null));};exports[_0xc85f('0x49')]=function(_0xe28fe,_0x3f248a,_0x50c0f5){if(_0xe28fe['body']['id']){delete _0xe28fe['body']['id'];}return db[_0xc85f('0x3a')][_0xc85f('0x46')]({'where':{'id':_0xe28fe[_0xc85f('0x44')]['id']}})['then'](handleEntityNotFound(_0x3f248a,null))[_0xc85f('0x1f')](function(_0x4df548){if(_0x4df548){_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4a')]=_0x4df548['id'];_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4b')]=integrations[_0xc85f('0x4c')](_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4d')],_0xe28fe[_0xc85f('0x43')]['type']);_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4e')]=integrations[_0xc85f('0x4f')](_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4d')],_0xe28fe[_0xc85f('0x43')][_0xc85f('0x29')]);return db[_0xc85f('0x47')][_0xc85f('0x42')](_0xe28fe[_0xc85f('0x43')],{'include':[{'model':db[_0xc85f('0x50')],'as':_0xc85f('0x4b')},{'model':db[_0xc85f('0x50')],'as':_0xc85f('0x4e')}]});}return null;})[_0xc85f('0x1f')](respondWithResult(_0x3f248a,null))[_0xc85f('0x3e')](handleError(_0x3f248a,null));};exports[_0xc85f('0x51')]=function(_0x7ff56d,_0x3c19e6,_0x2f0ba7){var _0x5e60bb;var _0x231332='';var _0x514de9=_0xc85f('0x52');return db[_0xc85f('0x3a')][_0xc85f('0x46')]({'where':{'id':_0x7ff56d['params']['id']},'attributes':['id',_0xc85f('0x53'),'clientId',_0xc85f('0x54'),_0xc85f('0x55'),_0xc85f('0x56'),_0xc85f('0x57')]})[_0xc85f('0x1f')](handleEntityNotFound(_0x3c19e6,null))[_0xc85f('0x1f')](function(_0x3d979e){if(_0x3d979e){_0x231332=_0x3d979e[_0xc85f('0x53')];var _0x5e4399=_0x231332['slice'](-0x1);if(_0x5e4399==='/'){_0x231332=_0x231332[_0xc85f('0x58')](0x0,_0x231332[_0xc85f('0x59')](_0x5e4399));}_0x5e60bb=new jsforce[(_0xc85f('0x5a'))]({'oauth2':{'loginUrl':_0x231332,'clientId':_0x3d979e['clientId'],'clientSecret':_0x3d979e[_0xc85f('0x54')]}});return _0x5e60bb['login'](_0x3d979e['username'],_0x3d979e[_0xc85f('0x56')][_0xc85f('0x5b')](_0x3d979e[_0xc85f('0x57')]));}})[_0xc85f('0x1f')](function(_0x1eb1f1){if(_0x1eb1f1){if(!_[_0xc85f('0x5c')](_0x7ff56d[_0xc85f('0x2c')][_0xc85f('0x5d')])){_0x514de9=_0x7ff56d[_0xc85f('0x2c')]['ticketType'];}return _0x5e60bb['sobject'](_0x514de9)[_0xc85f('0x5e')]();}})['then'](function(_0x1c49b2){var _0x493e3b=[_0xc85f('0x5f'),_0xc85f('0x60'),'IsReminderSet',_0xc85f('0x61'),_0xc85f('0x62'),_0xc85f('0x63')];var _0x35b002=[_0xc85f('0x64'),_0xc85f('0x65'),_0xc85f('0x66'),'boolean',_0xc85f('0x67'),_0xc85f('0x68'),_0xc85f('0x69')];if(_0x1c49b2){_[_0xc85f('0x6a')](_0x1c49b2[_0xc85f('0x31')],function(_0x46228f){return _0x493e3b['includes'](_0x46228f[_0xc85f('0x23')])||!_0x35b002[_0xc85f('0x6b')](_0x46228f[_0xc85f('0x29')]);});return{'count':_0x1c49b2['fields'][_0xc85f('0x40')],'rows':_['map'](_0x1c49b2[_0xc85f('0x31')],function(_0x426dc1){return{'id':_0x426dc1['name'],'name':_0x426dc1[_0xc85f('0x6c')],'custom':_0x426dc1[_0xc85f('0x6d')],'options':_0x426dc1[_0xc85f('0x6e')][_0xc85f('0x40')]>0x0?_['map'](_0x426dc1[_0xc85f('0x6e')],function(_0x252e49){return{'name':_0x252e49[_0xc85f('0x6c')],'value':_0x252e49[_0xc85f('0x6f')]};}):_0x426dc1[_0xc85f('0x29')]==_0xc85f('0x70')?[{'name':'True','value':_0xc85f('0x71')},{'name':_0xc85f('0x72'),'value':_0xc85f('0x73')}]:[]};})};}})[_0xc85f('0x1f')](respondWithResult(_0x3c19e6,null))[_0xc85f('0x3e')](function(_0x4346b8){var _0x1f3f03=_0x7ff56d[_0xc85f('0x2c')]['test']?0x1f4:_0x4346b8[_0xc85f('0x74')]||0x1f4;logger[_0xc85f('0x21')](_0xc85f('0x75'),_0xc85f('0x51'),_0x1f3f03,JSON[_0xc85f('0x76')](_0x4346b8));delete _0x4346b8['name'];if(_0x1f3f03===0x191){_0x1f3f03=0x190;}_0x3c19e6[_0xc85f('0x14')](_0x1f3f03)[_0xc85f('0x24')](_0x7ff56d['query'][_0xc85f('0x77')]?{'message':_0xc85f('0x78'),'statusCode':_0x4346b8['statusCode']}:_0x4346b8);});};
\ No newline at end of file