-
Notifications
You must be signed in to change notification settings - Fork 13
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.
- newStubTournament(hostRegion: TournamentRegion, named: String, hostUrl: String, amount: Int? = nil, info: TournamentInfo)
- createStubTournamentProvider(hostRegion: TournamentRegion, hostUrl: String)
- createStubTournament(providerId: ProviderId, named: String)
- createStubTournamentCode(tournamentId: TournamentId, amount: Int? = nil, info: TournamentInfo)
- StubTournamentEvents(tournamentCode: TournamentCode)
- 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.
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")")
}
}
- 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.
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")")
}
}
- 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.
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")")
}
}
- 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.
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")")
}
}
- 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.
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")")
}
}