assetTransactionCategoryTypeFromJson function

AssetTransactionCategoryType assetTransactionCategoryTypeFromJson(
  1. Object? assetTransactionCategoryType, [
  2. AssetTransactionCategoryType? defaultValue
])

Implementation

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

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

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