giftCardsSearch method

Future<GiftCardSearchResult?> giftCardsSearch({
  1. String? countryCode,
  2. String? category,
  3. String? valueType,
  4. String? q,
  5. bool? isRedeemableGlobally,
  6. String? currency,
  7. int? page,
  8. int? limit,
  9. Future<void>? abortTrigger,
})

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 GLOBAL is rejected.

  • String category: Keep the cards of this category; categories lists the values.

  • String valueType: Keep only fixed or only range offers; 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: true keeps 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;
}