Built motion from commit a61a4a20.|2.5.46
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index 127e8f3..a6e24c8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xca06=['POST','%s%s','/service/v4_1/rest.php','login','JSON','username','Invalid\x20Login','Password\x20Expired','format','get_module_fields','values','module_fields','remove','includes','label','endsWith','value','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','send','Wrong\x20credentials','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','mustache','util','path','to-csv','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','../../components/integrations/configuration','jayson/promise','http','request','then','info','SugarcrmAccount,\x20%s,\x20%s','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','destroy','sendStatus','name','index','SugarcrmAccount','rawAttributes','model','map','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','type','VIRTUAL','options','includeAll','include','findAll','rows','find','create','body','params','getConfigurations','SugarcrmConfiguration','pick','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','SugarcrmField','getFields','assigned_user_id','created_by','date_start','duration_hours','duration_minutes','parent_id','parent_type','parent_name','direction','password','remoteUri','slice','substring','lastIndexOf'];(function(_0x2399ec,_0x22b88c){var _0x5159a2=function(_0x5d23d0){while(--_0x5d23d0){_0x2399ec['push'](_0x2399ec['shift']());}};_0x5159a2(++_0x22b88c);}(_0xca06,0x9a));var _0x6ca0=function(_0x487d0e,_0x384d08){_0x487d0e=_0x487d0e-0x0;var _0x8e8353=_0xca06[_0x487d0e];return _0x8e8353;};'use strict';var pdf=require(_0x6ca0('0x0'));var emlformat=require(_0x6ca0('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x6ca0('0x2'));var jsonpatch=require(_0x6ca0('0x3'));var rp=require(_0x6ca0('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x6ca0('0x5'));var util=require(_0x6ca0('0x6'));var path=require(_0x6ca0('0x7'));var sox=require('sox');var csv=require(_0x6ca0('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x6ca0('0x9'));var crypto=require(_0x6ca0('0xa'));var jsforce=require(_0x6ca0('0xb'));var deskjs=require(_0x6ca0('0xc'));var toCsv=require(_0x6ca0('0x8'));var querystring=require('querystring');var Papa=require(_0x6ca0('0xd'));var Redis=require(_0x6ca0('0xe'));var authService=require(_0x6ca0('0xf'));var qs=require(_0x6ca0('0x10'));var as=require(_0x6ca0('0x11'));var hardwareService=require(_0x6ca0('0x12'));var logger=require(_0x6ca0('0x13'))(_0x6ca0('0x14'));var utils=require(_0x6ca0('0x15'));var config=require(_0x6ca0('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x6ca0('0x17'))['db'];var integrations=require(_0x6ca0('0x18'));var jayson=require(_0x6ca0('0x19'));var client=jayson['client'][_0x6ca0('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x15eeb8,_0xc18248,_0x1307bb,_0x2ce718){return new BPromise(function(_0x3f4b61,_0x340152){var _0x40a08c=_0x2ce718||client;return _0x40a08c[_0x6ca0('0x1b')](_0x15eeb8,_0x1307bb)[_0x6ca0('0x1c')](function(_0x29a8a6){logger[_0x6ca0('0x1d')](_0x6ca0('0x1e'),_0xc18248,_0x6ca0('0x1f'));logger[_0x6ca0('0x20')](_0x6ca0('0x21'),_0xc18248,_0x6ca0('0x1f'),JSON[_0x6ca0('0x22')](_0x29a8a6));if(_0x29a8a6[_0x6ca0('0x23')]){if(_0x29a8a6[_0x6ca0('0x23')][_0x6ca0('0x24')]===0x1f4){logger[_0x6ca0('0x23')](_0x6ca0('0x1e'),_0xc18248,_0x29a8a6[_0x6ca0('0x23')][_0x6ca0('0x25')]);return _0x340152(_0x29a8a6[_0x6ca0('0x23')][_0x6ca0('0x25')]);}logger[_0x6ca0('0x23')]('SugarcrmAccount,\x20%s,\x20%s',_0xc18248,_0x29a8a6[_0x6ca0('0x23')][_0x6ca0('0x25')]);return _0x3f4b61(_0x29a8a6[_0x6ca0('0x23')]['message']);}else{logger[_0x6ca0('0x1d')]('SugarcrmAccount,\x20%s,\x20%s',_0xc18248,'request\x20sent');_0x3f4b61(_0x29a8a6[_0x6ca0('0x26')][_0x6ca0('0x25')]);}})[_0x6ca0('0x27')](function(_0x70851d){logger[_0x6ca0('0x23')](_0x6ca0('0x1e'),_0xc18248,_0x70851d);_0x340152(_0x70851d);});});}function respondWithStatusCode(_0x1d9b47,_0x4b755a){_0x4b755a=_0x4b755a||0xcc;return function(_0x16d39f){if(_0x16d39f){return _0x1d9b47['sendStatus'](_0x4b755a);}return _0x1d9b47[_0x6ca0('0x28')](_0x4b755a)[_0x6ca0('0x29')]();};}function respondWithResult(_0x38d24e,_0x2ccf90){_0x2ccf90=_0x2ccf90||0xc8;return function(_0x4bf67d){if(_0x4bf67d){return _0x38d24e[_0x6ca0('0x28')](_0x2ccf90)[_0x6ca0('0x2a')](_0x4bf67d);}};}function respondWithFilteredResult(_0x5a0205,_0x2191e1){return function(_0x31ec6b){if(_0x31ec6b){var _0x5d8c3d=_0x31ec6b[_0x6ca0('0x2b')],_0x49aaec=_0x2191e1['offset'],_0xed566e=_0x2191e1[_0x6ca0('0x2c')]+_0x2191e1[_0x6ca0('0x2d')],_0x1df63e;if(_0xed566e>=_0x5d8c3d){_0xed566e=_0x5d8c3d;_0x1df63e=0xc8;}else{_0x1df63e=0xce;}_0x5a0205[_0x6ca0('0x28')](_0x1df63e);return _0x5a0205[_0x6ca0('0x2e')](_0x6ca0('0x2f'),_0x49aaec+'-'+_0xed566e+'/'+_0x5d8c3d)[_0x6ca0('0x2a')](_0x31ec6b);}return null;};}function patchUpdates(_0x41687e){return function(_0x323f08){try{jsonpatch['apply'](_0x323f08,_0x41687e,!![]);}catch(_0x369cb7){return BPromise[_0x6ca0('0x30')](_0x369cb7);}return _0x323f08[_0x6ca0('0x31')]();};}function saveUpdates(_0x123c24,_0x2431e8){return function(_0x2a1600){if(_0x2a1600){return _0x2a1600[_0x6ca0('0x32')](_0x123c24)[_0x6ca0('0x1c')](function(_0x23c81e){return _0x23c81e;});}return null;};}function removeEntity(_0x384dc5,_0x3ea386){return function(_0x1c04a2){if(_0x1c04a2){return _0x1c04a2[_0x6ca0('0x33')]()[_0x6ca0('0x1c')](function(){_0x384dc5['status'](0xcc)[_0x6ca0('0x29')]();});}};}function handleEntityNotFound(_0x583a8a,_0x4eb0b6){return function(_0x5f425c){if(!_0x5f425c){_0x583a8a[_0x6ca0('0x34')](0x194);}return _0x5f425c;};}function handleError(_0x542d4e,_0x47bd88){_0x47bd88=_0x47bd88||0x1f4;return function(_0x1245d8){logger[_0x6ca0('0x23')](_0x1245d8['stack']);if(_0x1245d8[_0x6ca0('0x35')]){delete _0x1245d8[_0x6ca0('0x35')];}_0x542d4e[_0x6ca0('0x28')](_0x47bd88)['send'](_0x1245d8);};}exports[_0x6ca0('0x36')]=function(_0x945858,_0x2cac52){var _0x339fe3={},_0x5e4002={},_0xda4c15={'count':0x0,'rows':[]};var _0x375818=_['map'](db[_0x6ca0('0x37')][_0x6ca0('0x38')],function(_0x2f3753){return{'name':_0x2f3753['fieldName'],'type':_0x2f3753['type']['key']};});_0x5e4002[_0x6ca0('0x39')]=_[_0x6ca0('0x3a')](_0x375818,_0x6ca0('0x35'));_0x5e4002['query']=_[_0x6ca0('0x3b')](_0x945858[_0x6ca0('0x3c')]);_0x5e4002[_0x6ca0('0x3d')]=_[_0x6ca0('0x3e')](_0x5e4002[_0x6ca0('0x39')],_0x5e4002['query']);_0x339fe3['attributes']=_[_0x6ca0('0x3e')](_0x5e4002[_0x6ca0('0x39')],qs[_0x6ca0('0x3f')](_0x945858[_0x6ca0('0x3c')][_0x6ca0('0x3f')]));_0x339fe3[_0x6ca0('0x40')]=_0x339fe3[_0x6ca0('0x40')][_0x6ca0('0x41')]?_0x339fe3[_0x6ca0('0x40')]:_0x5e4002['model'];if(!_0x945858[_0x6ca0('0x3c')][_0x6ca0('0x42')](_0x6ca0('0x43'))){_0x339fe3[_0x6ca0('0x2d')]=qs['limit'](_0x945858[_0x6ca0('0x3c')][_0x6ca0('0x2d')]);_0x339fe3[_0x6ca0('0x2c')]=qs[_0x6ca0('0x2c')](_0x945858['query']['offset']);}_0x339fe3[_0x6ca0('0x44')]=qs[_0x6ca0('0x45')](_0x945858[_0x6ca0('0x3c')]['sort']);_0x339fe3[_0x6ca0('0x46')]=qs[_0x6ca0('0x3d')](_['pick'](_0x945858['query'],_0x5e4002[_0x6ca0('0x3d')]),_0x375818);if(_0x945858['query'][_0x6ca0('0x47')]){_0x339fe3[_0x6ca0('0x46')]=_[_0x6ca0('0x48')](_0x339fe3[_0x6ca0('0x46')],{'$or':_[_0x6ca0('0x3a')](_0x375818,function(_0x563499){if(_0x563499[_0x6ca0('0x49')]!==_0x6ca0('0x4a')){var _0x504f1b={};_0x504f1b[_0x563499[_0x6ca0('0x35')]]={'$like':'%'+_0x945858[_0x6ca0('0x3c')][_0x6ca0('0x47')]+'%'};return _0x504f1b;}})});}_0x339fe3=_[_0x6ca0('0x48')]({},_0x339fe3,_0x945858[_0x6ca0('0x4b')]);var _0x3dc58e={'where':_0x339fe3[_0x6ca0('0x46')]};return db[_0x6ca0('0x37')][_0x6ca0('0x2b')](_0x3dc58e)[_0x6ca0('0x1c')](function(_0x5ec325){_0xda4c15['count']=_0x5ec325;if(_0x945858['query'][_0x6ca0('0x4c')]){_0x339fe3[_0x6ca0('0x4d')]=[{'all':!![]}];}return db['SugarcrmAccount'][_0x6ca0('0x4e')](_0x339fe3);})[_0x6ca0('0x1c')](function(_0x254b7b){_0xda4c15[_0x6ca0('0x4f')]=_0x254b7b;return _0xda4c15;})[_0x6ca0('0x1c')](respondWithFilteredResult(_0x2cac52,_0x339fe3))['catch'](handleError(_0x2cac52,null));};exports['show']=function(_0x40e28d,_0x2bb4e4){var _0x47e0ca={'raw':![],'where':{'id':_0x40e28d['params']['id']}},_0x3b4e12={};_0x3b4e12[_0x6ca0('0x39')]=_['keys'](db[_0x6ca0('0x37')][_0x6ca0('0x38')]);_0x3b4e12['query']=_[_0x6ca0('0x3b')](_0x40e28d[_0x6ca0('0x3c')]);_0x3b4e12[_0x6ca0('0x3d')]=_[_0x6ca0('0x3e')](_0x3b4e12['model'],_0x3b4e12[_0x6ca0('0x3c')]);_0x47e0ca[_0x6ca0('0x40')]=_[_0x6ca0('0x3e')](_0x3b4e12['model'],qs['fields'](_0x40e28d[_0x6ca0('0x3c')][_0x6ca0('0x3f')]));_0x47e0ca[_0x6ca0('0x40')]=_0x47e0ca[_0x6ca0('0x40')][_0x6ca0('0x41')]?_0x47e0ca[_0x6ca0('0x40')]:_0x3b4e12[_0x6ca0('0x39')];if(_0x40e28d[_0x6ca0('0x3c')][_0x6ca0('0x4c')]){_0x47e0ca['include']=[{'all':!![]}];}_0x47e0ca=_[_0x6ca0('0x48')]({},_0x47e0ca,_0x40e28d[_0x6ca0('0x4b')]);return db['SugarcrmAccount'][_0x6ca0('0x50')](_0x47e0ca)['then'](handleEntityNotFound(_0x2bb4e4,null))[_0x6ca0('0x1c')](respondWithResult(_0x2bb4e4,null))['catch'](handleError(_0x2bb4e4,null));};exports[_0x6ca0('0x51')]=function(_0x1291b4,_0x542b7e){return db[_0x6ca0('0x37')][_0x6ca0('0x51')](_0x1291b4['body'],{})[_0x6ca0('0x1c')](respondWithResult(_0x542b7e,0xc9))[_0x6ca0('0x27')](handleError(_0x542b7e,null));};exports['update']=function(_0x3399a9,_0x37ad0e){if(_0x3399a9[_0x6ca0('0x52')]['id']){delete _0x3399a9['body']['id'];}return db['SugarcrmAccount'][_0x6ca0('0x50')]({'where':{'id':_0x3399a9['params']['id']}})[_0x6ca0('0x1c')](handleEntityNotFound(_0x37ad0e,null))[_0x6ca0('0x1c')](saveUpdates(_0x3399a9['body'],null))[_0x6ca0('0x1c')](respondWithResult(_0x37ad0e,null))[_0x6ca0('0x27')](handleError(_0x37ad0e,null));};exports[_0x6ca0('0x33')]=function(_0x180035,_0x5c804f){return db['SugarcrmAccount'][_0x6ca0('0x50')]({'where':{'id':_0x180035[_0x6ca0('0x53')]['id']}})[_0x6ca0('0x1c')](handleEntityNotFound(_0x5c804f,null))[_0x6ca0('0x1c')](removeEntity(_0x5c804f,null))[_0x6ca0('0x27')](handleError(_0x5c804f,null));};exports[_0x6ca0('0x54')]=function(_0x4ce52,_0x1ef2a6,_0x4fcee7){var _0x426d99={};var _0x12ba34={};var _0x43911a;var _0x5d6562;return db[_0x6ca0('0x37')]['findOne']({'where':{'id':_0x4ce52['params']['id']}})['then'](handleEntityNotFound(_0x1ef2a6,null))['then'](function(_0x5c9693){if(_0x5c9693){_0x43911a=_0x5c9693;_0x12ba34['model']=_[_0x6ca0('0x3b')](db[_0x6ca0('0x55')][_0x6ca0('0x38')]);_0x12ba34[_0x6ca0('0x3c')]=_[_0x6ca0('0x3b')](_0x4ce52[_0x6ca0('0x3c')]);_0x12ba34[_0x6ca0('0x3d')]=_[_0x6ca0('0x3e')](_0x12ba34[_0x6ca0('0x39')],_0x12ba34['query']);_0x426d99[_0x6ca0('0x40')]=_[_0x6ca0('0x3e')](_0x12ba34[_0x6ca0('0x39')],qs[_0x6ca0('0x3f')](_0x4ce52['query']['fields']));_0x426d99[_0x6ca0('0x40')]=_0x426d99[_0x6ca0('0x40')]['length']?_0x426d99[_0x6ca0('0x40')]:_0x12ba34['model'];_0x426d99['order']=qs[_0x6ca0('0x45')](_0x4ce52[_0x6ca0('0x3c')][_0x6ca0('0x45')]);_0x426d99['where']=qs[_0x6ca0('0x3d')](_[_0x6ca0('0x56')](_0x4ce52[_0x6ca0('0x3c')],_0x12ba34[_0x6ca0('0x3d')]));if(_0x4ce52[_0x6ca0('0x3c')]['filter']){_0x426d99[_0x6ca0('0x46')]=_[_0x6ca0('0x48')](_0x426d99[_0x6ca0('0x46')],{'$or':_[_0x6ca0('0x3a')](_0x426d99[_0x6ca0('0x40')],function(_0x30f9a7){var _0x210836={};_0x210836[_0x30f9a7]={'$like':'%'+_0x4ce52[_0x6ca0('0x3c')][_0x6ca0('0x47')]+'%'};return _0x210836;})});}_0x426d99=_[_0x6ca0('0x48')]({},_0x426d99,_0x4ce52['options']);return _0x43911a['getConfigurations'](_0x426d99);}})[_0x6ca0('0x1c')](function(_0x35a396){if(_0x35a396){_0x5d6562=_0x35a396[_0x6ca0('0x41')];if(!_0x4ce52[_0x6ca0('0x3c')][_0x6ca0('0x42')](_0x6ca0('0x43'))){_0x426d99[_0x6ca0('0x2d')]=qs[_0x6ca0('0x2d')](_0x4ce52[_0x6ca0('0x3c')][_0x6ca0('0x2d')]);_0x426d99['offset']=qs[_0x6ca0('0x2c')](_0x4ce52[_0x6ca0('0x3c')][_0x6ca0('0x2c')]);}return _0x43911a[_0x6ca0('0x54')](_0x426d99);}})[_0x6ca0('0x1c')](function(_0x12ce34){if(_0x12ce34){return _0x12ce34?{'count':_0x5d6562,'rows':_0x12ce34}:null;}})['then'](respondWithResult(_0x1ef2a6,null))['catch'](handleError(_0x1ef2a6,null));};exports[_0x6ca0('0x57')]=function(_0x21e180,_0x57ddb3,_0x37e798){if(_0x21e180[_0x6ca0('0x52')]['id']){delete _0x21e180[_0x6ca0('0x52')]['id'];}return db['SugarcrmAccount']['findOne']({'where':{'id':_0x21e180['params']['id']}})['then'](handleEntityNotFound(_0x57ddb3,null))[_0x6ca0('0x1c')](function(_0x43103d){if(_0x43103d){_0x21e180[_0x6ca0('0x52')][_0x6ca0('0x58')]=_0x43103d['id'];_0x21e180[_0x6ca0('0x52')][_0x6ca0('0x59')]=integrations[_0x6ca0('0x5a')](_0x21e180['body'][_0x6ca0('0x5b')],_0x21e180[_0x6ca0('0x52')]['type']);_0x21e180[_0x6ca0('0x52')][_0x6ca0('0x5c')]=integrations[_0x6ca0('0x5d')](_0x21e180[_0x6ca0('0x52')][_0x6ca0('0x5b')],_0x21e180['body'][_0x6ca0('0x49')]);return db[_0x6ca0('0x55')][_0x6ca0('0x51')](_0x21e180['body'],{'include':[{'model':db['SugarcrmField'],'as':'Subjects'},{'model':db[_0x6ca0('0x5e')],'as':_0x6ca0('0x5c')}]});}return null;})[_0x6ca0('0x1c')](respondWithResult(_0x57ddb3,null))[_0x6ca0('0x27')](handleError(_0x57ddb3,null));};exports[_0x6ca0('0x5f')]=function(_0x22cdf8,_0xa177bf,_0x3de86f){var _0x445ccf='';var _0x1a7225=['id',_0x6ca0('0x35'),_0x6ca0('0x60'),_0x6ca0('0x61'),'description',_0x6ca0('0x62'),_0x6ca0('0x63'),_0x6ca0('0x64'),_0x6ca0('0x65'),_0x6ca0('0x66'),_0x6ca0('0x67'),_0x6ca0('0x68')];return db['SugarcrmAccount']['findOne']({'where':{'id':_0x22cdf8['params']['id']},'attributes':['id','username',_0x6ca0('0x69'),_0x6ca0('0x6a')]})['then'](handleEntityNotFound(_0xa177bf,null))[_0x6ca0('0x1c')](function(_0xf07b64){if(_0xf07b64){_0x445ccf=_0xf07b64[_0x6ca0('0x6a')];var _0x3ab2a3=_0x445ccf[_0x6ca0('0x6b')](-0x1);if(_0x3ab2a3==='/'){_0x445ccf=_0x445ccf[_0x6ca0('0x6c')](0x0,_0x445ccf[_0x6ca0('0x6d')](_0x3ab2a3));}return rp({'method':_0x6ca0('0x6e'),'uri':util['format'](_0x6ca0('0x6f'),_0x445ccf,_0x6ca0('0x70')),'json':!![],'form':{'method':_0x6ca0('0x71'),'input_type':_0x6ca0('0x72'),'response_type':_0x6ca0('0x72'),'rest_data':JSON[_0x6ca0('0x22')]({'user_auth':{'user_name':_0xf07b64[_0x6ca0('0x73')],'password':_0xf07b64[_0x6ca0('0x69')],'encryption':'PLAIN'},'application':'xCALLY\x20Motion\x20Integration'})}});}})[_0x6ca0('0x1c')](function(_0xa673d2){if(_0xa673d2&&_0xa673d2['name']!==_0x6ca0('0x74')&&_0xa673d2[_0x6ca0('0x35')]!==_0x6ca0('0x75')){return rp({'method':_0x6ca0('0x6e'),'uri':util[_0x6ca0('0x76')]('%s%s',_0x445ccf,_0x6ca0('0x70')),'json':!![],'form':{'method':_0x6ca0('0x77'),'input_type':'JSON','response_type':_0x6ca0('0x72'),'rest_data':JSON[_0x6ca0('0x22')]({'session':_0xa673d2['id'],'module_name':'Calls'})}})['then'](function(_0x3b9cda){if(_0x3b9cda){var _0x335df8=_[_0x6ca0('0x78')](_0x3b9cda[_0x6ca0('0x79')]);_[_0x6ca0('0x7a')](_0x335df8,function(_0x34c3f9){return _0x1a7225[_0x6ca0('0x7b')](_0x34c3f9['name']);});return{'count':_0x335df8[_0x6ca0('0x41')],'rows':_[_0x6ca0('0x3a')](_0x335df8,function(_0x5ec910){return{'id':_0x5ec910[_0x6ca0('0x35')],'name':_0x5ec910[_0x6ca0('0x7c')],'custom':_[_0x6ca0('0x7d')](_0x5ec910[_0x6ca0('0x35')],'_c')?!![]:![],'options':_0x5ec910[_0x6ca0('0x4b')]?_[_0x6ca0('0x3a')](_[_0x6ca0('0x78')](_0x5ec910[_0x6ca0('0x4b')]),function(_0x49e3af){return{'name':_0x49e3af[_0x6ca0('0x7e')],'value':_0x49e3af[_0x6ca0('0x35')]};}):[]};})};}})[_0x6ca0('0x1c')](respondWithResult(_0xa177bf,null))[_0x6ca0('0x27')](function(_0x3da03c){var _0x561450=_0x22cdf8[_0x6ca0('0x3c')][_0x6ca0('0x7f')]?0x1f4:_0x3da03c[_0x6ca0('0x80')]||0x1f4;logger[_0x6ca0('0x23')](_0x6ca0('0x81'),'getFields',_0x561450,JSON['stringify'](_0x3da03c));delete _0x3da03c['name'];if(_0x561450===0x191){_0x561450=0x190;}_0xa177bf[_0x6ca0('0x28')](_0x561450)[_0x6ca0('0x82')](_0x22cdf8[_0x6ca0('0x3c')]['test']?{'message':_0x6ca0('0x83'),'statusCode':_0x3da03c[_0x6ca0('0x80')]}:_0x3da03c);});}else{var _0x19dea6=0x1f4;_0xa177bf[_0x6ca0('0x28')](_0x19dea6)[_0x6ca0('0x82')]({'message':'Wrong\x20credentials','statusCode':0x190});}});};
\ No newline at end of file
+var _0x8ba3=['send','map','SugarcrmAccount','fieldName','key','query','keys','filters','intersection','model','fields','attributes','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','length','find','create','body','getConfigurations','findOne','addConfiguration','getSubjects','channel','type','Descriptions','getDescriptions','SugarcrmConfiguration','Subjects','SugarcrmField','getFields','assigned_user_id','created_by','description','date_start','duration_hours','parent_id','parent_type','parent_name','direction','username','password','remoteUri','slice','substring','lastIndexOf','POST','format','%s%s','/service/v4_1/rest.php','JSON','stringify','xCALLY\x20Motion\x20Integration','Password\x20Expired','get_module_fields','Calls','values','remove','endsWith','value','test','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','statusCode','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','error','stack','name'];(function(_0x29fb4a,_0x125899){var _0x1f46b1=function(_0x24b1e8){while(--_0x24b1e8){_0x29fb4a['push'](_0x29fb4a['shift']());}};_0x1f46b1(++_0x125899);}(_0x8ba3,0x1bf));var _0x38ba=function(_0x197a55,_0x4654ea){_0x197a55=_0x197a55-0x0;var _0x108330=_0x8ba3[_0x197a55];return _0x108330;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x38ba('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x38ba('0x1'));var rp=require('request-promise');var moment=require(_0x38ba('0x2'));var BPromise=require(_0x38ba('0x3'));var Mustache=require(_0x38ba('0x4'));var util=require(_0x38ba('0x5'));var path=require(_0x38ba('0x6'));var sox=require(_0x38ba('0x7'));var csv=require('to-csv');var ejs=require(_0x38ba('0x8'));var fs=require('fs');var fs_extra=require(_0x38ba('0x9'));var _=require(_0x38ba('0xa'));var squel=require('squel');var crypto=require(_0x38ba('0xb'));var jsforce=require(_0x38ba('0xc'));var deskjs=require(_0x38ba('0xd'));var toCsv=require(_0x38ba('0xe'));var querystring=require(_0x38ba('0xf'));var Papa=require(_0x38ba('0x10'));var Redis=require(_0x38ba('0x11'));var authService=require(_0x38ba('0x12'));var qs=require(_0x38ba('0x13'));var as=require(_0x38ba('0x14'));var hardwareService=require(_0x38ba('0x15'));var logger=require(_0x38ba('0x16'))(_0x38ba('0x17'));var utils=require(_0x38ba('0x18'));var config=require(_0x38ba('0x19'));var licenseUtil=require(_0x38ba('0x1a'));var db=require(_0x38ba('0x1b'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x34a84a,_0x1912d2){_0x1912d2=_0x1912d2||0xcc;return function(_0x36f9d2){if(_0x36f9d2){return _0x34a84a['sendStatus'](_0x1912d2);}return _0x34a84a[_0x38ba('0x1c')](_0x1912d2)[_0x38ba('0x1d')]();};}function respondWithResult(_0x3174ed,_0x13a8cd){_0x13a8cd=_0x13a8cd||0xc8;return function(_0x1ec974){if(_0x1ec974){return _0x3174ed[_0x38ba('0x1c')](_0x13a8cd)[_0x38ba('0x1e')](_0x1ec974);}};}function respondWithFilteredResult(_0x131aa7,_0x492b16){return function(_0x412546){if(_0x412546){var _0x20d27c=typeof _0x492b16[_0x38ba('0x1f')]===_0x38ba('0x20')&&typeof _0x492b16[_0x38ba('0x21')]==='undefined';var _0x291ec1=_0x412546[_0x38ba('0x22')];var _0x3b04eb=_0x20d27c?0x0:_0x492b16[_0x38ba('0x1f')];var _0x37ecdb=_0x20d27c?_0x412546[_0x38ba('0x22')]:_0x492b16[_0x38ba('0x1f')]+_0x492b16[_0x38ba('0x21')];var _0x4fc98e;if(_0x37ecdb>=_0x291ec1){_0x37ecdb=_0x291ec1;_0x4fc98e=0xc8;}else{_0x4fc98e=0xce;}_0x131aa7[_0x38ba('0x1c')](_0x4fc98e);return _0x131aa7[_0x38ba('0x23')](_0x38ba('0x24'),_0x3b04eb+'-'+_0x37ecdb+'/'+_0x291ec1)['json'](_0x412546);}return null;};}function patchUpdates(_0x493c7d){return function(_0x40686a){try{jsonpatch['apply'](_0x40686a,_0x493c7d,!![]);}catch(_0x63fe8c){return BPromise[_0x38ba('0x25')](_0x63fe8c);}return _0x40686a[_0x38ba('0x26')]();};}function saveUpdates(_0x4afdd2,_0x5c64e4){return function(_0x59ceb2){if(_0x59ceb2){return _0x59ceb2[_0x38ba('0x27')](_0x4afdd2)[_0x38ba('0x28')](function(_0x17b213){return _0x17b213;});}return null;};}function removeEntity(_0x1408c6,_0x3c44f3){return function(_0x4b1103){if(_0x4b1103){return _0x4b1103[_0x38ba('0x29')]()['then'](function(){_0x1408c6['status'](0xcc)[_0x38ba('0x1d')]();});}};}function handleEntityNotFound(_0x2c03cf,_0x59a97f){return function(_0x34d356){if(!_0x34d356){_0x2c03cf['sendStatus'](0x194);}return _0x34d356;};}function handleError(_0x361ec8,_0x2398e0){_0x2398e0=_0x2398e0||0x1f4;return function(_0x1aa4c6){logger[_0x38ba('0x2a')](_0x1aa4c6[_0x38ba('0x2b')]);if(_0x1aa4c6[_0x38ba('0x2c')]){delete _0x1aa4c6[_0x38ba('0x2c')];}_0x361ec8[_0x38ba('0x1c')](_0x2398e0)[_0x38ba('0x2d')](_0x1aa4c6);};}exports['index']=function(_0x525f9a,_0x17a9c1){var _0x23e64c={},_0x580c75={},_0x5ce355={'count':0x0,'rows':[]};var _0x5a311f=_[_0x38ba('0x2e')](db[_0x38ba('0x2f')]['rawAttributes'],function(_0x40f905){return{'name':_0x40f905[_0x38ba('0x30')],'type':_0x40f905['type'][_0x38ba('0x31')]};});_0x580c75['model']=_[_0x38ba('0x2e')](_0x5a311f,_0x38ba('0x2c'));_0x580c75[_0x38ba('0x32')]=_[_0x38ba('0x33')](_0x525f9a['query']);_0x580c75[_0x38ba('0x34')]=_[_0x38ba('0x35')](_0x580c75[_0x38ba('0x36')],_0x580c75['query']);_0x23e64c['attributes']=_[_0x38ba('0x35')](_0x580c75[_0x38ba('0x36')],qs[_0x38ba('0x37')](_0x525f9a['query'][_0x38ba('0x37')]));_0x23e64c[_0x38ba('0x38')]=_0x23e64c['attributes']['length']?_0x23e64c[_0x38ba('0x38')]:_0x580c75[_0x38ba('0x36')];if(!_0x525f9a['query']['hasOwnProperty'](_0x38ba('0x39'))){_0x23e64c['limit']=qs[_0x38ba('0x21')](_0x525f9a[_0x38ba('0x32')][_0x38ba('0x21')]);_0x23e64c[_0x38ba('0x1f')]=qs[_0x38ba('0x1f')](_0x525f9a['query'][_0x38ba('0x1f')]);}_0x23e64c[_0x38ba('0x3a')]=qs[_0x38ba('0x3b')](_0x525f9a['query'][_0x38ba('0x3b')]);_0x23e64c[_0x38ba('0x3c')]=qs['filters'](_[_0x38ba('0x3d')](_0x525f9a[_0x38ba('0x32')],_0x580c75[_0x38ba('0x34')]),_0x5a311f);if(_0x525f9a[_0x38ba('0x32')][_0x38ba('0x3e')]){_0x23e64c[_0x38ba('0x3c')]=_[_0x38ba('0x3f')](_0x23e64c[_0x38ba('0x3c')],{'$or':_[_0x38ba('0x2e')](_0x5a311f,function(_0x381432){if(_0x381432['type']!==_0x38ba('0x40')){var _0x447f85={};_0x447f85[_0x381432['name']]={'$like':'%'+_0x525f9a['query'][_0x38ba('0x3e')]+'%'};return _0x447f85;}})});}_0x23e64c=_[_0x38ba('0x3f')]({},_0x23e64c,_0x525f9a[_0x38ba('0x41')]);var _0x2932a1={'where':_0x23e64c[_0x38ba('0x3c')]};return db['SugarcrmAccount']['count'](_0x2932a1)[_0x38ba('0x28')](function(_0x3a3005){_0x5ce355['count']=_0x3a3005;if(_0x525f9a['query'][_0x38ba('0x42')]){_0x23e64c[_0x38ba('0x43')]=[{'all':!![]}];}return db[_0x38ba('0x2f')][_0x38ba('0x44')](_0x23e64c);})['then'](function(_0x5c41ca){_0x5ce355[_0x38ba('0x45')]=_0x5c41ca;return _0x5ce355;})[_0x38ba('0x28')](respondWithFilteredResult(_0x17a9c1,_0x23e64c))[_0x38ba('0x46')](handleError(_0x17a9c1,null));};exports[_0x38ba('0x47')]=function(_0x4c785f,_0x58bb26){var _0x13ccab={'raw':![],'where':{'id':_0x4c785f[_0x38ba('0x48')]['id']}},_0x3b61e7={};_0x3b61e7[_0x38ba('0x36')]=_['keys'](db[_0x38ba('0x2f')][_0x38ba('0x49')]);_0x3b61e7['query']=_[_0x38ba('0x33')](_0x4c785f['query']);_0x3b61e7[_0x38ba('0x34')]=_[_0x38ba('0x35')](_0x3b61e7[_0x38ba('0x36')],_0x3b61e7[_0x38ba('0x32')]);_0x13ccab[_0x38ba('0x38')]=_['intersection'](_0x3b61e7['model'],qs['fields'](_0x4c785f[_0x38ba('0x32')][_0x38ba('0x37')]));_0x13ccab[_0x38ba('0x38')]=_0x13ccab[_0x38ba('0x38')][_0x38ba('0x4a')]?_0x13ccab['attributes']:_0x3b61e7['model'];if(_0x4c785f['query'][_0x38ba('0x42')]){_0x13ccab[_0x38ba('0x43')]=[{'all':!![]}];}_0x13ccab=_[_0x38ba('0x3f')]({},_0x13ccab,_0x4c785f[_0x38ba('0x41')]);return db['SugarcrmAccount'][_0x38ba('0x4b')](_0x13ccab)[_0x38ba('0x28')](handleEntityNotFound(_0x58bb26,null))[_0x38ba('0x28')](respondWithResult(_0x58bb26,null))[_0x38ba('0x46')](handleError(_0x58bb26,null));};exports[_0x38ba('0x4c')]=function(_0x27df73,_0x4c7b0c){return db[_0x38ba('0x2f')][_0x38ba('0x4c')](_0x27df73[_0x38ba('0x4d')],{})[_0x38ba('0x28')](respondWithResult(_0x4c7b0c,0xc9))[_0x38ba('0x46')](handleError(_0x4c7b0c,null));};exports[_0x38ba('0x27')]=function(_0x25849b,_0x4ca6c1){if(_0x25849b['body']['id']){delete _0x25849b[_0x38ba('0x4d')]['id'];}return db['SugarcrmAccount'][_0x38ba('0x4b')]({'where':{'id':_0x25849b[_0x38ba('0x48')]['id']}})['then'](handleEntityNotFound(_0x4ca6c1,null))[_0x38ba('0x28')](saveUpdates(_0x25849b[_0x38ba('0x4d')],null))[_0x38ba('0x28')](respondWithResult(_0x4ca6c1,null))[_0x38ba('0x46')](handleError(_0x4ca6c1,null));};exports[_0x38ba('0x29')]=function(_0x4f79cf,_0x2660df){return db['SugarcrmAccount']['find']({'where':{'id':_0x4f79cf[_0x38ba('0x48')]['id']}})['then'](handleEntityNotFound(_0x2660df,null))[_0x38ba('0x28')](removeEntity(_0x2660df,null))[_0x38ba('0x46')](handleError(_0x2660df,null));};exports[_0x38ba('0x4e')]=function(_0x2a5ef1,_0x296d41,_0x382c6f){var _0x275d82={};var _0xd5d267={};var _0x4a93fc;var _0x2b2714;return db[_0x38ba('0x2f')][_0x38ba('0x4f')]({'where':{'id':_0x2a5ef1['params']['id']}})['then'](handleEntityNotFound(_0x296d41,null))['then'](function(_0x44592c){if(_0x44592c){_0x4a93fc=_0x44592c;_0xd5d267[_0x38ba('0x36')]=_[_0x38ba('0x33')](db['SugarcrmConfiguration'][_0x38ba('0x49')]);_0xd5d267[_0x38ba('0x32')]=_[_0x38ba('0x33')](_0x2a5ef1[_0x38ba('0x32')]);_0xd5d267['filters']=_['intersection'](_0xd5d267[_0x38ba('0x36')],_0xd5d267[_0x38ba('0x32')]);_0x275d82[_0x38ba('0x38')]=_['intersection'](_0xd5d267[_0x38ba('0x36')],qs[_0x38ba('0x37')](_0x2a5ef1['query'][_0x38ba('0x37')]));_0x275d82[_0x38ba('0x38')]=_0x275d82[_0x38ba('0x38')][_0x38ba('0x4a')]?_0x275d82[_0x38ba('0x38')]:_0xd5d267['model'];_0x275d82['order']=qs[_0x38ba('0x3b')](_0x2a5ef1[_0x38ba('0x32')][_0x38ba('0x3b')]);_0x275d82[_0x38ba('0x3c')]=qs[_0x38ba('0x34')](_['pick'](_0x2a5ef1[_0x38ba('0x32')],_0xd5d267[_0x38ba('0x34')]));if(_0x2a5ef1[_0x38ba('0x32')]['filter']){_0x275d82[_0x38ba('0x3c')]=_[_0x38ba('0x3f')](_0x275d82[_0x38ba('0x3c')],{'$or':_[_0x38ba('0x2e')](_0x275d82[_0x38ba('0x38')],function(_0x1a0aa1){var _0x2adec9={};_0x2adec9[_0x1a0aa1]={'$like':'%'+_0x2a5ef1['query'][_0x38ba('0x3e')]+'%'};return _0x2adec9;})});}_0x275d82=_['merge']({},_0x275d82,_0x2a5ef1[_0x38ba('0x41')]);return _0x4a93fc[_0x38ba('0x4e')](_0x275d82);}})[_0x38ba('0x28')](function(_0x16b030){if(_0x16b030){_0x2b2714=_0x16b030['length'];if(!_0x2a5ef1[_0x38ba('0x32')]['hasOwnProperty'](_0x38ba('0x39'))){_0x275d82[_0x38ba('0x21')]=qs[_0x38ba('0x21')](_0x2a5ef1[_0x38ba('0x32')][_0x38ba('0x21')]);_0x275d82['offset']=qs[_0x38ba('0x1f')](_0x2a5ef1['query']['offset']);}return _0x4a93fc['getConfigurations'](_0x275d82);}})[_0x38ba('0x28')](function(_0x681cb1){if(_0x681cb1){return _0x681cb1?{'count':_0x2b2714,'rows':_0x681cb1}:null;}})['then'](respondWithResult(_0x296d41,null))[_0x38ba('0x46')](handleError(_0x296d41,null));};exports[_0x38ba('0x50')]=function(_0x40bb85,_0x3f052a,_0x17f14e){if(_0x40bb85[_0x38ba('0x4d')]['id']){delete _0x40bb85['body']['id'];}return db['SugarcrmAccount'][_0x38ba('0x4f')]({'where':{'id':_0x40bb85[_0x38ba('0x48')]['id']}})[_0x38ba('0x28')](handleEntityNotFound(_0x3f052a,null))['then'](function(_0x264778){if(_0x264778){_0x40bb85[_0x38ba('0x4d')]['AccountId']=_0x264778['id'];_0x40bb85[_0x38ba('0x4d')]['Subjects']=integrations[_0x38ba('0x51')](_0x40bb85['body'][_0x38ba('0x52')],_0x40bb85[_0x38ba('0x4d')][_0x38ba('0x53')]);_0x40bb85[_0x38ba('0x4d')][_0x38ba('0x54')]=integrations[_0x38ba('0x55')](_0x40bb85['body'][_0x38ba('0x52')],_0x40bb85['body'][_0x38ba('0x53')]);return db[_0x38ba('0x56')][_0x38ba('0x4c')](_0x40bb85[_0x38ba('0x4d')],{'include':[{'model':db['SugarcrmField'],'as':_0x38ba('0x57')},{'model':db[_0x38ba('0x58')],'as':_0x38ba('0x54')}]});}return null;})['then'](respondWithResult(_0x3f052a,null))[_0x38ba('0x46')](handleError(_0x3f052a,null));};exports[_0x38ba('0x59')]=function(_0x4b4737,_0x4d433a,_0x4578ff){var _0x328164='';var _0x1b4e2e=['id',_0x38ba('0x2c'),_0x38ba('0x5a'),_0x38ba('0x5b'),_0x38ba('0x5c'),_0x38ba('0x5d'),_0x38ba('0x5e'),'duration_minutes',_0x38ba('0x5f'),_0x38ba('0x60'),_0x38ba('0x61'),_0x38ba('0x62')];return db[_0x38ba('0x2f')][_0x38ba('0x4f')]({'where':{'id':_0x4b4737[_0x38ba('0x48')]['id']},'attributes':['id',_0x38ba('0x63'),_0x38ba('0x64'),'remoteUri']})['then'](handleEntityNotFound(_0x4d433a,null))[_0x38ba('0x28')](function(_0x1c009f){if(_0x1c009f){_0x328164=_0x1c009f[_0x38ba('0x65')];var _0x201a60=_0x328164[_0x38ba('0x66')](-0x1);if(_0x201a60==='/'){_0x328164=_0x328164[_0x38ba('0x67')](0x0,_0x328164[_0x38ba('0x68')](_0x201a60));}return rp({'method':_0x38ba('0x69'),'uri':util[_0x38ba('0x6a')](_0x38ba('0x6b'),_0x328164,_0x38ba('0x6c')),'json':!![],'form':{'method':'login','input_type':'JSON','response_type':_0x38ba('0x6d'),'rest_data':JSON[_0x38ba('0x6e')]({'user_auth':{'user_name':_0x1c009f[_0x38ba('0x63')],'password':_0x1c009f[_0x38ba('0x64')],'encryption':'PLAIN'},'application':_0x38ba('0x6f')})}});}})['then'](function(_0x3ea0e5){if(_0x3ea0e5&&_0x3ea0e5[_0x38ba('0x2c')]!=='Invalid\x20Login'&&_0x3ea0e5[_0x38ba('0x2c')]!==_0x38ba('0x70')){return rp({'method':_0x38ba('0x69'),'uri':util[_0x38ba('0x6a')]('%s%s',_0x328164,_0x38ba('0x6c')),'json':!![],'form':{'method':_0x38ba('0x71'),'input_type':'JSON','response_type':_0x38ba('0x6d'),'rest_data':JSON['stringify']({'session':_0x3ea0e5['id'],'module_name':_0x38ba('0x72')})}})[_0x38ba('0x28')](function(_0x54a9ef){if(_0x54a9ef){var _0x33791a=_[_0x38ba('0x73')](_0x54a9ef['module_fields']);_[_0x38ba('0x74')](_0x33791a,function(_0x37e60e){return _0x1b4e2e['includes'](_0x37e60e['name']);});return{'count':_0x33791a['length'],'rows':_[_0x38ba('0x2e')](_0x33791a,function(_0x37a363){return{'id':_0x37a363[_0x38ba('0x2c')],'name':_0x37a363['label'],'custom':_[_0x38ba('0x75')](_0x37a363[_0x38ba('0x2c')],'_c')?!![]:![],'options':_0x37a363[_0x38ba('0x41')]?_[_0x38ba('0x2e')](_[_0x38ba('0x73')](_0x37a363[_0x38ba('0x41')]),function(_0x38da86){return{'name':_0x38da86[_0x38ba('0x76')],'value':_0x38da86[_0x38ba('0x2c')]};}):[]};})};}})[_0x38ba('0x28')](respondWithResult(_0x4d433a,null))[_0x38ba('0x46')](function(_0x2b1d76){var _0x480fb2=_0x4b4737[_0x38ba('0x32')][_0x38ba('0x77')]?0x1f4:_0x2b1d76['statusCode']||0x1f4;logger[_0x38ba('0x2a')](_0x38ba('0x78'),_0x38ba('0x59'),_0x480fb2,JSON['stringify'](_0x2b1d76));delete _0x2b1d76[_0x38ba('0x2c')];if(_0x480fb2===0x191){_0x480fb2=0x190;}_0x4d433a[_0x38ba('0x1c')](_0x480fb2)[_0x38ba('0x2d')](_0x4b4737['query'][_0x38ba('0x77')]?{'message':_0x38ba('0x79'),'statusCode':_0x2b1d76[_0x38ba('0x7a')]}:_0x2b1d76);});}else{var _0x6cc1bf=0x1f4;_0x4d433a[_0x38ba('0x1c')](_0x6cc1bf)['send']({'message':_0x38ba('0x79'),'statusCode':0x190});}});};
\ No newline at end of file