Built motion from commit 53e9689.|0.0.63
[motion.git] / server / api / salesforce_account / salesforce_account.controller.js
1 var _0xe5d3=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x6A\x73\x66\x6F\x72\x63\x65","\x53\x61\x6C\x65\x73\x66\x6F\x72\x63\x65\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x75\x73\x65\x72\x6E\x61\x6D\x65","\x72\x65\x6D\x6F\x74\x65\x55\x72\x69","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x63\x6C\x69\x65\x6E\x74\x49\x64","\x63\x6C\x69\x65\x6E\x74\x53\x65\x63\x72\x65\x74","\x73\x65\x63\x75\x72\x69\x74\x79\x54\x6F\x6B\x65\x6E","\x63\x6F\x6E\x63\x61\x74","\x70\x61\x73\x73\x77\x6F\x72\x64","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x6C\x6F\x67\x69\x6E","\x61\x63\x63\x6F\x75\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65","\x67\x65\x74\x46\x69\x65\x6C\x64\x73","\x66\x69\x65\x6C\x64\x73","\x64\x65\x73\x63\x72\x69\x62\x65","\x54\x61\x73\x6B","\x73\x6F\x62\x6A\x65\x63\x74","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0xe5d3[0];var _=require(_0xe5d3[1]);var util=require(_0xe5d3[2]);var jsforce=require(_0xe5d3[3]);var SalesforceAccount=require(_0xe5d3[5])[_0xe5d3[4]];function handleError(_0x457ex6,_0x457ex7){_0x457ex7=_0x457ex7||500;return function(_0x457ex8){_0x457ex6[_0xe5d3[7]](_0x457ex7)[_0xe5d3[6]](_0x457ex8)}}function responseWithResult(_0x457ex6,_0x457ex7){_0x457ex7=_0x457ex7||200;return function(_0x457exa){if(_0x457exa){_0x457ex6[_0xe5d3[7]](_0x457ex7)[_0xe5d3[8]](_0x457exa)}}}function handleEntityNotFound(_0x457ex6){return function(_0x457exa){if(!_0x457exa){_0x457ex6[_0xe5d3[7]](404)[_0xe5d3[9]]();return null};return _0x457exa}}function saveUpdates(_0x457exd){return function(_0x457exa){return _0x457exa[_0xe5d3[11]](_0x457exd)[_0xe5d3[10]](function(_0x457exe){return _0x457exe})}}function removeEntity(_0x457ex6){return function(_0x457exa){if(_0x457exa){return _0x457exa[_0xe5d3[12]]()[_0xe5d3[10]](function(){_0x457ex6[_0xe5d3[7]](204)[_0xe5d3[9]]()})}}}exports[_0xe5d3[13]]=function(_0x457ex10,_0x457ex6){var _0x457ex11=[_0xe5d3[14],_0xe5d3[15],_0xe5d3[16],_0xe5d3[17]];var _0x457ex12=_0x457ex10[_0xe5d3[19]][_0xe5d3[18]]?parseInt(_0x457ex10[_0xe5d3[19]][_0xe5d3[18]],10):100;var _0x457ex13=_0x457ex10[_0xe5d3[19]][_0xe5d3[20]]?parseInt(_0x457ex10[_0xe5d3[19]][_0xe5d3[20]],10):0;var _0x457ex14={where:{},limit:_0x457ex12,offset:_0x457ex13*_0x457ex12};_[_0xe5d3[34]](_0x457ex10[_0xe5d3[19]],function(_0x457ex15,_0x457ex16){switch(_0x457ex16){case _0xe5d3[18]:;case _0xe5d3[20]:break;case _0xe5d3[23]:_0x457ex14[_0xe5d3[21]]=util[_0xe5d3[26]](_0xe5d3[22],_0x457ex10[_0xe5d3[19]][_0xe5d3[23]],_0x457ex10[_0xe5d3[19]][_0xe5d3[24]]||_0xe5d3[25])||null;break;case _0xe5d3[24]:break;case _0xe5d3[32]:_0x457ex14[_0xe5d3[28]][_0xe5d3[27]]=[];_0x457ex11[_0xe5d3[31]](function(_0x457ex17){var _0x457ex18={};_0x457ex18[_0x457ex17]={$like:_0xe5d3[29]+_0x457ex15+_0xe5d3[29]};_0x457ex14[_0xe5d3[28]][_0xe5d3[27]][_0xe5d3[30]](_0x457ex18)});break;default:_0x457ex14[_0xe5d3[28]][_0x457ex16]={$like:{}};_0x457ex14[_0xe5d3[28]][_0x457ex16][_0xe5d3[33]]=_0xe5d3[29]+_0x457ex15+_0xe5d3[29]}});SalesforceAccount[_0xe5d3[46]](_0x457ex14)[_0xe5d3[10]](function(_0x457ex19){var _0x457ex1a=Math[_0xe5d3[38]](_0x457ex19[_0xe5d3[37]]/_0x457ex12);var _0x457ex1b=_0x457ex1a>(_0x457ex14[_0xe5d3[39]]+1)?util[_0xe5d3[26]](_0xe5d3[40],_0x457ex10[_0xe5d3[41]],_0x457ex10[_0xe5d3[43]][_0xe5d3[42]],_0x457ex10[_0xe5d3[44]],_0x457ex13+1):null;var _0x457ex1c=_0x457ex13>0?util[_0xe5d3[26]](_0xe5d3[40],_0x457ex10[_0xe5d3[41]],_0x457ex10[_0xe5d3[43]][_0xe5d3[42]],_0x457ex10[_0xe5d3[44]],_0x457ex13-1):null;return _0x457ex6[_0xe5d3[7]](200)[_0xe5d3[6]]({count:_0x457ex19[_0xe5d3[37]],rows:_0x457ex19[_0xe5d3[45]],next_page:_0x457ex1b,previous_page:_0x457ex1c,total_pages:_0x457ex1a})})[_0xe5d3[36]](function(_0x457ex8){return _0x457ex6[_0xe5d3[7]](500)[_0xe5d3[6]]({error:_0xe5d3[35]})})};exports[_0xe5d3[47]]=function(_0x457ex10,_0x457ex6){SalesforceAccount[_0xe5d3[50]](_0x457ex10[_0xe5d3[49]][_0xe5d3[48]])[_0xe5d3[10]](handleEntityNotFound(_0x457ex6))[_0xe5d3[10]](responseWithResult(_0x457ex6))[_0xe5d3[36]](handleError(_0x457ex6))};exports[_0xe5d3[51]]=function(_0x457ex10,_0x457ex6){SalesforceAccount[_0xe5d3[51]](_0x457ex10[_0xe5d3[52]])[_0xe5d3[10]](responseWithResult(_0x457ex6,201))[_0xe5d3[36]](handleError(_0x457ex6))};exports[_0xe5d3[53]]=function(_0x457ex10,_0x457ex6){if(_0x457ex10[_0xe5d3[52]][_0xe5d3[48]]){delete _0x457ex10[_0xe5d3[52]][_0xe5d3[48]]};SalesforceAccount[_0xe5d3[50]](_0x457ex10[_0xe5d3[49]][_0xe5d3[48]])[_0xe5d3[10]](handleEntityNotFound(_0x457ex6))[_0xe5d3[10]](saveUpdates(_0x457ex10[_0xe5d3[52]]))[_0xe5d3[10]](responseWithResult(_0x457ex6))[_0xe5d3[36]](handleError(_0x457ex6))};exports[_0xe5d3[12]]=function(_0x457ex10,_0x457ex6){SalesforceAccount[_0xe5d3[50]](_0x457ex10[_0xe5d3[49]][_0xe5d3[48]])[_0xe5d3[10]](handleEntityNotFound(_0x457ex6))[_0xe5d3[10]](removeEntity(_0x457ex6))[_0xe5d3[36]](handleError(_0x457ex6))};exports[_0xe5d3[54]]=function(_0x457ex10,_0x457ex6){SalesforceAccount[_0xe5d3[50]](_0x457ex10[_0xe5d3[49]][_0xe5d3[48]])[_0xe5d3[10]](handleEntityNotFound(_0x457ex6))[_0xe5d3[10]](function(_0x457ex1d){var _0x457ex1e= new jsforce.Connection({oauth2:{loginUrl:_0x457ex1d[_0xe5d3[17]],clientId:_0x457ex1d[_0xe5d3[55]],clientSecret:_0x457ex1d[_0xe5d3[56]]}});var _0x457ex1f=_0x457ex1d[_0xe5d3[59]][_0xe5d3[58]](_0x457ex1d[_0xe5d3[57]]);_0x457ex1e[_0xe5d3[61]](_0x457ex1d[_0xe5d3[16]],_0x457ex1f,function(_0x457ex8,_0x457ex20){if(_0x457ex8){return _0x457ex6[_0xe5d3[7]](400)[_0xe5d3[6]](_0x457ex8)};return _0x457ex6[_0xe5d3[60]](200)})})[_0xe5d3[36]](handleError(_0x457ex6))};exports[_0xe5d3[62]]=function(_0x457ex10,_0x457ex6){var _0x457ex21={};_0x457ex21[_0x457ex10[_0xe5d3[49]][_0xe5d3[63]]]=_0x457ex10[_0xe5d3[52]][_0xe5d3[64]];SalesforceAccount[_0xe5d3[46]]({where:_0x457ex21})[_0xe5d3[10]](function(_0x457ex19){if(_0x457ex19[_0xe5d3[37]]){return _0x457ex6[_0xe5d3[7]](200)[_0xe5d3[6]]({isValid:false,value:_0x457ex10[_0xe5d3[52]][_0xe5d3[64]]})};return _0x457ex6[_0xe5d3[7]](200)[_0xe5d3[6]]({isValid:true,value:_0x457ex10[_0xe5d3[52]][_0xe5d3[64]]})})[_0xe5d3[36]](function(_0x457ex8){return handleError(_0x457ex6,_0x457ex8)})};exports[_0xe5d3[65]]=function(_0x457ex10,_0x457ex6){SalesforceAccount[_0xe5d3[50]](_0x457ex10[_0xe5d3[49]][_0xe5d3[48]])[_0xe5d3[10]](handleEntityNotFound(_0x457ex6))[_0xe5d3[10]](function(_0x457ex1d){var _0x457ex1e= new jsforce.Connection({oauth2:{loginUrl:_0x457ex1d[_0xe5d3[17]],clientId:_0x457ex1d[_0xe5d3[55]],clientSecret:_0x457ex1d[_0xe5d3[56]]}});var _0x457ex1f=_0x457ex1d[_0xe5d3[59]][_0xe5d3[58]](_0x457ex1d[_0xe5d3[57]]);_0x457ex1e[_0xe5d3[61]](_0x457ex1d[_0xe5d3[16]],_0x457ex1f,function(_0x457ex8,_0x457ex20){if(_0x457ex8){return _0x457ex6[_0xe5d3[7]](400)[_0xe5d3[6]](_0x457ex8)};_0x457ex1e[_0xe5d3[69]](_0xe5d3[68])[_0xe5d3[67]](function(_0x457ex8,_0x457ex22){if(_0x457ex8){return _0x457ex6[_0xe5d3[7]](400)[_0xe5d3[6]](_0x457ex8)};return _0x457ex6[_0xe5d3[7]](200)[_0xe5d3[6]](_0x457ex22[_0xe5d3[66]])})})})[_0xe5d3[36]](handleError(_0x457ex6))};exports[_0xe5d3[70]]=function(_0x457ex10,_0x457ex6){SalesforceAccount[_0xe5d3[12]]({where:{id:_0x457ex10[_0xe5d3[19]][_0xe5d3[48]]},individualHooks:true})[_0xe5d3[10]](function(){return _0x457ex6[_0xe5d3[60]](204)})[_0xe5d3[36]](function(_0x457ex8){return handleError(_0x457ex6,_0x457ex8)})}