测试测试通过 | ✗ |
语种语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2017年4月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Jose Salavert 维护。
依赖项 | |
Alamofire | ~> 4.4 |
ObjectMapper | ~> 2.2 |
Treasure | >= 0 |
Zip | ~> 0.7 |
请求一个 Vainglory API 密钥 并将其传递给 VainggloryAPI 客户端
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)")
}
}
示例包含一组随机比赛
检索最新可用示例的比赛
vaingloryAPI.getSampleMatches(shard: .na) { matches, error in
if let matches = matches {
print(matches)
} else if let error = error {
print(error)
}
}
如果您更喜欢手动操作并查看下载进度,请执行以下操作:
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)
}