diff options
author | Joris Guyonvarch | 2015-07-10 00:03:42 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-07-10 00:03:42 +0200 |
commit | 0041c546869f0a7fd59a085cc75b481237b6c380 (patch) | |
tree | 4814108670fc1a3e7c5a334e884accd0e9dc5e96 /src/client/Model | |
parent | 4ce9751c9e645916fdde71874c2cdadd252f32a0 (diff) |
Fetching payments and showing them in a table
Diffstat (limited to 'src/client/Model')
-rw-r--r-- | src/client/Model/Payment.elm | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/client/Model/Payment.elm b/src/client/Model/Payment.elm new file mode 100644 index 0000000..4a08027 --- /dev/null +++ b/src/client/Model/Payment.elm @@ -0,0 +1,31 @@ +module Model.Payment + ( Payments + , Payment + , paymentsDecoder + ) where + +import Date exposing (..) +import Json.Decode as Json exposing ((:=)) + +type alias Payments = List Payment + +type alias Payment = + { creation : Date + , name : String + , cost : Int + , userName : String + } + +paymentsDecoder : Json.Decoder Payments +paymentsDecoder = Json.list paymentDecoder + +paymentDecoder : Json.Decoder Payment +paymentDecoder = + Json.object4 Payment + ("creation" := dateDecoder) + ("name" := Json.string) + ("cost" := Json.int) + ("userName" := Json.string) + +dateDecoder : Json.Decoder Date +dateDecoder = Json.customDecoder Json.string Date.fromString |