{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
module Rollbar.Item.Person
( Person(..)
, Id(..)
, Username(..)
, Email(..)
) where
import Data.Aeson
( FromJSON
, ToJSON
, defaultOptions
, genericToEncoding
, genericToJSON
, toEncoding
, toJSON
)
import Data.Aeson.Types (omitNothingFields)
import Data.String (IsString)
import GHC.Generics (Generic)
import qualified Data.Text as T
data Person
= Person
{ id :: Id
, username :: Maybe Username
, email :: Maybe Email
}
deriving (Eq, Generic, Show)
instance FromJSON Person
instance ToJSON Person where
toJSON = genericToJSON defaultOptions { omitNothingFields = True }
toEncoding = genericToEncoding defaultOptions { omitNothingFields = True }
newtype Id
= Id T.Text
deriving (Eq, FromJSON, IsString, Show, ToJSON)
newtype Username
= Username T.Text
deriving (Eq, FromJSON, IsString, Show, ToJSON)
newtype Email
= Email T.Text
deriving (Eq, FromJSON, IsString, Show, ToJSON)