gleam-spacetraders-sdk/src/models/ship_cargo.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

16 lines
494 B
Gleam

import gleam/dynamic/decode.{type Decoder}
import models/ship_cargo_item.{type ShipCargoItem}
pub type ShipCargo {
ShipCargo(capacity: Int, units: Int, inventory: List(ShipCargoItem))
}
pub fn decoder() -> Decoder(ShipCargo) {
use capacity <- decode.field("capacity", decode.int)
use units <- decode.field("units", decode.int)
use inventory <- decode.field(
"inventory",
decode.list(ship_cargo_item.decoder()),
)
decode.success(ShipCargo(capacity:, units:, inventory:))
}