gleam-spacetraders-sdk/src/models/ship_modification_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
1,015 B
Gleam

import birl.{type Time}
import gleam/dynamic/decode.{type Decoder}
import models/ship_symbol.{type ShipSymbol}
import models/trade_symbol.{type TradeSymbol}
import models/waypoint_symbol.{type WaypointSymbol}
import utils/api
pub type ShipModificationTransaction {
ShipModificationTransaction(
waypoint_symbol: WaypointSymbol,
ship_symbol: ShipSymbol,
trade_symbol: TradeSymbol,
total_price: Int,
timestamp: Time,
)
}
pub fn decoder() -> Decoder(ShipModificationTransaction) {
use waypoint_symbol <- decode.field(
"waypointSymbol",
waypoint_symbol.decoder(),
)
use ship_symbol <- decode.field("shipSymbol", ship_symbol.decoder())
use trade_symbol <- decode.field("tradeSymbol", trade_symbol.decoder())
use total_price <- decode.field("totalPrice", decode.int)
use timestamp <- decode.field("timestamp", api.time_decoder())
decode.success(ShipModificationTransaction(
waypoint_symbol:,
ship_symbol:,
trade_symbol:,
total_price:,
timestamp:,
))
}