23 lines
659 B
Gleam
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:))
|
|
}
|