{-# 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.IdentityDocument
-- 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.IdentityDocument 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.Block
import Amazonka.Textract.Types.IdentityDocumentField

-- | The structure that lists each document processed in an AnalyzeID
-- operation.
--
-- /See:/ 'newIdentityDocument' smart constructor.
data IdentityDocument = IdentityDocument'
  { -- | Individual word recognition, as returned by document detection.
    IdentityDocument -> Maybe [Block]
blocks :: Prelude.Maybe [Block],
    -- | Denotes the placement of a document in the IdentityDocument list. The
    -- first document is marked 1, the second 2 and so on.
    IdentityDocument -> Maybe Natural
documentIndex :: Prelude.Maybe Prelude.Natural,
    -- | The structure used to record information extracted from identity
    -- documents. Contains both normalized field and value of the extracted
    -- text.
    IdentityDocument -> Maybe [IdentityDocumentField]
identityDocumentFields :: Prelude.Maybe [IdentityDocumentField]
  }
  deriving (IdentityDocument -> IdentityDocument -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IdentityDocument -> IdentityDocument -> Bool
$c/= :: IdentityDocument -> IdentityDocument -> Bool
== :: IdentityDocument -> IdentityDocument -> Bool
$c== :: IdentityDocument -> IdentityDocument -> Bool
Prelude.Eq, ReadPrec [IdentityDocument]
ReadPrec IdentityDocument
Int -> ReadS IdentityDocument
ReadS [IdentityDocument]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IdentityDocument]
$creadListPrec :: ReadPrec [IdentityDocument]
readPrec :: ReadPrec IdentityDocument
$creadPrec :: ReadPrec IdentityDocument
readList :: ReadS [IdentityDocument]
$creadList :: ReadS [IdentityDocument]
readsPrec :: Int -> ReadS IdentityDocument
$creadsPrec :: Int -> ReadS IdentityDocument
Prelude.Read, Int -> IdentityDocument -> ShowS
[IdentityDocument] -> ShowS
IdentityDocument -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdentityDocument] -> ShowS
$cshowList :: [IdentityDocument] -> ShowS
show :: IdentityDocument -> String
$cshow :: IdentityDocument -> String
showsPrec :: Int -> IdentityDocument -> ShowS
$cshowsPrec :: Int -> IdentityDocument -> ShowS
Prelude.Show, forall x. Rep IdentityDocument x -> IdentityDocument
forall x. IdentityDocument -> Rep IdentityDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IdentityDocument x -> IdentityDocument
$cfrom :: forall x. IdentityDocument -> Rep IdentityDocument x
Prelude.Generic)

-- |
-- Create a value of 'IdentityDocument' 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:
--
-- 'blocks', 'identityDocument_blocks' - Individual word recognition, as returned by document detection.
--
-- 'documentIndex', 'identityDocument_documentIndex' - Denotes the placement of a document in the IdentityDocument list. The
-- first document is marked 1, the second 2 and so on.
--
-- 'identityDocumentFields', 'identityDocument_identityDocumentFields' - The structure used to record information extracted from identity
-- documents. Contains both normalized field and value of the extracted
-- text.
newIdentityDocument ::
  IdentityDocument
newIdentityDocument :: IdentityDocument
newIdentityDocument =
  IdentityDocument'
    { $sel:blocks:IdentityDocument' :: Maybe [Block]
blocks = forall a. Maybe a
Prelude.Nothing,
      $sel:documentIndex:IdentityDocument' :: Maybe Natural
documentIndex = forall a. Maybe a
Prelude.Nothing,
      $sel:identityDocumentFields:IdentityDocument' :: Maybe [IdentityDocumentField]
identityDocumentFields = forall a. Maybe a
Prelude.Nothing
    }

