getBadges static method
Returns all the BadgeBase, with optional filters.
Implementation
static Future<List<BadgeBase>> getBadges({
final String? userId,
final String? deviceId,
final QueryType? queryType,
}) async {
final Map<String, String> parameters = <String, String>{};
if (userId != null) {
parameters['user_id'] = userId;
}
if (deviceId != null) {
parameters['device_id'] = deviceId;
}
final Response response = await HttpHelper().doGetRequest(
UriHelper.getEventsUri(
path: '/badges',
queryParameters: parameters,
queryType: queryType,
),
queryType: queryType,
);
_checkResponse(response);
final List<BadgeBase> result = <BadgeBase>[];
final List<dynamic> json = jsonDecode(response.body) as List<dynamic>;
for (var element in json) {
result.add(BadgeBase.fromJson(element));
}
return result;
}