module TD.Data.ReadDatePrivacySettings
( ReadDatePrivacySettings(..)
, defaultReadDatePrivacySettings
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ReadDatePrivacySettings
= ReadDatePrivacySettings
{ ReadDatePrivacySettings -> Maybe Bool
show_read_date :: Maybe Bool
}
deriving (ReadDatePrivacySettings -> ReadDatePrivacySettings -> Bool
(ReadDatePrivacySettings -> ReadDatePrivacySettings -> Bool)
-> (ReadDatePrivacySettings -> ReadDatePrivacySettings -> Bool)
-> Eq ReadDatePrivacySettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReadDatePrivacySettings -> ReadDatePrivacySettings -> Bool
== :: ReadDatePrivacySettings -> ReadDatePrivacySettings -> Bool
$c/= :: ReadDatePrivacySettings -> ReadDatePrivacySettings -> Bool
/= :: ReadDatePrivacySettings -> ReadDatePrivacySettings -> Bool
Eq, Int -> ReadDatePrivacySettings -> ShowS
[ReadDatePrivacySettings] -> ShowS
ReadDatePrivacySettings -> String
(Int -> ReadDatePrivacySettings -> ShowS)
-> (ReadDatePrivacySettings -> String)
-> ([ReadDatePrivacySettings] -> ShowS)
-> Show ReadDatePrivacySettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReadDatePrivacySettings -> ShowS
showsPrec :: Int -> ReadDatePrivacySettings -> ShowS
$cshow :: ReadDatePrivacySettings -> String
show :: ReadDatePrivacySettings -> String
$cshowList :: [ReadDatePrivacySettings] -> ShowS
showList :: [ReadDatePrivacySettings] -> ShowS
Show)
instance I.ShortShow ReadDatePrivacySettings where
shortShow :: ReadDatePrivacySettings -> String
shortShow ReadDatePrivacySettings
{ show_read_date :: ReadDatePrivacySettings -> Maybe Bool
show_read_date = Maybe Bool
show_read_date_
}
= String
"ReadDatePrivacySettings"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"show_read_date" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
show_read_date_
]
instance AT.FromJSON ReadDatePrivacySettings where
parseJSON :: Value -> Parser ReadDatePrivacySettings
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"readDatePrivacySettings" -> Value -> Parser ReadDatePrivacySettings
parseReadDatePrivacySettings Value
v
String
_ -> Parser ReadDatePrivacySettings
forall a. Monoid a => a
mempty
where
parseReadDatePrivacySettings :: A.Value -> AT.Parser ReadDatePrivacySettings
parseReadDatePrivacySettings :: Value -> Parser ReadDatePrivacySettings
parseReadDatePrivacySettings = String
-> (Object -> Parser ReadDatePrivacySettings)
-> Value
-> Parser ReadDatePrivacySettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ReadDatePrivacySettings" ((Object -> Parser ReadDatePrivacySettings)
-> Value -> Parser ReadDatePrivacySettings)
-> (Object -> Parser ReadDatePrivacySettings)
-> Value
-> Parser ReadDatePrivacySettings
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Bool
show_read_date_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"show_read_date"
ReadDatePrivacySettings -> Parser ReadDatePrivacySettings
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ReadDatePrivacySettings -> Parser ReadDatePrivacySettings)
-> ReadDatePrivacySettings -> Parser ReadDatePrivacySettings
forall a b. (a -> b) -> a -> b
$ ReadDatePrivacySettings
{ show_read_date :: Maybe Bool
show_read_date = Maybe Bool
show_read_date_
}
parseJSON Value
_ = Parser ReadDatePrivacySettings
forall a. Monoid a => a
mempty
instance AT.ToJSON ReadDatePrivacySettings where
toJSON :: ReadDatePrivacySettings -> Value
toJSON ReadDatePrivacySettings
{ show_read_date :: ReadDatePrivacySettings -> Maybe Bool
show_read_date = Maybe Bool
show_read_date_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"readDatePrivacySettings"
, Key
"show_read_date" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
show_read_date_
]
defaultReadDatePrivacySettings :: ReadDatePrivacySettings
defaultReadDatePrivacySettings :: ReadDatePrivacySettings
defaultReadDatePrivacySettings =
ReadDatePrivacySettings
{ show_read_date :: Maybe Bool
show_read_date = Maybe Bool
forall a. Maybe a
Nothing
}