Skip to content

Tournament Stub

Antoine CLOP edited this page Aug 2, 2020 · 4 revisions

Tournament Stub

Tournament Stub is a fake implementation of Tournament API. The official Tournament API is unavailable with a Development API Key. Application must use Tournament Stub first before applying for Production Key. Tournament regroup multiple games which are only accessible through Tournament Code.
LeagueAPI also support official Tournaments.

Methods

newStubTournament

Parameters

  • TournamentRegion: The region hosting tournament. Currently, Korea cannot host tournament so providing .KR value as TournamentRegion will return nil.
  • named: Tournament name.
  • hostUrl: The server's url hosting tournament. Must support protocol http (with port 80 open) or https (with port 443 open).
  • amount: Optional parameter specifying the number of TournamentCode to generate. Maximum value is 1000. If not specified, will be considered as 1.
  • TournamentInfo: Informations about the tournament policy including: spectator type, team size (minimum 1 and maximum 5), pick type, allowed summoners, map type.

Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: ((ProviderId, TournamentId, [TournamentCode])?, String?). Tuple is composed of Tournament ProviderId, TournamentId and a list of TournamentCode generated. It is equivalent as making calls to createStubTournamentProvider, createStubTournament and createStubTournamentCode. Result will be nil only if parameter rule was broken. The String parameter contains the first error description encountered if existing.

Usage example

guard let spectatorType = SpectatorType(.None) else { return }
guard let pickType = PickType(.TournamentDraft) else { return }
guard let mapType = MapType(.SummonersRift) else { return }
guard let tournamentRegion = TournamentRegion(.EUW) else { return }
guard let tournamentInfo = TournamentInfo(spectatorType: spectatorType, teamSize: 5, pickType: pickType, allowedSummonerIds: [SummonerId("xc8IRVLGV1Gb75sbz8JoLdRvIJ_yAKNsSG1RBQVtnGZqZV8")], mapType: mapType, metadata: "Other informations") else { return }
league.lolAPI.newStubTournament(hostRegion: tournamentRegion, named: "My League Tournament", hostUrl: "https://myLeagueTournament.com", amount: 7, info: tournamentInfo) { (result, errorMsg) in
    if let (providerId, tournamentId, tournamentCodes) = result {
        print("Success!")
    }
    else {
        print("Request failed cause: \(errorMsg ?? "No error description")")
    }
}

createStubTournamentProvider

Parameters

  • TournamentRegion: The region hosting tournament. Currently, Korea cannot host tournament so providing .KR value as TournamentRegion will return nil.
  • hostUrl: The server's url hosting tournament. Must support protocol http (with port 80 open) or https (with port 443 open).

Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: (ProviderId?, String?). ProviderId is the unique identifier of the Provider (host and region) and will be nil only if parameter rule was broken. The String parameter contains the first error description encountered if existing.

Usage example

guard let tournamentRegion = TournamentRegion(.EUW) else { return }
league.lolAPI.createStubTournamentProvider(hostRegion: tournamentRegion, hostUrl: "https://myLeagueTournament.com") { (providerId, errorMsg) in
    if let providerId = providerId {
        print("Success!")
    }
    else {
        print("Request failed cause: \(errorMsg ?? "No error description")")
    }
}

createStubTournament

Parameters

  • ProviderId: Represents the unique identifier for a Provider. A provider is composed of a hostUrl and a region hosting tournament. See createStubTournamentProvider section above.
  • named: Tournament name.

Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: (TournamentId?, String?). TournamentId is the unique identifier of the Tournament instance (name and provider) and will be nil only if parameter rule was broken. The String parameter contains the first error description encountered if existing.

Usage example

league.lolAPI.createStubTournament(providerId: ProviderId(43), named: "My League Tournament") { (tournamentId, errorMsg) in
    if let tournamentId = tournamentId {
        print("Success!")
    }
    else {
        print("Request failed cause: \(errorMsg ?? "No error description")")
    }
}

createStubTournamentCode

Parameters

  • TournamentId: Represents the unique identifier for a Tournament. A tournament is composed of a provider and a name. See createStubTournament section above.
  • amount: Optional parameter specifying the number of TournamentCode to generate. Maximum value is 1000. If not specified, will be considered as 1.
  • TournamentInfo: Informations about the tournament policy including: spectator type, team size (minimum 1 and maximum 5), pick type, allowed summoners, map type.

Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: ([TournamentCode]?, String?). TournamentCode array contains all code generated. Those code allows owner to access confidential game data about the tournament. Result will be nil only if parameter rule was broken. The String parameter contains the first error description encountered if existing.

Usage example

guard let spectatorType = SpectatorType(.None) else { return }
guard let pickType = PickType(.TournamentDraft) else { return }
guard let mapType = MapType(.SummonersRift) else { return }
guard let tournamentInfo = TournamentInfo(spectatorType: spectatorType, teamSize: 5, pickType: pickType, allowedSummonerIds: [SummonerId("xc8IRVLGV1Gb75sbz8JoLdRvIJ_yAKNsSG1RBQVtnGZqZV8")], mapType: mapType, metadata: "Other informations") else { return }
league.lolAPI.createStubTournamentCode(tournamentId: TournamentId(44), amount: 7, info: tournamentInfo) { (tournamentCodes, errorMsg) in
    if let tournamentCodes = tournamentCodes {
        print("Success!")
    }
    else {
        print("Request failed cause: \(errorMsg ?? "No error description")")
    }
}

StubTournamentEvents

Parameters

  • TournamentCode: A code generated that allows user to access confidential game data about the tournament. See createStubTournamentCode section above.

Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: ([TournamentEvent]?, String?). TournamentEvent array contains records of actions and changes in tournament and will be nil only if TournamentCode was not found or invalid. The String parameter contains the first error description encountered if existing.

Usage example

league.lolAPI.getStubTournamentEvents(tournamentCode: TournamentCode("Tournament Code")) { (events, errorMsg) in
    if let events = events {
        print("Success!")
    }
    else {
        print("Request failed cause: \(errorMsg ?? "No error description")")
    }
}