Compare commits

...

2 commits
v1.5.4 ... main

Author SHA1 Message Date
050cef92e4 Bump version to 1.5.5
Some checks failed
test / test (push) Has been cancelled
2025-06-25 12:03:23 +10:00
de20cb5001 Handle float values without decimal point 2025-06-25 12:03:04 +10:00
3 changed files with 13 additions and 3 deletions

View file

@ -1,5 +1,5 @@
name = "spacetraders_sdk"
version = "1.5.4"
version = "1.5.5"
gleam = ">= 1.11.0"
description = "A Gleam SDK for the spacetraders.io game API"
licences = ["MIT"]

View file

@ -1,4 +1,5 @@
import gleam/dynamic/decode.{type Decoder}
import gleam/int
import gleam/json.{type Json}
pub opaque type ShipComponentCondition {
@ -17,7 +18,11 @@ pub fn parse(value: Float) -> Result(ShipComponentCondition, Nil) {
}
pub fn decoder() -> Decoder(ShipComponentCondition) {
use value <- decode.then(decode.float)
use value <- decode.then(
decode.one_of(decode.float, [
decode.then(decode.int, fn(i) { decode.success(int.to_float(i)) }),
]),
)
case parse(value) {
Ok(ship_component_condition) -> decode.success(ship_component_condition)
Error(Nil) ->

View file

@ -1,4 +1,5 @@
import gleam/dynamic/decode.{type Decoder}
import gleam/int
import gleam/json.{type Json}
pub opaque type ShipComponentIntegrity {
@ -17,7 +18,11 @@ pub fn parse(value: Float) -> Result(ShipComponentIntegrity, Nil) {
}
pub fn decoder() -> Decoder(ShipComponentIntegrity) {
use value <- decode.then(decode.float)
use value <- decode.then(
decode.one_of(decode.float, [
decode.then(decode.int, fn(i) { decode.success(int.to_float(i)) }),
]),
)
case parse(value) {
Ok(ship_component_integrity) -> decode.success(ship_component_integrity)
Error(Nil) ->