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

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

-- | Object to store union of different versions of layout content.
--
-- /See:/ 'newLayoutContent' smart constructor.
data LayoutContent = LayoutContent'
  { -- | Content specific to @BasicLayout@ type. It configures fields in the top
    -- panel and More Info tab of Cases user interface.
    LayoutContent -> Maybe BasicLayout
basic :: Prelude.Maybe BasicLayout
  }
  deriving (LayoutContent -> LayoutContent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LayoutContent -> LayoutContent -> Bool
$c/= :: LayoutContent -> LayoutContent -> Bool
== :: LayoutContent -> LayoutContent -> Bool
$c== :: LayoutContent -> LayoutContent -> Bool
Prelude.Eq, ReadPrec [LayoutContent]
ReadPrec LayoutContent
Int -> ReadS LayoutContent
ReadS [LayoutContent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LayoutContent]
$creadListPrec :: ReadPrec [LayoutContent]
readPrec :: ReadPrec LayoutContent
$creadPrec :: ReadPrec LayoutContent
readList :: ReadS [LayoutContent]
$creadList :: ReadS [LayoutContent]
readsPrec :: Int -> ReadS LayoutContent
$creadsPrec :: Int -> ReadS LayoutContent
Prelude.Read, Int -> LayoutContent -> ShowS
[LayoutContent] -> ShowS
LayoutContent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LayoutContent] -> ShowS
$cshowList :: [LayoutContent] -> ShowS
show :: LayoutContent -> String
$cshow :: LayoutContent -> String
showsPrec :: Int -> LayoutContent -> ShowS
$cshowsPrec :: Int -> LayoutContent -> ShowS
Prelude.Show, forall x. Rep LayoutContent x -> LayoutContent
forall x. LayoutContent -> Rep LayoutContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LayoutContent x -> LayoutContent
$cfrom :: forall x. LayoutContent -> Rep LayoutContent x
Prelude.Generic)

-- |
-- Create a value of 'LayoutContent' 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:
--
-- 'basic', 'layoutContent_basic' - Content specific to @BasicLayout@ type. It configures fields in the top
-- panel and More Info tab of Cases user interface.
newLayoutContent ::
  LayoutContent
newLayoutContent :: LayoutContent
newLayoutContent =
  LayoutContent' {$sel:basic:LayoutContent' :: Maybe BasicLayout
basic = forall a. Maybe a
Prelude.Nothing}

-- | Content specific to @BasicLayout@ type. It configures fields in the top
-- panel and More Info tab of Cases user interface.
layoutContent_basic :: Lens.Lens' LayoutContent (Prelude.Maybe BasicLayout)
layoutContent_basic :: Lens' LayoutContent (Maybe BasicLayout)
layoutContent_basic = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LayoutContent' {Maybe BasicLayout
basic :: Maybe BasicLayout
$sel:basic:LayoutContent' :: LayoutContent -> Maybe BasicLayout
basic} -> Maybe BasicLayout
basic) (\s :: LayoutContent
s@LayoutContent' {} Maybe BasicLayout
a -> LayoutContent
s {$sel:basic:LayoutContent' :: Maybe BasicLayout
basic = Maybe BasicLayout
a} :: LayoutContent)

instance Data.FromJSON LayoutContent where
  parseJSON :: Value -> Parser LayoutContent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LayoutContent"
      ( \Object
x ->
          Maybe BasicLayout -> LayoutContent
LayoutContent' 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
"basic")
      )

instance Prelude.Hashable LayoutContent where
  hashWithSalt :: Int -> LayoutContent -> Int
hashWithSalt Int
_salt LayoutContent' {Maybe BasicLayout
basic :: Maybe BasicLayout
$sel:basic:LayoutContent' :: LayoutContent -> Maybe BasicLayout
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BasicLayout
basic

instance Prelude.NFData LayoutContent where
  rnf :: LayoutContent -> ()
rnf LayoutContent' {Maybe BasicLayout
basic :: Maybe BasicLayout
$sel:basic:LayoutContent' :: LayoutContent -> Maybe BasicLayout
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe BasicLayout
basic

instance Data.ToJSON LayoutContent where
  toJSON :: LayoutContent -> Value
toJSON LayoutContent' {Maybe BasicLayout
basic :: Maybe BasicLayout
$sel:basic:LayoutContent' :: LayoutContent -> Maybe BasicLayout
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"basic" 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 BasicLayout
basic]
      )