Skip to content
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
@@ -1,10 +1,12 @@
package com.yapp.ndgl.data.travel.api

import com.yapp.ndgl.data.core.model.BaseResponse
import com.yapp.ndgl.data.travel.model.GetBookmarkedPlacesResponse
import com.yapp.ndgl.data.travel.model.GetPlacePhotosResponse
import com.yapp.ndgl.data.travel.model.PlaceDetailResponse
import com.yapp.ndgl.data.travel.model.SavePlaceRequest
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query
Expand All @@ -24,4 +26,20 @@ interface PlaceApi {
suspend fun getPlacePhotos(
@Query("googlePlaceId") googlePlaceId: String,
): BaseResponse<GetPlacePhotosResponse>

@GET("/api/v1/places/favorite")
suspend fun getBookmarkedPlaces(
@Query("page") page: Int? = null,
@Query("size")size: Int? = null,
): BaseResponse<GetBookmarkedPlacesResponse>

@POST("/api/v1/places/favorite")
suspend fun bookmarkPlace(
@Query("googlePlaceId") googlePlaceId: String,
): BaseResponse<Unit>

@DELETE("/api/v1/places/favorite")
suspend fun unBookmarkPlace(
@Query("googlePlaceId") googlePlaceId: String,
): BaseResponse<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.yapp.ndgl.data.travel.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class GetBookmarkedPlacesResponse(
@SerialName("content")
val places: List<PlaceInfo>,
val hasNext: Boolean,
)

@Serializable
data class PlaceInfo(
val id: Long,
val googlePlaceId: String,
val name: String,
val formattedAddress: String?,
val latitude: Double,
val longitude: Double,
val thumbnail: String?,
val rating: Double?,
val userRatingCount: Int?,
val category: PlaceCategory,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.google.android.libraries.places.api.net.PlacesClient
import com.yapp.ndgl.data.core.model.error.HttpResponseException
import com.yapp.ndgl.data.core.model.getData
import com.yapp.ndgl.data.travel.api.PlaceApi
import com.yapp.ndgl.data.travel.model.GetBookmarkedPlacesResponse
import com.yapp.ndgl.data.travel.model.GetPlacePhotosResponse
import com.yapp.ndgl.data.travel.model.PlaceDetailResponse
import com.yapp.ndgl.data.travel.model.SavePlaceRequest
Expand Down Expand Up @@ -63,4 +64,16 @@ class PlaceRepository @Inject constructor(
suspend fun getPlacePhotos(googlePlaceId: String): GetPlacePhotosResponse {
return placeApi.getPlacePhotos(googlePlaceId).getData()
}

suspend fun getBookmarkedPlaces(page: Int? = null, size: Int? = null): GetBookmarkedPlacesResponse {
return placeApi.getBookmarkedPlaces(page = page, size = size).getData()
}

suspend fun bookmarkPlace(googlePlaceId: String) {
placeApi.bookmarkPlace(googlePlaceId).getData()
}

suspend fun unBookmarkPlace(googlePlaceId: String) {
placeApi.unBookmarkPlace(googlePlaceId).getData()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ data class SelectablePlace(
val googlePlaceId: String,
val name: String,
val placeType: PlaceType = PlaceType.ATTRACTION,
val thumbnail: String,
val thumbnail: String?,
)

data class SelectedPlaceDetail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,47 +178,34 @@ private fun AddItineraryScreen(
}
}

private val previewRecommendedPlaces = listOf(
SelectablePlace(
googlePlaceId = "place_1",
name = "카피톨리니 박물관 (Musei Capitolini)",
placeType = PlaceType.ATTRACTION,
thumbnail = "https://picsum.photos/seed/capitolini/200",
),
SelectablePlace(
googlePlaceId = "place_2",
name = "콜로세움 (Colosseo)",
placeType = PlaceType.ATTRACTION,
thumbnail = "https://picsum.photos/seed/colosseo/200",
),
SelectablePlace(
googlePlaceId = "place_3",
name = "젤라테리아 파씨 (Gelateria Fassi)",
placeType = PlaceType.CAFE,
thumbnail = "https://picsum.photos/seed/gelato/200",
),
)

private val previewSelectedPlaceDetail = SelectedPlaceDetail(
placeInfo = PlaceInfo(
googlePlaceId = "1",
name = "콜로세움",
placeType = PlaceType.ATTRACTION,
rating = 4.8,
userRatingCount = 12450,
address = "Piazza del Colosseo, 1, 00184 Roma RM, Italy",
phoneNumber = "+39 06 3996 7700",
websiteUrl = "https://www.colosseo.it",
estimatedDuration = 2.hours,
),
)

@Preview(showBackground = true)
@Composable
private fun AddItineraryScreenWithAddItineraryBottomSheetPreview() {
NDGLTheme {
AddItineraryScreen(
state = AddItineraryState(day = 1, recommendedPlaces = previewRecommendedPlaces),
state = AddItineraryState(
day = 1,
recommendedPlaces = listOf(
SelectablePlace(
googlePlaceId = "place_1",
name = "카피톨리니 박물관 (Musei Capitolini)",
placeType = PlaceType.ATTRACTION,
thumbnail = "https://picsum.photos/seed/capitolini/200",
),
SelectablePlace(
googlePlaceId = "place_2",
name = "콜로세움 (Colosseo)",
placeType = PlaceType.ATTRACTION,
thumbnail = "https://picsum.photos/seed/colosseo/200",
),
SelectablePlace(
googlePlaceId = "place_3",
name = "젤라테리아 파씨 (Gelateria Fassi)",
placeType = PlaceType.CAFE,
thumbnail = "https://picsum.photos/seed/gelato/200",
),
),
),
clickBack = {},
updateKeyword = {},
searchKeyword = {},
Expand All @@ -243,7 +230,19 @@ private fun AddItineraryWithSearchedPlaceBottomSheetPreview() {
state = AddItineraryState(
day = 1,
isSearched = true,
selectedPlaceDetail = previewSelectedPlaceDetail,
selectedPlaceDetail = SelectedPlaceDetail(
placeInfo = PlaceInfo(
googlePlaceId = "1",
name = "콜로세움",
placeType = PlaceType.ATTRACTION,
rating = 4.8,
userRatingCount = 12450,
address = "Piazza del Colosseo, 1, 00184 Roma RM, Italy",
phoneNumber = "+39 06 3996 7700",
websiteUrl = "https://www.colosseo.it",
estimatedDuration = 2.hours,
),
),
),
clickBack = {},
updateKeyword = {},
Expand Down
Loading