From 0041c546869f0a7fd59a085cc75b481237b6c380 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Fri, 10 Jul 2015 00:03:42 +0200 Subject: Fetching payments and showing them in a table --- src/client/Model/Payment.elm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/client/Model/Payment.elm (limited to 'src/client/Model') 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 -- cgit v1.2.3