getMetadata method

Future<Map<String, dynamic>?> getMetadata(
  1. String url, {
  2. bool requestLatest = false,
})

Implementation

Future<Map<String, dynamic>?> getMetadata(
  String url, {
  bool requestLatest = false,
}) async {
  final uri = Uri.https(
    _baseUrl,
    '/v2/metadata',
    <String, dynamic>{'u': url, '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 bodyJson;
}