Skip to content

Commit

Permalink
Refactor: Rename GetFilesListWithParentIdUseCase into GetFilesListUse…
Browse files Browse the repository at this point in the history
…Case (#31)
  • Loading branch information
HectorNarvaez committed Jun 8, 2023
1 parent a0ed0ff commit c93935a
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal interface GoogleStorageApiService {
}

@GET(FILES_PARTICLE)
fun getFilesListWithParentId(
fun getFilesList(
@Query(QUERY_Q) query: String,
@Query(QUERY_FIELDS) fields: String = FIELDS_VALUE
): Call<FileListRemoteResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ internal class NonGmsFileRepositoryImpl(
private val dataSource: OmhFileRemoteDataSource
) : FileRepository {

override fun getFilesListWithParentId(parentId: String) =
dataSource.getFilesListWithParentId(parentId)
override fun getFilesList(parentId: String) =
dataSource.getFilesList(parentId)

override fun createFile(name: String, mimeType: String, parentId: String?) =
dataSource.createFile(name, mimeType, parentId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import com.omh.android.storage.api.drive.nongms.data.source.mapper.toFileList
internal class NonGmsFileRemoteDataSourceImpl(private val retrofitImpl: GoogleRetrofitImpl) :
OmhFileRemoteDataSource {

override fun getFilesListWithParentId(parentId: String): List<OmhFile> {
override fun getFilesList(parentId: String): List<OmhFile> {
val response = retrofitImpl
.getGoogleStorageApiService()
.getFilesListWithParentId(
.getFilesList(
query = GoogleStorageApiService.getQueryValue(parentId)
)
.execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.omh.android.auth.api.OmhAuthClient
import com.omh.android.storage.api.domain.repository.FileRepository
import com.omh.android.storage.api.domain.usecase.CreateFileUseCase
import com.omh.android.storage.api.domain.usecase.DeleteFileUseCase
import com.omh.android.storage.api.domain.usecase.GetFilesListWithParentIdUseCase
import com.omh.android.storage.api.domain.usecase.GetFilesListUseCase

abstract class OmhStorageClient protected constructor(
protected val authClient: OmhAuthClient
Expand All @@ -23,7 +23,7 @@ abstract class OmhStorageClient protected constructor(
* and will not return an use case
*/
@SuppressWarnings("ForbiddenComment")
fun listFiles() = GetFilesListWithParentIdUseCase(getRepository())
fun listFiles() = GetFilesListUseCase(getRepository())

fun createFile() = CreateFileUseCase(getRepository())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.omh.android.storage.api.domain.model.OmhFile

interface OmhFileRemoteDataSource {

fun getFilesListWithParentId(parentId: String = "root"): List<OmhFile>
fun getFilesList(parentId: String = "root"): List<OmhFile>

fun createFile(name: String, mimeType: String, parentId: String?): OmhFile?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.omh.android.storage.api.domain.model.OmhFile

interface FileRepository {

fun getFilesListWithParentId(parentId: String = "root"): List<OmhFile>
fun getFilesList(parentId: String = "root"): List<OmhFile>

fun createFile(name: String, mimeType: String, parentId: String?): OmhFile?

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.omh.android.storage.api.domain.usecase

import com.omh.android.storage.api.domain.model.OmhFile
import com.omh.android.storage.api.domain.repository.FileRepository
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers

class GetFilesListUseCase(
private val repository: FileRepository,
dispatcher: CoroutineDispatcher = Dispatchers.Default
) : OmhSuspendUseCase<GetFilesListUseCaseParams, GetFilesListUseCaseResult>(dispatcher) {

override suspend fun execute(
parameters: GetFilesListUseCaseParams
) = GetFilesListUseCaseResult(
repository.getFilesList(parameters.parentId)
)
}

data class GetFilesListUseCaseParams(val parentId: String = "root")

data class GetFilesListUseCaseResult(val files: List<OmhFile>)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.omh.android.storage.api.OmhStorageClient
import com.omh.android.storage.api.domain.model.OmhFileType
import com.omh.android.storage.api.domain.usecase.CreateFileUseCase
import com.omh.android.storage.api.domain.usecase.CreateFileUseCaseParams
import com.omh.android.storage.api.domain.usecase.GetFilesListWithParentIdUseCase
import com.omh.android.storage.api.domain.usecase.GetFilesListWithParentIdUseCaseParams
import com.omh.android.storage.api.domain.usecase.GetFilesListUseCase
import com.omh.android.storage.api.domain.usecase.GetFilesListUseCaseParams
import com.omh.android.storage.api.domain.usecase.OmhResult
import com.omh.android.storage.sample.domain.model.FileType
import com.omh.android.storage.sample.presentation.BaseViewModel
Expand Down Expand Up @@ -54,10 +54,10 @@ class FileViewerViewModel @Inject constructor(
setState(FileViewerViewState.Loading)
val parentId = parentIdStack.peek()

val listFilesUseCase: GetFilesListWithParentIdUseCase = omhStorageClient.listFiles()
val listFilesUseCase: GetFilesListUseCase = omhStorageClient.listFiles()

when (
val result = listFilesUseCase(GetFilesListWithParentIdUseCaseParams(parentId))
val result = listFilesUseCase(GetFilesListUseCaseParams(parentId))
) {
is OmhResult.OmhSuccess -> {
setState(FileViewerViewState.Content(result.data.files))
Expand Down

0 comments on commit c93935a

Please sign in to comment.