execute method
Implementation
Future<AuthResponse> execute(String appPackageName, String authCode,
String deviceId, String email) async {
if (authCode.isEmpty) {
return ErrorResponse(400, "Invalid code", "Please enter a code");
}
var authResponse = await _remoteStorageDatasource.getRefreshTokenFromApi(
appPackageName, authCode, deviceId, email);
switch (authResponse) {
case ErrorResponse():
break;
case SuccessResponse():
YLog.d("Body: ${authResponse.body}");
try {
ApiResponseModel apiResponseModel =
ApiResponseModel.fromJson(json.decode(authResponse.body));
if (apiResponseModel.expressToken?.refreshToken != null) {
_preferencesDatasource.saveRefreshToken(
apiResponseModel.expressToken?.refreshToken ?? "");
_cacheApiResponseUseCase.update(apiResponseModel);
SessionModel sessionModel =
SessionModel.fromJson(json.decode(authResponse.body));
_preferencesDatasource
.saveSession(jsonEncode(sessionModel.toJson()));
}
} catch (e) {
YLog.d("RequestRefreshTokenUseCase: Token Model exception: ${e}");
}
break;
}
return authResponse;
}