module TD.Query.GetChatStoryInteractions
  (GetChatStoryInteractions(..)
  , defaultGetChatStoryInteractions
  ) 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.ReactionType as ReactionType
import qualified Data.Text as T

-- | Returns interactions with a story posted in a chat. Can be used only if story is posted on behalf of a chat and the user is an administrator in the chat. Returns 'TD.Data.StoryInteractions.StoryInteractions'
data GetChatStoryInteractions
  = GetChatStoryInteractions
    { GetChatStoryInteractions -> Maybe Int
story_sender_chat_id :: Maybe Int                       -- ^ The identifier of the sender of the story
    , GetChatStoryInteractions -> Maybe Int
story_id             :: Maybe Int                       -- ^ Story identifier
    , GetChatStoryInteractions -> Maybe ReactionType
reaction_type        :: Maybe ReactionType.ReactionType -- ^ Pass the default heart reaction or a suggested reaction type to receive only interactions with the specified reaction type; pass null to receive all interactions; reactionTypePaid isn't supported
    , GetChatStoryInteractions -> Maybe Bool
prefer_forwards      :: Maybe Bool                      -- ^ Pass true to get forwards and reposts first, then reactions, then other views; pass false to get interactions sorted just by interaction date
    , GetChatStoryInteractions -> Maybe Text
offset               :: Maybe T.Text                    -- ^ Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
    , GetChatStoryInteractions -> Maybe Int
limit                :: Maybe Int                       -- ^ The maximum number of story interactions to return
    }
  deriving (GetChatStoryInteractions -> GetChatStoryInteractions -> Bool
(GetChatStoryInteractions -> GetChatStoryInteractions -> Bool)
-> (GetChatStoryInteractions -> GetChatStoryInteractions -> Bool)
-> Eq GetChatStoryInteractions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatStoryInteractions -> GetChatStoryInteractions -> Bool
== :: GetChatStoryInteractions -> GetChatStoryInteractions -> Bool
$c/= :: GetChatStoryInteractions -> GetChatStoryInteractions -> Bool
/= :: GetChatStoryInteractions -> GetChatStoryInteractions -> Bool
Eq, Int -> GetChatStoryInteractions -> ShowS
[GetChatStoryInteractions] -> ShowS
GetChatStoryInteractions -> String
(Int -> GetChatStoryInteractions -> ShowS)
-> (GetChatStoryInteractions -> String)
-> ([GetChatStoryInteractions] -> ShowS)
-> Show GetChatStoryInteractions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatStoryInteractions -> ShowS
showsPrec :: Int -> GetChatStoryInteractions -> ShowS
$cshow :: GetChatStoryInteractions -> String
show :: GetChatStoryInteractions -> String
$cshowList :: [GetChatStoryInteractions] -> ShowS
showList :: [GetChatStoryInteractions] -> ShowS
Show)

instance I.ShortShow GetChatStoryInteractions where
  shortShow :: GetChatStoryInteractions -> String
shortShow
    GetChatStoryInteractions
      { story_sender_chat_id :: GetChatStoryInteractions -> Maybe Int
story_sender_chat_id = Maybe Int
story_sender_chat_id_
      , story_id :: GetChatStoryInteractions -> Maybe Int
story_id             = Maybe Int
story_id_
      , reaction_type :: GetChatStoryInteractions -> Maybe ReactionType
reaction_type        = Maybe ReactionType
reaction_type_
      , prefer_forwards :: GetChatStoryInteractions -> Maybe Bool
prefer_forwards      = Maybe Bool
prefer_forwards_
      , offset :: GetChatStoryInteractions -> Maybe Text
offset               = Maybe Text
offset_
      , limit :: GetChatStoryInteractions -> Maybe Int
limit                = Maybe Int
limit_
      }
        = String
"GetChatStoryInteractions"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"story_sender_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_sender_chat_id_
          , String
"story_id"             String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_id_
          , String
"reaction_type"        String -> Maybe ReactionType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ReactionType
reaction_type_
          , String
"prefer_forwards"      String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
prefer_forwards_
          , String
"offset"               String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
offset_
          , String
"limit"                String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetChatStoryInteractions where
  toJSON :: GetChatStoryInteractions -> Value
toJSON
    GetChatStoryInteractions
      { story_sender_chat_id :: GetChatStoryInteractions -> Maybe Int
story_sender_chat_id = Maybe Int
story_sender_chat_id_
      , story_id :: GetChatStoryInteractions -> Maybe Int
story_id             = Maybe Int
story_id_
      , reaction_type :: GetChatStoryInteractions -> Maybe ReactionType
reaction_type        = Maybe ReactionType
reaction_type_
      , prefer_forwards :: GetChatStoryInteractions -> Maybe Bool
prefer_forwards      = Maybe Bool
prefer_forwards_
      , offset :: GetChatStoryInteractions -> Maybe Text
offset               = Maybe Text
offset_
      , limit :: GetChatStoryInteractions -> Maybe Int
limit                = Maybe Int
limit_
      }
        = [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
"getChatStoryInteractions"
          , Key
"story_sender_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
story_sender_chat_id_
          , Key
"story_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
story_id_
          , Key
"reaction_type"        Key -> Maybe ReactionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ReactionType
reaction_type_
          , Key
"prefer_forwards"      Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
prefer_forwards_
          , Key
"offset"               Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
offset_
          , Key
"limit"                Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
limit_
          ]

defaultGetChatStoryInteractions :: GetChatStoryInteractions
defaultGetChatStoryInteractions :: GetChatStoryInteractions
defaultGetChatStoryInteractions =
  GetChatStoryInteractions
    { story_sender_chat_id :: Maybe Int
story_sender_chat_id = Maybe Int
forall a. Maybe a
Nothing
    , story_id :: Maybe Int
story_id             = Maybe Int
forall a. Maybe a
Nothing
    , reaction_type :: Maybe ReactionType
reaction_type        = Maybe ReactionType
forall a. Maybe a
Nothing
    , prefer_forwards :: Maybe Bool
prefer_forwards      = Maybe Bool
forall a. Maybe a
Nothing
    , offset :: Maybe Text
offset               = Maybe Text
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit                = Maybe Int
forall a. Maybe a
Nothing
    }