Skip to content

Commit

Permalink
fix: serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
y9san9 committed Nov 1, 2023
1 parent 6aad1c3 commit 29cb47b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,9 @@ import kotlinx.serialization.json.Json
public class KtorMeetacyEngine(
private val baseUrl: Url,
httpClient: HttpClient = HttpClient(),
json: Json = Json,
private val json: Json = Json,
) : MeetacyRequestsEngine {

private val json = Json(json) {
ignoreUnknownKeys = true
}

private val httpClient = httpClient.config {
expectSuccess = true
install(WebSockets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal sealed interface ServerResponse<out T> {
override fun deserialize(decoder: Decoder): ServerResponse<T> {
val data = baseSerializer.deserialize(decoder)
return if (data.status) {
Success(data.data as T)
Success(data.result as T)
} else {
Error(data.errorCode!!, data.errorMessage!!)
}
Expand All @@ -36,7 +36,7 @@ internal sealed interface ServerResponse<out T> {
override fun serialize(encoder: Encoder, value: ServerResponse<T>) {
val data = Data(
status = value is Success,
data = (value as? Success)?.result,
result = (value as? Success)?.result,
errorCode = (value as? Error)?.errorCode,
errorMessage = (value as? Error)?.errorMessage
)
Expand All @@ -46,7 +46,7 @@ internal sealed interface ServerResponse<out T> {
@Serializable
private data class Data<T>(
val status: Boolean,
val data: T? = null,
val result: T? = null,
val errorCode: Int? = null,
val errorMessage: String? = null
)
Expand Down

0 comments on commit 29cb47b

Please sign in to comment.