# the-nodejs-sdk

> Gameball NodeJS SDK

Latest version **0.1.5** (published 2020-08-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install the-nodejs-sdk
pnpm add the-nodejs-sdk
yarn add the-nodejs-sdk
bun add the-nodejs-sdk
```

Provides the command `techietime`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2020-08-11 |
| First published | 2020-08-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 36.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gameball |
| Maintainers | mariamheikal |
| Keywords | gameball, nodejs, node, sdk |

## Links

- npm: https://www.npmjs.com/package/the-nodejs-sdk
- Repository: https://gameballers@dev.azure.com/gameballers/GB-NodeJs-SDK/_git/GB-NodeJs-SDK
- npm.io page: https://npm.io/package/the-nodejs-sdk

## Dependencies (4)

- [sha1](https://npm.io/package/sha1.md) ^1.1.1
- [https](https://npm.io/package/https.md) ^1.0.0
- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [querystring](https://npm.io/package/querystring.md) ^0.2.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2020-08-11
- 0.1.4 — 2020-08-11
- 0.1.0 — 2020-08-11

## README

# **Gameball NodeJS SDK**
---
This repository contains the open source SDK for integrating Gameball's API into your NodeJs app. 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](https://docs.gameball.co).
## 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:
```js
npm install gameball-nodejs-sdk
```
## Usage
---
The SDK needs to be configured with your account's API & Transaction keys available in your [Gameball Dashboard](https://help.gameball.co/en/articles/3467114-get-your-account-integration-details-api-key-and-transaction-key)

Require 'gameball-nodejs-sdk' in your file
```js
var gameball = require('gameball-nodejs-sdk')
```
Create a handler using the api key and transaction key (optional field), then call commands on it.
```js
var Gameball = new gameball(apikey, transactionkey)
```
### Commands:
```js
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
```js
Gameball.sendEvent({
        "events":{
                "reserve":{
                        "rooms":2
                  }
        },
        "playerUniqueId":" player123",
        "playerAttributes":{
                "displayName":" Jon Snow",
                "email":"jon.snow@example.com",
                "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
```js
Gameball.createReferral({
        "playerCode":"CODE11",
        "playerUniqueId":"player456"
})

Gameball.createReferral({
        "playerCode":"CODE11",
        "playerUniqueId":"player456",
        "playerAttributes":{
                "displayName":" Tyrion Lannister",
                "firstName":"Tyrion",
                "lastName":"Lannister",
                "email":"tyrion@example.com",
                "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
```js
Gameball.rewardPoints({
        "playerUniqueId":"player123",
        "amount":99.98
})

Gameball.rewardPoints({
        "playerUniqueId":"player456",
        "amount":2500,
        "playerAttributes":{
                "displayName":" Tyrion Lannister",
                "firstName":"Tyrion",
                "lastName":"Lannister",
                "email":"tyrion@example.com",
                "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 
```js
Gameball.getPlayerBalance({
        "playerUniqueId":"player456"
})
```
#### Hold Points Example 
```js
Gameball.holdPoints({
        "playerUniqueId":"player456",
        "amount":98.89
})
```
#### Redeem Example 
```js
Gameball.redeemPoints({
        "playerUniqueId":"player456",
        "amount":10,
        "holdReference":"2342452352435234"
})
```
#### Reverse Transaction Example
```js
Gameball.reverseTransaction({
        "playerUniqueId":"player456",
        "transactionId":"1234567890",
        "reversedTransactionId":"234567891"
})
```
#### Reverse Hold Example
```js
Gameball.reverseHold({
        "playerUniqueId":" player456",
        "holdReference":"9245fe4a-d402-451c-b9ed-9c1a04247482"
})
```

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

---
_Source: https://npm.io/package/the-nodejs-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
