TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Apr 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Jose Salavert.
Depends on: | |
Alamofire | ~> 4.4 |
ObjectMapper | ~> 2.2 |
Treasure | >= 0 |
Zip | ~> 0.7 |
Request a Vainglory API key and pass it to VainggloryAPI client
import VaingloryAPI
let vaingloryAPI = VaingloryAPIClient(apiKey: "YOUR_VAINGLORY_API_KEY")
vaingloryAPI.getPlayer(withId: "b7ce178c-bd4b-11e4-8883-06d90c28bf1a", shard: .eu) { player, error in
if let player = player {
print("[VaingloryAPI] \(player)")
} else if let error = error {
print("[VaingloryAPI] \(error)")
}
}
vaingloryAPI.getPlayer(withName: "Salavert", shard: .eu) { player, error in
if let player = player {
print("[VaingloryAPI] \(player)")
} else if let error = error {
print("[VaingloryAPI] \(error)")
}
}
vaingloryAPI.getPlayers(withNames: ["Salavert", "Facil"], shard: .eu) { players, error in
if let players = players {
for player in players {
print("[VaingloryAPI] \(player)")
}
} else if let error = error {
print("[VaingloryAPI] \(error)")
}
}
vaingloryAPI.getMatch(withId: "c481c96a-03fd-11e7-8f17-0266696addef", shard: .eu) { match, error in
if let match = match {
print("[VaingloryAPI] \(match)")
// match.rosters
// match.rosters?.first?.participants
// match.rosters?.first?.participants?.first?.player
} else if let error = error {
print(error)
}
}
let filters = RouterFilters()
.playerName("Salavert")
.limit(5)
vaingloryAPI.getMatches(shard: .eu, filters: filters) { matches, error in
if let matches = matches {
for match in matches {
print("[VaingloryAPI] \(match)")
}
} else if let error = error {
print("[VaingloryAPI] \(error)")
}
}
A sample contains a collection of random matches
Retrieving matches of latest available sample
vaingloryAPI.getSampleMatches(shard: .na) { matches, error in
if let matches = matches {
print(matches)
} else if let error = error {
print(error)
}
}
If you prefer to do it manually and have feedback of download progress
let filters = RouterFilters().limit(1)
vaingloryAPI.getSamples(shard: .na, filters: filters) { samples, error in
if let samples = samples {
samples.first?.getMatches(
completionHandler: { matches in
if let matches = matches {
print("Matches count: \(matches.count)")
}
},
progressHandler: { progress in
print("Download Progress: \(progress.fractionCompleted)")
})
} else if let error = error {
print(error)
}
}
let url = "https://gl-prod-us-east-1.s3.amazonaws.com/assets/semc-vainglory/na/2017/03/17/00/43/b900c179-0aaa-11e7-bb12-0242ac110005-telemetry.json"
vaingloryAPI.getTelemetry(url: url) { telemetryList, error in
print(telemetryList?.count)
}