documentAuthenticityMatchCodeFromJson function

DocumentAuthenticityMatchCode documentAuthenticityMatchCodeFromJson(
  1. Object? documentAuthenticityMatchCode, [
  2. DocumentAuthenticityMatchCode? defaultValue
])

Implementation

enums.DocumentAuthenticityMatchCode documentAuthenticityMatchCodeFromJson(
  Object? documentAuthenticityMatchCode, [
  enums.DocumentAuthenticityMatchCode? defaultValue,
]) {
  if (documentAuthenticityMatchCode is String) {
    return enums.$DocumentAuthenticityMatchCodeMap.entries
        .firstWhere(
            (element) =>
                element.value.toLowerCase() ==
                documentAuthenticityMatchCode.toLowerCase(),
            orElse: () => const MapEntry(
                enums.DocumentAuthenticityMatchCode.swaggerGeneratedUnknown,
                ''))
        .key;
  }

  final parsedResult = defaultValue == null
      ? null
      : enums.$DocumentAuthenticityMatchCodeMap.entries
          .firstWhereOrNull((element) => element.value == defaultValue)
          ?.key;

  return parsedResult ??
      defaultValue ??
      enums.DocumentAuthenticityMatchCode.swaggerGeneratedUnknown;
}