0.1.289 • Published 1 week ago
bb-api-platforma
Licence
MIT
Version
0.1.289
Deps
0
Size
1.0 MB
Vulns
0
Weekly
0
BetBooster API Platform
Module package for working with API of BetBooster platform.
Installation
To install the "bb-api-platforma" package, run the following command:
npm install bb-api-platforma
Usage
import axios from 'axios'
import { BetBoosterApi } from 'bb-api-platforma';
const axiosInstance = axios.create();
const apiRootUrl = 'https://api.example.com';
const defaultLanguage = 'en';
const maxTimeout = 15000;
const isDevelopmentMode = !!process.env.DEV;
const api = new BetBoosterApi(axiosInstance, apiRootUrl, defaultLanguage, maxTimeout, isDevelopmentMode);
const res = await api2.login({ login: 'login', password: 'password' });
console.log(res);
// ...
Presence tracker (Refferq)
PresenceTracker sends presence ticks, login/registration events, referral-link visits and code checks to Refferq. It lives next to BetBoosterApi and talks to it only through the duck-typed ApiLike interface (isSinged, user, srvTag); the API token is never sent. With an empty siteKey the tracker is disabled and all methods are silent.
import { BetBoosterApi, PresenceTracker, detectEnvironment } from 'bb-api-platforma';
const tracker = new PresenceTracker({
api, // BetBoosterApi instance
siteKey: 'pk_live_abc123', // Refferq site key; empty → disabled
trackUrl: 'https://api.example.com/affiliate', // official API + /affiliate
environment: detectEnvironment(), // or { client, device, os } from Quasar Platform.is
readUrlOnInit: true, // false for SPA with a router (call handleUrlCode yourself)
});
// login action
const res = await api.login({ login, password });
tracker.login(res.ok ? 'OK' : 'FAIL', res.ok ? undefined : res.errorCode);
if (res.ok) tracker.start();
// referral link ?ref=CODE (router)
router.beforeEach((to) => { if (typeof to.query.ref === 'string') tracker.handleUrlCode(to.query.ref); });
// code entered by the player
const check = await tracker.checkCode('PROMO10'); // { valid, kind, code, affiliateCode, ... }
const kind = await tracker.addCode('PROMO10'); // 'COUPON' | 'REFERRAL' | 'UNAVAILABLE' | null
// temporary registration → first login
const snapshot = await tracker.captureRegistrationSnapshot();
tracker.registration('OK', undefined, user.UserId, snapshot);
Options, methods and payloads are documented in the bundled d.ts. Tests: npm run test:presence (Node 22, tsx --test, no DOM).
Documentation
The documentation for the bb-api-platforma API can be found at the following link: https://betseller.gitlab.io/bb-api-platforma