c9c9eb1c00dc3e4ef05031e4ee83e65138620e23
[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 _0x45e1=['validateEmail','test','lodash','util','getString','length','type','push','content','toString','customVariable','Variable','toLowerCase','name','keyType','string','format','%s:\x20%s','key','variable','variableName','join','lastIndexOf'];(function(_0x2064e5,_0x4f6fa2){var _0x21a233=function(_0x1b2491){while(--_0x1b2491){_0x2064e5['push'](_0x2064e5['shift']());}};_0x21a233(++_0x4f6fa2);}(_0x45e1,0xff));var _0x145e=function(_0x6386f,_0x49eba4){_0x6386f=_0x6386f-0x0;var _0x1102dc=_0x45e1[_0x6386f];return _0x1102dc;};'use strict';var _=require(_0x145e('0x0'));var util=require(_0x145e('0x1'));exports[_0x145e('0x2')]=function(_0x2ae12f,_0x4a978d,_0x19ecd7){var _0x1b31c4=[];if(_0x2ae12f[_0x145e('0x3')]>0x0){var _0x316d25=_['sortBy'](_0x2ae12f,['id']);for(var _0x34d6c6=0x0;_0x34d6c6<_0x316d25[_0x145e('0x3')];_0x34d6c6++){var _0x2ae2d1=_0x316d25[_0x34d6c6];if(_0x2ae2d1[_0x145e('0x4')]==='string'){_0x1b31c4[_0x145e('0x5')](_0x2ae2d1[_0x145e('0x6')]);}else if(_0x2ae2d1[_0x145e('0x4')]==='variable'&&_0x2ae2d1['variableName']){_0x4a978d[_0x2ae2d1['variableName']]&&_0x1b31c4[_0x145e('0x5')](_0x4a978d[_0x2ae2d1['variableName']][_0x145e('0x7')]());}else if(_0x2ae2d1[_0x145e('0x4')]===_0x145e('0x8')&&_0x2ae2d1[_0x145e('0x9')]&&_0x2ae2d1['Variable']['name']){_0x4a978d[_0x2ae2d1['Variable']['name'][_0x145e('0xa')]()]&&_0x1b31c4[_0x145e('0x5')](_0x4a978d[_0x2ae2d1[_0x145e('0x9')][_0x145e('0xb')][_0x145e('0xa')]()][_0x145e('0x7')]());}else if(_0x2ae2d1['type']==='keyValue'){if(_0x2ae2d1[_0x145e('0xc')]===_0x145e('0xd')&&_0x2ae2d1['key']){_0x1b31c4[_0x145e('0x5')](util[_0x145e('0xe')](_0x145e('0xf'),_0x2ae2d1[_0x145e('0x10')],_0x2ae2d1['keyContent']));}else if(_0x2ae2d1[_0x145e('0xc')]===_0x145e('0x11')&&_0x2ae2d1[_0x145e('0x12')]&&_0x2ae2d1[_0x145e('0x10')]){_0x4a978d[_0x2ae2d1['variableName']]&&_0x1b31c4[_0x145e('0x5')](util[_0x145e('0xe')](_0x145e('0xf'),_0x2ae2d1[_0x145e('0x10')],_0x4a978d[_0x2ae2d1[_0x145e('0x12')]]));}else if(_0x2ae2d1[_0x145e('0xc')]===_0x145e('0x8')&&_0x2ae2d1[_0x145e('0x9')]&&_0x2ae2d1['Variable'][_0x145e('0xb')]&&_0x2ae2d1[_0x145e('0x10')]){_0x4a978d[_0x2ae2d1[_0x145e('0x9')][_0x145e('0xb')][_0x145e('0xa')]()]&&_0x1b31c4[_0x145e('0x5')](util[_0x145e('0xe')](_0x145e('0xf'),_0x2ae2d1['key'],_0x4a978d[_0x2ae2d1[_0x145e('0x9')][_0x145e('0xb')]['toLowerCase']()]));}}}}return _0x1b31c4[_0x145e('0x13')](_0x19ecd7);};exports['stripTrailingSlash']=function(_0x17f0ca){var _0x2c8b26=_0x17f0ca['slice'](-0x1);if(_0x2c8b26==='/'){_0x17f0ca=_0x17f0ca['substring'](0x0,_0x17f0ca[_0x145e('0x14')](_0x2c8b26));}return _0x17f0ca;};exports[_0x145e('0x15')]=function(_0x7afeac){if(!_['isNil'](_0x7afeac)&&_0x7afeac!==''){var _0x93ab8b=/^(([^<>()\[\]\\.,;:\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 _0x93ab8b[_0x145e('0x16')](String(_0x7afeac)['toLowerCase']());}else{return![];}};