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

23 lines
659 B
Gleam

import birl.{type Time}
import gleam/dynamic/decode.{type Decoder}
import models/agent_symbol.{type AgentSymbol}
import models/waypoint_symbol.{type WaypointSymbol}
import utils/api
pub type Chart {
Chart(
waypoint_symbol: WaypointSymbol,
submitted_by: AgentSymbol,
submitted_on: Time,
)
}
pub fn decoder() -> Decoder(Chart) {
use waypoint_symbol <- decode.field(
"waypointSymbol",
waypoint_symbol.decoder(),
)
use submitted_by <- decode.field("submittedBy", agent_symbol.decoder())
use submitted_on <- decode.field("submittedOn", api.time_decoder())
decode.success(Chart(waypoint_symbol:, submitted_by:, submitted_on:))
}