{-# 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.Support.Types.RecentCaseCommunications
-- 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.Support.Types.RecentCaseCommunications where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Support.Types.Communication

-- | The five most recent communications associated with the case.
--
-- /See:/ 'newRecentCaseCommunications' smart constructor.
data RecentCaseCommunications = RecentCaseCommunications'
  { -- | A resumption point for pagination.
    RecentCaseCommunications -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The five most recent communications associated with the case.
    RecentCaseCommunications -> Maybe [Communication]
communications :: Prelude.Maybe [Communication]
  }
  deriving (RecentCaseCommunications -> RecentCaseCommunications -> Bool
(RecentCaseCommunications -> RecentCaseCommunications -> Bool)
-> (RecentCaseCommunications -> RecentCaseCommunications -> Bool)
-> Eq RecentCaseCommunications
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecentCaseCommunications -> RecentCaseCommunications -> Bool
$c/= :: RecentCaseCommunications -> RecentCaseCommunications -> Bool
== :: RecentCaseCommunications -> RecentCaseCommunications -> Bool
$c== :: RecentCaseCommunications -> RecentCaseCommunications -> Bool
Prelude.Eq, ReadPrec [RecentCaseCommunications]
ReadPrec RecentCaseCommunications
Int -> ReadS RecentCaseCommunications
ReadS [RecentCaseCommunications]
(Int -> ReadS RecentCaseCommunications)
-> ReadS [RecentCaseCommunications]
-> ReadPrec RecentCaseCommunications
-> ReadPrec [RecentCaseCommunications]
-> Read RecentCaseCommunications
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecentCaseCommunications]
$creadListPrec :: ReadPrec [RecentCaseCommunications]
readPrec :: ReadPrec RecentCaseCommunications
$creadPrec :: ReadPrec RecentCaseCommunications
readList :: ReadS [RecentCaseCommunications]
$creadList :: ReadS [RecentCaseCommunications]
readsPrec :: Int -> ReadS RecentCaseCommunications
$creadsPrec :: Int -> ReadS RecentCaseCommunications
Prelude.Read, Int -> RecentCaseCommunications -> ShowS
[RecentCaseCommunications] -> ShowS
RecentCaseCommunications -> String
(Int -> RecentCaseCommunications -> ShowS)
-> (RecentCaseCommunications -> String)
-> ([RecentCaseCommunications] -> ShowS)
-> Show RecentCaseCommunications
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecentCaseCommunications] -> ShowS
$cshowList :: [RecentCaseCommunications] -> ShowS
show :: RecentCaseCommunications -> String
$cshow :: RecentCaseCommunications -> String
showsPrec :: Int -> RecentCaseCommunications -> ShowS
$cshowsPrec :: Int -> RecentCaseCommunications -> ShowS
Prelude.Show, (forall x.
 RecentCaseCommunications -> Rep RecentCaseCommunications x)
-> (forall x.
    Rep RecentCaseCommunications x -> RecentCaseCommunications)
-> Generic RecentCaseCommunications
forall x.
Rep RecentCaseCommunications x -> RecentCaseCommunications
forall x.
RecentCaseCommunications -> Rep RecentCaseCommunications x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RecentCaseCommunications x -> RecentCaseCommunications
$cfrom :: forall x.
RecentCaseCommunications -> Rep RecentCaseCommunications x
Prelude.Generic)

-- |
-- Create a value of 'RecentCaseCommunications' 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:
--
-- 'nextToken', 'recentCaseCommunications_nextToken' - A resumption point for pagination.
--
-- 'communications', 'recentCaseCommunications_communications' - The five most recent communications associated with the case.
newRecentCaseCommunications ::
  RecentCaseCommunications
newRecentCaseCommunications :: RecentCaseCommunications
newRecentCaseCommunications =
  RecentCaseCommunications' :: Maybe Text -> Maybe [Communication] -> RecentCaseCommunications