-- | Individual word recognition, as returned by document detection.
identityDocument_blocks :: Lens.Lens' IdentityDocument (Prelude.Maybe [Block])
identityDocument_blocks :: Lens' IdentityDocument (Maybe [Block])
identityDocument_blocks = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDocument' {Maybe [Block]
blocks :: Maybe [Block]
$sel:blocks:IdentityDocument' :: IdentityDocument -> Maybe [Block]
blocks} -> Maybe [Block]
blocks) (\s :: IdentityDocument
s@IdentityDocument' {} Maybe [Block]
a -> IdentityDocument
s {$sel:blocks:IdentityDocument' :: Maybe [Block]
blocks = Maybe [Block]
a} :: IdentityDocument) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Denotes the placement of a document in the IdentityDocument list. The
-- first document is marked 1, the second 2 and so on.
identityDocument_documentIndex :: Lens.Lens' IdentityDocument (Prelude.Maybe Prelude.Natural)
identityDocument_documentIndex :: Lens' IdentityDocument (Maybe Natural)
identityDocument_documentIndex = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDocument' {Maybe Natural
documentIndex :: Maybe Natural
$sel:documentIndex:IdentityDocument' :: IdentityDocument -> Maybe Natural
documentIndex} -> Maybe Natural
documentIndex) (\s :: IdentityDocument
s@IdentityDocument' {} Maybe Natural
a -> IdentityDocument
s {$sel:documentIndex:IdentityDocument' :: Maybe Natural
documentIndex = Maybe Natural
a} :: IdentityDocument)

-- | The structure used to record information extracted from identity
-- documents. Contains both normalized field and value of the extracted
-- text.
identityDocument_identityDocumentFields :: Lens.Lens' IdentityDocument (Prelude.Maybe [IdentityDocumentField])
identityDocument_identityDocumentFields :: Lens' IdentityDocument (Maybe [IdentityDocumentField])
identityDocument_identityDocumentFields = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDocument' {Maybe [IdentityDocumentField]
identityDocumentFields :: Maybe [IdentityDocumentField]
$sel:identityDocumentFields:IdentityDocument' :: IdentityDocument -> Maybe [IdentityDocumentField]
identityDocumentFields} -> Maybe [IdentityDocumentField]
identityDocumentFields) (\s :: IdentityDocument
s@IdentityDocument' {} Maybe [IdentityDocumentField]
a -> IdentityDocument
s {$sel:identityDocumentFields:IdentityDocument' :: Maybe [IdentityDocumentField]
identityDocumentFields = Maybe [IdentityDocumentField]
a} :: IdentityDocument) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON IdentityDocument where
  parseJSON :: Value -> Parser IdentityDocument
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IdentityDocument"
      ( \Object
x ->
          Maybe [Block]
-> Maybe Natural
-> Maybe [IdentityDocumentField]
-> IdentityDocument
IdentityDocument'
            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
"Blocks" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"DocumentIndex")
            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
"IdentityDocumentFields"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable IdentityDocument where
  hashWithSalt :: Int -> IdentityDocument -> Int
hashWithSalt Int
_salt IdentityDocument' {Maybe Natural
Maybe [Block]
Maybe [IdentityDocumentField]
identityDocumentFields :: Maybe [IdentityDocumentField]
documentIndex :: Maybe Natural
blocks :: Maybe [Block]
$sel:identityDocumentFields:IdentityDocument' :: IdentityDocument -> Maybe [IdentityDocumentField]
$sel:documentIndex:IdentityDocument' :: IdentityDocument -> Maybe Natural
$sel:blocks:IdentityDocument' :: IdentityDocument -> Maybe [Block]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Block]
blocks
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
documentIndex
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [IdentityDocumentField]
identityDocumentFields

instance Prelude.NFData IdentityDocument where
  rnf :: IdentityDocument -> ()
rnf IdentityDocument' {Maybe Natural
Maybe [Block]
Maybe [IdentityDocumentField]
identityDocumentFields :: Maybe [IdentityDocumentField]
documentIndex :: Maybe Natural
blocks :: Maybe [Block]
$sel:identityDocumentFields:IdentityDocument' :: IdentityDocument -> Maybe [IdentityDocumentField]
$sel:documentIndex:IdentityDocument' :: IdentityDocument -> Maybe Natural
$sel:blocks:IdentityDocument' :: IdentityDocument -> Maybe [Block]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Block]
blocks
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
documentIndex
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [IdentityDocumentField]
identityDocumentFields