playbasis
Version:
Playbasis Javascript SDK
1,525 lines (509 loc) • 20.2 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Documentation Namespace: helpers</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Documentation</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="Playbasis.html">Playbasis</a></li><li><a href="Playbasis.authApi.html">Playbasis.authApi</a></li><li><a href="Playbasis.badgeApi.html">Playbasis.badgeApi</a></li><li><a href="Playbasis.barCode.html">Playbasis.barCode</a></li><li><a href="Playbasis.builder.html">Playbasis.builder</a></li><li><a href="Playbasis.communicationApi.html">Playbasis.communicationApi</a></li><li><a href="Playbasis.const.html">Playbasis.const</a></li><li><a href="Playbasis.contentApi.html">Playbasis.contentApi</a></li><li><a href="Playbasis.engineApi.html">Playbasis.engineApi</a></li><li><a href="Playbasis.goodsApi.html">Playbasis.goodsApi</a></li><li><a href="Playbasis.helpers.html">Playbasis.helpers</a></li><li><a href="Playbasis.http.html">Playbasis.http</a></li><li><a href="Playbasis.livefeedApi.html">Playbasis.livefeedApi</a></li><li><a href="Playbasis.merchantApi.html">Playbasis.merchantApi</a></li><li><a href="Playbasis.playerApi.html">Playbasis.playerApi</a></li><li><a href="Playbasis.pointApi.html">Playbasis.pointApi</a></li><li><a href="Playbasis.qrCode.html">Playbasis.qrCode</a></li><li><a href="Playbasis.questApi.html">Playbasis.questApi</a></li><li><a href="Playbasis.quizApi.html">Playbasis.quizApi</a></li><li><a href="Playbasis.redeemApi.html">Playbasis.redeemApi</a></li><li><a href="Playbasis.serviceApi.html">Playbasis.serviceApi</a></li><li><a href="Playbasis.storeOrganizeApi.html">Playbasis.storeOrganizeApi</a></li><li><a href="Playbasis.util.html">Playbasis.util</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-8">
<div id="main">
<h1 class="page-title">Namespace: helpers</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="Playbasis.html">Playbasis</a>.</span>
helpers
</h2>
</header>
<article>
<div class="container-overview">
<div class="description"><p>Playbasis Helpers</p></div>
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<dl>
<hr>
<dt>
<h4 class="name" id=".appendAndJoinIfNotNullAsUrlParam"><span class="type-signature"><static> </span>appendAndJoinIfNotNullAsUrlParam(param)</h4>
</dt>
<dd>
<div class="description">
<p>Join variable url param together as query string, then prefix it with "&" if there's at least one non-null key-value pair.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>param</code></td>
<td class="type">
<span class="param-type">param</span>
</td>
<td class="attributes">
<repeatable><br>
</td>
<td class="description last"><p>url param as part of url</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>query string</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".appendAndJoinIfNotNullAsUrlParam2"><span class="type-signature"><static> </span>appendAndJoinIfNotNullAsUrlParam2(keys, defaultValues, inputObj)</h4>
</dt>
<dd>
<div class="description">
<p>Join variable url param together as query string, then prefix it with "&" if there's at least one non-null key-value pair.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>keys</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"><p>Array containing all keys string</p></td>
</tr>
<tr>
<td class="name"><code>defaultValues</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"><p>Array containing all default values string</p></td>
</tr>
<tr>
<td class="name"><code>inputObj</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>Input optional object parameter, inside there're key-value pairs according to key and values of final query string</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>query string</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".combinedObjects"><span class="type-signature"><static> </span>combinedObjects(objA, objB)</h4>
</dt>
<dd>
<div class="description">
<p>Combine two objects together but skip key-value pair whose either key or value is null.
If both of objects are null, then return empty object.
If object B has same keys as in object A, object A's values will be replaced by values of object B.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>objA</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>object A to combine</p></td>
</tr>
<tr>
<td class="name"><code>objB</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>object B to combine</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Combined object A and B but skipped key-value pair whose either key or value is null</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".createApiUrl"><span class="type-signature"><static> </span>createApiUrl(method, param)</h4>
</dt>
<dd>
<div class="description">
<p>Create api url for used with Playbasis's API modules.
If you use this, make sure you know what you're doing.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>method</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>method url for target API</p></td>
</tr>
<tr>
<td class="name"><code>param</code></td>
<td class="type">
<span class="param-type">param</span>
</td>
<td class="attributes">
<repeatable><br>
</td>
<td class="description last"><p>url param as part of url</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>url ready to be used to make a qurey for Playbasis's API modules</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".createObjectFromTarget"><span class="type-signature"><static> </span>createObjectFromTarget(obj, keysLimit)</h4>
</dt>
<dd>
<div class="description">
<p>Create object with keys and values from specified object.
If 'keysLimit' is specified then it will only copy for those matching keys only, and ignore the less.
It will ignore and skip key-value pair whose either key or value is null.
It specified object is null, then it will create an empty object.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>obj</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"><p>target object to get keys and values from in order to create a new object</p></td>
</tr>
<tr>
<td class="name"><code>keysLimit</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"><p>(optional) keys as array to limit the copying process from target object</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>new object created with non-null keys and values from specified object</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".joinIfNotNullAsUrlParam"><span class="type-signature"><static> </span>joinIfNotNullAsUrlParam(param)</h4>
</dt>
<dd>
<div class="description">
<p>Join variable url param together as query string.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>param</code></td>
<td class="type">
<span class="param-type">param</span>
</td>
<td class="attributes">
<repeatable><br>
</td>
<td class="description last"><p>url param as part of url</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>query string</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".joinParams"><span class="type-signature"><static> </span>joinParams(paramKvp)</h4>
</dt>
<dd>
<div class="description">
<p>Join each key of object into querystring and return it.
It will iterate for all keys of its object, and process each pair of KVP making into final querystring.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>paramKvp</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>options object</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>query string</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-3">
<div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
</div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a>
on August 23rd 2019, 1:59:06 pm
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>