Skip to content

Commit 92c889a

Browse files
endpoint updated
1 parent 727dda5 commit 92c889a

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

app/src/main/java/com/github/code/gambit/network/api/ApiService.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.github.code.gambit.network.api
33
import com.github.code.gambit.data.entity.network.FileNetworkEntity
44
import com.github.code.gambit.data.entity.network.UrlNetworkEntity
55
import com.github.code.gambit.data.entity.network.UserNetworkEntity
6+
import com.github.code.gambit.utility.AppConstant
67
import retrofit2.http.Body
78
import retrofit2.http.DELETE
89
import retrofit2.http.GET
@@ -17,33 +18,33 @@ interface ApiService {
1718
suspend fun getUser(@Path("userId") @Named("UID") userId: String): UserNetworkEntity
1819

1920
@PUT("user/{userId}")
20-
suspend fun updateUser(@Path("userId") @Named("UID") userId: String, @Body userNetworkEntity: UserNetworkEntity): UserNetworkEntity
21+
suspend fun updateUser(@Path("userId") @Named(AppConstant.Named.USER_ID) userId: String, @Body userNetworkEntity: UserNetworkEntity): UserNetworkEntity
2122

2223
@DELETE("user/{userId}")
23-
suspend fun deleteUser(@Path("userId") @Named("UID") userId: String): UserNetworkEntity
24+
suspend fun deleteUser(@Path("userId") @Named(AppConstant.Named.USER_ID) userId: String): UserNetworkEntity
2425

2526
@GET("user/{userId}/file")
26-
suspend fun getFiles(@Path("userId") @Named("UID") userId: String): List<FileNetworkEntity>
27+
suspend fun getFiles(@Path("userId") @Named(AppConstant.Named.USER_ID) userId: String): List<FileNetworkEntity>
2728

2829
@POST("user/{userId}/file")
29-
suspend fun uploadFiles(@Path("userId") @Named("UID") userId: String, @Body fileNetworkEntity: FileNetworkEntity): FileNetworkEntity
30+
suspend fun uploadFiles(@Path("userId") @Named(AppConstant.Named.USER_ID) userId: String, @Body fileNetworkEntity: FileNetworkEntity): FileNetworkEntity
3031

31-
@DELETE("file/{fileId}")
32-
suspend fun deleteFile(@Path("fileId") fileId: String): FileNetworkEntity
32+
@DELETE("user/{userId}/file/{fileId}")
33+
suspend fun deleteFile(@Path(AppConstant.API_PATH.USER_ID) userId: String, @Path(AppConstant.API_PATH.FILE_ID) fileId: String): FileNetworkEntity
3334

3435
@GET("file/{fileId}/url")
35-
suspend fun getUrls(@Path("fileId") fileId: String): List<UrlNetworkEntity>
36+
suspend fun getUrls(@Path(AppConstant.API_PATH.FILE_ID) fileId: String): List<UrlNetworkEntity>
3637

3738
@POST("file/{fileId}/url")
38-
suspend fun generateUrl(@Path("fileId") fileId: String): UrlNetworkEntity
39+
suspend fun generateUrl(@Path(AppConstant.API_PATH.FILE_ID) fileId: String): UrlNetworkEntity
3940

4041
@PUT("file/{fileId}/url/{urlId}")
4142
suspend fun updateUrl(
42-
@Path("fileId") fileId: String,
43-
@Path("urlId") urlId: String,
43+
@Path(AppConstant.API_PATH.FILE_ID) fileId: String,
44+
@Path(AppConstant.API_PATH.URL_ID) urlId: String,
4445
@Body urlNetworkEntity: UrlNetworkEntity
4546
): UrlNetworkEntity
4647

4748
@DELETE("file/{fileId}/url/{urlId}")
48-
suspend fun deleteUrl(@Path("fileId") fileId: String, @Path("urlId") urlId: String): UrlNetworkEntity
49+
suspend fun deleteUrl(@Path(AppConstant.API_PATH.FILE_ID) fileId: String, @Path(AppConstant.API_PATH.URL_ID) urlId: String): UrlNetworkEntity
4950
}

app/src/main/java/com/github/code/gambit/network/api/NetworkDataSource.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import javax.inject.Named
88
interface NetworkDataSource {
99
suspend fun getFiles(@Named("UID") userId: String): List<File>
1010
suspend fun uploadFile(@Named("UID") userId: String, fileNetworkEntity: File): File
11-
suspend fun deleteFile(fileId: String): File
11+
suspend fun deleteFile(userId: String, fileId: String): File
1212

1313
suspend fun getUrls(fileId: String): List<Url>
1414
suspend fun generateUrl(fileId: String): Url

app/src/main/java/com/github/code/gambit/network/api/NetworkDataSourceImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class NetworkDataSourceImpl(
2727
return fileNetworkMapper.mapFromEntity(fileService.uploadFile(userId, fileNetworkMapper.mapToEntity(file)))
2828
}
2929

30-
override suspend fun deleteFile(fileId: String): File {
31-
return fileNetworkMapper.mapFromEntity(fileService.deleteFile(fileId))
30+
override suspend fun deleteFile(userId: String, fileId: String): File {
31+
return fileNetworkMapper.mapFromEntity(fileService.deleteFile(userId, fileId))
3232
}
3333

3434
override suspend fun getUrls(fileId: String): List<Url> {

app/src/main/java/com/github/code/gambit/network/api/file/FileService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ interface FileService {
77

88
suspend fun getFiles(@Named("UID") userId: String): List<FileNetworkEntity>
99
suspend fun uploadFile(@Named("UID") userId: String, fileNetworkEntity: FileNetworkEntity): FileNetworkEntity
10-
suspend fun deleteFile(fileId: String): FileNetworkEntity
10+
suspend fun deleteFile(userId: String, fileId: String): FileNetworkEntity
1111
}

app/src/main/java/com/github/code/gambit/network/api/file/FileServiceImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FileServiceImpl(val apiService: ApiService) : FileService {
1616
return apiService.uploadFiles(userId, fileNetworkEntity)
1717
}
1818

19-
override suspend fun deleteFile(fileId: String): FileNetworkEntity {
20-
return apiService.deleteFile(fileId)
19+
override suspend fun deleteFile(userId: String, fileId: String): FileNetworkEntity {
20+
return apiService.deleteFile(userId, fileId)
2121
}
2222
}

app/src/main/java/com/github/code/gambit/utility/AppConstant.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@ object AppConstant {
44
object RequestCode {
55
const val PERMISSIONS = 101
66
}
7+
78
object Named {
89
const val PERMISSION_ARRAY = "PERMISSION"
910
const val USER_ID = "UID"
1011
}
12+
1113
object Cloudinary {
1214
const val UPLOAD_PRESET = "mqlj7ft0"
1315
const val RESULT_URL_KEY = "url"
14-
const val BASE_URL = "http://res.cloudinary.com/code-gambit/image/upload/v1619956278/Profile%20Image/"
16+
const val BASE_URL =
17+
"http://res.cloudinary.com/code-gambit/image/upload/v1619956278/Profile%20Image/"
18+
}
19+
20+
object API_PATH {
21+
const val USER_ID = "userId"
22+
const val FILE_ID = "fileId"
23+
const val URL_ID = "urlId"
1524
}
1625
}

0 commit comments

Comments
 (0)