getConsoleIds function

Future<List<ConsoleId>> getConsoleIds(
  1. AuthObject authorization
)

A call to this function will retrieve the complete list of console ID and name pairs on the RetroAchievements.org platform.

@param authorization An object containing your userName and webApiKey. This can be constructed with buildAuthorization().

@example

final consoleIds = await getConsoleIds(authorization);

@returns A list containing a complete list of console ID and name pairs for RetroAchievements.org.

{ id: 1, name: 'Mega Drive' }

Implementation

Future<List<ConsoleId>> getConsoleIds(AuthObject authorization) async {
  final url = buildRequestUrl(
    apiBaseUrl,
    '/API_GetConsoleIDs.php',
    authorization,
  );

  final response = await http.get(Uri.parse(url));
  final rawResponse = json.decode(response.body) as List<dynamic>;

  return rawResponse.map((console) => ConsoleId.fromJson(console)).toList();
}