addPostPollOptionAws method
Implementation
Future<String?> addPostPollOptionAws(final String resourceId,
final String userId, final String pollOption) async {
try {
final body = {
"resourceId": resourceId,
"resourceType": "POST",
"resourceSubType": "POLL",
"interactionType": pollOption,
"userId": userId
};
/*
final request = client.request(ApiConfig.interactionPath,
method: "POST", body: json.encode(body));
request.headers.addAll(<String, String>{
"x-api-key": ApiConfig.apiKey,
"content-type": "application/json",
"cdauthtoken": "Bearer ${ApiConfig.idToken}"
});
final value = await http.post(request.url,
headers: request.headers, body: request.body);
*/
final SharedPreferences prefs = await _prefs;
final String? kcuserId = prefs.getString(ApiConfig.kcUserId); // To Do
final String? apiKey = prefs.getString(ApiConfig.kcAPIKey);
final Dio dio = Dio();
final value = await dio.post(
ApiConfig.kcInteractionPath,
options: Options(
headers: {
"x-api-key": apiKey,
"content-type": "application/json",
"kcuserid": kcuserId
},
),
data: body,
);
if (value.statusCode == 201) {
return value.toString();
} else {
return null;
}
} catch (error) {
rethrow;
}
}