ResourceClaimStatus.fromJson constructor

ResourceClaimStatus.fromJson(
  1. Map<String, dynamic> json
)

Creates a ResourceClaimStatus from JSON data.

Implementation

factory ResourceClaimStatus.fromJson(Map<String, dynamic> json) {
  final tempAllocationJson = json['allocation'];
  final tempDeallocationRequestedJson = json['deallocationRequested'];
  final tempDriverNameJson = json['driverName'];
  final tempReservedForJson = json['reservedFor'];

  final AllocationResult? tempAllocation = tempAllocationJson != null
      ? AllocationResult.fromJson(tempAllocationJson)
      : null;
  final bool? tempDeallocationRequested = tempDeallocationRequestedJson;
  final String? tempDriverName = tempDriverNameJson;

  final List<ResourceClaimConsumerReference>? tempReservedFor =
      tempReservedForJson != null
          ? List<dynamic>.from(tempReservedForJson)
              .map(
                (e) => ResourceClaimConsumerReference.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  return ResourceClaimStatus(
    allocation: tempAllocation,
    deallocationRequested: tempDeallocationRequested,
    driverName: tempDriverName,
    reservedFor: tempReservedFor,
  );
}