b80dee8eaf03d539b70bd9c0b09f73900592be52
[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 _0x4f95=['substring','lastIndexOf','validateEmail','test','lodash','getString','length','sortBy','type','push','content','variable','variableName','toString','customVariable','Variable','name','toLowerCase','keyValue','keyType','key','format','keyContent','join','stripTrailingSlash'];(function(_0x2e76a7,_0x23871a){var _0x454cde=function(_0x51724d){while(--_0x51724d){_0x2e76a7['push'](_0x2e76a7['shift']());}};_0x454cde(++_0x23871a);}(_0x4f95,0x9a));var _0x54f9=function(_0x32a91b,_0x5c6a01){_0x32a91b=_0x32a91b-0x0;var _0x35ea56=_0x4f95[_0x32a91b];return _0x35ea56;};'use strict';var _=require(_0x54f9('0x0'));var util=require('util');exports[_0x54f9('0x1')]=function(_0x49de5f,_0x4744f7,_0x14e941){var _0x27c503=[];if(_0x49de5f[_0x54f9('0x2')]>0x0){var _0x48a083=_[_0x54f9('0x3')](_0x49de5f,['id']);for(var _0x371df8=0x0;_0x371df8<_0x48a083['length'];_0x371df8++){var _0x26e1f5=_0x48a083[_0x371df8];if(_0x26e1f5[_0x54f9('0x4')]==='string'){_0x27c503[_0x54f9('0x5')](_0x26e1f5[_0x54f9('0x6')]);}else if(_0x26e1f5[_0x54f9('0x4')]===_0x54f9('0x7')&&_0x26e1f5[_0x54f9('0x8')]){_0x4744f7[_0x26e1f5[_0x54f9('0x8')]]&&_0x27c503[_0x54f9('0x5')](_0x4744f7[_0x26e1f5[_0x54f9('0x8')]][_0x54f9('0x9')]());}else if(_0x26e1f5[_0x54f9('0x4')]===_0x54f9('0xa')&&_0x26e1f5['Variable']&&_0x26e1f5[_0x54f9('0xb')][_0x54f9('0xc')]){_0x4744f7[_0x26e1f5[_0x54f9('0xb')][_0x54f9('0xc')][_0x54f9('0xd')]()]&&_0x27c503['push'](_0x4744f7[_0x26e1f5['Variable']['name'][_0x54f9('0xd')]()][_0x54f9('0x9')]());}else if(_0x26e1f5['type']===_0x54f9('0xe')){if(_0x26e1f5[_0x54f9('0xf')]==='string'&&_0x26e1f5[_0x54f9('0x10')]){_0x27c503['push'](util[_0x54f9('0x11')]('%s:\x20%s',_0x26e1f5[_0x54f9('0x10')],_0x26e1f5[_0x54f9('0x12')]));}else if(_0x26e1f5[_0x54f9('0xf')]===_0x54f9('0x7')&&_0x26e1f5[_0x54f9('0x8')]&&_0x26e1f5[_0x54f9('0x10')]){_0x4744f7[_0x26e1f5[_0x54f9('0x8')]]&&_0x27c503[_0x54f9('0x5')](util['format']('%s:\x20%s',_0x26e1f5['key'],_0x4744f7[_0x26e1f5[_0x54f9('0x8')]]));}else if(_0x26e1f5[_0x54f9('0xf')]===_0x54f9('0xa')&&_0x26e1f5[_0x54f9('0xb')]&&_0x26e1f5[_0x54f9('0xb')]['name']&&_0x26e1f5[_0x54f9('0x10')]){_0x4744f7[_0x26e1f5['Variable']['name'][_0x54f9('0xd')]()]&&_0x27c503['push'](util[_0x54f9('0x11')]('%s:\x20%s',_0x26e1f5[_0x54f9('0x10')],_0x4744f7[_0x26e1f5['Variable'][_0x54f9('0xc')][_0x54f9('0xd')]()]));}}}}return _0x27c503[_0x54f9('0x13')](_0x14e941);};exports[_0x54f9('0x14')]=function(_0x28f94a){var _0x4f7a04=_0x28f94a['slice'](-0x1);if(_0x4f7a04==='/'){_0x28f94a=_0x28f94a[_0x54f9('0x15')](0x0,_0x28f94a[_0x54f9('0x16')](_0x4f7a04));}return _0x28f94a;};exports[_0x54f9('0x17')]=function(_0x4f12a1){if(!_['isNil'](_0x4f12a1)&&_0x4f12a1!==''){var _0x2d7e8c=/^(([^<>()\[\]\\.,;:\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 _0x2d7e8c[_0x54f9('0x18')](String(_0x4f12a1)['toLowerCase']());}else{return![];}};