resolveCredential method
Implementation
Future<List<String>> resolveCredential(
String url, String walletId, String cookie) async {
Uri? uri = Uri.tryParse(Uri.decodeFull(url));
if (uri != null) {
String credentialOffer = "openid-initiate-issuance://?${uri.query}";
var body = base64.encode(utf8.encode(credentialOffer));
String referer =
"${ApiConfig.baseUrl}wallet/$walletId/exchange/issuance?request=$body";
var header = {"Cookie": cookie, "Referer": referer};
header["Content-Type"] = "application/json";
header["Accept"] = "application/json";
// emit(state.copyWith(
// openIdUrl: credentialOffer,
// openIdOffer: event.url,
// referer: referer));
var response = await http.post(
Uri.parse(
"${ApiConfig.baseUrl}wallet/$walletId/exchange/resolveCredentialOffer"),
headers: header,
body: jsonEncode({"offer": credentialOffer}),
);
log("URL::${Uri.parse("${ApiConfig.baseUrl}wallet/$walletId/exchange/resolveCredentialOffer")} :: BODY :: ${jsonEncode({
"offer": credentialOffer
})} :: RESPONSE :: ${response.body}");
Map<String, dynamic> jsonMap = json.decode(response.body)["data"];
List<dynamic> credentialIds = jsonMap['credential_configuration_ids'];
List<String> offeredCredentials = credentialIds.map((dynamic item) {
return formatCamelCaseString(item.split('_').first);
}).toList();
return offeredCredentials;
} else {
return [];
}
}