14 lines
547 B
Gleam
14 lines
547 B
Gleam
import gleam/dynamic/decode.{type Decoder}
|
|
import models/faction_symbol.{type FactionSymbol}
|
|
import models/ship_role.{type ShipRole}
|
|
|
|
pub type ShipRegistration {
|
|
ShipRegistration(name: String, faction_symbol: FactionSymbol, role: ShipRole)
|
|
}
|
|
|
|
pub fn decoder() -> Decoder(ShipRegistration) {
|
|
use name <- decode.field("name", decode.string)
|
|
use faction_symbol <- decode.field("factionSymbol", faction_symbol.decoder())
|
|
use role <- decode.field("role", ship_role.decoder())
|
|
decode.success(ShipRegistration(name:, faction_symbol:, role:))
|
|
}
|