{-# 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.ExpenseField
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Textract.Types.ExpenseField where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Textract.Types.ExpenseDetection
import Amazonka.Textract.Types.ExpenseType

-- | Breakdown of detected information, seperated into the catagories Type,
-- LableDetection, and ValueDetection
--
-- /See:/ 'newExpenseField' smart constructor.
data ExpenseField = ExpenseField'
  { -- | The explicitly stated label of a detected element.
    ExpenseField -> Maybe ExpenseDetection
labelDetection :: Prelude.Maybe ExpenseDetection,
    -- | The value of a detected element. Present in explicit and implicit
    -- elements.
    ExpenseField -> Maybe ExpenseDetection
valueDetection :: Prelude.Maybe ExpenseDetection,
    -- | The implied label of a detected element. Present alongside
    -- LabelDetection for explicit elements.
    ExpenseField -> Maybe ExpenseType
type' :: Prelude.Maybe ExpenseType,
    -- | The page number the value was detected on.
    ExpenseField -> Maybe Natural
pageNumber :: Prelude.Maybe Prelude.Natural
  }
  deriving (ExpenseField -> ExpenseField -> Bool
(ExpenseField -> ExpenseField -> Bool)
-> (ExpenseField -> ExpenseField -> Bool) -> Eq ExpenseField
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExpenseField -> ExpenseField -> Bool
$c/= :: ExpenseField -> ExpenseField -> Bool
== :: ExpenseField -> ExpenseField -> Bool
$c== :: ExpenseField -> ExpenseField -> Bool
Prelude.Eq, ReadPrec [ExpenseField]
ReadPrec ExpenseField
Int -> ReadS ExpenseField
ReadS [ExpenseField]
(Int -> ReadS ExpenseField)
-> ReadS [ExpenseField]
-> ReadPrec ExpenseField
-> ReadPrec [ExpenseField]
-> Read ExpenseField
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExpenseField]
$creadListPrec :: ReadPrec [ExpenseField]
readPrec :: ReadPrec ExpenseField
$creadPrec :: ReadPrec ExpenseField
readList :: ReadS [ExpenseField]
$creadList :: ReadS [ExpenseField]
readsPrec :: Int -> ReadS ExpenseField
$creadsPrec :: Int -> ReadS ExpenseField
Prelude.Read, Int -> ExpenseField -> ShowS
[ExpenseField] -> ShowS
ExpenseField -> String
(Int -> ExpenseField -> ShowS)
-> (ExpenseField -> String)
-> ([ExpenseField] -> ShowS)
-> Show ExpenseField
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExpenseField] -> ShowS
$cshowList :: [ExpenseField] -> ShowS
show :: ExpenseField -> String
$cshow :: ExpenseField -> String
showsPrec :: Int -> ExpenseField -> ShowS
$cshowsPrec :: Int -> ExpenseField -> ShowS
Prelude.Show, (forall x. ExpenseField -> Rep ExpenseField x)
-> (forall x. Rep ExpenseField x -> ExpenseField)
-> Generic ExpenseField
forall x. Rep ExpenseField x -> ExpenseField
forall x. ExpenseField -> Rep ExpenseField x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExpenseField x -> ExpenseField
$cfrom :: forall x. ExpenseField -> Rep ExpenseField x
Prelude.Generic)

-- |
-- Create a value of 'ExpenseField' 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:
--
-- 'labelDetection', 'expenseField_labelDetection' - The explicitly stated label of a detected element.
--
-- 'valueDetection', 'expenseField_valueDetection' - The value of a detected element. Present in explicit and implicit
-- elements.
--
-- 'type'', 'expenseField_type' - The implied label of a detected element. Present alongside
-- LabelDetection for explicit elements.
--
-- 'pageNumber', 'expenseField_pageNumber' - The page number the value was detected on.
newExpenseField ::
  ExpenseField
newExpenseField :: ExpenseField
newExpenseField =
  ExpenseField' :: Maybe ExpenseDetection
-> Maybe ExpenseDetection
-> Maybe ExpenseType
-> Maybe Natural
-> ExpenseField
ExpenseField'
    { $sel:labelDetection:ExpenseField' :: Maybe ExpenseDetection
labelDetection = Maybe ExpenseDetection
forall a. Maybe a
Prelude.Nothing,
      $sel:valueDetection:ExpenseField' :: Maybe ExpenseDetection
valueDetection = Maybe ExpenseDetection
forall a. Maybe a
Prelude.Nothing,
      $sel:type':ExpenseField' :: Maybe ExpenseType
type' = Maybe ExpenseType
forall a. Maybe a
Prelude.Nothing,
      $sel:pageNumber:ExpenseField' :: Maybe Natural
pageNumber = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The explicitly stated label of a detected element.
expenseField_labelDetection :: Lens.Lens' ExpenseField (Prelude.Maybe ExpenseDetection)
expenseField_labelDetection :: (Maybe ExpenseDetection -> f (Maybe ExpenseDetection))
-> ExpenseField -> f ExpenseField
expenseField_labelDetection = (ExpenseField -> Maybe ExpenseDetection)
-> (ExpenseField -> Maybe ExpenseDetection -> ExpenseField)
-> Lens
     ExpenseField
     ExpenseField
     (Maybe ExpenseDetection)
     (Maybe ExpenseDetection)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExpenseField' {Maybe ExpenseDetection
labelDetection :: Maybe ExpenseDetection
$sel:labelDetection:ExpenseField' :: ExpenseField -> Maybe ExpenseDetection
labelDetection} -> Maybe ExpenseDetection
labelDetection) (\s :: ExpenseField
s@ExpenseField' {} Maybe ExpenseDetection
a -> ExpenseField
s {$sel:labelDetection:ExpenseField' :: Maybe ExpenseDetection
labelDetection = Maybe ExpenseDetection
a} :: ExpenseField)

