21 lines
678 B
Gleam
21 lines
678 B
Gleam
import gleam/dynamic/decode.{type Decoder}
|
|
import spacetraders_sdk/models/construction_material.{type ConstructionMaterial}
|
|
import spacetraders_sdk/models/waypoint_symbol.{type WaypointSymbol}
|
|
|
|
pub type Construction {
|
|
Construction(
|
|
symbol: WaypointSymbol,
|
|
materials: List(ConstructionMaterial),
|
|
is_complete: Bool,
|
|
)
|
|
}
|
|
|
|
pub fn decoder() -> Decoder(Construction) {
|
|
use symbol <- decode.field("symbol", waypoint_symbol.decoder())
|
|
use materials <- decode.field(
|
|
"materials",
|
|
decode.list(construction_material.decoder()),
|
|
)
|
|
use is_complete <- decode.field("isComplete", decode.bool)
|
|
decode.success(Construction(symbol:, materials:, is_complete:))
|
|
}
|