fetchMatchesPlayedFromUser method
fetchMatchesPlayedFromUser It will return a list of games played by the user
Implementation
Future<List<WarzoneMatch>> fetchMatchesPlayedFromUser(
{required String username, Platform platform = Platform.atvi}) async {
String url =
'${Global.trackerApi}/matches/${platform.name.toLowerCase()}/$username'
.replaceAll('#', '%23');
Uri uri = Uri.parse(url);
final response = await http.get(uri, headers: headers);
print(response.body);
if (response.statusCode == 200) {
// Matches OK
final dataJson = jsonDecode(response.body);
return (dataJson['data']['matches'] as List)
.map((matchJson) => WarzoneMatch.fromMap(matchJson))
.toList();
} else {
// Matches not found
return [];
}
}