onasty/web/src/Data/Me.elm (view raw)
Olexandr Smirnov
Olexandr Smirnov
ss2316544@gmail.com feat(web): add account settings (#190)..., 9 months ago
ss2316544@gmail.com feat(web): add account settings (#190)..., 9 months ago
| 1 | module Data.Me exposing (Me, decode) |
| 2 | |
| 3 | import Iso8601 |
| 4 | import Json.Decode as Decode exposing (Decoder) |
| 5 | import Time exposing (Posix) |
| 6 | |
| 7 | |
| 8 | type alias Me = |
| 9 | { email : String |
| 10 | , createdAt : Posix |
| 11 | , lastLoginAt : Posix |
| 12 | , notesCreated : Int |
| 13 | } |
| 14 | |
| 15 | |
| 16 | decode : Decoder Me |
| 17 | decode = |
| 18 | Decode.map4 Me |
| 19 | (Decode.field "email" Decode.string) |
| 20 | (Decode.field "created_at" Iso8601.decoder) |
| 21 | (Decode.field "last_login_at" Iso8601.decoder) |
| 22 | (Decode.field "notes_created" Decode.int) |