module TD.Data.ChatAdministratorRights
  ( ChatAdministratorRights(..)    
  , defaultChatAdministratorRights 
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

data ChatAdministratorRights
  = ChatAdministratorRights -- ^ Describes rights of the administrator
    { ChatAdministratorRights -> Maybe Bool
can_manage_chat        :: Maybe Bool -- ^ True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report supergroup spam messages and ignore slow mode. Implied by any other privilege; applicable to supergroups and channels only
    , ChatAdministratorRights -> Maybe Bool
can_change_info        :: Maybe Bool -- ^ True, if the administrator can change the chat title, photo, and other settings
    , ChatAdministratorRights -> Maybe Bool
can_post_messages      :: Maybe Bool -- ^ True, if the administrator can create channel posts or view channel statistics; applicable to channels only
    , ChatAdministratorRights -> Maybe Bool
can_edit_messages      :: Maybe Bool -- ^ True, if the administrator can edit messages of other users and pin messages; applicable to channels only
    , ChatAdministratorRights -> Maybe Bool
can_delete_messages    :: Maybe Bool -- ^ True, if the administrator can delete messages of other users
    , ChatAdministratorRights -> Maybe Bool
can_invite_users       :: Maybe Bool -- ^ True, if the administrator can invite new users to the chat
    , ChatAdministratorRights -> Maybe Bool
can_restrict_members   :: Maybe Bool -- ^ True, if the administrator can restrict, ban, or unban chat members or view supergroup statistics; always true for channels
    , ChatAdministratorRights -> Maybe Bool
can_pin_messages       :: Maybe Bool -- ^ True, if the administrator can pin messages; applicable to basic groups and supergroups only
    , ChatAdministratorRights -> Maybe Bool
can_manage_topics      :: Maybe Bool -- ^ True, if the administrator can create, rename, close, reopen, hide, and unhide forum topics; applicable to forum supergroups only
    , ChatAdministratorRights -> Maybe Bool
can_promote_members    :: Maybe Bool -- ^ True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that were directly or indirectly promoted by them
    , ChatAdministratorRights -> Maybe Bool
can_manage_video_chats :: Maybe Bool -- ^ True, if the administrator can manage video chats
    , ChatAdministratorRights -> Maybe Bool
can_post_stories       :: Maybe Bool -- ^ True, if the administrator can create new chat stories, or edit and delete posted stories; applicable to supergroups and channels only
    , ChatAdministratorRights -> Maybe Bool
can_edit_stories       :: Maybe Bool -- ^ True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access story archive; applicable to supergroups and channels only
    , ChatAdministratorRights -> Maybe Bool
can_delete_stories     :: Maybe Bool -- ^ True, if the administrator can delete stories posted by other users; applicable to supergroups and channels only
    , ChatAdministratorRights -> Maybe Bool
is_anonymous           :: Maybe Bool -- ^ True, if the administrator isn't shown in the chat member list and sends messages anonymously; applicable to supergroups only
    }
  deriving (ChatAdministratorRights -> ChatAdministratorRights -> Bool
(ChatAdministratorRights -> ChatAdministratorRights -> Bool)
-> (ChatAdministratorRights -> ChatAdministratorRights -> Bool)
-> Eq ChatAdministratorRights
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatAdministratorRights -> ChatAdministratorRights -> Bool
== :: ChatAdministratorRights -> ChatAdministratorRights -> Bool
$c/= :: ChatAdministratorRights -> ChatAdministratorRights -> Bool
/= :: ChatAdministratorRights -> ChatAdministratorRights -> Bool
Eq, Int -> ChatAdministratorRights -> ShowS
[ChatAdministratorRights] -> ShowS
ChatAdministratorRights -> String
(Int -> ChatAdministratorRights -> ShowS)
-> (ChatAdministratorRights -> String)
-> ([ChatAdministratorRights] -> ShowS)
-> Show ChatAdministratorRights
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatAdministratorRights -> ShowS
showsPrec :: Int -> ChatAdministratorRights -> ShowS
$cshow :: ChatAdministratorRights -> String
show :: ChatAdministratorRights -> String
$cshowList :: [ChatAdministratorRights] -> ShowS
showList :: [ChatAdministratorRights] -> ShowS
Show)

instance I.ShortShow ChatAdministratorRights where
  shortShow :: ChatAdministratorRights -> String
shortShow ChatAdministratorRights
    { can_manage_chat :: ChatAdministratorRights -> Maybe Bool
can_manage_chat        = Maybe Bool
can_manage_chat_
    , can_change_info :: ChatAdministratorRights -> Maybe Bool
can_change_info        = Maybe Bool
can_change_info_
    , can_post_messages :: ChatAdministratorRights -> Maybe Bool
can_post_messages      = Maybe Bool
can_post_messages_
    , can_edit_messages :: ChatAdministratorRights -> Maybe Bool
can_edit_messages      = Maybe Bool
can_edit_messages_
    , can_delete_messages :: ChatAdministratorRights -> Maybe Bool
can_delete_messages    = Maybe Bool
can_delete_messages_
    , can_invite_users :: ChatAdministratorRights -> Maybe Bool
can_invite_users       = Maybe Bool
can_invite_users_
    , can_restrict_members :: ChatAdministratorRights -> Maybe Bool
can_restrict_members   = Maybe Bool
can_restrict_members_
    , can_pin_messages :: ChatAdministratorRights -> Maybe Bool
can_pin_messages       = Maybe Bool
can_pin_messages_
    , can_manage_topics :: ChatAdministratorRights -> Maybe Bool
can_manage_topics      = Maybe Bool
can_manage_topics_
    , can_promote_members :: ChatAdministratorRights -> Maybe Bool
can_promote_members    = Maybe Bool
can_promote_members_
    , can_manage_video_chats :: ChatAdministratorRights -> Maybe Bool
can_manage_video_chats = Maybe Bool
can_manage_video_chats_
    , can_post_stories :: ChatAdministratorRights -> Maybe Bool
can_post_stories       = Maybe Bool
can_post_stories_
    , can_edit_stories :: ChatAdministratorRights -> Maybe Bool
can_edit_stories       = Maybe Bool
can_edit_stories_
    , can_delete_stories :: ChatAdministratorRights -> Maybe Bool
can_delete_stories     = Maybe Bool
can_delete_stories_
    , is_anonymous :: ChatAdministratorRights -> Maybe Bool
is_anonymous           = Maybe Bool
is_anonymous_
    }
      = String
"ChatAdministratorRights"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"can_manage_chat"        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_manage_chat_
        , String
"can_change_info"        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_change_info_
        , String
"can_post_messages"      String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_post_messages_
        , String
"can_edit_messages"      String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_edit_messages_
        , String
"can_delete_messages"    String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_delete_messages_
        , String
"can_invite_users"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_invite_users_
        , String
"can_restrict_members"   String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_restrict_members_
        , String
"can_pin_messages"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_pin_messages_
        , String
"can_manage_topics"      String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_manage_topics_
        , String
"can_promote_members"    String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_promote_members_
        , String
"can_manage_video_chats" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_manage_video_chats_
        , String
"can_post_stories"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_post_stories_
        , String
"can_edit_stories"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_edit_stories_
        , String
"can_delete_stories"     String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_delete_stories_
        , String
"is_anonymous"           String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_anonymous_
        ]

