# gamification-boksy-lib

> gamification-lib

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

## Install

```sh
npm install gamification-boksy-lib
pnpm add gamification-boksy-lib
yarn add gamification-boksy-lib
bun add gamification-boksy-lib
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.19 |
| Published | 2020-11-11 |
| First published | 2020-06-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Brane Petkoski |
| Maintainers | philosopher_mk |

## Links

- npm: https://www.npmjs.com/package/gamification-boksy-lib
- npm.io page: https://npm.io/package/gamification-boksy-lib

## Dependencies (1)

- [react-native-axios](https://npm.io/package/react-native-axios.md) ^0.17.1

## Recent versions

- 1.0.19 (latest) — 2020-11-11
- 1.0.18 — 2020-10-27
- 1.0.17 — 2020-10-27
- 1.0.16 — 2020-10-27
- 1.0.15 — 2020-10-27
- 1.0.14 — 2020-10-21
- 1.0.13 — 2020-10-19
- 1.0.12 — 2020-09-18
- 1.0.11 — 2020-09-18
- 1.0.10 — 2020-09-18
- 1.0.9 — 2020-09-16
- 1.0.8 — 2020-09-16
- 1.0.7 — 2020-09-16
- 1.0.6 — 2020-09-16
- 1.0.5 — 2020-09-15
- … 5 more at https://npm.io/package/gamification-boksy-lib/versions

## README

# gamification-boksy

Promise based gamification client for the browser and react native

## Features


Gamification client is simple library to minimize the complexity on front-end side



## Usage


```js
let gamification = require("gamification-boksy-lib");
```


## Initialization

```js
let user = "boksy"; // userId
let BASE_URL = "http://example.com/api/Stage"; // userId

gamification.init(user,BASE_URL)
```


## Sending Event

Events are predefined into constant so you can easily reuse them

```js
gamification.sendEvent(gamification.EVENTS.INFO).then(res => {
    console.log("res",res);
})



// or using await

let res = await gamification.sendEvent(gamification.EVENTS.INFO);

```

## Sending Session

Events are predefined into constant so you can easily reuse them

```js

readingSession {
  timeSpend : seconds,
  progress : %,
  bookId : string,
  userId : string
}
gamification.sendEbookSession(readingSession).then(res => {
    console.log("res",res);
})

gamification.sendAudioBookSession(readingSession).then(res => {
    console.log("res",res);
})

gamification.sendEbookFinished({userId,coins,bookId}).then(res => {
    console.log("res",res);
})



// or using await

let res = await gamification.sendEvent(gamification.EVENTS.INFO);

```

## Sample Response

```js
  data: {
    userId: 'boksy',
    level: '4',
    points: 500,
    achievements: [],
    avatars: [],
    trophies: [],
    coins: 100
  }
```

## Basic events
```js
    TEST
    INFO // this is getting user info
    READ_EBOOK
    START_READING
    CHANGED_AVATAR
    EBOOK_5_MIN: 
    EBOOK_COMPLETE
    AUDIOBOOK_5_MIN
    AUDIOBOOK_COMPLETE
    KNOWLEDGE_QUIZ_COMPLETE
    FACTS_QUIZ_COMPLETE
```

## Handling Errors

This is promise based library so you can handle error like simple promise
```js
gamification.sendEvent(gamification.EVENTS.INFO).then(res => {
    console.log("res",res);
}).catch(err => throw err);

```

## Usage as singleton

If you don't have multiple users at the same time and  you don't want to do

init every time, you can crete gamificationSingleton.js file with this content

```js
let gamification = require("gamification-boksy-lib");

let user = "boksy"; // your user id

gamification.init(user)

module.exports = gamification;
```

And then when you want to use it

```js
let gamification= require("./gamificationSingleton");


gamification.sendEvent(gamification.EVENTS.INFO).then(res => {
    console.log("res",res);
    
})
```

## Promises
If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).


## License

ICS

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