module TD.Data.ChatFolder
  ( ChatFolder(..)    
  , defaultChatFolder 
  ) 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.ChatFolderIcon as ChatFolderIcon

data ChatFolder
  = ChatFolder -- ^ Represents a folder for user chats
    { ChatFolder -> Maybe Text
title                :: Maybe T.Text                        -- ^ The title of the folder; 1-12 characters without line feeds
    , ChatFolder -> Maybe ChatFolderIcon
icon                 :: Maybe ChatFolderIcon.ChatFolderIcon -- ^ The chosen icon for the chat folder; may be null. If null, use getChatFolderDefaultIconName to get default icon name for the folder
    , ChatFolder -> Maybe Int
color_id             :: Maybe Int                           -- ^ The identifier of the chosen color for the chat folder icon; from -1 to 6. If -1, then color is disabled. Can't be changed if folder tags are disabled or the current user doesn't have Telegram Premium subscription
    , ChatFolder -> Maybe Bool
is_shareable         :: Maybe Bool                          -- ^ True, if at least one link has been created for the folder
    , ChatFolder -> Maybe [Int]
pinned_chat_ids      :: Maybe [Int]                         -- ^ The chat identifiers of pinned chats in the folder. There can be up to getOption("chat_folder_chosen_chat_count_max") pinned and always included non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
    , ChatFolder -> Maybe [Int]
included_chat_ids    :: Maybe [Int]                         -- ^ The chat identifiers of always included chats in the folder. There can be up to getOption("chat_folder_chosen_chat_count_max") pinned and always included non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
    , ChatFolder -> Maybe [Int]
excluded_chat_ids    :: Maybe [Int]                         -- ^ The chat identifiers of always excluded chats in the folder. There can be up to getOption("chat_folder_chosen_chat_count_max") always excluded non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
    , ChatFolder -> Maybe Bool
exclude_muted        :: Maybe Bool                          -- ^ True, if muted chats need to be excluded
    , ChatFolder -> Maybe Bool
exclude_read         :: Maybe Bool                          -- ^ True, if read chats need to be excluded
    , ChatFolder -> Maybe Bool
exclude_archived     :: Maybe Bool                          -- ^ True, if archived chats need to be excluded
    , ChatFolder -> Maybe Bool
include_contacts     :: Maybe Bool                          -- ^ True, if contacts need to be included
    , ChatFolder -> Maybe Bool
include_non_contacts :: Maybe Bool                          -- ^ True, if non-contact users need to be included
    , ChatFolder -> Maybe Bool
include_bots         :: Maybe Bool                          -- ^ True, if bots need to be included
    , ChatFolder -> Maybe Bool
include_groups       :: Maybe Bool                          -- ^ True, if basic groups and supergroups need to be included
    , ChatFolder -> Maybe Bool
include_channels     :: Maybe Bool                          -- ^ True, if channels need to be included
    }
  deriving (ChatFolder -> ChatFolder -> Bool
(ChatFolder -> ChatFolder -> Bool)
-> (ChatFolder -> ChatFolder -> Bool) -> Eq ChatFolder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatFolder -> ChatFolder -> Bool
== :: ChatFolder -> ChatFolder -> Bool
$c/= :: ChatFolder -> ChatFolder -> Bool
/= :: ChatFolder -> ChatFolder -> Bool
Eq, Int -> ChatFolder -> ShowS
[ChatFolder] -> ShowS
ChatFolder -> String
(Int -> ChatFolder -> ShowS)
-> (ChatFolder -> String)
-> ([ChatFolder] -> ShowS)
-> Show ChatFolder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatFolder -> ShowS
showsPrec :: Int -> ChatFolder -> ShowS
$cshow :: ChatFolder -> String
show :: ChatFolder -> String
$cshowList :: [ChatFolder] -> ShowS
showList :: [ChatFolder] -> ShowS
Show)

instance I.ShortShow ChatFolder where
  shortShow :: ChatFolder -> String
shortShow ChatFolder
    { title :: ChatFolder -> Maybe Text
title                = Maybe Text
title_
    , icon :: ChatFolder -> Maybe ChatFolderIcon
icon                 = Maybe ChatFolderIcon
icon_
    , color_id :: ChatFolder -> Maybe Int
color_id             = Maybe Int
color_id_
    , is_shareable :: ChatFolder -> Maybe Bool
is_shareable         = Maybe Bool
is_shareable_
    , pinned_chat_ids :: ChatFolder -> Maybe [Int]
pinned_chat_ids      = Maybe [Int]
pinned_chat_ids_
    , included_chat_ids :: ChatFolder -> Maybe [Int]
included_chat_ids    = Maybe [Int]
included_chat_ids_
    , excluded_chat_ids :: ChatFolder -> Maybe [Int]
excluded_chat_ids    = Maybe [Int]
excluded_chat_ids_
    , exclude_muted :: ChatFolder -> Maybe Bool
exclude_muted        = Maybe Bool
exclude_muted_
    , exclude_read :: ChatFolder -> Maybe Bool
exclude_read         = Maybe Bool
exclude_read_
    , exclude_archived :: ChatFolder -> Maybe Bool
exclude_archived     = Maybe Bool
exclude_archived_
    , include_contacts :: ChatFolder -> Maybe Bool
include_contacts     = Maybe Bool
include_contacts_
    , include_non_contacts :: ChatFolder -> Maybe Bool
include_non_contacts = Maybe Bool
include_non_contacts_
    , include_bots :: ChatFolder -> Maybe Bool
include_bots         = Maybe Bool
include_bots_
    , include_groups :: ChatFolder -> Maybe Bool
include_groups       = Maybe Bool
include_groups_
    , include_channels :: ChatFolder -> Maybe Bool
include_channels     = Maybe Bool
include_channels_
    }
      = String