-- | The value of a detected element. Present in explicit and implicit
-- elements.
expenseField_valueDetection :: Lens.Lens' ExpenseField (Prelude.Maybe ExpenseDetection)
expenseField_valueDetection :: (Maybe ExpenseDetection -> f (Maybe ExpenseDetection))
-> ExpenseField -> f ExpenseField
expenseField_valueDetection = (ExpenseField -> Maybe ExpenseDetection)
-> (ExpenseField -> Maybe ExpenseDetection -> ExpenseField)
-> Lens
     ExpenseField
     ExpenseField
     (Maybe ExpenseDetection)
     (Maybe ExpenseDetection)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExpenseField' {Maybe ExpenseDetection
valueDetection :: Maybe ExpenseDetection
$sel:valueDetection:ExpenseField' :: ExpenseField -> Maybe ExpenseDetection
valueDetection} -> Maybe ExpenseDetection
valueDetection) (\s :: ExpenseField
s@ExpenseField' {} Maybe ExpenseDetection
a -> ExpenseField
s {$sel:valueDetection:ExpenseField' :: Maybe ExpenseDetection
valueDetection = Maybe ExpenseDetection
a} :: ExpenseField)

-- | The implied label of a detected element. Present alongside
-- LabelDetection for explicit elements.
expenseField_type :: Lens.Lens' ExpenseField (Prelude.Maybe ExpenseType)
expenseField_type :: (Maybe ExpenseType -> f (Maybe ExpenseType))
-> ExpenseField -> f ExpenseField
expenseField_type = (ExpenseField -> Maybe ExpenseType)
-> (ExpenseField -> Maybe ExpenseType -> ExpenseField)
-> Lens
     ExpenseField ExpenseField (Maybe ExpenseType) (Maybe ExpenseType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExpenseField' {Maybe ExpenseType
type' :: Maybe ExpenseType
$sel:type':ExpenseField' :: ExpenseField -> Maybe ExpenseType
type'} -> Maybe ExpenseType
type') (\s :: ExpenseField
s@ExpenseField' {} Maybe ExpenseType
a -> ExpenseField
s {$sel:type':ExpenseField' :: Maybe ExpenseType
type' = Maybe ExpenseType
a} :: ExpenseField)

-- | The page number the value was detected on.
expenseField_pageNumber :: Lens.Lens' ExpenseField (Prelude.Maybe Prelude.Natural)
expenseField_pageNumber :: (Maybe Natural -> f (Maybe Natural))
-> ExpenseField -> f ExpenseField
expenseField_pageNumber = (ExpenseField -> Maybe Natural)
-> (ExpenseField -> Maybe Natural -> ExpenseField)
-> Lens ExpenseField ExpenseField (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExpenseField' {Maybe Natural
pageNumber :: Maybe Natural
$sel:pageNumber:ExpenseField' :: ExpenseField -> Maybe Natural
pageNumber} -> Maybe Natural
pageNumber) (\s :: ExpenseField
s@ExpenseField' {} Maybe Natural
a -> ExpenseField
s {$sel:pageNumber:ExpenseField' :: Maybe Natural
pageNumber = Maybe Natural
a} :: ExpenseField)

instance Core.FromJSON ExpenseField where
  parseJSON :: Value -> Parser ExpenseField
parseJSON =
    String
-> (Object -> Parser ExpenseField) -> Value -> Parser ExpenseField
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExpenseField"
      ( \Object
x ->
          Maybe ExpenseDetection
-> Maybe ExpenseDetection
-> Maybe ExpenseType
-> Maybe Natural
-> ExpenseField
ExpenseField'
            (Maybe ExpenseDetection
 -> Maybe ExpenseDetection
 -> Maybe ExpenseType
 -> Maybe Natural
 -> ExpenseField)
-> Parser (Maybe ExpenseDetection)
-> Parser
     (Maybe ExpenseDetection
      -> Maybe ExpenseType -> Maybe Natural -> ExpenseField)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ExpenseDetection)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LabelDetection")
            Parser
  (Maybe ExpenseDetection
   -> Maybe ExpenseType -> Maybe Natural -> ExpenseField)
-> Parser (Maybe ExpenseDetection)
-> Parser (Maybe ExpenseType -> Maybe Natural -> ExpenseField)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ExpenseDetection)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ValueDetection")
            Parser (Maybe ExpenseType -> Maybe Natural -> ExpenseField)
-> Parser (Maybe ExpenseType)
-> Parser (Maybe Natural -> ExpenseField)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ExpenseType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe Natural -> ExpenseField)
-> Parser (Maybe Natural) -> Parser ExpenseField
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PageNumber")
      )

instance Prelude.Hashable ExpenseField

instance Prelude.NFData ExpenseField