transformActivityResponse method
Transforms activity response to flatten specific result from activity.result.{specificResult} to top-level result
Implementation
Map<String, dynamic> transformActivityResponse(
Map<String, dynamic> json, String operationId) {
// Convert operationId to the expected result field name (e.g., "StampLogin" -> "stampLoginResult")
final resultFieldName =
'${operationId[0].toLowerCase()}${operationId.substring(1)}Result';
final result = <String, dynamic>{
'activity': json['activity'],
};
// Extract specific result from activity.result.{specificResult} and flatten to top level
if (json['activity'] != null &&
json['activity']['result'] != null &&
json['activity']['result'][resultFieldName] != null) {
result['result'] = json['activity']['result'][resultFieldName];
}
return result;
}