Get Available Prizes

Android

Get all active available prizes that a logged in user is eligible for. Note: Requires an active Versus Session. Challenges are paginated by default - page and pagesize below will afford the ability to retrieve results in a performant manner.

/**
* @property page Page to request if there are multiple pages of prizes
* @property pageSize The maximum number of prizes that will come back per page.
* @return VsLiveData that returns an array of available Winfinite Prizes on success
*/
fun getAvailablePrizes(page: Int, pageSize: Int): VsLiveData<Array<Prize>>
val page: Int = 1
val pageSize: Int = 10

SDK.Prizing.getAvailablePrizes(page, pageSize)
    .observe(object : VsObserver<Array<Prize>>() {
      override fun onError(error: Throwable) {}

      override fun onChanged(t: Array<Prize>) {}
})

Get the next set of available prizes for your game. Note: If you don't want to manually configure pagination, this can handle it for you and just continue to provide the next set of results.

/**
* @return VsLiveData with an array of Versus Prizes on success
*/
fun getAdditionalAvailablePrizes(): VsLiveData<Array<Prize>>
SDK.Prizing.getAdditionalAvailablePrizes()
    .observe(object : VsObserver<Array<Prize>>() {
      override fun onError(error: Throwable) {}

      override fun onChanged(t: Array<Prize>) {}
})

iOS

/// - Parameters:
///   - pageNumber: Page of results to pull (defaults to 1)
///   - pageSize: Size of each page's results (defaults to 10)
///   - archived: boolean to pull only the archived prizes, defaults to false
///   - completionHandler: Closure which returns PrizeResponse containing a collection of Versus Prizes
getPrizes(pageNumber: Int, pageSize: Int, completionHandler: @escaping VersusApiResponse<PrizeResponse>)
VersusSDK?.getPrizes(pageNumber: 1, pageSize: 10, completionHandler: { (prizeResponse, error) in
    if error != nil {
        // error occurred
    } else {
        // Successfully fetched prizes (contained in PrizeResponse object)
    }
})