-
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 #48 from stslex/dev
refactor modules
- Loading branch information
Showing
242 changed files
with
811 additions
and
744 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
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
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
5 changes: 5 additions & 0 deletions
5
...monMain/kotlin/com/stslex/wizard/core/network/api/api/kinopoisk/api/KinopoiskApiClient.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,5 @@ | ||
package com.stslex.wizard.core.network.api.api.kinopoisk.api | ||
|
||
import com.stslex.wizard.core.network.api.api.base.NetworkClient | ||
|
||
interface KinopoiskApiClient : NetworkClient |
35 changes: 35 additions & 0 deletions
35
...ain/kotlin/com/stslex/wizard/core/network/api/api/kinopoisk/api/KinopoiskApiClientImpl.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,35 @@ | ||
package com.stslex.wizard.core.network.api.api.kinopoisk.api | ||
|
||
import Wizard.core.network.api.BuildConfig | ||
import com.stslex.wizard.core.core.AppDispatcher | ||
import com.stslex.wizard.core.network.api.api.base.BaseNetworkClient | ||
import com.stslex.wizard.core.network.client.DefaultRequest | ||
import io.ktor.client.HttpClient | ||
|
||
class KinopoiskApiClientImpl( | ||
appDispatcher: AppDispatcher, | ||
client: HttpClient | ||
) : KinopoiskApiClient, BaseNetworkClient( | ||
appDispatcher = appDispatcher, | ||
client = client, | ||
defaultRequest = DEFAULT_REQUEST | ||
) { | ||
|
||
companion object { | ||
// TODO parse error | ||
private const val KINOPOISK_HOST_URL = "kinopoiskapiunofficial.tech/api/v2.2" | ||
private const val API_KEY = BuildConfig.KINOPOISK_API_KEY | ||
private const val API_HEADER = "X-API-KEY" | ||
private const val CONTENT_TYPE = "Content-Type" | ||
private const val CONTENT_TYPE_VALUE = "application/json" | ||
|
||
private val DEFAULT_REQUEST = | ||
DefaultRequest( | ||
hostUrl = KINOPOISK_HOST_URL, | ||
headers = mapOf( | ||
API_HEADER to API_KEY, | ||
CONTENT_TYPE to CONTENT_TYPE_VALUE | ||
) | ||
) | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
...otlin/com/stslex/wizard/core/network/api/api/kinopoisk/model/NetworkApiKinopoiskMapper.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,96 @@ | ||
package com.stslex.wizard.core.network.api.api.kinopoisk.model | ||
|
||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.FilmItemKinopoisk | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.FilmListKinopoisk | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.FilmProductionStatusNetwork | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.FilmTypeNetwork | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.MovieKinopoisk | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.TrailerItemKinopoisk | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.TrailerKinopoisk | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.response.FilmItemResponse | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.response.FilmListResponse | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.response.MovieResponse | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.response.TrailerItemResponse | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.response.TrailerResponse | ||
import com.stslex.wizard.core.network.api.clients.film.model.TrailerSiteType | ||
|
||
fun FilmListResponse.toNetwork(): FilmListKinopoisk = FilmListKinopoisk( | ||
total = total ?: 0, | ||
totalPages = totalPages ?: 0, | ||
items = items?.map { it.toNetwork() }.orEmpty() | ||
) | ||
|
||
fun FilmItemResponse.toNetwork(): FilmItemKinopoisk = FilmItemKinopoisk( | ||
kinopoiskId = kinopoiskId, | ||
imdbId = imdbId.orEmpty(), | ||
nameRu = nameRu.orEmpty(), | ||
nameEn = nameEn.orEmpty(), | ||
nameOriginal = nameOriginal.orEmpty(), | ||
countries = countries?.map { it.country }.orEmpty(), | ||
genres = genres?.map { it.genre }.orEmpty(), | ||
ratingKinopoisk = ratingKinopoisk, | ||
ratingImdb = ratingImdb, | ||
year = year, | ||
posterUrl = posterUrl.orEmpty(), | ||
posterUrlPreview = posterUrlPreview.orEmpty(), | ||
type = FilmTypeNetwork.getType(type.orEmpty()) | ||
) | ||
|
||
fun TrailerResponse.toNetwork(): TrailerKinopoisk = TrailerKinopoisk( | ||
total = total ?: 0, | ||
items = items?.map { it.toNetwork() }.orEmpty() | ||
) | ||
|
||
fun TrailerItemResponse.toNetwork(): TrailerItemKinopoisk = TrailerItemKinopoisk( | ||
url = url.orEmpty(), | ||
name = name.orEmpty(), | ||
site = TrailerSiteType.getByValue(site.orEmpty()), | ||
) | ||
|
||
fun MovieResponse.toNetwork(): MovieKinopoisk = MovieKinopoisk( | ||
kinopoiskId = kinopoiskId, | ||
kinopoiskHDId = kinopoiskHDId.orEmpty(), | ||
imdbId = imdbId.orEmpty(), | ||
nameRu = nameRu.orEmpty(), | ||
nameEn = nameEn.orEmpty(), | ||
nameOriginal = nameOriginal.orEmpty(), | ||
posterUrl = posterUrl.orEmpty(), | ||
posterUrlPreview = posterUrlPreview.orEmpty(), | ||
coverUrl = coverUrl.orEmpty(), | ||
logoUrl = logoUrl.orEmpty(), | ||
reviewsCount = reviewsCount, | ||
ratingGoodReview = ratingGoodReview, | ||
ratingGoodReviewVoteCount = ratingGoodReviewVoteCount, | ||
ratingKinopoisk = ratingKinopoisk, | ||
ratingKinopoiskVoteCount = ratingKinopoiskVoteCount, | ||
ratingImdb = ratingImdb, | ||
ratingImdbVoteCount = ratingImdbVoteCount, | ||
ratingFilmCritics = ratingFilmCritics, | ||
ratingFilmCriticsVoteCount = ratingFilmCriticsVoteCount, | ||
ratingAwait = ratingAwait, | ||
ratingAwaitCount = ratingAwaitCount, | ||
ratingRfCritics = ratingRfCritics, | ||
ratingRfCriticsVoteCount = ratingRfCriticsVoteCount, | ||
webUrl = webUrl.orEmpty(), | ||
year = year, | ||
filmLength = filmLength, | ||
slogan = slogan.orEmpty(), | ||
description = description, | ||
shortDescription = shortDescription.orEmpty(), | ||
editorAnnotation = editorAnnotation.orEmpty(), | ||
isTicketsAvailable = isTicketsAvailable ?: false, | ||
productionStatus = FilmProductionStatusNetwork.getType(productionStatus.orEmpty()), | ||
type = type, | ||
ratingMpaa = ratingMpaa, | ||
ratingAgeLimits = ratingAgeLimits, | ||
hasImax = hasImax ?: false, | ||
has3D = has3D ?: false, | ||
lastSync = lastSync, | ||
countries = countries?.map { it.country }.orEmpty(), | ||
genres = genres?.map { it.genre }.orEmpty(), | ||
startYear = startYear, | ||
endYear = endYear, | ||
isSerial = serial ?: false, | ||
isShortFilm = shortFilm ?: false, | ||
isCompleted = completed ?: false | ||
) |
2 changes: 1 addition & 1 deletion
2
...opoisk/model/network/FilmItemKinopoisk.kt → ...opoisk/model/network/FilmItemKinopoisk.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
2 changes: 1 addition & 1 deletion
2
...opoisk/model/network/FilmListKinopoisk.kt → ...opoisk/model/network/FilmListKinopoisk.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
2 changes: 1 addition & 1 deletion
2
...el/network/FilmProductionStatusNetwork.kt → ...el/network/FilmProductionStatusNetwork.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
2 changes: 1 addition & 1 deletion
2
...inopoisk/model/network/FilmTypeNetwork.kt → ...inopoisk/model/network/FilmTypeNetwork.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
2 changes: 1 addition & 1 deletion
2
...kinopoisk/model/network/MovieKinopoisk.kt → ...kinopoisk/model/network/MovieKinopoisk.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
9 changes: 9 additions & 0 deletions
9
...in/com/stslex/wizard/core/network/api/api/kinopoisk/model/network/TrailerItemKinopoisk.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.stslex.wizard.core.network.api.api.kinopoisk.model.network | ||
|
||
import com.stslex.wizard.core.network.api.clients.film.model.TrailerSiteType | ||
|
||
data class TrailerItemKinopoisk( | ||
val url: String, | ||
val name: String, | ||
val site: TrailerSiteType | ||
) |
2 changes: 1 addition & 1 deletion
2
...nopoisk/model/network/TrailerKinopoisk.kt → ...nopoisk/model/network/TrailerKinopoisk.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
2 changes: 1 addition & 1 deletion
2
...i/kinopoisk/model/request/FilmsRequest.kt → ...i/kinopoisk/model/request/FilmsRequest.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
2 changes: 1 addition & 1 deletion
2
...nopoisk/model/response/CountryResponse.kt → ...nopoisk/model/response/CountryResponse.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
2 changes: 1 addition & 1 deletion
2
...opoisk/model/response/FilmItemResponse.kt → ...opoisk/model/response/FilmItemResponse.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
2 changes: 1 addition & 1 deletion
2
...opoisk/model/response/FilmListResponse.kt → ...opoisk/model/response/FilmListResponse.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
2 changes: 1 addition & 1 deletion
2
...kinopoisk/model/response/GenreResponse.kt → ...kinopoisk/model/response/GenreResponse.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
2 changes: 1 addition & 1 deletion
2
...kinopoisk/model/response/MovieResponse.kt → ...kinopoisk/model/response/MovieResponse.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
2 changes: 1 addition & 1 deletion
2
...isk/model/response/TrailerItemResponse.kt → ...isk/model/response/TrailerItemResponse.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
2 changes: 1 addition & 1 deletion
2
...nopoisk/model/response/TrailerResponse.kt → ...nopoisk/model/response/TrailerResponse.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
14 changes: 14 additions & 0 deletions
14
.../kotlin/com/stslex/wizard/core/network/api/api/kinopoisk/source/KinopoiskNetworkClient.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,14 @@ | ||
package com.stslex.wizard.core.network.api.api.kinopoisk.source | ||
|
||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.FilmListKinopoisk | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.MovieKinopoisk | ||
import com.stslex.wizard.core.network.api.api.kinopoisk.model.network.TrailerKinopoisk | ||
|
||
interface KinopoiskNetworkClient { | ||
|
||
suspend fun getFilms(page: Int): FilmListKinopoisk | ||
|
||
suspend fun getFilm(id: String): MovieKinopoisk | ||
|
||
suspend fun getFilmTrailers(id: String): TrailerKinopoisk | ||
} |
Oops, something went wrong.