UNPKG

playbasis.js

Version:
279 lines (196 loc) 12 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Documentation Index</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"> <section class="readme-section"> <article><p><a href="https://badge.fury.io/js/playbasis.js"><img src="https://badge.fury.io/js/playbasis.js.svg" alt="npm version"></a> <a href="https://github.com/playbasis/native-sdk-js/blob/master/LICENSE.md"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="npm version"></a></p> <h1>Playbasis Native JS SDK</h1><p>Playbasis.js allows developers to connect and utilize <a href="http://doc.playbasis.com/pbapp">Playbasis API</a> with Javascript with Promise support.</p> <h1>Development</h1><p>The development uses <a href="http://nvie.com/posts/a-successful-git-branching-model/">git branching model</a> approach, this applies to when you add a new feature and making a new release.</p> <ul> <li>Clone the project, then <code>npm install</code> to install all dependencies to be ready to begin development.</li> <li>Add API support especially in <code>src/api/api.xxx.js</code> according to which API you're targeting to support for Playbasis end-point. You can take a look at <a href="http://doc.playbasis.com/pbapp">Playbasis Live Doc</a> to see which end-point the end-point isn't supported yet.</li> <li>Write test case (we use <a href="https://jasmine.github.io/">jasmine</a> for finished feature you've added in <code>test/api.xxx.test.js</code>.</li> <li>Make sure tests pass by executing <code>npm run unittest</code>.</li> <li>When need to publish to NPM, execute <code>npm publish</code>. This will begin build process, and automatically generate documentation of SDK in which it will push to remote <code>gh-pages</code> branch.</li> <li>You're done!</li> </ul> <h1>Available Commands</h1><p>The following commands can be executed separately. But normally you will just follow steps in <em>Development</em> section above.</p> <ul> <li><code>npm run test</code> or <code>npm run uniitest</code> - run unittest for all tests inside <code>test/</code> directory</li> <li><code>npm run build</code> - build the project. This will create distribution files inside <code>dist/</code></li> <li><code>npm run doc</code> - generate documentation based on comments on each function in source file.</li> <li><code>npm run deploy</code> - this command should be run after <code>npm run doc</code>. It will copy generated document directory then commit and push to remote <code>gh-pages</code> branch serving live documentation there. You can see it at <a href="https://.playbasis.github.io/native-sdk-js/">https://playbasis.github.io/native-sdk-js/</a>.</li> </ul> <blockquote> <p>Deployment needs <a href="https://github.com/davisp/ghp-import">ghp-import</a> to be installed on your system. You can install it by executing <code>pip install ghp-import</code>. That's it. When you executed command in <em>Available Commands</em> section, it will be used automatically.</p> </blockquote> <h1>How to Use</h1><h2>Get it via <code>npm</code></h2><p>Execute <code>npm install playbasis.js</code> or <code>npm install --save playbasis.js</code>.</p> <p>Import it in your source file as follows.</p> <pre class="prettyprint source lang-javascript"><code>var Playbasis = require('playbasis.js');</code></pre><h2>Get it via manual build</h2><p>Create a distribution of library file included a minified version by executing <code>gulp build</code>. It will create <code>Playbasis.js</code> and <code>Playbasis.min.js</code> in <code>./dist</code> folder. Include it in your source code via</p> <pre class="prettyprint source lang-javascript"><code>&lt;script src=&quot;dist/Playbasis.min.js&quot;>&lt;/script></code></pre><h2>Usage</h2><p>Create Playbasis's environment first before calling APIs via the following call. Get your apikey, and apisecret by registering a new account, and creating a new application at <a href="https://www.pbapp.net/login">Playbasis Dashboard</a>.</p> <pre class="prettyprint source lang-javascript"><code>Playbasis.builder .setApiKey(&quot;&lt;YOUR-API-KEY-HERE>&quot;) .setApiSecret(&quot;&lt;YOUR-API-SECRET-HERE>&quot;) .build();</code></pre><p>Then you're free to call other apis.</p> <p>Get player's public information.</p> <pre class="prettyprint source lang-javascript"><code>Playbasis.playerApi.playerPublicInfo(&quot;jon&quot;) .then((result) => { console.log(result); }) .error((e) => { console.log(e.code + &quot;: &quot; + e.message); });</code></pre><p>Execute rule engine <code>click</code> action for player id <code>jon</code>. This rule is set up via Playbasis Dashboard to give dynamic reward upon executing the call. By specify <code>reward</code>, and <code>quantity</code> we can customize reward and its amount to give to player.</p> <pre class="prettyprint source lang-javascript"><code>Playbasis.engineApi.rule(&quot;click&quot;, &quot;jon&quot;, {reward: &quot;point&quot;, quantity: 20}) .then((result) => { console.log(result); }) .error((e) => { console.log(e.code + &quot;: &quot; + e.message); });</code></pre><h1>Document</h1><p>There's many more apis you can call. There're 2 options for you.</p> <ul> <li>Generate it manually via <code>npm run doc</code>. Document will be generated at <code>docs/</code> thus you can look at it offline.</li> <li>Go to live document (generated and deployed using commands represented in <em>Available Commands</em> section) at <a href="https://playbasis.github.io/native-sdk-js/">https://playbasis.github.io/native-sdk-js/</a>. We update it against every release. Thus it's always latest.</li> </ul> <h1>License</h1><p>Playbasis.js is available under the <a href="https://github.com/playbasis/native-sdk-js/blob/master/LICENSE.md">MIT license</a>.</p></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">&times;</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.4.3</a> on September 6th 2017, 3:37:41 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>