formatExpirerTarget function

String formatExpirerTarget(
  1. String type,
  2. dynamic value
)

Implementation

String formatExpirerTarget(String type, dynamic value) {
  if (value is String && value.startsWith('$type:')) return value;
  if (type.toLowerCase() == "topic") {
    if (value is! String) {
      throw WCException('Value must be String for expirer target type: topic');
    }
    return 'topic:$value';
  } else if (type.toLowerCase() == "id") {
    if (value is! int) {
      throw WCException('Value must be int for expirer target type: id');
    }
    return 'id:$value';
  }
  throw WCException('Unknown expirer target type: $type');
}