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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.divinelink.core.network.media.model.details.DetailsResponseApi
import com.divinelink.core.network.media.model.details.ProductionCompany
import com.divinelink.core.network.media.model.details.ProductionCountryResponse
import com.divinelink.core.testing.factories.api.media.GenreResponseFactory
import com.divinelink.core.testing.factories.api.media.KeywordsResponseFactory
import com.divinelink.factories.CreditsFactory

object DetailsResponseApiFactory {
Expand Down Expand Up @@ -84,5 +85,6 @@ object DetailsResponseApiFactory {
voteAverage = 8.438,
voteCount = 30_452,
credits = CreditsFactory.all(),
keywords = KeywordsResponseFactory.fightClub,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class ProdDetailsRepositoryTest {
request = MediaRequestApiFactory.tv(),
).test {
assertThat(awaitItem()).isEqualTo(
Result.success(MediaDetailsFactory.TheOffice()),
Result.success(MediaDetailsFactory.TheOffice().copy(keywords = null)),
)
awaitComplete()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.divinelink.core.fixtures.details.media
import com.divinelink.core.fixtures.details.credits.SeriesCastFactory
import com.divinelink.core.fixtures.details.review.ReviewFactory
import com.divinelink.core.fixtures.details.season.SeasonFactory
import com.divinelink.core.fixtures.model.details.KeywordFactory
import com.divinelink.core.fixtures.model.details.MediaDetailsFactory
import com.divinelink.core.fixtures.model.media.MediaItemFactory
import com.divinelink.core.model.details.media.DetailsData
Expand All @@ -17,6 +18,7 @@ object DetailsDataFactory {
creators = null,
information = null,
collection = null,
keywords = null,
)

fun cast(isTv: Boolean) = DetailsData.Cast(
Expand Down Expand Up @@ -44,7 +46,8 @@ object DetailsDataFactory {
genres = MediaDetailsFactory.FightClub().genres,
creators = MediaDetailsFactory.FightClub().creators,
information = MediaDetailsFactory.FightClub().information,
collection = null, // MediaDetailsFactory.FightClub().information
collection = null,
keywords = KeywordFactory.fightClub,
)

fun cast() = DetailsData.Cast(
Expand All @@ -69,6 +72,7 @@ object DetailsDataFactory {
creators = MediaDetailsFactory.TheOffice().creators,
information = MediaDetailsFactory.TheOffice().information,
collection = null,
keywords = KeywordFactory.theOffice,
)

fun cast() = DetailsData.Cast(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.divinelink.core.fixtures.model.details

import com.divinelink.core.model.details.Keyword

object KeywordFactory {

val basedOnNovelOrBook = Keyword(
id = 818,
name = "based on novel or book",
)

val fight = Keyword(
id = 1721,
name = "fight",
)

val mockumentary = Keyword(
id = 11800,
name = "Mockumentary",
)

val amused = Keyword(
id = 325765,
name = "Amused",
)

val sitcom = Keyword(
id = 193171,
name = "sitcom",
)

val theOffice = listOf(
mockumentary,
amused,
sitcom,
)

val fightClub = listOf(
basedOnNovelOrBook,
fight,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ object MediaDetailsFactory {
Country.UNITED_STATES,
),
),
keywords = KeywordFactory.fightClub,
)

fun TheOffice() = TV(
Expand Down Expand Up @@ -130,5 +131,6 @@ object MediaDetailsFactory {
),
nextEpisodeAirDate = null,
),
keywords = KeywordFactory.theOffice,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.divinelink.core.model.details

data class Keyword(
val id: Long,
val name: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ sealed class MediaDetails {
abstract val imdbId: String?
abstract val popularity: Double
abstract val information: MediaDetailsInformation
abstract val keywords: List<Keyword>?

fun copy(
id: Int = this.id,
Expand Down Expand Up @@ -56,6 +57,7 @@ sealed class MediaDetails {
popularity = popularity,
collection = collection,
information = information,
keywords = keywords,
)
is TV -> TV(
id = id,
Expand All @@ -74,6 +76,7 @@ sealed class MediaDetails {
imdbId = imdbId,
popularity = popularity,
information = information,
keywords = keywords,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ data class Movie(
override val information: MediaDetailsInformation.Movie,
override val popularity: Double,
override val isFavorite: Boolean,
override val keywords: List<Keyword>?,
) : MediaDetails()
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ data class TV(
override val tagline: String?,
override val popularity: Double,
override val information: MediaDetailsInformation.TV,
override val keywords: List<Keyword>?,
val creators: List<Person>?,
val seasons: List<Season>,
val numberOfSeasons: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.divinelink.core.model.details.media

import com.divinelink.core.model.Genre
import com.divinelink.core.model.details.Collection
import com.divinelink.core.model.details.Keyword
import com.divinelink.core.model.details.Person
import com.divinelink.core.model.details.Season
import com.divinelink.core.model.details.review.Review
Expand All @@ -15,6 +16,7 @@ sealed interface DetailsData {
val creators: List<Person>?,
val information: MediaDetailsInformation?,
val collection: Collection?,
val keywords: List<Keyword>?,
) : DetailsData

data class Cast(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ class BuildUrlTest {
appendToResponse = true,
)

url shouldBe
"https://api.themoviedb.org/3/tv/1234?language=en-US&append_to_response=external_ids"
url shouldBe "https://api.themoviedb.org/3/tv/1234" +
"?language=en-US" +
"&append_to_response=external_ids%2Ckeywords"
}

@Test
Expand All @@ -38,7 +39,9 @@ class BuildUrlTest {
appendToResponse = true,
)

url shouldBe "https://api.themoviedb.org/3/movie/1234?language=en-US&append_to_response=credits"
url shouldBe "https://api.themoviedb.org/3/movie/1234" +
"?language=en-US" +
"&append_to_response=credits%2Ckeywords"
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.divinelink.core.network.media.mapper.details

import com.divinelink.core.model.details.Keyword
import com.divinelink.core.network.media.model.details.KeywordResponse
import com.divinelink.core.network.media.model.details.KeywordsResponse

fun KeywordsResponse?.map() = this
?.keywords
?.map { it.map() }

private fun KeywordResponse.map() = Keyword(
id = id,
name = name,
)
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ sealed class DetailsResponseApi {
@SerialName("production_countries")
abstract val countries: List<ProductionCountryResponse>

abstract val keywords: KeywordsResponse?

@Serializable
data class Movie(
override val id: Int,
Expand Down Expand Up @@ -82,6 +84,7 @@ sealed class DetailsResponseApi {
val credits: CreditsApi? = null, // TODO credits call should be made separately
val status: String? = null,
@SerialName("belongs_to_collection") val collection: BelongsToCollectionResponse?,
override val keywords: KeywordsResponse?,
) : DetailsResponseApi()

@Serializable
Expand Down Expand Up @@ -111,6 +114,7 @@ sealed class DetailsResponseApi {
@SerialName("next_episode_to_air") val nextEpisodeToAir: NextEpisodeToAirResponse? = null,
@SerialName("production_companies") override val companies: List<ProductionCompany>,
@SerialName("production_countries") override val countries: List<ProductionCountryResponse>,
override val keywords: KeywordsResponse?,
) : DetailsResponseApi()
}

Expand Down Expand Up @@ -159,6 +163,7 @@ private fun DetailsResponseApi.Movie.toDomainMovie(): MediaDetails = Movie(
"$${revenue.formatWithCommas()}"
},
),
keywords = keywords.map(),
)

private fun DetailsResponseApi.TV.toDomainTVShow(): MediaDetails = TV(
Expand Down Expand Up @@ -194,6 +199,7 @@ private fun DetailsResponseApi.TV.toDomainTVShow(): MediaDetails = TV(
Country.fromCode(it.iso31611)
},
),
keywords = keywords.map(),
)

private fun List<CastApi>.toActors(): List<Person> = this.map(CastApi::toPerson)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.divinelink.core.network.media.model.details

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonNames

@Serializable
data class KeywordResponse(
val id: Long,
val name: String,
)

@OptIn(ExperimentalSerializationApi::class)
@Serializable
data class KeywordsResponse(
@JsonNames("results", "keywords") val keywords: List<KeywordResponse>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ fun buildFetchDetailsUrl(
append("language", "en-US")
if (appendToResponse) {
when (media) {
MediaType.MOVIE -> append("append_to_response", "credits")
MediaType.TV -> append("append_to_response", "external_ids")
else -> {
// Do nothing
}
MediaType.MOVIE -> append("append_to_response", "credits,keywords")
MediaType.TV -> append("append_to_response", "external_ids,keywords")
else -> Unit
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.divinelink.core.testing.factories.api.media

import com.divinelink.core.network.media.model.details.KeywordResponse

object KeywordResponseFactory {

val basedOnNovelOrBook = KeywordResponse(
id = 818,
name = "based on novel or book",
)

val fight = KeywordResponse(
id = 1721,
name = "fight",
)

val mockumentary = KeywordResponse(
id = 11800,
name = "Mockumentary",
)

val amused = KeywordResponse(
id = 325765,
name = "Amused",
)

val sitcom = KeywordResponse(
id = 193171,
name = "sitcom",
)

val theOffice = listOf(
mockumentary,
amused,
sitcom,
)

val fightClub = listOf(
basedOnNovelOrBook,
fight,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.divinelink.core.testing.factories.api.media

import com.divinelink.core.network.media.model.details.KeywordsResponse

object KeywordsResponseFactory {

val theOffice = KeywordsResponse(keywords = KeywordResponseFactory.theOffice)
val fightClub = KeywordsResponse(keywords = KeywordResponseFactory.fightClub)
}
1 change: 1 addition & 0 deletions core/ui/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string name="core_ui_share_error_details">Share error details</string>

<string name="core_ui_information">Information</string>
<string name="core_ui_keywords">Keywords</string>

<string name="core_ui_approve">Approve</string>
<string name="core_ui_decline">Decline</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import org.jetbrains.compose.resources.stringResource

@Composable
fun CreatorsItem(
modifier: Modifier = Modifier,
creators: List<Person>,
onClick: (Person) -> Unit,
) {
FlowRow(
modifier = Modifier.offset(x = -MaterialTheme.dimensions.keyline_12),
modifier = modifier.offset(x = -MaterialTheme.dimensions.keyline_12),
) {
creators.forEach { person ->
CreatorItem(
Expand Down
Loading