92c49f097e97173216896b547269dfa2ae33d246
[motion.git] / server / api / desk_account / desk_account.controller.js
1 var _0x527e=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x64\x65\x73\x6B\x2E\x6A\x73","\x61\x70\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\x44\x65\x73\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\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","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\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","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\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","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x63\x68\x65\x63\x6B\x41\x63\x63\x6F\x75\x6E\x74","\x61\x75\x74\x68\x54\x79\x70\x65","\x62\x61\x73\x69\x63","\x70\x61\x73\x73\x77\x6F\x72\x64","\x6F\x61\x75\x74\x68","\x63\x6F\x6E\x73\x75\x6D\x65\x72\x4B\x65\x79","\x63\x6F\x6E\x73\x75\x6D\x65\x72\x53\x65\x63\x72\x65\x74","\x74\x6F\x6B\x65\x6E","\x74\x6F\x6B\x65\x6E\x53\x65\x63\x72\x65\x74","\x63\x72\x65\x61\x74\x65\x43\x6C\x69\x65\x6E\x74","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x75\x73\x65\x72\x73\x2F\x6D\x65","\x67\x65\x74","\x64\x65\x73\x6B\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","\x2F\x61\x70\x69\x2F\x76\x32\x2F\x63\x75\x73\x74\x6F\x6D\x5F\x66\x69\x65\x6C\x64\x73","\x65\x6E\x74\x72\x69\x65\x73","\x5F\x65\x6D\x62\x65\x64\x64\x65\x64","\x6A\x73\x6F\x6E","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x73\x75\x62\x73\x74\x72","\x2F","\x6C\x65\x6E\x67\x74\x68","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72"];_0x527e[0];var _=require(_0x527e[1]);var util=require(_0x527e[2]);var desk=require(_0x527e[3]);var logger=require(_0x527e[5])(_0x527e[4]);var DeskAccount=require(_0x527e[7])[_0x527e[6]];exports[_0x527e[8]]= function(_0x95a2x6,_0x95a2x7){var _0x95a2x8=[_0x527e[9],_0x527e[10],_0x527e[11],_0x527e[12]];var _0x95a2x9=_0x95a2x6[_0x527e[14]][_0x527e[13]]?parseInt(_0x95a2x6[_0x527e[14]][_0x527e[13]],10):100;var _0x95a2xa=_0x95a2x6[_0x527e[14]][_0x527e[15]]?parseInt(_0x95a2x6[_0x527e[14]][_0x527e[15]],10):0;var _0x95a2xb={where:{},limit:_0x95a2x9,offset:_0x95a2xa* _0x95a2x9};_[_0x527e[29]](_0x95a2x6[_0x527e[14]],function(_0x95a2xc,_0x95a2xd){switch(_0x95a2xd){case _0x527e[13]:;case _0x527e[15]:break;case _0x527e[18]:_0x95a2xb[_0x527e[16]]= util[_0x527e[21]](_0x527e[17],_0x95a2x6[_0x527e[14]][_0x527e[18]],_0x95a2x6[_0x527e[14]][_0x527e[19]]|| _0x527e[20])|| null;break;case _0x527e[19]:break;case _0x527e[27]:_0x95a2xb[_0x527e[23]][_0x527e[22]]= [];_0x95a2x8[_0x527e[26]](function(_0x95a2xe){var _0x95a2xf={};_0x95a2xf[_0x95a2xe]= {$like:_0x527e[24]+ _0x95a2xc+ _0x527e[24]};_0x95a2xb[_0x527e[23]][_0x527e[22]][_0x527e[25]](_0x95a2xf)});break;default:_0x95a2xb[_0x527e[23]][_0x95a2xd]= {$like:{}};_0x95a2xb[_0x527e[23]][_0x95a2xd][_0x527e[28]]= _0x527e[24]+ _0x95a2xc+ _0x527e[24]}});return DeskAccount[_0x527e[44]](_0x95a2xb)[_0x527e[43]](function(_0x95a2x11){var _0x95a2x12=Math[_0x527e[35]](_0x95a2x11[_0x527e[34]]/ _0x95a2x9);var _0x95a2x13=_0x95a2x12> (_0x95a2xb[_0x527e[36]]+ 1)?util[_0x527e[21]](_0x527e[37],_0x95a2x6[_0x527e[38]],_0x95a2x6[_0x527e[40]][_0x527e[39]],_0x95a2x6[_0x527e[41]],_0x95a2xa+ 1):null;var _0x95a2x14=_0x95a2xa> 0?util[_0x527e[21]](_0x527e[37],_0x95a2x6[_0x527e[38]],_0x95a2x6[_0x527e[40]][_0x527e[39]],_0x95a2x6[_0x527e[41]],_0x95a2xa- 1):null;return _0x95a2x7[_0x527e[32]](200)[_0x527e[31]]({count:_0x95a2x11[_0x527e[34]],rows:_0x95a2x11[_0x527e[42]],next_page:_0x95a2x13,previous_page:_0x95a2x14,total_pages:_0x95a2x12})})[_0x527e[33]](function(_0x95a2x10){return _0x95a2x7[_0x527e[32]](500)[_0x527e[31]]({error:_0x527e[30]})})};exports[_0x527e[45]]= function(_0x95a2x6,_0x95a2x7){DeskAccount[_0x527e[49]](_0x95a2x6[_0x527e[48]][_0x527e[47]])[_0x527e[43]](function(_0x95a2x15){if(!_0x95a2x15){return _0x95a2x7[_0x527e[46]](404)};return _0x95a2x7[_0x527e[31]](_0x95a2x15)})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})};exports[_0x527e[50]]= function(_0x95a2x6,_0x95a2x7,_0x95a2x16){DeskAccount[_0x527e[50]](_0x95a2x6[_0x527e[51]])[_0x527e[43]](function(_0x95a2x15){return _0x95a2x7[_0x527e[32]](201)[_0x527e[31]](_0x95a2x15)})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})};exports[_0x527e[52]]= function(_0x95a2x6,_0x95a2x7){if(_0x95a2x6[_0x527e[51]][_0x527e[47]]){delete _0x95a2x6[_0x527e[51]][_0x527e[47]]};DeskAccount[_0x527e[49]](_0x95a2x6[_0x527e[48]][_0x527e[47]])[_0x527e[43]](function(_0x95a2x15){if(!_0x95a2x15){return _0x95a2x7[_0x527e[46]](404)};var _0x95a2x17=_[_0x527e[53]](_0x95a2x15,_0x95a2x6[_0x527e[51]]);_0x95a2x17[_0x527e[54]]()[_0x527e[43]](function(){return _0x95a2x7[_0x527e[32]](200)[_0x527e[31]](_0x95a2x15)})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})};exports[_0x527e[55]]= function(_0x95a2x6,_0x95a2x7){DeskAccount[_0x527e[49]](_0x95a2x6[_0x527e[48]][_0x527e[47]])[_0x527e[43]](function(_0x95a2x15){if(!_0x95a2x15){return _0x95a2x7[_0x527e[46]](404)};_0x95a2x15[_0x527e[55]]()[_0x527e[43]](function(){return _0x95a2x7[_0x527e[46]](204)})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})};exports[_0x527e[56]]= function(_0x95a2x6,_0x95a2x7){DeskAccount[_0x527e[49]](_0x95a2x6[_0x527e[48]][_0x527e[47]])[_0x527e[43]](function(_0x95a2x18){var _0x95a2x15={endpoint:stripTrailingSlash(_0x95a2x18[_0x527e[12]]),retry:false};if(_0x95a2x18[_0x527e[57]]=== _0x527e[58]){_0x95a2x15[_0x527e[11]]= _0x95a2x18[_0x527e[11]];_0x95a2x15[_0x527e[59]]= _0x95a2x18[_0x527e[59]]}else {if(_0x95a2x18[_0x527e[57]]=== _0x527e[60]){_0x95a2x15[_0x527e[61]]= _0x95a2x18[_0x527e[61]];_0x95a2x15[_0x527e[62]]= _0x95a2x18[_0x527e[62]];_0x95a2x15[_0x527e[63]]= _0x95a2x18[_0x527e[63]];_0x95a2x15[_0x527e[64]]= _0x95a2x18[_0x527e[64]]}};var _0x95a2x19=desk[_0x527e[65]](_0x95a2x15);_0x95a2x19[_0x527e[67]](_0x527e[66],function(_0x95a2x10,_0x95a2x1a,_0x95a2x1b){if(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)};return _0x95a2x7[_0x527e[46]](200)})})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})};exports[_0x527e[68]]= function(_0x95a2x6,_0x95a2x7){var _0x95a2x1c={};_0x95a2x1c[_0x95a2x6[_0x527e[48]][_0x527e[69]]]= _0x95a2x6[_0x527e[51]][_0x527e[70]];DeskAccount[_0x527e[44]]({where:_0x95a2x1c})[_0x527e[43]](function(_0x95a2x11){if(_0x95a2x11[_0x527e[34]]){return _0x95a2x7[_0x527e[32]](200)[_0x527e[31]]({isValid:false,value:_0x95a2x6[_0x527e[51]][_0x527e[70]]})};return _0x95a2x7[_0x527e[32]](200)[_0x527e[31]]({isValid:true,value:_0x95a2x6[_0x527e[51]][_0x527e[70]]})})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})};exports[_0x527e[71]]= function(_0x95a2x6,_0x95a2x7){DeskAccount[_0x527e[49]](_0x95a2x6[_0x527e[48]][_0x527e[47]])[_0x527e[43]](function(_0x95a2x18){var _0x95a2x15={endpoint:stripTrailingSlash(_0x95a2x18[_0x527e[12]]),retry:false};if(_0x95a2x18[_0x527e[57]]=== _0x527e[58]){_0x95a2x15[_0x527e[11]]= _0x95a2x18[_0x527e[11]];_0x95a2x15[_0x527e[59]]= _0x95a2x18[_0x527e[59]]}else {if(_0x95a2x18[_0x527e[57]]=== _0x527e[60]){_0x95a2x15[_0x527e[61]]= _0x95a2x18[_0x527e[61]];_0x95a2x15[_0x527e[62]]= _0x95a2x18[_0x527e[62]];_0x95a2x15[_0x527e[63]]= _0x95a2x18[_0x527e[63]];_0x95a2x15[_0x527e[64]]= _0x95a2x18[_0x527e[64]]}};var _0x95a2x19=desk[_0x527e[65]](_0x95a2x15);_0x95a2x19[_0x527e[67]](_0x527e[72],function(_0x95a2x10,_0x95a2x1a,_0x95a2x1b){if(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)};return _0x95a2x7[_0x527e[32]](200)[_0x527e[75]](_0x95a2x1a[_0x527e[74]][_0x527e[73]])})})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})};exports[_0x527e[76]]= function(_0x95a2x6,_0x95a2x7){DeskAccount[_0x527e[55]]({where:{id:_0x95a2x6[_0x527e[14]][_0x527e[47]]},individualHooks:true})[_0x527e[43]](function(){return _0x95a2x7[_0x527e[46]](204)})[_0x527e[33]](function(_0x95a2x10){return handleError(_0x95a2x7,_0x95a2x10)})};function stripTrailingSlash(_0x95a2x1e){if(_0x95a2x1e[_0x527e[77]](-1) === _0x527e[78]){return _0x95a2x1e[_0x527e[77]](0,_0x95a2x1e[_0x527e[79]]- 1)};return _0x95a2x1e}function handleError(_0x95a2x7,_0x95a2x10){logger[_0x527e[81]](_0x95a2x10[_0x527e[80]]);return _0x95a2x7[_0x527e[32]](500)[_0x527e[31]](_0x95a2x10)}