This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const val CLIENT_ERROR = "Terjadi kesalahan, mohon periksa masukan anda" | |
const val SERVER_ERROR = "Terjadi kesalahan pada Server, coba lagi nanti" | |
const val NETWORK_ERROR = "Koneksi internet bermasalah, coba lagi nanti" | |
const val HTTP_UNKNOWN_ERROR = "HTTP Error tidak diketahui (exc: 4xx/5xx)" | |
const val UNKNOWN_ERROR = "Error tidak diketahui" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GET("list/{id}") | |
suspend fun getDetailAgentVisitWithFullResponse( | |
@Header("Authorization") token: String, | |
@Path(value = "id", encoded = true) id: Int | |
): BaseResponse<GetAgentDetailResponse> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suspend fun getDetailAgentVisitFullResponse( | |
token: String, | |
id: Int | |
): SallyResponseResource<BaseResponse<GetAgentDetailResponse>> { | |
return asSallyResponseResourceSuspend { | |
agentVisitService.getDetailAgentVisitWithFullResponse( | |
token = token, | |
id = id | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getDetailAgentVisitFullResponseFlow( | |
token: String, | |
id: Int | |
): Flow<BaseResponse<GetAgentDetailResponse>> { | |
return flow { | |
while (true) { | |
val getDetailAgent = agentVisitService.getDetailAgentVisitWithFullResponse( | |
token = token, | |
id = id | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override suspend fun getDetailAgentVisitWithFullResponse(id: Int): SallyResponseResource<BaseResponse<GetAgentDetailResponse>> { | |
return agentVisitDataSource.getDetailAgentVisitFullResponse( | |
token = "", | |
id = id | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun getDetailAgentVisitFullResponseFlow(id: Int): Flow<SallyResponseResource<BaseResponse<GetAgentDetailResponse>>> { | |
return agentVisitDataSource.getDetailAgentVisitFullResponseFlow( | |
token = "", | |
id = id | |
).asSallyResponseResourceFlow() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override suspend fun getDetailAgentVisitWithFullResponse(id: Int): SallyResponseResource<BaseResponse<GetAgentDetailResponse>> { | |
return iAgentVisitRepository.getDetailAgentVisitWithFullResponse(id) | |
} | |
override fun getDetailAgentVisitFullResponseFlow(id: Int): Flow<SallyResponseResource<BaseResponse<GetAgentDetailResponse>>> { | |
return iAgentVisitRepository.getDetailAgentVisitFullResponseFlow(id) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed interface VisitingUiEvent { | |
data class ShowErrorMessageStatic( | |
val staticError: String?, | |
val dynamicError: String?, | |
val errorCode: String? | |
) : VisitingUiEvent | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed interface VisitingDetailUiState { | |
object Loading : VisitingDetailUiState | |
data class Error(val error: String) : VisitingDetailUiState | |
data class Success( | |
val agentVisitingDetail: GetAgentDetailResponse? = null | |
) : VisitingDetailUiState | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val _uiStateDetail = | |
MutableStateFlow<VisitingDetailUiState>(VisitingDetailUiState.Loading) | |
val uiStateDetail = _uiStateDetail.asStateFlow() | |
private val _eventFlow = MutableSharedFlow<VisitingUiEvent>(replay = 1) | |
val eventFlow = _eventFlow.asSharedFlow() |