package com.fireworksdk.bridge.models import org.json.JSONObject object FWActionButtonDeserializer { private const val BACKGROUND_COLOR = "backgroundColor" private const val TEXT_COLOR = "textColor" private const val SHAPE = "shape" private const val DIVIDING_LINE_COLOR = "dividingLineColor" fun deserialize(responseJson: JSONObject?): FWActionButtonModel? { responseJson ?: return null val backgroundColor = if (responseJson.has(BACKGROUND_COLOR)) responseJson.optString(BACKGROUND_COLOR) else null val textColor = if (responseJson.has(TEXT_COLOR)) responseJson.optString(TEXT_COLOR) else null val dividingLineColor = if (responseJson.has(DIVIDING_LINE_COLOR)) responseJson.optString(DIVIDING_LINE_COLOR) else null val shape = if (responseJson.has(SHAPE)) responseJson.optString(SHAPE) else null return FWActionButtonModel( backgroundColor = backgroundColor, textColor = textColor, dividingLineColor = dividingLineColor, shape = if (!shape.isNullOrBlank()) FWShape.deserialize(shape) else null, ) } }