giftCardsSearch method
Search gift cards
Searches gift cards and returns them with their offers, one page at a time. Returns { items, pagination }. countryCode, category, q and isRedeemableGlobally select cards; valueType selects offers within them, and a card left without an offer is dropped. Pages count cards. Prices are indicative, in currency; a fixed offer is listed only when it is cheaper than the card's range at the same value. An invalid or unknown parameter gives 400 / 10001; an unsupported currency gives 404 / 10004.
Parameters:
-
String countryCode: Optional ISO 3166-1 alpha-2 issuing country, in either case; every country when omitted. A card without a country is not listed when it is set, and a blank value or
GLOBALis rejected. -
String category: Keep the cards of this category;
categorieslists the values. -
String valueType: Keep only
fixedor onlyrangeoffers; a card left without an offer is dropped. -
String q: Brand name or card ID, case-insensitive; at most 100 characters, without control characters.
-
bool isRedeemableGlobally:
truekeeps only cards that can be redeemed in any country. -
String currency: Price currency, three letters in either case; the API key's currency when omitted. An unsupported code gives 404 / 10004.
-
int page: Page number, from 1; default 1.
-
int limit: Page size, 1 to 100; default 10.
Implementation
Future<GiftCardSearchResult?> giftCardsSearch({ String? countryCode, String? category, String? valueType, String? q, bool? isRedeemableGlobally, String? currency, int? page, int? limit, Future<void>? abortTrigger, }) async {
final response = await giftCardsSearchWithHttpInfo(countryCode: countryCode, category: category, valueType: valueType, q: q, isRedeemableGlobally: isRedeemableGlobally, currency: currency, page: page, limit: limit, abortTrigger: abortTrigger,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'GiftCardSearchResult',) as GiftCardSearchResult;
}
return null;
}