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

trial-sdk

v0.1.5

Published

NodeJS SDK

Downloads

5

Readme

Gameball NodeJS SDK


The Gameball NodeJS SDK provides convinient access to the Gameball API frpm applicatopns written in the JavaScript langauage.

Documentation


Please refer to the Gameball API docs.

Installation


You don't need this source code unless you want to modify the SDK. If you just want to use the SDK, just run:

npm install gameball-nodejs-sdk

Requirements

Usage


The SDK needs to be configured with your account's API & Transaction keys available in your Gameball Dashboard

Require 'gameball-nodejs-sdk' in your file

var gameball = require('gameball-nodejs-sdk')

Create a handler using the api key and transaction key (optional field), then call commands on it.

var Gameball = new gameball(apikey, transactionkey)

Commands:

Gameball.initializePlayer(PlayerRequest, callback) //creates a new player with the given player attributes.

Gameball.sendEvent(EventRequest, callback) //performs action based on event triggered by users.

Gameball.createReferral(ReferralRequest, callback) //refers a new user through player with the given player code.

Gameball.getPlayerBalance(PlayerBalanceRequest, callback) //obtains player's balance value.

Gameball.holdPoints(HoldPointsRequest, callback) //holds a specific amount of points from the player’s points balance. 

Gameball.reverseHold(ReverseHoldRequest, callback) //cancels previously held points identified by the given hold reference. 

Gameball.reverseTransaction(ReverseTransaction, callback) //cancels a purchase reward or refund a points redemption transactions in Gameball.

Gameball.redeemPoints(RedeemPointsRequest, callback) //enables the player to use Gameball points as a payment method since it can be substituted for monetary values.

Gameball.rewardPoints(RewardPointsRequest, callback) //rewards a player with points equivalent to the given amount.

Examples

Sending an Event Example

Gameball.sendEvent({
        "events":{
                "reserve":{
                        "rooms":2
                  }
        },
        "playerUniqueId":" player123",
        "playerAttributes":{
                "displayName":" Jon Snow",
                "email":"[email protected]",
                "dateOfBirth":"1980-09-19T00:00:00.000Z",
                "joinDate":"2019-09-19T21:06:29.158Z"
        }
})

Gameball.sendEvent({
        "events":{
                "place_order":  {
                      "total_amount":"100",
                      "category":[
                         "electronics",
                         "cosmetics"
                                 ]
                },
                "review":{}
        },
        "playerUniqueId":"1596487841748"
})

Create a Referral Example

Gameball.createReferral({
        "playerCode":"CODE11",
        "playerUniqueId":"player456"
})

Gameball.createReferral({
        "playerCode":"CODE11",
        "playerUniqueId":"player456",
        "playerAttributes":{
                "displayName":" Tyrion Lannister",
                "firstName":"Tyrion",
                "lastName":"Lannister",
                "email":"[email protected]",
                "gender":"M",
                "dateOfBirth":"1978-01-11T00:00:00.000Z",
                "joinDate":"2019-09-19T21:06:29.158Z",
                "custom":{
                        "location":"Miami",
                        "graduationDate":"2018-07-04T21:06:29.158Z",
                        "isMarried":false
                }
        }
})

Reward Examples

Gameball.rewardPoints({
        "playerUniqueId":"player123",
        "amount":99.98
})

Gameball.rewardPoints({
        "playerUniqueId":"player456",
        "amount":2500,
        "playerAttributes":{
                "displayName":" Tyrion Lannister",
                "firstName":"Tyrion",
                "lastName":"Lannister",
                "email":"[email protected]",
                "gender":"M",
                "dateOfBirth":"1978-01-11T00:00:00.000Z",
                "joinDate":"2019-09-19T21:06:29.158Z",
                "custom":{
                        "location":"Miami",
                        "graduationDate":"2018-07-04T21:06:29.158Z",
                        "isMarried":false
                }
        }
})

Get Player Balance Example

Gameball.getPlayerBalance({
        "playerUniqueId":"player456"
})

Hold Points Example

Gameball.holdPoints({
        "playerUniqueId":"player456",
        "amount":98.89
})

Redeem Example

Gameball.redeemPoints({
        "playerUniqueId":"player456",
        "amount":10,
        "holdReference":"2342452352435234"
})

Reverse Transaction Example

Gameball.reverseTransaction({
        "playerUniqueId":"player456",
        "transactionId":"1234567890",
        "reversedTransactionId":"234567891"
})

Reverse Hold Example

Gameball.reverseHold({
        "playerUniqueId":" player456",
        "holdReference":"9245fe4a-d402-451c-b9ed-9c1a04247482"
})

Handling exceptions

Unsuccessful requests raise exceptions. The raised exception will reflect the sort of error that occurred with appropriate message and error code . Please refer to the Gameball API docs.

Contribution


The master branch of this repository contains the latest stable release of the SDK.

Contact


For usage questions\suggestions drop us an email at support[ at ]gameball.co. Please report any bugs as issues.