module TD.Query.GetSearchedForTags
  (GetSearchedForTags(..)
  , defaultGetSearchedForTags
  ) 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 recently searched for hashtags or cashtags by their prefix. Returns 'TD.Data.Hashtags.Hashtags'
data GetSearchedForTags
  = GetSearchedForTags
    { GetSearchedForTags -> Maybe Text
tag_prefix :: Maybe T.Text -- ^ Prefix of hashtags or cashtags to return
    , GetSearchedForTags -> Maybe Int
limit      :: Maybe Int    -- ^ The maximum number of items to be returned
    }
  deriving (GetSearchedForTags -> GetSearchedForTags -> Bool
(GetSearchedForTags -> GetSearchedForTags -> Bool)
-> (GetSearchedForTags -> GetSearchedForTags -> Bool)
-> Eq GetSearchedForTags
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetSearchedForTags -> GetSearchedForTags -> Bool
== :: GetSearchedForTags -> GetSearchedForTags -> Bool
$c/= :: GetSearchedForTags -> GetSearchedForTags -> Bool
/= :: GetSearchedForTags -> GetSearchedForTags -> Bool
Eq, Int -> GetSearchedForTags -> ShowS
[GetSearchedForTags] -> ShowS
GetSearchedForTags -> String
(Int -> GetSearchedForTags -> ShowS)
-> (GetSearchedForTags -> String)
-> ([GetSearchedForTags] -> ShowS)
-> Show GetSearchedForTags
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetSearchedForTags -> ShowS
showsPrec :: Int -> GetSearchedForTags -> ShowS
$cshow :: GetSearchedForTags -> String
show :: GetSearchedForTags -> String
$cshowList :: [GetSearchedForTags] -> ShowS
showList :: [GetSearchedForTags] -> ShowS
Show)

instance I.ShortShow GetSearchedForTags where
  shortShow :: GetSearchedForTags -> String
shortShow
    GetSearchedForTags
      { tag_prefix :: GetSearchedForTags -> Maybe Text
tag_prefix = Maybe Text
tag_prefix_
      , limit :: GetSearchedForTags -> Maybe Int
limit      = Maybe Int
limit_
      }
        = String
"GetSearchedForTags"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"tag_prefix" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
tag_prefix_
          , String
"limit"      String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetSearchedForTags where
  toJSON :: GetSearchedForTags -> Value
toJSON
    GetSearchedForTags
      { tag_prefix :: GetSearchedForTags -> Maybe Text
tag_prefix = Maybe Text
tag_prefix_
      , limit :: GetSearchedForTags -> 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
"getSearchedForTags"
          , Key
"tag_prefix" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
tag_prefix_
          , 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_
          ]

defaultGetSearchedForTags :: GetSearchedForTags
defaultGetSearchedForTags :: GetSearchedForTags
defaultGetSearchedForTags =
  GetSearchedForTags
    { tag_prefix :: Maybe Text
tag_prefix = Maybe Text
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit      = Maybe Int
forall a. Maybe a
Nothing
    }