@azuro-org/toolkit
Version:
This framework-agnostic package provides essential utilities for building applications on the Azuro Protocol.
26 lines (25 loc) • 1.21 kB
TypeScript
import type { ConditionDetailedData } from '../feed/getConditionsByGameIds';
import type { GameMarkets } from './types';
export type { GameMarkets, MarketOutcome, Market, } from './types';
/**
* Groups game conditions by their market types and sorts them according to sport-specific ordering.
* It processes outcomes to include selection names, handles duplicate conditions, and organizes data for display.
* Conditions whose conditionId begins with '5' use the modern (API-supplied titles) path;
* all others use the legacy (dictionary-resolved names) path.
*
* - Docs: https://gem.azuro.org/hub/apps/toolkit/utils/groupConditionsByMarket
*
* @example
* import { groupConditionsByMarket } from '@azuro-org/toolkit'
*
* const conditions = await getConditionsByGameIds({ gameIds: ['123'] })
* const markets = groupConditionsByMarket(conditions)
*
* markets.forEach(market => {
* console.log(market.name) // e.g., "Match Winner", "Total Goals"
* market.conditions.forEach(condition => {
* console.log(condition.outcomes) // outcomes with odds and selection names
* })
* })
* */
export declare const groupConditionsByMarket: (conditions: ConditionDetailedData[]) => GameMarkets;