getApiKey function
Implementation
Future<String> getApiKey({
required String apiKey,
required String name,
required String accessToken,
}) async {
try {
final String timeStamp = getCurrentDateTimeInISO8601();
final http.Response response = await http.get(
Uri.parse('${apiBaseUrl}apikey?name=$name'),
headers: <String, String>{
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-api-key': apiKey,
'x-timestamp': timeStamp,
'Authorization': 'Bearer $accessToken'
},
);
var result = jsonDecode(response.body);
if (kDebugMode) {
print(result);
}
if (!result.containsKey('error')) {
return result["apiKey"];
} else {
if (kDebugMode) {
print(result);
}
return '';
}
} catch (e) {
if (kDebugMode) {
print(e);
}
return '';
}
}