"ChatFolder"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"title"                String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
title_
        , String
"icon"                 String -> Maybe ChatFolderIcon -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatFolderIcon
icon_
        , String
"color_id"             String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
color_id_
        , String
"is_shareable"         String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_shareable_
        , String
"pinned_chat_ids"      String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
pinned_chat_ids_
        , String
"included_chat_ids"    String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
included_chat_ids_
        , String
"excluded_chat_ids"    String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
excluded_chat_ids_
        , String
"exclude_muted"        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_muted_
        , String
"exclude_read"         String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_read_
        , String
"exclude_archived"     String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_archived_
        , String
"include_contacts"     String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_contacts_
        , String
"include_non_contacts" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_non_contacts_
        , String
"include_bots"         String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_bots_
        , String
"include_groups"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_groups_
        , String
"include_channels"     String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
include_channels_
        ]

instance AT.FromJSON ChatFolder where
  parseJSON :: Value -> Parser ChatFolder
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
"chatFolder" -> Value -> Parser ChatFolder
parseChatFolder Value
v
      String
_            -> Parser ChatFolder
forall a. Monoid a => a
mempty
    
    where
      parseChatFolder :: A.Value -> AT.Parser ChatFolder
      parseChatFolder :: Value -> Parser ChatFolder
parseChatFolder = String
-> (Object -> Parser ChatFolder) -> Value -> Parser ChatFolder
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatFolder" ((Object -> Parser ChatFolder) -> Value -> Parser ChatFolder)
-> (Object -> Parser ChatFolder) -> Value -> Parser ChatFolder
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Text
title_                <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"title"
        Maybe ChatFolderIcon
icon_                 <- Object
o Object -> Key -> Parser (Maybe ChatFolderIcon)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"icon"
        Maybe Int
color_id_             <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"color_id"
        Maybe Bool
is_shareable_         <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_shareable"
        Maybe [Int]
pinned_chat_ids_      <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"pinned_chat_ids"
        Maybe [Int]
included_chat_ids_    <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"included_chat_ids"
        Maybe [Int]
excluded_chat_ids_    <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"excluded_chat_ids"
        Maybe Bool
exclude_muted_        <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"exclude_muted"
        Maybe Bool
exclude_read_         <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"exclude_read"
        Maybe Bool
exclude_archived_     <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"exclude_archived"
        Maybe Bool
include_contacts_     <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"include_contacts"
        Maybe Bool
include_non_contacts_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"include_non_contacts"
        Maybe Bool
include_bots_         <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"include_bots"
        Maybe Bool
include_groups_       <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"include_groups"
        Maybe Bool
include_channels_     <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"include_channels"
        ChatFolder -> Parser ChatFolder
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatFolder -> Parser ChatFolder)
-> ChatFolder -> Parser ChatFolder
forall a b. (a -> b) -> a -> b
$ ChatFolder
          { title :: Maybe Text
title                = Maybe Text
title_
          , icon :: Maybe ChatFolderIcon
icon                 = Maybe ChatFolderIcon
icon_
          , color_id :: Maybe Int
color_id             = Maybe Int
color_id_
          , is_shareable :: Maybe Bool
is_shareable         = Maybe Bool
is_shareable_
          , pinned_chat_ids :: Maybe [Int]
pinned_chat_ids      = Maybe [Int]
pinned_chat_ids_
          , included_chat_ids :: Maybe [Int]
included_chat_ids    = Maybe [Int]
included_chat_ids_
          , excluded_chat_ids :: Maybe [Int]
excluded_chat_ids    = Maybe [Int]
excluded_chat_ids_
          , exclude_muted :: Maybe Bool
exclude_muted        = Maybe Bool
exclude_muted_
          , exclude_read :: Maybe Bool
exclude_read         = Maybe Bool
exclude_read_
          , exclude_archived :: Maybe Bool
exclude_archived     = Maybe Bool
exclude_archived_
          , include_contacts :: Maybe Bool
include_contacts     = Maybe Bool
include_contacts_
          , include_non_contacts :: Maybe Bool
include_non_contacts = Maybe Bool
include_non_contacts_
          , include_bots :: Maybe Bool
include_bots         = Maybe Bool
include_bots_
          , include_groups :: Maybe Bool
include_groups       = Maybe Bool
include_groups_
          , include_channels :: Maybe Bool
include_channels     = Maybe Bool
include_channels_
          }
  parseJSON Value
