b79bfc49f73912778800b5b33dc175ad8682a82e
[motion2.git] / server / services / ami / trigger / integration / util.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 _0x5019=['Variable','name','toLowerCase','keyValue','keyType','key','format','%s:\x20%s','join','slice','lastIndexOf','isNil','test','util','getString','length','sortBy','type','string','content','variable','variableName','push','toString','customVariable'];(function(_0x433f01,_0x4b8594){var _0x35c353=function(_0x53ef5d){while(--_0x53ef5d){_0x433f01['push'](_0x433f01['shift']());}};_0x35c353(++_0x4b8594);}(_0x5019,0x8a));var _0x9501=function(_0x52ecff,_0x2cba3a){_0x52ecff=_0x52ecff-0x0;var _0x1347b7=_0x5019[_0x52ecff];return _0x1347b7;};'use strict';var _=require('lodash');var util=require(_0x9501('0x0'));exports[_0x9501('0x1')]=function(_0x4470ff,_0x1a4032,_0x3a04ef){var _0x2da407=[];if(_0x4470ff[_0x9501('0x2')]>0x0){var _0x11c5aa=_[_0x9501('0x3')](_0x4470ff,['id']);for(var _0x48fe0c=0x0;_0x48fe0c<_0x11c5aa[_0x9501('0x2')];_0x48fe0c++){var _0x11b963=_0x11c5aa[_0x48fe0c];if(_0x11b963[_0x9501('0x4')]===_0x9501('0x5')){_0x2da407['push'](_0x11b963[_0x9501('0x6')]);}else if(_0x11b963[_0x9501('0x4')]===_0x9501('0x7')&&_0x11b963['variableName']){_0x1a4032[_0x11b963[_0x9501('0x8')]]&&_0x2da407[_0x9501('0x9')](_0x1a4032[_0x11b963[_0x9501('0x8')]][_0x9501('0xa')]());}else if(_0x11b963[_0x9501('0x4')]===_0x9501('0xb')&&_0x11b963[_0x9501('0xc')]&&_0x11b963['Variable'][_0x9501('0xd')]){_0x1a4032[_0x11b963[_0x9501('0xc')]['name'][_0x9501('0xe')]()]&&_0x2da407['push'](_0x1a4032[_0x11b963[_0x9501('0xc')][_0x9501('0xd')][_0x9501('0xe')]()][_0x9501('0xa')]());}else if(_0x11b963[_0x9501('0x4')]===_0x9501('0xf')){if(_0x11b963[_0x9501('0x10')]===_0x9501('0x5')&&_0x11b963[_0x9501('0x11')]){_0x2da407[_0x9501('0x9')](util[_0x9501('0x12')](_0x9501('0x13'),_0x11b963[_0x9501('0x11')],_0x11b963['keyContent']));}else if(_0x11b963[_0x9501('0x10')]===_0x9501('0x7')&&_0x11b963[_0x9501('0x8')]&&_0x11b963[_0x9501('0x11')]){_0x1a4032[_0x11b963['variableName']]&&_0x2da407[_0x9501('0x9')](util[_0x9501('0x12')]('%s:\x20%s',_0x11b963[_0x9501('0x11')],_0x1a4032[_0x11b963['variableName']]));}else if(_0x11b963['keyType']==='customVariable'&&_0x11b963[_0x9501('0xc')]&&_0x11b963[_0x9501('0xc')][_0x9501('0xd')]&&_0x11b963[_0x9501('0x11')]){_0x1a4032[_0x11b963['Variable'][_0x9501('0xd')][_0x9501('0xe')]()]&&_0x2da407[_0x9501('0x9')](util[_0x9501('0x12')](_0x9501('0x13'),_0x11b963[_0x9501('0x11')],_0x1a4032[_0x11b963[_0x9501('0xc')]['name'][_0x9501('0xe')]()]));}}}}return _0x2da407[_0x9501('0x14')](_0x3a04ef);};exports['stripTrailingSlash']=function(_0x4657ce){var _0x370cb7=_0x4657ce[_0x9501('0x15')](-0x1);if(_0x370cb7==='/'){_0x4657ce=_0x4657ce['substring'](0x0,_0x4657ce[_0x9501('0x16')](_0x370cb7));}return _0x4657ce;};exports['validateEmail']=function(_0xcecd35){if(!_[_0x9501('0x17')](_0xcecd35)&&_0xcecd35!==''){var _0x5bd52a=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return _0x5bd52a[_0x9501('0x18')](String(_0xcecd35)['toLowerCase']());}else{return![];}};