Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API - Add methods documentation #91

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ abstract class OmhStorageClient protected constructor(

protected abstract fun getRepository(): OmhFileRepository

/**
* This method list files from an specific folder
*
* @param parentId The id of the folder you want to get the list of files
*
* @return An OmhTask with the result of the operation
*/
fun listFiles(parentId: String): OmhTask<GetFilesListUseCaseResult> {
val getFilesListUseCase = GetFilesListUseCase(getRepository())
return OmhStorageTaskImpl {
Expand All @@ -61,6 +68,15 @@ abstract class OmhStorageClient protected constructor(
}
}

/**
* This method create files in an specific folder
*
* @param name The name of the file to be created
* @param mimeType The mimeType of the file to be created
* @param parentId The id of the folder where the file will be created
*
* @return An OmhTask with the result of the operation
*/
fun createFile(
name: String,
mimeType: String,
Expand All @@ -74,6 +90,13 @@ abstract class OmhStorageClient protected constructor(
}
}

/**
* This method delete files with a given file id
*
* @param id The id of the desired file to delete
*
* @return An OmhTask with the result of the operation
*/
fun deleteFile(id: String): OmhTask<DeleteFileUseCaseResult> {
val deleteFileUseCase = DeleteFileUseCase(getRepository())
return OmhStorageTaskImpl {
Expand All @@ -83,6 +106,14 @@ abstract class OmhStorageClient protected constructor(
}
}

/**
* This method upload a file in an specific folder
*
* @param localFileToUpload The file to be uploaded
* @param parentId The id of the folder where the file will be uploaded
*
* @return An OmhTask with the result of the operation
*/
fun uploadFile(
localFileToUpload: File,
parentId: String?
Expand All @@ -95,6 +126,14 @@ abstract class OmhStorageClient protected constructor(
}
}

/**
* This method download a file with a given mime type and a given id
*
* @param fileId The id fo the file to be downloaded
* @param mimeType The mimeType of the file to be downloaded
*
* @return An OmhTask with the result of the operation
*/
fun downloadFile(fileId: String, mimeType: String?): OmhTask<DownloadFileUseCaseResult> {
val downloadFileUseCase = DownloadFileUseCase(getRepository())
return OmhStorageTaskImpl {
Expand All @@ -104,6 +143,14 @@ abstract class OmhStorageClient protected constructor(
}
}

/**
* This method update a remote file with the content of a local file
*
* @param localFileToUpload The local file to be uploaded
* @param fileId The id of the desired file to be updated
*
* @return An OmhTask with the result of the operation
*/
fun updateFile(
localFileToUpload: File,
fileId: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,62 @@ import java.io.File

interface OmhFileRemoteDataSource {

/**
* This method list files from an specific folder
*
* @param parentId The id of the folder you want to get the list of files
*
* @return A list of OmhFiles
*/
fun getFilesList(parentId: String = "root"): List<OmhFile>

/**
* This method create files in an specific folder
*
* @param name The name of the file to be created
* @param mimeType The mimeType of the file to be created
* @param parentId The id of the folder where the file will be created
*
* @return An OmhFile with the information of the created file. Null in case the file was not created
*/
fun createFile(name: String, mimeType: String, parentId: String?): OmhFile?

/**
* This method delete files with a given file id
*
* @param fileId The id of the desired file to delete
*
* @return true if the file was deleted, false otherwise
*/
fun deleteFile(fileId: String): Boolean

/**
* This method upload a file in an specific folder
*
* @param localFileToUpload The file to be uploaded
* @param parentId The id of the folder where the file will be uploaded
*
* @return An OmhFile with the information of the uploaded file. Null in case the file was not uploaded
*/
fun uploadFile(localFileToUpload: File, parentId: String?): OmhFile?

/**
* This method download a file with a given mime type and a given id
*
* @param fileId The id fo the file to be downloaded
* @param mimeType The mimeType of the file to be downloaded
*
* @return A ByteArrayOutputStream with the content of the downloaded file
*/
fun downloadFile(fileId: String, mimeType: String?): ByteArrayOutputStream

/**
* This method update a remote file with the content of a local file
*
* @param localFileToUpload The local file to be uploaded
* @param fileId The id of the desired file to be updated
*
* @return An OmhFile with the information of the updated file
*/
fun updateFile(localFileToUpload: File, fileId: String): OmhFile?
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,62 @@ import java.io.File

interface OmhFileRepository {

/**
* This method list files from an specific folder
*
* @param parentId The id of the folder you want to get the list of files
*
* @return A list of OmhFiles
*/
fun getFilesList(parentId: String = "root"): List<OmhFile>

/**
* This method create files in an specific folder
*
* @param name The name of the file to be created
* @param mimeType The mimeType of the file to be created
* @param parentId The id of the folder where the file will be created
*
* @return An OmhFile with the information of the created file. Null in case the file was not created
*/
fun createFile(name: String, mimeType: String, parentId: String?): OmhFile?

/**
* This method delete files with a given file id
*
* @param fileId The id of the desired file to delete
*
* @return true if the file was deleted, false otherwise
*/
fun deleteFile(fileId: String): Boolean

/**
* This method upload a file in an specific folder
*
* @param localFileToUpload The file to be uploaded
* @param parentId The id of the folder where the file will be uploaded
*
* @return An OmhFile with the information of the uploaded file. Null in case the file was not uploaded
*/
fun uploadFile(localFileToUpload: File, parentId: String?): OmhFile?

/**
* This method download a file with a given mime type and a given id
*
* @param fileId The id fo the file to be downloaded
* @param mimeType The mimeType of the file to be downloaded
*
* @return A ByteArrayOutputStream with the content of the downloaded file
*/
fun downloadFile(fileId: String, mimeType: String?): ByteArrayOutputStream

/**
* This method update a remote file with the content of a local file
*
* @param localFileToUpload The local file to be uploaded
* @param fileId The id of the desired file to be updated
*
* @return An OmhFile with the information of the updated file
*/
fun updateFile(localFileToUpload: File, fileId: String): OmhFile?
}