8d29fcec3f7726959832751db7c7462985c32348
[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 _0xb1f7=['validateEmail','isNil','lodash','getString','length','type','string','content','variableName','toString','customVariable','Variable','name','toLowerCase','push','keyType','key','%s:\x20%s','keyContent','format'];(function(_0x44dbc2,_0x333e80){var _0x4e4bed=function(_0x3f4a52){while(--_0x3f4a52){_0x44dbc2['push'](_0x44dbc2['shift']());}};_0x4e4bed(++_0x333e80);}(_0xb1f7,0x7a));var _0x7b1f=function(_0x5056d9,_0x1f678c){_0x5056d9=_0x5056d9-0x0;var _0x166f29=_0xb1f7[_0x5056d9];return _0x166f29;};'use strict';var _=require(_0x7b1f('0x0'));var util=require('util');exports[_0x7b1f('0x1')]=function(_0x996cd0,_0x45c538,_0x451c9a){var _0x58b4ea=[];if(_0x996cd0[_0x7b1f('0x2')]>0x0){var _0x4e8cbd=_['sortBy'](_0x996cd0,['id']);for(var _0x1552d6=0x0;_0x1552d6<_0x4e8cbd[_0x7b1f('0x2')];_0x1552d6++){var _0x5576dc=_0x4e8cbd[_0x1552d6];if(_0x5576dc[_0x7b1f('0x3')]===_0x7b1f('0x4')){_0x58b4ea['push'](_0x5576dc[_0x7b1f('0x5')]);}else if(_0x5576dc[_0x7b1f('0x3')]==='variable'&&_0x5576dc[_0x7b1f('0x6')]){_0x45c538[_0x5576dc[_0x7b1f('0x6')]]&&_0x58b4ea['push'](_0x45c538[_0x5576dc[_0x7b1f('0x6')]][_0x7b1f('0x7')]());}else if(_0x5576dc[_0x7b1f('0x3')]===_0x7b1f('0x8')&&_0x5576dc['Variable']&&_0x5576dc[_0x7b1f('0x9')][_0x7b1f('0xa')]){_0x45c538[_0x5576dc[_0x7b1f('0x9')][_0x7b1f('0xa')][_0x7b1f('0xb')]()]&&_0x58b4ea[_0x7b1f('0xc')](_0x45c538[_0x5576dc['Variable']['name']['toLowerCase']()][_0x7b1f('0x7')]());}else if(_0x5576dc[_0x7b1f('0x3')]==='keyValue'){if(_0x5576dc[_0x7b1f('0xd')]===_0x7b1f('0x4')&&_0x5576dc[_0x7b1f('0xe')]){_0x58b4ea[_0x7b1f('0xc')](util['format'](_0x7b1f('0xf'),_0x5576dc[_0x7b1f('0xe')],_0x5576dc[_0x7b1f('0x10')]));}else if(_0x5576dc[_0x7b1f('0xd')]==='variable'&&_0x5576dc[_0x7b1f('0x6')]&&_0x5576dc['key']){_0x45c538[_0x5576dc[_0x7b1f('0x6')]]&&_0x58b4ea['push'](util[_0x7b1f('0x11')](_0x7b1f('0xf'),_0x5576dc['key'],_0x45c538[_0x5576dc['variableName']]));}else if(_0x5576dc[_0x7b1f('0xd')]===_0x7b1f('0x8')&&_0x5576dc[_0x7b1f('0x9')]&&_0x5576dc[_0x7b1f('0x9')][_0x7b1f('0xa')]&&_0x5576dc[_0x7b1f('0xe')]){_0x45c538[_0x5576dc[_0x7b1f('0x9')]['name'][_0x7b1f('0xb')]()]&&_0x58b4ea['push'](util[_0x7b1f('0x11')]('%s:\x20%s',_0x5576dc[_0x7b1f('0xe')],_0x45c538[_0x5576dc[_0x7b1f('0x9')][_0x7b1f('0xa')][_0x7b1f('0xb')]()]));}}}}return _0x58b4ea['join'](_0x451c9a);};exports['stripTrailingSlash']=function(_0x50ccfa){var _0x39c9b9=_0x50ccfa['slice'](-0x1);if(_0x39c9b9==='/'){_0x50ccfa=_0x50ccfa['substring'](0x0,_0x50ccfa['lastIndexOf'](_0x39c9b9));}return _0x50ccfa;};exports[_0x7b1f('0x12')]=function(_0x50dcca){if(!_[_0x7b1f('0x13')](_0x50dcca)&&_0x50dcca!==''){var _0x5dd502=/^(([^<>()\[\]\\.,;:\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 _0x5dd502['test'](String(_0x50dcca)[_0x7b1f('0xb')]());}else{return![];}};