gleam-spacetraders-sdk/src/models/cooldown.gleam
Lily Rose cc8edbed02
Some checks are pending
test / test (push) Waiting to run
Add functioning sdk
2025-06-17 01:43:06 +10:00

29 lines
770 B
Gleam

import gleam/dynamic/decode.{type Decoder}
import gleam/option.{type Option}
import models/ship_symbol.{type ShipSymbol}
import utils/decode as decode_utils
pub type Cooldown {
Cooldown(
ship_symbol: ShipSymbol,
total_seconds: Int,
remaining_seconds: Int,
expiration: Option(String),
)
}
pub fn decoder() -> Decoder(Cooldown) {
use ship_symbol <- decode.field("shipSymbol", ship_symbol.decoder())
use total_seconds <- decode.field("totalSeconds", decode.int)
use remaining_seconds <- decode.field("remainingSeconds", decode.int)
use expiration <- decode_utils.field_key_value_optional(
"expiration",
decode.string,
)
decode.success(Cooldown(
ship_symbol:,
total_seconds:,
remaining_seconds:,
expiration:,
))
}