autoComplete method
Auto complete Providers users a list of valid terms that completes the given tag on the GIPHY network.
Implementation
Future<SuccessTermResponseModel> autoComplete(
String tagTerm, {
int limit = 5,
int offset = 0,
}) async {
// Verify if limit is an Int32 value
if (!limit.isInt32 && limit < 1) {
throw Exception('Limit must be an Int32 value and greater than 0');
}
// Verify if offset is an Int32 value
if (!offset.isInt32 && offset < 0) {
throw Exception(
'Offset must be an Int32 value and greater than or equal to 0',
);
}
const baseUrl = GiphyAPIPath.baseUrl;
final pathSegments = [
GiphyAPIPath.version1,
GiphyAPIPath.gif,
GiphyAPIPath.search,
GiphyAPIPath.autocomplete,
];
Map<String, dynamic> queryParameters = {
'api_key': apiKey,
"q": tagTerm,
'limit': limit.toString(),
'offset': offset.toString(),
};
// Make the request
final responseMap = await GiphyApiManager.get(
baseUrl,
pathSegments,
queryParameters: queryParameters,
debugMode: debugMode,
);
// Parse the response
return SuccessTermResponseModel.fromJson(responseMap);
}