Built motion from commit (unavailable).|2.5.17
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index 31efe44..89dd4c1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x326f=['filter','map','VIRTUAL','includeAll','include','findAll','rows','show','params','intersection','merge','find','create','body','update','getConfigurations','findOne','SalesforceConfiguration','options','addConfiguration','AccountId','getSubjects','Descriptions','SalesforceField','Subjects','getFields','Task','remoteUri','clientSecret','username','password','securityToken','slice','clientId','login','concat','isNil','ticketType','describe','CallDisposition','CallDurationInSeconds','CallObject','CallType','IsArchived','Status','Type','Case','Origin','Reason','Priority','IsEscalated','SuppliedName','SuppliedCompany','remove','custom','includes','label','picklistValues','value','True','true','False','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','send','Wrong\x20credentials','html-pdf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../mysqldb','jayson/promise','client','Sequelize','request','info','SalesforceAccount,\x20%s,\x20%s','request\x20sent','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','sendStatus','status','end','count','offset','limit','set','Content-Range','json','apply','reject','then','destroy','stack','name','index','SalesforceAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick'];(function(_0x3bd85e,_0x478af4){var _0x1c02e1=function(_0x477889){while(--_0x477889){_0x3bd85e['push'](_0x3bd85e['shift']());}};_0x1c02e1(++_0x478af4);}(_0x326f,0xd1));var _0xf326=function(_0x27f1b0,_0x67bf84){_0x27f1b0=_0x27f1b0-0x0;var _0x3f4e29=_0x326f[_0x27f1b0];return _0x3f4e29;};'use strict';var pdf=require(_0xf326('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf326('0x1'));var jsonpatch=require(_0xf326('0x2'));var rp=require(_0xf326('0x3'));var moment=require(_0xf326('0x4'));var BPromise=require(_0xf326('0x5'));var Mustache=require(_0xf326('0x6'));var util=require(_0xf326('0x7'));var path=require(_0xf326('0x8'));var sox=require(_0xf326('0x9'));var csv=require(_0xf326('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf326('0xb'));var squel=require(_0xf326('0xc'));var crypto=require(_0xf326('0xd'));var jsforce=require(_0xf326('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf326('0xf'));var Redis=require(_0xf326('0x10'));var authService=require(_0xf326('0x11'));var qs=require(_0xf326('0x12'));var as=require(_0xf326('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf326('0x14'))('api');var utils=require(_0xf326('0x15'));var config=require('../../config/environment');var db=require(_0xf326('0x16'))['db'];var integrations=require('../../components/integrations/configuration');var jayson=require(_0xf326('0x17'));var client=jayson[_0xf326('0x18')]['http']({'port':0x232a});function checkPasswordPattern(_0x342fe5,_0x472632,_0x3504eb){if(_0x3504eb){var _0x17a098=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x17a098['test'](_0x472632)){return _0x342fe5;}else{throw new db[(_0xf326('0x19'))]['ValidationError']('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x342fe5;}}function respondWithRpcPromise(_0xdf21d9,_0x11f6d2,_0x1f2e5a,_0xa63d1a){return new BPromise(function(_0x292f4b,_0x287a2a){var _0x34128e=_0xa63d1a||client;return _0x34128e[_0xf326('0x1a')](_0xdf21d9,_0x1f2e5a)['then'](function(_0x3ad7da){logger[_0xf326('0x1b')](_0xf326('0x1c'),_0x11f6d2,_0xf326('0x1d'));logger[_0xf326('0x1e')](_0xf326('0x1f'),_0x11f6d2,'request\x20sent',JSON['stringify'](_0x3ad7da));if(_0x3ad7da['error']){if(_0x3ad7da[_0xf326('0x20')][_0xf326('0x21')]===0x1f4){logger['error']('SalesforceAccount,\x20%s,\x20%s',_0x11f6d2,_0x3ad7da[_0xf326('0x20')]['message']);return _0x287a2a(_0x3ad7da['error'][_0xf326('0x22')]);}logger[_0xf326('0x20')]('SalesforceAccount,\x20%s,\x20%s',_0x11f6d2,_0x3ad7da['error'][_0xf326('0x22')]);return _0x292f4b(_0x3ad7da[_0xf326('0x20')]['message']);}else{logger[_0xf326('0x1b')](_0xf326('0x1c'),_0x11f6d2,_0xf326('0x1d'));_0x292f4b(_0x3ad7da[_0xf326('0x23')][_0xf326('0x22')]);}})[_0xf326('0x24')](function(_0x5ce532){logger['error']('SalesforceAccount,\x20%s,\x20%s',_0x11f6d2,_0x5ce532);_0x287a2a(_0x5ce532);});});}function respondWithStatusCode(_0x520d85,_0x1a2c4e){_0x1a2c4e=_0x1a2c4e||0xcc;return function(_0x2cd45a){if(_0x2cd45a){return _0x520d85[_0xf326('0x25')](_0x1a2c4e);}return _0x520d85[_0xf326('0x26')](_0x1a2c4e)[_0xf326('0x27')]();};}function respondWithResult(_0x5217d4,_0x201d28){_0x201d28=_0x201d28||0xc8;return function(_0xa3c0b){if(_0xa3c0b){return _0x5217d4[_0xf326('0x26')](_0x201d28)['json'](_0xa3c0b);}};}function respondWithFilteredResult(_0x1617d2,_0x55ad0f){return function(_0x4a9abf){if(_0x4a9abf){var _0x6a8e89=_0x4a9abf[_0xf326('0x28')],_0x1ae23a=_0x55ad0f[_0xf326('0x29')],_0x2fa28e=_0x55ad0f['offset']+_0x55ad0f[_0xf326('0x2a')],_0x5dbe63;if(_0x2fa28e>=_0x6a8e89){_0x2fa28e=_0x6a8e89;_0x5dbe63=0xc8;}else{_0x5dbe63=0xce;}_0x1617d2[_0xf326('0x26')](_0x5dbe63);return _0x1617d2[_0xf326('0x2b')](_0xf326('0x2c'),_0x1ae23a+'-'+_0x2fa28e+'/'+_0x6a8e89)[_0xf326('0x2d')](_0x4a9abf);}return null;};}function patchUpdates(_0x269be9){return function(_0x161143){try{jsonpatch[_0xf326('0x2e')](_0x161143,_0x269be9,!![]);}catch(_0x43b951){return BPromise[_0xf326('0x2f')](_0x43b951);}return _0x161143['save']();};}function saveUpdates(_0x1035ed,_0x424104){return function(_0x21b23d){if(_0x21b23d){return _0x21b23d['update'](_0x1035ed)[_0xf326('0x30')](function(_0x1721fd){return _0x1721fd;});}return null;};}function removeEntity(_0x303dc6,_0x4df451){return function(_0x5b101d){if(_0x5b101d){return _0x5b101d[_0xf326('0x31')]()[_0xf326('0x30')](function(){_0x303dc6[_0xf326('0x26')](0xcc)[_0xf326('0x27')]();});}};}function handleEntityNotFound(_0x30694f,_0x2e8a64){return function(_0x62585a){if(!_0x62585a){_0x30694f[_0xf326('0x25')](0x194);}return _0x62585a;};}function handleError(_0x580374,_0x461e93){_0x461e93=_0x461e93||0x1f4;return function(_0x1981bc){logger['error'](_0x1981bc[_0xf326('0x32')]);if(_0x1981bc['name']){delete _0x1981bc[_0xf326('0x33')];}_0x580374['status'](_0x461e93)['send'](_0x1981bc);};}exports[_0xf326('0x34')]=function(_0x4d8eac,_0x40dcb4){var _0x57aa27={},_0x310dbb={},_0x409260={'count':0x0,'rows':[]};var _0x2750ae=_['map'](db[_0xf326('0x35')][_0xf326('0x36')],function(_0x48525a){return{'name':_0x48525a[_0xf326('0x37')],'type':_0x48525a[_0xf326('0x38')][_0xf326('0x39')]};});_0x310dbb[_0xf326('0x3a')]=_['map'](_0x2750ae,_0xf326('0x33'));_0x310dbb[_0xf326('0x3b')]=_[_0xf326('0x3c')](_0x4d8eac[_0xf326('0x3b')]);_0x310dbb[_0xf326('0x3d')]=_['intersection'](_0x310dbb[_0xf326('0x3a')],_0x310dbb[_0xf326('0x3b')]);_0x57aa27['attributes']=_['intersection'](_0x310dbb[_0xf326('0x3a')],qs['fields'](_0x4d8eac['query'][_0xf326('0x3e')]));_0x57aa27['attributes']=_0x57aa27[_0xf326('0x3f')][_0xf326('0x40')]?_0x57aa27[_0xf326('0x3f')]:_0x310dbb[_0xf326('0x3a')];if(!_0x4d8eac['query'][_0xf326('0x41')](_0xf326('0x42'))){_0x57aa27[_0xf326('0x2a')]=qs[_0xf326('0x2a')](_0x4d8eac[_0xf326('0x3b')][_0xf326('0x2a')]);_0x57aa27[_0xf326('0x29')]=qs[_0xf326('0x29')](_0x4d8eac[_0xf326('0x3b')][_0xf326('0x29')]);}_0x57aa27[_0xf326('0x43')]=qs[_0xf326('0x44')](_0x4d8eac['query'][_0xf326('0x44')]);_0x57aa27[_0xf326('0x45')]=qs[_0xf326('0x3d')](_[_0xf326('0x46')](_0x4d8eac[_0xf326('0x3b')],_0x310dbb[_0xf326('0x3d')]));if(_0x4d8eac['query'][_0xf326('0x47')]){_0x57aa27[_0xf326('0x45')]=_['merge'](_0x57aa27[_0xf326('0x45')],{'$or':_[_0xf326('0x48')](_0x2750ae,function(_0x130c56){if(_0x130c56[_0xf326('0x38')]!==_0xf326('0x49')){var _0x55361f={};_0x55361f[_0x130c56['name']]={'$like':'%'+_0x4d8eac[_0xf326('0x3b')][_0xf326('0x47')]+'%'};return _0x55361f;}})});}_0x57aa27=_['merge']({},_0x57aa27,_0x4d8eac['options']);var _0x8e318d={'where':_0x57aa27[_0xf326('0x45')]};return db[_0xf326('0x35')]['count'](_0x8e318d)[_0xf326('0x30')](function(_0xe96e1e){_0x409260[_0xf326('0x28')]=_0xe96e1e;if(_0x4d8eac[_0xf326('0x3b')][_0xf326('0x4a')]){_0x57aa27[_0xf326('0x4b')]=[{'all':!![]}];}return db[_0xf326('0x35')][_0xf326('0x4c')](_0x57aa27);})[_0xf326('0x30')](function(_0x27ced1){_0x409260[_0xf326('0x4d')]=_0x27ced1;return _0x409260;})[_0xf326('0x30')](respondWithFilteredResult(_0x40dcb4,_0x57aa27))[_0xf326('0x24')](handleError(_0x40dcb4,null));};exports[_0xf326('0x4e')]=function(_0xeac1a1,_0x59f9a7){var _0x199f8b={'raw':![],'where':{'id':_0xeac1a1[_0xf326('0x4f')]['id']}},_0x1b0e03={};_0x1b0e03[_0xf326('0x3a')]=_['keys'](db[_0xf326('0x35')][_0xf326('0x36')]);_0x1b0e03[_0xf326('0x3b')]=_[_0xf326('0x3c')](_0xeac1a1['query']);_0x1b0e03[_0xf326('0x3d')]=_[_0xf326('0x50')](_0x1b0e03[_0xf326('0x3a')],_0x1b0e03[_0xf326('0x3b')]);_0x199f8b[_0xf326('0x3f')]=_['intersection'](_0x1b0e03['model'],qs[_0xf326('0x3e')](_0xeac1a1[_0xf326('0x3b')][_0xf326('0x3e')]));_0x199f8b['attributes']=_0x199f8b[_0xf326('0x3f')][_0xf326('0x40')]?_0x199f8b[_0xf326('0x3f')]:_0x1b0e03['model'];if(_0xeac1a1['query'][_0xf326('0x4a')]){_0x199f8b['include']=[{'all':!![]}];}_0x199f8b=_[_0xf326('0x51')]({},_0x199f8b,_0xeac1a1['options']);return db[_0xf326('0x35')][_0xf326('0x52')](_0x199f8b)[_0xf326('0x30')](handleEntityNotFound(_0x59f9a7,null))[_0xf326('0x30')](respondWithResult(_0x59f9a7,null))[_0xf326('0x24')](handleError(_0x59f9a7,null));};exports[_0xf326('0x53')]=function(_0x7f7ece,_0x495a16){return db[_0xf326('0x35')][_0xf326('0x53')](_0x7f7ece[_0xf326('0x54')],{})['then'](respondWithResult(_0x495a16,0xc9))[_0xf326('0x24')](handleError(_0x495a16,null));};exports[_0xf326('0x55')]=function(_0x3b8635,_0x16c578){if(_0x3b8635[_0xf326('0x54')]['id']){delete _0x3b8635['body']['id'];}return db[_0xf326('0x35')][_0xf326('0x52')]({'where':{'id':_0x3b8635[_0xf326('0x4f')]['id']}})[_0xf326('0x30')](handleEntityNotFound(_0x16c578,null))['then'](saveUpdates(_0x3b8635[_0xf326('0x54')],null))[_0xf326('0x30')](respondWithResult(_0x16c578,null))[_0xf326('0x24')](handleError(_0x16c578,null));};exports[_0xf326('0x31')]=function(_0x4d3b9e,_0x5be2b1){return db[_0xf326('0x35')][_0xf326('0x52')]({'where':{'id':_0x4d3b9e['params']['id']}})[_0xf326('0x30')](handleEntityNotFound(_0x5be2b1,null))[_0xf326('0x30')](removeEntity(_0x5be2b1,null))[_0xf326('0x24')](handleError(_0x5be2b1,null));};exports[_0xf326('0x56')]=function(_0x5765b0,_0xb1c18c,_0x5657b7){var _0x5dbeb9={};var _0x9d84c3={};var _0x51d466;var _0x173760;return db[_0xf326('0x35')][_0xf326('0x57')]({'where':{'id':_0x5765b0['params']['id']}})['then'](handleEntityNotFound(_0xb1c18c,null))[_0xf326('0x30')](function(_0xa85a42){if(_0xa85a42){_0x51d466=_0xa85a42;_0x9d84c3[_0xf326('0x3a')]=_['keys'](db[_0xf326('0x58')]['rawAttributes']);_0x9d84c3[_0xf326('0x3b')]=_[_0xf326('0x3c')](_0x5765b0[_0xf326('0x3b')]);_0x9d84c3[_0xf326('0x3d')]=_[_0xf326('0x50')](_0x9d84c3[_0xf326('0x3a')],_0x9d84c3[_0xf326('0x3b')]);_0x5dbeb9[_0xf326('0x3f')]=_[_0xf326('0x50')](_0x9d84c3[_0xf326('0x3a')],qs[_0xf326('0x3e')](_0x5765b0[_0xf326('0x3b')][_0xf326('0x3e')]));_0x5dbeb9['attributes']=_0x5dbeb9[_0xf326('0x3f')]['length']?_0x5dbeb9[_0xf326('0x3f')]:_0x9d84c3[_0xf326('0x3a')];_0x5dbeb9['order']=qs[_0xf326('0x44')](_0x5765b0['query'][_0xf326('0x44')]);_0x5dbeb9[_0xf326('0x45')]=qs[_0xf326('0x3d')](_[_0xf326('0x46')](_0x5765b0[_0xf326('0x3b')],_0x9d84c3['filters']));if(_0x5765b0['query'][_0xf326('0x47')]){_0x5dbeb9[_0xf326('0x45')]=_[_0xf326('0x51')](_0x5dbeb9[_0xf326('0x45')],{'$or':_[_0xf326('0x48')](_0x5dbeb9['attributes'],function(_0x28c4f2){var _0x471da8={};_0x471da8[_0x28c4f2]={'$like':'%'+_0x5765b0['query']['filter']+'%'};return _0x471da8;})});}_0x5dbeb9=_['merge']({},_0x5dbeb9,_0x5765b0[_0xf326('0x59')]);return _0x51d466[_0xf326('0x56')](_0x5dbeb9);}})[_0xf326('0x30')](function(_0x235525){if(_0x235525){_0x173760=_0x235525[_0xf326('0x40')];if(!_0x5765b0[_0xf326('0x3b')][_0xf326('0x41')]('nolimit')){_0x5dbeb9[_0xf326('0x2a')]=qs[_0xf326('0x2a')](_0x5765b0[_0xf326('0x3b')][_0xf326('0x2a')]);_0x5dbeb9['offset']=qs[_0xf326('0x29')](_0x5765b0['query']['offset']);}return _0x51d466[_0xf326('0x56')](_0x5dbeb9);}})['then'](function(_0x78ba34){if(_0x78ba34){return _0x78ba34?{'count':_0x173760,'rows':_0x78ba34}:null;}})[_0xf326('0x30')](respondWithResult(_0xb1c18c,null))[_0xf326('0x24')](handleError(_0xb1c18c,null));};exports[_0xf326('0x5a')]=function(_0x17cd36,_0x541491,_0x4a053c){if(_0x17cd36['body']['id']){delete _0x17cd36[_0xf326('0x54')]['id'];}return db[_0xf326('0x35')][_0xf326('0x57')]({'where':{'id':_0x17cd36[_0xf326('0x4f')]['id']}})[_0xf326('0x30')](handleEntityNotFound(_0x541491,null))['then'](function(_0x1ed961){if(_0x1ed961){_0x17cd36[_0xf326('0x54')][_0xf326('0x5b')]=_0x1ed961['id'];_0x17cd36['body']['Subjects']=integrations[_0xf326('0x5c')](_0x17cd36[_0xf326('0x54')]['channel'],_0x17cd36['body'][_0xf326('0x38')]);_0x17cd36['body'][_0xf326('0x5d')]=integrations['getDescriptions'](_0x17cd36['body']['channel'],_0x17cd36[_0xf326('0x54')][_0xf326('0x38')]);return db[_0xf326('0x58')]['create'](_0x17cd36[_0xf326('0x54')],{'include':[{'model':db[_0xf326('0x5e')],'as':_0xf326('0x5f')},{'model':db[_0xf326('0x5e')],'as':_0xf326('0x5d')}]});}return null;})[_0xf326('0x30')](respondWithResult(_0x541491,null))[_0xf326('0x24')](handleError(_0x541491,null));};exports[_0xf326('0x60')]=function(_0x3855a4,_0x5290da,_0x34c3cf){var _0x5b1494;var _0x2c81a7='';var _0x366312=_0xf326('0x61');return db['SalesforceAccount'][_0xf326('0x57')]({'where':{'id':_0x3855a4[_0xf326('0x4f')]['id']},'attributes':['id',_0xf326('0x62'),'clientId',_0xf326('0x63'),_0xf326('0x64'),_0xf326('0x65'),_0xf326('0x66')]})['then'](handleEntityNotFound(_0x5290da,null))[_0xf326('0x30')](function(_0x5c9900){if(_0x5c9900){_0x2c81a7=_0x5c9900['remoteUri'];var _0x32d9c5=_0x2c81a7[_0xf326('0x67')](-0x1);if(_0x32d9c5==='/'){_0x2c81a7=_0x2c81a7['substring'](0x0,_0x2c81a7['lastIndexOf'](_0x32d9c5));}_0x5b1494=new jsforce['Connection']({'oauth2':{'loginUrl':_0x2c81a7,'clientId':_0x5c9900[_0xf326('0x68')],'clientSecret':_0x5c9900['clientSecret']}});return _0x5b1494[_0xf326('0x69')](_0x5c9900[_0xf326('0x64')],_0x5c9900[_0xf326('0x65')][_0xf326('0x6a')](_0x5c9900[_0xf326('0x66')]));}})[_0xf326('0x30')](function(_0x5d23f0){if(_0x5d23f0){if(!_[_0xf326('0x6b')](_0x3855a4[_0xf326('0x3b')]['ticketType'])){_0x366312=_0x3855a4['query'][_0xf326('0x6c')];}return _0x5b1494['sobject'](_0x366312)[_0xf326('0x6d')]();}})[_0xf326('0x30')](function(_0x153027){var _0x363e64=[_0xf326('0x6e'),_0xf326('0x6f'),_0xf326('0x70'),_0xf326('0x71'),_0xf326('0x72'),'Priority',_0xf326('0x73'),_0xf326('0x74')];if(!_['isNil'](_0x3855a4[_0xf326('0x3b')]['ticketType'])&&_0x3855a4[_0xf326('0x3b')][_0xf326('0x6c')]===_0xf326('0x75')){_0x363e64=['Type',_0xf326('0x76'),_0xf326('0x77'),_0xf326('0x73'),_0xf326('0x78'),_0xf326('0x79'),_0xf326('0x7a'),_0xf326('0x7b')];}if(_0x153027){_[_0xf326('0x7c')](_0x153027[_0xf326('0x3e')],function(_0x38b696){return _0x38b696[_0xf326('0x7d')]===![]&&!_0x363e64[_0xf326('0x7e')](_0x38b696[_0xf326('0x33')]);});return{'count':_0x153027[_0xf326('0x3e')][_0xf326('0x40')],'rows':_['map'](_0x153027[_0xf326('0x3e')],function(_0x24aaca){return{'id':_0x24aaca['name'],'name':_0x24aaca[_0xf326('0x7f')],'custom':_0x24aaca[_0xf326('0x7d')],'options':_0x24aaca['picklistValues'][_0xf326('0x40')]>0x0?_[_0xf326('0x48')](_0x24aaca[_0xf326('0x80')],function(_0x8dbd96){return{'name':_0x8dbd96[_0xf326('0x7f')],'value':_0x8dbd96[_0xf326('0x81')]};}):_0x24aaca[_0xf326('0x38')]=='boolean'?[{'name':_0xf326('0x82'),'value':_0xf326('0x83')},{'name':_0xf326('0x84'),'value':_0xf326('0x85')}]:[]};})};}})[_0xf326('0x30')](respondWithResult(_0x5290da,null))[_0xf326('0x24')](function(_0x204002){var _0x3b250d=_0x3855a4['query'][_0xf326('0x86')]?0x1f4:_0x204002[_0xf326('0x87')]||0x1f4;logger['error'](_0xf326('0x88'),'getFields',_0x3b250d,JSON[_0xf326('0x89')](_0x204002));delete _0x204002[_0xf326('0x33')];if(_0x3b250d===0x191){_0x3b250d=0x190;}_0x5290da[_0xf326('0x26')](_0x3b250d)[_0xf326('0x8a')](_0x3855a4[_0xf326('0x3b')][_0xf326('0x86')]?{'message':_0xf326('0x8b'),'statusCode':_0x204002[_0xf326('0x87')]}:_0x204002);});};
\ No newline at end of file
+var _0xab40=['VIRTUAL','merge','options','SalesforceAccount','count','includeAll','include','findAll','rows','show','params','rawAttributes','find','catch','body','update','getConfigurations','findOne','SalesforceConfiguration','addConfiguration','AccountId','Subjects','getSubjects','Descriptions','getDescriptions','create','SalesforceField','getFields','Task','remoteUri','clientSecret','securityToken','slice','Connection','clientId','username','password','ticketType','describe','CallDisposition','CallDurationInSeconds','CallObject','CallType','IsArchived','Priority','Type','isNil','Case','Origin','Reason','Status','IsEscalated','SuppliedName','SuppliedCompany','remove','custom','includes','label','picklistValues','value','True','true','False','false','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','html-pdf','eml-format','request-promise','moment','bluebird','mustache','util','to-csv','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../components/integrations/configuration','jayson/promise','client','http','request','then','info','SalesforceAccount,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','sendStatus','status','end','json','limit','set','Content-Range','reject','save','destroy','stack','send','index','fieldName','type','key','model','map','name','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','offset','order','sort','where','pick','filters','filter'];(function(_0x56e12b,_0x5beada){var _0x5f5030=function(_0x1e7eb6){while(--_0x1e7eb6){_0x56e12b['push'](_0x56e12b['shift']());}};_0x5f5030(++_0x5beada);}(_0xab40,0xcd));var _0x0ab4=function(_0x3f7016,_0x3c70d3){_0x3f7016=_0x3f7016-0x0;var _0x39040b=_0xab40[_0x3f7016];return _0x39040b;};'use strict';var pdf=require(_0x0ab4('0x0'));var emlformat=require(_0x0ab4('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0ab4('0x2'));var moment=require(_0x0ab4('0x3'));var BPromise=require(_0x0ab4('0x4'));var Mustache=require(_0x0ab4('0x5'));var util=require(_0x0ab4('0x6'));var path=require('path');var sox=require('sox');var csv=require(_0x0ab4('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x0ab4('0x8'));var squel=require(_0x0ab4('0x9'));var crypto=require(_0x0ab4('0xa'));var jsforce=require(_0x0ab4('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x0ab4('0xc'));var Redis=require(_0x0ab4('0xd'));var authService=require(_0x0ab4('0xe'));var qs=require(_0x0ab4('0xf'));var as=require(_0x0ab4('0x10'));var hardwareService=require(_0x0ab4('0x11'));var logger=require(_0x0ab4('0x12'))(_0x0ab4('0x13'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x0ab4('0x14'));var db=require('../../mysqldb')['db'];var integrations=require(_0x0ab4('0x15'));var jayson=require(_0x0ab4('0x16'));var client=jayson[_0x0ab4('0x17')][_0x0ab4('0x18')]({'port':0x232a});function respondWithRpcPromise(_0x26ce0d,_0x329104,_0x112162,_0x2cc644){return new BPromise(function(_0x3cb1df,_0x2033c8){var _0x216a17=_0x2cc644||client;return _0x216a17[_0x0ab4('0x19')](_0x26ce0d,_0x112162)[_0x0ab4('0x1a')](function(_0x45fad1){logger[_0x0ab4('0x1b')](_0x0ab4('0x1c'),_0x329104,_0x0ab4('0x1d'));logger[_0x0ab4('0x1e')]('SalesforceAccount,\x20%s,\x20%s,\x20%s',_0x329104,'request\x20sent',JSON['stringify'](_0x45fad1));if(_0x45fad1[_0x0ab4('0x1f')]){if(_0x45fad1[_0x0ab4('0x1f')][_0x0ab4('0x20')]===0x1f4){logger['error'](_0x0ab4('0x1c'),_0x329104,_0x45fad1[_0x0ab4('0x1f')][_0x0ab4('0x21')]);return _0x2033c8(_0x45fad1[_0x0ab4('0x1f')]['message']);}logger['error'](_0x0ab4('0x1c'),_0x329104,_0x45fad1['error'][_0x0ab4('0x21')]);return _0x3cb1df(_0x45fad1[_0x0ab4('0x1f')]['message']);}else{logger[_0x0ab4('0x1b')](_0x0ab4('0x1c'),_0x329104,_0x0ab4('0x1d'));_0x3cb1df(_0x45fad1[_0x0ab4('0x22')][_0x0ab4('0x21')]);}})['catch'](function(_0x58d9ce){logger[_0x0ab4('0x1f')](_0x0ab4('0x1c'),_0x329104,_0x58d9ce);_0x2033c8(_0x58d9ce);});});}function respondWithStatusCode(_0x392afe,_0x13c882){_0x13c882=_0x13c882||0xcc;return function(_0x4e4b80){if(_0x4e4b80){return _0x392afe[_0x0ab4('0x23')](_0x13c882);}return _0x392afe[_0x0ab4('0x24')](_0x13c882)[_0x0ab4('0x25')]();};}function respondWithResult(_0x4ea9aa,_0x4c5caf){_0x4c5caf=_0x4c5caf||0xc8;return function(_0x176ff1){if(_0x176ff1){return _0x4ea9aa[_0x0ab4('0x24')](_0x4c5caf)[_0x0ab4('0x26')](_0x176ff1);}};}function respondWithFilteredResult(_0x4ae515,_0x519b23){return function(_0x49c72d){if(_0x49c72d){var _0x19ecc6=_0x49c72d['count'],_0x5ba3a2=_0x519b23['offset'],_0x3bf844=_0x519b23['offset']+_0x519b23[_0x0ab4('0x27')],_0x3b4621;if(_0x3bf844>=_0x19ecc6){_0x3bf844=_0x19ecc6;_0x3b4621=0xc8;}else{_0x3b4621=0xce;}_0x4ae515[_0x0ab4('0x24')](_0x3b4621);return _0x4ae515[_0x0ab4('0x28')](_0x0ab4('0x29'),_0x5ba3a2+'-'+_0x3bf844+'/'+_0x19ecc6)[_0x0ab4('0x26')](_0x49c72d);}return null;};}function patchUpdates(_0x588e0d){return function(_0x5b55c1){try{jsonpatch['apply'](_0x5b55c1,_0x588e0d,!![]);}catch(_0x2e7a97){return BPromise[_0x0ab4('0x2a')](_0x2e7a97);}return _0x5b55c1[_0x0ab4('0x2b')]();};}function saveUpdates(_0x182bbe,_0x46eda7){return function(_0x5a1364){if(_0x5a1364){return _0x5a1364['update'](_0x182bbe)[_0x0ab4('0x1a')](function(_0xe6682){return _0xe6682;});}return null;};}function removeEntity(_0x361f7c,_0x4819be){return function(_0x48e430){if(_0x48e430){return _0x48e430[_0x0ab4('0x2c')]()['then'](function(){_0x361f7c[_0x0ab4('0x24')](0xcc)[_0x0ab4('0x25')]();});}};}function handleEntityNotFound(_0x263e5a,_0x1ab60f){return function(_0x36841e){if(!_0x36841e){_0x263e5a[_0x0ab4('0x23')](0x194);}return _0x36841e;};}function handleError(_0x5bcf75,_0x133311){_0x133311=_0x133311||0x1f4;return function(_0x4696fc){logger[_0x0ab4('0x1f')](_0x4696fc[_0x0ab4('0x2d')]);if(_0x4696fc['name']){delete _0x4696fc['name'];}_0x5bcf75[_0x0ab4('0x24')](_0x133311)[_0x0ab4('0x2e')](_0x4696fc);};}exports[_0x0ab4('0x2f')]=function(_0x4fca1b,_0x507d77){var _0x4cd319={},_0x1c234e={},_0x35eab3={'count':0x0,'rows':[]};var _0x2354a0=_['map'](db['SalesforceAccount']['rawAttributes'],function(_0x1951d8){return{'name':_0x1951d8[_0x0ab4('0x30')],'type':_0x1951d8[_0x0ab4('0x31')][_0x0ab4('0x32')]};});_0x1c234e[_0x0ab4('0x33')]=_[_0x0ab4('0x34')](_0x2354a0,_0x0ab4('0x35'));_0x1c234e[_0x0ab4('0x36')]=_[_0x0ab4('0x37')](_0x4fca1b[_0x0ab4('0x36')]);_0x1c234e['filters']=_[_0x0ab4('0x38')](_0x1c234e[_0x0ab4('0x33')],_0x1c234e[_0x0ab4('0x36')]);_0x4cd319[_0x0ab4('0x39')]=_[_0x0ab4('0x38')](_0x1c234e[_0x0ab4('0x33')],qs[_0x0ab4('0x3a')](_0x4fca1b[_0x0ab4('0x36')][_0x0ab4('0x3a')]));_0x4cd319[_0x0ab4('0x39')]=_0x4cd319[_0x0ab4('0x39')][_0x0ab4('0x3b')]?_0x4cd319['attributes']:_0x1c234e[_0x0ab4('0x33')];if(!_0x4fca1b[_0x0ab4('0x36')][_0x0ab4('0x3c')](_0x0ab4('0x3d'))){_0x4cd319['limit']=qs[_0x0ab4('0x27')](_0x4fca1b['query'][_0x0ab4('0x27')]);_0x4cd319[_0x0ab4('0x3e')]=qs[_0x0ab4('0x3e')](_0x4fca1b[_0x0ab4('0x36')][_0x0ab4('0x3e')]);}_0x4cd319[_0x0ab4('0x3f')]=qs['sort'](_0x4fca1b[_0x0ab4('0x36')][_0x0ab4('0x40')]);_0x4cd319[_0x0ab4('0x41')]=qs['filters'](_[_0x0ab4('0x42')](_0x4fca1b[_0x0ab4('0x36')],_0x1c234e[_0x0ab4('0x43')]),_0x2354a0);if(_0x4fca1b[_0x0ab4('0x36')][_0x0ab4('0x44')]){_0x4cd319['where']=_['merge'](_0x4cd319['where'],{'$or':_[_0x0ab4('0x34')](_0x2354a0,function(_0x2e87e4){if(_0x2e87e4['type']!==_0x0ab4('0x45')){var _0x4c349e={};_0x4c349e[_0x2e87e4[_0x0ab4('0x35')]]={'$like':'%'+_0x4fca1b['query'][_0x0ab4('0x44')]+'%'};return _0x4c349e;}})});}_0x4cd319=_[_0x0ab4('0x46')]({},_0x4cd319,_0x4fca1b[_0x0ab4('0x47')]);var _0x188eb7={'where':_0x4cd319[_0x0ab4('0x41')]};return db[_0x0ab4('0x48')]['count'](_0x188eb7)[_0x0ab4('0x1a')](function(_0xfb61b8){_0x35eab3[_0x0ab4('0x49')]=_0xfb61b8;if(_0x4fca1b[_0x0ab4('0x36')][_0x0ab4('0x4a')]){_0x4cd319[_0x0ab4('0x4b')]=[{'all':!![]}];}return db['SalesforceAccount'][_0x0ab4('0x4c')](_0x4cd319);})['then'](function(_0x2103d7){_0x35eab3[_0x0ab4('0x4d')]=_0x2103d7;return _0x35eab3;})[_0x0ab4('0x1a')](respondWithFilteredResult(_0x507d77,_0x4cd319))['catch'](handleError(_0x507d77,null));};exports[_0x0ab4('0x4e')]=function(_0x1fcc3b,_0x1ce096){var _0x3c1247={'raw':![],'where':{'id':_0x1fcc3b[_0x0ab4('0x4f')]['id']}},_0x14179f={};_0x14179f['model']=_[_0x0ab4('0x37')](db[_0x0ab4('0x48')][_0x0ab4('0x50')]);_0x14179f[_0x0ab4('0x36')]=_[_0x0ab4('0x37')](_0x1fcc3b[_0x0ab4('0x36')]);_0x14179f[_0x0ab4('0x43')]=_[_0x0ab4('0x38')](_0x14179f[_0x0ab4('0x33')],_0x14179f[_0x0ab4('0x36')]);_0x3c1247[_0x0ab4('0x39')]=_[_0x0ab4('0x38')](_0x14179f[_0x0ab4('0x33')],qs['fields'](_0x1fcc3b[_0x0ab4('0x36')][_0x0ab4('0x3a')]));_0x3c1247['attributes']=_0x3c1247[_0x0ab4('0x39')]['length']?_0x3c1247['attributes']:_0x14179f[_0x0ab4('0x33')];if(_0x1fcc3b[_0x0ab4('0x36')][_0x0ab4('0x4a')]){_0x3c1247['include']=[{'all':!![]}];}_0x3c1247=_[_0x0ab4('0x46')]({},_0x3c1247,_0x1fcc3b[_0x0ab4('0x47')]);return db[_0x0ab4('0x48')][_0x0ab4('0x51')](_0x3c1247)[_0x0ab4('0x1a')](handleEntityNotFound(_0x1ce096,null))[_0x0ab4('0x1a')](respondWithResult(_0x1ce096,null))[_0x0ab4('0x52')](handleError(_0x1ce096,null));};exports['create']=function(_0x20fd66,_0x59d3f1){return db[_0x0ab4('0x48')]['create'](_0x20fd66[_0x0ab4('0x53')],{})['then'](respondWithResult(_0x59d3f1,0xc9))['catch'](handleError(_0x59d3f1,null));};exports[_0x0ab4('0x54')]=function(_0x257a2b,_0x433346){if(_0x257a2b[_0x0ab4('0x53')]['id']){delete _0x257a2b['body']['id'];}return db[_0x0ab4('0x48')][_0x0ab4('0x51')]({'where':{'id':_0x257a2b[_0x0ab4('0x4f')]['id']}})[_0x0ab4('0x1a')](handleEntityNotFound(_0x433346,null))[_0x0ab4('0x1a')](saveUpdates(_0x257a2b[_0x0ab4('0x53')],null))[_0x0ab4('0x1a')](respondWithResult(_0x433346,null))[_0x0ab4('0x52')](handleError(_0x433346,null));};exports[_0x0ab4('0x2c')]=function(_0x1bf892,_0xe5bce8){return db[_0x0ab4('0x48')][_0x0ab4('0x51')]({'where':{'id':_0x1bf892[_0x0ab4('0x4f')]['id']}})[_0x0ab4('0x1a')](handleEntityNotFound(_0xe5bce8,null))[_0x0ab4('0x1a')](removeEntity(_0xe5bce8,null))[_0x0ab4('0x52')](handleError(_0xe5bce8,null));};exports[_0x0ab4('0x55')]=function(_0x41f85b,_0x59705f,_0x27d7c4){var _0x1e30fe={};var _0x3eba1e={};var _0x308f7a;var _0x32e38c;return db[_0x0ab4('0x48')][_0x0ab4('0x56')]({'where':{'id':_0x41f85b[_0x0ab4('0x4f')]['id']}})['then'](handleEntityNotFound(_0x59705f,null))[_0x0ab4('0x1a')](function(_0x339ebd){if(_0x339ebd){_0x308f7a=_0x339ebd;_0x3eba1e['model']=_['keys'](db[_0x0ab4('0x57')][_0x0ab4('0x50')]);_0x3eba1e['query']=_['keys'](_0x41f85b[_0x0ab4('0x36')]);_0x3eba1e['filters']=_['intersection'](_0x3eba1e[_0x0ab4('0x33')],_0x3eba1e[_0x0ab4('0x36')]);_0x1e30fe[_0x0ab4('0x39')]=_[_0x0ab4('0x38')](_0x3eba1e[_0x0ab4('0x33')],qs[_0x0ab4('0x3a')](_0x41f85b[_0x0ab4('0x36')]['fields']));_0x1e30fe[_0x0ab4('0x39')]=_0x1e30fe[_0x0ab4('0x39')][_0x0ab4('0x3b')]?_0x1e30fe[_0x0ab4('0x39')]:_0x3eba1e[_0x0ab4('0x33')];_0x1e30fe[_0x0ab4('0x3f')]=qs['sort'](_0x41f85b[_0x0ab4('0x36')][_0x0ab4('0x40')]);_0x1e30fe['where']=qs[_0x0ab4('0x43')](_['pick'](_0x41f85b[_0x0ab4('0x36')],_0x3eba1e['filters']));if(_0x41f85b[_0x0ab4('0x36')][_0x0ab4('0x44')]){_0x1e30fe[_0x0ab4('0x41')]=_[_0x0ab4('0x46')](_0x1e30fe['where'],{'$or':_['map'](_0x1e30fe[_0x0ab4('0x39')],function(_0x4477ba){var _0x559b1f={};_0x559b1f[_0x4477ba]={'$like':'%'+_0x41f85b[_0x0ab4('0x36')][_0x0ab4('0x44')]+'%'};return _0x559b1f;})});}_0x1e30fe=_[_0x0ab4('0x46')]({},_0x1e30fe,_0x41f85b['options']);return _0x308f7a[_0x0ab4('0x55')](_0x1e30fe);}})[_0x0ab4('0x1a')](function(_0x2c16cf){if(_0x2c16cf){_0x32e38c=_0x2c16cf[_0x0ab4('0x3b')];if(!_0x41f85b[_0x0ab4('0x36')][_0x0ab4('0x3c')](_0x0ab4('0x3d'))){_0x1e30fe[_0x0ab4('0x27')]=qs['limit'](_0x41f85b['query'][_0x0ab4('0x27')]);_0x1e30fe[_0x0ab4('0x3e')]=qs[_0x0ab4('0x3e')](_0x41f85b[_0x0ab4('0x36')]['offset']);}return _0x308f7a[_0x0ab4('0x55')](_0x1e30fe);}})['then'](function(_0x16197f){if(_0x16197f){return _0x16197f?{'count':_0x32e38c,'rows':_0x16197f}:null;}})[_0x0ab4('0x1a')](respondWithResult(_0x59705f,null))[_0x0ab4('0x52')](handleError(_0x59705f,null));};exports[_0x0ab4('0x58')]=function(_0x340129,_0x41b65f,_0x46a008){if(_0x340129[_0x0ab4('0x53')]['id']){delete _0x340129[_0x0ab4('0x53')]['id'];}return db['SalesforceAccount'][_0x0ab4('0x56')]({'where':{'id':_0x340129['params']['id']}})[_0x0ab4('0x1a')](handleEntityNotFound(_0x41b65f,null))[_0x0ab4('0x1a')](function(_0x3a0e36){if(_0x3a0e36){_0x340129[_0x0ab4('0x53')][_0x0ab4('0x59')]=_0x3a0e36['id'];_0x340129[_0x0ab4('0x53')][_0x0ab4('0x5a')]=integrations[_0x0ab4('0x5b')](_0x340129[_0x0ab4('0x53')]['channel'],_0x340129[_0x0ab4('0x53')][_0x0ab4('0x31')]);_0x340129['body'][_0x0ab4('0x5c')]=integrations[_0x0ab4('0x5d')](_0x340129[_0x0ab4('0x53')]['channel'],_0x340129[_0x0ab4('0x53')][_0x0ab4('0x31')]);return db[_0x0ab4('0x57')][_0x0ab4('0x5e')](_0x340129['body'],{'include':[{'model':db['SalesforceField'],'as':_0x0ab4('0x5a')},{'model':db[_0x0ab4('0x5f')],'as':_0x0ab4('0x5c')}]});}return null;})[_0x0ab4('0x1a')](respondWithResult(_0x41b65f,null))['catch'](handleError(_0x41b65f,null));};exports[_0x0ab4('0x60')]=function(_0xa0f095,_0x5281da,_0x55c921){var _0x5c8d42;var _0x10852d='';var _0x2d2dbb=_0x0ab4('0x61');return db[_0x0ab4('0x48')][_0x0ab4('0x56')]({'where':{'id':_0xa0f095[_0x0ab4('0x4f')]['id']},'attributes':['id',_0x0ab4('0x62'),'clientId',_0x0ab4('0x63'),'username','password',_0x0ab4('0x64')]})['then'](handleEntityNotFound(_0x5281da,null))[_0x0ab4('0x1a')](function(_0x40d18f){if(_0x40d18f){_0x10852d=_0x40d18f[_0x0ab4('0x62')];var _0x368573=_0x10852d[_0x0ab4('0x65')](-0x1);if(_0x368573==='/'){_0x10852d=_0x10852d['substring'](0x0,_0x10852d['lastIndexOf'](_0x368573));}_0x5c8d42=new jsforce[(_0x0ab4('0x66'))]({'oauth2':{'loginUrl':_0x10852d,'clientId':_0x40d18f[_0x0ab4('0x67')],'clientSecret':_0x40d18f['clientSecret']}});return _0x5c8d42['login'](_0x40d18f[_0x0ab4('0x68')],_0x40d18f[_0x0ab4('0x69')]['concat'](_0x40d18f[_0x0ab4('0x64')]));}})[_0x0ab4('0x1a')](function(_0x1aef6c){if(_0x1aef6c){if(!_['isNil'](_0xa0f095[_0x0ab4('0x36')][_0x0ab4('0x6a')])){_0x2d2dbb=_0xa0f095[_0x0ab4('0x36')][_0x0ab4('0x6a')];}return _0x5c8d42['sobject'](_0x2d2dbb)[_0x0ab4('0x6b')]();}})[_0x0ab4('0x1a')](function(_0x338075){var _0x2eefbf=[_0x0ab4('0x6c'),_0x0ab4('0x6d'),_0x0ab4('0x6e'),_0x0ab4('0x6f'),_0x0ab4('0x70'),_0x0ab4('0x71'),'Status',_0x0ab4('0x72')];if(!_[_0x0ab4('0x73')](_0xa0f095[_0x0ab4('0x36')][_0x0ab4('0x6a')])&&_0xa0f095[_0x0ab4('0x36')]['ticketType']===_0x0ab4('0x74')){_0x2eefbf=[_0x0ab4('0x72'),_0x0ab4('0x75'),_0x0ab4('0x76'),_0x0ab4('0x77'),_0x0ab4('0x71'),_0x0ab4('0x78'),_0x0ab4('0x79'),_0x0ab4('0x7a')];}if(_0x338075){_[_0x0ab4('0x7b')](_0x338075[_0x0ab4('0x3a')],function(_0x1989fd){return _0x1989fd[_0x0ab4('0x7c')]===![]&&!_0x2eefbf[_0x0ab4('0x7d')](_0x1989fd['name']);});return{'count':_0x338075[_0x0ab4('0x3a')][_0x0ab4('0x3b')],'rows':_[_0x0ab4('0x34')](_0x338075[_0x0ab4('0x3a')],function(_0x51aaa1){return{'id':_0x51aaa1['name'],'name':_0x51aaa1[_0x0ab4('0x7e')],'custom':_0x51aaa1[_0x0ab4('0x7c')],'options':_0x51aaa1['picklistValues'][_0x0ab4('0x3b')]>0x0?_[_0x0ab4('0x34')](_0x51aaa1[_0x0ab4('0x7f')],function(_0x46e26b){return{'name':_0x46e26b[_0x0ab4('0x7e')],'value':_0x46e26b[_0x0ab4('0x80')]};}):_0x51aaa1[_0x0ab4('0x31')]=='boolean'?[{'name':_0x0ab4('0x81'),'value':_0x0ab4('0x82')},{'name':_0x0ab4('0x83'),'value':_0x0ab4('0x84')}]:[]};})};}})[_0x0ab4('0x1a')](respondWithResult(_0x5281da,null))[_0x0ab4('0x52')](function(_0x30f735){var _0x3670a2=_0xa0f095[_0x0ab4('0x36')]['test']?0x1f4:_0x30f735[_0x0ab4('0x85')]||0x1f4;logger['error'](_0x0ab4('0x86'),_0x0ab4('0x60'),_0x3670a2,JSON[_0x0ab4('0x87')](_0x30f735));delete _0x30f735[_0x0ab4('0x35')];if(_0x3670a2===0x191){_0x3670a2=0x190;}_0x5281da[_0x0ab4('0x24')](_0x3670a2)[_0x0ab4('0x2e')](_0xa0f095['query']['test']?{'message':_0x0ab4('0x88'),'statusCode':_0x30f735[_0x0ab4('0x85')]}:_0x30f735);});};
\ No newline at end of file