Front End

Integration

To get the game up and running you will need to insert this snippet on the page where you want the game platform to be loaded:


    
<div class="scout-games-wrapper"> <view-port></view-port> </div> <script src="https://customer-scripts.assets.scoutgg-stg.net/customer-client/application.js" data-white-label="customer" data-environment="staging" > </script>

    
<div class="scout-games-wrapper"> <view-port></view-port> </div> <script src="https://customer-scripts.assets.scoutgg.net/customer-client/application.js" data-white-label="customer" data-environment="production" > </script>

This will bootstrap the Scout Gaming Platform and it will render inside the view-port HTML tag. The dataset can be used to override default configurations. For instance if you need to change the language to ukranian, you can override the config option by setting data-lang="ua".

Configuration options

Config Parameter Data parameter(script tag) Options Default Comment
environment data-environment staging, production production Which environment to load
currency data-currency Any ISO 4217 supported code EUR
whiteLabel data-white-label customer none Is required. Will be provided to you by your key account manager.
token data-token none none Token should be generated when a user is logged in and passed to this parameter. If a token is present the platform will assume a user is logged in.
basePath data-base-path none / Should be the base path to the game. For instance /sports/fantasy/. Base path should always have a trailing slash.
root data-root Any URL https://fantasy-game.api.scoutgg-stg.net URL to game server.
ws data-ws Any URL https://fantasy-game.ws.scoutgg-stg.net URL to web socket server.
assetHost data-asset-host Any URL https://fantasy.assets.scoutgg.net URL to assets(icons etc).
lang data-lang
  • cs - Czech
  • de - German
  • el - Greek
  • en - English
  • es - Spanish
  • et - Estonian
  • fi - Finnish
  • hi - Hindi
  • hy - Armenian
  • id - Indonesian
  • it - Italian
  • km - Khmer
  • ko - Korean
  • lv - Latvian
  • nl - Dutch
  • no - Norwegian
  • pl - Polish
  • pt - Portuguese
  • ro - Romanian
  • ru - Russian
  • se - se
  • sk - Slovak
  • sv - Swedish
  • th - Thai
  • tr - Turkish
  • vi - Vietnamese
  • zh - Chinese
en - English

Scout Widgets API

The Widgets API is a way to change configuration parameters after the script has bootstrapped. After boostrapping window.ftWidgets will be available. ftWidgets contains a few helper functions, including the config scheme.


    
// Accessible in the browser after Scout Gaming // platform has bootstraped { "page": Function, // Access to the Scout UI Router "renderSite": Function, // Trigger a repaint of all visible components "config": Object, // Access all configuration parameters "models": Object // Access to all models used }

You can change the configuration options on the fly. Example:


    
// Guard the API (check that its bootstrapped) if(window.ftWidgets) { window.ftWidgets.config.lang = 'ru' window.ftWidgets.renderSite() // Re-render elements }

Authentication

Authentication is done by passing a JWT Token to the token config parameter. A secret to sign the JWT token will be provided to you by your key account manager. For more information on JWT you can see jwt.io. Generating the token must happen server side to not expose the secret in the frontend. The token should include the following payload:


    
{ id: String, // The unique identifier of your user username: String, // A username that is displayed in the game exp: Number, // Expiry of the token. Unix timestamp (seconds). iat: Number, // Issued at. Timestamp of when the token was generated. }

Node.js Express example of generating token.


    
const jwt = require('jsonwebtoken') const moment = require('moment') const config = require('../config') const db = require('../services/database-connection') module.exports = async function getToken(req, res, next) { const user = await db.query(`SELECT * FROM users WHERE id = ${req.user.id}`) const payload = { id: user.id, username: user.username, exp: +moment().add(1, 'hour').format('X'), // Unix timestamp iat: +moment().format('X'), // Unix timestamp } const token = jwt.sign(payload, config.secret) res.send(token) }