override fun deserialize()

in ses-plugin-server/src/main/kotlin/jetbrains/buildServer/sesPlugin/sqs/SESNotificationParserImpl.kt [27:41]


    override fun deserialize(el: JsonElement, type: Type, context: JsonDeserializationContext): SESNotification {
        if (el is JsonObject) {
            val eventType = el["eventType"]?.asString ?: throw JsonSyntaxException("eventType is not defined in $el")

            val realType = when (eventType) {
                "Bounce" -> BounceNotification::class.java
                "Complaint" -> ComplaintNotification::class.java
                else -> UnknownSESNotification::class.java
            }

            return context.deserialize<SESNotification>(el, realType)
        }

        throw JsonSyntaxException("Expected an json object but got $el")
    }