module TD.Query.SetChatPinnedStories
  (SetChatPinnedStories(..)
  , defaultSetChatPinnedStories
  ) where

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

-- | Changes the list of pinned stories on a chat page; requires can_edit_stories right in the chat. Returns 'TD.Data.Ok.Ok'
data SetChatPinnedStories
  = SetChatPinnedStories
    { SetChatPinnedStories -> Maybe Int
chat_id   :: Maybe Int   -- ^ Identifier of the chat that posted the stories
    , SetChatPinnedStories -> Maybe [Int]
story_ids :: Maybe [Int] -- ^ New list of pinned stories. All stories must be posted to the chat page first. There can be up to getOption("pinned_story_count_max") pinned stories on a chat page
    }
  deriving (SetChatPinnedStories -> SetChatPinnedStories -> Bool
(SetChatPinnedStories -> SetChatPinnedStories -> Bool)
-> (SetChatPinnedStories -> SetChatPinnedStories -> Bool)
-> Eq SetChatPinnedStories
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetChatPinnedStories -> SetChatPinnedStories -> Bool
== :: SetChatPinnedStories -> SetChatPinnedStories -> Bool
$c/= :: SetChatPinnedStories -> SetChatPinnedStories -> Bool
/= :: SetChatPinnedStories -> SetChatPinnedStories -> Bool
Eq, Int -> SetChatPinnedStories -> ShowS
[SetChatPinnedStories] -> ShowS
SetChatPinnedStories -> String
(Int -> SetChatPinnedStories -> ShowS)
-> (SetChatPinnedStories -> String)
-> ([SetChatPinnedStories] -> ShowS)
-> Show SetChatPinnedStories
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetChatPinnedStories -> ShowS
showsPrec :: Int -> SetChatPinnedStories -> ShowS
$cshow :: SetChatPinnedStories -> String
show :: SetChatPinnedStories -> String
$cshowList :: [SetChatPinnedStories] -> ShowS
showList :: [SetChatPinnedStories] -> ShowS
Show)

instance I.ShortShow SetChatPinnedStories where
  shortShow :: SetChatPinnedStories -> String
shortShow
    SetChatPinnedStories
      { chat_id :: SetChatPinnedStories -> Maybe Int
chat_id   = Maybe Int
chat_id_
      , story_ids :: SetChatPinnedStories -> Maybe [Int]
story_ids = Maybe [Int]
story_ids_
      }
        = String
"SetChatPinnedStories"
          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
"story_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
story_ids_
          ]

instance AT.ToJSON SetChatPinnedStories where
  toJSON :: SetChatPinnedStories -> Value
toJSON
    SetChatPinnedStories
      { chat_id :: SetChatPinnedStories -> Maybe Int
chat_id   = Maybe Int
chat_id_
      , story_ids :: SetChatPinnedStories -> Maybe [Int]
story_ids = Maybe [Int]
story_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
"setChatPinnedStories"
          , Key
"chat_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
chat_id_
          , Key
"story_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]
story_ids_
          ]

defaultSetChatPinnedStories :: SetChatPinnedStories
defaultSetChatPinnedStories :: SetChatPinnedStories
defaultSetChatPinnedStories =
  SetChatPinnedStories
    { chat_id :: Maybe Int
chat_id   = Maybe Int
forall a. Maybe a
Nothing
    , story_ids :: Maybe [Int]
story_ids = Maybe [Int]
forall a. Maybe a
Nothing
    }