5f01fa2454b89814f65e55a31364ff6469b2c07c
[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 _0xdb3d=['variableName','toString','customVariable','Variable','name','toLowerCase','keyValue','keyType','key','%s:\x20%s','format','join','lastIndexOf','isNil','test','lodash','util','getString','length','sortBy','string','push','content','type','variable'];(function(_0x41273c,_0x4c0c04){var _0x453ce4=function(_0x5504e9){while(--_0x5504e9){_0x41273c['push'](_0x41273c['shift']());}};_0x453ce4(++_0x4c0c04);}(_0xdb3d,0x73));var _0xddb3=function(_0x15a099,_0x4eb0c1){_0x15a099=_0x15a099-0x0;var _0x8f248c=_0xdb3d[_0x15a099];return _0x8f248c;};'use strict';var _=require(_0xddb3('0x0'));var util=require(_0xddb3('0x1'));exports[_0xddb3('0x2')]=function(_0x464d71,_0x38eece,_0x52e715){var _0x57ad16=[];if(_0x464d71[_0xddb3('0x3')]>0x0){var _0x7a73f=_[_0xddb3('0x4')](_0x464d71,['id']);for(var _0x360dfb=0x0;_0x360dfb<_0x7a73f[_0xddb3('0x3')];_0x360dfb++){var _0x100dfb=_0x7a73f[_0x360dfb];if(_0x100dfb['type']===_0xddb3('0x5')){_0x57ad16[_0xddb3('0x6')](_0x100dfb[_0xddb3('0x7')]);}else if(_0x100dfb[_0xddb3('0x8')]===_0xddb3('0x9')&&_0x100dfb[_0xddb3('0xa')]){_0x38eece[_0x100dfb[_0xddb3('0xa')]]&&_0x57ad16[_0xddb3('0x6')](_0x38eece[_0x100dfb[_0xddb3('0xa')]][_0xddb3('0xb')]());}else if(_0x100dfb[_0xddb3('0x8')]===_0xddb3('0xc')&&_0x100dfb[_0xddb3('0xd')]&&_0x100dfb[_0xddb3('0xd')][_0xddb3('0xe')]){_0x38eece[_0x100dfb['Variable'][_0xddb3('0xe')][_0xddb3('0xf')]()]&&_0x57ad16[_0xddb3('0x6')](_0x38eece[_0x100dfb[_0xddb3('0xd')][_0xddb3('0xe')][_0xddb3('0xf')]()]['toString']());}else if(_0x100dfb['type']===_0xddb3('0x10')){if(_0x100dfb[_0xddb3('0x11')]==='string'&&_0x100dfb[_0xddb3('0x12')]){_0x57ad16[_0xddb3('0x6')](util['format'](_0xddb3('0x13'),_0x100dfb['key'],_0x100dfb['keyContent']));}else if(_0x100dfb['keyType']==='variable'&&_0x100dfb[_0xddb3('0xa')]&&_0x100dfb[_0xddb3('0x12')]){_0x38eece[_0x100dfb[_0xddb3('0xa')]]&&_0x57ad16[_0xddb3('0x6')](util[_0xddb3('0x14')](_0xddb3('0x13'),_0x100dfb[_0xddb3('0x12')],_0x38eece[_0x100dfb[_0xddb3('0xa')]]));}else if(_0x100dfb[_0xddb3('0x11')]===_0xddb3('0xc')&&_0x100dfb[_0xddb3('0xd')]&&_0x100dfb[_0xddb3('0xd')][_0xddb3('0xe')]&&_0x100dfb[_0xddb3('0x12')]){_0x38eece[_0x100dfb[_0xddb3('0xd')][_0xddb3('0xe')][_0xddb3('0xf')]()]&&_0x57ad16[_0xddb3('0x6')](util[_0xddb3('0x14')](_0xddb3('0x13'),_0x100dfb['key'],_0x38eece[_0x100dfb['Variable']['name'][_0xddb3('0xf')]()]));}}}}return _0x57ad16[_0xddb3('0x15')](_0x52e715);};exports['stripTrailingSlash']=function(_0x428632){var _0x25c93c=_0x428632['slice'](-0x1);if(_0x25c93c==='/'){_0x428632=_0x428632['substring'](0x0,_0x428632[_0xddb3('0x16')](_0x25c93c));}return _0x428632;};exports['validateEmail']=function(_0x1af738){if(!_[_0xddb3('0x17')](_0x1af738)&&_0x1af738!==''){var _0x22f8ea=/^(([^<>()\[\]\\.,;:\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 _0x22f8ea[_0xddb3('0x18')](String(_0x1af738)[_0xddb3('0xf')]());}else{return![];}};