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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 breakdown of information on a particular line of a table.
    LineItemGroup -> Maybe [LineItemFields]
lineItems :: Prelude.Maybe [LineItemFields],
    -- | 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
  }
  deriving (LineItemGroup -> LineItemGroup -> Bool
(LineItemGroup -> LineItemGroup -> Bool)
-> (LineItemGroup -> LineItemGroup -> Bool) -> Eq LineItemGroup
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]
(Int -> ReadS LineItemGroup)
-> ReadS [LineItemGroup]
-> ReadPrec LineItemGroup
-> ReadPrec [LineItemGroup]
-> Read 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
(Int -> LineItemGroup -> ShowS)
-> (LineItemGroup -> String)
-> ([LineItemGroup] -> ShowS)
-> Show LineItemGroup
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. LineItemGroup -> Rep LineItemGroup x)
-> (forall x. Rep LineItemGroup x -> LineItemGroup)
-> Generic LineItemGroup
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:
--
-- 'lineItems', 'lineItemGroup_lineItems' - The breakdown of information on a particular line of a table.
--
-- '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.
newLineItemGroup ::
  LineItemGroup
newLineItemGroup :: LineItemGroup
newLineItemGroup =
  LineItemGroup' :: Maybe [LineItemFields] -> Maybe Natural -> LineItemGroup
LineItemGroup'
    { $sel:lineItems:LineItemGroup' :: Maybe [LineItemFields]
lineItems = Maybe [LineItemFields]
forall a. Maybe a
Prelude.Nothing,
      $sel:lineItemGroupIndex:LineItemGroup' :: Maybe Natural
lineItemGroupIndex = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The breakdown of information on a particular line of a table.
lineItemGroup_lineItems :: Lens.Lens' LineItemGroup (Prelude.Maybe [LineItemFields])
lineItemGroup_lineItems :: (Maybe [LineItemFields] -> f (Maybe [LineItemFields]))
-> LineItemGroup -> f LineItemGroup
lineItemGroup_lineItems = (LineItemGroup -> Maybe [LineItemFields])
-> (LineItemGroup -> Maybe [LineItemFields] -> LineItemGroup)
-> Lens
     LineItemGroup
     LineItemGroup
     (Maybe [LineItemFields])
     (Maybe [LineItemFields])
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) ((Maybe [LineItemFields] -> f (Maybe [LineItemFields]))
 -> LineItemGroup -> f LineItemGroup)
-> ((Maybe [LineItemFields] -> f (Maybe [LineItemFields]))
    -> Maybe [LineItemFields] -> f (Maybe [LineItemFields]))
-> (Maybe [LineItemFields] -> f (Maybe [LineItemFields]))
-> LineItemGroup
-> f LineItemGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LineItemFields] [LineItemFields] [LineItemFields] [LineItemFields]
-> Iso
     (Maybe [LineItemFields])
     (Maybe [LineItemFields])
     (Maybe [LineItemFields])
     (Maybe [LineItemFields])
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 AnIso
  [LineItemFields] [LineItemFields] [LineItemFields] [LineItemFields]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> LineItemGroup -> f LineItemGroup
lineItemGroup_lineItemGroupIndex = (LineItemGroup -> Maybe Natural)
-> (LineItemGroup -> Maybe Natural -> LineItemGroup)
-> Lens LineItemGroup LineItemGroup (Maybe Natural) (Maybe Natural)
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)

instance Core.FromJSON LineItemGroup where
  parseJSON :: Value -> Parser LineItemGroup
parseJSON =
    String
-> (Object -> Parser LineItemGroup)
-> Value
-> Parser LineItemGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LineItemGroup"
      ( \Object
x ->
          Maybe [LineItemFields] -> Maybe Natural -> LineItemGroup
LineItemGroup'
            (Maybe [LineItemFields] -> Maybe Natural -> LineItemGroup)
-> Parser (Maybe [LineItemFields])
-> Parser (Maybe Natural -> LineItemGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [LineItemFields]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LineItems" Parser (Maybe (Maybe [LineItemFields]))
-> Maybe [LineItemFields] -> Parser (Maybe [LineItemFields])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [LineItemFields]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Natural -> LineItemGroup)
-> Parser (Maybe Natural) -> Parser LineItemGroup
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
"LineItemGroupIndex")
      )

instance Prelude.Hashable LineItemGroup

instance Prelude.NFData LineItemGroup