2023-05-26 01:39:50 +02:00
|
|
|
module App.UserPublic where
|
|
|
|
|
|
|
|
import Prelude
|
|
|
|
|
2023-06-04 01:24:05 +02:00
|
|
|
import Data.Maybe
|
|
|
|
|
2023-05-26 01:39:50 +02:00
|
|
|
import Data.Codec.Argonaut (JsonCodec)
|
|
|
|
import Data.Codec.Argonaut as CA
|
|
|
|
import Data.Codec.Argonaut.Record as CAR
|
|
|
|
import Data.Newtype (class Newtype)
|
|
|
|
|
2023-05-27 12:26:03 +02:00
|
|
|
-- | Currently not the real type.
|
2023-06-04 02:01:50 +02:00
|
|
|
-- | Lacks 'profile' attribute.
|
|
|
|
-- TODO: add profile :: JSON any
|
2023-06-04 01:24:05 +02:00
|
|
|
type UserPublic = { login :: String, uid :: Int, date_registration :: Maybe String }
|
2023-05-26 01:39:50 +02:00
|
|
|
|
|
|
|
-- | UserPublic.codec can be used to parse and encode public user info,
|
|
|
|
-- | which can be exchanged in different messages.
|
|
|
|
codec :: JsonCodec UserPublic
|
2023-06-04 02:01:50 +02:00
|
|
|
codec = CA.object "UserPublic" (CAR.record { login: CA.string
|
|
|
|
, uid: CA.int
|
|
|
|
, date_registration: CAR.optional CA.string })
|
2023-06-04 01:24:05 +02:00
|
|
|
|
|
|
|
-- {"user":{"login":"a","uid": 1003,"date_registration":"2023-06-03T03:32:10+02:00"}}
|