Built motion from commit b598105.|2.0.4
[motion2.git] / server / api / integration / integration.controller.js
1 var _0x1733=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x66\x61\x73\x74\x2D\x6A\x73\x6F\x6E\x2D\x70\x61\x74\x63\x68","\x72\x65\x71\x75\x65\x73\x74\x2D\x70\x72\x6F\x6D\x69\x73\x65","\x6D\x6F\x6D\x65\x6E\x74","\x62\x6C\x75\x65\x62\x69\x72\x64","\x75\x74\x69\x6C","\x70\x61\x74\x68","\x73\x6F\x78","\x65\x6A\x73","\x66\x73","\x6C\x6F\x64\x61\x73\x68","\x73\x71\x75\x65\x6C","\x63\x72\x79\x70\x74\x6F","\x6A\x73\x66\x6F\x72\x63\x65","\x74\x6F\x2D\x63\x73\x76","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6D\x70\x6F\x6E\x65\x6E\x74\x73\x2F\x70\x61\x72\x73\x65\x72\x73\x2F\x71\x73","\x61\x70\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x64\x62","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x79\x73\x71\x6C\x64\x62","\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73","\x6E\x6F\x20\x63\x6F\x6E\x74\x65\x6E\x74","\x69\x6E\x66\x6F","\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73","\x64\x65\x62\x75\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x65\x6E\x74\x69\x74\x79\x20\x66\x6F\x75\x6E\x64","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x6A\x73\x6F\x6E","\x63\x6F\x75\x6E\x74","\x6F\x66\x66\x73\x65\x74","\x6C\x69\x6D\x69\x74","\x65\x6E\x74\x69\x74\x69\x65\x73\x20\x66\x6F\x75\x6E\x64","\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x52\x61\x6E\x67\x65","\x2D","\x2F","\x73\x65\x74","\x61\x70\x70\x6C\x79","\x72\x65\x6A\x65\x63\x74","\x73\x61\x76\x65","\x65\x6E\x74\x69\x74\x79\x20\x75\x70\x64\x61\x74\x65\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65","\x65\x6E\x74\x69\x74\x79\x20\x72\x65\x6D\x6F\x76\x65\x64","\x64\x65\x73\x74\x72\x6F\x79","\x65\x6E\x74\x69\x74\x79\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x65\x72\x72\x6F\x72","\x6E\x61\x6D\x65","\x73\x65\x6E\x64","\x69\x6E\x64\x65\x78","\x6D\x6F\x64\x65\x6C","\x72\x61\x77\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x6B\x65\x79\x73","\x71\x75\x65\x72\x79","\x66\x69\x6C\x74\x65\x72\x73","\x69\x6E\x74\x65\x72\x73\x65\x63\x74\x69\x6F\x6E","\x61\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x66\x69\x65\x6C\x64\x73","\x6C\x65\x6E\x67\x74\x68","\x6E\x6F\x6C\x69\x6D\x69\x74","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x6F\x72\x64\x65\x72","\x73\x6F\x72\x74","\x77\x68\x65\x72\x65","\x70\x69\x63\x6B","\x66\x69\x6C\x74\x65\x72","\x25","\x6D\x61\x70","\x6D\x65\x72\x67\x65","\x6F\x70\x74\x69\x6F\x6E\x73","\x63\x61\x74\x63\x68","\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","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79"];_0x1733[0];var jsonpatch=require(_0x1733[1]);var rp=require(_0x1733[2]);var moment=require(_0x1733[3]);var BPromise=require(_0x1733[4]);var util=require(_0x1733[5]);var path=require(_0x1733[6]);var sox=require(_0x1733[7]);var ejs=require(_0x1733[8]);var fs=require(_0x1733[9]);var _=require(_0x1733[10]);var squel=require(_0x1733[11]);var crypto=require(_0x1733[12]);var jsforce=require(_0x1733[13]);var toCsv=require(_0x1733[14]);var qs=require(_0x1733[15]);var logger=require(_0x1733[17])(_0x1733[16]);var utils=require(_0x1733[18]);var config=require(_0x1733[19]);var db=require(_0x1733[21])[_0x1733[20]];function respondWithStatusCode(_0xe9fcx15,_0xe9fcx16,_0xe9fcx17){_0xe9fcx16= _0xe9fcx16|| 204;return function(_0xe9fcx18){if(_0xe9fcx18){logger[_0x1733[24]](_0x1733[22],_0xe9fcx17,_0xe9fcx16,_0x1733[23]);logger[_0x1733[26]](_0x1733[25],_0xe9fcx17,_0xe9fcx16,_0x1733[23]);return _0xe9fcx15[_0x1733[27]](_0xe9fcx16)};return _0xe9fcx15[_0x1733[29]](304)[_0x1733[28]]()}}function respondWithResult(_0xe9fcx15,_0xe9fcx16,_0xe9fcx17){_0xe9fcx16= _0xe9fcx16|| 200;return function(_0xe9fcx18){if(_0xe9fcx18){logger[_0x1733[24]](_0x1733[22],_0xe9fcx17,_0xe9fcx16,_0x1733[30]);logger[_0x1733[26]](_0x1733[25],_0xe9fcx17,_0xe9fcx16,_0x1733[30],JSON[_0x1733[31]](_0xe9fcx18));return _0xe9fcx15[_0x1733[29]](_0xe9fcx16)[_0x1733[32]](_0xe9fcx18)};return _0xe9fcx15[_0x1733[29]](304)[_0x1733[28]]()}}function respondWithFilteredResult(_0xe9fcx15,_0xe9fcx1b,_0xe9fcx17){return function(_0xe9fcx18){if(_0xe9fcx18){var _0xe9fcx1c=_0xe9fcx18[_0x1733[33]],_0xe9fcx1d=_0xe9fcx1b[_0x1733[34]],_0xe9fcx1e=_0xe9fcx1b[_0x1733[34]]+ _0xe9fcx1b[_0x1733[35]],_0xe9fcx16;if(_0xe9fcx1e>= _0xe9fcx1c){_0xe9fcx1e= _0xe9fcx1c;_0xe9fcx16= 200}else {_0xe9fcx16= 206};_0xe9fcx15[_0x1733[29]](_0xe9fcx16);logger[_0x1733[24]](_0x1733[22],_0xe9fcx17,_0xe9fcx16,_0x1733[36]);logger[_0x1733[26]](_0x1733[25],_0xe9fcx17,_0xe9fcx16,_0x1733[30],JSON[_0x1733[31]](_0xe9fcx18));return _0xe9fcx15[_0x1733[40]](_0x1733[37],_0xe9fcx1d+ _0x1733[38]+ _0xe9fcx1e+ _0x1733[39]+ _0xe9fcx1c)[_0x1733[32]](_0xe9fcx18)};return null}}function patchUpdates(_0xe9fcx20){return function(_0xe9fcx18){try{jsonpatch[_0x1733[41]](_0xe9fcx18,_0xe9fcx20,true)}catch(err){return BPromise[_0x1733[42]](err)};return _0xe9fcx18[_0x1733[43]]()}}function saveUpdates(_0xe9fcx22,_0xe9fcx16,_0xe9fcx17){return function(_0xe9fcx18){if(_0xe9fcx18){return _0xe9fcx18[_0x1733[46]](_0xe9fcx22)[_0x1733[45]](function(_0xe9fcx23){logger[_0x1733[24]](_0x1733[22],_0xe9fcx17,_0xe9fcx16,_0x1733[44]);logger[_0x1733[26]](_0x1733[25],_0xe9fcx17,_0xe9fcx16,_0x1733[44],JSON[_0x1733[31]](_0xe9fcx18));return _0xe9fcx23})};return null}}function removeEntity(_0xe9fcx15,_0xe9fcx16,_0xe9fcx17){return function(_0xe9fcx18){if(_0xe9fcx18){return _0xe9fcx18[_0x1733[48]]()[_0x1733[45]](function(){logger[_0x1733[24]](_0x1733[22],_0xe9fcx17,_0xe9fcx16,_0x1733[47]);logger[_0x1733[26]](_0x1733[25],_0xe9fcx17,_0xe9fcx16,_0x1733[47],JSON[_0x1733[31]](_0xe9fcx18));_0xe9fcx15[_0x1733[29]](204)[_0x1733[28]]()})}}}function handleEntityNotFound(_0xe9fcx15,_0xe9fcx16,_0xe9fcx17){return function(_0xe9fcx18){if(!_0xe9fcx18){logger[_0x1733[50]](_0x1733[22],_0xe9fcx17,404,_0x1733[49]);_0xe9fcx15[_0x1733[29]](404)[_0x1733[28]]();return null};return _0xe9fcx18}}function handleError(_0xe9fcx15,_0xe9fcx16,_0xe9fcx17){_0xe9fcx16= _0xe9fcx16|| 500;return function(_0xe9fcx27){logger[_0x1733[50]](_0x1733[22],_0xe9fcx17,_0xe9fcx16,JSON[_0x1733[31]](_0xe9fcx27));delete _0xe9fcx27[_0x1733[51]];_0xe9fcx15[_0x1733[29]](_0xe9fcx16)[_0x1733[52]](_0xe9fcx27)}}exports[_0x1733[53]]= function(_0xe9fcx28,_0xe9fcx15){var _0xe9fcx1b={},_0xe9fcx29={};_0xe9fcx29[_0x1733[54]]= _[_0x1733[57]](db[_0x1733[56]][_0x1733[55]]);_0xe9fcx29[_0x1733[58]]= _[_0x1733[57]](_0xe9fcx28[_0x1733[58]]);_0xe9fcx29[_0x1733[59]]= _[_0x1733[60]](_0xe9fcx29[_0x1733[54]],_0xe9fcx29[_0x1733[58]]);_0xe9fcx1b[_0x1733[61]]= _[_0x1733[60]](_0xe9fcx29[_0x1733[54]],qs[_0x1733[62]](_0xe9fcx28[_0x1733[58]][_0x1733[62]]));_0xe9fcx1b[_0x1733[61]]= (_0xe9fcx1b[_0x1733[61]][_0x1733[63]])?_0xe9fcx1b[_0x1733[61]]:_0xe9fcx29[_0x1733[54]];if(!_0xe9fcx28[_0x1733[58]][_0x1733[65]](_0x1733[64])){_0xe9fcx1b[_0x1733[35]]= qs[_0x1733[35]](_0xe9fcx28[_0x1733[58]][_0x1733[35]]);_0xe9fcx1b[_0x1733[34]]= qs[_0x1733[34]](_0xe9fcx28[_0x1733[58]][_0x1733[34]])};_0xe9fcx1b[_0x1733[66]]= qs[_0x1733[67]](_0xe9fcx28[_0x1733[58]][_0x1733[67]]);_0xe9fcx1b[_0x1733[68]]= qs[_0x1733[59]](_[_0x1733[69]](_0xe9fcx28[_0x1733[58]],_0xe9fcx29[_0x1733[59]]));if(_0xe9fcx28[_0x1733[58]][_0x1733[70]]){_0xe9fcx1b[_0x1733[68]]= _[_0x1733[73]](_0xe9fcx1b[_0x1733[68]],{$or:_[_0x1733[72]](_0xe9fcx1b[_0x1733[61]],function(_0xe9fcx2a){var _0xe9fcx2b={};_0xe9fcx2b[_0xe9fcx2a]= {$like:_0x1733[71]+ _0xe9fcx28[_0x1733[58]][_0x1733[70]]+ _0x1733[71]};return _0xe9fcx2b})})};_0xe9fcx1b= _[_0x1733[73]]({},_0xe9fcx1b,_0xe9fcx28[_0x1733[74]]);return db[_0x1733[56]][_0x1733[76]](_0xe9fcx1b)[_0x1733[45]](respondWithFilteredResult(_0xe9fcx15,_0xe9fcx1b,_0x1733[53]))[_0x1733[75]](handleError(_0xe9fcx15,null,_0x1733[53]))};exports[_0x1733[77]]= function(_0xe9fcx28,_0xe9fcx15){var _0xe9fcx1b={raw:false,where:{id:_0xe9fcx28[_0x1733[79]][_0x1733[78]]}},_0xe9fcx29={};_0xe9fcx29[_0x1733[54]]= _[_0x1733[57]](db[_0x1733[56]][_0x1733[55]]);_0xe9fcx29[_0x1733[58]]= _[_0x1733[57]](_0xe9fcx28[_0x1733[58]]);_0xe9fcx29[_0x1733[59]]= _[_0x1733[60]](_0xe9fcx29[_0x1733[54]],_0xe9fcx29[_0x1733[58]]);_0xe9fcx1b[_0x1733[61]]= _[_0x1733[60]](_0xe9fcx29[_0x1733[54]],qs[_0x1733[62]](_0xe9fcx28[_0x1733[58]][_0x1733[62]]));_0xe9fcx1b[_0x1733[61]]= (_0xe9fcx1b[_0x1733[61]][_0x1733[63]])?_0xe9fcx1b[_0x1733[61]]:_0xe9fcx29[_0x1733[54]];_0xe9fcx1b= _[_0x1733[73]]({},_0xe9fcx1b,_0xe9fcx28[_0x1733[74]]);return db[_0x1733[56]][_0x1733[80]](_0xe9fcx1b)[_0x1733[45]](handleEntityNotFound(_0xe9fcx15,null,_0x1733[77]))[_0x1733[45]](respondWithResult(_0xe9fcx15,null,_0x1733[77]))[_0x1733[75]](handleError(_0xe9fcx15,null,_0x1733[77]))};exports[_0x1733[81]]= function(_0xe9fcx28,_0xe9fcx15){return db[_0x1733[56]][_0x1733[81]](_0xe9fcx28[_0x1733[82]],{raw:true})[_0x1733[45]](respondWithResult(_0xe9fcx15,201,_0x1733[81]))[_0x1733[75]](handleError(_0xe9fcx15,null,_0x1733[81]))};exports[_0x1733[46]]= function(_0xe9fcx28,_0xe9fcx15){if(_0xe9fcx28[_0x1733[82]][_0x1733[78]]){delete _0xe9fcx28[_0x1733[82]][_0x1733[78]]};return db[_0x1733[56]][_0x1733[80]]({where:{id:_0xe9fcx28[_0x1733[79]][_0x1733[78]]}})[_0x1733[45]](handleEntityNotFound(_0xe9fcx15,null,_0x1733[46]))[_0x1733[45]](saveUpdates(_0xe9fcx28[_0x1733[82]],null,_0x1733[46]))[_0x1733[45]](respondWithResult(_0xe9fcx15,null,_0x1733[46]))[_0x1733[75]](handleError(_0xe9fcx15,null,_0x1733[46]))};exports[_0x1733[48]]= function(_0xe9fcx28,_0xe9fcx15){return db[_0x1733[56]][_0x1733[80]]({where:{id:_0xe9fcx28[_0x1733[79]][_0x1733[78]]}})[_0x1733[45]](handleEntityNotFound(_0xe9fcx15,null,_0x1733[48]))[_0x1733[45]](removeEntity(_0xe9fcx15,null,_0x1733[48]))[_0x1733[75]](handleError(_0xe9fcx15,null,_0x1733[48]))}