mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 08:01:20 +02:00
Working request flow
This commit is contained in:
parent
ac5f0aa367
commit
4a0198b462
5 changed files with 210 additions and 14 deletions
|
|
@ -192,7 +192,8 @@ aboutLibraries {
|
||||||
|
|
||||||
openApiGenerate {
|
openApiGenerate {
|
||||||
generatorName.set("kotlin")
|
generatorName.set("kotlin")
|
||||||
inputSpec.set("$projectDir/src/main/seerr-api.yml")
|
inputSpec.set("$projectDir/src/main/seerr/seerr-api.yml")
|
||||||
|
templateDir.set("$projectDir/src/main/seerr/templates")
|
||||||
outputDir.set("$buildDir/generated/seerr_api")
|
outputDir.set("$buildDir/generated/seerr_api")
|
||||||
apiPackage.set("com.github.damontecres.wholphin.api.seerr")
|
apiPackage.set("com.github.damontecres.wholphin.api.seerr")
|
||||||
modelPackage.set("com.github.damontecres.wholphin.api.seerr.model")
|
modelPackage.set("com.github.damontecres.wholphin.api.seerr.model")
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ class DiscoverMovieViewModel
|
||||||
seerrService.api.requestApi.requestPost(
|
seerrService.api.requestApi.requestPost(
|
||||||
RequestPostRequest(
|
RequestPostRequest(
|
||||||
is4k = false,
|
is4k = false,
|
||||||
mediaid = id,
|
mediaId = id,
|
||||||
mediaType = RequestPostRequest.MediaType.MOVIE,
|
mediaType = RequestPostRequest.MediaType.MOVIE,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ fun ExpandableDiscoverButtons(
|
||||||
.focusRestorer(firstFocus),
|
.focusRestorer(firstFocus),
|
||||||
) {
|
) {
|
||||||
if (availability == SeerrAvailability.UNKNOWN) {
|
if (availability == SeerrAvailability.UNKNOWN) {
|
||||||
item("request") {
|
item("first") {
|
||||||
ExpandableFaButton(
|
ExpandableFaButton(
|
||||||
title = R.string.request,
|
title = R.string.request,
|
||||||
iconStringRes = R.string.fa_download,
|
iconStringRes = R.string.fa_download,
|
||||||
|
|
@ -54,7 +54,7 @@ fun ExpandableDiscoverButtons(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (availability == SeerrAvailability.PENDING || availability == SeerrAvailability.PROCESSING) {
|
} else if (availability == SeerrAvailability.PENDING || availability == SeerrAvailability.PROCESSING) {
|
||||||
item("pending") {
|
item("first") {
|
||||||
ExpandableFaButton(
|
ExpandableFaButton(
|
||||||
title = R.string.pending,
|
title = R.string.pending,
|
||||||
iconStringRes = R.string.fa_clock,
|
iconStringRes = R.string.fa_clock,
|
||||||
|
|
@ -75,12 +75,11 @@ fun ExpandableDiscoverButtons(
|
||||||
resume = Duration.ZERO,
|
resume = Duration.ZERO,
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.focusRequester(firstFocus)
|
|
||||||
.onFocusChanged(buttonOnFocusChanged),
|
.onFocusChanged(buttonOnFocusChanged),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (availability == SeerrAvailability.PARTIALLY_AVAILABLE || availability == SeerrAvailability.AVAILABLE) {
|
} else if (availability == SeerrAvailability.PARTIALLY_AVAILABLE || availability == SeerrAvailability.AVAILABLE) {
|
||||||
item("goto") {
|
item("first") {
|
||||||
ExpandablePlayButton(
|
ExpandablePlayButton(
|
||||||
title = R.string.go_to,
|
title = R.string.go_to,
|
||||||
icon = Icons.Default.PlayArrow,
|
icon = Icons.Default.PlayArrow,
|
||||||
|
|
|
||||||
|
|
@ -6117,20 +6117,24 @@ paths:
|
||||||
type: string
|
type: string
|
||||||
enum: [movie, tv]
|
enum: [movie, tv]
|
||||||
example: movie
|
example: movie
|
||||||
mediaid:
|
mediaId:
|
||||||
type: integer
|
type: integer
|
||||||
example: 123
|
example: 123
|
||||||
tvdbid:
|
tvdbid:
|
||||||
type: integer
|
type: integer
|
||||||
example: 123
|
example: 123
|
||||||
seasons:
|
seasons:
|
||||||
oneOf:
|
# oneOf:
|
||||||
- type: array
|
# - type: array
|
||||||
items:
|
# items:
|
||||||
type: integer
|
# type: integer
|
||||||
minimum: 0
|
# minimum: 0
|
||||||
- type: string
|
# - type: string
|
||||||
enum: [all]
|
# enum: [all]
|
||||||
|
# TODO
|
||||||
|
type: string
|
||||||
|
enum: [all]
|
||||||
|
nullable: true
|
||||||
is4k:
|
is4k:
|
||||||
type: boolean
|
type: boolean
|
||||||
example: false
|
example: false
|
||||||
|
|
@ -6140,6 +6144,7 @@ paths:
|
||||||
type: integer
|
type: integer
|
||||||
rootFolder:
|
rootFolder:
|
||||||
type: string
|
type: string
|
||||||
|
nullable: true
|
||||||
languageProfileid:
|
languageProfileid:
|
||||||
type: integer
|
type: integer
|
||||||
userid:
|
userid:
|
||||||
|
|
@ -0,0 +1,191 @@
|
||||||
|
package {{packageName}}.infrastructure
|
||||||
|
|
||||||
|
{{#moshi}}
|
||||||
|
import com.squareup.moshi.Moshi
|
||||||
|
{{#enumUnknownDefaultCase}}
|
||||||
|
import com.squareup.moshi.adapters.EnumJsonAdapter
|
||||||
|
{{/enumUnknownDefaultCase}}
|
||||||
|
{{^moshiCodeGen}}
|
||||||
|
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||||
|
{{/moshiCodeGen}}
|
||||||
|
{{/moshi}}
|
||||||
|
{{#gson}}
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.GsonBuilder
|
||||||
|
{{^threetenbp}}
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.OffsetDateTime
|
||||||
|
{{/threetenbp}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
import org.threeten.bp.LocalDate
|
||||||
|
import org.threeten.bp.LocalDateTime
|
||||||
|
import org.threeten.bp.OffsetDateTime
|
||||||
|
{{/threetenbp}}
|
||||||
|
{{#kotlinx-datetime}}
|
||||||
|
import kotlin.time.Instant
|
||||||
|
import kotlinx.datetime.LocalDate
|
||||||
|
import kotlinx.datetime.LocalTime
|
||||||
|
{{/kotlinx-datetime}}
|
||||||
|
import java.util.UUID
|
||||||
|
{{/gson}}
|
||||||
|
{{#jackson}}
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude
|
||||||
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
|
{{/jackson}}
|
||||||
|
{{#kotlinx_serialization}}
|
||||||
|
import java.math.BigDecimal
|
||||||
|
import java.math.BigInteger
|
||||||
|
{{^threetenbp}}
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.OffsetDateTime
|
||||||
|
{{/threetenbp}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
import org.threeten.bp.LocalDate
|
||||||
|
import org.threeten.bp.LocalDateTime
|
||||||
|
import org.threeten.bp.OffsetDateTime
|
||||||
|
{{/threetenbp}}
|
||||||
|
import java.util.UUID
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.JsonBuilder
|
||||||
|
import kotlinx.serialization.modules.SerializersModule
|
||||||
|
import kotlinx.serialization.modules.SerializersModuleBuilder
|
||||||
|
import java.net.URI
|
||||||
|
import java.net.URL
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
|
{{/kotlinx_serialization}}
|
||||||
|
|
||||||
|
{{#nonPublicApi}}internal {{/nonPublicApi}}{{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}object Serializer {
|
||||||
|
{{#moshi}}
|
||||||
|
@JvmStatic
|
||||||
|
{{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}val moshiBuilder: Moshi.Builder = Moshi.Builder()
|
||||||
|
.add(OffsetDateTimeAdapter())
|
||||||
|
{{#kotlinx-datetime}}
|
||||||
|
.add(InstantAdapter())
|
||||||
|
.add(LocalDateAdapter())
|
||||||
|
.add(LocalTimeAdapter())
|
||||||
|
{{/kotlinx-datetime}}
|
||||||
|
.add(LocalDateTimeAdapter())
|
||||||
|
.add(LocalDateAdapter())
|
||||||
|
.add(UUIDAdapter())
|
||||||
|
.add(ByteArrayAdapter())
|
||||||
|
.add(URIAdapter())
|
||||||
|
{{^moshiCodeGen}}
|
||||||
|
.add(KotlinJsonAdapterFactory())
|
||||||
|
{{/moshiCodeGen}}
|
||||||
|
.add(BigDecimalAdapter())
|
||||||
|
.add(BigIntegerAdapter())
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
{{^nonPublicApi}}{{#explicitApi}}public {{/explicitApi}}{{/nonPublicApi}}val moshi: Moshi by lazy {
|
||||||
|
{{#enumUnknownDefaultCase}}
|
||||||
|
SerializerHelper.addEnumUnknownDefaultCase(moshiBuilder)
|
||||||
|
{{/enumUnknownDefaultCase}}
|
||||||
|
moshiBuilder.build()
|
||||||
|
}
|
||||||
|
{{/moshi}}
|
||||||
|
{{#gson}}
|
||||||
|
@JvmStatic
|
||||||
|
val gsonBuilder: GsonBuilder = GsonBuilder()
|
||||||
|
.registerTypeAdapter(OffsetDateTime::class.java, OffsetDateTimeAdapter())
|
||||||
|
{{#kotlinx-datetime}}
|
||||||
|
.registerTypeAdapter(Instant::class.java, InstantAdapter())
|
||||||
|
.registerTypeAdapter(LocalDate::class.java, LocalDateAdapter())
|
||||||
|
.registerTypeAdapter(LocalTime::class.java, LocalTimeAdapter())
|
||||||
|
{{/kotlinx-datetime}}
|
||||||
|
.registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter())
|
||||||
|
.registerTypeAdapter(LocalDate::class.java, LocalDateAdapter())
|
||||||
|
.registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter())
|
||||||
|
{{#generateOneOfAnyOfWrappers}}
|
||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
{{^isEnum}}
|
||||||
|
{{^hasChildren}}
|
||||||
|
.registerTypeAdapterFactory({{modelPackage}}.{{{classname}}}.CustomTypeAdapterFactory())
|
||||||
|
{{/hasChildren}}
|
||||||
|
{{/isEnum}}
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
||||||
|
{{/generateOneOfAnyOfWrappers}}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val gson: Gson by lazy {
|
||||||
|
gsonBuilder.create()
|
||||||
|
}
|
||||||
|
{{/gson}}
|
||||||
|
{{#jackson}}
|
||||||
|
@JvmStatic
|
||||||
|
val jacksonObjectMapper: ObjectMapper = jacksonObjectMapper()
|
||||||
|
.findAndRegisterModules()
|
||||||
|
.setSerializationInclusion(JsonInclude.Include.NON_ABSENT)
|
||||||
|
{{#enumUnknownDefaultCase}}
|
||||||
|
.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, true)
|
||||||
|
{{/enumUnknownDefaultCase}}
|
||||||
|
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
|
||||||
|
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, {{failOnUnknownProperties}})
|
||||||
|
{{/jackson}}
|
||||||
|
{{#kotlinx_serialization}}
|
||||||
|
private var isAdaptersInitialized = false
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val kotlinxSerializationAdapters: SerializersModule by lazy {
|
||||||
|
isAdaptersInitialized = true
|
||||||
|
SerializersModule {
|
||||||
|
contextual(BigDecimal::class, BigDecimalAdapter)
|
||||||
|
contextual(BigInteger::class, BigIntegerAdapter)
|
||||||
|
{{^kotlinx-datetime}}
|
||||||
|
contextual(LocalDate::class, LocalDateAdapter)
|
||||||
|
contextual(LocalDateTime::class, LocalDateTimeAdapter)
|
||||||
|
contextual(OffsetDateTime::class, OffsetDateTimeAdapter)
|
||||||
|
{{/kotlinx-datetime}}
|
||||||
|
contextual(UUID::class, UUIDAdapter)
|
||||||
|
contextual(AtomicInteger::class, AtomicIntegerAdapter)
|
||||||
|
contextual(AtomicLong::class, AtomicLongAdapter)
|
||||||
|
contextual(AtomicBoolean::class, AtomicBooleanAdapter)
|
||||||
|
contextual(URI::class, URIAdapter)
|
||||||
|
contextual(URL::class, URLAdapter)
|
||||||
|
contextual(StringBuilder::class, StringBuilderAdapter)
|
||||||
|
|
||||||
|
apply(kotlinxSerializationAdaptersConfiguration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var kotlinxSerializationAdaptersConfiguration: SerializersModuleBuilder.() -> Unit = {}
|
||||||
|
set(value) {
|
||||||
|
check(!isAdaptersInitialized) {
|
||||||
|
"Cannot configure kotlinxSerializationAdaptersConfiguration after kotlinxSerializationAdapters has been initialized."
|
||||||
|
}
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
|
||||||
|
private var isJsonInitialized = false
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val kotlinxSerializationJson: Json by lazy {
|
||||||
|
isJsonInitialized = true
|
||||||
|
Json {
|
||||||
|
serializersModule = kotlinxSerializationAdapters
|
||||||
|
encodeDefaults = true
|
||||||
|
ignoreUnknownKeys = true
|
||||||
|
isLenient = true
|
||||||
|
explicitNulls = false
|
||||||
|
|
||||||
|
apply(kotlinxSerializationJsonConfiguration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var kotlinxSerializationJsonConfiguration: JsonBuilder.() -> Unit = {}
|
||||||
|
set(value) {
|
||||||
|
check(!isJsonInitialized) {
|
||||||
|
"Cannot configure kotlinxSerializationJsonConfiguration after kotlinxSerializationJson has been initialized."
|
||||||
|
}
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
{{/kotlinx_serialization}}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue