module TD.Query.GetStoryInteractions
  (GetStoryInteractions(..)
  , defaultGetStoryInteractions
  ) 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

-- | Returns interactions with a story. The method can be called only for stories posted on behalf of the current user. Returns 'TD.Data.StoryInteractions.StoryInteractions'
data GetStoryInteractions
  = GetStoryInteractions
    { GetStoryInteractions -> Maybe Int
story_id             :: Maybe Int    -- ^ Story identifier
    , GetStoryInteractions -> Maybe Text
query                :: Maybe T.Text -- ^ Query to search for in names, usernames and titles; may be empty to get all relevant interactions
    , GetStoryInteractions -> Maybe Bool
only_contacts        :: Maybe Bool   -- ^ Pass true to get only interactions by contacts; pass false to get all relevant interactions
    , GetStoryInteractions -> 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
    , GetStoryInteractions -> Maybe Bool
prefer_with_reaction :: Maybe Bool   -- ^ Pass true to get interactions with reaction first; pass false to get interactions sorted just by interaction date. Ignored if prefer_forwards == true
    , GetStoryInteractions -> 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
    , GetStoryInteractions -> Maybe Int
limit                :: Maybe Int    -- ^ The maximum number of story interactions to return
    }
  deriving (GetStoryInteractions -> GetStoryInteractions -> Bool
(GetStoryInteractions -> GetStoryInteractions -> Bool)
-> (GetStoryInteractions -> GetStoryInteractions -> Bool)
-> Eq GetStoryInteractions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetStoryInteractions -> GetStoryInteractions -> Bool
== :: GetStoryInteractions -> GetStoryInteractions -> Bool
$c/= :: GetStoryInteractions -> GetStoryInteractions -> Bool
/= :: GetStoryInteractions -> GetStoryInteractions -> Bool
Eq, Int -> GetStoryInteractions -> ShowS
[GetStoryInteractions] -> ShowS
GetStoryInteractions -> String
(Int -> GetStoryInteractions -> ShowS)
-> (GetStoryInteractions -> String)
-> ([GetStoryInteractions] -> ShowS)
-> Show GetStoryInteractions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetStoryInteractions -> ShowS
showsPrec :: Int -> GetStoryInteractions -> ShowS
$cshow :: GetStoryInteractions -> String
show :: GetStoryInteractions -> String
$cshowList :: [GetStoryInteractions] -> ShowS
showList :: [GetStoryInteractions] -> ShowS
Show)

instance I.ShortShow GetStoryInteractions where
  shortShow :: GetStoryInteractions -> String
shortShow
    GetStoryInteractions
      { story_id :: GetStoryInteractions -> Maybe Int
story_id             = Maybe Int
story_id_
      , query :: GetStoryInteractions -> Maybe Text
query                = Maybe Text
query_
      , only_contacts :: GetStoryInteractions -> Maybe Bool
only_contacts        = Maybe Bool
only_contacts_
      , prefer_forwards :: GetStoryInteractions -> Maybe Bool
prefer_forwards      = Maybe Bool
prefer_forwards_
      , prefer_with_reaction :: GetStoryInteractions -> Maybe Bool
prefer_with_reaction = Maybe Bool
prefer_with_reaction_
      , offset :: GetStoryInteractions -> Maybe Text
offset               = Maybe Text
offset_
      , limit :: GetStoryInteractions -> Maybe Int
limit                = Maybe Int
limit_
      }
        = String
"GetStoryInteractions"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"story_id"             String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_id_
          , String
"query"                String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
query_
          , String
"only_contacts"        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_contacts_
          , String
"prefer_forwards"      String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
prefer_forwards_
          , String
"prefer_with_reaction" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
prefer_with_reaction_
          , 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 GetStoryInteractions where
  toJSON :: GetStoryInteractions -> Value
toJSON
    GetStoryInteractions
      { story_id :: GetStoryInteractions -> Maybe Int
story_id             = Maybe Int
story_id_
      , query :: GetStoryInteractions -> Maybe Text
query                = Maybe Text
query_
      , only_contacts :: GetStoryInteractions -> Maybe Bool
only_contacts        = Maybe Bool
only_contacts_
      , prefer_forwards :: GetStoryInteractions -> Maybe Bool
prefer_forwards      = Maybe Bool
prefer_forwards_
      , prefer_with_reaction :: GetStoryInteractions -> Maybe Bool
prefer_with_reaction = Maybe Bool
prefer_with_reaction_
      , offset :: GetStoryInteractions -> Maybe Text
offset               = Maybe Text
offset_
      , limit :: GetStoryInteractions -> 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
"getStoryInteractions"
          , 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
"query"                Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
query_
          , Key
"only_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
only_contacts_
          , 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
"prefer_with_reaction" 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_with_reaction_
          , 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_
          ]

defaultGetStoryInteractions :: GetStoryInteractions
defaultGetStoryInteractions :: GetStoryInteractions
defaultGetStoryInteractions =
  GetStoryInteractions
    { story_id :: Maybe Int
story_id             = Maybe Int
forall a. Maybe a
Nothing
    , query :: Maybe Text
query                = Maybe Text
forall a. Maybe a
Nothing
    , only_contacts :: Maybe Bool
only_contacts        = Maybe Bool
forall a. Maybe a
Nothing
    , prefer_forwards :: Maybe Bool
prefer_forwards      = Maybe Bool
forall a. Maybe a
Nothing
    , prefer_with_reaction :: Maybe Bool
prefer_with_reaction = 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
    }