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