module TD.Query.ReorderChatFolders
  (ReorderChatFolders(..)
  , defaultReorderChatFolders
  ) where

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

-- | Changes the order of chat folders. Returns 'TD.Data.Ok.Ok'
data ReorderChatFolders
  = ReorderChatFolders
    { ReorderChatFolders -> Maybe [Int]
chat_folder_ids         :: Maybe [Int] -- ^ Identifiers of chat folders in the new correct order
    , ReorderChatFolders -> Maybe Int
main_chat_list_position :: Maybe Int   -- ^ Position of the main chat list among chat folders, 0-based. Can be non-zero only for Premium users
    }
  deriving (ReorderChatFolders -> ReorderChatFolders -> Bool
(ReorderChatFolders -> ReorderChatFolders -> Bool)
-> (ReorderChatFolders -> ReorderChatFolders -> Bool)
-> Eq ReorderChatFolders
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReorderChatFolders -> ReorderChatFolders -> Bool
== :: ReorderChatFolders -> ReorderChatFolders -> Bool
$c/= :: ReorderChatFolders -> ReorderChatFolders -> Bool
/= :: ReorderChatFolders -> ReorderChatFolders -> Bool
Eq, Int -> ReorderChatFolders -> ShowS
[ReorderChatFolders] -> ShowS
ReorderChatFolders -> String
(Int -> ReorderChatFolders -> ShowS)
-> (ReorderChatFolders -> String)
-> ([ReorderChatFolders] -> ShowS)
-> Show ReorderChatFolders
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReorderChatFolders -> ShowS
showsPrec :: Int -> ReorderChatFolders -> ShowS
$cshow :: ReorderChatFolders -> String
show :: ReorderChatFolders -> String
$cshowList :: [ReorderChatFolders] -> ShowS
showList :: [ReorderChatFolders] -> ShowS
Show)

instance I.ShortShow ReorderChatFolders where
  shortShow :: ReorderChatFolders -> String
shortShow
    ReorderChatFolders
      { chat_folder_ids :: ReorderChatFolders -> Maybe [Int]
chat_folder_ids         = Maybe [Int]
chat_folder_ids_
      , main_chat_list_position :: ReorderChatFolders -> Maybe Int
main_chat_list_position = Maybe Int
main_chat_list_position_
      }
        = String
"ReorderChatFolders"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_folder_ids"         String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
chat_folder_ids_
          , String
"main_chat_list_position" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
main_chat_list_position_
          ]

instance AT.ToJSON ReorderChatFolders where
  toJSON :: ReorderChatFolders -> Value
toJSON
    ReorderChatFolders
      { chat_folder_ids :: ReorderChatFolders -> Maybe [Int]
chat_folder_ids         = Maybe [Int]
chat_folder_ids_
      , main_chat_list_position :: ReorderChatFolders -> Maybe Int
main_chat_list_position = Maybe Int
main_chat_list_position_
      }
        = [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
"reorderChatFolders"
          , Key
"chat_folder_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_folder_ids_
          , Key
"main_chat_list_position" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
main_chat_list_position_
          ]

defaultReorderChatFolders :: ReorderChatFolders
defaultReorderChatFolders :: ReorderChatFolders
defaultReorderChatFolders =
  ReorderChatFolders
    { chat_folder_ids :: Maybe [Int]
chat_folder_ids         = Maybe [Int]
forall a. Maybe a
Nothing
    , main_chat_list_position :: Maybe Int
main_chat_list_position = Maybe Int
forall a. Maybe a
Nothing
    }