import gleam/dynamic/decode.{type Decoder} import models/trade_symbol.{type TradeSymbol} pub type ShipCargoItem { ShipCargoItem( symbol: TradeSymbol, name: String, description: String, units: Int, ) } pub fn decoder() -> Decoder(ShipCargoItem) { use symbol <- decode.field("symbol", trade_symbol.decoder()) use name <- decode.field("name", decode.string) use description <- decode.field("description", decode.string) use units <- decode.field("units", decode.int) decode.success(ShipCargoItem(symbol:, name:, description:, units:)) }