module TD.Query.SearchPublicStoriesByVenue
  (SearchPublicStoriesByVenue(..)
  , defaultSearchPublicStoriesByVenue
  ) 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

-- | Searches for public stories from the given venue. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit. Returns 'TD.Data.FoundStories.FoundStories'
data SearchPublicStoriesByVenue
  = SearchPublicStoriesByVenue
    { SearchPublicStoriesByVenue -> Maybe Text
venue_provider :: Maybe T.Text -- ^ Provider of the venue
    , SearchPublicStoriesByVenue -> Maybe Text
venue_id       :: Maybe T.Text -- ^ Identifier of the venue in the provider database
    , SearchPublicStoriesByVenue -> 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
    , SearchPublicStoriesByVenue -> Maybe Int
limit          :: Maybe Int    -- ^ The maximum number of stories to be returned; up to 100. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit
    }
  deriving (SearchPublicStoriesByVenue -> SearchPublicStoriesByVenue -> Bool
(SearchPublicStoriesByVenue -> SearchPublicStoriesByVenue -> Bool)
-> (SearchPublicStoriesByVenue
    -> SearchPublicStoriesByVenue -> Bool)
-> Eq SearchPublicStoriesByVenue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SearchPublicStoriesByVenue -> SearchPublicStoriesByVenue -> Bool
== :: SearchPublicStoriesByVenue -> SearchPublicStoriesByVenue -> Bool
$c/= :: SearchPublicStoriesByVenue -> SearchPublicStoriesByVenue -> Bool
/= :: SearchPublicStoriesByVenue -> SearchPublicStoriesByVenue -> Bool
Eq, Int -> SearchPublicStoriesByVenue -> ShowS
[SearchPublicStoriesByVenue] -> ShowS
SearchPublicStoriesByVenue -> String
(Int -> SearchPublicStoriesByVenue -> ShowS)
-> (SearchPublicStoriesByVenue -> String)
-> ([SearchPublicStoriesByVenue] -> ShowS)
-> Show SearchPublicStoriesByVenue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SearchPublicStoriesByVenue -> ShowS
showsPrec :: Int -> SearchPublicStoriesByVenue -> ShowS
$cshow :: SearchPublicStoriesByVenue -> String
show :: SearchPublicStoriesByVenue -> String
$cshowList :: [SearchPublicStoriesByVenue] -> ShowS
showList :: [SearchPublicStoriesByVenue] -> ShowS
Show)

instance I.ShortShow SearchPublicStoriesByVenue where
  shortShow :: SearchPublicStoriesByVenue -> String
shortShow
    SearchPublicStoriesByVenue
      { venue_provider :: SearchPublicStoriesByVenue -> Maybe Text
venue_provider = Maybe Text
venue_provider_
      , venue_id :: SearchPublicStoriesByVenue -> Maybe Text
venue_id       = Maybe Text
venue_id_
      , offset :: SearchPublicStoriesByVenue -> Maybe Text
offset         = Maybe Text
offset_
      , limit :: SearchPublicStoriesByVenue -> Maybe Int
limit          = Maybe Int
limit_
      }
        = String
"SearchPublicStoriesByVenue"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"venue_provider" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
venue_provider_
          , String
"venue_id"       String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
venue_id_
          , 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 SearchPublicStoriesByVenue where
  toJSON :: SearchPublicStoriesByVenue -> Value
toJSON
    SearchPublicStoriesByVenue
      { venue_provider :: SearchPublicStoriesByVenue -> Maybe Text
venue_provider = Maybe Text
venue_provider_
      , venue_id :: SearchPublicStoriesByVenue -> Maybe Text
venue_id       = Maybe Text
venue_id_
      , offset :: SearchPublicStoriesByVenue -> Maybe Text
offset         = Maybe Text
offset_
      , limit :: SearchPublicStoriesByVenue -> 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
"searchPublicStoriesByVenue"
          , Key
"venue_provider" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
venue_provider_
          , Key
"venue_id"       Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
venue_id_
          , 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_
          ]

defaultSearchPublicStoriesByVenue :: SearchPublicStoriesByVenue
defaultSearchPublicStoriesByVenue :: SearchPublicStoriesByVenue
defaultSearchPublicStoriesByVenue =
  SearchPublicStoriesByVenue
    { venue_provider :: Maybe Text
venue_provider = Maybe Text
forall a. Maybe a
Nothing
    , venue_id :: Maybe Text
venue_id       = Maybe Text
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
    }