fromJson static method
Implementation
static ApiRequestAuthorizationEntity fromJson(Map<String, dynamic> json) {
if (json['authorization_method'] == null) {
return const ApiRequestNoneAuthorizationEntity(
authorizationMethod: APIRequestAuthorizationMethods.none,
);
}
if (json['authorization_method'] ==
EnumToString.convertToString(APIRequestAuthorizationMethods.none)) {
return const ApiRequestNoneAuthorizationEntity(
authorizationMethod: APIRequestAuthorizationMethods.none,
);
}
if (json['authorization_method'] ==
EnumToString.convertToString(APIRequestAuthorizationMethods.bearer)) {
return ApiRequestBearerAuthorizationEntity(
bearerToken: json['token'] as String? ?? '',
);
}
if (json['authorization_method'] ==
EnumToString.convertToString(APIRequestAuthorizationMethods.custom)) {
return ApiRequestCustomAuthorizationEntity(
customData: json['custom_data'] as String? ?? '',
);
}
return ApiRequestBasicAuthorizationEntity(
authorizationMethod: EnumToString.fromString(
APIRequestAuthorizationMethods.values,
json['authorization_method']) ??
APIRequestAuthorizationMethods.none,
username: json['username'] as String,
password: json['password'] as String,
);
}