7702facc843150eaf2657023da4b3838b4f46392
[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 _0x8cdc=['util','getString','sortBy','length','type','variable','variableName','push','toString','Variable','name','toLowerCase','keyValue','keyType','key','keyContent','format','%s:\x20%s','slice','substring','lastIndexOf','validateEmail','test','lodash'];(function(_0x39e84d,_0x11931d){var _0x1991bc=function(_0xc81e32){while(--_0xc81e32){_0x39e84d['push'](_0x39e84d['shift']());}};_0x1991bc(++_0x11931d);}(_0x8cdc,0xa7));var _0xc8cd=function(_0x55d17b,_0x9aabe8){_0x55d17b=_0x55d17b-0x0;var _0xf6a458=_0x8cdc[_0x55d17b];return _0xf6a458;};'use strict';var _=require(_0xc8cd('0x0'));var util=require(_0xc8cd('0x1'));exports[_0xc8cd('0x2')]=function(_0x5bc653,_0x3209b1,_0xa3cdb){var _0x44e6cc=[];if(_0x5bc653['length']>0x0){var _0x232d2a=_[_0xc8cd('0x3')](_0x5bc653,['id']);for(var _0x404033=0x0;_0x404033<_0x232d2a[_0xc8cd('0x4')];_0x404033++){var _0x198cec=_0x232d2a[_0x404033];if(_0x198cec[_0xc8cd('0x5')]==='string'){_0x44e6cc['push'](_0x198cec['content']);}else if(_0x198cec[_0xc8cd('0x5')]===_0xc8cd('0x6')&&_0x198cec[_0xc8cd('0x7')]){_0x3209b1[_0x198cec[_0xc8cd('0x7')]]&&_0x44e6cc[_0xc8cd('0x8')](_0x3209b1[_0x198cec['variableName']][_0xc8cd('0x9')]());}else if(_0x198cec[_0xc8cd('0x5')]==='customVariable'&&_0x198cec[_0xc8cd('0xa')]&&_0x198cec['Variable'][_0xc8cd('0xb')]){_0x3209b1[_0x198cec['Variable'][_0xc8cd('0xb')][_0xc8cd('0xc')]()]&&_0x44e6cc[_0xc8cd('0x8')](_0x3209b1[_0x198cec[_0xc8cd('0xa')][_0xc8cd('0xb')][_0xc8cd('0xc')]()][_0xc8cd('0x9')]());}else if(_0x198cec[_0xc8cd('0x5')]===_0xc8cd('0xd')){if(_0x198cec[_0xc8cd('0xe')]==='string'&&_0x198cec[_0xc8cd('0xf')]){_0x44e6cc[_0xc8cd('0x8')](util['format']('%s:\x20%s',_0x198cec[_0xc8cd('0xf')],_0x198cec[_0xc8cd('0x10')]));}else if(_0x198cec[_0xc8cd('0xe')]==='variable'&&_0x198cec[_0xc8cd('0x7')]&&_0x198cec[_0xc8cd('0xf')]){_0x3209b1[_0x198cec['variableName']]&&_0x44e6cc[_0xc8cd('0x8')](util[_0xc8cd('0x11')](_0xc8cd('0x12'),_0x198cec['key'],_0x3209b1[_0x198cec[_0xc8cd('0x7')]]));}else if(_0x198cec['keyType']==='customVariable'&&_0x198cec[_0xc8cd('0xa')]&&_0x198cec[_0xc8cd('0xa')]['name']&&_0x198cec[_0xc8cd('0xf')]){_0x3209b1[_0x198cec['Variable'][_0xc8cd('0xb')][_0xc8cd('0xc')]()]&&_0x44e6cc[_0xc8cd('0x8')](util['format']('%s:\x20%s',_0x198cec[_0xc8cd('0xf')],_0x3209b1[_0x198cec[_0xc8cd('0xa')][_0xc8cd('0xb')][_0xc8cd('0xc')]()]));}}}}return _0x44e6cc['join'](_0xa3cdb);};exports['stripTrailingSlash']=function(_0x3c3eea){var _0x31c074=_0x3c3eea[_0xc8cd('0x13')](-0x1);if(_0x31c074==='/'){_0x3c3eea=_0x3c3eea[_0xc8cd('0x14')](0x0,_0x3c3eea[_0xc8cd('0x15')](_0x31c074));}return _0x3c3eea;};exports[_0xc8cd('0x16')]=function(_0x2744ca){if(!_['isNil'](_0x2744ca)&&_0x2744ca!==''){var _0xa8ee26=/^(([^<>()\[\]\\.,;:\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 _0xa8ee26[_0xc8cd('0x17')](String(_0x2744ca)[_0xc8cd('0xc')]());}else{return![];}};