module TD.Data.InviteLinkChatType
  (InviteLinkChatType(..)) where

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

-- | Describes the type of chat to which points an invite link
data InviteLinkChatType
  = InviteLinkChatTypeBasicGroup -- ^ The link is an invite link for a basic group
  | InviteLinkChatTypeSupergroup -- ^ The link is an invite link for a supergroup
  | InviteLinkChatTypeChannel -- ^ The link is an invite link for a channel
  deriving (InviteLinkChatType -> InviteLinkChatType -> Bool
(InviteLinkChatType -> InviteLinkChatType -> Bool)
-> (InviteLinkChatType -> InviteLinkChatType -> Bool)
-> Eq InviteLinkChatType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InviteLinkChatType -> InviteLinkChatType -> Bool
== :: InviteLinkChatType -> InviteLinkChatType -> Bool
$c/= :: InviteLinkChatType -> InviteLinkChatType -> Bool
/= :: InviteLinkChatType -> InviteLinkChatType -> Bool
Eq, Int -> InviteLinkChatType -> ShowS
[InviteLinkChatType] -> ShowS
InviteLinkChatType -> String
(Int -> InviteLinkChatType -> ShowS)
-> (InviteLinkChatType -> String)
-> ([InviteLinkChatType] -> ShowS)
-> Show InviteLinkChatType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InviteLinkChatType -> ShowS
showsPrec :: Int -> InviteLinkChatType -> ShowS
$cshow :: InviteLinkChatType -> String
show :: InviteLinkChatType -> String
$cshowList :: [InviteLinkChatType] -> ShowS
showList :: [InviteLinkChatType] -> ShowS
Show)

instance I.ShortShow InviteLinkChatType where
  shortShow :: InviteLinkChatType -> String
shortShow InviteLinkChatType
InviteLinkChatTypeBasicGroup
      = String
"InviteLinkChatTypeBasicGroup"
  shortShow InviteLinkChatType
InviteLinkChatTypeSupergroup
      = String
"InviteLinkChatTypeSupergroup"
  shortShow InviteLinkChatType
InviteLinkChatTypeChannel
      = String
"InviteLinkChatTypeChannel"

instance AT.FromJSON InviteLinkChatType where
  parseJSON :: Value -> Parser InviteLinkChatType
parseJSON (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
"inviteLinkChatTypeBasicGroup" -> InviteLinkChatType -> Parser InviteLinkChatType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InviteLinkChatType
InviteLinkChatTypeBasicGroup
      String
"inviteLinkChatTypeSupergroup" -> InviteLinkChatType -> Parser InviteLinkChatType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InviteLinkChatType
InviteLinkChatTypeSupergroup
      String
"inviteLinkChatTypeChannel"    -> InviteLinkChatType -> Parser InviteLinkChatType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InviteLinkChatType
InviteLinkChatTypeChannel
      String
_                              -> Parser InviteLinkChatType
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser InviteLinkChatType
forall a. Monoid a => a
mempty