forked from DiscordBots/lilJudd
refactor: splatoon3ink api
Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
parent
d8753a8c1f
commit
f3b28ac392
18 changed files with 39 additions and 37 deletions
|
@ -16,9 +16,9 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink
|
||||
|
||||
import net.moonleay.lilJudd.data.api.entry.schedule.ModeData
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule.ModeData
|
||||
import net.moonleay.lilJudd.util.TimeUtil
|
||||
|
||||
object Splatoon3Api {
|
|
@ -16,21 +16,21 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink
|
||||
|
||||
import io.ktor.http.*
|
||||
import kotlinx.serialization.json.*
|
||||
import net.moonleay.lilJudd.data.api.entry.coop.CoopGearData
|
||||
import net.moonleay.lilJudd.data.api.entry.schedule.*
|
||||
import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestColor
|
||||
import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestData
|
||||
import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamData
|
||||
import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamResults
|
||||
import net.moonleay.lilJudd.data.api.entry.splatnet.BrandData
|
||||
import net.moonleay.lilJudd.data.api.entry.splatnet.GearAbilityData
|
||||
import net.moonleay.lilJudd.data.api.entry.splatnet.SplatnetItemData
|
||||
import net.moonleay.lilJudd.data.api.type.ApiDataType
|
||||
import net.moonleay.lilJudd.data.api.type.ApiRequestType
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.coop.CoopGearData
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule.*
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest.SplatfestColor
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest.SplatfestData
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest.SplatfestTeamData
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest.SplatfestTeamResults
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatnet.BrandData
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatnet.GearAbilityData
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatnet.SplatnetItemData
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType
|
||||
import net.moonleay.lilJudd.util.Logger
|
||||
import net.moonleay.lilJudd.util.NetUtil
|
||||
import net.moonleay.liljudd.build.BuildConstants
|
||||
|
@ -49,13 +49,14 @@ object Splatoon3ApiCache {
|
|||
internal var cachedChallengesData = mutableListOf<ChallengeModeData>()
|
||||
internal var cachedShiftData = mutableListOf<ShiftData>()
|
||||
internal var cachedBigRunShiftData = mutableListOf<ShiftData>()
|
||||
internal var cachedCoopRewardsData = mutableListOf<CoopGearData>()
|
||||
internal var cachedCoopRewardsData =
|
||||
mutableListOf<CoopGearData>()
|
||||
internal var cachedSplatnetItemData = mutableListOf<SplatnetItemData>()
|
||||
internal var cachedSplatnetLimitedItemData = mutableListOf<SplatnetItemData>()
|
||||
internal lateinit var splatnetShopBrandData: BrandData
|
||||
internal lateinit var splatnetShopNextBrandData: BrandData
|
||||
fun updateData(dataType: ApiDataType, requestType: ApiRequestType) {
|
||||
Logger.out("Updating data for $dataType with USER-AGENT: $user_agent")
|
||||
Logger.out("Updating data for $dataType with USER-AGENT: ${user_agent}")
|
||||
Logger.out("Reason for update: $requestType")
|
||||
when (dataType) {
|
||||
ApiDataType.SCHEDULES -> {
|
||||
|
@ -225,7 +226,8 @@ object Splatoon3ApiCache {
|
|||
val obj = it as JsonObject
|
||||
val imageURL = Url(obj.jsonObject["originalImage"]!!.jsonObject["url"]!!.jsonPrimitive.content)
|
||||
val id = obj.jsonObject["vsStageId"]!!.jsonPrimitive.int
|
||||
cachedMapData[id] = MapData(
|
||||
cachedMapData[id] =
|
||||
MapData(
|
||||
id,
|
||||
imageURL,
|
||||
it.jsonObject["name"]!!.jsonPrimitive.content
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.coop
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.coop
|
||||
|
||||
import io.ktor.http.*
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.schedule
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule
|
||||
|
||||
data class ChallengeModeData(
|
||||
val leagueMatchEventId: String,
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.schedule
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule
|
||||
|
||||
import io.ktor.http.*
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.schedule
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule
|
||||
|
||||
data class ModeData(
|
||||
val startTime: String,
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.schedule
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule
|
||||
|
||||
import io.ktor.http.*
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.schedule
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule
|
||||
|
||||
data class TimePeriodData(
|
||||
val startTime: String,
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.schedule
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule
|
||||
|
||||
import io.ktor.http.*
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.splatfest
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest
|
||||
|
||||
data class SplatfestColor(
|
||||
val a: Int,
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.splatfest
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest
|
||||
|
||||
import io.ktor.http.*
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.splatfest
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest
|
||||
|
||||
data class SplatfestTeamData(
|
||||
val teamName: String,
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.splatfest
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest
|
||||
|
||||
data class SplatfestTeamResults(
|
||||
val isWinner: Boolean,
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.splatnet
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatnet
|
||||
|
||||
import io.ktor.http.*
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.splatnet
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatnet
|
||||
|
||||
import io.ktor.http.*
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.entry.splatnet
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatnet
|
||||
|
||||
import io.ktor.http.*
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.type
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.type
|
||||
|
||||
enum class ApiDataType {
|
||||
SCHEDULES,
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data.api.type
|
||||
package net.moonleay.lilJudd.data.api.splatoon3ink.type
|
||||
|
||||
enum class ApiRequestType(val nameToDisplay: String) {
|
||||
AUTOMATIC_CACHE_UPDATE("automatic request to update the cache"),
|
Loading…
Reference in a new issue