instance AT.FromJSON ChatAdministratorRights where
  parseJSON :: Value -> Parser ChatAdministratorRights
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
"chatAdministratorRights" -> Value -> Parser ChatAdministratorRights
parseChatAdministratorRights Value
v
      String
_                         -> Parser ChatAdministratorRights
forall a. Monoid a => a
mempty
    
    where
      parseChatAdministratorRights :: A.Value -> AT.Parser ChatAdministratorRights
      parseChatAdministratorRights :: Value -> Parser ChatAdministratorRights
parseChatAdministratorRights = String
-> (Object -> Parser ChatAdministratorRights)
-> Value
-> Parser ChatAdministratorRights
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatAdministratorRights" ((Object -> Parser ChatAdministratorRights)
 -> Value -> Parser ChatAdministratorRights)
-> (Object -> Parser ChatAdministratorRights)
-> Value
-> Parser ChatAdministratorRights
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
can_manage_chat_        <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_manage_chat"
        Maybe Bool
can_change_info_        <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_change_info"
        Maybe Bool
can_post_messages_      <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_post_messages"
        Maybe Bool
can_edit_messages_      <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_edit_messages"
        Maybe Bool
can_delete_messages_    <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_delete_messages"
        Maybe Bool
can_invite_users_       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_invite_users"
        Maybe Bool
