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

34 lines
944 B
Gleam

import birl.{type Time}
import gleam/dynamic/decode.{type Decoder}
import models/agent_symbol.{type AgentSymbol}
import models/ship_type.{type ShipType}
import models/waypoint_symbol.{type WaypointSymbol}
import utils/api
pub type ShipyardTransaction {
ShipyardTransaction(
waypoint_symbol: WaypointSymbol,
ship_type: ShipType,
price: Int,
agent_symbol: AgentSymbol,
timestamp: Time,
)
}
pub fn decoder() -> Decoder(ShipyardTransaction) {
use waypoint_symbol <- decode.field(
"waypointSymbol",
waypoint_symbol.decoder(),
)
use ship_type <- decode.field("shipType", ship_type.decoder())
use price <- decode.field("price", decode.int)
use agent_symbol <- decode.field("agentSymbol", agent_symbol.decoder())
use timestamp <- decode.field("timestamp", api.time_decoder())
decode.success(ShipyardTransaction(
waypoint_symbol:,
ship_type:,
price:,
agent_symbol:,
timestamp:,
))
}