module TD.Data.BotWriteAccessAllowReason
(BotWriteAccessAllowReason(..)) 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.WebApp as WebApp
data BotWriteAccessAllowReason
= BotWriteAccessAllowReasonConnectedWebsite
{ BotWriteAccessAllowReason -> Maybe Text
domain_name :: Maybe T.Text
}
|
| BotWriteAccessAllowReasonLaunchedWebApp
{ BotWriteAccessAllowReason -> Maybe WebApp
web_app :: Maybe WebApp.WebApp
}
| BotWriteAccessAllowReasonAcceptedRequest
deriving (BotWriteAccessAllowReason -> BotWriteAccessAllowReason -> Bool
(BotWriteAccessAllowReason -> BotWriteAccessAllowReason -> Bool)
-> (BotWriteAccessAllowReason -> BotWriteAccessAllowReason -> Bool)
-> Eq BotWriteAccessAllowReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BotWriteAccessAllowReason -> BotWriteAccessAllowReason -> Bool
== :: BotWriteAccessAllowReason -> BotWriteAccessAllowReason -> Bool
$c/= :: BotWriteAccessAllowReason -> BotWriteAccessAllowReason -> Bool
/= :: BotWriteAccessAllowReason -> BotWriteAccessAllowReason -> Bool
Eq, Int -> BotWriteAccessAllowReason -> ShowS
[BotWriteAccessAllowReason] -> ShowS
BotWriteAccessAllowReason -> String
(Int -> BotWriteAccessAllowReason -> ShowS)
-> (BotWriteAccessAllowReason -> String)
-> ([BotWriteAccessAllowReason] -> ShowS)
-> Show BotWriteAccessAllowReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BotWriteAccessAllowReason -> ShowS
showsPrec :: Int -> BotWriteAccessAllowReason -> ShowS
$cshow :: BotWriteAccessAllowReason -> String
show :: BotWriteAccessAllowReason -> String
$cshowList :: [BotWriteAccessAllowReason] -> ShowS
showList :: [BotWriteAccessAllowReason] -> ShowS
Show)
instance I.ShortShow BotWriteAccessAllowReason where
shortShow :: BotWriteAccessAllowReason -> String
shortShow BotWriteAccessAllowReasonConnectedWebsite
{ domain_name :: BotWriteAccessAllowReason -> Maybe Text
domain_name = Maybe Text
domain_name_
}
= String
"BotWriteAccessAllowReasonConnectedWebsite"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"domain_name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
domain_name_
]
shortShow BotWriteAccessAllowReason
BotWriteAccessAllowReasonAddedToAttachmentMenu
= String
"BotWriteAccessAllowReasonAddedToAttachmentMenu"
shortShow BotWriteAccessAllowReasonLaunchedWebApp
{ web_app :: BotWriteAccessAllowReason -> Maybe WebApp
web_app = Maybe WebApp
web_app_
}
= String
"BotWriteAccessAllowReasonLaunchedWebApp"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"web_app" String -> Maybe WebApp -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe WebApp
web_app_
]
shortShow BotWriteAccessAllowReason
BotWriteAccessAllowReasonAcceptedRequest
= String
"BotWriteAccessAllowReasonAcceptedRequest"
instance AT.FromJSON BotWriteAccessAllowReason where
parseJSON :: Value -> Parser BotWriteAccessAllowReason
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
"botWriteAccessAllowReasonConnectedWebsite" -> Value -> Parser BotWriteAccessAllowReason
parseBotWriteAccessAllowReasonConnectedWebsite Value
v
String
"botWriteAccessAllowReasonAddedToAttachmentMenu" -> BotWriteAccessAllowReason -> Parser BotWriteAccessAllowReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BotWriteAccessAllowReason
BotWriteAccessAllowReasonAddedToAttachmentMenu
String
"botWriteAccessAllowReasonLaunchedWebApp" -> Value -> Parser BotWriteAccessAllowReason
parseBotWriteAccessAllowReasonLaunchedWebApp Value
v
String
"botWriteAccessAllowReasonAcceptedRequest" -> BotWriteAccessAllowReason -> Parser BotWriteAccessAllowReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BotWriteAccessAllowReason
BotWriteAccessAllowReasonAcceptedRequest
String
_ -> Parser BotWriteAccessAllowReason
forall a. Monoid a => a
mempty
where
parseBotWriteAccessAllowReasonConnectedWebsite :: A.Value -> AT.Parser BotWriteAccessAllowReason
parseBotWriteAccessAllowReasonConnectedWebsite :: Value -> Parser BotWriteAccessAllowReason
parseBotWriteAccessAllowReasonConnectedWebsite = String
-> (Object -> Parser BotWriteAccessAllowReason)
-> Value
-> Parser BotWriteAccessAllowReason
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotWriteAccessAllowReasonConnectedWebsite" ((Object -> Parser BotWriteAccessAllowReason)
-> Value -> Parser BotWriteAccessAllowReason)
-> (Object -> Parser BotWriteAccessAllowReason)
-> Value
-> Parser BotWriteAccessAllowReason
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
domain_name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"domain_name"
BotWriteAccessAllowReason -> Parser BotWriteAccessAllowReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotWriteAccessAllowReason -> Parser BotWriteAccessAllowReason)
-> BotWriteAccessAllowReason -> Parser BotWriteAccessAllowReason
forall a b. (a -> b) -> a -> b
$ BotWriteAccessAllowReasonConnectedWebsite
{ domain_name :: Maybe Text
domain_name = Maybe Text
domain_name_
}
parseBotWriteAccessAllowReasonLaunchedWebApp :: A.Value -> AT.Parser BotWriteAccessAllowReason
parseBotWriteAccessAllowReasonLaunchedWebApp :: Value -> Parser BotWriteAccessAllowReason
parseBotWriteAccessAllowReasonLaunchedWebApp = String
-> (Object -> Parser BotWriteAccessAllowReason)
-> Value
-> Parser BotWriteAccessAllowReason
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotWriteAccessAllowReasonLaunchedWebApp" ((Object -> Parser BotWriteAccessAllowReason)
-> Value -> Parser BotWriteAccessAllowReason)
-> (Object -> Parser BotWriteAccessAllowReason)
-> Value
-> Parser BotWriteAccessAllowReason
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe WebApp
web_app_ <- Object
o Object -> Key -> Parser (Maybe WebApp)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"web_app"
BotWriteAccessAllowReason -> Parser BotWriteAccessAllowReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotWriteAccessAllowReason -> Parser BotWriteAccessAllowReason)
-> BotWriteAccessAllowReason -> Parser BotWriteAccessAllowReason
forall a b. (a -> b) -> a -> b
$ BotWriteAccessAllowReasonLaunchedWebApp
{ web_app :: Maybe WebApp
web_app = Maybe WebApp
web_app_
}
parseJSON Value
_ = Parser BotWriteAccessAllowReason
forall a. Monoid a => a
mempty