can_restrict_members_   <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_restrict_members"
        Maybe Bool
can_pin_messages_       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_pin_messages"
        Maybe Bool
can_manage_topics_      <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_manage_topics"
        Maybe Bool
can_promote_members_    <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_promote_members"
        Maybe Bool
can_manage_video_chats_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_manage_video_chats"
        Maybe Bool
can_post_stories_       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_post_stories"
        Maybe Bool
can_edit_stories_       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_edit_stories"
        Maybe Bool
can_delete_stories_     <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_delete_stories"
        Maybe Bool
is_anonymous_           <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_anonymous"
        ChatAdministratorRights -> Parser ChatAdministratorRights
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatAdministratorRights -> Parser ChatAdministratorRights)
-> ChatAdministratorRights -> Parser ChatAdministratorRights
forall a b. (a -> b) -> a -> b
$ ChatAdministratorRights
          { can_manage_chat :: Maybe Bool
can_manage_chat        = Maybe Bool
can_manage_chat_
          , can_change_info :: Maybe Bool
can_change_info        = Maybe Bool
can_change_info_
          , can_post_messages :: Maybe Bool
can_post_messages      = Maybe Bool
can_post_messages_
          , can_edit_messages :: Maybe Bool
can_edit_messages      = Maybe Bool
can_edit_messages_
          , can_delete_messages :: Maybe Bool
can_delete_messages    = Maybe Bool
can_delete_messages_
          , can_invite_users :: Maybe Bool
can_invite_users       = Maybe Bool
can_invite_users_
          , can_restrict_members :: Maybe Bool
can_restrict_members   = Maybe Bool
can_restrict_members_
          , can_pin_messages :: Maybe Bool
can_pin_messages       = Maybe Bool
can_pin_messages_
          , can_manage_topics :: Maybe Bool
can_manage_topics      = Maybe Bool
can_manage_topics_
          , can_promote_members :: Maybe Bool
can_promote_members    = Maybe Bool
can_promote_members_
          , can_manage_video_chats :: Maybe Bool
can_manage_video_chats = Maybe Bool
can_manage_video_chats_
          , can_post_stories :: Maybe Bool
can_post_stories       = Maybe Bool
can_post_stories_
          , can_edit_stories :: Maybe Bool
can_edit_stories       = Maybe Bool
can_edit_stories_
          , can_delete_stories :: Maybe Bool
can_delete_stories     = Maybe Bool
can_delete_stories_
          , is_anonymous :: Maybe Bool
is_anonymous           = Maybe Bool
is_anonymous_
          }
  parseJSON Value
_ = Parser ChatAdministratorRights
forall a. Monoid a => a
mempty

instance AT.ToJSON ChatAdministratorRights where
  toJSON :: ChatAdministratorRights -> Value
