Built motion from commit d1eab355.|2.6.28
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index 6df30d0..d03811d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa575=['limit','count','Content-Range','reject','save','update','then','destroy','sendStatus','error','stack','name','status','index','rawAttributes','fieldName','type','key','keys','query','filters','intersection','attributes','fields','model','hasOwnProperty','nolimit','order','sort','where','pick','filter','map','includeAll','include','SalesforceAccount','findAll','rows','catch','show','length','merge','options','create','body','find','params','getConfigurations','findOne','SalesforceConfiguration','addConfiguration','getSubjects','channel','Descriptions','SalesforceField','Subjects','getFields','remoteUri','username','password','securityToken','slice','lastIndexOf','clientId','clientSecret','concat','isNil','ticketType','sobject','OwnerId','IsReminderSet','IsRecurrence','Subject','string','int','boolean','textarea','phone','remove','includes','label','custom','picklistValues','true','False','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','send','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','end','json','offset'];(function(_0xd22d95,_0xc59f8f){var _0x15d7a3=function(_0x3db95c){while(--_0x3db95c){_0xd22d95['push'](_0xd22d95['shift']());}};_0x15d7a3(++_0xc59f8f);}(_0xa575,0x14b));var _0x5a57=function(_0x41d93c,_0x4a6967){_0x41d93c=_0x41d93c-0x0;var _0x45634d=_0xa575[_0x41d93c];return _0x45634d;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x5a57('0x0'));var zipdir=require(_0x5a57('0x1'));var jsonpatch=require(_0x5a57('0x2'));var rp=require(_0x5a57('0x3'));var moment=require(_0x5a57('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x5a57('0x5'));var util=require(_0x5a57('0x6'));var path=require(_0x5a57('0x7'));var sox=require(_0x5a57('0x8'));var csv=require(_0x5a57('0x9'));var ejs=require(_0x5a57('0xa'));var fs=require('fs');var fs_extra=require(_0x5a57('0xb'));var _=require(_0x5a57('0xc'));var squel=require(_0x5a57('0xd'));var crypto=require(_0x5a57('0xe'));var jsforce=require(_0x5a57('0xf'));var deskjs=require(_0x5a57('0x10'));var toCsv=require('to-csv');var querystring=require(_0x5a57('0x11'));var Papa=require(_0x5a57('0x12'));var Redis=require(_0x5a57('0x13'));var authService=require(_0x5a57('0x14'));var qs=require(_0x5a57('0x15'));var as=require(_0x5a57('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x5a57('0x17'))(_0x5a57('0x18'));var utils=require('../../config/utils');var config=require(_0x5a57('0x19'));var licenseUtil=require(_0x5a57('0x1a'));var db=require(_0x5a57('0x1b'))['db'];var integrations=require(_0x5a57('0x1c'));function respondWithStatusCode(_0x3fadae,_0x4f8297){_0x4f8297=_0x4f8297||0xcc;return function(_0x290759){if(_0x290759){return _0x3fadae['sendStatus'](_0x4f8297);}return _0x3fadae['status'](_0x4f8297)[_0x5a57('0x1d')]();};}function respondWithResult(_0x4a348b,_0xeb369f){_0xeb369f=_0xeb369f||0xc8;return function(_0x2f7897){if(_0x2f7897){return _0x4a348b['status'](_0xeb369f)[_0x5a57('0x1e')](_0x2f7897);}};}function respondWithFilteredResult(_0x18b808,_0x56c3f3){return function(_0x51fe3e){if(_0x51fe3e){var _0x96b8bb=typeof _0x56c3f3[_0x5a57('0x1f')]==='undefined'&&typeof _0x56c3f3[_0x5a57('0x20')]==='undefined';var _0x5a4ffe=_0x51fe3e[_0x5a57('0x21')];var _0xc04011=_0x96b8bb?0x0:_0x56c3f3[_0x5a57('0x1f')];var _0x18dc16=_0x96b8bb?_0x51fe3e[_0x5a57('0x21')]:_0x56c3f3['offset']+_0x56c3f3[_0x5a57('0x20')];var _0x83ae87;if(_0x18dc16>=_0x5a4ffe){_0x18dc16=_0x5a4ffe;_0x83ae87=0xc8;}else{_0x83ae87=0xce;}_0x18b808['status'](_0x83ae87);return _0x18b808['set'](_0x5a57('0x22'),_0xc04011+'-'+_0x18dc16+'/'+_0x5a4ffe)[_0x5a57('0x1e')](_0x51fe3e);}return null;};}function patchUpdates(_0x45859a){return function(_0x42ec81){try{jsonpatch['apply'](_0x42ec81,_0x45859a,!![]);}catch(_0x249b75){return BPromise[_0x5a57('0x23')](_0x249b75);}return _0x42ec81[_0x5a57('0x24')]();};}function saveUpdates(_0x574c04,_0x56ddf0){return function(_0x247a77){if(_0x247a77){return _0x247a77[_0x5a57('0x25')](_0x574c04)[_0x5a57('0x26')](function(_0x55beb8){return _0x55beb8;});}return null;};}function removeEntity(_0x5d89e4,_0xa94dbd){return function(_0x37f725){if(_0x37f725){return _0x37f725[_0x5a57('0x27')]()['then'](function(){_0x5d89e4['status'](0xcc)[_0x5a57('0x1d')]();});}};}function handleEntityNotFound(_0x563237,_0x4a766c){return function(_0x3baf99){if(!_0x3baf99){_0x563237[_0x5a57('0x28')](0x194);}return _0x3baf99;};}function handleError(_0x5da64b,_0x3065a2){_0x3065a2=_0x3065a2||0x1f4;return function(_0x1314ec){logger[_0x5a57('0x29')](_0x1314ec[_0x5a57('0x2a')]);if(_0x1314ec['name']){delete _0x1314ec[_0x5a57('0x2b')];}_0x5da64b[_0x5a57('0x2c')](_0x3065a2)['send'](_0x1314ec);};}exports[_0x5a57('0x2d')]=function(_0x1f521a,_0x46e7ac){var _0x3d59ec={},_0x1bc0b2={},_0x2b68e0={'count':0x0,'rows':[]};var _0x278093=_['map'](db['SalesforceAccount'][_0x5a57('0x2e')],function(_0x19b497){return{'name':_0x19b497[_0x5a57('0x2f')],'type':_0x19b497[_0x5a57('0x30')][_0x5a57('0x31')]};});_0x1bc0b2['model']=_['map'](_0x278093,_0x5a57('0x2b'));_0x1bc0b2['query']=_[_0x5a57('0x32')](_0x1f521a[_0x5a57('0x33')]);_0x1bc0b2[_0x5a57('0x34')]=_[_0x5a57('0x35')](_0x1bc0b2['model'],_0x1bc0b2[_0x5a57('0x33')]);_0x3d59ec[_0x5a57('0x36')]=_[_0x5a57('0x35')](_0x1bc0b2['model'],qs[_0x5a57('0x37')](_0x1f521a[_0x5a57('0x33')][_0x5a57('0x37')]));_0x3d59ec[_0x5a57('0x36')]=_0x3d59ec[_0x5a57('0x36')]['length']?_0x3d59ec['attributes']:_0x1bc0b2[_0x5a57('0x38')];if(!_0x1f521a['query'][_0x5a57('0x39')](_0x5a57('0x3a'))){_0x3d59ec[_0x5a57('0x20')]=qs[_0x5a57('0x20')](_0x1f521a[_0x5a57('0x33')][_0x5a57('0x20')]);_0x3d59ec[_0x5a57('0x1f')]=qs['offset'](_0x1f521a['query'][_0x5a57('0x1f')]);}_0x3d59ec[_0x5a57('0x3b')]=qs[_0x5a57('0x3c')](_0x1f521a[_0x5a57('0x33')][_0x5a57('0x3c')]);_0x3d59ec[_0x5a57('0x3d')]=qs[_0x5a57('0x34')](_[_0x5a57('0x3e')](_0x1f521a[_0x5a57('0x33')],_0x1bc0b2[_0x5a57('0x34')]),_0x278093);if(_0x1f521a[_0x5a57('0x33')][_0x5a57('0x3f')]){_0x3d59ec['where']=_['merge'](_0x3d59ec[_0x5a57('0x3d')],{'$or':_[_0x5a57('0x40')](_0x278093,function(_0x29eeb6){if(_0x29eeb6[_0x5a57('0x30')]!=='VIRTUAL'){var _0xa1079b={};_0xa1079b[_0x29eeb6['name']]={'$like':'%'+_0x1f521a[_0x5a57('0x33')]['filter']+'%'};return _0xa1079b;}})});}_0x3d59ec=_['merge']({},_0x3d59ec,_0x1f521a['options']);var _0x165c7a={'where':_0x3d59ec[_0x5a57('0x3d')]};return db['SalesforceAccount'][_0x5a57('0x21')](_0x165c7a)[_0x5a57('0x26')](function(_0x47f32a){_0x2b68e0[_0x5a57('0x21')]=_0x47f32a;if(_0x1f521a[_0x5a57('0x33')][_0x5a57('0x41')]){_0x3d59ec[_0x5a57('0x42')]=[{'all':!![]}];}return db[_0x5a57('0x43')][_0x5a57('0x44')](_0x3d59ec);})['then'](function(_0x364766){_0x2b68e0[_0x5a57('0x45')]=_0x364766;return _0x2b68e0;})[_0x5a57('0x26')](respondWithFilteredResult(_0x46e7ac,_0x3d59ec))[_0x5a57('0x46')](handleError(_0x46e7ac,null));};exports[_0x5a57('0x47')]=function(_0x3bd441,_0x4fa062){var _0xc46931={'raw':![],'where':{'id':_0x3bd441['params']['id']}},_0x3f38bf={};_0x3f38bf['model']=_[_0x5a57('0x32')](db['SalesforceAccount'][_0x5a57('0x2e')]);_0x3f38bf[_0x5a57('0x33')]=_[_0x5a57('0x32')](_0x3bd441[_0x5a57('0x33')]);_0x3f38bf['filters']=_[_0x5a57('0x35')](_0x3f38bf[_0x5a57('0x38')],_0x3f38bf[_0x5a57('0x33')]);_0xc46931[_0x5a57('0x36')]=_[_0x5a57('0x35')](_0x3f38bf['model'],qs[_0x5a57('0x37')](_0x3bd441[_0x5a57('0x33')][_0x5a57('0x37')]));_0xc46931[_0x5a57('0x36')]=_0xc46931[_0x5a57('0x36')][_0x5a57('0x48')]?_0xc46931[_0x5a57('0x36')]:_0x3f38bf[_0x5a57('0x38')];if(_0x3bd441['query']['includeAll']){_0xc46931[_0x5a57('0x42')]=[{'all':!![]}];}_0xc46931=_[_0x5a57('0x49')]({},_0xc46931,_0x3bd441[_0x5a57('0x4a')]);return db[_0x5a57('0x43')]['find'](_0xc46931)[_0x5a57('0x26')](handleEntityNotFound(_0x4fa062,null))['then'](respondWithResult(_0x4fa062,null))[_0x5a57('0x46')](handleError(_0x4fa062,null));};exports[_0x5a57('0x4b')]=function(_0x1b538f,_0x3a5e3e){return db[_0x5a57('0x43')][_0x5a57('0x4b')](_0x1b538f[_0x5a57('0x4c')],{})[_0x5a57('0x26')](respondWithResult(_0x3a5e3e,0xc9))[_0x5a57('0x46')](handleError(_0x3a5e3e,null));};exports['update']=function(_0x100f3f,_0x5f35ba){if(_0x100f3f[_0x5a57('0x4c')]['id']){delete _0x100f3f['body']['id'];}return db['SalesforceAccount'][_0x5a57('0x4d')]({'where':{'id':_0x100f3f[_0x5a57('0x4e')]['id']}})[_0x5a57('0x26')](handleEntityNotFound(_0x5f35ba,null))[_0x5a57('0x26')](saveUpdates(_0x100f3f[_0x5a57('0x4c')],null))['then'](respondWithResult(_0x5f35ba,null))['catch'](handleError(_0x5f35ba,null));};exports[_0x5a57('0x27')]=function(_0xb73aa6,_0x48c0ed){return db[_0x5a57('0x43')][_0x5a57('0x4d')]({'where':{'id':_0xb73aa6['params']['id']}})[_0x5a57('0x26')](handleEntityNotFound(_0x48c0ed,null))[_0x5a57('0x26')](removeEntity(_0x48c0ed,null))[_0x5a57('0x46')](handleError(_0x48c0ed,null));};exports[_0x5a57('0x4f')]=function(_0x162366,_0x22a516,_0x4ab537){var _0x3a7426={};var _0x33c8d5={};var _0x2979f6;var _0x27a296;return db[_0x5a57('0x43')][_0x5a57('0x50')]({'where':{'id':_0x162366[_0x5a57('0x4e')]['id']}})[_0x5a57('0x26')](handleEntityNotFound(_0x22a516,null))[_0x5a57('0x26')](function(_0x38a5f3){if(_0x38a5f3){_0x2979f6=_0x38a5f3;_0x33c8d5[_0x5a57('0x38')]=_[_0x5a57('0x32')](db[_0x5a57('0x51')][_0x5a57('0x2e')]);_0x33c8d5['query']=_[_0x5a57('0x32')](_0x162366['query']);_0x33c8d5['filters']=_[_0x5a57('0x35')](_0x33c8d5[_0x5a57('0x38')],_0x33c8d5['query']);_0x3a7426[_0x5a57('0x36')]=_['intersection'](_0x33c8d5[_0x5a57('0x38')],qs[_0x5a57('0x37')](_0x162366[_0x5a57('0x33')][_0x5a57('0x37')]));_0x3a7426[_0x5a57('0x36')]=_0x3a7426['attributes'][_0x5a57('0x48')]?_0x3a7426[_0x5a57('0x36')]:_0x33c8d5[_0x5a57('0x38')];_0x3a7426[_0x5a57('0x3b')]=qs[_0x5a57('0x3c')](_0x162366['query'][_0x5a57('0x3c')]);_0x3a7426[_0x5a57('0x3d')]=qs['filters'](_[_0x5a57('0x3e')](_0x162366[_0x5a57('0x33')],_0x33c8d5[_0x5a57('0x34')]));if(_0x162366[_0x5a57('0x33')][_0x5a57('0x3f')]){_0x3a7426['where']=_['merge'](_0x3a7426[_0x5a57('0x3d')],{'$or':_[_0x5a57('0x40')](_0x3a7426[_0x5a57('0x36')],function(_0x15f58f){var _0x456293={};_0x456293[_0x15f58f]={'$like':'%'+_0x162366[_0x5a57('0x33')][_0x5a57('0x3f')]+'%'};return _0x456293;})});}_0x3a7426=_[_0x5a57('0x49')]({},_0x3a7426,_0x162366[_0x5a57('0x4a')]);return _0x2979f6['getConfigurations'](_0x3a7426);}})[_0x5a57('0x26')](function(_0x552fd1){if(_0x552fd1){_0x27a296=_0x552fd1['length'];if(!_0x162366[_0x5a57('0x33')]['hasOwnProperty'](_0x5a57('0x3a'))){_0x3a7426[_0x5a57('0x20')]=qs['limit'](_0x162366[_0x5a57('0x33')][_0x5a57('0x20')]);_0x3a7426[_0x5a57('0x1f')]=qs[_0x5a57('0x1f')](_0x162366['query'][_0x5a57('0x1f')]);}return _0x2979f6['getConfigurations'](_0x3a7426);}})[_0x5a57('0x26')](function(_0x52fe65){if(_0x52fe65){return _0x52fe65?{'count':_0x27a296,'rows':_0x52fe65}:null;}})['then'](respondWithResult(_0x22a516,null))[_0x5a57('0x46')](handleError(_0x22a516,null));};exports[_0x5a57('0x52')]=function(_0x3be7c8,_0x1b9e41,_0x529ba0){if(_0x3be7c8[_0x5a57('0x4c')]['id']){delete _0x3be7c8['body']['id'];}return db[_0x5a57('0x43')][_0x5a57('0x50')]({'where':{'id':_0x3be7c8['params']['id']}})[_0x5a57('0x26')](handleEntityNotFound(_0x1b9e41,null))[_0x5a57('0x26')](function(_0x52bf89){if(_0x52bf89){_0x3be7c8['body']['AccountId']=_0x52bf89['id'];_0x3be7c8[_0x5a57('0x4c')]['Subjects']=integrations[_0x5a57('0x53')](_0x3be7c8[_0x5a57('0x4c')][_0x5a57('0x54')],_0x3be7c8[_0x5a57('0x4c')][_0x5a57('0x30')]);_0x3be7c8[_0x5a57('0x4c')][_0x5a57('0x55')]=integrations['getDescriptions'](_0x3be7c8['body'][_0x5a57('0x54')],_0x3be7c8[_0x5a57('0x4c')][_0x5a57('0x30')]);return db[_0x5a57('0x51')][_0x5a57('0x4b')](_0x3be7c8['body'],{'include':[{'model':db[_0x5a57('0x56')],'as':_0x5a57('0x57')},{'model':db['SalesforceField'],'as':_0x5a57('0x55')}]});}return null;})[_0x5a57('0x26')](respondWithResult(_0x1b9e41,null))[_0x5a57('0x46')](handleError(_0x1b9e41,null));};exports[_0x5a57('0x58')]=function(_0x56c422,_0x5c43a7,_0x14f17b){var _0x118415;var _0x20588b='';var _0x117132='Task';return db[_0x5a57('0x43')]['findOne']({'where':{'id':_0x56c422[_0x5a57('0x4e')]['id']},'attributes':['id',_0x5a57('0x59'),'clientId','clientSecret',_0x5a57('0x5a'),_0x5a57('0x5b'),_0x5a57('0x5c')]})[_0x5a57('0x26')](handleEntityNotFound(_0x5c43a7,null))[_0x5a57('0x26')](function(_0x137e94){if(_0x137e94){_0x20588b=_0x137e94[_0x5a57('0x59')];var _0xe3f381=_0x20588b[_0x5a57('0x5d')](-0x1);if(_0xe3f381==='/'){_0x20588b=_0x20588b['substring'](0x0,_0x20588b[_0x5a57('0x5e')](_0xe3f381));}_0x118415=new jsforce['Connection']({'oauth2':{'loginUrl':_0x20588b,'clientId':_0x137e94[_0x5a57('0x5f')],'clientSecret':_0x137e94[_0x5a57('0x60')]}});return _0x118415['login'](_0x137e94['username'],_0x137e94[_0x5a57('0x5b')][_0x5a57('0x61')](_0x137e94[_0x5a57('0x5c')]));}})[_0x5a57('0x26')](function(_0x54e526){if(_0x54e526){if(!_[_0x5a57('0x62')](_0x56c422['query']['ticketType'])){_0x117132=_0x56c422[_0x5a57('0x33')][_0x5a57('0x63')];}return _0x118415[_0x5a57('0x64')](_0x117132)['describe']();}})['then'](function(_0x454157){var _0x276ade=[_0x5a57('0x65'),'ActivityDate',_0x5a57('0x66'),_0x5a57('0x67'),_0x5a57('0x68'),'Description'];var _0x375e55=[_0x5a57('0x69'),_0x5a57('0x6a'),'picklist',_0x5a57('0x6b'),'email',_0x5a57('0x6c'),_0x5a57('0x6d')];if(_0x454157){_[_0x5a57('0x6e')](_0x454157['fields'],function(_0x620da5){return _0x276ade[_0x5a57('0x6f')](_0x620da5[_0x5a57('0x2b')])||!_0x375e55[_0x5a57('0x6f')](_0x620da5[_0x5a57('0x30')]);});return{'count':_0x454157[_0x5a57('0x37')][_0x5a57('0x48')],'rows':_[_0x5a57('0x40')](_0x454157[_0x5a57('0x37')],function(_0x24fda8){return{'id':_0x24fda8[_0x5a57('0x2b')],'name':_0x24fda8[_0x5a57('0x70')],'custom':_0x24fda8[_0x5a57('0x71')],'options':_0x24fda8[_0x5a57('0x72')][_0x5a57('0x48')]>0x0?_[_0x5a57('0x40')](_0x24fda8[_0x5a57('0x72')],function(_0x396794){return{'name':_0x396794[_0x5a57('0x70')],'value':_0x396794['value']};}):_0x24fda8[_0x5a57('0x30')]==_0x5a57('0x6b')?[{'name':'True','value':_0x5a57('0x73')},{'name':_0x5a57('0x74'),'value':'false'}]:[]};})};}})[_0x5a57('0x26')](respondWithResult(_0x5c43a7,null))['catch'](function(_0x1a0dc7){var _0x352b95=_0x56c422[_0x5a57('0x33')][_0x5a57('0x75')]?0x1f4:_0x1a0dc7[_0x5a57('0x76')]||0x1f4;logger[_0x5a57('0x29')](_0x5a57('0x77'),_0x5a57('0x58'),_0x352b95,JSON['stringify'](_0x1a0dc7));delete _0x1a0dc7[_0x5a57('0x2b')];if(_0x352b95===0x191){_0x352b95=0x190;}_0x5c43a7[_0x5a57('0x2c')](_0x352b95)[_0x5a57('0x78')](_0x56c422['query'][_0x5a57('0x75')]?{'message':'Wrong\x20credentials','statusCode':_0x1a0dc7[_0x5a57('0x76')]}:_0x1a0dc7);});};
\ No newline at end of file
+var _0x326f=['end','sendStatus','error','stack','name','index','map','SalesforceAccount','rawAttributes','key','keys','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','options','then','includeAll','include','findAll','catch','show','params','find','create','body','getConfigurations','findOne','SalesforceConfiguration','addConfiguration','Subjects','channel','Descriptions','SalesforceField','Task','remoteUri','clientId','clientSecret','username','password','securityToken','slice','substring','login','concat','isNil','ticketType','describe','OwnerId','IsRecurrence','Description','int','boolean','email','textarea','phone','includes','label','custom','picklistValues','value','true','False','false','statusCode','stringify','send','Wrong\x20credentials','rimraf','zip-dir','fast-json-patch','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','json','limit','undefined','count','offset','Content-Range','apply','reject','save','update','destroy'];(function(_0x259868,_0x2f8cc8){var _0x3c0843=function(_0x4b1a97){while(--_0x4b1a97){_0x259868['push'](_0x259868['shift']());}};_0x3c0843(++_0x2f8cc8);}(_0x326f,0x1af));var _0xf326=function(_0x3063cb,_0x31b8d6){_0x3063cb=_0x3063cb-0x0;var _0x2ad0e7=_0x326f[_0x3063cb];return _0x2ad0e7;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xf326('0x0'));var zipdir=require(_0xf326('0x1'));var jsonpatch=require(_0xf326('0x2'));var rp=require('request-promise');var moment=require(_0xf326('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xf326('0x4'));var util=require(_0xf326('0x5'));var path=require(_0xf326('0x6'));var sox=require(_0xf326('0x7'));var csv=require(_0xf326('0x8'));var ejs=require(_0xf326('0x9'));var fs=require('fs');var fs_extra=require(_0xf326('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xf326('0xb'));var deskjs=require(_0xf326('0xc'));var toCsv=require(_0xf326('0x8'));var querystring=require(_0xf326('0xd'));var Papa=require(_0xf326('0xe'));var Redis=require(_0xf326('0xf'));var authService=require(_0xf326('0x10'));var qs=require(_0xf326('0x11'));var as=require(_0xf326('0x12'));var hardwareService=require(_0xf326('0x13'));var logger=require(_0xf326('0x14'))('api');var utils=require(_0xf326('0x15'));var config=require(_0xf326('0x16'));var licenseUtil=require(_0xf326('0x17'));var db=require(_0xf326('0x18'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x1d57a4,_0xadd550){_0xadd550=_0xadd550||0xcc;return function(_0x5eee6a){if(_0x5eee6a){return _0x1d57a4['sendStatus'](_0xadd550);}return _0x1d57a4[_0xf326('0x19')](_0xadd550)['end']();};}function respondWithResult(_0x3bab9c,_0x3a5f80){_0x3a5f80=_0x3a5f80||0xc8;return function(_0x19deab){if(_0x19deab){return _0x3bab9c['status'](_0x3a5f80)[_0xf326('0x1a')](_0x19deab);}};}function respondWithFilteredResult(_0x72d5f,_0x340e66){return function(_0x3136a7){if(_0x3136a7){var _0x374e0f=typeof _0x340e66['offset']==='undefined'&&typeof _0x340e66[_0xf326('0x1b')]===_0xf326('0x1c');var _0x40c47b=_0x3136a7[_0xf326('0x1d')];var _0x2b5be3=_0x374e0f?0x0:_0x340e66[_0xf326('0x1e')];var _0x5aa845=_0x374e0f?_0x3136a7[_0xf326('0x1d')]:_0x340e66[_0xf326('0x1e')]+_0x340e66[_0xf326('0x1b')];var _0x482ef1;if(_0x5aa845>=_0x40c47b){_0x5aa845=_0x40c47b;_0x482ef1=0xc8;}else{_0x482ef1=0xce;}_0x72d5f[_0xf326('0x19')](_0x482ef1);return _0x72d5f['set'](_0xf326('0x1f'),_0x2b5be3+'-'+_0x5aa845+'/'+_0x40c47b)[_0xf326('0x1a')](_0x3136a7);}return null;};}function patchUpdates(_0x4fb9c1){return function(_0x1a20ba){try{jsonpatch[_0xf326('0x20')](_0x1a20ba,_0x4fb9c1,!![]);}catch(_0x18b0dd){return BPromise[_0xf326('0x21')](_0x18b0dd);}return _0x1a20ba[_0xf326('0x22')]();};}function saveUpdates(_0xdbec2b,_0x58360d){return function(_0x236060){if(_0x236060){return _0x236060[_0xf326('0x23')](_0xdbec2b)['then'](function(_0x30556c){return _0x30556c;});}return null;};}function removeEntity(_0x346489,_0x361e99){return function(_0x58ed12){if(_0x58ed12){return _0x58ed12[_0xf326('0x24')]()['then'](function(){_0x346489['status'](0xcc)[_0xf326('0x25')]();});}};}function handleEntityNotFound(_0x143564,_0xce179d){return function(_0x25fddc){if(!_0x25fddc){_0x143564[_0xf326('0x26')](0x194);}return _0x25fddc;};}function handleError(_0x50219e,_0x35ae17){_0x35ae17=_0x35ae17||0x1f4;return function(_0x4ca96b){logger[_0xf326('0x27')](_0x4ca96b[_0xf326('0x28')]);if(_0x4ca96b['name']){delete _0x4ca96b[_0xf326('0x29')];}_0x50219e[_0xf326('0x19')](_0x35ae17)['send'](_0x4ca96b);};}exports[_0xf326('0x2a')]=function(_0x3e3a74,_0x4e221a){var _0x7cffd9={},_0x195567={},_0xf2192={'count':0x0,'rows':[]};var _0x54e0b5=_[_0xf326('0x2b')](db[_0xf326('0x2c')][_0xf326('0x2d')],function(_0x51af1c){return{'name':_0x51af1c['fieldName'],'type':_0x51af1c['type'][_0xf326('0x2e')]};});_0x195567['model']=_['map'](_0x54e0b5,_0xf326('0x29'));_0x195567['query']=_[_0xf326('0x2f')](_0x3e3a74[_0xf326('0x30')]);_0x195567[_0xf326('0x31')]=_[_0xf326('0x32')](_0x195567[_0xf326('0x33')],_0x195567[_0xf326('0x30')]);_0x7cffd9['attributes']=_['intersection'](_0x195567['model'],qs[_0xf326('0x34')](_0x3e3a74[_0xf326('0x30')][_0xf326('0x34')]));_0x7cffd9[_0xf326('0x35')]=_0x7cffd9[_0xf326('0x35')][_0xf326('0x36')]?_0x7cffd9[_0xf326('0x35')]:_0x195567[_0xf326('0x33')];if(!_0x3e3a74[_0xf326('0x30')][_0xf326('0x37')](_0xf326('0x38'))){_0x7cffd9['limit']=qs[_0xf326('0x1b')](_0x3e3a74[_0xf326('0x30')]['limit']);_0x7cffd9[_0xf326('0x1e')]=qs['offset'](_0x3e3a74[_0xf326('0x30')][_0xf326('0x1e')]);}_0x7cffd9[_0xf326('0x39')]=qs[_0xf326('0x3a')](_0x3e3a74['query']['sort']);_0x7cffd9['where']=qs[_0xf326('0x31')](_[_0xf326('0x3b')](_0x3e3a74[_0xf326('0x30')],_0x195567[_0xf326('0x31')]),_0x54e0b5);if(_0x3e3a74[_0xf326('0x30')][_0xf326('0x3c')]){_0x7cffd9[_0xf326('0x3d')]=_[_0xf326('0x3e')](_0x7cffd9['where'],{'$or':_['map'](_0x54e0b5,function(_0x5123a2){if(_0x5123a2[_0xf326('0x3f')]!=='VIRTUAL'){var _0x400f3c={};_0x400f3c[_0x5123a2['name']]={'$like':'%'+_0x3e3a74[_0xf326('0x30')][_0xf326('0x3c')]+'%'};return _0x400f3c;}})});}_0x7cffd9=_[_0xf326('0x3e')]({},_0x7cffd9,_0x3e3a74[_0xf326('0x40')]);var _0x5f08b7={'where':_0x7cffd9[_0xf326('0x3d')]};return db[_0xf326('0x2c')][_0xf326('0x1d')](_0x5f08b7)[_0xf326('0x41')](function(_0x35afca){_0xf2192[_0xf326('0x1d')]=_0x35afca;if(_0x3e3a74[_0xf326('0x30')][_0xf326('0x42')]){_0x7cffd9[_0xf326('0x43')]=[{'all':!![]}];}return db[_0xf326('0x2c')][_0xf326('0x44')](_0x7cffd9);})['then'](function(_0x56741a){_0xf2192['rows']=_0x56741a;return _0xf2192;})[_0xf326('0x41')](respondWithFilteredResult(_0x4e221a,_0x7cffd9))[_0xf326('0x45')](handleError(_0x4e221a,null));};exports[_0xf326('0x46')]=function(_0x3a827d,_0x46003e){var _0x35575d={'raw':![],'where':{'id':_0x3a827d[_0xf326('0x47')]['id']}},_0x2dd3bf={};_0x2dd3bf[_0xf326('0x33')]=_[_0xf326('0x2f')](db[_0xf326('0x2c')][_0xf326('0x2d')]);_0x2dd3bf['query']=_[_0xf326('0x2f')](_0x3a827d[_0xf326('0x30')]);_0x2dd3bf[_0xf326('0x31')]=_[_0xf326('0x32')](_0x2dd3bf[_0xf326('0x33')],_0x2dd3bf[_0xf326('0x30')]);_0x35575d[_0xf326('0x35')]=_[_0xf326('0x32')](_0x2dd3bf[_0xf326('0x33')],qs[_0xf326('0x34')](_0x3a827d['query']['fields']));_0x35575d[_0xf326('0x35')]=_0x35575d[_0xf326('0x35')]['length']?_0x35575d[_0xf326('0x35')]:_0x2dd3bf[_0xf326('0x33')];if(_0x3a827d[_0xf326('0x30')][_0xf326('0x42')]){_0x35575d['include']=[{'all':!![]}];}_0x35575d=_['merge']({},_0x35575d,_0x3a827d[_0xf326('0x40')]);return db[_0xf326('0x2c')][_0xf326('0x48')](_0x35575d)['then'](handleEntityNotFound(_0x46003e,null))[_0xf326('0x41')](respondWithResult(_0x46003e,null))[_0xf326('0x45')](handleError(_0x46003e,null));};exports[_0xf326('0x49')]=function(_0x268605,_0x3a9778){return db['SalesforceAccount'][_0xf326('0x49')](_0x268605[_0xf326('0x4a')],{})['then'](respondWithResult(_0x3a9778,0xc9))['catch'](handleError(_0x3a9778,null));};exports[_0xf326('0x23')]=function(_0x436082,_0xbc3f42){if(_0x436082[_0xf326('0x4a')]['id']){delete _0x436082['body']['id'];}return db['SalesforceAccount'][_0xf326('0x48')]({'where':{'id':_0x436082[_0xf326('0x47')]['id']}})[_0xf326('0x41')](handleEntityNotFound(_0xbc3f42,null))[_0xf326('0x41')](saveUpdates(_0x436082[_0xf326('0x4a')],null))[_0xf326('0x41')](respondWithResult(_0xbc3f42,null))[_0xf326('0x45')](handleError(_0xbc3f42,null));};exports[_0xf326('0x24')]=function(_0x150d5f,_0x5ae5af){return db[_0xf326('0x2c')][_0xf326('0x48')]({'where':{'id':_0x150d5f[_0xf326('0x47')]['id']}})[_0xf326('0x41')](handleEntityNotFound(_0x5ae5af,null))[_0xf326('0x41')](removeEntity(_0x5ae5af,null))[_0xf326('0x45')](handleError(_0x5ae5af,null));};exports[_0xf326('0x4b')]=function(_0x170fa1,_0x4591be,_0x1eb78c){var _0x4db9cc={};var _0x5314ac={};var _0x2f7b5;var _0x53dc92;return db['SalesforceAccount'][_0xf326('0x4c')]({'where':{'id':_0x170fa1[_0xf326('0x47')]['id']}})['then'](handleEntityNotFound(_0x4591be,null))['then'](function(_0x1a2546){if(_0x1a2546){_0x2f7b5=_0x1a2546;_0x5314ac[_0xf326('0x33')]=_[_0xf326('0x2f')](db[_0xf326('0x4d')]['rawAttributes']);_0x5314ac['query']=_['keys'](_0x170fa1[_0xf326('0x30')]);_0x5314ac[_0xf326('0x31')]=_['intersection'](_0x5314ac[_0xf326('0x33')],_0x5314ac[_0xf326('0x30')]);_0x4db9cc['attributes']=_['intersection'](_0x5314ac[_0xf326('0x33')],qs[_0xf326('0x34')](_0x170fa1[_0xf326('0x30')][_0xf326('0x34')]));_0x4db9cc[_0xf326('0x35')]=_0x4db9cc['attributes']['length']?_0x4db9cc[_0xf326('0x35')]:_0x5314ac[_0xf326('0x33')];_0x4db9cc[_0xf326('0x39')]=qs[_0xf326('0x3a')](_0x170fa1[_0xf326('0x30')][_0xf326('0x3a')]);_0x4db9cc[_0xf326('0x3d')]=qs['filters'](_[_0xf326('0x3b')](_0x170fa1[_0xf326('0x30')],_0x5314ac['filters']));if(_0x170fa1[_0xf326('0x30')][_0xf326('0x3c')]){_0x4db9cc[_0xf326('0x3d')]=_[_0xf326('0x3e')](_0x4db9cc[_0xf326('0x3d')],{'$or':_[_0xf326('0x2b')](_0x4db9cc[_0xf326('0x35')],function(_0x379ff6){var _0x1bcb9c={};_0x1bcb9c[_0x379ff6]={'$like':'%'+_0x170fa1['query']['filter']+'%'};return _0x1bcb9c;})});}_0x4db9cc=_[_0xf326('0x3e')]({},_0x4db9cc,_0x170fa1['options']);return _0x2f7b5[_0xf326('0x4b')](_0x4db9cc);}})[_0xf326('0x41')](function(_0x52842c){if(_0x52842c){_0x53dc92=_0x52842c['length'];if(!_0x170fa1['query'][_0xf326('0x37')](_0xf326('0x38'))){_0x4db9cc[_0xf326('0x1b')]=qs[_0xf326('0x1b')](_0x170fa1[_0xf326('0x30')]['limit']);_0x4db9cc['offset']=qs[_0xf326('0x1e')](_0x170fa1[_0xf326('0x30')]['offset']);}return _0x2f7b5[_0xf326('0x4b')](_0x4db9cc);}})[_0xf326('0x41')](function(_0x12d8b8){if(_0x12d8b8){return _0x12d8b8?{'count':_0x53dc92,'rows':_0x12d8b8}:null;}})['then'](respondWithResult(_0x4591be,null))[_0xf326('0x45')](handleError(_0x4591be,null));};exports[_0xf326('0x4e')]=function(_0x1764f4,_0x616afb,_0x191b11){if(_0x1764f4[_0xf326('0x4a')]['id']){delete _0x1764f4[_0xf326('0x4a')]['id'];}return db[_0xf326('0x2c')][_0xf326('0x4c')]({'where':{'id':_0x1764f4['params']['id']}})[_0xf326('0x41')](handleEntityNotFound(_0x616afb,null))['then'](function(_0x2fc2f6){if(_0x2fc2f6){_0x1764f4[_0xf326('0x4a')]['AccountId']=_0x2fc2f6['id'];_0x1764f4[_0xf326('0x4a')][_0xf326('0x4f')]=integrations['getSubjects'](_0x1764f4[_0xf326('0x4a')][_0xf326('0x50')],_0x1764f4['body'][_0xf326('0x3f')]);_0x1764f4[_0xf326('0x4a')][_0xf326('0x51')]=integrations['getDescriptions'](_0x1764f4[_0xf326('0x4a')]['channel'],_0x1764f4[_0xf326('0x4a')][_0xf326('0x3f')]);return db[_0xf326('0x4d')][_0xf326('0x49')](_0x1764f4['body'],{'include':[{'model':db[_0xf326('0x52')],'as':_0xf326('0x4f')},{'model':db[_0xf326('0x52')],'as':'Descriptions'}]});}return null;})[_0xf326('0x41')](respondWithResult(_0x616afb,null))['catch'](handleError(_0x616afb,null));};exports['getFields']=function(_0x31e4d4,_0x42491a,_0xb9cd3f){var _0x11ed64;var _0x26f5a4='';var _0x13acf0=_0xf326('0x53');return db[_0xf326('0x2c')][_0xf326('0x4c')]({'where':{'id':_0x31e4d4[_0xf326('0x47')]['id']},'attributes':['id',_0xf326('0x54'),_0xf326('0x55'),_0xf326('0x56'),_0xf326('0x57'),_0xf326('0x58'),_0xf326('0x59')]})['then'](handleEntityNotFound(_0x42491a,null))[_0xf326('0x41')](function(_0xbaa98e){if(_0xbaa98e){_0x26f5a4=_0xbaa98e[_0xf326('0x54')];var _0x8bbed8=_0x26f5a4[_0xf326('0x5a')](-0x1);if(_0x8bbed8==='/'){_0x26f5a4=_0x26f5a4[_0xf326('0x5b')](0x0,_0x26f5a4['lastIndexOf'](_0x8bbed8));}_0x11ed64=new jsforce['Connection']({'oauth2':{'loginUrl':_0x26f5a4,'clientId':_0xbaa98e[_0xf326('0x55')],'clientSecret':_0xbaa98e['clientSecret']}});return _0x11ed64[_0xf326('0x5c')](_0xbaa98e[_0xf326('0x57')],_0xbaa98e[_0xf326('0x58')][_0xf326('0x5d')](_0xbaa98e['securityToken']));}})['then'](function(_0xfd2cf8){if(_0xfd2cf8){if(!_[_0xf326('0x5e')](_0x31e4d4['query'][_0xf326('0x5f')])){_0x13acf0=_0x31e4d4[_0xf326('0x30')]['ticketType'];}return _0x11ed64['sobject'](_0x13acf0)[_0xf326('0x60')]();}})[_0xf326('0x41')](function(_0x3eb2d3){var _0x2244e7=[_0xf326('0x61'),'ActivityDate','IsReminderSet',_0xf326('0x62'),'Subject',_0xf326('0x63')];var _0x4e1b74=['string',_0xf326('0x64'),'picklist',_0xf326('0x65'),_0xf326('0x66'),_0xf326('0x67'),_0xf326('0x68')];if(_0x3eb2d3){_['remove'](_0x3eb2d3[_0xf326('0x34')],function(_0x70b5c3){return _0x2244e7[_0xf326('0x69')](_0x70b5c3[_0xf326('0x29')])||!_0x4e1b74[_0xf326('0x69')](_0x70b5c3[_0xf326('0x3f')]);});return{'count':_0x3eb2d3[_0xf326('0x34')][_0xf326('0x36')],'rows':_['map'](_0x3eb2d3[_0xf326('0x34')],function(_0x3df404){return{'id':_0x3df404[_0xf326('0x29')],'name':_0x3df404[_0xf326('0x6a')],'custom':_0x3df404[_0xf326('0x6b')],'options':_0x3df404[_0xf326('0x6c')]['length']>0x0?_[_0xf326('0x2b')](_0x3df404[_0xf326('0x6c')],function(_0x4f47c9){return{'name':_0x4f47c9[_0xf326('0x6a')],'value':_0x4f47c9[_0xf326('0x6d')]};}):_0x3df404[_0xf326('0x3f')]=='boolean'?[{'name':'True','value':_0xf326('0x6e')},{'name':_0xf326('0x6f'),'value':_0xf326('0x70')}]:[]};})};}})[_0xf326('0x41')](respondWithResult(_0x42491a,null))['catch'](function(_0x1d0fbf){var _0x3284ad=_0x31e4d4[_0xf326('0x30')]['test']?0x1f4:_0x1d0fbf[_0xf326('0x71')]||0x1f4;logger['error']('getFields,\x20%s,\x20%s,\x20%s','getFields',_0x3284ad,JSON[_0xf326('0x72')](_0x1d0fbf));delete _0x1d0fbf[_0xf326('0x29')];if(_0x3284ad===0x191){_0x3284ad=0x190;}_0x42491a[_0xf326('0x19')](_0x3284ad)[_0xf326('0x73')](_0x31e4d4[_0xf326('0x30')]['test']?{'message':_0xf326('0x74'),'statusCode':_0x1d0fbf['statusCode']}:_0x1d0fbf);});};
\ No newline at end of file