{-# 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.LineItemGroup
-- 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.LineItemGroup 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.LineItemFields

-- | A grouping of tables which contain LineItems, with each table identified
-- by the table\'s @LineItemGroupIndex@.
--
-- /See:/ 'newLineItemGroup' smart constructor.
data LineItemGroup = LineItemGroup'
  { -- | The number used to identify a specific table in a document. The first
    -- table encountered will have a LineItemGroupIndex of 1, the second 2,
    -- etc.
    LineItemGroup -> Maybe Natural
lineItemGroupIndex :: Prelude.Maybe Prelude.Natural,
    -- | The breakdown of information on a particular line of a table.
    LineItemGroup -> Maybe [LineItemFields]
lineItems :: Prelude.Maybe [LineItemFields]
  }
  deriving (LineItemGroup -> LineItemGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LineItemGroup -> LineItemGroup -> Bool
$c/= :: LineItemGroup -> LineItemGroup -> Bool
== :: LineItemGroup -> LineItemGroup -> Bool
$c== :: LineItemGroup -> LineItemGroup -> Bool
Prelude.Eq, ReadPrec [LineItemGroup]
ReadPrec LineItemGroup
Int -> ReadS LineItemGroup
ReadS [LineItemGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LineItemGroup]
$creadListPrec :: ReadPrec [LineItemGroup]
readPrec :: ReadPrec LineItemGroup
$creadPrec :: ReadPrec LineItemGroup
readList :: ReadS [LineItemGroup]
$creadList :: ReadS [LineItemGroup]
readsPrec :: Int -> ReadS LineItemGroup
$creadsPrec :: Int -> ReadS LineItemGroup
Prelude.Read, Int -> LineItemGroup -> ShowS
[LineItemGroup] -> ShowS
LineItemGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LineItemGroup] -> ShowS
$cshowList :: [LineItemGroup] -> ShowS
show :: LineItemGroup -> String
$cshow :: LineItemGroup -> String
showsPrec :: Int -> LineItemGroup -> ShowS
$cshowsPrec :: Int -> LineItemGroup -> ShowS
Prelude.Show, forall x. Rep LineItemGroup x -> LineItemGroup
forall x. LineItemGroup -> Rep LineItemGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LineItemGroup x -> LineItemGroup
$cfrom :: forall x. LineItemGroup -> Rep LineItemGroup x
Prelude.Generic)

-- |
-- Create a value of 'LineItemGroup' 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:
--
-- 'lineItemGroupIndex', 'lineItemGroup_lineItemGroupIndex' - The number used to identify a specific table in a document. The first
-- table encountered will have a LineItemGroupIndex of 1, the second 2,
-- etc.
--
-- 'lineItems', 'lineItemGroup_lineItems' - The breakdown of information on a particular line of a table.
newLineItemGroup ::
  LineItemGroup
newLineItemGroup :: LineItemGroup
newLineItemGroup =
  LineItemGroup'
    { $sel:lineItemGroupIndex:LineItemGroup' :: Maybe Natural
lineItemGroupIndex =
        forall a. Maybe a
Prelude.Nothing,
      $sel:lineItems:LineItemGroup' :: Maybe [LineItemFields]
lineItems = forall a. Maybe a
Prelude.Nothing
    }

-- | The number used to identify a specific table in a document. The first
-- table encountered will have a LineItemGroupIndex of 1, the second 2,
-- etc.
lineItemGroup_lineItemGroupIndex :: Lens.Lens' LineItemGroup (Prelude.Maybe Prelude.Natural)
lineItemGroup_lineItemGroupIndex :: Lens' LineItemGroup (Maybe Natural)
lineItemGroup_lineItemGroupIndex = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LineItemGroup' {Maybe Natural
lineItemGroupIndex :: Maybe Natural
$sel:lineItemGroupIndex:LineItemGroup' :: LineItemGroup -> Maybe Natural
lineItemGroupIndex} -> Maybe Natural
lineItemGroupIndex) (\s :: LineItemGroup
s@LineItemGroup' {} Maybe Natural
a -> LineItemGroup
s {$sel:lineItemGroupIndex:LineItemGroup' :: Maybe Natural
lineItemGroupIndex = Maybe Natural
a} :: LineItemGroup)

-- | The breakdown of information on a particular line of a table.
lineItemGroup_lineItems :: Lens.Lens' LineItemGroup (Prelude.Maybe [LineItemFields])
lineItemGroup_lineItems :: Lens' LineItemGroup (Maybe [LineItemFields])
lineItemGroup_lineItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LineItemGroup' {Maybe [LineItemFields]
lineItems :: Maybe [LineItemFields]
$sel:lineItems:LineItemGroup' :: LineItemGroup -> Maybe [LineItemFields]
lineItems} -> Maybe [LineItemFields]
lineItems) (\s :: LineItemGroup
s@LineItemGroup' {} Maybe [LineItemFields]
a -> LineItemGroup
s {$sel:lineItems:LineItemGroup' :: Maybe [LineItemFields]
lineItems = Maybe [LineItemFields]
a} :: LineItemGroup) 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 LineItemGroup where
  parseJSON :: Value -> Parser LineItemGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LineItemGroup"
      ( \Object
x ->
          Maybe Natural -> Maybe [LineItemFields] -> LineItemGroup
LineItemGroup'
            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
"LineItemGroupIndex")
            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
"LineItems" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable LineItemGroup where
  hashWithSalt :: Int -> LineItemGroup -> Int
hashWithSalt Int
_salt LineItemGroup' {Maybe Natural
Maybe [LineItemFields]
lineItems :: Maybe [LineItemFields]
lineItemGroupIndex :: Maybe Natural
$sel:lineItems:LineItemGroup' :: LineItemGroup -> Maybe [LineItemFields]
$sel:lineItemGroupIndex:LineItemGroup' :: LineItemGroup -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
lineItemGroupIndex
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [LineItemFields]
lineItems

instance Prelude.NFData LineItemGroup where
  rnf :: LineItemGroup -> ()
rnf LineItemGroup' {Maybe Natural
Maybe [LineItemFields]
lineItems :: Maybe [LineItemFields]
lineItemGroupIndex :: Maybe Natural
$sel:lineItems:LineItemGroup' :: LineItemGroup -> Maybe [LineItemFields]
$sel:lineItemGroupIndex:LineItemGroup' :: LineItemGroup -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
lineItemGroupIndex
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [LineItemFields]
lineItems