Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index aa2825d..a16efb2 100644 (file)
@@ -1 +1 @@
-const a336_0x4ae9=['substring','Reason','end','False','where','getDescriptions','catch','getFields','fields','statusCode','SuppliedName','Descriptions','Wrong\x20credentials','SuppliedCompany','SalesforceField','VIRTUAL','../../components/integrations/configuration','label','stringify','name','Status','order','jsforce','attributes','merge','sobject','json','password','custom','Priority','api','channel','AccountId','keys','rawAttributes','CallDurationInSeconds','concat','SalesforceAccount','query','CallType','pick','send','count','destroy','error','../../components/parsers/qs','Origin','Connection','intersection','getConfigurations','slice','findAll','stack','clientId','lodash','isNil','then','undefined','test','sendStatus','Case','SalesforceConfiguration','key','login','Subjects','status','rows','includeAll','IsArchived','offset','length','getFields,\x20%s,\x20%s,\x20%s','value','Type','findOne','IsEscalated','model','describe','include','sort','create','limit','CallObject','boolean','update','params','filter','map','true','body','../../mysqldb','lastIndexOf','type','filters','options','True','show','ticketType','picklistValues','sequelize','CallDisposition','like','remoteUri','username'];(function(_0x28bfb9,_0x53077f){const _0x4ae9d0=function(_0x4d771d){while(--_0x4d771d){_0x28bfb9['push'](_0x28bfb9['shift']());}};_0x4ae9d0(++_0x53077f);}(a336_0x4ae9,0x137));const a336_0x4d77=function(_0x28bfb9,_0x53077f){_0x28bfb9=_0x28bfb9-0x1ac;let _0x4ae9d0=a336_0x4ae9[_0x28bfb9];return _0x4ae9d0;};const a336_0xb7b50=a336_0x4d77;'use strict';const _=require(a336_0xb7b50(0x1e3)),jsforce=require(a336_0xb7b50(0x1c3)),qs=require(a336_0xb7b50(0x1da)),logger=require('../../config/logger')(a336_0xb7b50(0x1cb)),{db}=require(a336_0xb7b50(0x207)),{Op}=require(a336_0xb7b50(0x210)),integrations=require(a336_0xb7b50(0x1bd));function respondWithResult(_0x4f1a68,_0x436786){return _0x436786=_0x436786||0xc8,function(_0x22d334){const _0x410a0e=a336_0x4d77;if(_0x22d334)return _0x4f1a68[_0x410a0e(0x1ee)](_0x436786)[_0x410a0e(0x1c7)](_0x22d334);};}function respondWithFilteredResult(_0x57a249,_0x2875e8){return function(_0x3029ad){const _0x29e9e5=a336_0x4d77;if(_0x3029ad){const _0x1a2238=_0x3029ad['count'],_0x2d46f4=_0x2875e8['offset'];let _0x3aaa0a=_0x2875e8[_0x29e9e5(0x1f2)]+_0x2875e8['limit'],_0x8d71ab;return _0x3aaa0a>=_0x1a2238?(_0x3aaa0a=_0x1a2238,_0x8d71ab=0xc8):_0x8d71ab=0xce,_0x57a249[_0x29e9e5(0x1ee)](_0x8d71ab),_0x57a249['set']('Content-Range',_0x2d46f4+'-'+_0x3aaa0a+'/'+_0x1a2238)[_0x29e9e5(0x1c7)](_0x3029ad);}return null;};}function saveUpdates(_0x4268c4){return function(_0x1e470d){const _0x1a78ec=a336_0x4d77;if(_0x1e470d)return _0x1e470d[_0x1a78ec(0x201)](_0x4268c4)[_0x1a78ec(0x1e5)](function(_0x398cb0){return _0x398cb0;});return null;};}function removeEntity(_0x44ca3c){return function(_0x372482){const _0x371121=a336_0x4d77;if(_0x372482)return _0x372482[_0x371121(0x1d8)]()[_0x371121(0x1e5)](function(){const _0x14aa3a=_0x371121;_0x44ca3c[_0x14aa3a(0x1ee)](0xcc)[_0x14aa3a(0x1af)]();});};}function handleEntityNotFound(_0x122002){return function(_0x28e403){const _0x2aeae4=a336_0x4d77;return!_0x28e403&&_0x122002[_0x2aeae4(0x1e8)](0x194),_0x28e403;};}function handleError(_0xe2cfec,_0x56c1b0){return _0x56c1b0=_0x56c1b0||0x1f4,function(_0x325112){const _0x281aa0=a336_0x4d77;logger[_0x281aa0(0x1d9)](_0x325112[_0x281aa0(0x1e1)]),_0x325112['name']&&delete _0x325112['name'],_0xe2cfec[_0x281aa0(0x1ee)](_0x56c1b0)[_0x281aa0(0x1d6)](_0x325112);};}exports['index']=function(_0x368ce1,_0x5f30fe){const _0x3ffd22=a336_0xb7b50;let _0x2b3a5f={};const _0x262f26={},_0x4c047e={'count':0x0,'rows':[]},_0x5d0299=_[_0x3ffd22(0x204)](db['SalesforceAccount'][_0x3ffd22(0x1cf)],function(_0x33b924){const _0x5d0fb8=_0x3ffd22;return{'name':_0x33b924['fieldName'],'type':_0x33b924[_0x5d0fb8(0x209)][_0x5d0fb8(0x1eb)]};});_0x262f26[_0x3ffd22(0x1f9)]=_[_0x3ffd22(0x204)](_0x5d0299,_0x3ffd22(0x1c0)),_0x262f26[_0x3ffd22(0x1d3)]=_[_0x3ffd22(0x1ce)](_0x368ce1['query']),_0x262f26[_0x3ffd22(0x20a)]=_[_0x3ffd22(0x1dd)](_0x262f26[_0x3ffd22(0x1f9)],_0x262f26[_0x3ffd22(0x1d3)]),_0x2b3a5f['attributes']=_[_0x3ffd22(0x1dd)](_0x262f26[_0x3ffd22(0x1f9)],qs['fields'](_0x368ce1[_0x3ffd22(0x1d3)]['fields'])),_0x2b3a5f[_0x3ffd22(0x1c4)]=_0x2b3a5f[_0x3ffd22(0x1c4)][_0x3ffd22(0x1f3)]?_0x2b3a5f[_0x3ffd22(0x1c4)]:_0x262f26['model'];typeof _0x368ce1[_0x3ffd22(0x1d3)]['nolimit']===_0x3ffd22(0x1e6)&&(_0x2b3a5f[_0x3ffd22(0x1fe)]=qs[_0x3ffd22(0x1fe)](_0x368ce1[_0x3ffd22(0x1d3)][_0x3ffd22(0x1fe)]),_0x2b3a5f[_0x3ffd22(0x1f2)]=qs[_0x3ffd22(0x1f2)](_0x368ce1['query'][_0x3ffd22(0x1f2)]));_0x2b3a5f[_0x3ffd22(0x1c2)]=qs[_0x3ffd22(0x1fc)](_0x368ce1[_0x3ffd22(0x1d3)][_0x3ffd22(0x1fc)]),_0x2b3a5f['where']=qs[_0x3ffd22(0x20a)](_['pick'](_0x368ce1[_0x3ffd22(0x1d3)],_0x262f26[_0x3ffd22(0x20a)]),_0x5d0299);_0x368ce1[_0x3ffd22(0x1d3)][_0x3ffd22(0x203)]&&(_0x2b3a5f['where']=_['merge'](_0x2b3a5f[_0x3ffd22(0x1b1)],{[Op['or']]:_[_0x3ffd22(0x204)](_0x5d0299,function(_0x149007){const _0x49536c=_0x3ffd22;if(_0x149007[_0x49536c(0x209)]!==_0x49536c(0x1bc)){const _0x556c6c={};return _0x556c6c[_0x149007['name']]={[Op[_0x49536c(0x212)]]:'%'+_0x368ce1[_0x49536c(0x1d3)][_0x49536c(0x203)]+'%'},_0x556c6c;}})}));_0x2b3a5f=_[_0x3ffd22(0x1c5)]({},_0x2b3a5f,_0x368ce1[_0x3ffd22(0x20b)]);const _0x4be171={'where':_0x2b3a5f[_0x3ffd22(0x1b1)]};return db[_0x3ffd22(0x1d2)][_0x3ffd22(0x1d7)](_0x4be171)['then'](function(_0x2b3ee2){const _0x2a5835=_0x3ffd22;return _0x4c047e[_0x2a5835(0x1d7)]=_0x2b3ee2,_0x368ce1[_0x2a5835(0x1d3)]['includeAll']&&(_0x2b3a5f[_0x2a5835(0x1fb)]=[{'all':!![]}]),db[_0x2a5835(0x1d2)][_0x2a5835(0x1e0)](_0x2b3a5f);})['then'](function(_0x4b6520){const _0x3964d6=_0x3ffd22;return _0x4c047e[_0x3964d6(0x1ef)]=_0x4b6520,_0x4c047e;})['then'](respondWithFilteredResult(_0x5f30fe,_0x2b3a5f))['catch'](handleError(_0x5f30fe,null));},exports[a336_0xb7b50(0x20d)]=function(_0x1dacb3,_0x4fbf75){const _0x36f9ca=a336_0xb7b50;let _0x4147c4={'raw':![],'where':{'id':_0x1dacb3[_0x36f9ca(0x202)]['id']}};const _0x2eb208={};return _0x2eb208[_0x36f9ca(0x1f9)]=_[_0x36f9ca(0x1ce)](db[_0x36f9ca(0x1d2)]['rawAttributes']),_0x2eb208[_0x36f9ca(0x1d3)]=_[_0x36f9ca(0x1ce)](_0x1dacb3['query']),_0x2eb208['filters']=_['intersection'](_0x2eb208[_0x36f9ca(0x1f9)],_0x2eb208[_0x36f9ca(0x1d3)]),_0x4147c4[_0x36f9ca(0x1c4)]=_[_0x36f9ca(0x1dd)](_0x2eb208[_0x36f9ca(0x1f9)],qs[_0x36f9ca(0x1b5)](_0x1dacb3['query']['fields'])),_0x4147c4['attributes']=_0x4147c4['attributes']['length']?_0x4147c4['attributes']:_0x2eb208[_0x36f9ca(0x1f9)],_0x1dacb3['query'][_0x36f9ca(0x1f0)]&&(_0x4147c4[_0x36f9ca(0x1fb)]=[{'all':!![]}]),_0x4147c4=_[_0x36f9ca(0x1c5)]({},_0x4147c4,_0x1dacb3[_0x36f9ca(0x20b)]),db['SalesforceAccount']['findOne'](_0x4147c4)[_0x36f9ca(0x1e5)](handleEntityNotFound(_0x4fbf75,null))[_0x36f9ca(0x1e5)](respondWithResult(_0x4fbf75,null))[_0x36f9ca(0x1b3)](handleError(_0x4fbf75,null));},exports['create']=function(_0x14337d,_0x2e60e8){const _0x564793=a336_0xb7b50;return db['SalesforceAccount'][_0x564793(0x1fd)](_0x14337d[_0x564793(0x206)],{})[_0x564793(0x1e5)](respondWithResult(_0x2e60e8,0xc9))[_0x564793(0x1b3)](handleError(_0x2e60e8,null));},exports[a336_0xb7b50(0x201)]=function(_0x38b69c,_0x1989be){const _0x52720d=a336_0xb7b50;return _0x38b69c[_0x52720d(0x206)]['id']&&delete _0x38b69c['body']['id'],db[_0x52720d(0x1d2)][_0x52720d(0x1f7)]({'where':{'id':_0x38b69c[_0x52720d(0x202)]['id']}})[_0x52720d(0x1e5)](handleEntityNotFound(_0x1989be,null))[_0x52720d(0x1e5)](saveUpdates(_0x38b69c['body'],null))[_0x52720d(0x1e5)](respondWithResult(_0x1989be,null))[_0x52720d(0x1b3)](handleError(_0x1989be,null));},exports[a336_0xb7b50(0x1d8)]=function(_0x3eee8a,_0x1dc97a){const _0x12abbe=a336_0xb7b50;return db['SalesforceAccount'][_0x12abbe(0x1f7)]({'where':{'id':_0x3eee8a[_0x12abbe(0x202)]['id']}})[_0x12abbe(0x1e5)](handleEntityNotFound(_0x1dc97a,null))[_0x12abbe(0x1e5)](removeEntity(_0x1dc97a,null))[_0x12abbe(0x1b3)](handleError(_0x1dc97a,null));},exports[a336_0xb7b50(0x1de)]=function(_0x5ed7ca,_0x469984){const _0x32d132=a336_0xb7b50;let _0x5e62cc={};const _0x548b1={};let _0x1698e0,_0x311961;return db[_0x32d132(0x1d2)][_0x32d132(0x1f7)]({'where':{'id':_0x5ed7ca['params']['id']}})[_0x32d132(0x1e5)](handleEntityNotFound(_0x469984,null))[_0x32d132(0x1e5)](function(_0x25466d){const _0x3f2463=_0x32d132;if(_0x25466d)return _0x1698e0=_0x25466d,_0x548b1[_0x3f2463(0x1f9)]=_['keys'](db[_0x3f2463(0x1ea)][_0x3f2463(0x1cf)]),_0x548b1[_0x3f2463(0x1d3)]=_[_0x3f2463(0x1ce)](_0x5ed7ca[_0x3f2463(0x1d3)]),_0x548b1[_0x3f2463(0x20a)]=_['intersection'](_0x548b1['model'],_0x548b1['query']),_0x5e62cc['attributes']=_[_0x3f2463(0x1dd)](_0x548b1[_0x3f2463(0x1f9)],qs[_0x3f2463(0x1b5)](_0x5ed7ca[_0x3f2463(0x1d3)][_0x3f2463(0x1b5)])),_0x5e62cc[_0x3f2463(0x1c4)]=_0x5e62cc[_0x3f2463(0x1c4)][_0x3f2463(0x1f3)]?_0x5e62cc[_0x3f2463(0x1c4)]:_0x548b1[_0x3f2463(0x1f9)],_0x5e62cc[_0x3f2463(0x1c2)]=qs[_0x3f2463(0x1fc)](_0x5ed7ca[_0x3f2463(0x1d3)][_0x3f2463(0x1fc)]),_0x5e62cc[_0x3f2463(0x1b1)]=qs[_0x3f2463(0x20a)](_[_0x3f2463(0x1d5)](_0x5ed7ca['query'],_0x548b1[_0x3f2463(0x20a)])),_0x5ed7ca[_0x3f2463(0x1d3)][_0x3f2463(0x203)]&&(_0x5e62cc[_0x3f2463(0x1b1)]=_[_0x3f2463(0x1c5)](_0x5e62cc['where'],{[Op['or']]:_[_0x3f2463(0x204)](_0x5e62cc[_0x3f2463(0x1c4)],function(_0xf4facb){const _0x597a93=_0x3f2463,_0x36058a={};return _0x36058a[_0xf4facb]={[Op[_0x597a93(0x212)]]:'%'+_0x5ed7ca['query'][_0x597a93(0x203)]+'%'},_0x36058a;})})),_0x5e62cc=_[_0x3f2463(0x1c5)]({},_0x5e62cc,_0x5ed7ca[_0x3f2463(0x20b)]),_0x1698e0['getConfigurations'](_0x5e62cc);})[_0x32d132(0x1e5)](function(_0x25af60){const _0x8c9a69=_0x32d132;if(_0x25af60)return _0x311961=_0x25af60[_0x8c9a69(0x1f3)],typeof _0x5ed7ca[_0x8c9a69(0x1d3)]['nolimit']===_0x8c9a69(0x1e6)&&(_0x5e62cc[_0x8c9a69(0x1fe)]=qs[_0x8c9a69(0x1fe)](_0x5ed7ca[_0x8c9a69(0x1d3)][_0x8c9a69(0x1fe)]),_0x5e62cc[_0x8c9a69(0x1f2)]=qs[_0x8c9a69(0x1f2)](_0x5ed7ca['query']['offset'])),_0x1698e0['getConfigurations'](_0x5e62cc);})['then'](function(_0x5d954e){if(_0x5d954e)return _0x5d954e?{'count':_0x311961,'rows':_0x5d954e}:null;})[_0x32d132(0x1e5)](respondWithResult(_0x469984,null))[_0x32d132(0x1b3)](handleError(_0x469984,null));},exports['addConfiguration']=function(_0x310f38,_0x4ebdef){const _0x3a21fa=a336_0xb7b50;return _0x310f38[_0x3a21fa(0x206)]['id']&&delete _0x310f38[_0x3a21fa(0x206)]['id'],db[_0x3a21fa(0x1d2)][_0x3a21fa(0x1f7)]({'where':{'id':_0x310f38[_0x3a21fa(0x202)]['id']}})[_0x3a21fa(0x1e5)](handleEntityNotFound(_0x4ebdef,null))[_0x3a21fa(0x1e5)](function(_0x42022d){const _0x2cb66c=_0x3a21fa;if(_0x42022d)return _0x310f38['body'][_0x2cb66c(0x1cd)]=_0x42022d['id'],_0x310f38[_0x2cb66c(0x206)][_0x2cb66c(0x1ed)]=integrations['getSubjects'](_0x310f38['body'][_0x2cb66c(0x1cc)],_0x310f38['body']['type']),_0x310f38['body'][_0x2cb66c(0x1b8)]=integrations[_0x2cb66c(0x1b2)](_0x310f38[_0x2cb66c(0x206)]['channel'],_0x310f38['body'][_0x2cb66c(0x209)]),db[_0x2cb66c(0x1ea)][_0x2cb66c(0x1fd)](_0x310f38[_0x2cb66c(0x206)],{'include':[{'model':db[_0x2cb66c(0x1bb)],'as':_0x2cb66c(0x1ed)},{'model':db[_0x2cb66c(0x1bb)],'as':_0x2cb66c(0x1b8)}]});return null;})[_0x3a21fa(0x1e5)](respondWithResult(_0x4ebdef,null))[_0x3a21fa(0x1b3)](handleError(_0x4ebdef,null));},exports[a336_0xb7b50(0x1b4)]=function(_0x56ca98,_0x3bc341){const _0x47f59d=a336_0xb7b50;let _0x5035f6,_0x2d5dd8='',_0x550079='Task';return db[_0x47f59d(0x1d2)]['findOne']({'where':{'id':_0x56ca98[_0x47f59d(0x202)]['id']},'attributes':['id',_0x47f59d(0x213),'clientId','clientSecret',_0x47f59d(0x1ac),_0x47f59d(0x1c8),'securityToken']})[_0x47f59d(0x1e5)](handleEntityNotFound(_0x3bc341,null))[_0x47f59d(0x1e5)](function(_0x2b34f8){const _0x25443e=_0x47f59d;if(_0x2b34f8){_0x2d5dd8=_0x2b34f8['remoteUri'];const _0x1d20cc=_0x2d5dd8[_0x25443e(0x1df)](-0x1);return _0x1d20cc==='/'&&(_0x2d5dd8=_0x2d5dd8[_0x25443e(0x1ad)](0x0,_0x2d5dd8[_0x25443e(0x208)](_0x1d20cc))),_0x5035f6=new jsforce[(_0x25443e(0x1dc))]({'oauth2':{'loginUrl':_0x2d5dd8,'clientId':_0x2b34f8[_0x25443e(0x1e2)],'clientSecret':_0x2b34f8['clientSecret']}}),_0x5035f6[_0x25443e(0x1ec)](_0x2b34f8['username'],_0x2b34f8[_0x25443e(0x1c8)][_0x25443e(0x1d1)](_0x2b34f8['securityToken']));}})['then'](function(_0x3aadda){const _0x36855a=_0x47f59d;if(_0x3aadda)return!_[_0x36855a(0x1e4)](_0x56ca98[_0x36855a(0x1d3)]['ticketType'])&&(_0x550079=_0x56ca98['query'][_0x36855a(0x20e)]),_0x5035f6[_0x36855a(0x1c6)](_0x550079)[_0x36855a(0x1fa)]();})[_0x47f59d(0x1e5)](function(_0x1c4c8a){const _0x2485fd=_0x47f59d;let _0x2b01e7=[_0x2485fd(0x211),_0x2485fd(0x1d0),_0x2485fd(0x1ff),_0x2485fd(0x1d4),_0x2485fd(0x1f1),_0x2485fd(0x1ca),_0x2485fd(0x1c1),_0x2485fd(0x1f6)];!_[_0x2485fd(0x1e4)](_0x56ca98[_0x2485fd(0x1d3)][_0x2485fd(0x20e)])&&_0x56ca98[_0x2485fd(0x1d3)][_0x2485fd(0x20e)]===_0x2485fd(0x1e9)&&(_0x2b01e7=[_0x2485fd(0x1f6),_0x2485fd(0x1db),_0x2485fd(0x1ae),_0x2485fd(0x1c1),_0x2485fd(0x1ca),_0x2485fd(0x1f8),_0x2485fd(0x1b7),_0x2485fd(0x1ba)]);if(_0x1c4c8a)return _['remove'](_0x1c4c8a[_0x2485fd(0x1b5)],function(_0x444c88){const _0x5eb839=_0x2485fd;return _0x444c88[_0x5eb839(0x1c9)]===![]&&!_0x2b01e7['includes'](_0x444c88[_0x5eb839(0x1c0)]);}),{'count':_0x1c4c8a[_0x2485fd(0x1b5)]['length'],'rows':_[_0x2485fd(0x204)](_0x1c4c8a[_0x2485fd(0x1b5)],function(_0x591308){const _0x41a074=_0x2485fd;return{'id':_0x591308[_0x41a074(0x1c0)],'name':_0x591308['label'],'custom':_0x591308[_0x41a074(0x1c9)],'options':_0x591308['picklistValues'][_0x41a074(0x1f3)]>0x0?_[_0x41a074(0x204)](_0x591308[_0x41a074(0x20f)],function(_0x178e38){const _0xa1f3af=_0x41a074;return{'name':_0x178e38[_0xa1f3af(0x1be)],'value':_0x178e38[_0xa1f3af(0x1f5)]};}):_0x591308[_0x41a074(0x209)]==_0x41a074(0x200)?[{'name':_0x41a074(0x20c),'value':_0x41a074(0x205)},{'name':_0x41a074(0x1b0),'value':'false'}]:[]};})};})[_0x47f59d(0x1e5)](respondWithResult(_0x3bc341,null))['catch'](function(_0x2a9a82){const _0x4960d2=_0x47f59d;let _0x1d7bdf=_0x56ca98[_0x4960d2(0x1d3)][_0x4960d2(0x1e7)]?0x1f4:_0x2a9a82[_0x4960d2(0x1b6)]||0x1f4;logger['error'](_0x4960d2(0x1f4),'getFields',_0x1d7bdf,JSON[_0x4960d2(0x1bf)](_0x2a9a82)),delete _0x2a9a82['name'],_0x1d7bdf===0x191&&(_0x1d7bdf=0x190),_0x3bc341[_0x4960d2(0x1ee)](_0x1d7bdf)[_0x4960d2(0x1d6)](_0x56ca98[_0x4960d2(0x1d3)][_0x4960d2(0x1e7)]?{'message':_0x4960d2(0x1b9),'statusCode':_0x2a9a82[_0x4960d2(0x1b6)]}:_0x2a9a82);});};
\ No newline at end of file
+const a336_0x3711=['login','sequelize','intersection','findAll','limit','value','CallObject','order','SuppliedCompany','substring','include','filters','params','password','username','getConfigurations','concat','attributes','getDescriptions','update','statusCode','then','false','CallType','clientId','Subjects','includeAll','true','like','../../mysqldb','channel','remoteUri','AccountId','custom','error','nolimit','../../components/integrations/configuration','destroy','model','merge','type','stack','pick','Connection','keys','getFields','../../components/parsers/qs','json','options','length','getSubjects','IsArchived','show','False','rows','send','isNil','test','index','../../config/logger','SalesforceConfiguration','SuppliedName','SalesforceAccount','query','SalesforceField','Type','lodash','jsforce','offset','Case','Descriptions','name','securityToken','map','ticketType','describe','VIRTUAL','where','addConfiguration','Wrong\x20credentials','body','rawAttributes','label','Content-Range','catch','boolean','Status','True','sendStatus','Reason','sort','remove','filter','undefined','create','clientSecret','end','fields','api','status','findOne'];(function(_0x328787,_0x409803){const _0x3711a7=function(_0x5b12cb){while(--_0x5b12cb){_0x328787['push'](_0x328787['shift']());}};_0x3711a7(++_0x409803);}(a336_0x3711,0x184));const a336_0x5b12=function(_0x328787,_0x409803){_0x328787=_0x328787-0xc7;let _0x3711a7=a336_0x3711[_0x328787];return _0x3711a7;};const a336_0x7e4da7=a336_0x5b12;'use strict';const _=require(a336_0x7e4da7(0x119)),jsforce=require(a336_0x7e4da7(0x11a)),qs=require(a336_0x7e4da7(0x105)),logger=require(a336_0x7e4da7(0x112))(a336_0x7e4da7(0xd4)),{db}=require(a336_0x7e4da7(0xf4)),{Op}=require(a336_0x7e4da7(0xd8)),integrations=require(a336_0x7e4da7(0xfb));function respondWithResult(_0x395278,_0x190929){return _0x190929=_0x190929||0xc8,function(_0x2043bf){const _0x3f47a=a336_0x5b12;if(_0x2043bf)return _0x395278['status'](_0x190929)[_0x3f47a(0x106)](_0x2043bf);};}function respondWithFilteredResult(_0x227939,_0x5233b8){return function(_0x12bad0){const _0x5ea726=a336_0x5b12;if(_0x12bad0){const _0x17d89f=_0x12bad0['count'],_0x13c630=_0x5233b8[_0x5ea726(0x11b)];let _0x171225=_0x5233b8['offset']+_0x5233b8['limit'],_0xf2b2dd;return _0x171225>=_0x17d89f?(_0x171225=_0x17d89f,_0xf2b2dd=0xc8):_0xf2b2dd=0xce,_0x227939[_0x5ea726(0xd5)](_0xf2b2dd),_0x227939['set'](_0x5ea726(0x12a),_0x13c630+'-'+_0x171225+'/'+_0x17d89f)['json'](_0x12bad0);}return null;};}function saveUpdates(_0x2a604e){return function(_0x318d57){const _0x1f9510=a336_0x5b12;if(_0x318d57)return _0x318d57[_0x1f9510(0xea)](_0x2a604e)[_0x1f9510(0xec)](function(_0x5d3a3c){return _0x5d3a3c;});return null;};}function removeEntity(_0x47bdf1){return function(_0x57e4aa){const _0x404ab4=a336_0x5b12;if(_0x57e4aa)return _0x57e4aa['destroy']()[_0x404ab4(0xec)](function(){const _0x14fc58=_0x404ab4;_0x47bdf1['status'](0xcc)[_0x14fc58(0xd2)]();});};}function handleEntityNotFound(_0x3833df){return function(_0x196f2d){const _0x43a61a=a336_0x5b12;return!_0x196f2d&&_0x3833df[_0x43a61a(0xca)](0x194),_0x196f2d;};}function handleError(_0x8573fc,_0x47a5fa){return _0x47a5fa=_0x47a5fa||0x1f4,function(_0x3b92f9){const _0x2fa09d=a336_0x5b12;logger[_0x2fa09d(0xf9)](_0x3b92f9[_0x2fa09d(0x100)]),_0x3b92f9['name']&&delete _0x3b92f9['name'],_0x8573fc[_0x2fa09d(0xd5)](_0x47a5fa)['send'](_0x3b92f9);};}exports[a336_0x7e4da7(0x111)]=function(_0x6afe3,_0x2a80fb){const _0x149d3b=a336_0x7e4da7;let _0x1e093e={};const _0x2ff6a4={},_0x1aa2e8={'count':0x0,'rows':[]},_0x22da20=_['map'](db[_0x149d3b(0x115)][_0x149d3b(0x128)],function(_0x5a0403){const _0x4e53bf=_0x149d3b;return{'name':_0x5a0403['fieldName'],'type':_0x5a0403[_0x4e53bf(0xff)]['key']};});_0x2ff6a4[_0x149d3b(0xfd)]=_[_0x149d3b(0x120)](_0x22da20,'name'),_0x2ff6a4[_0x149d3b(0x116)]=_[_0x149d3b(0x103)](_0x6afe3['query']),_0x2ff6a4[_0x149d3b(0xe2)]=_[_0x149d3b(0xd9)](_0x2ff6a4[_0x149d3b(0xfd)],_0x2ff6a4['query']),_0x1e093e[_0x149d3b(0xe8)]=_['intersection'](_0x2ff6a4[_0x149d3b(0xfd)],qs[_0x149d3b(0xd3)](_0x6afe3['query']['fields'])),_0x1e093e[_0x149d3b(0xe8)]=_0x1e093e[_0x149d3b(0xe8)][_0x149d3b(0x108)]?_0x1e093e[_0x149d3b(0xe8)]:_0x2ff6a4['model'];typeof _0x6afe3[_0x149d3b(0x116)][_0x149d3b(0xfa)]===_0x149d3b(0xcf)&&(_0x1e093e[_0x149d3b(0xdb)]=qs[_0x149d3b(0xdb)](_0x6afe3[_0x149d3b(0x116)]['limit']),_0x1e093e[_0x149d3b(0x11b)]=qs[_0x149d3b(0x11b)](_0x6afe3[_0x149d3b(0x116)][_0x149d3b(0x11b)]));_0x1e093e[_0x149d3b(0xde)]=qs[_0x149d3b(0xcc)](_0x6afe3['query'][_0x149d3b(0xcc)]),_0x1e093e[_0x149d3b(0x124)]=qs[_0x149d3b(0xe2)](_['pick'](_0x6afe3[_0x149d3b(0x116)],_0x2ff6a4['filters']),_0x22da20);_0x6afe3[_0x149d3b(0x116)]['filter']&&(_0x1e093e['where']=_[_0x149d3b(0xfe)](_0x1e093e[_0x149d3b(0x124)],{[Op['or']]:_[_0x149d3b(0x120)](_0x22da20,function(_0x148ec4){const _0x34d394=_0x149d3b;if(_0x148ec4[_0x34d394(0xff)]!==_0x34d394(0x123)){const _0x4984fe={};return _0x4984fe[_0x148ec4[_0x34d394(0x11e)]]={[Op[_0x34d394(0xf3)]]:'%'+_0x6afe3[_0x34d394(0x116)][_0x34d394(0xce)]+'%'},_0x4984fe;}})}));_0x1e093e=_[_0x149d3b(0xfe)]({},_0x1e093e,_0x6afe3[_0x149d3b(0x107)]);const _0x57d301={'where':_0x1e093e[_0x149d3b(0x124)]};return db['SalesforceAccount']['count'](_0x57d301)[_0x149d3b(0xec)](function(_0x4e6b7e){const _0x174f02=_0x149d3b;return _0x1aa2e8['count']=_0x4e6b7e,_0x6afe3['query'][_0x174f02(0xf1)]&&(_0x1e093e[_0x174f02(0xe1)]=[{'all':!![]}]),db['SalesforceAccount'][_0x174f02(0xda)](_0x1e093e);})[_0x149d3b(0xec)](function(_0x69e98){const _0x44e928=_0x149d3b;return _0x1aa2e8[_0x44e928(0x10d)]=_0x69e98,_0x1aa2e8;})[_0x149d3b(0xec)](respondWithFilteredResult(_0x2a80fb,_0x1e093e))[_0x149d3b(0x12b)](handleError(_0x2a80fb,null));},exports[a336_0x7e4da7(0x10b)]=function(_0x2a65f5,_0x246cc4){const _0x50e2b7=a336_0x7e4da7;let _0x2d982f={'raw':![],'where':{'id':_0x2a65f5[_0x50e2b7(0xe3)]['id']}};const _0x5001eb={};return _0x5001eb[_0x50e2b7(0xfd)]=_[_0x50e2b7(0x103)](db['SalesforceAccount'][_0x50e2b7(0x128)]),_0x5001eb[_0x50e2b7(0x116)]=_[_0x50e2b7(0x103)](_0x2a65f5['query']),_0x5001eb['filters']=_[_0x50e2b7(0xd9)](_0x5001eb[_0x50e2b7(0xfd)],_0x5001eb[_0x50e2b7(0x116)]),_0x2d982f['attributes']=_[_0x50e2b7(0xd9)](_0x5001eb[_0x50e2b7(0xfd)],qs[_0x50e2b7(0xd3)](_0x2a65f5[_0x50e2b7(0x116)][_0x50e2b7(0xd3)])),_0x2d982f[_0x50e2b7(0xe8)]=_0x2d982f[_0x50e2b7(0xe8)][_0x50e2b7(0x108)]?_0x2d982f['attributes']:_0x5001eb[_0x50e2b7(0xfd)],_0x2a65f5[_0x50e2b7(0x116)][_0x50e2b7(0xf1)]&&(_0x2d982f[_0x50e2b7(0xe1)]=[{'all':!![]}]),_0x2d982f=_['merge']({},_0x2d982f,_0x2a65f5[_0x50e2b7(0x107)]),db[_0x50e2b7(0x115)][_0x50e2b7(0xd6)](_0x2d982f)[_0x50e2b7(0xec)](handleEntityNotFound(_0x246cc4,null))[_0x50e2b7(0xec)](respondWithResult(_0x246cc4,null))[_0x50e2b7(0x12b)](handleError(_0x246cc4,null));},exports['create']=function(_0x544934,_0x15fd20){const _0x298bec=a336_0x7e4da7;return db['SalesforceAccount'][_0x298bec(0xd0)](_0x544934[_0x298bec(0x127)],{})[_0x298bec(0xec)](respondWithResult(_0x15fd20,0xc9))[_0x298bec(0x12b)](handleError(_0x15fd20,null));},exports[a336_0x7e4da7(0xea)]=function(_0xd7a63b,_0x540fd0){const _0x33b827=a336_0x7e4da7;return _0xd7a63b['body']['id']&&delete _0xd7a63b['body']['id'],db[_0x33b827(0x115)]['findOne']({'where':{'id':_0xd7a63b['params']['id']}})[_0x33b827(0xec)](handleEntityNotFound(_0x540fd0,null))[_0x33b827(0xec)](saveUpdates(_0xd7a63b['body'],null))[_0x33b827(0xec)](respondWithResult(_0x540fd0,null))[_0x33b827(0x12b)](handleError(_0x540fd0,null));},exports[a336_0x7e4da7(0xfc)]=function(_0x2809e2,_0x392c1e){const _0x55b91=a336_0x7e4da7;return db['SalesforceAccount'][_0x55b91(0xd6)]({'where':{'id':_0x2809e2['params']['id']}})[_0x55b91(0xec)](handleEntityNotFound(_0x392c1e,null))[_0x55b91(0xec)](removeEntity(_0x392c1e,null))[_0x55b91(0x12b)](handleError(_0x392c1e,null));},exports['getConfigurations']=function(_0xe6e1f2,_0x3a30e6){const _0x30ac9f=a336_0x7e4da7;let _0x525b61={};const _0x35ed08={};let _0x2b592e,_0x300416;return db[_0x30ac9f(0x115)][_0x30ac9f(0xd6)]({'where':{'id':_0xe6e1f2[_0x30ac9f(0xe3)]['id']}})[_0x30ac9f(0xec)](handleEntityNotFound(_0x3a30e6,null))[_0x30ac9f(0xec)](function(_0x19665e){const _0x10c4de=_0x30ac9f;if(_0x19665e)return _0x2b592e=_0x19665e,_0x35ed08[_0x10c4de(0xfd)]=_[_0x10c4de(0x103)](db[_0x10c4de(0x113)][_0x10c4de(0x128)]),_0x35ed08[_0x10c4de(0x116)]=_[_0x10c4de(0x103)](_0xe6e1f2[_0x10c4de(0x116)]),_0x35ed08[_0x10c4de(0xe2)]=_['intersection'](_0x35ed08[_0x10c4de(0xfd)],_0x35ed08[_0x10c4de(0x116)]),_0x525b61['attributes']=_[_0x10c4de(0xd9)](_0x35ed08['model'],qs[_0x10c4de(0xd3)](_0xe6e1f2[_0x10c4de(0x116)]['fields'])),_0x525b61[_0x10c4de(0xe8)]=_0x525b61[_0x10c4de(0xe8)][_0x10c4de(0x108)]?_0x525b61['attributes']:_0x35ed08[_0x10c4de(0xfd)],_0x525b61[_0x10c4de(0xde)]=qs[_0x10c4de(0xcc)](_0xe6e1f2[_0x10c4de(0x116)][_0x10c4de(0xcc)]),_0x525b61['where']=qs['filters'](_[_0x10c4de(0x101)](_0xe6e1f2[_0x10c4de(0x116)],_0x35ed08[_0x10c4de(0xe2)])),_0xe6e1f2['query']['filter']&&(_0x525b61['where']=_[_0x10c4de(0xfe)](_0x525b61['where'],{[Op['or']]:_[_0x10c4de(0x120)](_0x525b61[_0x10c4de(0xe8)],function(_0x2daa01){const _0x21aed4=_0x10c4de,_0x498050={};return _0x498050[_0x2daa01]={[Op['like']]:'%'+_0xe6e1f2[_0x21aed4(0x116)][_0x21aed4(0xce)]+'%'},_0x498050;})})),_0x525b61=_[_0x10c4de(0xfe)]({},_0x525b61,_0xe6e1f2[_0x10c4de(0x107)]),_0x2b592e[_0x10c4de(0xe6)](_0x525b61);})['then'](function(_0x2a4778){const _0x416f28=_0x30ac9f;if(_0x2a4778)return _0x300416=_0x2a4778[_0x416f28(0x108)],typeof _0xe6e1f2[_0x416f28(0x116)][_0x416f28(0xfa)]==='undefined'&&(_0x525b61['limit']=qs[_0x416f28(0xdb)](_0xe6e1f2[_0x416f28(0x116)][_0x416f28(0xdb)]),_0x525b61[_0x416f28(0x11b)]=qs['offset'](_0xe6e1f2[_0x416f28(0x116)][_0x416f28(0x11b)])),_0x2b592e[_0x416f28(0xe6)](_0x525b61);})[_0x30ac9f(0xec)](function(_0x39bb9b){if(_0x39bb9b)return _0x39bb9b?{'count':_0x300416,'rows':_0x39bb9b}:null;})['then'](respondWithResult(_0x3a30e6,null))[_0x30ac9f(0x12b)](handleError(_0x3a30e6,null));},exports[a336_0x7e4da7(0x125)]=function(_0x1918dc,_0x10bca8){const _0x173e5=a336_0x7e4da7;return _0x1918dc['body']['id']&&delete _0x1918dc[_0x173e5(0x127)]['id'],db[_0x173e5(0x115)][_0x173e5(0xd6)]({'where':{'id':_0x1918dc[_0x173e5(0xe3)]['id']}})[_0x173e5(0xec)](handleEntityNotFound(_0x10bca8,null))[_0x173e5(0xec)](function(_0x3c05f1){const _0xf54b7c=_0x173e5;if(_0x3c05f1)return _0x1918dc[_0xf54b7c(0x127)][_0xf54b7c(0xf7)]=_0x3c05f1['id'],_0x1918dc[_0xf54b7c(0x127)][_0xf54b7c(0xf0)]=integrations[_0xf54b7c(0x109)](_0x1918dc[_0xf54b7c(0x127)][_0xf54b7c(0xf5)],_0x1918dc[_0xf54b7c(0x127)][_0xf54b7c(0xff)]),_0x1918dc[_0xf54b7c(0x127)][_0xf54b7c(0x11d)]=integrations[_0xf54b7c(0xe9)](_0x1918dc[_0xf54b7c(0x127)][_0xf54b7c(0xf5)],_0x1918dc[_0xf54b7c(0x127)]['type']),db[_0xf54b7c(0x113)]['create'](_0x1918dc['body'],{'include':[{'model':db[_0xf54b7c(0x117)],'as':_0xf54b7c(0xf0)},{'model':db[_0xf54b7c(0x117)],'as':'Descriptions'}]});return null;})[_0x173e5(0xec)](respondWithResult(_0x10bca8,null))['catch'](handleError(_0x10bca8,null));},exports[a336_0x7e4da7(0x104)]=function(_0x9092a1,_0x13318f){const _0x358bab=a336_0x7e4da7;let _0x4e54f9,_0x13644c='',_0x5c9bd4='Task';return db[_0x358bab(0x115)]['findOne']({'where':{'id':_0x9092a1[_0x358bab(0xe3)]['id']},'attributes':['id',_0x358bab(0xf6),_0x358bab(0xef),_0x358bab(0xd1),_0x358bab(0xe5),_0x358bab(0xe4),_0x358bab(0x11f)]})[_0x358bab(0xec)](handleEntityNotFound(_0x13318f,null))[_0x358bab(0xec)](function(_0x216bd4){const _0x1cfec7=_0x358bab;if(_0x216bd4){_0x13644c=_0x216bd4['remoteUri'];const _0x552682=_0x13644c['slice'](-0x1);return _0x552682==='/'&&(_0x13644c=_0x13644c[_0x1cfec7(0xe0)](0x0,_0x13644c['lastIndexOf'](_0x552682))),_0x4e54f9=new jsforce[(_0x1cfec7(0x102))]({'oauth2':{'loginUrl':_0x13644c,'clientId':_0x216bd4[_0x1cfec7(0xef)],'clientSecret':_0x216bd4[_0x1cfec7(0xd1)]}}),_0x4e54f9[_0x1cfec7(0xd7)](_0x216bd4['username'],_0x216bd4[_0x1cfec7(0xe4)][_0x1cfec7(0xe7)](_0x216bd4[_0x1cfec7(0x11f)]));}})[_0x358bab(0xec)](function(_0x533303){const _0x49b1ee=_0x358bab;if(_0x533303)return!_['isNil'](_0x9092a1[_0x49b1ee(0x116)][_0x49b1ee(0x121)])&&(_0x5c9bd4=_0x9092a1['query'][_0x49b1ee(0x121)]),_0x4e54f9['sobject'](_0x5c9bd4)[_0x49b1ee(0x122)]();})['then'](function(_0x52f03a){const _0x4aa057=_0x358bab;let _0xae579c=['CallDisposition','CallDurationInSeconds',_0x4aa057(0xdd),_0x4aa057(0xee),_0x4aa057(0x10a),'Priority',_0x4aa057(0xc8),_0x4aa057(0x118)];!_[_0x4aa057(0x10f)](_0x9092a1[_0x4aa057(0x116)][_0x4aa057(0x121)])&&_0x9092a1[_0x4aa057(0x116)][_0x4aa057(0x121)]===_0x4aa057(0x11c)&&(_0xae579c=['Type','Origin',_0x4aa057(0xcb),_0x4aa057(0xc8),'Priority','IsEscalated',_0x4aa057(0x114),_0x4aa057(0xdf)]);if(_0x52f03a)return _[_0x4aa057(0xcd)](_0x52f03a[_0x4aa057(0xd3)],function(_0x493bf2){const _0x4c8a2f=_0x4aa057;return _0x493bf2[_0x4c8a2f(0xf8)]===![]&&!_0xae579c['includes'](_0x493bf2[_0x4c8a2f(0x11e)]);}),{'count':_0x52f03a['fields'][_0x4aa057(0x108)],'rows':_['map'](_0x52f03a[_0x4aa057(0xd3)],function(_0x4c71b2){const _0x3edb20=_0x4aa057;return{'id':_0x4c71b2[_0x3edb20(0x11e)],'name':_0x4c71b2['label'],'custom':_0x4c71b2['custom'],'options':_0x4c71b2['picklistValues'][_0x3edb20(0x108)]>0x0?_[_0x3edb20(0x120)](_0x4c71b2['picklistValues'],function(_0x472992){const _0x401f9b=_0x3edb20;return{'name':_0x472992[_0x401f9b(0x129)],'value':_0x472992[_0x401f9b(0xdc)]};}):_0x4c71b2[_0x3edb20(0xff)]==_0x3edb20(0xc7)?[{'name':_0x3edb20(0xc9),'value':_0x3edb20(0xf2)},{'name':_0x3edb20(0x10c),'value':_0x3edb20(0xed)}]:[]};})};})[_0x358bab(0xec)](respondWithResult(_0x13318f,null))[_0x358bab(0x12b)](function(_0x48f773){const _0x1eb1ca=_0x358bab;let _0x56c94a=_0x9092a1['query'][_0x1eb1ca(0x110)]?0x1f4:_0x48f773[_0x1eb1ca(0xeb)]||0x1f4;logger['error']('getFields,\x20%s,\x20%s,\x20%s',_0x1eb1ca(0x104),_0x56c94a,JSON['stringify'](_0x48f773)),delete _0x48f773[_0x1eb1ca(0x11e)],_0x56c94a===0x191&&(_0x56c94a=0x190),_0x13318f[_0x1eb1ca(0xd5)](_0x56c94a)[_0x1eb1ca(0x10e)](_0x9092a1[_0x1eb1ca(0x116)][_0x1eb1ca(0x110)]?{'message':_0x1eb1ca(0x126),'statusCode':_0x48f773[_0x1eb1ca(0xeb)]}:_0x48f773);});};
\ No newline at end of file