Skip to content

Commit

Permalink
fix: encode physicalDurability parameter. (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 authored Sep 13, 2024
1 parent efe88f5 commit f6750b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Data/Textile/Inputs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ stepsToStrings inputs =
else
""
)
++ (case inputs.physicalDurability of
Just physicalDurability ->
", durabilité physique " ++ String.fromFloat (Unit.physicalDurabilityToFloat physicalDurability)

Nothing ->
""
)
, Format.kgToString inputs.mass
]
, ifStepEnabled Label.Material
Expand Down Expand Up @@ -500,6 +507,7 @@ encode inputs =
, ( "mass", Encode.float (Mass.inKilograms inputs.mass) )
, ( "materials", Encode.list encodeMaterialInput inputs.materials )
, ( "numberOfReferences", inputs.numberOfReferences |> Maybe.map Encode.int |> Maybe.withDefault Encode.null )
, ( "physicalDurability", inputs.physicalDurability |> Maybe.map Unit.encodePhysicalDurability |> Maybe.withDefault Encode.null )
, ( "price", inputs.price |> Maybe.map Economics.encodePrice |> Maybe.withDefault Encode.null )
, ( "printing", inputs.printing |> Maybe.map Printing.encode |> Maybe.withDefault Encode.null )
, ( "product", Product.encode inputs.product )
Expand Down
1 change: 1 addition & 0 deletions src/Data/Textile/Query.elm
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ encode query =
, ( "mass", query.mass |> Mass.inKilograms |> Encode.float |> Just )
, ( "materials", query.materials |> Encode.list encodeMaterialQuery |> Just )
, ( "numberOfReferences", query.numberOfReferences |> Maybe.map Encode.int )
, ( "physicalDurability", query.physicalDurability |> Maybe.map Unit.encodePhysicalDurability )
, ( "price", query.price |> Maybe.map Economics.encodePrice )
, ( "printing", query.printing |> Maybe.map Printing.encode )
, ( "product", query.product |> Product.idToString |> Encode.string |> Just )
Expand Down
6 changes: 6 additions & 0 deletions src/Data/Unit.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Data.Unit exposing
, decodeYarnSize
, encodeImpact
, encodeNonPhysicalDurability
, encodePhysicalDurability
, encodePickPerMeter
, encodeRatio
, encodeSurfaceMass
Expand Down Expand Up @@ -191,6 +192,11 @@ decodePhysicalDurability =
|> Decode.map physicalDurability


encodePhysicalDurability : PhysicalDurability -> Encode.Value
encodePhysicalDurability (PhysicalDurability float) =
Encode.float float


encodeNonPhysicalDurability : NonPhysicalDurability -> Encode.Value
encodeNonPhysicalDurability (NonPhysicalDurability float) =
Encode.float float
Expand Down

0 comments on commit f6750b8

Please sign in to comment.