RecentCaseCommunications'
    { $sel:nextToken:RecentCaseCommunications' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:communications:RecentCaseCommunications' :: Maybe [Communication]
communications = Maybe [Communication]
forall a. Maybe a
Prelude.Nothing
    }

-- | A resumption point for pagination.
recentCaseCommunications_nextToken :: Lens.Lens' RecentCaseCommunications (Prelude.Maybe Prelude.Text)
recentCaseCommunications_nextToken :: (Maybe Text -> f (Maybe Text))
-> RecentCaseCommunications -> f RecentCaseCommunications
recentCaseCommunications_nextToken = (RecentCaseCommunications -> Maybe Text)
-> (RecentCaseCommunications
    -> Maybe Text -> RecentCaseCommunications)
-> Lens
     RecentCaseCommunications
     RecentCaseCommunications
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecentCaseCommunications' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:RecentCaseCommunications' :: RecentCaseCommunications -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: RecentCaseCommunications
s@RecentCaseCommunications' {} Maybe Text
a -> RecentCaseCommunications
s {$sel:nextToken:RecentCaseCommunications' :: Maybe Text
nextToken = Maybe Text
a} :: RecentCaseCommunications)

-- | The five most recent communications associated with the case.
recentCaseCommunications_communications :: Lens.Lens' RecentCaseCommunications (Prelude.Maybe [Communication])
recentCaseCommunications_communications :: (Maybe [Communication] -> f (Maybe [Communication]))
-> RecentCaseCommunications -> f RecentCaseCommunications
recentCaseCommunications_communications = (RecentCaseCommunications -> Maybe [Communication])
-> (RecentCaseCommunications
    -> Maybe [Communication] -> RecentCaseCommunications)
-> Lens
     RecentCaseCommunications
     RecentCaseCommunications
     (Maybe [Communication])
     (Maybe [Communication])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecentCaseCommunications' {Maybe [Communication]
communications :: Maybe [Communication]
$sel:communications:RecentCaseCommunications' :: RecentCaseCommunications -> Maybe [Communication]
communications} -> Maybe [Communication]
communications) (\s :: RecentCaseCommunications
s@RecentCaseCommunications' {} Maybe [Communication]
a -> RecentCaseCommunications
s {$sel:communications:RecentCaseCommunications' :: Maybe [Communication]
communications = Maybe [Communication]
a} :: RecentCaseCommunications) ((Maybe [Communication] -> f (Maybe [Communication]))
 -> RecentCaseCommunications -> f RecentCaseCommunications)
-> ((Maybe [Communication] -> f (Maybe [Communication]))
    -> Maybe [Communication] -> f (Maybe [Communication]))
-> (Maybe [Communication] -> f (Maybe [Communication]))
-> RecentCaseCommunications
-> f RecentCaseCommunications
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [Communication] [Communication] [Communication] [Communication]
-> Iso
     (Maybe [Communication])
     (Maybe [Communication])
     (Maybe [Communication])
     (Maybe [Communication])
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
  [Communication] [Communication] [Communication] [Communication]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON RecentCaseCommunications where
  parseJSON :: Value -> Parser RecentCaseCommunications
parseJSON =
    String
-> (Object -> Parser RecentCaseCommunications)
-> Value
-> Parser RecentCaseCommunications
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RecentCaseCommunications"
      ( \Object
x ->
          Maybe Text -> Maybe [Communication] -> RecentCaseCommunications
RecentCaseCommunications'
            (Maybe Text -> Maybe [Communication] -> RecentCaseCommunications)
-> Parser (Maybe Text)
-> Parser (Maybe [Communication] -> RecentCaseCommunications)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"nextToken")
            Parser (Maybe [Communication] -> RecentCaseCommunications)
-> Parser (Maybe [Communication])
-> Parser RecentCaseCommunications
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Communication]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"communications"
                            Parser (Maybe (Maybe [Communication]))
-> Maybe [Communication] -> Parser (Maybe [Communication])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Communication]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable RecentCaseCommunications

instance Prelude.NFData RecentCaseCommunications