This repository has been archived by the owner on Nov 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add anime search endpoints * Add manga endpoints * Fix docs
- Loading branch information
1 parent
d2a012e
commit 6e30c55
Showing
16 changed files
with
616 additions
and
5 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
87 changes: 87 additions & 0 deletions
87
src/main/kotlin/moe/ganen/jikankt/models/base/types/AnimeSearchSubEntity.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,87 @@ | ||
package moe.ganen.jikankt.models.base.types | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import moe.ganen.jikankt.models.base.MalEntity | ||
import moe.ganen.jikankt.models.base.enum.AnimeType | ||
import java.util.* | ||
|
||
data class AnimeSearchSubEntity( | ||
/** | ||
* ID associated with MyAnimeList. | ||
*/ | ||
@SerializedName("mal_id") | ||
override val malId: Int, | ||
|
||
/** | ||
* Anime's MyAnimeList link. | ||
*/ | ||
@SerializedName("url") | ||
val url: String? = null, | ||
|
||
/** | ||
* Anime's MyAnimeList cover/image link. | ||
*/ | ||
@SerializedName("image_url") | ||
val imageUrl: String? = null, | ||
|
||
/** | ||
* Title of the anime. | ||
*/ | ||
@SerializedName("title") | ||
val title: String? = null, | ||
|
||
/** | ||
* Synopsis of the anime. | ||
*/ | ||
@SerializedName("synopsis") | ||
val synopsis: String? = null, | ||
|
||
/** | ||
* Type of the anime. | ||
* @see AnimeType for the detail. | ||
*/ | ||
@SerializedName("type") | ||
val type: AnimeType? = null, | ||
|
||
/** | ||
* Score at MyAnimeList. Formatted up to 2 decimal places. | ||
*/ | ||
@SerializedName("score") | ||
val score: Double? = null, | ||
|
||
/** | ||
* Total episode(s) of the anime. | ||
*/ | ||
@SerializedName("episodes") | ||
val episodes: Int? = null, | ||
|
||
/** | ||
* Anime's members count on MyAnimeList. | ||
*/ | ||
@SerializedName("members") | ||
val members: Int? = null, | ||
|
||
/** | ||
* Whether the anime is currently airing or not. | ||
*/ | ||
@SerializedName("airing") | ||
val airing: Boolean? = null, | ||
|
||
/** | ||
* Anime airing date. | ||
*/ | ||
@SerializedName("start_date") | ||
val startDate: Date? = null, | ||
|
||
/** | ||
* Anime finished airing date. | ||
*/ | ||
@SerializedName("end_date") | ||
val endDate: Date? = null, | ||
|
||
/** | ||
* Rating of the anime (PG, G, Rx, etc.). | ||
*/ | ||
@SerializedName("rated") | ||
val rated: String? = null | ||
) : MalEntity |
87 changes: 87 additions & 0 deletions
87
src/main/kotlin/moe/ganen/jikankt/models/base/types/MangaSearchSubEntity.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,87 @@ | ||
package moe.ganen.jikankt.models.base.types | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import moe.ganen.jikankt.models.base.MalEntity | ||
import moe.ganen.jikankt.models.search.enums.MangaType | ||
import java.util.* | ||
|
||
data class MangaSearchSubEntity( | ||
/** | ||
* ID associated with MyAnimeList. | ||
*/ | ||
@SerializedName("mal_id") | ||
override val malId: Int, | ||
|
||
/** | ||
* Manga's MyAnimeList link. | ||
*/ | ||
@SerializedName("url") | ||
val url: String? = null, | ||
|
||
/** | ||
* Manga's MyAnimeList cover/image link. | ||
*/ | ||
@SerializedName("image_url") | ||
val imageUrl: String? = null, | ||
|
||
/** | ||
* Title of the manga. | ||
*/ | ||
@SerializedName("title") | ||
val title: String? = null, | ||
|
||
/** | ||
* Synopsis of the manga. | ||
*/ | ||
@SerializedName("synopsis") | ||
val synopsis: String? = null, | ||
|
||
/** | ||
* Type of the manga. | ||
* @see MangaType for the detail. | ||
*/ | ||
@SerializedName("type") | ||
val type: MangaType? = null, | ||
|
||
/** | ||
* Score at MyAnimeList. Formatted up to 2 decimal places. | ||
*/ | ||
@SerializedName("score") | ||
val score: Double? = null, | ||
|
||
/** | ||
* Total chapter(s) of the manga. | ||
*/ | ||
@SerializedName("chapters") | ||
val chapters: Int? = null, | ||
|
||
/** | ||
* Total volume(s) of the manga. | ||
*/ | ||
@SerializedName("volumes") | ||
val volumes: Int? = null, | ||
|
||
/** | ||
* Manga's members count on MyAnimeList. | ||
*/ | ||
@SerializedName("members") | ||
val members: Int? = null, | ||
|
||
/** | ||
* Whether the manga is currently publishing or not. | ||
*/ | ||
@SerializedName("publishing") | ||
val publishing: Boolean? = null, | ||
|
||
/** | ||
* Manga publishing date. | ||
*/ | ||
@SerializedName("start_date") | ||
val startDate: Date? = null, | ||
|
||
/** | ||
* Manga finished publishing date. | ||
*/ | ||
@SerializedName("end_date") | ||
val endDate: Date? = null | ||
) : MalEntity |
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/moe/ganen/jikankt/models/search/AnimeSearchQuery.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,63 @@ | ||
package moe.ganen.jikankt.models.search | ||
|
||
import moe.ganen.jikankt.models.search.enums.* | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
data class AnimeSearchQuery( | ||
val type: AnimeType = AnimeType.All, | ||
val status: AnimeStatus = AnimeStatus.All, | ||
val rated: AgeRating = AgeRating.All, | ||
val genre: List<AnimeGenre>? = null, | ||
val score: Int? = null, | ||
val startDate: Date? = null, | ||
val endDate: Date? = null, | ||
val excludedGenre: Boolean = false, | ||
val limit: Int? = null, | ||
val orderBy: AnimeOrderBy = AnimeOrderBy.None, | ||
val sort: Sort = Sort.Descending, | ||
val producerId: Int? = null | ||
) { | ||
override fun toString(): String { | ||
val stringBuilder = StringBuilder() | ||
val queryDateFormat = SimpleDateFormat("yyyy-MM-dd") | ||
|
||
if (type != AnimeType.All) | ||
stringBuilder.append("&type=${type.name}") | ||
|
||
if (status != AnimeStatus.All) | ||
stringBuilder.append("&status=${status.name}") | ||
|
||
if (rated != AgeRating.All) | ||
stringBuilder.append("&rated=${rated.name}") | ||
|
||
if (!genre.isNullOrEmpty()) | ||
stringBuilder.append("&genre=${genre.joinToString(separator = ",") { "${it.ordinal}" }}") | ||
|
||
if (score != null && score in 1..10) | ||
stringBuilder.append("&score=$score") | ||
|
||
if (startDate != null) | ||
stringBuilder.append("&start_date=${queryDateFormat.format(startDate)}") | ||
|
||
if (endDate != null) | ||
stringBuilder.append("&end_date=${queryDateFormat.format(endDate)}") | ||
|
||
if (excludedGenre) | ||
stringBuilder.append("&genre_exclude=1") | ||
|
||
if (limit != null) | ||
stringBuilder.append("&limit=${limit}") | ||
|
||
if (orderBy != AnimeOrderBy.None) | ||
stringBuilder.append("&order_by=${if (orderBy.queryString.isNullOrEmpty()) orderBy.name else orderBy.queryString}") | ||
|
||
if (sort == Sort.Ascending) | ||
stringBuilder.append("&sort=asc") | ||
|
||
if (producerId != null) | ||
stringBuilder.append("&producer=${producerId}") | ||
|
||
return stringBuilder.toString() | ||
} | ||
} |
Oops, something went wrong.