Extend RestApiUtility to Support Leaderboard Base URL

This commit extends the `RestApiUtility` class to include support for a new leaderboard base URL. A new `ApiType` enum value `ApiType.leaderboard` has been added, and the `_getEffectiveBaseUrl` method has been updated to handle this new type. The leaderboard base URL is "https://leaderboard.vercel.app/".
This commit is contained in:
hunteraraujo
2023-09-20 14:43:45 -07:00
parent a0512254ca
commit 7901c750b6

View File

@@ -6,6 +6,7 @@ import 'package:http/http.dart' as http;
class RestApiUtility {
String _agentBaseUrl;
final String _benchmarkBaseUrl = "http://127.0.0.1:8080/ap/v1";
final String _leaderboardBaseUrl = "https://leaderboard.vercel.app/";
RestApiUtility(this._agentBaseUrl);
@@ -14,7 +15,16 @@ class RestApiUtility {
}
String _getEffectiveBaseUrl(ApiType apiType) {
return apiType == ApiType.agent ? _agentBaseUrl : _benchmarkBaseUrl;
switch (apiType) {
case ApiType.agent:
return _agentBaseUrl;
case ApiType.benchmark:
return _benchmarkBaseUrl;
case ApiType.leaderboard:
return _leaderboardBaseUrl;
default:
return _agentBaseUrl;
}
}
Future<Map<String, dynamic>> get(String endpoint,