consentStatusToJson function
Converts a ConsentStatus enumeration value to a consent status string for JSON serialization.
This function takes a ConsentStatus
enumeration value as input and converts it into
a corresponding consent status string for JSON serialization. If the input consentStatus
is null, the function returns the string representation of ConsentStatus.PENDING
.
If the input consentStatus
is ConsentStatus.UNKNOWN
, the function also returns
the string representation of ConsentStatus.PENDING
. For other valid ConsentStatus
values, the function returns the string representation of the input value.
@param consentStatus The ConsentStatus
enumeration value to convert.
@return A consent status string for JSON serialization.
Implementation
String consentStatusToJson(ConsentStatus? consentStatus) {
switch (consentStatus) {
case null:
return ConsentStatus.PENDING.name;
case ConsentStatus.UNKNOWN:
return ConsentStatus.PENDING.name;
default:
return consentStatus.name;
}
}