1.4.6 • Published 7 years ago

playbasis.js v1.4.6

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

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.

1.4.6

7 years ago

1.4.5

7 years ago

1.4.4

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.12

7 years ago

1.3.11

7 years ago

1.3.10

7 years ago

1.3.9

7 years ago

1.3.8

7 years ago

1.3.7

7 years ago

1.3.6

7 years ago

1.3.5

7 years ago

1.3.4

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago