20 lines
732 B
Gleam
20 lines
732 B
Gleam
import gleam/dynamic/decode.{type Decoder}
|
|
import models/ship_component.{type ShipComponent}
|
|
import models/ship_condition_event_symbol.{type ShipConditionEventSymbol}
|
|
|
|
pub type ShipConditionEvent {
|
|
ShipConditionEvent(
|
|
symbol: ShipConditionEventSymbol,
|
|
component: ShipComponent,
|
|
name: String,
|
|
description: String,
|
|
)
|
|
}
|
|
|
|
pub fn decoder() -> Decoder(ShipConditionEvent) {
|
|
use symbol <- decode.field("symbol", ship_condition_event_symbol.decoder())
|
|
use component <- decode.field("component", ship_component.decoder())
|
|
use name <- decode.field("name", decode.string)
|
|
use description <- decode.field("description", decode.string)
|
|
decode.success(ShipConditionEvent(symbol:, component:, name:, description:))
|
|
}
|