a43e21deece4a396b8c1a27bb7350bf4589c069c
[motion2.git] / server / services / ami / trigger / integration / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x087b=['format','%s\x20configuration\x20#%s\x20not\x20found','lodash','util','./sugarcrm','./zoho','./desk','./vtiger','./servicenow','./dynamics365','./freshsales','zendesk','salesforce','sugarcrm','freshdesk','zoho','desk','vtiger','dynamics365','freshsales','servicenow','exec','includes','data1','toLowerCase','data2','find','Configurations','data3','queue','routeId','log','EVENT\x20UNKNOWN','error','[EXEC]'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x087b,0x11a));var _0xb087=function(_0x5f309e,_0x66e31){_0x5f309e=_0x5f309e-0x0;var _0x487b5e=_0x087b[_0x5f309e];return _0x487b5e;};'use strict';var _=require(_0xb087('0x0'));var util=require(_0xb087('0x1'));var zendesk=require('./zendesk');var salesforce=require('./salesforce');var sugarcrm=require(_0xb087('0x2'));var freshdesk=require('./freshdesk');var zoho=require(_0xb087('0x3'));var desk=require(_0xb087('0x4'));var vtiger=require(_0xb087('0x5'));var servicenow=require(_0xb087('0x6'));var dynamics365=require(_0xb087('0x7'));var freshsales=require(_0xb087('0x8'));var integrations=[_0xb087('0x9'),_0xb087('0xa'),_0xb087('0xb'),_0xb087('0xc'),_0xb087('0xd'),_0xb087('0xe'),_0xb087('0xf'),_0xb087('0x10'),_0xb087('0x11'),_0xb087('0x12')];exports[_0xb087('0x13')]=function(_0x583d25,_0x244abc,_0x108451,_0x903a16,_0x3bce7a,_0x3b45c1){if(_0x108451){if(_[_0xb087('0x14')](integrations,_0x583d25[_0xb087('0x15')]['toLowerCase']())){try{var _0x189e2b=null;var _0x31f977='';var _0x323656=_0x108451[_0x583d25['data1'][_0xb087('0x16')]()];if(_0x323656){var _0x3f145e=_0x323656[_0x583d25[_0xb087('0x17')]];if(_0x3f145e){var _0x46410b=_[_0xb087('0x18')](_0x3f145e[_0xb087('0x19')],{'id':parseInt(_0x583d25[_0xb087('0x1a')],0xa)});if(_0x46410b){if(_0x903a16){if(_0x3bce7a&&_0x244abc[_0xb087('0x1b')]){_0x31f977=_0xb087('0x1b');}else if(_0x244abc[_0xb087('0x1c')]){_0x31f977='outbound';}else{console[_0xb087('0x1d')](_0xb087('0x1e'),_0x244abc);}}else{_0x31f977='unmanaged';}switch(_0x583d25[_0xb087('0x15')][_0xb087('0x16')]()){case _0xb087('0x9'):zendesk[_0x31f977](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1);break;case'salesforce':salesforce[_0x31f977](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1);break;case _0xb087('0xb'):sugarcrm[_0x31f977](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1);break;case _0xb087('0xc'):freshdesk[_0x31f977](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1);break;case _0xb087('0xd'):zoho[_0x31f977](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1);break;case _0xb087('0xe'):desk[_0x31f977](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1);break;case'vtiger':vtiger[_0x31f977](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1);break;case _0xb087('0x11'):freshsales['cs'](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1,_0x31f977);break;case _0xb087('0x12'):servicenow['cs'](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1,_0x31f977);break;case _0xb087('0x10'):dynamics365['cs'](_0x583d25,_0x244abc,_0x46410b,_0x903a16,_0x3bce7a,_0x3f145e,_0x3b45c1,_0x31f977);break;default:console[_0xb087('0x1d')]('unknown\x20integration');}}else{_0x189e2b=require('../../../../config/logger')(_0x583d25['data1']['toLowerCase']());_0x189e2b[_0xb087('0x1f')](_0xb087('0x20'),util[_0xb087('0x21')](_0xb087('0x22'),_0x583d25[_0xb087('0x15')][_0xb087('0x16')](),_0x583d25[_0xb087('0x1a')]));}}else{_0x189e2b=require('../../../../config/logger')(_0x583d25[_0xb087('0x15')][_0xb087('0x16')]());_0x189e2b[_0xb087('0x1f')](_0xb087('0x20'),util[_0xb087('0x21')]('%s\x20account\x20#%s\x20not\x20found',_0x583d25[_0xb087('0x15')][_0xb087('0x16')](),_0x583d25['data2']));}}else{}}catch(_0x5a2dc6){console['error'](_0x5a2dc6);}}}};