{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Textract.Types.AnalyzeIDDetections
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Textract.Types.AnalyzeIDDetections where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Textract.Types.NormalizedValue

-- | Used to contain the information detected by an AnalyzeID operation.
--
-- /See:/ 'newAnalyzeIDDetections' smart constructor.
data AnalyzeIDDetections = AnalyzeIDDetections'
  { -- | The confidence score of the detected text.
    AnalyzeIDDetections -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | Only returned for dates, returns the type of value detected and the date
    -- written in a more machine readable way.
    AnalyzeIDDetections -> Maybe NormalizedValue
normalizedValue :: Prelude.Maybe NormalizedValue,
    -- | Text of either the normalized field or value associated with it.
    AnalyzeIDDetections -> Text
text :: Prelude.Text
  }
  deriving (AnalyzeIDDetections -> AnalyzeIDDetections -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnalyzeIDDetections -> AnalyzeIDDetections -> Bool
$c/= :: AnalyzeIDDetections -> AnalyzeIDDetections -> Bool
== :: AnalyzeIDDetections -> AnalyzeIDDetections -> Bool
$c== :: AnalyzeIDDetections -> AnalyzeIDDetections -> Bool
Prelude.Eq, ReadPrec [AnalyzeIDDetections]
ReadPrec AnalyzeIDDetections
Int -> ReadS AnalyzeIDDetections
ReadS [AnalyzeIDDetections]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnalyzeIDDetections]
$creadListPrec :: ReadPrec [AnalyzeIDDetections]
readPrec :: ReadPrec AnalyzeIDDetections
$creadPrec :: ReadPrec AnalyzeIDDetections
readList :: ReadS [AnalyzeIDDetections]
$creadList :: ReadS [AnalyzeIDDetections]
readsPrec :: Int -> ReadS AnalyzeIDDetections
$creadsPrec :: Int -> ReadS AnalyzeIDDetections
Prelude.Read, Int -> AnalyzeIDDetections -> ShowS
[AnalyzeIDDetections] -> ShowS
AnalyzeIDDetections -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnalyzeIDDetections] -> ShowS
$cshowList :: [AnalyzeIDDetections] -> ShowS
show :: AnalyzeIDDetections -> String
$cshow :: AnalyzeIDDetections -> String
showsPrec :: Int -> AnalyzeIDDetections -> ShowS
$cshowsPrec :: Int -> AnalyzeIDDetections -> ShowS
Prelude.Show, forall x. Rep AnalyzeIDDetections x -> AnalyzeIDDetections
forall x. AnalyzeIDDetections -> Rep AnalyzeIDDetections x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnalyzeIDDetections x -> AnalyzeIDDetections
$cfrom :: forall x. AnalyzeIDDetections -> Rep AnalyzeIDDetections x
Prelude.Generic)

-- |
-- Create a value of 'AnalyzeIDDetections' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'confidence', 'analyzeIDDetections_confidence' - The confidence score of the detected text.
--
-- 'normalizedValue', 'analyzeIDDetections_normalizedValue' - Only returned for dates, returns the type of value detected and the date
-- written in a more machine readable way.
--
-- 'text', 'analyzeIDDetections_text' - Text of either the normalized field or value associated with it.
newAnalyzeIDDetections ::
  -- | 'text'
  Prelude.Text ->
  AnalyzeIDDetections
newAnalyzeIDDetections :: Text -> AnalyzeIDDetections
newAnalyzeIDDetections Text
pText_ =
  AnalyzeIDDetections'
    { $sel:confidence:AnalyzeIDDetections' :: Maybe Double
confidence = forall a. Maybe a
Prelude.Nothing,
      $sel:normalizedValue:AnalyzeIDDetections' :: Maybe NormalizedValue
normalizedValue = forall a. Maybe a
Prelude.Nothing,
      $sel:text:AnalyzeIDDetections' :: Text
text = Text
pText_
    }

