mirror of
https://github.com/jie65535/mirai-console-jcf-plugin.git
synced 2025-06-02 17:39:15 +08:00
fix apis
This commit is contained in:
parent
917d5f2a68
commit
be20a22fe9
@ -16,6 +16,7 @@ import top.jie65535.jcf.model.response.*
|
||||
|
||||
/**
|
||||
* [Api docs](https://docs.curseforge.com/)
|
||||
* @author jie65535
|
||||
*/
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
class CurseforgeApi(apiKey: String) {
|
||||
@ -57,7 +58,7 @@ class CurseforgeApi(apiKey: String) {
|
||||
* Specify a game id for a list of all game categories,
|
||||
* or a class id for a list of categories under that class.
|
||||
*/
|
||||
suspend fun getCategories(gameId: Int, classId: Int?): Array<Category> {
|
||||
suspend fun getCategories(gameId: Int, classId: Int? = null): Array<Category> {
|
||||
return json.decodeFromString<GetCategoriesResponse>(
|
||||
http.get("/v1/categories") {
|
||||
parameter("gameId", gameId)
|
||||
@ -87,17 +88,17 @@ class CurseforgeApi(apiKey: String) {
|
||||
*/
|
||||
suspend fun searchMods(
|
||||
gameId: Int,
|
||||
classId: Int?,
|
||||
categoryId: Int?,
|
||||
gameVersion: String?,
|
||||
searchFilter: String?,
|
||||
sortField: ModsSearchSortField?,
|
||||
sortOrder: SortOrder?,
|
||||
modLoaderType: ModLoaderType?,
|
||||
gameVersionTypeId: Int?,
|
||||
slug: String?,
|
||||
index: Int?,
|
||||
pageSize: Int?
|
||||
classId: Int? = null,
|
||||
categoryId: Int? = null,
|
||||
gameVersion: String? = null,
|
||||
searchFilter: String? = null,
|
||||
sortField: ModsSearchSortField? = null,
|
||||
sortOrder: SortOrder? = null,
|
||||
modLoaderType: ModLoaderType? = null,
|
||||
gameVersionTypeId: Int? = null,
|
||||
slug: String? = null,
|
||||
index: Int? = null,
|
||||
pageSize: Int? = null
|
||||
): SearchModsResponse {
|
||||
return json.decodeFromString(
|
||||
http.get("/v1/mods/search") {
|
||||
@ -147,7 +148,7 @@ class CurseforgeApi(apiKey: String) {
|
||||
suspend fun getFeaturedMods(
|
||||
gameId: Int,
|
||||
excludedModIds: IntArray,
|
||||
gameVersionTypeId: Int?
|
||||
gameVersionTypeId: Int? = null
|
||||
): FeaturedModsResponse {
|
||||
return json.decodeFromString<GetFeaturedModsResponse>(
|
||||
http.get("/v1/mods/featured") {
|
||||
@ -183,11 +184,11 @@ class CurseforgeApi(apiKey: String) {
|
||||
*/
|
||||
suspend fun getModFiles(
|
||||
modId: Int,
|
||||
gameVersion: String?,
|
||||
modLoaderType: ModLoaderType?,
|
||||
gameVersionTypeId: Int?,
|
||||
index: Int?,
|
||||
pageSize: Int?
|
||||
gameVersion: String? = null,
|
||||
modLoaderType: ModLoaderType? = null,
|
||||
gameVersionTypeId: Int? = null,
|
||||
index: Int? = null,
|
||||
pageSize: Int? = null
|
||||
): GetModFilesResponse {
|
||||
return json.decodeFromString(
|
||||
http.get("/v1/mods/$modId/files") {
|
||||
|
@ -6,16 +6,59 @@ import java.time.OffsetDateTime
|
||||
|
||||
@Serializable
|
||||
class Category(
|
||||
/**
|
||||
* The category id
|
||||
*/
|
||||
val id: Int,
|
||||
|
||||
/**
|
||||
* The game id related to the category
|
||||
*/
|
||||
val gameId: Int,
|
||||
|
||||
/**
|
||||
* Category name
|
||||
*/
|
||||
val name: String,
|
||||
|
||||
/**
|
||||
* The category slug as it appear in the URL
|
||||
*/
|
||||
val slug: String,
|
||||
|
||||
/**
|
||||
* The category URL
|
||||
*/
|
||||
val url: String,
|
||||
|
||||
/**
|
||||
* URL for the category icon
|
||||
*/
|
||||
val iconUrl: String,
|
||||
|
||||
/**
|
||||
* Last modified date of the category
|
||||
*/
|
||||
@Serializable(OffsetDateTimeSerializer::class)
|
||||
val dateModified: OffsetDateTime,
|
||||
|
||||
/**
|
||||
* A top level category for other categories
|
||||
*/
|
||||
val isClass: Boolean?,
|
||||
|
||||
/**
|
||||
* The class id of the category, meaning - the class of which this category is under
|
||||
*/
|
||||
val classId: Int?,
|
||||
|
||||
/**
|
||||
* The parent category for this category
|
||||
*/
|
||||
val parentCategoryId: Int?,
|
||||
|
||||
/**
|
||||
* The display index for this category
|
||||
*/
|
||||
val displayIndex: Int?
|
||||
)
|
||||
|
@ -2,8 +2,23 @@ package top.jie65535.jcf.model
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
class Pagination(
|
||||
/**
|
||||
* A zero based index of the first item that is included in the response
|
||||
*/
|
||||
val index: Int,
|
||||
|
||||
/**
|
||||
* The requested number of items to be included in the response
|
||||
*/
|
||||
val pageSize: Int,
|
||||
|
||||
/**
|
||||
* The actual number of items that were included in the response
|
||||
*/
|
||||
val resultCount: Int,
|
||||
|
||||
/**
|
||||
* The total number of items available by the request
|
||||
*/
|
||||
val totalCount: Long,
|
||||
)
|
@ -10,19 +10,23 @@ class SortableGameVersion(
|
||||
* Original version name (e.g. 1.5b)
|
||||
*/
|
||||
val gameVersionName: String,
|
||||
|
||||
/**
|
||||
* Used for sorting (e.g. 0000000001.0000000005)
|
||||
*/
|
||||
val gameVersionPadded: String,
|
||||
|
||||
/**
|
||||
* game version clean name (e.g. 1.5)
|
||||
*/
|
||||
val gameVersion: String,
|
||||
|
||||
/**
|
||||
* Game version release date
|
||||
*/
|
||||
@Serializable(OffsetDateTimeSerializer::class)
|
||||
val gameVersionReleaseDate: OffsetDateTime,
|
||||
|
||||
/**
|
||||
* Game version type id
|
||||
*/
|
||||
|
@ -7,108 +7,132 @@ import top.jie65535.jcf.model.file.FileIndex
|
||||
import top.jie65535.jcf.util.OffsetDateTimeSerializer
|
||||
import java.time.OffsetDateTime
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
class Mod(
|
||||
/**
|
||||
* The mod id
|
||||
*/
|
||||
val id: Int,
|
||||
|
||||
/**
|
||||
* The game id this mod is for
|
||||
*/
|
||||
val gameId: Int,
|
||||
|
||||
/**
|
||||
* The name of the mod
|
||||
*/
|
||||
val name: String,
|
||||
|
||||
/**
|
||||
* The mod slug that would appear in the URL
|
||||
*/
|
||||
val slug: String,
|
||||
|
||||
/**
|
||||
* Relevant links for the mod such as Issue tracker and Wiki
|
||||
*/
|
||||
val links: ModLinks,
|
||||
|
||||
/**
|
||||
* Mod summary
|
||||
*/
|
||||
val summary: String,
|
||||
|
||||
/**
|
||||
* Current mod status
|
||||
*/
|
||||
val status: ModStatus,
|
||||
|
||||
/**
|
||||
* Number of downloads for the mod
|
||||
*/
|
||||
val downloadCount: Long,
|
||||
|
||||
/**
|
||||
* Whether the mod is included in the featured mods list
|
||||
*/
|
||||
val isFeatured: Boolean,
|
||||
|
||||
/**
|
||||
* The main category of the mod as it was chosen by the mod author
|
||||
*/
|
||||
val primaryCategoryId: Int,
|
||||
|
||||
/**
|
||||
* List of categories that this mod is related to
|
||||
*/
|
||||
val categories: Array<Category>,
|
||||
|
||||
/**
|
||||
* The class id this mod belongs to
|
||||
*/
|
||||
val classId: Int?,
|
||||
|
||||
/**
|
||||
* List of the mod's authors
|
||||
*/
|
||||
val authors: Array<ModAuthor>,
|
||||
|
||||
/**
|
||||
* The mod's logo asset
|
||||
*/
|
||||
val logo: ModAsset,
|
||||
|
||||
/**
|
||||
* List of screenshots assets
|
||||
*/
|
||||
val screenshots: Array<ModAsset>,
|
||||
|
||||
/**
|
||||
* The id of the main file of the mod
|
||||
*/
|
||||
val mainFileId: Int,
|
||||
|
||||
/**
|
||||
* List of latest files of the mod
|
||||
*/
|
||||
val latestFiles: Array<File>,
|
||||
|
||||
/**
|
||||
* List of file related details for the latest files of the mod
|
||||
*/
|
||||
val latestFilesIndexes: Array<FileIndex>,
|
||||
|
||||
/**
|
||||
* The creation date of the mod
|
||||
*/
|
||||
@Serializable(OffsetDateTimeSerializer::class)
|
||||
val dateCreated: OffsetDateTime,
|
||||
|
||||
/**
|
||||
* The last time the mod was modified
|
||||
*/
|
||||
@Serializable(OffsetDateTimeSerializer::class)
|
||||
val dateModified: OffsetDateTime,
|
||||
|
||||
/**
|
||||
* The release date of the mod
|
||||
*/
|
||||
@Serializable(OffsetDateTimeSerializer::class)
|
||||
val dateReleased: OffsetDateTime,
|
||||
|
||||
/**
|
||||
* Is mod allowed to be distributed
|
||||
*/
|
||||
val allowModDistribution: Boolean?,
|
||||
|
||||
/**
|
||||
* The mod popularity rank for the game
|
||||
*/
|
||||
val gamePopularityRank: Int,
|
||||
|
||||
/**
|
||||
* Is the mod available for search. This can be false when a mod is experimental,
|
||||
* in a deleted state or has only alpha files
|
||||
*/
|
||||
val isAvailable: Boolean,
|
||||
|
||||
/**
|
||||
* The mod's thumbs up count
|
||||
*/
|
||||
|
@ -5,6 +5,6 @@ import top.jie65535.jcf.model.mod.Mod
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
class SearchModsResponse(
|
||||
val data: Mod,
|
||||
val data: Array<Mod>,
|
||||
val pagination: Pagination,
|
||||
)
|
Loading…
Reference in New Issue
Block a user