import gleam/dynamic/decode.{type Decoder} import spacetraders_models/agent_symbol.{type AgentSymbol} import spacetraders_models/ship_type.{type ShipType} import spacetraders_models/timestamp.{type Timestamp} import spacetraders_models/waypoint_symbol.{type WaypointSymbol} pub type ShipyardTransaction { ShipyardTransaction( waypoint_symbol: WaypointSymbol, ship_type: ShipType, price: Int, agent_symbol: AgentSymbol, timestamp: Timestamp, ) } pub fn decoder() -> Decoder(ShipyardTransaction) { use waypoint_symbol <- decode.field( "waypointSymbol", waypoint_symbol.decoder(), ) use ship_type <- decode.field("shipType", ship_type.decoder()) use price <- decode.field("price", decode.int) use agent_symbol <- decode.field("agentSymbol", agent_symbol.decoder()) use timestamp <- decode.field("timestamp", timestamp.decoder()) decode.success(ShipyardTransaction( waypoint_symbol:, ship_type:, price:, agent_symbol:, timestamp:, )) }