Skip to content
This repository has been archived by the owner on Nov 22, 2020. It is now read-only.

Add manga endpoints #16

Merged
merged 5 commits into from
May 12, 2020
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repositories {
}

dependencies {
implementation 'com.github.GSculerlor:JikanKt:1.1.3'
implementation 'com.github.GSculerlor:JikanKt:1.2.0'
}
```
with Maven
Expand All @@ -27,7 +27,7 @@ with Maven
<dependency>
<groupId>com.github.GSculerlor</groupId>
<artifactId>JikanKt</artifactId>
<version>1.1.3</version>
<version>1.2.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}

group = "com.github.GSculerlor"
version = "1.1.3"
version = "1.2.0"

dependencies {
implementation(kotlin("stdlib-jdk8"))
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/moe/ganen/jikankt/JikanClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ open class JikanClient {

companion object {
private const val JIKANKT_NAME = "JikanKt"
private const val JIKANKT_VERSION = "1.1.3"
private const val JIKANKT_VERSION = "1.2.0"
}
}
86 changes: 86 additions & 0 deletions src/main/kotlin/moe/ganen/jikankt/JikanKt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import moe.ganen.jikankt.models.club.Club
import moe.ganen.jikankt.models.club.ClubMembers
import moe.ganen.jikankt.models.genre.Genre
import moe.ganen.jikankt.models.genre.RequestType
import moe.ganen.jikankt.models.manga.*
import moe.ganen.jikankt.models.person.Person
import moe.ganen.jikankt.models.person.PersonPictures
import moe.ganen.jikankt.models.prod.Magazine
Expand Down Expand Up @@ -133,6 +134,91 @@ object JikanKt {

//endregion

//region Manga

/**
* Function to get manga by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @return Manga with given MyAnimeList id.
*/
suspend fun getManga(id: Int): Manga = gson.deserialize(restClient.request("manga/$id"), Manga::class.java)

/**
* Function to get manga's characters by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @return List of characters and staff of the manga with given MyAnimeList id.
*/
suspend fun getMangaCharacters(id: Int): MangaCharacters =
gson.deserialize(restClient.request("manga/$id/characters"), MangaCharacters::class.java)

/**
* Function to get manga's news by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @return List of articles related to the manga with given MyAnimeList id.
*/
suspend fun getMangaNews(id: Int): MangaNews =
gson.deserialize(restClient.request("manga/$id/news"), MangaNews::class.java)

/**
* Function to get manga's pictures by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @return List of pictures to the manga with given MyAnimeList id.
*/
suspend fun getMangaPictures(id: Int): MangaPictures =
gson.deserialize(restClient.request("manga/$id/pictures"), MangaPictures::class.java)

/**
* Function to get manga's stats by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @return Statistics to the manga with given MyAnimeList id.
*/
suspend fun getMangaStats(id: Int): MangaStats =
gson.deserialize(restClient.request("manga/$id/stats"), MangaStats::class.java)

/**
* Function to get manga's forum by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @return List of topics to the manga with given MyAnimeList id.
*/
suspend fun getMangaForum(id: Int): MangaForum =
gson.deserialize(restClient.request("manga/$id/forum"), MangaForum::class.java)

/**
* Function to get manga's more info by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @return Manga's more info in string, if any.
*/
suspend fun getMangaMoreInfo(id: Int): MangaMoreInfo =
gson.deserialize(restClient.request("manga/$id/moreinfo"), MangaMoreInfo::class.java)

/**
* Function to get manga's reviews by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @param page: Optional, default is 1. Index of page, each page contain 20 items.
* @return List of reviews of the manga with given MyAnimeList id.
*/
suspend fun getMangaReviews(id: Int, page: Int? = 1): MangaReviews =
gson.deserialize(restClient.request("manga/$id/reviews/$page"), MangaReviews::class.java)

/**
* Function to get manga's recommendations by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @return List of recommendations to the manga with given MyAnimeList id.
*/
suspend fun getMangaRecommendations(id: Int): MangaRecommendations =
gson.deserialize(restClient.request("manga/$id/recommendations"), MangaRecommendations::class.java)

/**
* Function to get manga's user updates by it's MyAnimeList id
* @param id: MyAnimeList id of the manga.
* @param page: Optional, default is 1. Index of page, each page contain 75 items.
* @return List of user updates of the manga with given MyAnimeList id.
*/
suspend fun getMangaUserUpdates(id: Int, page: Int? = 1): MangaUserUpdates =
gson.deserialize(restClient.request("manga/$id/userupdates/$page"), MangaUserUpdates::class.java)

//endregion

//region People

/**
Expand Down
18 changes: 18 additions & 0 deletions src/main/kotlin/moe/ganen/jikankt/models/anime/Anime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,39 @@ data class Anime(
@SerializedName("related")
val related: RelatedAnime? = null,

/**
* List of producers of this anime.
*/
@SerializedName("producers")
val producers: List<MalSubEntity?>? = null,

/**
* List of licensors of this anime.
*/
@SerializedName("licensors")
val licensors: List<MalSubEntity?>? = null,

/**
* List of studios of this anime.
*/
@SerializedName("studios")
val studios: List<MalSubEntity?>? = null,

/**
* List of genre of this anime.
*/
@SerializedName("genres")
val genres: List<MalSubEntity?>? = null,

/**
* List of opening theme (OP) of this anime.
*/
@SerializedName("opening_themes")
val openingThemes: List<String?>? = null,

/**
* List of ending theme (ED) of this anime.
*/
@SerializedName("ending_themes")
val endingThemes: List<String?>? = null

Expand Down
17 changes: 17 additions & 0 deletions src/main/kotlin/moe/ganen/jikankt/models/anime/MangaCharacters.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package moe.ganen.jikankt.models.anime

import com.google.gson.annotations.SerializedName
import moe.ganen.jikankt.models.base.Entity
import moe.ganen.jikankt.models.base.types.Character

/**
* Manga's characters data class
*/
data class MangaCharacters(
/**
* List of manga character.
* @see Character for the detail.
*/
@SerializedName("characters")
val characters: List<Character?>? = null
) : Entity()
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package moe.ganen.jikankt.models.base.types

import com.google.gson.annotations.SerializedName

/**
* Lists of related items of the manga.
* @see MalSubEntity for the detail.
*/
data class RelatedManga(
/**
* List of prequels of the manga.
*/
@SerializedName("Prequel")
val prequel: List<MalSubEntity?>? = null,

/**
* List of alternative versions of the manga.
*/
@SerializedName("Alternative version")
val alternativeVersion: List<MalSubEntity?>? = null,

/**
* List of spin-off of the manga.
*/
@SerializedName("Spin-off")
val spinOff: List<MalSubEntity?>? = null,

/**
* List of adaptations of the manga.
*/
@SerializedName("Adaptation")
val adaptation: List<MalSubEntity?>? = null,

/**
* List of summaries of the manga.
*/
@SerializedName("Summary")
val summary: List<MalSubEntity?>? = null,

/**
* List of sequels of the manga.
*/
@SerializedName("Sequel")
val sequel: List<MalSubEntity?>? = null,

/**
* List of side-stories of the manga.
*/
@SerializedName("Side story")
val sideStory: List<MalSubEntity?>? = null,

/**
* List of other entries of the manga.
*/
@SerializedName("Other")
val other: List<MalSubEntity?>? = null,

/**
* List of parent story of the manga.
*/
@SerializedName("Parent story")
val parentStory: List<MalSubEntity?>? = null,

/**
* List of alternative settings of the manga.
*/
@SerializedName("Alternative setting")
val alternativeSetting: List<MalSubEntity?>? = null,

/**
* List of related characters of the manga.
*/
@SerializedName("Character")
val character: List<MalSubEntity?>? = null,

/**
* List of full stories of the manga.
*/
@SerializedName("Full story")
val fullStory: List<MalSubEntity?>? = null
)
Loading