fromJson static method

TicketMobileBaseDTOInternal? fromJson(
  1. dynamic value
)

Returns a new TicketMobileBaseDTOInternal instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static TicketMobileBaseDTOInternal? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "TicketMobileBaseDTOInternal[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "TicketMobileBaseDTOInternal[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return TicketMobileBaseDTOInternal(
      id: mapValueOfType<int>(json, r'id'),
      createdAt: mapDateTime(json, r'createdAt', r''),
      modifiedAt: mapDateTime(json, r'modifiedAt', r''),
      closedAt: mapDateTime(json, r'closedAt', r''),
      subject: mapValueOfType<String>(json, r'subject'),
      description: mapValueOfType<String>(json, r'description'),
      ticketState: TicketMobileBaseDTOInternalTicketStateEnum.fromJson(json[r'ticketState']),
      possibleTicketStates: json[r'possibleTicketStates'] is Iterable
          ? (json[r'possibleTicketStates'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      ticketPriority: TicketMobileBaseDTOInternalTicketPriorityEnum.fromJson(json[r'ticketPriority']),
      dueDate: mapDateTime(json, r'dueDate', r''),
      ticketCategory: mapValueOfType<String>(json, r'ticketCategory'),
      ticketArea: mapValueOfType<String>(json, r'ticketArea'),
      projectName: mapValueOfType<String>(json, r'projectName'),
      tags: json[r'tags'] is Iterable
          ? (json[r'tags'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      ticketMembersContactInfo: TicketMemberContactDTOInternal.listFromJson(json[r'ticketMembersContactInfo']),
      relations: TicketRelatedDTOInternal.listFromJson(json[r'relations']),
      privateTicket: mapValueOfType<bool>(json, r'privateTicket'),
      noComments: mapValueOfType<bool>(json, r'noComments'),
      ticketMemberCount: mapValueOfType<int>(json, r'ticketMemberCount'),
      pinned: mapValueOfType<bool>(json, r'pinned'),
    );
  }
  return null;
}