{-# 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.ConnectCases.Types.LayoutSections
-- 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.ConnectCases.Types.LayoutSections where

import Amazonka.ConnectCases.Types.Section
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

-- | Ordered list containing different kinds of sections that can be added. A
-- LayoutSections object can only contain one section.
--
-- /See:/ 'newLayoutSections' smart constructor.
data LayoutSections = LayoutSections'
  { LayoutSections -> Maybe [Section]
sections :: Prelude.Maybe [Section]
  }
  deriving (LayoutSections -> LayoutSections -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LayoutSections -> LayoutSections -> Bool
$c/= :: LayoutSections -> LayoutSections -> Bool
== :: LayoutSections -> LayoutSections -> Bool
$c== :: LayoutSections -> LayoutSections -> Bool
Prelude.Eq, ReadPrec [LayoutSections]
ReadPrec LayoutSections
Int -> ReadS LayoutSections
ReadS [LayoutSections]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LayoutSections]
$creadListPrec :: ReadPrec [LayoutSections]
readPrec :: ReadPrec LayoutSections
$creadPrec :: ReadPrec LayoutSections
readList :: ReadS [LayoutSections]
$creadList :: ReadS [LayoutSections]
readsPrec :: Int -> ReadS LayoutSections
$creadsPrec :: Int -> ReadS LayoutSections
Prelude.Read, Int -> LayoutSections -> ShowS
[LayoutSections] -> ShowS
LayoutSections -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LayoutSections] -> ShowS
$cshowList :: [LayoutSections] -> ShowS
show :: LayoutSections -> String
$cshow :: LayoutSections -> String
showsPrec :: Int -> LayoutSections -> ShowS
$cshowsPrec :: Int -> LayoutSections -> ShowS
Prelude.Show, forall x. Rep LayoutSections x -> LayoutSections
forall x. LayoutSections -> Rep LayoutSections x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LayoutSections x -> LayoutSections
$cfrom :: forall x. LayoutSections -> Rep LayoutSections x
Prelude.Generic)

-- |
-- Create a value of 'LayoutSections' 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:
--
-- 'sections', 'layoutSections_sections' - Undocumented member.
newLayoutSections ::
  LayoutSections
newLayoutSections :: LayoutSections
newLayoutSections =
  LayoutSections' {$sel:sections:LayoutSections' :: Maybe [Section]
sections = forall a. Maybe a
Prelude.Nothing}

-- | Undocumented member.
layoutSections_sections :: Lens.Lens' LayoutSections (Prelude.Maybe [Section])
layoutSections_sections :: Lens' LayoutSections (Maybe [Section])
layoutSections_sections = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LayoutSections' {Maybe [Section]
sections :: Maybe [Section]
$sel:sections:LayoutSections' :: LayoutSections -> Maybe [Section]
sections} -> Maybe [Section]
sections) (\s :: LayoutSections
s@LayoutSections' {} Maybe [Section]
a -> LayoutSections
s {$sel:sections:LayoutSections' :: Maybe [Section]
sections = Maybe [Section]
a} :: LayoutSections) 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 LayoutSections where
  parseJSON :: Value -> Parser LayoutSections
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LayoutSections"
      ( \Object
x ->
          Maybe [Section] -> LayoutSections
LayoutSections'
            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
"sections" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable LayoutSections where
  hashWithSalt :: Int -> LayoutSections -> Int
hashWithSalt Int
_salt LayoutSections' {Maybe [Section]
sections :: Maybe [Section]
$sel:sections:LayoutSections' :: LayoutSections -> Maybe [Section]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Section]
sections

instance Prelude.NFData LayoutSections where
  rnf :: LayoutSections -> ()
rnf LayoutSections' {Maybe [Section]
sections :: Maybe [Section]
$sel:sections:LayoutSections' :: LayoutSections -> Maybe [Section]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [Section]
sections

instance Data.ToJSON LayoutSections where
  toJSON :: LayoutSections -> Value
toJSON LayoutSections' {Maybe [Section]
sections :: Maybe [Section]
$sel:sections:LayoutSections' :: LayoutSections -> Maybe [Section]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"sections" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Section]
sections]
      )