overtime-live-trading-utils 2.0.55 → 2.0.57-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.js +1 -1
- package/package.json +2 -2
- package/src/constants/sports.ts +0 -347
- package/src/tests/unit/opticOdds.test.ts +296 -0
- package/src/utils/opticOdds.ts +6 -5
package/src/utils/opticOdds.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import bytes32 from 'bytes32';
|
|
2
|
+
import { getLeagueOpticOddsName, LeagueMap } from 'overtime-utils';
|
|
2
3
|
import { OPTIC_ODDS_ID_SEPARATOR, OVERTIME_ID_SEPARATOR } from '../constants/common';
|
|
3
|
-
import { LeagueIdMapOpticOdds } from '../constants/sports';
|
|
4
4
|
import { Fixture, OddsObject, ScoresObject } from '../types/odds';
|
|
5
5
|
|
|
6
6
|
export const mapOpticOddsApiFixtures = (fixturesData: any[]): Fixture[] =>
|
|
@@ -85,9 +85,10 @@ export const mapFromOpticOddsToOvertimeFormat = (fixtureId: string) => {
|
|
|
85
85
|
return fixtureId;
|
|
86
86
|
}
|
|
87
87
|
const [leagueName, id] = fixtureId.split(OPTIC_ODDS_ID_SEPARATOR);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
console.log('Mapping from Optic Odds to Overtime format:', { leagueName, id });
|
|
89
|
+
const overtimeLeagueId = Object.values(LeagueMap).find(
|
|
90
|
+
(league) => formatOpticOddsLeagueName(league.opticOddsName || '') === leagueName
|
|
91
|
+
)?.id;
|
|
91
92
|
if (!overtimeLeagueId) {
|
|
92
93
|
throw `Optic Odds league ${leagueName} not mapped.`;
|
|
93
94
|
}
|
|
@@ -99,7 +100,7 @@ export const mapFromOvertimeToOpticOddsFormat = (gameId: string) => {
|
|
|
99
100
|
return gameId;
|
|
100
101
|
}
|
|
101
102
|
const [leagueId, id] = gameId.split(OVERTIME_ID_SEPARATOR);
|
|
102
|
-
const opticOddsLeagueName =
|
|
103
|
+
const opticOddsLeagueName = getLeagueOpticOddsName(Number(leagueId));
|
|
103
104
|
if (!opticOddsLeagueName) {
|
|
104
105
|
throw `Overtime league ID ${leagueId} not mapped.`;
|
|
105
106
|
}
|