-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented use case for create files on non-gms module
- Loading branch information
1 parent
e406f71
commit ccf3917
Showing
8 changed files
with
61 additions
and
11 deletions.
There are no files selected for viewing
17 changes: 14 additions & 3 deletions
17
...ms/src/main/java/com/omh/android/storage/api/drive/nongms/data/GoogleStorageApiService.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
package com.omh.android.storage.api.drive.nongms.data | ||
|
||
import com.omh.android.storage.api.drive.nongms.data.source.body.CreateFileBody | ||
import com.omh.android.storage.api.drive.nongms.data.source.response.FileListRemoteResponse | ||
import com.omh.android.storage.api.drive.nongms.data.source.response.FileRemoteResponse | ||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Query | ||
|
||
internal interface GoogleStorageApiService { | ||
|
||
companion object { | ||
private const val GET_ALL_FILES_AND_FOLDERS_LIST_PARTICLE = "files" | ||
private const val FILES_PARTICLE = "files" | ||
|
||
private const val QUERY_Q = "q" | ||
private const val QUERY_FIELDS = "fields" | ||
|
||
private const val Q_VALUE = "'root' in parents and trashed = false" | ||
private const val FIELDS_VALUE = "files(id, name, mimeType, modifiedTime)" | ||
private const val QUERY_REQUESTED_FIELDS = "id,name,mimeType,modifiedTime" | ||
private const val FIELDS_VALUE = "files($QUERY_REQUESTED_FIELDS)" | ||
} | ||
|
||
@GET(GET_ALL_FILES_AND_FOLDERS_LIST_PARTICLE) | ||
@GET(FILES_PARTICLE) | ||
fun getRootFilesList( | ||
@Query(QUERY_Q) query: String = Q_VALUE, | ||
@Query(QUERY_FIELDS) fields: String = FIELDS_VALUE | ||
): Call<FileListRemoteResponse> | ||
|
||
@POST(FILES_PARTICLE) | ||
fun createFile( | ||
@Query(QUERY_FIELDS) query: String = QUERY_REQUESTED_FIELDS, | ||
@Body body: CreateFileBody | ||
): Call<FileRemoteResponse> | ||
} |
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
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
6 changes: 6 additions & 0 deletions
6
...src/main/java/com/omh/android/storage/api/drive/nongms/data/source/body/CreateFileBody.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.omh.android.storage.api.drive.nongms.data.source.body | ||
|
||
data class CreateFileBody( | ||
val mimeType: String, | ||
val name: String | ||
) |
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
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
5 changes: 0 additions & 5 deletions
5
storage-api/src/main/java/com/omh/android/storage/api/domain/usecase/CreateFile.kt
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
storage-api/src/main/java/com/omh/android/storage/api/domain/usecase/CreateFileUseCase.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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 CreateFileUseCase( | ||
private val repository: FileRepository, | ||
dispatcher: CoroutineDispatcher = Dispatchers.Default | ||
) : OmhSuspendUseCase<CreateFileUseCaseParams, CreateFileUseCaseResult>(dispatcher) { | ||
|
||
override suspend fun execute(parameters: CreateFileUseCaseParams) = CreateFileUseCaseResult( | ||
repository.createFile(parameters.name, parameters.mimeType) | ||
) | ||
} | ||
|
||
data class CreateFileUseCaseParams(val name: String, val mimeType: String) | ||
|
||
data class CreateFileUseCaseResult(val file: OmhFile?) |