getThreadTags method

Future<Map<String, int>?> getThreadTags({
  1. bool requestLatest = false,
})

Implementation

Future<Map<String, int>?> getThreadTags({bool requestLatest = false}) async {
  final uri = Uri.https(
    _baseUrl,
    '/v2/threads/tags',
    <String, dynamic>{'latest': requestLatest == true ? '1' : '0'},
  );

  final response = await _httpGet(uri);

  if (response.statusCode != 200) {
    if (response.statusCode == 404) {
      return null;
    } else {
      throw ContentRequestFailure(statusCode: response.statusCode);
    }
  }

  final bodyJson = jsonDecode(response.body) as Map<String, dynamic>;

  return Map<String, int>.from(bodyJson);
}