Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
� Conflicts:
�	gradle/versions.gradle
�	gradle/wrapper/gradle-wrapper.properties
�	library/src/main/kotlin/me/proxer/library/internal/adapter/DelimitedEnumSetAdapterFactory.kt
  • Loading branch information
TrueMB committed Jan 31, 2022
2 parents 8f0d265 + 17aa6e0 commit 16b311c
Show file tree
Hide file tree
Showing 35 changed files with 774 additions and 79 deletions.
4 changes: 4 additions & 0 deletions config/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ complexity:
exceptions:
TooGenericExceptionCaught:
active: false
SwallowedException:
active: false

performance:
SpreadOperator:
Expand All @@ -14,3 +16,5 @@ style:
active: false
ForbiddenComment:
active: false
UnnecessaryAbstractClass:
active: false
8 changes: 5 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.dokka.gradle.DokkaTask

plugins {
id 'org.jetbrains.kotlin.jvm'
id "org.jetbrains.kotlin.kapt"
Expand All @@ -15,7 +17,7 @@ plugins {

apply from: "${rootDir}/gradle/dependencies.gradle"

tasks.withType(org.jetbrains.dokka.gradle.DokkaTask).configureEach {
tasks.withType(DokkaTask).configureEach {
dokkaSourceSets {
configureEach {
sourceLink {
Expand All @@ -35,13 +37,13 @@ tasks.dokkaJavadoc.configure {
}

task sourceJar(type: Jar) {
archiveClassifier = "sources"
archiveClassifier.set("sources")

from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
archiveClassifier = "javadoc"
archiveClassifier.set("javadoc")

from javadoc.destinationDir
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ suspend fun <T : Any> ProxerCall<T>.await(): T {
if (result != null) {
continuation.resume(result)
} else {
continuation.resumeWithException(NullPointerException())
continuation.resumeWithException(NullPointerException("Couldn't load any data."))
}
},
{ error -> continuation.resumeWithException(error) }
Expand Down
14 changes: 14 additions & 0 deletions library/src/main/kotlin/me/proxer/library/api/info/InfoApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ class InfoApi internal constructor(retrofit: Retrofit) {
return ModifyUserInfoEndpoint(internalApi, entryId, UserInfoType.FINISHED)
}

/**
* Returns the respective endpoint.
*/
fun person(personId: String): PersonEndpoint {
return PersonEndpoint(internalApi, personId)
}

/**
* Returns the respective endpoint.
*/
fun persons(entryId: String): PersonsCoreEndpoint {
return PersonsCoreEndpoint(internalApi, entryId)
}

/**
* Returns the respective endpoint.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import me.proxer.library.entity.info.EpisodeInfo
import me.proxer.library.entity.info.ForumDiscussion
import me.proxer.library.entity.info.Industry
import me.proxer.library.entity.info.MediaUserInfo
import me.proxer.library.entity.info.Person
import me.proxer.library.entity.info.PersonCore
import me.proxer.library.entity.info.Recommendation
import me.proxer.library.entity.info.Relation
import me.proxer.library.entity.info.TranslatorGroup
Expand Down Expand Up @@ -61,6 +63,12 @@ internal interface InternalApi {
@GET("info/industry")
fun industry(@Query("id") id: String?): ProxerCall<Industry>

@GET("info/person")
fun person(@Query("id") id: String?): ProxerCall<Person>

@GET("info/persons")
fun persons(@Query("id") id: String?): ProxerCall<List<PersonCore>>

@FormUrlEncoded
@POST("info/setuserinfo")
fun modifyUserInfo(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.proxer.library.api.info

import me.proxer.library.ProxerCall
import me.proxer.library.api.Endpoint
import me.proxer.library.entity.info.Person

/**
* Endpoint for retrieving all information of a [Person].
*
* @author TrueMB
*/
class PersonEndpoint internal constructor(
private val internalApi: InternalApi,
private val id: String
) : Endpoint<Person> {

override fun build(): ProxerCall<Person> {
return internalApi.person(id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.proxer.library.api.info

import me.proxer.library.ProxerCall
import me.proxer.library.api.Endpoint
import me.proxer.library.entity.info.PersonCore

/**
* Endpoint for retrieving multiple [PersonCore] Objects for a medium entry.
*
* @author TrueMB
*/
class PersonsCoreEndpoint internal constructor(
private val internalApi: InternalApi,
private val id: String
) : Endpoint<List<PersonCore>> {

override fun build(): ProxerCall<List<PersonCore>> {
return internalApi.persons(id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package me.proxer.library.api.list
import me.proxer.library.ProxerCall
import me.proxer.library.api.PagingLimitEndpoint
import me.proxer.library.entity.list.CharacterListEntry
import me.proxer.library.enums.DescriptionType
import me.proxer.library.enums.CharacterDescriptionType

/**
* Search for all available characters. Features various filter and uses paging.
Expand All @@ -17,18 +17,18 @@ class CharacterSearchEndpoint internal constructor(
private var page: Int? = null
private var limit: Int? = null

private var start: String? = null
private var searchStart: String? = null
private var contains: String? = null
private var search: String? = null
private var subject: DescriptionType? = null
private var subject: CharacterDescriptionType? = null

override fun page(page: Int?) = this.apply { this.page = page }
override fun limit(limit: Int?) = this.apply { this.limit = limit }

/**
* Sets the start String to search for.
* Sets the search start String
*/
fun start(start: String?) = this.apply { this.start = start }
fun searchStart(searchStart: String?) = this.apply { this.searchStart = searchStart }

/**
* Sets the contains String to search for.
Expand All @@ -43,9 +43,9 @@ class CharacterSearchEndpoint internal constructor(
/**
* Sets the subject that should be looked in.
*/
fun subject(subject: DescriptionType?) = this.apply { this.subject = subject }
fun subject(subject: CharacterDescriptionType?) = this.apply { this.subject = subject }

override fun build(): ProxerCall<List<CharacterListEntry>> {
return internalApi.characterSearch(start, contains, search, subject, page, limit)
return internalApi.characterSearch(searchStart, contains, search, subject, page, limit)
}
}
16 changes: 14 additions & 2 deletions library/src/main/kotlin/me/proxer/library/api/list/InternalApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ import me.proxer.library.entity.list.CharacterListEntry
import me.proxer.library.entity.list.IndustryCore
import me.proxer.library.entity.list.IndustryProject
import me.proxer.library.entity.list.MediaListEntry
import me.proxer.library.entity.list.PersonListEntry
import me.proxer.library.entity.list.Tag
import me.proxer.library.entity.list.TranslatorGroupCore
import me.proxer.library.entity.list.TranslatorGroupProject
import me.proxer.library.enums.Category
import me.proxer.library.enums.Country
import me.proxer.library.enums.DescriptionType
import me.proxer.library.enums.CharacterDescriptionType
import me.proxer.library.enums.IndustryType
import me.proxer.library.enums.Language
import me.proxer.library.enums.LengthBound
import me.proxer.library.enums.MediaListSortCriteria
import me.proxer.library.enums.MediaSearchSortCriteria
import me.proxer.library.enums.MediaType
import me.proxer.library.enums.Medium
import me.proxer.library.enums.PersonDescriptionType
import me.proxer.library.enums.ProjectState
import me.proxer.library.enums.SortType
import me.proxer.library.enums.TagRateFilter
Expand Down Expand Up @@ -70,7 +72,7 @@ internal interface InternalApi {
@Query("start") start: String?,
@Query("contains") contains: String?,
@Query("search") search: String?,
@Query("subject") subject: DescriptionType?,
@Query("subject") subject: CharacterDescriptionType?,
@Query("page") page: Int?,
@Query("limit") limit: Int?
): ProxerCall<List<CharacterListEntry>>
Expand All @@ -93,6 +95,16 @@ internal interface InternalApi {
@Query("limit") limit: Int?
): ProxerCall<List<IndustryCore>>

@GET("list/persons")
fun personList(
@Query("start") searchStart: String?,
@Query("contains") contains: String?,
@Query("search") search: String?,
@Query("subject") subject: PersonDescriptionType?,
@Query("p") page: Int?,
@Query("limit") limit: Int?
): ProxerCall<List<PersonListEntry>>

@GET("list/translatorgroupprojects")
fun translatorGroupProjectList(
@Query("id") id: String?,
Expand Down
7 changes: 7 additions & 0 deletions library/src/main/kotlin/me/proxer/library/api/list/ListApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class ListApi internal constructor(retrofit: Retrofit) {
return MediaSearchEndpoint(internalApi)
}

/**
* Returns the respective endpoint.
*/
fun personSearch(): PersonSearchEndpoint {
return PersonSearchEndpoint(internalApi)
}

/**
* Returns the respective endpoint.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package me.proxer.library.api.list

import me.proxer.library.ProxerCall
import me.proxer.library.api.PagingLimitEndpoint
import me.proxer.library.entity.list.PersonListEntry
import me.proxer.library.enums.PersonDescriptionType

/**
* Endpoint for retrieving a list of Persons. Features various filter and uses paging.
*
* @author TrueMB
*/
class PersonSearchEndpoint internal constructor(
private val internalApi: InternalApi
) : PagingLimitEndpoint<List<PersonListEntry>> {

private var page: Int? = null
private var limit: Int? = null

private var searchStart: String? = null
private var contains: String? = null
private var search: String? = null
private var subject: PersonDescriptionType? = null

override fun page(page: Int?) = this.apply { this.page = page }
override fun limit(limit: Int?) = this.apply { this.limit = limit }

/**
* Sets the query to search for only from the start.
*/
fun searchStart(searchStart: String?) = this.apply { this.searchStart = searchStart }

/**
* Sets the contains String to search for.
*/
fun contains(contains: String?) = this.apply { this.contains = contains }

/**
* Sets the query to search for.
*/
fun search(search: String?) = this.apply { this.search = search }

/**
* Sets the subject (description) in which should be searched. (default: intro)
*/
fun subject(subject: PersonDescriptionType?) = this.apply { this.subject = subject }

override fun build(): ProxerCall<List<PersonListEntry>> {
return internalApi.personList(searchStart, contains, search, subject, page, limit)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import me.proxer.library.enums.TagType
*
* @author Ruben Gees
*/
class TagListEndpoint internal constructor(private val internalApi: InternalApi) : Endpoint<List<Tag>> {
class TagListEndpoint internal constructor(
private val internalApi: InternalApi

) : Endpoint<List<Tag>> {

private var name: String? = null
private var type: TagType? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import java.util.Date
* @property birthday The birthday.
* @property height The height.
* @property weight The weight.
* @property descriptions The description.
* @property descriptions The descriptions.
* @property persons The persons in contact with the character
*
* @author Ruben Gees
Expand All @@ -33,6 +33,6 @@ data class Character(
@Json(name = "birthday") val birthday: Date,
@Json(name = "height") val height: String,
@Json(name = "weight") val weight: String,
@Json(name = "description") val descriptions: Set<Description>,
@Json(name = "description") val descriptions: Set<CharacterDescription>,
@Json(name = "persons") val persons: Set<PersonCore>
) : ProxerIdItem
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package me.proxer.library.entity.info

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import me.proxer.library.entity.ProxerIdItem
import me.proxer.library.enums.Language
import me.proxer.library.enums.OccupationType

/**
* Entity with basic Information from a Character.
*
* @property name The name.
* @property type The type
* @property language The language
*
* @author TrueMB
*/
@JsonClass(generateAdapter = true)
data class CharacterCore(
@Json(name = "cid") override val id: String,
@Json(name = "type") val type: OccupationType,
@Json(name = "language") val language: Language,
@Json(name = "name") val name: String
) : ProxerIdItem
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.proxer.library.entity.info

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import me.proxer.library.enums.CharacterDescriptionType
import me.proxer.library.enums.Language

/**
* Entity holding the description Info from [Character].
*
* @property characterDescriptionType The description type
* @property text The text to the description
* @property language The language in which the text was written
*/
@JsonClass(generateAdapter = true)
data class CharacterDescription(
@Json(name = "subject") val characterDescriptionType: CharacterDescriptionType,
@Json(name = "text") val text: String,
@Json(name = "language") val language: Language
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package me.proxer.library.entity.info
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import me.proxer.library.entity.ProxerIdItem
import me.proxer.library.entity.list.CharacterListEntry
import me.proxer.library.entity.list.IndustryCore
import me.proxer.library.enums.Category
import me.proxer.library.enums.FskConstraint
Expand Down Expand Up @@ -60,6 +61,8 @@ data class Entry(
@Json(name = "seasons") val seasons: List<EntrySeasonInfo>,
@Json(name = "groups") val translatorGroups: List<EntryTranslatorGroup>,
@Json(name = "publisher") val industries: List<IndustryCore>,
@Json(name = "characters") val characters: Set<CharacterListEntry>,
@Json(name = "persons") val persons: Set<PersonCore>,
@Json(name = "tags") val tags: List<InfoTag>,
@Json(name = "genres") val genres: List<InfoGenre>
) : ProxerIdItem {
Expand Down
Loading

0 comments on commit 16b311c

Please sign in to comment.