aboutsummaryrefslogtreecommitdiff
path: root/src/client/Model/Payment.elm
blob: ff8f157beb8c0ee7fd3ba32be8f2098a0f0e99fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module Model.Payment
  ( Payments
  , Payment
  , paymentsDecoder
  ) where

import Date exposing (..)
import Json.Decode as Json exposing ((:=))

type alias Payments = List Payment

type alias Payment =
  { id : String
  , creation : Date
  , name : String
  , cost : Int
  , userName : String
  }

paymentsDecoder : Json.Decoder Payments
paymentsDecoder = Json.list paymentDecoder

paymentDecoder : Json.Decoder Payment
paymentDecoder =
  Json.object5 Payment
    ("id" := Json.string)
    ("creation" := dateDecoder)
    ("name" := Json.string)
    ("cost" := Json.int)
    ("userName" := Json.string)

dateDecoder : Json.Decoder Date
dateDecoder = Json.customDecoder Json.string Date.fromString