module TD.Query.SearchPublicStoriesByLocation
  (SearchPublicStoriesByLocation(..)
  , defaultSearchPublicStoriesByLocation
  ) 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.LocationAddress as LocationAddress
import qualified Data.Text as T

-- | Searches for public stories by the given address location. 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 SearchPublicStoriesByLocation
  = SearchPublicStoriesByLocation
    { SearchPublicStoriesByLocation -> Maybe LocationAddress
address :: Maybe LocationAddress.LocationAddress -- ^ Address of the location
    , SearchPublicStoriesByLocation -> 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
    , SearchPublicStoriesByLocation -> 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 (SearchPublicStoriesByLocation
-> SearchPublicStoriesByLocation -> Bool
(SearchPublicStoriesByLocation
 -> SearchPublicStoriesByLocation -> Bool)
-> (SearchPublicStoriesByLocation
    -> SearchPublicStoriesByLocation -> Bool)
-> Eq SearchPublicStoriesByLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SearchPublicStoriesByLocation
-> SearchPublicStoriesByLocation -> Bool
== :: SearchPublicStoriesByLocation
-> SearchPublicStoriesByLocation -> Bool
$c/= :: SearchPublicStoriesByLocation
-> SearchPublicStoriesByLocation -> Bool
/= :: SearchPublicStoriesByLocation
-> SearchPublicStoriesByLocation -> Bool
Eq, Int -> SearchPublicStoriesByLocation -> ShowS
[SearchPublicStoriesByLocation] -> ShowS
SearchPublicStoriesByLocation -> String
(Int -> SearchPublicStoriesByLocation -> ShowS)
-> (SearchPublicStoriesByLocation -> String)
-> ([SearchPublicStoriesByLocation] -> ShowS)
-> Show SearchPublicStoriesByLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SearchPublicStoriesByLocation -> ShowS
showsPrec :: Int -> SearchPublicStoriesByLocation -> ShowS
$cshow :: SearchPublicStoriesByLocation -> String
show :: SearchPublicStoriesByLocation -> String
$cshowList :: [SearchPublicStoriesByLocation] -> ShowS
showList :: [SearchPublicStoriesByLocation] -> ShowS
Show)

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

defaultSearchPublicStoriesByLocation :: SearchPublicStoriesByLocation
defaultSearchPublicStoriesByLocation :: SearchPublicStoriesByLocation
defaultSearchPublicStoriesByLocation =
  SearchPublicStoriesByLocation
    { address :: Maybe LocationAddress
address = Maybe LocationAddress
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
    }