toJSON ChatAdministratorRights
    { can_manage_chat :: ChatAdministratorRights -> Maybe Bool
can_manage_chat        = Maybe Bool
can_manage_chat_
    , can_change_info :: ChatAdministratorRights -> Maybe Bool
can_change_info        = Maybe Bool
can_change_info_
    , can_post_messages :: ChatAdministratorRights -> Maybe Bool
can_post_messages      = Maybe Bool
can_post_messages_
    , can_edit_messages :: ChatAdministratorRights -> Maybe Bool
can_edit_messages      = Maybe Bool
can_edit_messages_
    , can_delete_messages :: ChatAdministratorRights -> Maybe Bool
can_delete_messages    = Maybe Bool
can_delete_messages_
    , can_invite_users :: ChatAdministratorRights -> Maybe Bool
can_invite_users       = Maybe Bool
can_invite_users_
    , can_restrict_members :: ChatAdministratorRights -> Maybe Bool
can_restrict_members   = Maybe Bool
can_restrict_members_
    , can_pin_messages :: ChatAdministratorRights -> Maybe Bool
can_pin_messages       = Maybe Bool
can_pin_messages_
    , can_manage_topics :: ChatAdministratorRights -> Maybe Bool
can_manage_topics      = Maybe Bool
can_manage_topics_
    , can_promote_members :: ChatAdministratorRights -> Maybe Bool
can_promote_members    = Maybe Bool
can_promote_members_
    , can_manage_video_chats :: ChatAdministratorRights -> Maybe Bool
can_manage_video_chats = Maybe Bool
can_manage_video_chats_
    , can_post_stories :: ChatAdministratorRights -> Maybe Bool
can_post_stories       = Maybe Bool
can_post_stories_
    , can_edit_stories :: ChatAdministratorRights -> Maybe Bool
can_edit_stories       = Maybe Bool
can_edit_stories_
    , can_delete_stories :: ChatAdministratorRights -> Maybe Bool
can_delete_stories     = Maybe Bool
can_delete_stories_
    , is_anonymous :: ChatAdministratorRights -> Maybe Bool
is_anonymous           = Maybe Bool
is_anonymous_
    }
      = [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
"chatAdministratorRights"
        , Key
"can_manage_chat"        Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_manage_chat_
        , Key
"can_change_info"        Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_change_info_
        , Key
"can_post_messages"      Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_post_messages_
        , Key
"can_edit_messages"      Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_edit_messages_
        , Key
"can_delete_messages"    Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_delete_messages_
        , Key
"can_invite_users"       Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_invite_users_
        , Key
"can_restrict_members"   Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_restrict_members_
        , Key
"can_pin_messages"       Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_pin_messages_
        , Key
"can_manage_topics"      Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_manage_topics_
        , Key
"can_promote_members"    Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_promote_members_
        , Key
"can_manage_video_chats" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_manage_video_chats_
        , Key
"can_post_stories"       Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_post_stories_
        , Key
"can_edit_stories"       Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_edit_stories_
        , Key
"can_delete_stories"     Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_delete_stories_
        , Key
"is_anonymous"           Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_anonymous_
        ]

defaultChatAdministratorRights :: ChatAdministratorRights
defaultChatAdministratorRights :: ChatAdministratorRights
defaultChatAdministratorRights =
  ChatAdministratorRights
    { can_manage_chat :: Maybe Bool
can_manage_chat        = Maybe Bool
forall a. Maybe a
Nothing
    , can_change_info :: Maybe Bool
can_change_info        = Maybe Bool
forall a. Maybe a
Nothing
    , can_post_messages :: Maybe Bool
can_post_messages      = Maybe Bool
forall a. Maybe a
Nothing
    , can_edit_messages :: Maybe Bool
can_edit_messages      = Maybe Bool
forall a. Maybe a
Nothing
    , can_delete_messages :: Maybe Bool
can_delete_messages    = Maybe Bool
forall a. Maybe a
Nothing
    , can_invite_users :: Maybe Bool
can_invite_users       = Maybe Bool
forall a. Maybe a
Nothing
    , can_restrict_members :: Maybe Bool
can_restrict_members   = Maybe Bool
forall a. Maybe a
Nothing
    , can_pin_messages :: Maybe Bool
can_pin_messages       = Maybe Bool
forall a. Maybe a
Nothing
    , can_manage_topics :: Maybe Bool
can_manage_topics      = Maybe Bool
forall a. Maybe a
Nothing
    , can_promote_members :: Maybe Bool
can_promote_members    = Maybe Bool
forall a. Maybe a
Nothing
    , can_manage_video_chats :: Maybe Bool
can_manage_video_chats = Maybe Bool
forall a. Maybe a
Nothing
    , can_post_stories :: Maybe Bool
can_post_stories       = Maybe Bool
forall a. Maybe a
Nothing
    , can_edit_stories :: Maybe Bool
can_edit_stories       = Maybe Bool
forall a. Maybe a
Nothing
    , can_delete_stories :: Maybe Bool
can_delete_stories     = Maybe Bool
forall a. Maybe a
Nothing
    , is_anonymous :: Maybe Bool
is_anonymous           = Maybe Bool
forall a. Maybe a
Nothing
    }