module TD.Query.GetSpeechRecognitionModels
  (GetSpeechRecognitionModels(..)
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Returns the newest models for on-device speech recognition supported by the given version of the speech recognition library, including models for speech language and voice activity detection. If the request fails or no models are returned, then built-in models or recognizeSpeech must be used instead. The method is supposed to be called after an application update, before the first on-device speech recognition, and from application settings. Returns 'TD.Data.SpeechRecognitionModels.SpeechRecognitionModels'
data GetSpeechRecognitionModels
  = GetSpeechRecognitionModels
    { GetSpeechRecognitionModels -> Maybe Int
version :: Maybe Int -- ^ Version of the speech recognition library built into the application; must be positive
    }
  deriving (GetSpeechRecognitionModels -> GetSpeechRecognitionModels -> Bool
(GetSpeechRecognitionModels -> GetSpeechRecognitionModels -> Bool)
-> (GetSpeechRecognitionModels
    -> GetSpeechRecognitionModels -> Bool)
-> Eq GetSpeechRecognitionModels
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetSpeechRecognitionModels -> GetSpeechRecognitionModels -> Bool
== :: GetSpeechRecognitionModels -> GetSpeechRecognitionModels -> Bool
$c/= :: GetSpeechRecognitionModels -> GetSpeechRecognitionModels -> Bool
/= :: GetSpeechRecognitionModels -> GetSpeechRecognitionModels -> Bool
Eq, Int -> GetSpeechRecognitionModels -> ShowS
[GetSpeechRecognitionModels] -> ShowS
GetSpeechRecognitionModels -> String
(Int -> GetSpeechRecognitionModels -> ShowS)
-> (GetSpeechRecognitionModels -> String)
-> ([GetSpeechRecognitionModels] -> ShowS)
-> Show GetSpeechRecognitionModels
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetSpeechRecognitionModels -> ShowS
showsPrec :: Int -> GetSpeechRecognitionModels -> ShowS
$cshow :: GetSpeechRecognitionModels -> String
show :: GetSpeechRecognitionModels -> String
$cshowList :: [GetSpeechRecognitionModels] -> ShowS
showList :: [GetSpeechRecognitionModels] -> ShowS
Show)

instance I.ShortShow GetSpeechRecognitionModels where
  shortShow :: GetSpeechRecognitionModels -> String
shortShow
    GetSpeechRecognitionModels
      { version :: GetSpeechRecognitionModels -> Maybe Int
version = Maybe Int
version_
      }
        = String
"GetSpeechRecognitionModels"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"version" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
version_
          ]

instance AT.ToJSON GetSpeechRecognitionModels where
  toJSON :: GetSpeechRecognitionModels -> Value
toJSON
    GetSpeechRecognitionModels
      { version :: GetSpeechRecognitionModels -> Maybe Int
version = Maybe Int
version_
      }
        = [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
"getSpeechRecognitionModels"
          , Key
"version" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
version_
          ]