module TD.Query.SearchTextCompositionStyle
  (SearchTextCompositionStyle(..)
  ) 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 a custom text composition style by its name. Returns 'TD.Data.TextCompositionStyle.TextCompositionStyle'
data SearchTextCompositionStyle
  = SearchTextCompositionStyle
    { SearchTextCompositionStyle -> Maybe Text
name :: Maybe T.Text -- ^ Name of the style
    }
  deriving (SearchTextCompositionStyle -> SearchTextCompositionStyle -> Bool
(SearchTextCompositionStyle -> SearchTextCompositionStyle -> Bool)
-> (SearchTextCompositionStyle
    -> SearchTextCompositionStyle -> Bool)
-> Eq SearchTextCompositionStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SearchTextCompositionStyle -> SearchTextCompositionStyle -> Bool
== :: SearchTextCompositionStyle -> SearchTextCompositionStyle -> Bool
$c/= :: SearchTextCompositionStyle -> SearchTextCompositionStyle -> Bool
/= :: SearchTextCompositionStyle -> SearchTextCompositionStyle -> Bool
Eq, Int -> SearchTextCompositionStyle -> ShowS
[SearchTextCompositionStyle] -> ShowS
SearchTextCompositionStyle -> String
(Int -> SearchTextCompositionStyle -> ShowS)
-> (SearchTextCompositionStyle -> String)
-> ([SearchTextCompositionStyle] -> ShowS)
-> Show SearchTextCompositionStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SearchTextCompositionStyle -> ShowS
showsPrec :: Int -> SearchTextCompositionStyle -> ShowS
$cshow :: SearchTextCompositionStyle -> String
show :: SearchTextCompositionStyle -> String
$cshowList :: [SearchTextCompositionStyle] -> ShowS
showList :: [SearchTextCompositionStyle] -> ShowS
Show)

instance I.ShortShow SearchTextCompositionStyle where
  shortShow :: SearchTextCompositionStyle -> String
shortShow
    SearchTextCompositionStyle
      { name :: SearchTextCompositionStyle -> Maybe Text
name = Maybe Text
name_
      }
        = String
"SearchTextCompositionStyle"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          ]

instance AT.ToJSON SearchTextCompositionStyle where
  toJSON :: SearchTextCompositionStyle -> Value
toJSON
    SearchTextCompositionStyle
      { name :: SearchTextCompositionStyle -> Maybe Text
name = Maybe Text
name_
      }
        = [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
"searchTextCompositionStyle"
          , Key
"name"  Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
name_
          ]