fromJson static method
Factory method to parse a JSON map and statusCode
into an UnauthorizedResponse object.
Returns null
if the statusCode
is not 401, indicating it's not an unauthorized response.
Example:
final response = UnauthorizedResponse.fromJson(jsonMap, 401);
Implementation
static UnauthorizedResponse? fromJson(
Map<String, dynamic> json, int statusCode) {
return statusCode == 401
? UnauthorizedResponse(
timestamp: json['timestamp'],
statusCode: json['status'],
error: json['error'],
message: json['message'],
)
: null;
}