Built motion from commit da617fac.|2.6.6
[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 _0x761d=['key','%s:\x20%s','keyContent','keyType','format','slice','substring','lastIndexOf','validateEmail','isNil','test','length','sortBy','string','push','content','type','variable','variableName','toString','customVariable','Variable','name','toLowerCase'];(function(_0x2f8db3,_0x24b6c6){var _0x50b153=function(_0x3e4106){while(--_0x3e4106){_0x2f8db3['push'](_0x2f8db3['shift']());}};_0x50b153(++_0x24b6c6);}(_0x761d,0xcb));var _0xd761=function(_0x5cdc25,_0x2d1308){_0x5cdc25=_0x5cdc25-0x0;var _0x54d663=_0x761d[_0x5cdc25];return _0x54d663;};'use strict';var _=require('lodash');var util=require('util');exports['getString']=function(_0x40ed4b,_0x2413f8,_0x4af9fc){var _0x1907ca=[];if(_0x40ed4b[_0xd761('0x0')]>0x0){var _0x375635=_[_0xd761('0x1')](_0x40ed4b,['id']);for(var _0x156ac9=0x0;_0x156ac9<_0x375635[_0xd761('0x0')];_0x156ac9++){var _0xe93f4a=_0x375635[_0x156ac9];if(_0xe93f4a['type']===_0xd761('0x2')){_0x1907ca[_0xd761('0x3')](_0xe93f4a[_0xd761('0x4')]);}else if(_0xe93f4a[_0xd761('0x5')]===_0xd761('0x6')&&_0xe93f4a[_0xd761('0x7')]){_0x2413f8[_0xe93f4a[_0xd761('0x7')]]&&_0x1907ca[_0xd761('0x3')](_0x2413f8[_0xe93f4a['variableName']][_0xd761('0x8')]());}else if(_0xe93f4a['type']===_0xd761('0x9')&&_0xe93f4a['Variable']&&_0xe93f4a[_0xd761('0xa')][_0xd761('0xb')]){_0x2413f8[_0xe93f4a[_0xd761('0xa')][_0xd761('0xb')][_0xd761('0xc')]()]&&_0x1907ca[_0xd761('0x3')](_0x2413f8[_0xe93f4a['Variable'][_0xd761('0xb')][_0xd761('0xc')]()][_0xd761('0x8')]());}else if(_0xe93f4a['type']==='keyValue'){if(_0xe93f4a['keyType']===_0xd761('0x2')&&_0xe93f4a[_0xd761('0xd')]){_0x1907ca['push'](util['format'](_0xd761('0xe'),_0xe93f4a[_0xd761('0xd')],_0xe93f4a[_0xd761('0xf')]));}else if(_0xe93f4a[_0xd761('0x10')]===_0xd761('0x6')&&_0xe93f4a[_0xd761('0x7')]&&_0xe93f4a[_0xd761('0xd')]){_0x2413f8[_0xe93f4a[_0xd761('0x7')]]&&_0x1907ca[_0xd761('0x3')](util[_0xd761('0x11')](_0xd761('0xe'),_0xe93f4a[_0xd761('0xd')],_0x2413f8[_0xe93f4a['variableName']]));}else if(_0xe93f4a[_0xd761('0x10')]===_0xd761('0x9')&&_0xe93f4a['Variable']&&_0xe93f4a['Variable'][_0xd761('0xb')]&&_0xe93f4a[_0xd761('0xd')]){_0x2413f8[_0xe93f4a[_0xd761('0xa')][_0xd761('0xb')][_0xd761('0xc')]()]&&_0x1907ca[_0xd761('0x3')](util['format'](_0xd761('0xe'),_0xe93f4a[_0xd761('0xd')],_0x2413f8[_0xe93f4a['Variable'][_0xd761('0xb')][_0xd761('0xc')]()]));}}}}return _0x1907ca['join'](_0x4af9fc);};exports['stripTrailingSlash']=function(_0x1e6bd9){var _0x448efb=_0x1e6bd9[_0xd761('0x12')](-0x1);if(_0x448efb==='/'){_0x1e6bd9=_0x1e6bd9[_0xd761('0x13')](0x0,_0x1e6bd9[_0xd761('0x14')](_0x448efb));}return _0x1e6bd9;};exports[_0xd761('0x15')]=function(_0x129ffd){if(!_[_0xd761('0x16')](_0x129ffd)&&_0x129ffd!==''){var _0x20d1ff=/^(([^<>()\[\]\\.,;:\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 _0x20d1ff[_0xd761('0x17')](String(_0x129ffd)[_0xd761('0xc')]());}else{return![];}};