Skip to content

Commit

Permalink
chore: fixed more serialization errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Lycoon committed Nov 22, 2023
1 parent a648e3a commit 3155a13
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 24 deletions.
16 changes: 8 additions & 8 deletions src/main/java/com/lycoon/clashapi/core/QueryBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class ClanQueryParamsBuilder(
override val limit: Int? = null,
override val after: String? = null,
override val before: String? = null,
val name: String? = null,
val warFrequency: String? = null,
val locationId: Int? = null,
val minMembers: Int? = null,
val maxMembers: Int? = null,
val minClanPoints: Int? = null,
val minClanLevel: Int? = null,
val labelIds: String? = null
val name: String? = null,
val warFrequency: String? = null,
val locationId: Int? = null,
val minMembers: Int? = null,
val maxMembers: Int? = null,
val minClanPoints: Int? = null,
val minClanLevel: Int? = null,
val labelIds: String? = null
) : QueryParamsBuilder(limit, after, before)
{
override fun build(): String
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lycoon/clashapi/models/clan/Clan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data class Clan
val location: Location? = null, // nullable when using clan search
val badgeUrls: BadgeUrls,
val members: Int = 0,
val memberList: List<ClanMember>? = null, // nullable when using clan search
val memberList: List<ClanMember> = emptyList(), // nullable when using clan search

@Deprecated("Use requiredBuilderBaseTrophies instead")
val requiredVersusTrophies: Int = 0,
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/com/lycoon/clashapi/models/war/War.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package com.lycoon.clashapi.models.war

import com.lycoon.clashapi.models.war.enums.WarState
import kotlinx.serialization.Serializable

@Serializable
data class War(
data class War
(
val clan: WarClan? = null, // if warTag from warleague is #0 (not found)
val teamSize: Int = 0, // if clan is not in war
val attacksPerMember: Int = 0, // if from a warleague round war
val opponent: WarClan? = null, // if warTag from warleague is #0 (not found)
val startTime: String? = null, // if warTag from warleague is #0 (not found)
val state: State,
val state: WarState,
val endTime: String? = null, // if warTag from warleague is #0 (not found)
val preparationStartTime: String? = null // if warTag from warleague is #0 (not found)
) {
enum class State {
CLAN_NOT_FOUND, ACCESS_DENIED, NOT_IN_WAR,
IN_MATCHMAKING, ENTER_WAR, MATCHED, PREPARATION,
WAR, IN_WAR, ENDED
}
}
)
11 changes: 6 additions & 5 deletions src/main/java/com/lycoon/clashapi/models/war/WarClan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import com.lycoon.clashapi.models.common.BadgeUrls
import kotlinx.serialization.Serializable

@Serializable
data class WarClan(
data class WarClan
(
val destructionPercentage: Float = 0f,
val tag: String? = null, // if clan is not in war
val name: String? = null, // if clan is not in war
val tag: String? = null, // if clan is not in war
val name: String? = null, // if clan is not in war
val badgeUrls: BadgeUrls? = null,
val clanLevel: Int = 0,
val attacks: Int = 0,
val stars: Int = 0,
val expEarned: Int = 0, // if from a warleague round war
val members: List<WarMember>?, // if clan is not in war
val expEarned: Int = 0, // if from a war league round war
val members: List<WarMember> = emptyList(), // if clan is not in war
)
2 changes: 1 addition & 1 deletion src/main/java/com/lycoon/clashapi/models/war/WarMember.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ data class WarMember(
val townhallLevel: Int = 0,
val opponentAttacks: Int = 0,
val bestOpponentAttack: WarAttack? = null,
val attacks: List<WarAttack>?
val attacks: List<WarAttack> = emptyList()
)
19 changes: 19 additions & 0 deletions src/main/java/com/lycoon/clashapi/models/war/enums/WarState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.lycoon.clashapi.models.war.enums

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
enum class WarState
{
@SerialName("clanNotFound") CLAN_NOT_FOUND,
@SerialName("accessDenied") ACCESS_DENIED,
@SerialName("notInWar") NOT_IN_WAR,
@SerialName("inMatchmaking") IN_MATCHMAKING,
@SerialName("enterWar") ENTER_WAR,
@SerialName("matched") MATCHED,
@SerialName("preparation") PREPARATION,
@SerialName("war") WAR,
@SerialName("inWar") IN_WAR,
@SerialName("ended") ENDED
}

0 comments on commit 3155a13

Please sign in to comment.