{-# 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.LendingField
-- 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.LendingField 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.LendingDetection

-- | Holds the normalized key-value pairs returned by AnalyzeDocument,
-- including the document type, detected text, and geometry.
--
-- /See:/ 'newLendingField' smart constructor.
data LendingField = LendingField'
  { LendingField -> Maybe LendingDetection
keyDetection :: Prelude.Maybe LendingDetection,
    -- | The type of the lending document.
    LendingField -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | An array of LendingDetection objects.
    LendingField -> Maybe [LendingDetection]
valueDetections :: Prelude.Maybe [LendingDetection]
  }
  deriving (LendingField -> LendingField -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LendingField -> LendingField -> Bool
$c/= :: LendingField -> LendingField -> Bool
== :: LendingField -> LendingField -> Bool
$c== :: LendingField -> LendingField -> Bool
Prelude.Eq, ReadPrec [LendingField]
ReadPrec LendingField
Int -> ReadS LendingField
ReadS [LendingField]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LendingField]
$creadListPrec :: ReadPrec [LendingField]
readPrec :: ReadPrec LendingField
$creadPrec :: ReadPrec LendingField
readList :: ReadS [LendingField]
$creadList :: ReadS [LendingField]
readsPrec :: Int -> ReadS LendingField
$creadsPrec :: Int -> ReadS LendingField
Prelude.Read, Int -> LendingField -> ShowS
[LendingField] -> ShowS
LendingField -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LendingField] -> ShowS
$cshowList :: [LendingField] -> ShowS
show :: LendingField -> String
$cshow :: LendingField -> String
showsPrec :: Int -> LendingField -> ShowS
$cshowsPrec :: Int -> LendingField -> ShowS
Prelude.Show, forall x. Rep LendingField x -> LendingField
forall x. LendingField -> Rep LendingField x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LendingField x -> LendingField
$cfrom :: forall x. LendingField -> Rep LendingField x
Prelude.Generic)

-- |
-- Create a value of 'LendingField' 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:
--
-- 'keyDetection', 'lendingField_keyDetection' - Undocumented member.
--
-- 'type'', 'lendingField_type' - The type of the lending document.
--
-- 'valueDetections', 'lendingField_valueDetections' - An array of LendingDetection objects.
newLendingField ::
  LendingField
newLendingField :: LendingField
newLendingField =
  LendingField'
    { $sel:keyDetection:LendingField' :: Maybe LendingDetection
keyDetection = forall a. Maybe a
Prelude.Nothing,
      $sel:type':LendingField' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:valueDetections:LendingField' :: Maybe [LendingDetection]
valueDetections = forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
lendingField_keyDetection :: Lens.Lens' LendingField (Prelude.Maybe LendingDetection)
lendingField_keyDetection :: Lens' LendingField (Maybe LendingDetection)
lendingField_keyDetection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LendingField' {Maybe LendingDetection
keyDetection :: Maybe LendingDetection
$sel:keyDetection:LendingField' :: LendingField -> Maybe LendingDetection
keyDetection} -> Maybe LendingDetection
keyDetection) (\s :: LendingField
s@LendingField' {} Maybe LendingDetection
a -> LendingField
s {$sel:keyDetection:LendingField' :: Maybe LendingDetection
keyDetection = Maybe LendingDetection
a} :: LendingField)

-- | The type of the lending document.
lendingField_type :: Lens.Lens' LendingField (Prelude.Maybe Prelude.Text)
lendingField_type :: Lens' LendingField (Maybe Text)
lendingField_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LendingField' {Maybe Text
type' :: Maybe Text
$sel:type':LendingField' :: LendingField -> Maybe Text
type'} -> Maybe Text
type') (\s :: LendingField
s@LendingField' {} Maybe Text
a -> LendingField
s {$sel:type':LendingField' :: Maybe Text
type' = Maybe Text
a} :: LendingField)

-- | An array of LendingDetection objects.
lendingField_valueDetections :: Lens.Lens' LendingField (Prelude.Maybe [LendingDetection])
lendingField_valueDetections :: Lens' LendingField (Maybe [LendingDetection])
lendingField_valueDetections = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LendingField' {Maybe [LendingDetection]
valueDetections :: Maybe [LendingDetection]
$sel:valueDetections:LendingField' :: LendingField -> Maybe [LendingDetection]
valueDetections} -> Maybe [LendingDetection]
valueDetections) (\s :: LendingField
s@LendingField' {} Maybe [LendingDetection]
a -> LendingField
s {$sel:valueDetections:LendingField' :: Maybe [LendingDetection]
valueDetections = Maybe [LendingDetection]
a} :: LendingField) 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 LendingField where
  parseJSON :: Value -> Parser LendingField
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LendingField"
      ( \Object
x ->
          Maybe LendingDetection
-> Maybe Text -> Maybe [LendingDetection] -> LendingField
LendingField'
            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
"KeyDetection")
            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
"Type")
            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
"ValueDetections"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable LendingField where
  hashWithSalt :: Int -> LendingField -> Int
hashWithSalt Int
_salt LendingField' {Maybe [LendingDetection]
Maybe Text
Maybe LendingDetection
valueDetections :: Maybe [LendingDetection]
type' :: Maybe Text
keyDetection :: Maybe LendingDetection
$sel:valueDetections:LendingField' :: LendingField -> Maybe [LendingDetection]
$sel:type':LendingField' :: LendingField -> Maybe Text
$sel:keyDetection:LendingField' :: LendingField -> Maybe LendingDetection
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LendingDetection
keyDetection
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [LendingDetection]
valueDetections

instance Prelude.NFData LendingField where
  rnf :: LendingField -> ()
rnf LendingField' {Maybe [LendingDetection]
Maybe Text
Maybe LendingDetection
valueDetections :: Maybe [LendingDetection]
type' :: Maybe Text
keyDetection :: Maybe LendingDetection
$sel:valueDetections:LendingField' :: LendingField -> Maybe [LendingDetection]
$sel:type':LendingField' :: LendingField -> Maybe Text
$sel:keyDetection:LendingField' :: LendingField -> Maybe LendingDetection
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe LendingDetection
keyDetection
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [LendingDetection]
valueDetections