module TD.Data.InputBusinessStartPage
( InputBusinessStartPage(..)
, defaultInputBusinessStartPage
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
import qualified TD.Data.InputFile as InputFile
data InputBusinessStartPage
= InputBusinessStartPage
{ InputBusinessStartPage -> Maybe Text
title :: Maybe T.Text
, InputBusinessStartPage -> Maybe Text
message :: Maybe T.Text
, InputBusinessStartPage -> Maybe InputFile
sticker :: Maybe InputFile.InputFile
}
deriving (InputBusinessStartPage -> InputBusinessStartPage -> Bool
(InputBusinessStartPage -> InputBusinessStartPage -> Bool)
-> (InputBusinessStartPage -> InputBusinessStartPage -> Bool)
-> Eq InputBusinessStartPage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InputBusinessStartPage -> InputBusinessStartPage -> Bool
== :: InputBusinessStartPage -> InputBusinessStartPage -> Bool
$c/= :: InputBusinessStartPage -> InputBusinessStartPage -> Bool
/= :: InputBusinessStartPage -> InputBusinessStartPage -> Bool
Eq, Int -> InputBusinessStartPage -> ShowS
[InputBusinessStartPage] -> ShowS
InputBusinessStartPage -> String
(Int -> InputBusinessStartPage -> ShowS)
-> (InputBusinessStartPage -> String)
-> ([InputBusinessStartPage] -> ShowS)
-> Show InputBusinessStartPage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InputBusinessStartPage -> ShowS
showsPrec :: Int -> InputBusinessStartPage -> ShowS
$cshow :: InputBusinessStartPage -> String
show :: InputBusinessStartPage -> String
$cshowList :: [InputBusinessStartPage] -> ShowS
showList :: [InputBusinessStartPage] -> ShowS
Show)
instance I.ShortShow InputBusinessStartPage where
shortShow :: InputBusinessStartPage -> String
shortShow InputBusinessStartPage
{ title :: InputBusinessStartPage -> Maybe Text
title = Maybe Text
title_
, message :: InputBusinessStartPage -> Maybe Text
message = Maybe Text
message_
, sticker :: InputBusinessStartPage -> Maybe InputFile
sticker = Maybe InputFile
sticker_
}
= String
"InputBusinessStartPage"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"title" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
title_
, String
"message" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
message_
, String
"sticker" String -> Maybe InputFile -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputFile
sticker_
]
instance AT.FromJSON InputBusinessStartPage where
parseJSON :: Value -> Parser InputBusinessStartPage
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
"inputBusinessStartPage" -> Value -> Parser InputBusinessStartPage
parseInputBusinessStartPage Value
v
String
_ -> Parser InputBusinessStartPage
forall a. Monoid a => a
mempty
where
parseInputBusinessStartPage :: A.Value -> AT.Parser InputBusinessStartPage
parseInputBusinessStartPage :: Value -> Parser InputBusinessStartPage
parseInputBusinessStartPage = String
-> (Object -> Parser InputBusinessStartPage)
-> Value
-> Parser InputBusinessStartPage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"InputBusinessStartPage" ((Object -> Parser InputBusinessStartPage)
-> Value -> Parser InputBusinessStartPage)
-> (Object -> Parser InputBusinessStartPage)
-> Value
-> Parser InputBusinessStartPage
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
title_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"title"
Maybe Text
message_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"message"
Maybe InputFile
sticker_ <- Object
o Object -> Key -> Parser (Maybe InputFile)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sticker"
InputBusinessStartPage -> Parser InputBusinessStartPage
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InputBusinessStartPage -> Parser InputBusinessStartPage)
-> InputBusinessStartPage -> Parser InputBusinessStartPage
forall a b. (a -> b) -> a -> b
$ InputBusinessStartPage
{ title :: Maybe Text
title = Maybe Text
title_
, message :: Maybe Text
message = Maybe Text
message_
, sticker :: Maybe InputFile
sticker = Maybe InputFile
sticker_
}
parseJSON Value
_ = Parser InputBusinessStartPage
forall a. Monoid a => a
mempty
instance AT.ToJSON InputBusinessStartPage where
toJSON :: InputBusinessStartPage -> Value
toJSON InputBusinessStartPage
{ title :: InputBusinessStartPage -> Maybe Text
title = Maybe Text
title_
, message :: InputBusinessStartPage -> Maybe Text
message = Maybe Text
message_
, sticker :: InputBusinessStartPage -> Maybe InputFile
sticker = Maybe InputFile
sticker_
}
= [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
"inputBusinessStartPage"
, Key
"title" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
title_
, Key
"message" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
message_
, Key
"sticker" Key -> Maybe InputFile -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputFile
sticker_
]
defaultInputBusinessStartPage :: InputBusinessStartPage
defaultInputBusinessStartPage :: InputBusinessStartPage
defaultInputBusinessStartPage =
InputBusinessStartPage
{ title :: Maybe Text
title = Maybe Text
forall a. Maybe a
Nothing
, message :: Maybe Text
message = Maybe Text
forall a. Maybe a
Nothing
, sticker :: Maybe InputFile
sticker = Maybe InputFile
forall a. Maybe a
Nothing
}