# @datafire/whapi_sessions

> DataFire integration for Sessions API

Latest version **5.0.0** (published 2020-12-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @datafire/whapi_sessions
pnpm add @datafire/whapi_sessions
yarn add @datafire/whapi_sessions
bun add @datafire/whapi_sessions
```

## 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 | 5.0.0 |
| Published | 2020-12-21 |
| First published | 2017-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 29.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 135 |
| Author | DataFire |
| Maintainers | datafire |

## Links

- npm: https://www.npmjs.com/package/@datafire/whapi_sessions
- Repository: https://github.com/DataFire/integrations
- Homepage: https://github.com/DataFire/integrations#readme
- Issues: https://github.com/DataFire/integrations/issues
- npm.io page: https://npm.io/package/@datafire/whapi_sessions

## Dependencies (1)

- [datafire](https://npm.io/package/datafire.md) ^2.0.0

## Recent versions

- 5.0.0 (latest) — 2020-12-21
- 4.0.0 — 2018-06-12
- 3.0.0 — 2018-02-16
- 2.0.0 — 2017-12-04

## README

# @datafire/whapi_sessions

Client library for Sessions API

## Installation and Usage
```bash
npm install --save @datafire/whapi_sessions
```
```js
let whapi_sessions = require('@datafire/whapi_sessions').create();

.then(data => {
  console.log(data);
});
```

## Description

The William Hill Sessions API uses a central authentication service (CAS*) on all resources that require access to a customer’s account or betting functionality. To authenticate, you’ll need to supply a sportsbook username and password, in return you will be given an authentication ticket, which you can use on the majority of requests found within our services. <br /><br /><br /> The Sessions API should be used whenever you want to login a customer and:<br /><br /> <ul> <li>continue to use the William Hill API for that customer’s transactions</li> <li>use other CAS-enabled William Hill services outside the suite of APIs</li> </ul> <br /> CAS is an enterprise Single Sign-On solution for web services (see https://wiki.jasig.org/display/CAS/Home). It is used by many William Hill services. <br /> Note: all requests must be executed over HTTPS and include an API key and secret.<br /><br /><br /> <b>Authentication Ticket Expiration Times</b><br /><br /> When a customer is logged in using the Sessions API, they are given an Authentication Ticket; using this ticket on subsequent API requests gives you access to account activities (such as placing a bet, deposits, etc). However, this ticket is only valid for a given period of time depending on how it is used. If the ticket is used and then has a period of inactivity longer than 7,200 seconds (2 hours), then the ticket will expire and further requests using the ticket will be denied - in effect, a customer has been logged out and will need to authenticate again. <br /><br /><br /> Normally, any ticket issued only has a maximum life expectancy of 28,000 seconds (8 hours) after which it can no longer be used, even if it has been used regularly. The customer again will be effectively logged out and will need to authenticate again. If you wish to avoid this, you need to set the query parameter extended to Y, which will enable your application to generate a ticket valid for 60 days without expiring due to inactivity. <br />

## Actions

### logIn
Logs in a customer by obtaining an authentication ticket. It can then be used directly with the other William Hill APIs to access a customer’s sportsbook account, place a bet, etc. 


```js
whapi_sessions.logIn({
  "apiKey": "",
  "apiSecret": "",
  "login": {
    "username": "",
    "password": ""
  }
}, context)
```

#### Input
* input `object`
  * apiKey **required** `string`: A unique identifier of your application that is generated by the API portal.
  * apiSecret **required** `string`: Another unique identifier for your application.
  * fields `array`: Specify an absolute field list to return (Comma Separated List)
  * include `array`: Specify fields in addition to the default to return (Comma Separated List)
  * exclude `array`: Specify fields from the default to exclude (Comma Separated List)
  * territory `string`: Territory from which request originates
  * languageAsPerTerritory `string`: Defines response field name language, true (default) returns in language defined by territory, false returns in English
  * login **required** [loginRequest](#loginrequest)

#### Output
* output [session](#session)

### logOut
Logs out a customer.


```js
whapi_sessions.logOut({
  "apiKey": "",
  "apiSecret": "",
  "tgt": ""
}, context)
```

#### Input
* input `object`
  * apiKey **required** `string`: A unique identifier of your application that is generated by the API portal.
  * apiSecret **required** `string`: Another unique identifier for your application.
  * tgt **required** `string`: Ticket Granting Ticket obtained from a previous request
  * territory `string`: Territory from which request originates
  * languageAsPerTerritory `string`: Defines response field name language, true (default) returns in language defined by territory, false returns in English

#### Output
* output [logoutresponse](#logoutresponse)

### validateSession
Checks the validity of a session ticket.


```js
whapi_sessions.validateSession({
  "apiKey": "",
  "apiSecret": "",
  "tgt": ""
}, context)
```

#### Input
* input `object`
  * apiKey **required** `string`: A unique identifier of your application that is generated by the API portal.
  * apiSecret **required** `string`: Another unique identifier for your application.
  * tgt **required** `string`: Ticket Granting Ticket obtained from a previous request
  * territory `string`: Territory from which request originates
  * languageAsPerTerritory `string`: Defines response field name language, true (default) returns in language defined by territory, false returns in English

#### Output
* output [ticketvalidityresponse](#ticketvalidityresponse)

### getServiceTicket
Obtains a one-time Service Ticket that can be used to access other CAS enabled William Hill services that are not available through the standard suite of APIs. You first need to have logged in a customer to obtain an Authentication Ticket.


```js
whapi_sessions.getServiceTicket({
  "apiKey": "",
  "apiSecret": "",
  "tgt": "",
  "target": ""
}, context)
```

#### Input
* input `object`
  * apiKey **required** `string`: A unique identifier of your application that is generated by the API portal.
  * apiSecret **required** `string`: Another unique identifier for your application.
  * tgt **required** `string`: Ticket Granting Ticket obtained from a previous request
  * territory `string`: Territory from which request originates
  * languageAsPerTerritory `string`: Defines response field name language, true (default) returns in language defined by territory, false returns in English
  * target **required** `string`: The target URL of the CAS enabled service that you want to use with the service ticket.
  * fields `array`: Specify an absolute field list to return (Comma Separated List)
  * include `array`: Specify fields in addition to the default to return (Comma Separated List)
  * exclude `array`: Specify fields from the default to exclude (Comma Separated List)

#### Output
* output [serviceTicket](#serviceticket)



## Definitions

### error
* error `object`
  * code `string`: A unique William Hill identifier for the error
  * field `string`: To help pinpoint the exact parameter where a request has failed
  * message `string`: A unique William Hill text string to enable you to identify the error

### loginRequest
* loginRequest `object`
  * extended `boolean`: Whether extended login or normal login is required. If the parameter is set to Y your application will generate an authentication ticket valid for a period of 60 days, without expiring due to inactivity. If the parameter is left blank or set to N this means your application will support the normal expiry times for tickets: The ticket expires after 2 hours of inactivity. The ticket is valid for a maximum of 8 hours after it has been issued.
  * password **required** `string`: Customer Password
  * username **required** `string`: Customer Username

### logoutresponse
* logoutresponse `object`
  * success `boolean`

### serviceTicket
* serviceTicket `object`
  * location `string`: This is the URL of the target service sent in the request. This is a combination of the endpoint and the ticket for future operations such as DELETE.
  * ticket **required** `string`: The TGT ticket

### session
* session `object`
  * expiryDateTime **required** `string`: The UTC time when the ticket expires.
  * extended `boolean`: The value you have selected previous to executing the request. If the value is Y, this enables your application to generate a ticket valid for 60 days without expiring due to inactivity.
  * location `string`: This is the URL of the target service sent in the request. This is a combination of the endpoint and the ticket for future operations such as DELETE.
  * temporaryPassword `boolean`: Indicates that the account has a temporary password set and hence the user must be prompted to change their password.
  * temporaryPasswordUrl `string`: Url for user to change password. A TGT must be added to the URL
  * ticket **required** `string`: The TGT ticket

### sessionsErrors
* sessionsErrors `object`
  * errors `array`
    * items [error](#error)

### ticketvalidityresponse
* ticketvalidityresponse `object`
  * valid `boolean`

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