getCardByTcgplayerId method

Future<MtgCard> getCardByTcgplayerId(
  1. int tcgplayerId
)

GET /cards/tcgplayer/:id

Returns a single card with the given tcgplayerId or tcgplayer_etched_id, also known as the productId on TCGplayer’s API.

Implementation

Future<MtgCard> getCardByTcgplayerId(int tcgplayerId) async {
  final url = Uri.https(_baseUrl, '/cards/tcgplayer/$tcgplayerId');
  final response = await _httpClient.get(url);

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

  if (response.statusCode != 200) {
    throw ScryfallException.fromJson(json);
  }

  return MtgCard.fromJson(json);
}