Request.fromJson constructor

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

Implementation

factory Request.fromJson(Map<String, dynamic> json) {
  try {
    return Request(
      timestamp:
          json['timestamp'] ?? DateTime.now().toUtc().millisecondsSinceEpoch,
      url: json['url'],
      method: json['method'],
      dataSent: json['data_sent']?.toInt(),
      dataReceived: json['data_received']?.toInt(),
      statusCode: json['status_code']?.toInt(),
      duration: json['duration']?.toInt(),
      body: json['body'],
      request: json['request'],
      subCode: json['sub_code'],
      message: json['message'],
      headers: json['headers'],
    );
  } catch (e) {
    return Request(timestamp: DateTime.now().toUtc().millisecondsSinceEpoch);
  }
}