module TD.Data.MessageCopyOptions
( MessageCopyOptions(..)
, defaultMessageCopyOptions
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.FormattedText as FormattedText
data MessageCopyOptions
= MessageCopyOptions
{ MessageCopyOptions -> Maybe Bool
send_copy :: Maybe Bool
, MessageCopyOptions -> Maybe Bool
replace_caption :: Maybe Bool
, MessageCopyOptions -> Maybe FormattedText
new_caption :: Maybe FormattedText.FormattedText
, MessageCopyOptions -> Maybe Bool
new_show_caption_above_media :: Maybe Bool
}
deriving (MessageCopyOptions -> MessageCopyOptions -> Bool
(MessageCopyOptions -> MessageCopyOptions -> Bool)
-> (MessageCopyOptions -> MessageCopyOptions -> Bool)
-> Eq MessageCopyOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MessageCopyOptions -> MessageCopyOptions -> Bool
== :: MessageCopyOptions -> MessageCopyOptions -> Bool
$c/= :: MessageCopyOptions -> MessageCopyOptions -> Bool
/= :: MessageCopyOptions -> MessageCopyOptions -> Bool
Eq, Int -> MessageCopyOptions -> ShowS
[MessageCopyOptions] -> ShowS
MessageCopyOptions -> String
(Int -> MessageCopyOptions -> ShowS)
-> (MessageCopyOptions -> String)
-> ([MessageCopyOptions] -> ShowS)
-> Show MessageCopyOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MessageCopyOptions -> ShowS
showsPrec :: Int -> MessageCopyOptions -> ShowS
$cshow :: MessageCopyOptions -> String
show :: MessageCopyOptions -> String
$cshowList :: [MessageCopyOptions] -> ShowS
showList :: [MessageCopyOptions] -> ShowS
Show)
instance I.ShortShow MessageCopyOptions where
shortShow :: MessageCopyOptions -> String
shortShow MessageCopyOptions
{ send_copy :: MessageCopyOptions -> Maybe Bool
send_copy = Maybe Bool
send_copy_
, replace_caption :: MessageCopyOptions -> Maybe Bool
replace_caption = Maybe Bool
replace_caption_
, new_caption :: MessageCopyOptions -> Maybe FormattedText
new_caption = Maybe FormattedText
new_caption_
, new_show_caption_above_media :: MessageCopyOptions -> Maybe Bool
new_show_caption_above_media = Maybe Bool
new_show_caption_above_media_
}
= String
"MessageCopyOptions"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"send_copy" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
send_copy_
, String
"replace_caption" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
replace_caption_
, String
"new_caption" String -> Maybe FormattedText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FormattedText
new_caption_
, String
"new_show_caption_above_media" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
new_show_caption_above_media_
]
instance AT.FromJSON MessageCopyOptions where
parseJSON :: Value -> Parser MessageCopyOptions
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
"messageCopyOptions" -> Value -> Parser MessageCopyOptions
parseMessageCopyOptions Value
v
String
_ -> Parser MessageCopyOptions
forall a. Monoid a => a
mempty
where
parseMessageCopyOptions :: A.Value -> AT.Parser MessageCopyOptions
parseMessageCopyOptions :: Value -> Parser MessageCopyOptions
parseMessageCopyOptions = String
-> (Object -> Parser MessageCopyOptions)
-> Value
-> Parser MessageCopyOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"MessageCopyOptions" ((Object -> Parser MessageCopyOptions)
-> Value -> Parser MessageCopyOptions)
-> (Object -> Parser MessageCopyOptions)
-> Value
-> Parser MessageCopyOptions
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Bool
send_copy_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"send_copy"
Maybe Bool
replace_caption_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"replace_caption"
Maybe FormattedText
new_caption_ <- Object
o Object -> Key -> Parser (Maybe FormattedText)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"new_caption"
Maybe Bool
new_show_caption_above_media_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"new_show_caption_above_media"
MessageCopyOptions -> Parser MessageCopyOptions
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (MessageCopyOptions -> Parser MessageCopyOptions)
-> MessageCopyOptions -> Parser MessageCopyOptions
forall a b. (a -> b) -> a -> b
$ MessageCopyOptions
{ send_copy :: Maybe Bool
send_copy = Maybe Bool
send_copy_
, replace_caption :: Maybe Bool
replace_caption = Maybe Bool
replace_caption_
, new_caption :: Maybe FormattedText
new_caption = Maybe FormattedText
new_caption_
, new_show_caption_above_media :: Maybe Bool
new_show_caption_above_media = Maybe Bool
new_show_caption_above_media_
}
parseJSON Value
_ = Parser MessageCopyOptions
forall a. Monoid a => a
mempty
instance AT.ToJSON MessageCopyOptions where
toJSON :: MessageCopyOptions -> Value
toJSON MessageCopyOptions
{ send_copy :: MessageCopyOptions -> Maybe Bool
send_copy = Maybe Bool
send_copy_
, replace_caption :: MessageCopyOptions -> Maybe Bool
replace_caption = Maybe Bool
replace_caption_
, new_caption :: MessageCopyOptions -> Maybe FormattedText
new_caption = Maybe FormattedText
new_caption_
, new_show_caption_above_media :: MessageCopyOptions -> Maybe Bool
new_show_caption_above_media = Maybe Bool
new_show_caption_above_media_
}
= [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
"messageCopyOptions"
, Key
"send_copy" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
send_copy_
, Key
"replace_caption" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
replace_caption_
, Key
"new_caption" Key -> Maybe FormattedText -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe FormattedText
new_caption_
, Key
"new_show_caption_above_media" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
new_show_caption_above_media_
]
defaultMessageCopyOptions :: MessageCopyOptions
defaultMessageCopyOptions :: MessageCopyOptions
defaultMessageCopyOptions =
MessageCopyOptions
{ send_copy :: Maybe Bool
send_copy = Maybe Bool
forall a. Maybe a
Nothing
, replace_caption :: Maybe Bool
replace_caption = Maybe Bool
forall a. Maybe a
Nothing
, new_caption :: Maybe FormattedText
new_caption = Maybe FormattedText
forall a. Maybe a
Nothing
, new_show_caption_above_media :: Maybe Bool
new_show_caption_above_media = Maybe Bool
forall a. Maybe a
Nothing
}