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

37 lines
956 B
Gleam

import gleam/dynamic/decode.{type Decoder}
import utils/decode as decode_utils
pub type WaypointModifierSymbol {
Stripped
Unstable
RadiationLeak
CriticalLimit
CivilUnrest
}
pub fn to_string(waypoint_modifier_symbol: WaypointModifierSymbol) -> String {
case waypoint_modifier_symbol {
Stripped -> "STRIPPED"
Unstable -> "UNSTABLE"
RadiationLeak -> "RADIATION_LEAK"
CriticalLimit -> "CRITICAL_LIMIT"
CivilUnrest -> "CIVIL_UNREST"
}
}
pub fn parse(
waypoint_modifier_symbol_str: String,
) -> Result(WaypointModifierSymbol, WaypointModifierSymbol) {
case waypoint_modifier_symbol_str {
"STRIPPED" -> Ok(Stripped)
"UNSTABLE" -> Ok(Unstable)
"RADIATION_LEAK" -> Ok(RadiationLeak)
"CRITICAL_LIMIT" -> Ok(CriticalLimit)
"CIVIL_UNREST" -> Ok(CivilUnrest)
_ -> Error(Stripped)
}
}
pub fn decoder() -> Decoder(WaypointModifierSymbol) {
decode_utils.enum_decoder(parse, "WaypointModifierSymbol")
}