npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

playbasis.js

v1.4.6

Published

Playbasis Javascript SDK

Downloads

11

Readme

npm version npm version

Playbasis Native JS SDK

Playbasis.js allows developers to connect and utilize Playbasis API with Javascript with Promise support.

Development

The development uses git branching model approach, this applies to when you add a new feature and making a new release.

  • Clone the project, then npm install to install all dependencies to be ready to begin development.
  • Add API support especially in src/api/api.xxx.js according to which API you're targeting to support for Playbasis end-point. You can take a look at Playbasis Live Doc to see which end-point the end-point isn't supported yet.
  • Write test case (we use jasmine for finished feature you've added in test/api.xxx.test.js.
  • Make sure tests pass by executing npm run unittest.
  • When need to publish to NPM, execute npm publish. This will begin build process, and automatically generate documentation of SDK in which it will push to remote gh-pages branch.
  • You're done!

Available Commands

The following commands can be executed separately. But normally you will just follow steps in Development section above.

  • npm run test or npm run uniitest - run unittest for all tests inside test/ directory
  • npm run build - build the project. This will create distribution files inside dist/
  • npm run doc - generate documentation based on comments on each function in source file.
  • npm run deploy - this command should be run after npm run doc. It will copy generated document directory then commit and push to remote gh-pages branch serving live documentation there. You can see it at https://playbasis.github.io/native-sdk-js/.

Deployment needs ghp-import to be installed on your system. You can install it by executing pip install ghp-import. That's it. When you executed command in Available Commands section, it will be used automatically.

How to Use

Get it via npm

Execute npm install playbasis.js or npm install --save playbasis.js.

Import it in your source file as follows.

var Playbasis = require('playbasis.js');

Get it via manual build

Create a distribution of library file included a minified version by executing gulp build. It will create Playbasis.js and Playbasis.min.js in ./dist folder. Include it in your source code via

<script src="dist/Playbasis.min.js"></script>

Usage

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 Playbasis Dashboard.

Playbasis.builder
		.setApiKey("<YOUR-API-KEY-HERE>")
		.setApiSecret("<YOUR-API-SECRET-HERE>")
		.build();

Then you're free to call other apis.

Get player's public information.

Playbasis.playerApi.playerPublicInfo("jon")
	.then((result) => {
		console.log(result);
	})
	.error((e) => {
		console.log(e.code + ": " + e.message);
	});

Execute rule engine click action for player id jon. This rule is set up via Playbasis Dashboard to give dynamic reward upon executing the call. By specify reward, and quantity we can customize reward and its amount to give to player.

Playbasis.engineApi.rule("click", "jon", {reward: "point", quantity: 20})
	.then((result) => {
		console.log(result);
	})
	.error((e) => {
		console.log(e.code + ": " + e.message);
	});

Document

There's many more apis you can call. There're 2 options for you.

  • Generate it manually via npm run doc. Document will be generated at docs/ thus you can look at it offline.
  • Go to live document (generated and deployed using commands represented in Available Commands section) at https://playbasis.github.io/native-sdk-js/. We update it against every release. Thus it's always latest.

License

Playbasis.js is available under the MIT license.