-- | The confidence score of the detected text.
analyzeIDDetections_confidence :: Lens.Lens' AnalyzeIDDetections (Prelude.Maybe Prelude.Double)
analyzeIDDetections_confidence :: Lens' AnalyzeIDDetections (Maybe Double)
analyzeIDDetections_confidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeIDDetections' {Maybe Double
confidence :: Maybe Double
$sel:confidence:AnalyzeIDDetections' :: AnalyzeIDDetections -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: AnalyzeIDDetections
s@AnalyzeIDDetections' {} Maybe Double
a -> AnalyzeIDDetections
s {$sel:confidence:AnalyzeIDDetections' :: Maybe Double
confidence = Maybe Double
a} :: AnalyzeIDDetections)

-- | Only returned for dates, returns the type of value detected and the date
-- written in a more machine readable way.
analyzeIDDetections_normalizedValue :: Lens.Lens' AnalyzeIDDetections (Prelude.Maybe NormalizedValue)
analyzeIDDetections_normalizedValue :: Lens' AnalyzeIDDetections (Maybe NormalizedValue)
analyzeIDDetections_normalizedValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeIDDetections' {Maybe NormalizedValue
normalizedValue :: Maybe NormalizedValue
$sel:normalizedValue:AnalyzeIDDetections' :: AnalyzeIDDetections -> Maybe NormalizedValue
normalizedValue} -> Maybe NormalizedValue
normalizedValue) (\s :: AnalyzeIDDetections
s@AnalyzeIDDetections' {} Maybe NormalizedValue
a -> AnalyzeIDDetections
s {$sel:normalizedValue:AnalyzeIDDetections' :: Maybe NormalizedValue
normalizedValue = Maybe NormalizedValue
a} :: AnalyzeIDDetections)

-- | Text of either the normalized field or value associated with it.
analyzeIDDetections_text :: Lens.Lens' AnalyzeIDDetections Prelude.Text
analyzeIDDetections_text :: Lens' AnalyzeIDDetections Text
analyzeIDDetections_text = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnalyzeIDDetections' {Text
text :: Text
$sel:text:AnalyzeIDDetections' :: AnalyzeIDDetections -> Text
text} -> Text
text) (\s :: AnalyzeIDDetections
s@AnalyzeIDDetections' {} Text
a -> AnalyzeIDDetections
s {$sel:text:AnalyzeIDDetections' :: Text
text = Text
a} :: AnalyzeIDDetections)

instance Data.FromJSON AnalyzeIDDetections where
  parseJSON :: Value -> Parser AnalyzeIDDetections
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AnalyzeIDDetections"
      ( \Object
x ->
          Maybe Double
-> Maybe NormalizedValue -> Text -> AnalyzeIDDetections
AnalyzeIDDetections'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Confidence")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NormalizedValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Text")
      )

instance Prelude.Hashable AnalyzeIDDetections where
  hashWithSalt :: Int -> AnalyzeIDDetections -> Int
hashWithSalt Int
_salt AnalyzeIDDetections' {Maybe Double
Maybe NormalizedValue
Text
text :: Text
normalizedValue :: Maybe NormalizedValue
confidence :: Maybe Double
$sel:text:AnalyzeIDDetections' :: AnalyzeIDDetections -> Text
$sel:normalizedValue:AnalyzeIDDetections' :: AnalyzeIDDetections -> Maybe NormalizedValue
$sel:confidence:AnalyzeIDDetections' :: AnalyzeIDDetections -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
confidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NormalizedValue
normalizedValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
text

instance Prelude.NFData AnalyzeIDDetections where
  rnf :: AnalyzeIDDetections -> ()
rnf AnalyzeIDDetections' {Maybe Double
Maybe NormalizedValue
Text
text :: Text
normalizedValue :: Maybe NormalizedValue
confidence :: Maybe Double
$sel:text:AnalyzeIDDetections' :: AnalyzeIDDetections -> Text
$sel:normalizedValue:AnalyzeIDDetections' :: AnalyzeIDDetections -> Maybe NormalizedValue
$sel:confidence:AnalyzeIDDetections' :: AnalyzeIDDetections -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
confidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NormalizedValue
normalizedValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
text