module TD.Query.SetPinnedChats
  (SetPinnedChats(..)
  , defaultSetPinnedChats
  ) 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.ChatList as ChatList

-- | Changes the order of pinned chats. Returns 'TD.Data.Ok.Ok'
data SetPinnedChats
  = SetPinnedChats
    { SetPinnedChats -> Maybe ChatList
chat_list :: Maybe ChatList.ChatList -- ^ Chat list in which to change the order of pinned chats
    , SetPinnedChats -> Maybe [Int]
chat_ids  :: Maybe [Int]             -- ^ The new list of pinned chats
    }
  deriving (SetPinnedChats -> SetPinnedChats -> Bool
(SetPinnedChats -> SetPinnedChats -> Bool)
-> (SetPinnedChats -> SetPinnedChats -> Bool) -> Eq SetPinnedChats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetPinnedChats -> SetPinnedChats -> Bool
== :: SetPinnedChats -> SetPinnedChats -> Bool
$c/= :: SetPinnedChats -> SetPinnedChats -> Bool
/= :: SetPinnedChats -> SetPinnedChats -> Bool
Eq, Int -> SetPinnedChats -> ShowS
[SetPinnedChats] -> ShowS
SetPinnedChats -> String
(Int -> SetPinnedChats -> ShowS)
-> (SetPinnedChats -> String)
-> ([SetPinnedChats] -> ShowS)
-> Show SetPinnedChats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetPinnedChats -> ShowS
showsPrec :: Int -> SetPinnedChats -> ShowS
$cshow :: SetPinnedChats -> String
show :: SetPinnedChats -> String
$cshowList :: [SetPinnedChats] -> ShowS
showList :: [SetPinnedChats] -> ShowS
Show)

instance I.ShortShow SetPinnedChats where
  shortShow :: SetPinnedChats -> String
shortShow
    SetPinnedChats
      { chat_list :: SetPinnedChats -> Maybe ChatList
chat_list = Maybe ChatList
chat_list_
      , chat_ids :: SetPinnedChats -> Maybe [Int]
chat_ids  = Maybe [Int]
chat_ids_
      }
        = String
"SetPinnedChats"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_list" String -> Maybe ChatList -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatList
chat_list_
          , String
"chat_ids"  String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
chat_ids_
          ]

instance AT.ToJSON SetPinnedChats where
  toJSON :: SetPinnedChats -> Value
toJSON
    SetPinnedChats
      { chat_list :: SetPinnedChats -> Maybe ChatList
chat_list = Maybe ChatList
chat_list_
      , chat_ids :: SetPinnedChats -> Maybe [Int]
chat_ids  = Maybe [Int]
chat_ids_
      }
        = [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
"setPinnedChats"
          , Key
"chat_list" Key -> Maybe ChatList -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatList
chat_list_
          , Key
"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]
chat_ids_
          ]

defaultSetPinnedChats :: SetPinnedChats
defaultSetPinnedChats :: SetPinnedChats
defaultSetPinnedChats =
  SetPinnedChats
    { chat_list :: Maybe ChatList
chat_list = Maybe ChatList
forall a. Maybe a
Nothing
    , chat_ids :: Maybe [Int]
chat_ids  = Maybe [Int]
forall a. Maybe a
Nothing
    }