getVoucherCodeStatusFromString static method
The function converts a string to a corresponding VoucherCodeStatus enum value.
Args: string (String): A string representing the status of a voucher code. It can be one of the following values: 'UNASSIGNED', 'ASSIGNED', 'REDEEMED', or 'CANCELED'.
Returns:
This function returns a value of the VoucherCodeStatus enum type based on the input string. If
the input string matches one of the defined enum values, the corresponding enum value is returned.
If the input string does not match any of the defined enum values, the default value of
VoucherCodeStatus.unassigned is returned.
Implementation
static VoucherCodeStatus getVoucherCodeStatusFromString(String string) {
if (string == 'UNASSIGNED') {
return VoucherCodeStatus.unassigned;
} else if (string == 'ASSIGNED') {
return VoucherCodeStatus.assigned;
} else if (string == 'REDEEMED') {
return VoucherCodeStatus.redeemed;
} else if (string == 'CANCELED') {
return VoucherCodeStatus.canceled;
} else {
return VoucherCodeStatus.unassigned;
}
}