fix: android sdk segment bug

This commit is contained in:
pandeymangg
2025-05-13 19:24:06 +05:30
parent 3ace91cdd5
commit 1fba692626
2 changed files with 0 additions and 33 deletions

View File

@@ -18,12 +18,6 @@ data class LanguageDetail(
@SerializedName("projectId") val projectId: String
)
@Serializable
data class SurveyRecaptcha(
@SerializedName("enabled") val enabled: Boolean,
@SerializedName("threshold") val threshold: Double
)
@Serializable
data class Survey(
@SerializedName("id") val id: String,
@@ -37,5 +31,4 @@ data class Survey(
@SerializedName("segment") val segment: Segment?,
@SerializedName("styling") val styling: Styling?,
@SerializedName("languages") val languages: List<SurveyLanguage>?,
@SerializedName("recaptcha") val recaptcha: SurveyRecaptcha?
)

View File

@@ -17,31 +17,6 @@ struct SurveyLanguage: Codable {
}
}
struct SurveyRecaptcha: Codable {
let enabled: Bool
let threshold: Double
private enum CodingKeys: String, CodingKey {
case enabled
case threshold
}
// Optional: enforce range at decode time
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.enabled = try container.decode(Bool.self, forKey: .enabled)
let value = try container.decode(Double.self, forKey: .threshold)
guard (0.1...0.9).contains(value) else {
throw DecodingError.dataCorruptedError(
forKey: .threshold,
in: container,
debugDescription: "threshold must be between 0.1 and 0.9"
)
}
self.threshold = value
}
}
struct LanguageDetail: Codable {
let id: String
let code: String
@@ -61,5 +36,4 @@ struct Survey: Codable {
let segment: Segment?
let styling: Styling?
let languages: [SurveyLanguage]?
let recaptcha: SurveyRecaptcha?
}