_ = Parser ChatFolder
forall a. Monoid a => a
mempty

instance AT.ToJSON ChatFolder where
  toJSON :: ChatFolder -> Value
toJSON ChatFolder
    { title :: ChatFolder -> Maybe Text
title                = Maybe Text
title_
    , icon :: ChatFolder -> Maybe ChatFolderIcon
icon                 = Maybe ChatFolderIcon
icon_
    , color_id :: ChatFolder -> Maybe Int
color_id             = Maybe Int
color_id_
    , is_shareable :: ChatFolder -> Maybe Bool
is_shareable         = Maybe Bool
is_shareable_
    , pinned_chat_ids :: ChatFolder -> Maybe [Int]
pinned_chat_ids      = Maybe [Int]
pinned_chat_ids_
    , included_chat_ids :: ChatFolder -> Maybe [Int]
included_chat_ids    = Maybe [Int]
included_chat_ids_
    , excluded_chat_ids :: ChatFolder -> Maybe [Int]
excluded_chat_ids    = Maybe [Int]
excluded_chat_ids_
    , exclude_muted :: ChatFolder -> Maybe Bool
exclude_muted        = Maybe Bool
exclude_muted_
    , exclude_read :: ChatFolder -> Maybe Bool
exclude_read         = Maybe Bool
exclude_read_
    , exclude_archived :: ChatFolder -> Maybe Bool
exclude_archived     = Maybe Bool
exclude_archived_
    , include_contacts :: ChatFolder -> Maybe Bool
include_contacts     = Maybe Bool
include_contacts_
    , include_non_contacts :: ChatFolder -> Maybe Bool
include_non_contacts = Maybe Bool
include_non_contacts_
    , include_bots :: ChatFolder -> Maybe Bool
include_bots         = Maybe Bool
include_bots_
    , include_groups :: ChatFolder -> Maybe Bool
include_groups       = Maybe Bool
include_groups_
    , include_channels :: ChatFolder -> Maybe Bool
include_channels     = Maybe Bool
include_channels_
    }
      = [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
"chatFolder"
        , Key
"title"                Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
title_
        , Key
"icon"                 Key -> Maybe ChatFolderIcon -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatFolderIcon
icon_
        , Key
"color_id"             Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
color_id_
        , Key
"is_shareable"         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_shareable_
        , Key
"pinned_chat_ids"      Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
pinned_chat_ids_
        , Key
"included_chat_ids"    Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
included_chat_ids_
        , Key
"excluded_chat_ids"    Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
excluded_chat_ids_
        , Key
"exclude_muted"        Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_muted_
        , Key
"exclude_read"         Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_read_
        , Key
"exclude_archived"     Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_archived_
        , Key
"include_contacts"     Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_contacts_
        , Key
"include_non_contacts" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_non_contacts_
        , Key
"include_bots"         Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_bots_
        , Key
"include_groups"       Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_groups_
        , Key
"include_channels"     Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
include_channels_
        ]

defaultChatFolder :: ChatFolder
defaultChatFolder :: ChatFolder
defaultChatFolder =
  ChatFolder
    { title :: Maybe Text
title                = Maybe Text
forall a. Maybe a
Nothing
    , icon :: Maybe ChatFolderIcon
icon                 = Maybe ChatFolderIcon
forall a. Maybe a
Nothing
    , color_id :: Maybe Int
color_id             = Maybe Int
forall a. Maybe a
Nothing
    , is_shareable :: Maybe Bool
is_shareable         = Maybe Bool
forall a. Maybe a
Nothing
    , pinned_chat_ids :: Maybe [Int]
pinned_chat_ids      = Maybe [Int]
forall a. Maybe a
Nothing
    , included_chat_ids :: Maybe [Int]
included_chat_ids    = Maybe [Int]
forall a. Maybe a
Nothing
    , excluded_chat_ids :: Maybe [Int]
excluded_chat_ids    = Maybe [Int]
forall a. Maybe a
Nothing
    , exclude_muted :: Maybe Bool
exclude_muted        = Maybe Bool
forall a. Maybe a
Nothing
    , exclude_read :: Maybe Bool
exclude_read         = Maybe Bool
forall a. Maybe a
Nothing
    , exclude_archived :: Maybe Bool
exclude_archived     = Maybe Bool
forall a. Maybe a
Nothing
    , include_contacts :: Maybe Bool
include_contacts     = Maybe Bool
forall a. Maybe a
Nothing
    , include_non_contacts :: Maybe Bool
include_non_contacts = Maybe Bool
forall a. Maybe a
Nothing
    , include_bots :: Maybe Bool
include_bots         = Maybe Bool
forall a. Maybe a
Nothing
    , include_groups :: Maybe Bool
include_groups       = Maybe Bool
forall a. Maybe a
Nothing
    , include_channels :: Maybe Bool
include_channels     = Maybe Bool
forall a. Maybe a
Nothing
    }