package com.fireworksdk.bridge.models import com.fireworksdk.bridge.models.enums.FWGradientDrawableOrientation import org.json.JSONArray import org.json.JSONObject object FWGradientDrawableModelSerializer { private const val ORIENTATION_KEY = "orientation" private const val COLORS_KEY = "colors" fun serialize(model: FWGradientDrawableModel?): JSONObject? { model ?: return null val jsonObject = JSONObject() jsonObject.put(ORIENTATION_KEY, FWGradientDrawableOrientation.serialize(model.orientation)) if (!model.colors.isNullOrEmpty()) { val colorJsonArray = JSONArray() for (color in model.colors) { colorJsonArray.put(color) } jsonObject.put(COLORS_KEY, colorJsonArray) } return jsonObject } }