Skip to content

Commit

Permalink
Merge pull request #19 from KanuKim97/hotfix/network-model
Browse files Browse the repository at this point in the history
[Hot Fix] Fix Kotlin Serialization Exception
  • Loading branch information
KanuKim97 authored Aug 24, 2024
2 parents 3c99dbe + 8715d06 commit 9a5ca64
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 65 deletions.
44 changes: 44 additions & 0 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class GetGridItemUseCase @Inject constructor(
.map { result ->
result.map {
GridItemsModel(
placeID = it.placeId,
name = it.name,
placeID = it.placeId ?: "",
name = it.name ?: "",
photoRef = if (it.photos.isNotEmpty()) {
it.photos[0].getFullPhotoReference(BuildConfig.PLACE_API_KEY)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class GetMainBannerUseCase @Inject constructor(
.map { result ->
result.map {
BannerItemsModel(
placeID = it.placeId,
name = it.name,
placeID = it.placeId ?: "",
name = it.name ?: "",
photoRef = it.photos[0].getFullPhotoReference(BuildConfig.PLACE_API_KEY)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class GetPlaceDetailUseCase @Inject constructor(
DetailedModel(
placeId = value?.placeId.toString(),
placeName = value?.name.toString(),
placeImgUrl = value?.photos?.get(0)?.getFullPhotoReference(BuildConfig.PLACE_API_KEY) ?: "",
placeImgUrl = value?.photos?.let { photos ->
if (photos.isNotEmpty()) photos[0].getFullPhotoReference(BuildConfig.PLACE_API_KEY) else ""
} ?: "",
placeRating = value?.rating.toString(),
placeAddress = value?.formattedAddress.toString(),
placePhoneNumber = value?.formattedPhoneNumber.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable

@Serializable
data class AddressComponent(
@SerialName("long_name") val longName: String,
@SerialName("short_name") val shortName: String,
@SerialName("types") val types: List<String>
@SerialName("long_name") val longName: String? = "",
@SerialName("short_name") val shortName: String? = "",
@SerialName("types") val types: List<String>? = emptyList()
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable

@Serializable
data class CurrentOpeningHours(
@SerialName("open_now") val openNow: Boolean,
@SerialName("periods") val periods: List<Period>,
@SerialName("weekday_text") val weekdayText: List<String>
@SerialName("open_now") val openNow: Boolean? = null,
@SerialName("periods") val periods: List<Period>? = emptyList(),
@SerialName("weekday_text") val weekdayText: List<String>? = emptyList()
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import kotlinx.serialization.Serializable

@Serializable
data class Geometry(
@SerialName("location") val location: Location,
@SerialName("viewport") val viewport: Viewport
@SerialName("location") val location: Location? = null,
@SerialName("viewport") val viewport: Viewport? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import kotlinx.serialization.Serializable

@Serializable
data class Location(
@SerialName("lat") val lat: Double,
@SerialName("lng") val lng: Double
@SerialName("lat") val lat: Double? = 0.0,
@SerialName("lng") val lng: Double? = 0.0
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable

@Serializable
data class OpeningHours(
@SerialName("open_now") val openNow: Boolean,
@SerialName("open_now") val openNow: Boolean? = null,
@SerialName("periods") val periods: List<PeriodX> = emptyList(),
@SerialName("weekday_text") val weekdayText: List<String> = emptyList()
)
12 changes: 6 additions & 6 deletions core/model/src/main/java/com/example/model/network/Period.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ data class Period(

@Serializable
data class Open(
@SerialName("date") val date: String,
@SerialName("day") val day: Int,
@SerialName("time") val time: String
@SerialName("date") val date: String? = "",
@SerialName("day") val day: Int? = 0,
@SerialName("time") val time: String? = ""
)

@Serializable
data class Close(
@SerialName("date") val date: String,
@SerialName("day") val day: Int,
@SerialName("time") val time: String
@SerialName("date") val date: String? = "",
@SerialName("day") val day: Int? = 0,
@SerialName("time") val time: String? = ""
)
12 changes: 6 additions & 6 deletions core/model/src/main/java/com/example/model/network/PeriodX.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import kotlinx.serialization.Serializable

@Serializable
data class PeriodX(
@SerialName("open") val open: OpenX,
@SerialName("close") val close: CloseX
@SerialName("open") val open: OpenX? = null,
@SerialName("close") val close: CloseX? = null
)

@Serializable
data class OpenX(
@SerialName("day") val day: Int,
@SerialName("time") val time: String
@SerialName("day") val day: Int? = 0,
@SerialName("time") val time: String? = ""
)

@Serializable
data class CloseX(
@SerialName("day") val day: Int,
@SerialName("time") val time: String
@SerialName("day") val day: Int? = 0,
@SerialName("time") val time: String? = ""
)
8 changes: 4 additions & 4 deletions core/model/src/main/java/com/example/model/network/Photo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import kotlinx.serialization.Serializable

@Serializable
data class Photo(
@SerialName("height") val height: Int,
@SerialName("html_attributions") val htmlAttributions: List<String>,
@SerialName("photo_reference") val photoReference: String = "",
@SerialName("width") val width: Int
@SerialName("height") val height: Int? = 0,
@SerialName("width") val width: Int? = 0,
@SerialName("html_attributions") val htmlAttributions: List<String>? = emptyList(),
@SerialName("photo_reference") val photoReference: String = ""
) {
fun getFullPhotoReference(apiKey: String): String {
return StringBuilder("https://maps.googleapis.com/maps/api/place/photo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import kotlinx.serialization.Serializable

@Serializable
data class PlusCode(
@SerialName("compound_code") val compoundCode: String,
@SerialName("global_code") val globalCode: String
@SerialName("compound_code") val compoundCode: String? = "",
@SerialName("global_code") val globalCode: String? = ""
)
20 changes: 10 additions & 10 deletions core/model/src/main/java/com/example/model/network/Review.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import kotlinx.serialization.Serializable

@Serializable
data class Review(
@SerialName("author_name") val authorName: String,
@SerialName("author_url") val authorUrl: String,
@SerialName("language") val language: String,
@SerialName("original_language") val originalLanguage: String,
@SerialName("profile_photo_url") val profilePhotoUrl: String,
@SerialName("rating") val rating: Int,
@SerialName("relative_time_description") val relativeTimeDescription: String,
@SerialName("text") val text: String,
@SerialName("time") val time: Int,
@SerialName("translated") val translated: Boolean
@SerialName("author_name") val authorName: String ? = "",
@SerialName("author_url") val authorUrl: String? = "",
@SerialName("language") val language: String? = "",
@SerialName("original_language") val originalLanguage: String? = "",
@SerialName("profile_photo_url") val profilePhotoUrl: String? = "",
@SerialName("rating") val rating: Int? = 0,
@SerialName("relative_time_description") val relativeTimeDescription: String? = "",
@SerialName("text") val text: String? = "",
@SerialName("time") val time: Int? = 0,
@SerialName("translated") val translated: Boolean? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ data class Viewport(

@Serializable
data class Southwest(
@SerialName("lat") val lat: Double,
@SerialName("lng") val lng: Double
@SerialName("lat") val lat: Double? = 0.0,
@SerialName("lng") val lng: Double? = 0.0
)

@Serializable
data class Northeast(
@SerialName("lat") val lat: Double,
@SerialName("lng") val lng: Double
@SerialName("lat") val lat: Double? = 0.0,
@SerialName("lng") val lng: Double? = 0.0
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable
@Serializable
data class DetailedPlace(
@SerialName("status") val status : String,
@SerialName("result") val result : DetailedResult
@SerialName("result") val result : DetailedResult? = null
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ import kotlinx.serialization.Serializable
@Serializable
data class NearBySearch(
@SerialName("status") val status: String,
@SerialName("results") val results: List<NearBySearchResult> = listOf()
@SerialName("results") val results: List<NearBySearchResult> = emptyList()
)

@Serializable
data class NearBySearchResult(
@SerialName("business_status") val businessStatus: String,
@SerialName("geometry") val geometry: Geometry,
@SerialName("icon") val icon: String,
@SerialName("icon_background_color") val iconBackgroundColor: String,
@SerialName("icon_mask_base_uri") val iconMaskBaseUri: String,
@SerialName("name") val name: String,
@SerialName("business_status") val businessStatus: String? = "",
@SerialName("geometry") val geometry: Geometry? = null,
@SerialName("icon") val icon: String? = "",
@SerialName("icon_background_color") val iconBackgroundColor: String? = "",
@SerialName("icon_mask_base_uri") val iconMaskBaseUri: String? = "",
@SerialName("name") val name: String? = "",
@SerialName("opening_hours") val openingHours: OpeningHours? = null,
@SerialName("photos") val photos: List<Photo> = listOf(),
@SerialName("place_id") val placeId: String,
@SerialName("plus_code") val plusCode: PlusCode,
@SerialName("photos") val photos: List<Photo> = emptyList(),
@SerialName("place_id") val placeId: String? = "",
@SerialName("plus_code") val plusCode: PlusCode? = null,
@SerialName("price_level") val priceLevel: Int? = null,
@SerialName("rating") val rating: Double,
@SerialName("reference") val reference: String,
@SerialName("scope") val scope: String,
@SerialName("types") val types: List<String>,
@SerialName("user_ratings_total") val userRatingsTotal: Int,
@SerialName("vicinity") val vicinity: String
@SerialName("rating") val rating: Double? = 0.0,
@SerialName("reference") val reference: String? = "",
@SerialName("scope") val scope: String? = "",
@SerialName("types") val types: List<String>? = emptyList(),
@SerialName("user_ratings_total") val userRatingsTotal: Int? = 0,
@SerialName("vicinity") val vicinity: String? = ""
)

0 comments on commit 9a5ca64

Please sign in to comment.