
org.http4k.format.SQSBatchResponseAdapter.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http4k-serverless-lambda Show documentation
Show all versions of http4k-serverless-lambda Show documentation
Http4k Serverless support for AWS Lambda
package org.http4k.format
import com.amazonaws.services.lambda.runtime.events.SQSBatchResponse
import com.amazonaws.services.lambda.runtime.events.SQSBatchResponse.BatchItemFailure
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
object SQSBatchResponseAdapter : JsonAdapter() {
override fun fromJson(reader: JsonReader): SQSBatchResponse =
with(reader) {
obj(::SQSBatchResponse) {
when (it) {
"batchItemFailures" -> batchItemFailures = list(::BatchItemFailure) {
when (it) {
"itemIdentifier" -> itemIdentifier = nextString()
}
}
}
}
}
override fun toJson(writer: JsonWriter, response: SQSBatchResponse?) {
with(writer) {
obj(response) {
list("batchItemFailures", batchItemFailures) {
obj(this) {
string("itemIdentifier", itemIdentifier)
}
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy