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

19 lines
566 B
Gleam

import gleam/dynamic/decode.{type Decoder}
import models/trade_symbol.{type TradeSymbol}
pub type ShipCargoItem {
ShipCargoItem(
symbol: TradeSymbol,
name: String,
description: String,
units: Int,
)
}
pub fn decoder() -> Decoder(ShipCargoItem) {
use symbol <- decode.field("symbol", trade_symbol.decoder())
use name <- decode.field("name", decode.string)
use description <- decode.field("description", decode.string)
use units <- decode.field("units", decode.int)
decode.success(ShipCargoItem(symbol:, name:, description:, units:))
}