module TD.Data.ChatInviteLinkInfo
  (ChatInviteLinkInfo(..)) 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.InviteLinkChatType as InviteLinkChatType
import qualified Data.Text as T
import qualified TD.Data.ChatPhotoInfo as ChatPhotoInfo
import qualified TD.Data.ChatInviteLinkSubscriptionInfo as ChatInviteLinkSubscriptionInfo

data ChatInviteLinkInfo
  = ChatInviteLinkInfo -- ^ Contains information about a chat invite link
    { ChatInviteLinkInfo -> Maybe Int
chat_id              :: Maybe Int                                                           -- ^ Chat identifier of the invite link; 0 if the user has no access to the chat before joining
    , ChatInviteLinkInfo -> Maybe Int
accessible_for       :: Maybe Int                                                           -- ^ If non-zero, the amount of time for which read access to the chat will remain available, in seconds
    , ChatInviteLinkInfo -> Maybe InviteLinkChatType
_type                :: Maybe InviteLinkChatType.InviteLinkChatType                         -- ^ Type of the chat
    , ChatInviteLinkInfo -> Maybe Text
title                :: Maybe T.Text                                                        -- ^ Title of the chat
    , ChatInviteLinkInfo -> Maybe ChatPhotoInfo
photo                :: Maybe ChatPhotoInfo.ChatPhotoInfo                                   -- ^ Chat photo; may be null
    , ChatInviteLinkInfo -> Maybe Int
accent_color_id      :: Maybe Int                                                           -- ^ Identifier of the accent color for chat title and background of chat photo
    , ChatInviteLinkInfo -> Maybe Text
description          :: Maybe T.Text                                                        -- ^ Chat description
    , ChatInviteLinkInfo -> Maybe Int
member_count         :: Maybe Int                                                           -- ^ Number of members in the chat
    , ChatInviteLinkInfo -> Maybe [Int]
member_user_ids      :: Maybe [Int]                                                         -- ^ User identifiers of some chat members that may be known to the current user
    , ChatInviteLinkInfo -> Maybe ChatInviteLinkSubscriptionInfo
subscription_info    :: Maybe ChatInviteLinkSubscriptionInfo.ChatInviteLinkSubscriptionInfo -- ^ Information about subscription plan that must be paid by the user to use the link; may be null if the link doesn't require subscription
    , ChatInviteLinkInfo -> Maybe Bool
creates_join_request :: Maybe Bool                                                          -- ^ True, if the link only creates join request
    , ChatInviteLinkInfo -> Maybe Bool
is_public            :: Maybe Bool                                                          -- ^ True, if the chat is a public supergroup or channel, i.e. it has a username or it is a location-based supergroup
    , ChatInviteLinkInfo -> Maybe Bool
is_verified          :: Maybe Bool                                                          -- ^ True, if the chat is verified
    , ChatInviteLinkInfo -> Maybe Bool
is_scam              :: Maybe Bool                                                          -- ^ True, if many users reported this chat as a scam
    , ChatInviteLinkInfo -> Maybe Bool
is_fake              :: Maybe Bool                                                          -- ^ True, if many users reported this chat as a fake account
    }
  deriving (ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
(ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool)
-> (ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool)
-> Eq ChatInviteLinkInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
== :: ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
$c/= :: ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
/= :: ChatInviteLinkInfo -> ChatInviteLinkInfo -> Bool
Eq, Int -> ChatInviteLinkInfo -> ShowS
[ChatInviteLinkInfo] -> ShowS
ChatInviteLinkInfo -> String
(Int -> ChatInviteLinkInfo -> ShowS)
-> (ChatInviteLinkInfo -> String)
-> ([ChatInviteLinkInfo] -> ShowS)
-> Show ChatInviteLinkInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatInviteLinkInfo -> ShowS
showsPrec :: Int -> ChatInviteLinkInfo -> ShowS
$cshow :: ChatInviteLinkInfo -> String
show :: ChatInviteLinkInfo -> String
$cshowList :: [ChatInviteLinkInfo] -> ShowS
showList :: [ChatInviteLinkInfo] -> ShowS
Show)

instance I.ShortShow ChatInviteLinkInfo where
  shortShow :: ChatInviteLinkInfo -> String
shortShow ChatInviteLinkInfo
    { chat_id :: ChatInviteLinkInfo -> Maybe Int
chat_id              = Maybe Int
chat_id_
    , accessible_for :: ChatInviteLinkInfo -> Maybe Int
accessible_for       = Maybe Int
accessible_for_
    , _type :: ChatInviteLinkInfo -> Maybe InviteLinkChatType
_type                = Maybe InviteLinkChatType
_type_
    , title :: ChatInviteLinkInfo -> Maybe Text
title                = Maybe Text
title_
    , photo :: ChatInviteLinkInfo -> Maybe ChatPhotoInfo
photo                = Maybe ChatPhotoInfo
photo_
    , accent_color_id :: ChatInviteLinkInfo -> Maybe Int
accent_color_id      = Maybe Int
accent_color_id_
    , description :: ChatInviteLinkInfo -> Maybe Text
description          = Maybe Text
description_
    , member_count :: ChatInviteLinkInfo -> Maybe Int
member_count         = Maybe Int
member_count_
    , member_user_ids :: ChatInviteLinkInfo -> Maybe [Int]
member_user_ids      = Maybe [Int]
member_user_ids_
    , subscription_info :: ChatInviteLinkInfo -> Maybe ChatInviteLinkSubscriptionInfo
subscription_info    = Maybe ChatInviteLinkSubscriptionInfo
subscription_info_
    , creates_join_request :: ChatInviteLinkInfo -> Maybe Bool
creates_join_request = Maybe Bool
creates_join_request_
    , is_public :: ChatInviteLinkInfo -> Maybe Bool
is_public            = Maybe Bool
is_public_
    , is_verified :: ChatInviteLinkInfo -> Maybe Bool
is_verified          = Maybe Bool
is_verified_
    , is_scam :: ChatInviteLinkInfo -> Maybe Bool
is_scam              = Maybe Bool
is_scam_
    , is_fake :: ChatInviteLinkInfo -> Maybe Bool
is_fake              = Maybe Bool
is_fake_
    }
      = String
