gleam-spacetraders-sdk/src/models/ship_registration.gleam
Lily Rose cc8edbed02
Some checks are pending
test / test (push) Waiting to run
Add functioning sdk
2025-06-17 01:43:06 +10:00

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:))
}