API Module
To utilize the API layer will require both using the Frontend SDK as well as integrating several API calls on your Backend to set/fetch data to/from the Lucra system at appropriate times. View the API Integration document for more information.
Interacting with APIs
Use Lucra instance easily by invoking the class operator LucraClient().* or fetching the instance LucraClient.getInstance().*
Once you have the instance, you can interact with our headless SDK methods:
User API
Get and update the current user's properties
Methods
observeSDKUserFlow, observeSDKUser
Observe the active SDKUser based on authed status.
Example usage:
private fun observeLoggedInUser() {
// Or use observeSDKUser { result -> ... }
LucraClient().observeSDKUserFlow().onEach { sdkUserResult ->
when (sdkUserResult) {
is SDKUserResult.Success -> {
Log.d("Lucra SDK Sample", "Fetched latest user")
lucraSDKUser = sdkUserResult.sdkUser
}
is SDKUserResult.Error -> {
Log.e("Lucra SDK Sample", "Unable to get username ${sdkUserResult.error}")
lucraSDKUser = null
}
SDKUserResult.InvalidUsername -> {
// Shouldn't happen here
}
SDKUserResult.NotLoggedIn -> {
Log.e(
"Lucra SDK Sample",
"User not logged in yet!"
)
lucraSDKUser = null
}
SDKUserResult.Loading -> {
}
}
}.launchIn(lifecycleScope)
}Configure User
Description:
Pushes profile attributes into Lucra for the currently authenticated user. Only non-null values on the supplied SDKUser are submitted.
If configure is invoked before the Lucra session is established, the request is queued and automatically retried after login. Deprecated properties such as birthday are ignored. Any values sent here are also surfaced inside LucraFlow.VerifyIdentity, minimizing what the user must re-enter during KYC.
Phone number implications
Provide
phoneNumberonly when you intend to bind the Lucra account to that value. After the number is verified, the SDK login flow requires the same phone for future authentications.Skip the field (or pass
null) if you prefer Lucra to collect and manage the phone number directly.Whatever value you send appears pre-filled in the Verify Identity flow.
User metadata implications
Use
metadatato pass identifiers and traits from your system. This is a Map of Strings to Strings, anexternal_identry (example:"external_id" to clientUserId) is recommended at minimum to bind your users to Lucra users. Which will help for score submission and other identifying properties from Lucra systems.
Method:
configure(SDKUser, onResult: (SDKUserResult) -> Unit)
Example:
Response Type: SDKUserResult
logout
Logs out the current user, if any
Example usage:
GamesMatchup API
The GamesMatchup interface provides methods to manage game contests. It allows users to create, accept, and cancel contests. Each method provides a callback mechanism to handle the result of the operation.
Methods
createGamesMatchup
Creates a new game contest.
Parameters:
gameTypeId: ID associated with the game type.atStake: Amount of money being wagered.onResult: Callback with a result of typeCreateGamesMatchupResult.
Example usage:
acceptGamesMatchup
Accepts a contest with the given ID.
Parameters:
matchupId: ID of the contest.teamId: ID of the team the user wants to join.onResult: Callback with a result of typeMatchupActionResult.
Example usage:
retrieveGamesMatchup
Retrieve a contest with the given ID.
Parameters:
matchupId: ID of the contest.onResult: Callback with a result of typeRetrieveGamesMatchupResult.
Example usage:
cancelGamesMatchup
Cancels a contest with the given ID.
Parameters:
matchupId: ID of the contest.onResult: Callback with a result of typeMatchupActionResult.
Example usage:
retrieveSportsMatchup
Retrieve a sports contest with the given ID.
Parameters:
matchupId: ID of the contest.onResult: Callback with a result of typeRetrieveGamesMatchupResult.
Example usage:
Tournaments API
The Tournament interface provides methods to join and retrieve tournament matchups. Each method provides a callback mechanism to handle the results of the operation.
Methods
retrieveTournament
Retrieve a tournament with a given ID.
Parameters:
tournamentId: ID associated with the tournament.onResult: Callback with a result of typeRetrieveTournamentResult
Example usage:
queryRecommendedTournaments
Retrieve a list of recommended tournaments.
Parameters:
limit: The max number tournaments that will be returned.offset: The starting index of the query.includeCompletedTournaments: Should completed tournaments be included in the query.onResult: Callback with a result of typeQueryRecommendedTournamentsResult
Example usage:
joinTournament
Join a tournament with a given ID.
Parameters:
tournamentId: ID associated with the tournament.onResult: Callback with a result of typeJoinTournamentResult
Example usage:
setDeeplinkTransformer
Sets lambda function that will be used to transform original lucra URI to client specific URI. Make sure to keep the original URI in the process to allow conversion into LucraFlow later.
Parameters:
suspend (String) -> String: suspended string transformer lambda
Example usage:
getLucraFlowForDeeplinkUri
Convert lucra URI (ex: lucra://...) into LucraFlow that can be launched to show a UI component.
Parameters:
uri: uri string to convert into a LucraFlow
Example usage:
Result Types
MatchupActionResult
Represents the result of an operation on an existing GamesMatchup.
Success: Represents a successful operation.Failure: Represents a failed operation. Contains afailureof typeFailedCreateGamesMatchup.
CreateGamesMatchupResult
Represents the result of creating a GamesMatchup.
GYPCreatedMatchupOutput: Represents a successfully created matchup. ContainsmatchupId,ownerTeamId, andopponentTeamId.Failure: Represents a failed operation. Contains afailureof typeFailedCreateGamesMatchup.
Error Types
FailedCreateGamesMatchup
Represents the types of errors that can occur when creating a GamesMatchup.
UserStateError: Errors related to the current user account status or available funds.NotInitialized: User account is not initialized.Unverified: User account is unverified.NotAllowed: User is not allowed to perform the operation.InsufficientFunds: User has insufficient funds.
LocationError: Errors related to the user's location. Contains amessage.APIError: All other errors. Contains amessage.
Get User's KYC Status
Fetching the KYC status will determine if the current user is verified or not, allowing for money and sports contest interactions. If the user is not verified, launch the VerifyIdentity LucraFlow.
Methods
checkUsersKYCStatus
Returns the status of the current logged in user.
Parameters:
userId: ID associated to the current user (see)lucraKYCStatusListener: Listener to implement specific callbacks for KYC interaction
Example usage:
Event listeners
setEventListener
Sets a event listener so you can listen for Lucra-specific events that occur with the SDK. A LucraEvent may hold data associated with the event (ex: LucraEvent.SportsContest.Create holds a contestId).
Parameters:
LucraEventListener: listener used to receive aLucraEvent
Example usage:
Last updated