getConsent method
Implementation
Future<ConsentInfo?> getConsent(String id) async {
final baseUrl = ConfigManager.current.baseUrl;
final url = Uri.parse('$baseUrl$_consentEndpoint/$id');
final token = await storage.getTokenOrThrow();
final headers = {
'Authorization': 'Bearer $token',
};
try {
final response = await http.get(
url,
headers: headers,
);
final responseDataReady = await _checkResponseData(response, 'Failed to get Consent');
if (responseDataReady) {
final Map<String, dynamic>? jsonMap = jsonDecode(response.body);
return jsonMap != null ? ConsentInfo.fromJson(jsonMap) : null;
}
return null;
} on SDKException {
rethrow;
} catch (e) {
throw SDKException.withMessage(
'PlumCheck SDK Exeption - Failed to get Consent, Description: ${e.toString()}');
}
}