gleam-spacetraders-sdk/src/spacetraders_sdk/models/ship_nav_route_waypoint.gleam

23 lines
836 B
Gleam

import gleam/dynamic/decode.{type Decoder}
import spacetraders_sdk/models/system_symbol.{type SystemSymbol}
import spacetraders_sdk/models/waypoint_symbol.{type WaypointSymbol}
import spacetraders_sdk/models/waypoint_type.{type WaypointType}
pub type ShipNavRouteWaypoint {
ShipNavRouteWaypoint(
symbol: WaypointSymbol,
type_: WaypointType,
system_symbol: SystemSymbol,
x: Int,
y: Int,
)
}
pub fn decoder() -> Decoder(ShipNavRouteWaypoint) {
use symbol <- decode.field("symbol", waypoint_symbol.decoder())
use type_ <- decode.field("type", waypoint_type.decoder())
use system_symbol <- decode.field("systemSymbol", system_symbol.decoder())
use x <- decode.field("x", decode.int)
use y <- decode.field("y", decode.int)
decode.success(ShipNavRouteWaypoint(symbol:, type_:, system_symbol:, x:, y:))
}