module TD.Query.AddTextCompositionStyle
  (AddTextCompositionStyle(..)
  ) 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

-- | Adds a custom text composition style to the list of used by the user styles. May return an error with a message "TONES_SAVED_TOO_MANY" if the maximum number of added custom styles has been reached. Returns 'TD.Data.Ok.Ok'
data AddTextCompositionStyle
  = AddTextCompositionStyle
    { AddTextCompositionStyle -> Maybe Text
name :: Maybe T.Text -- ^ Name of the style
    }
  deriving (AddTextCompositionStyle -> AddTextCompositionStyle -> Bool
(AddTextCompositionStyle -> AddTextCompositionStyle -> Bool)
-> (AddTextCompositionStyle -> AddTextCompositionStyle -> Bool)
-> Eq AddTextCompositionStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddTextCompositionStyle -> AddTextCompositionStyle -> Bool
== :: AddTextCompositionStyle -> AddTextCompositionStyle -> Bool
$c/= :: AddTextCompositionStyle -> AddTextCompositionStyle -> Bool
/= :: AddTextCompositionStyle -> AddTextCompositionStyle -> Bool
Eq, Int -> AddTextCompositionStyle -> ShowS
[AddTextCompositionStyle] -> ShowS
AddTextCompositionStyle -> String
(Int -> AddTextCompositionStyle -> ShowS)
-> (AddTextCompositionStyle -> String)
-> ([AddTextCompositionStyle] -> ShowS)
-> Show AddTextCompositionStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddTextCompositionStyle -> ShowS
showsPrec :: Int -> AddTextCompositionStyle -> ShowS
$cshow :: AddTextCompositionStyle -> String
show :: AddTextCompositionStyle -> String
$cshowList :: [AddTextCompositionStyle] -> ShowS
showList :: [AddTextCompositionStyle] -> ShowS
Show)

instance I.ShortShow AddTextCompositionStyle where
  shortShow :: AddTextCompositionStyle -> String
shortShow
    AddTextCompositionStyle
      { name :: AddTextCompositionStyle -> Maybe Text
name = Maybe Text
name_
      }
        = String
"AddTextCompositionStyle"
          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 AddTextCompositionStyle where
  toJSON :: AddTextCompositionStyle -> Value
toJSON
    AddTextCompositionStyle
      { name :: AddTextCompositionStyle -> 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
"addTextCompositionStyle"
          , 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_
          ]