Sports You Watch Headless Functions

Sports You Watch Headless Functions

Headless function setuparrow-up-right


matchup(for:) -> AsyncStream<Result<LucraMatchup?, APIError>>

Retrieve and subscribe to updates for a Lucra matchup (sports or SYW games).

Parameters

  • matchupId: The Lucra matchup identifier to fetch and subscribe to.

Returns

  • An AsyncStream<Result<LucraMatchup?, APIError>> that emits:

    • .success(LucraMatchup?) — The latest matchup payload (participants, stakes, status, etc.).

    • .failure(APIError) — Any error encountered, including location-related failures or general API issues.

Usage

let stream = lucraClient.api.matchup(for: "syw-2024-001")

Task {
    for await result in stream {
        switch result {
        case .success(let matchup):
            if let matchup {
                print("Fetched matchup: \(matchup.id)")
            } else {
                print("Matchup not found.")
            }

        case .failure(let error):
            print("Failed to load matchup: \(error)")
        }
    }
}

matchup(for:) async -> Result<LucraMatchup, MatchupError>

Parameters

  • matchupId: The Lucra matchup identifier to fetch.

Returns

  • Result<LucraMatchup, MatchupError> — The matchup object on success, or a MatchupError on failure.

Usage

Error Types

For specific error handling, please see (1.2.9_headless_interactions.md) Error Handling section.

MatchupError

  • .user(UserStateError) — Wraps user state errors

  • .location(LocationError) — Wraps location errors

  • .customError(message: String) — Custom error message

  • .unknown — Unknown error

UserStateError

  • .notInitialized

  • .unverified

  • .notAllowed

  • .insufficientFunds

  • .demographicInformationMissing

LocationError

  • .unauthorized

  • .unableToDetermineLocation(error)

  • .clError(clError)


Last updated