-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #289 from Nexters/feature/Boolti-287
Feature/boolti 287 프로필 조회 및 편집
- Loading branch information
Showing
48 changed files
with
2,046 additions
and
66 deletions.
There are no files selected for viewing
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
30 changes: 30 additions & 0 deletions
30
data/src/main/java/com/nexters/boolti/data/datasource/FileDataSource.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,30 @@ | ||
package com.nexters.boolti.data.datasource | ||
|
||
import android.content.Context | ||
import com.nexters.boolti.data.network.api.AuthFileService | ||
import com.nexters.boolti.data.network.api.FileService | ||
import com.nexters.boolti.data.network.response.UploadUrlsDto | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.RequestBody.Companion.asRequestBody | ||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
internal class FileDataSource @Inject constructor( | ||
@ApplicationContext private val context: Context, | ||
private val authFileService: AuthFileService, | ||
private val fileService: FileService, | ||
) { | ||
suspend fun requestUploadUrls(file: File): Result<UploadUrlsDto> = runCatching { | ||
authFileService.requestUploadUrls().also { | ||
val url = it.uploadUrl | ||
fileService.requestUploadImage( | ||
contentType = "image/jpeg", | ||
url = url, | ||
file = file.asRequestBody("image/jpeg".toMediaType()), | ||
) | ||
} | ||
}.onFailure { | ||
it.printStackTrace() | ||
} | ||
} |
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
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
9 changes: 9 additions & 0 deletions
9
data/src/main/java/com/nexters/boolti/data/network/api/AuthFileService.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,9 @@ | ||
package com.nexters.boolti.data.network.api | ||
|
||
import com.nexters.boolti.data.network.response.UploadUrlsDto | ||
import retrofit2.http.POST | ||
|
||
interface AuthFileService { | ||
@POST("/app/api/v1/user/profile-images/upload-urls") | ||
suspend fun requestUploadUrls(): UploadUrlsDto | ||
} |
16 changes: 16 additions & 0 deletions
16
data/src/main/java/com/nexters/boolti/data/network/api/FileService.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,16 @@ | ||
package com.nexters.boolti.data.network.api | ||
|
||
import okhttp3.RequestBody | ||
import retrofit2.http.Body | ||
import retrofit2.http.Header | ||
import retrofit2.http.PUT | ||
import retrofit2.http.Url | ||
|
||
internal interface FileService { | ||
@PUT | ||
suspend fun requestUploadImage( | ||
@Header("Content-Type") contentType: String, | ||
@Url url: String, | ||
@Body file: RequestBody, | ||
) | ||
} |
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
9 changes: 9 additions & 0 deletions
9
data/src/main/java/com/nexters/boolti/data/network/response/UploadUrlsDto.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,9 @@ | ||
package com.nexters.boolti.data.network.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class UploadUrlsDto( | ||
val uploadUrl: String, | ||
val expectedUrl: 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
13 changes: 13 additions & 0 deletions
13
data/src/main/java/com/nexters/boolti/data/repository/FileRepositoryImpl.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,13 @@ | ||
package com.nexters.boolti.data.repository | ||
|
||
import com.nexters.boolti.data.datasource.FileDataSource | ||
import com.nexters.boolti.domain.repository.FileRepository | ||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
internal class FileRepositoryImpl @Inject constructor( | ||
private val dataSource: FileDataSource, | ||
) : FileRepository { | ||
override suspend fun requestUrlForUpload(file: File): Result<String> = | ||
dataSource.requestUploadUrls(file).map { it.expectedUrl } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.nexters.boolti.domain.model | ||
|
||
data class Link( | ||
val id: String, | ||
val name: String, | ||
val url: 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
Oops, something went wrong.