{-# LANGUAGE DeriveGeneric #-}
module Telegram.Bot.API.Types.WriteAccessAllowed where

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Text
import GHC.Generics (Generic)

import Telegram.Bot.API.Internal.Utils

-- ** 'WriteAccessAllowed'

-- | This object represents a service message about a user allowing a bot added to the attachment menu to write messages. Currently holds no information.
data WriteAccessAllowed = WriteAccessAllowed
  { WriteAccessAllowed -> Maybe Bool
writeAccessAllowedFromRequest :: Maybe Bool -- ^ True, if the access was granted after the user accepted an explicit request from a Web App sent by the method 'requestWriteAccess'.
  , WriteAccessAllowed -> Maybe Text
writeAccessAllowedWebAppName :: Maybe Text -- ^ Name of the Web App which was launched from a link.
  , WriteAccessAllowed -> Maybe Bool
writeAccessAllowedFromAttachmentMenu :: Maybe Bool -- ^ 'True', if the access was granted when the bot was added to the attachment or side menu.
  }
  deriving ((forall x. WriteAccessAllowed -> Rep WriteAccessAllowed x)
-> (forall x. Rep WriteAccessAllowed x -> WriteAccessAllowed)
-> Generic WriteAccessAllowed
forall x. Rep WriteAccessAllowed x -> WriteAccessAllowed
forall x. WriteAccessAllowed -> Rep WriteAccessAllowed x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. WriteAccessAllowed -> Rep WriteAccessAllowed x
from :: forall x. WriteAccessAllowed -> Rep WriteAccessAllowed x
$cto :: forall x. Rep WriteAccessAllowed x -> WriteAccessAllowed
to :: forall x. Rep WriteAccessAllowed x -> WriteAccessAllowed
Generic, Int -> WriteAccessAllowed -> ShowS
[WriteAccessAllowed] -> ShowS
WriteAccessAllowed -> String
(Int -> WriteAccessAllowed -> ShowS)
-> (WriteAccessAllowed -> String)
-> ([WriteAccessAllowed] -> ShowS)
-> Show WriteAccessAllowed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WriteAccessAllowed -> ShowS
showsPrec :: Int -> WriteAccessAllowed -> ShowS
$cshow :: WriteAccessAllowed -> String
show :: WriteAccessAllowed -> String
$cshowList :: [WriteAccessAllowed] -> ShowS
showList :: [WriteAccessAllowed] -> ShowS
Show)

instance ToJSON   WriteAccessAllowed where toJSON :: WriteAccessAllowed -> Value
toJSON = WriteAccessAllowed -> Value
forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
instance FromJSON WriteAccessAllowed where parseJSON :: Value -> Parser WriteAccessAllowed
parseJSON = Value -> Parser WriteAccessAllowed
forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON