# JS Bundles Inputs - Outputs - Errors
## Bundle Operations Inputs
### Register Inputs
Provider
User
Callback
### Successful Register Outputs
Response
### Login
Provider
User
Callback
### Balance
Provider
User
Callback
### Get bet odds
Provider
User
Bet
Callback
### Place bet
Provider
User
Bet
Callback
### Bet history
Provider
User
Date
Callback
### Deposit
Provider
User
Callback
### Withdraw
Provider
User
Callback
### Stream
Provider
User
GameId
callback
### (Not implemented) Bonus
## Input Parameter Structures
### Provider
```swift=
static func request(_ request: [String: Any],
_ callback: JSValue,
_ operatorName: String)
static func formRequest(_ request: [String: Any],
_ callback: JSValue,
_ operatorName: String)
static func webRequest(_ url: String,
_ options: [String: Any],
_ callback: JSValue,
_ operatorName: String)
static func webView(_ url: String,
_ options: [String: Any],
_ callback: JSValue,
_ operatorName: String,
_ makedelay: Int)
static func clearCache(_ operatorName: String)
static func getCookies(_ operatorName: String) -> String
static func setParameter(_ operatorName: String,
_ key: String,
_ value: String)
static func getParameter(_ operatorName: String,
_ key: String) -> String
static func clearParameter(_ operatorName: String,
_ key: String)
static func clearAllParameters(_ operatorName: String)
static func openURL(_ url: String)
static func openBankID()
static func openPopup(_ key: String,
_ date: String,
_ callback: JSValue)
static func openTextInput(_ key: String,
_ callback: JSValue)
```
### User
An object containing the user information required for each function.
#### Register
```json=
{
"email": "helmutxl@gmail.com",
"ssn": "123456789",
"lastName": "Boman",
"gender": "Male",
"language": "swe",
"defaultBetAmount": "1.0",
"birthDate": "20 Oct 1972",
"telephoneCode": "46",
"mobileNumber": "767187133",
"currency": "SEK",
"username": "username",
"password": "mypassword",
"title": "Mr",
"firstName": "Stephen",
"addressStreet": "1003 Moore Avenue",
"addressCity": "Yardley",
"addressZipCode": "19067",
"addressState": "WV",
"addressCountry": "Sweden",
"deviceType": "2"
}
Note: The app stores months like so:
const appMonths = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
```
#### Other functions
All the functions except for register, expect this type of user
```json=
{
"username": "helmutxl",
"ssn": "111111111",
"password": "mypassword",
"deviceType": "2"
}
```
### Bet
#### Bet Odds
```json=
{
"gameId": "226964871",
"operatorTournamentId": "213131",
"betSide": "723591978",
"sportId": "1",
"isLive": "true"
}
```
#### Place Bet
```json=
{
"gameId": "226964871",
"operatorTournamentId": "213131",
"betType": "2",
"betSide": "723591978",
"betAmount": "1.00",
"odds": "1.00",
"sportId": "1",
"isLive": "true"
}
```
### Date
```json=
{
"dateFrom": "1989/05/18",
"dateTo": "2021/05/15",
}
```
### GameId
```
"gameId": "string"
```
### Callback
Callback function provided by the mobile application for the bundle to return to upon completion.
### Response
#### Successful Response
The applications should be able to check only the `success` field in order to know whether the bundle requested and got and response needed from the operators.
```json=
{
"name": "RESPONSE",
"success": "true",
"data": {},
"error": null,
"statusCode": "200",
"headers": {
"Content-Type": "application/json"
},
"log": [
{
"name": "REQUEST",
"url": "https://www.google.com",
"options": {
"method": "GET",
"encoding": "json",
"headers": {
"Accept": "*/*"
}
},
"headers": {
"Accept": "*/*"
}
}
]
}
```
#### Failed Response
```json=
{
"name": "RESPONSE",
"success": "false",
"data": null,
"error": {
"message": "Error Message",
"function": "1",
"type": "3"
},
"statusCode": "400",
"headers": {
"Content-Type": "application/json"
},
"log": [
{
"name": "REQUEST",
"url": "https://www.google.com",
"options": {
"method": "GET",
"encoding": "json",
"headers": {
"Accept": "*/*"
}
},
"headers": {
"Accept": "*/*"
}
}
]
}
```
### Data for successful responses
#### Register
```json=
{
"username": "myUsername",
"password": "myPassword"
}
```
#### Login
Empty data
#### Balance
```json=
{
"total": "0.00",
"withdrawable": "0.00",
"betCredits": "0.00",
"currencyCode": "USD",
}
```
#### Get bet odds
The numbers represent the ids of the odds for the specific selection
```json=
{
"submarketId": {
"oddsId": {
"odds": "1.50",
"decimal": "1.00",
"american": "-200",
"fractional": "0.5/1"
}
}
}
```
#### Place bet
```json=
{
"betReference" : "referenceId"
}
```
#### Bet history
Note: Bet History is called for any bets placed from the Oddsium app. It will **not** be called in regard to bets placed outside of the Oddsium app (for instance, a bet placed on the operator website will not be tracked within the app).
The application calls the betHistory function & provides parameters like so:
```
betHistory(provider, user, date, callback)
```
Provider, user & callback are self explanatory.
'date' is an object with dateTo & dateFrom keys. Each date is in DD/MM/YYYY format. The date's provided by the application cover the previous 2 week period.
```
{"dateFrom":"08/02/2022","dateTo":"02/03/2022"}
```
dateFrom: The date of the oldest un-settled bet from the operator that has concluded.
dateTo: The date of the most recent un-settled bet from the operator that has concluded.
The applications expect a JSON response including the status & reference like so:
```json=
{
"history": [
{
"betReference":"RS5024406510W",
"betStatus":"1"
},
{
"betReference":"RS5024406510E",
"betStatus":"2"
}
]
}
{
"betStatusCodes" {
open: '1',
won: '2',
lost: '3',
cancelled: '4',
void: '4'
};
}
```
#### Deposit
Note: Deposit triggers a webView to allow the user to control navigation. Because we cede control to the user, we cannot use JavaScript to indicate when the operation is complete. The iOS & Android apps listen for the webView activity to close at which point a getBalance() request is called.
Empty data
#### Withdraw
Note: Withdraw triggers a webView to allow the user to control navigation. Because we cede control to the user, we cannot use JavaScript to indicate when the operation is complete. The iOS & Android apps listen for the webView activity to close at which point a getBalance() request is called.
Empty data
#### Stream
```json=
{
"hlsLink": "https://example.com",
"m3u8Data": "",
"streamIsLive": "true"
}
```
#### (Not implemented) Bonus
### Error Types
```=
user: '0',
general: '1',
session: '2',
invalidCredentials: '3',
bankidInit: '4',
bankidCheck: '5',
token: '6',
depositLimit: '7',
matchId: '8',
oddsId: '9',
oddsType: '10',
preWebView: '11',
affiliate: '12',
createAccount: '13',
verifyAccount: '14',
userExist: '15',
oddsChange: '16',
tac: '17',
interval: '18',
oddsMissing: '19',
accountBlocked: '20',
sessionLimit: '21'
stakeTooLow: '22'
stakeTooHigh: '23'
notEnoughFunds: '24'
```
#### Operator Functions
```=
login: '1',
logout: '2',
balance: '3',
betHistory: '4',
betOdds: '5',
betOddsLive: '6',
placeBet: '7',
placeBetLive: '8',
deposit: '9',
withdraw: '10',
register: '11',
stream: '12'
```
#### Error Type by Operator Function
```json=
{
"login": {
"general": {
"value": "1"
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"invalidCredentials": {
"value": "3"
"description": "Authentication of credentials failed",
"resolution": "Contact operator support",
"internal": false
},
"accountBlocked": {
"value": "20",
"description": "Account blocked by the operator",
"resolution": "Check operator's site",
"internal": false
},
"sessionLimit": {
"value": "21",
"description": "Limit on responsible gambling session limit couldn't be set",
"resolution": "Implement setting of responsible gaming limits on the bundle",
"internal": true
},
"tac": {
"value": "17",
"description": "Terms and conditions not accepted",
"resolution": "Implement acceptance of TaC on the bundle",
"internal": true
},
"depositLimit": {
"value": "7",
"description": "Limit on deposit couldn't be set",
"resolution": "Implement setting of limits on the bundle",
"internal": true
},
"token": {
"value": "6",
"description": "Error acquiring one or more required tokens during the login process",
"resolution": "Refer to bundle login function and response chain for more information",
"internal": true
},
"bankidInit": {
"value": "6",
"description": "bank id initialization error",
"resolution": "User SSN might be have wrong format",
"internal": true
},
"bankidCheck": {
"value": "6",
"description": "error when checking bank id status",
"resolution": "",
"internal": true
}
},
"logout": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"session": {
"value": "2",
"description": "The user's session has expired",
"resolution": "Perform a login request to establish a new session",
"internal": true
}
},
"balance": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"session": {
"value": "2",
"description": "The user's session has expired",
"resolution": "Perform a login request to establish a new session",
"internal": true
}
},
"betHistory": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"session": {
"value": "2",
"description": "The user's session has expired",
"resolution": "Perform a login request to establish a new session",
"internal": true
}
},
"betOdds/betOddsLive"": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"session": {
"value": "2",
"description": "The user's session has expired",
"resolution": "Perform a login request to establish a new session",
"internal": true
},
"oddsMissing": {
"value": "19",
"description": "No odds were found for the match",
"resolution": "No odds currently available for the selected match",
"internal": false
},
"matchId": {
"value": "8",
"description": "No match was found for the provided match id",
"resolution": "Check the match id",
"internal": true
}
},
"placeBet": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"session": {
"value": "2",
"description": "The user's session has expired",
"resolution": "Perform a login request to establish a new session",
"internal": true
},
"oddsChange": {
"value": "16",
"description": "The odds for the selected wager have changed by > .01",
"resolution": "Try again with current odds",
"internal": false
},
"oddsMissing": {
"value": "19",
"description": "No odds were found for the selection provided",
"resolution": "Check the selection id",
"internal": true
},
"matchId": {
"value": "8",
"description": "No match was found for the provided match id",
"resolution": "Check the match id",
"internal": true
},
"oddsId": {
"value": "9",
"description": "The selection id is not valid",
"resolution": "Check the selection id",
"internal": true
},
"oddsType": {
"value": "10",
"description": "Odds type for the provided selection is not equal to that of the operator's selection",
"resolution": "Check the selection id",
"internal": true
},
"stakeTooLow": {
"value": "22",
"description": "The amount of money (stake) wagered for the bet is too low",
"resolution": "The user must increase his or her stake",
"internal": false
},
"stakeTooHigh": {
"value": "23",
"description": "The amount of money (stake) wagered for the bet is too high",
"resolution": "The user must decrease his or her stake",
"internal": false
},
"notEnoughFunds": {
"value": "",
"description": "Not enough funds are available to place the bet",
"resolution": "Deposit more money",
"internal": false
},
},
"placeBetLive": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"session": {
"value": "2",
"description": "The user's session has expired",
"resolution": "Perform a login request to establish a new session",
"internal": true
},
"oddsChange": {
"value": "16",
"description": "The odds for the selected wager have changed by > .01",
"resolution": "Try again with current odds",
"internal": false
},
"oddsMissing": {
"value": "19",
"description": "No odds were found for the selection provided",
"resolution": "Check the selection id",
"internal": true
},
"matchId": {
"value": "8",
"description": "No match was found for the provided match id",
"resolution": "Check the match id",
"internal": true
},
"oddsId": {
"value": "9",
"description": "The selection id is not valid",
"resolution": "Check the selection id",
"internal": true
},
"oddsType": {
"value": "10",
"description": "Odds type for the provided selection is not equal to that of the operator's selection",
"resolution": "Check the selection id",
"internal": true
},
"stakeTooLow": {
"value": "22",
"description": "The amount of money (stake) wagered for the bet is too low",
"resolution": "The user must increase his or her stake",
"internal": false
},
"stakeTooHigh": {
"value": "23",
"description": "The amount of money (stake) wagered for the bet is too high",
"resolution": "The user must decrease his or her stake",
"internal": false
},
"notEnoughFunds": {
"value": "",
"description": "Not enough funds are available to place the bet",
"resolution": "Deposit more money",
"internal": false
},
},
"deposit": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"invalidCredentials": {
"value": "3"
"description": "Authentication of credentials failed",
"resolution": "Contact operator support",
"internal": false
}
},
"withdraw": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"invalidCredentials": {
"value": "3"
"description": "Authentication of credentials failed",
"resolution": "Contact operator support",
"internal": false
}
},
"register": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"bankidInit": {
"value": "4",
"description": "Bank id initialization error",
"resolution": "Check ssn or fix functionality on bundle",
"internal": false
},
"bankidCheck": {
"value": "5",
"description": "Error when checking bank id status",
"resolution": "Check if user has bank id or fix functionality on bundle",
"internal": false
},
"userExist": {
"value": "15",
"description": "User already have an existing account",
"resolution": "Use different user",
"internal": false
},
"affiliate": {
"value": "12",
"description": "Error getting affiliate cookie/id or affiliate link error",
"resolution": "Fix affiliate link on the bundle",
"internal": true
}
},
"stream": {
"general": {
"value": "7",
"description": "Unknown error",
"resolution": "Good luck",
"internal": false
},
"session": {
"value": "2",
"description": "The user's session has expired",
"resolution": "Perform a login request to establish a new session",
"internal": true
},
"matchId": {
"value": "8",
"description": "No stream was found for the provided match id",
"resolution": "Check the match id",
"internal": true
},
}
}
```