npm package: @quattro-bet/sportsbook-control
Description: ## Install
Latest version: 1.0.21

# @quattro-bet/sportsbook-control

## Install

```bash
npm i  @quattro-bet/sportsbook-control
```

or 

```bash
yarn add  @quattro-bet/sportsbook-control
```

### Usage

#### 1. Add javascript file `sportsbookControl.js` from dist to your page:

```html
<script src="https://domain.com/sportsbookControl.js"></script>
```

Or import `sportsbookControl` from `node_modules`:
```javascript
import * as sportsbookControl from "@quattro-bet/sportsbook-control";
```

#### 2. Call `sportsbookControl.create()`: 
```javascript
/**
 * @param {Object} options
 * @return {Promise} Promise with the control object
 */
var promise = sportsbookControl.create(options);
```

Or via async/await:
```javascript
async function foo() {
  var control = await sportsbookControl.create(options);
}
```

#### Options

|Name                   |Type                |Description                                                            |
|-----------------------|--------------------|-----------------------------------------------------------------------|
|mountNode              |HTMLElement         |Node to create a sportsbook                                            |
|url                    |string              |Url to sportsbook                                                      |
|params                                                                                                              |
|  token                |string              |Partner system player token may be omitted when a player is not logged |
|  page                 |`live` or `prelive` |Sportsbook page, default value is `prelive`                            |
|  locale               |`tr_TR` or `en_US`  |Application locale, default value is `tr_TR`                           |
|  mobile               |boolean             |Mobile or desktop version, default value is `false`                    |
|  defaultCurrency      |string              |The default currency for unauthorized player, default value is `EUR`   |
|  timeZoneOffset       |number              |Timezone offset in milliseconds, browser timezone by default           |


#### Controller methods:

    changeParams(params: Object): void   - Change params.
    destroy(): Promise<void>             - Destroy sportsbook application.

#### Login/logout

For login logout players use `params.token`.

For example, when you want to create an application but the user is not logged, you should omit a token filed. When the user will be logged
call `control::changeParams` with token field.
```javascript
 control.changeParams({token: "user_token"})
```

When the user logout, call change params with null.

```javascript
 control.changeParams({token: null})
```

It's important to know that call `control::changeParams` with an empty object doesn't affect the application. If you want to delete some fields or a certain field, you should set its value equal to null.

#### Example:
```javascript
var div = document.createElement("div");
document.body.appendChild(div);
    
var promise = sportsbookControl.create({
  mountNode: div,
  url: "https://bet.domain.com",
  params: {
    page: "prelive",
    token: "n3add69a9-f2c1-4029-ba3b-946a12263c4a",
    locale: "tr_TR"
  }
});
```