gleam-spacetraders-sdk/src/models/ship_nav_route.gleam
Lily Rose 64f3729d0c
Some checks are pending
test / test (push) Waiting to run
Refactoring and general tidying up
2025-06-17 19:04:29 +10:00

24 lines
749 B
Gleam

import birl.{type Time}
import gleam/dynamic/decode.{type Decoder}
import models/ship_nav_route_waypoint.{type ShipNavRouteWaypoint}
import utils/api
pub type ShipNavRoute {
ShipNavRoute(
destination: ShipNavRouteWaypoint,
origin: ShipNavRouteWaypoint,
departure_time: Time,
arrival: Time,
)
}
pub fn decoder() -> Decoder(ShipNavRoute) {
use destination <- decode.field(
"destination",
ship_nav_route_waypoint.decoder(),
)
use origin <- decode.field("origin", ship_nav_route_waypoint.decoder())
use departure_time <- decode.field("departureTime", api.time_decoder())
use arrival <- decode.field("arrival", api.time_decoder())
decode.success(ShipNavRoute(destination:, origin:, departure_time:, arrival:))
}