Compare commits
No commits in common. "main" and "v1.5.4" have entirely different histories.
3 changed files with 3 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
name = "spacetraders_sdk"
|
name = "spacetraders_sdk"
|
||||||
version = "1.5.5"
|
version = "1.5.4"
|
||||||
gleam = ">= 1.11.0"
|
gleam = ">= 1.11.0"
|
||||||
description = "A Gleam SDK for the spacetraders.io game API"
|
description = "A Gleam SDK for the spacetraders.io game API"
|
||||||
licences = ["MIT"]
|
licences = ["MIT"]
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import gleam/dynamic/decode.{type Decoder}
|
import gleam/dynamic/decode.{type Decoder}
|
||||||
import gleam/int
|
|
||||||
import gleam/json.{type Json}
|
import gleam/json.{type Json}
|
||||||
|
|
||||||
pub opaque type ShipComponentCondition {
|
pub opaque type ShipComponentCondition {
|
||||||
|
@ -18,11 +17,7 @@ pub fn parse(value: Float) -> Result(ShipComponentCondition, Nil) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decoder() -> Decoder(ShipComponentCondition) {
|
pub fn decoder() -> Decoder(ShipComponentCondition) {
|
||||||
use value <- decode.then(
|
use value <- decode.then(decode.float)
|
||||||
decode.one_of(decode.float, [
|
|
||||||
decode.then(decode.int, fn(i) { decode.success(int.to_float(i)) }),
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
case parse(value) {
|
case parse(value) {
|
||||||
Ok(ship_component_condition) -> decode.success(ship_component_condition)
|
Ok(ship_component_condition) -> decode.success(ship_component_condition)
|
||||||
Error(Nil) ->
|
Error(Nil) ->
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import gleam/dynamic/decode.{type Decoder}
|
import gleam/dynamic/decode.{type Decoder}
|
||||||
import gleam/int
|
|
||||||
import gleam/json.{type Json}
|
import gleam/json.{type Json}
|
||||||
|
|
||||||
pub opaque type ShipComponentIntegrity {
|
pub opaque type ShipComponentIntegrity {
|
||||||
|
@ -18,11 +17,7 @@ pub fn parse(value: Float) -> Result(ShipComponentIntegrity, Nil) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decoder() -> Decoder(ShipComponentIntegrity) {
|
pub fn decoder() -> Decoder(ShipComponentIntegrity) {
|
||||||
use value <- decode.then(
|
use value <- decode.then(decode.float)
|
||||||
decode.one_of(decode.float, [
|
|
||||||
decode.then(decode.int, fn(i) { decode.success(int.to_float(i)) }),
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
case parse(value) {
|
case parse(value) {
|
||||||
Ok(ship_component_integrity) -> decode.success(ship_component_integrity)
|
Ok(ship_component_integrity) -> decode.success(ship_component_integrity)
|
||||||
Error(Nil) ->
|
Error(Nil) ->
|
||||||
|
|
Loading…
Reference in a new issue