getCardByTcgplayerIdAsImage method
Future<Uint8List>
getCardByTcgplayerIdAsImage(
- int tcgplayerId, {
- bool? backFace,
- ImageVersion? imageVersion,
GET /cards/tcgplayer/:id?format=image
Returns a single card with the given tcgplayerId
or tcgplayer_etched_id
, also known as the productId
on TCGplayer’s API.
backFace
: If true
, the back face of the card is returned.
Will return a 422 if this card has no back face.
Defaults to false
.
imageVersion
: The version of the image that shall
be returned.
Defaults to ImageVersion.large.
Implementation
Future<Uint8List> getCardByTcgplayerIdAsImage(
int tcgplayerId, {
bool? backFace,
ImageVersion? imageVersion,
}) async {
final url = Uri.https(
_baseUrl,
'/cards/tcgplayer/$tcgplayerId',
<String, String?>{
'format': 'image',
'face': backFace == true ? 'back' : null,
'version': imageVersion?.json,
},
);
final response = await _httpClient.get(url);
if (response.statusCode != 200) {
final json = jsonDecode(response.body) as Map<String, dynamic>;
throw ScryfallException.fromJson(json);
}
return response.bodyBytes;
}