"ChatInviteLinkInfo"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"chat_id"              String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
        , String
"accessible_for"       String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
accessible_for_
        , String
"_type"                String -> Maybe InviteLinkChatType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InviteLinkChatType
_type_
        , String
"title"                String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
title_
        , String
"photo"                String -> Maybe ChatPhotoInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatPhotoInfo
photo_
        , String
"accent_color_id"      String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
accent_color_id_
        , String
"description"          String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
description_
        , String
"member_count"         String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
member_count_
        , String
"member_user_ids"      String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
member_user_ids_
        , String
"subscription_info"    String -> Maybe ChatInviteLinkSubscriptionInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatInviteLinkSubscriptionInfo
subscription_info_
        , String
"creates_join_request" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
creates_join_request_
        , String
"is_public"            String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_public_
        , String
"is_verified"          String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_verified_
        , String
"is_scam"              String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_scam_
        , String
"is_fake"              String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_fake_
        ]

instance AT.FromJSON ChatInviteLinkInfo where
  parseJSON :: Value -> Parser ChatInviteLinkInfo
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
"chatInviteLinkInfo" -> Value -> Parser ChatInviteLinkInfo
parseChatInviteLinkInfo Value
v
      String
_                    -> Parser ChatInviteLinkInfo
forall a. Monoid a => a
mempty
    
    where
      parseChatInviteLinkInfo :: A.Value -> AT.Parser ChatInviteLinkInfo
      parseChatInviteLinkInfo :: Value -> Parser ChatInviteLinkInfo
parseChatInviteLinkInfo = String
-> (Object -> Parser ChatInviteLinkInfo)
-> Value
-> Parser ChatInviteLinkInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatInviteLinkInfo" ((Object -> Parser ChatInviteLinkInfo)
 -> Value -> Parser ChatInviteLinkInfo)
-> (Object -> Parser ChatInviteLinkInfo)
-> Value
-> Parser ChatInviteLinkInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
chat_id_              <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"chat_id"
        Maybe Int
accessible_for_       <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"accessible_for"
        Maybe InviteLinkChatType
_type_                <- Object
o Object -> Key -> Parser (Maybe InviteLinkChatType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"type"
        Maybe Text
title_                <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"title"
        Maybe ChatPhotoInfo
photo_                <- Object
o Object -> Key -> Parser (Maybe ChatPhotoInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"photo"
        Maybe Int
accent_color_id_      <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"accent_color_id"
        Maybe Text
description_          <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"description"
        Maybe Int
member_count_         <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"member_count"
        Maybe [Int]
member_user_ids_      <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"member_user_ids"
        Maybe ChatInviteLinkSubscriptionInfo
subscription_info_    <- Object
o Object -> Key -> Parser (Maybe ChatInviteLinkSubscriptionInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"subscription_info"
        Maybe Bool
creates_join_request_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"creates_join_request"
        Maybe Bool
is_public_            <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_public"
        Maybe Bool
is_verified_          <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_verified"
        Maybe Bool
is_scam_              <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_scam"
        Maybe Bool
is_fake_              <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_fake"
        ChatInviteLinkInfo -> Parser ChatInviteLinkInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatInviteLinkInfo -> Parser ChatInviteLinkInfo)
-> ChatInviteLinkInfo -> Parser ChatInviteLinkInfo
forall a b. (a -> b) -> a -> b
$ ChatInviteLinkInfo
          { chat_id :: Maybe Int
chat_id              = Maybe Int
chat_id_
          , accessible_for :: Maybe Int
accessible_for       = Maybe Int
accessible_for_
          , _type :: Maybe InviteLinkChatType
_type                = Maybe InviteLinkChatType
_type_
          , title :: Maybe Text
title                = Maybe Text
title_
          , photo :: Maybe ChatPhotoInfo
photo                = Maybe ChatPhotoInfo
photo_
          , accent_color_id :: Maybe Int
accent_color_id      = Maybe Int
accent_color_id_
          , description :: Maybe Text
description          = Maybe Text
description_
          , member_count :: Maybe Int
member_count         = Maybe Int
member_count_
          , member_user_ids :: Maybe [Int]
member_user_ids      = Maybe [Int]
member_user_ids_
          , subscription_info :: Maybe ChatInviteLinkSubscriptionInfo
subscription_info    = Maybe ChatInviteLinkSubscriptionInfo
subscription_info_
          , creates_join_request :: Maybe Bool
creates_join_request = Maybe Bool
creates_join_request_
          , is_public :: Maybe Bool
is_public            = Maybe Bool
is_public_
          , is_verified :: Maybe Bool
is_verified          = Maybe Bool
is_verified_
          , is_scam :: Maybe Bool
is_scam              = Maybe Bool
is_scam_
          , is_fake :: Maybe Bool
is_fake              = Maybe Bool
is_fake_
          }
  parseJSON Value
_ = Parser ChatInviteLinkInfo
forall a. Monoid a => a
mempty