getCategorySearchManifest method

Future<List<CategorySearchManifestDto>> getCategorySearchManifest({
  1. required String authToken,
  2. required int categoryId,
})

This endpoint returns a search manifest for the specified category. The search manifest describes all of the sorting options and filters that are available for this category. Its contents should be used to build requests to the POST /catalog/categories/{categoryId}/search endpoint.

Implementation

Future<List<CategorySearchManifestDto>>
    getCategorySearchManifest(
        {required String authToken, required int categoryId}) async {
  Map<String, String> headers = {
    "Authorization": "Bearer $authToken",
    'Content-Type': 'application/json',
    "Access-Control-Allow-Origin": "*", // Required for CORS support to work
  };

  Uri endpoint;
  if (secure) {
    endpoint =
        Uri.https(baseUrl, "/catalog/categories/$categoryId/search/manifest");
  } else {
    endpoint =
        Uri.http(baseUrl, "/catalog/categories/$categoryId/search/manifest");
  }

  var response = await http.get(endpoint, headers: headers);

  if (response.statusCode == 200 || response.statusCode == 201) {
    TcgPlayerResponseDto<CategorySearchManifestDto> responseDto = TcgPlayerResponseDto.fromJson(
        jsonDecode(const Utf8Decoder().convert(response.bodyBytes)),
        (data) =>
            CategorySearchManifestDto.fromJson(data as Map<String, dynamic>));

      return responseDto.results;
  } else {
    var error = ServerError.fromJson(jsonDecode(response.body));
    throw CatalogException(
        statusCode: response.statusCode, message:  "${error.error} - ${error.errorDescription}");
  }
}