GetVersionInfoResponse.fromJson constructor

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

Implementation

factory GetVersionInfoResponse.fromJson(Map<String, dynamic> json) {
  GetVersionInfoResponse response = GetVersionInfoResponse(json);
  if (json['result'] != null) {
    response.version = json['result']['version'];

    if (json['result']['commit_hash'] != null) {
      response.commitHash =
          json['result']['commit_hash']; // protocol version < 22
    } else {
      response.commitHash =
          json['result']['commitHash']; // protocol version >= 22
    }

    if (json['result']['build_time_stamp'] != null) {
      response.buildTimeStamp =
          json['result']['build_time_stamp']; // protocol version < 22
    } else {
      response.buildTimeStamp =
          json['result']['buildTimestamp']; // protocol version >= 22
    }

    if (json['result']['captive_core_version'] != null) {
      response.captiveCoreVersion =
          json['result']['captive_core_version']; // protocol version < 22
    } else {
      response.captiveCoreVersion =
          json['result']['captiveCoreVersion']; // protocol version >= 22
    }

    if (json['result']['protocol_version'] != null) {
      response.protocolVersion =
          json['result']['protocol_version']; // protocol version < 22
    } else {
      response.protocolVersion =
          json['result']['protocolVersion']; // protocol version >= 22
    }
  } else if (json['error'] != null) {
    response.error = SorobanRpcErrorResponse.fromJson(json);
  }
  return response;
}