{-# 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.Pinpoint.Types.TemplatesResponse
-- 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.Pinpoint.Types.TemplatesResponse where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.TemplateResponse
import qualified Amazonka.Prelude as Prelude

-- | Provides information about all the message templates that are associated
-- with your Amazon Pinpoint account.
--
-- /See:/ 'newTemplatesResponse' smart constructor.
data TemplatesResponse = TemplatesResponse'
  { -- | The string to use in a subsequent request to get the next page of
    -- results in a paginated response. This value is null if there are no
    -- additional pages.
    TemplatesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of responses, one for each message template that\'s associated
    -- with your Amazon Pinpoint account and meets any filter criteria that you
    -- specified in the request.
    TemplatesResponse -> [TemplateResponse]
item :: [TemplateResponse]
  }
  deriving (TemplatesResponse -> TemplatesResponse -> Bool
(TemplatesResponse -> TemplatesResponse -> Bool)
-> (TemplatesResponse -> TemplatesResponse -> Bool)
-> Eq TemplatesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TemplatesResponse -> TemplatesResponse -> Bool
$c/= :: TemplatesResponse -> TemplatesResponse -> Bool
== :: TemplatesResponse -> TemplatesResponse -> Bool
$c== :: TemplatesResponse -> TemplatesResponse -> Bool
Prelude.Eq, ReadPrec [TemplatesResponse]
ReadPrec TemplatesResponse
Int -> ReadS TemplatesResponse
ReadS [TemplatesResponse]
(Int -> ReadS TemplatesResponse)
-> ReadS [TemplatesResponse]
-> ReadPrec TemplatesResponse
-> ReadPrec [TemplatesResponse]
-> Read TemplatesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TemplatesResponse]
$creadListPrec :: ReadPrec [TemplatesResponse]
readPrec :: ReadPrec TemplatesResponse
$creadPrec :: ReadPrec TemplatesResponse
readList :: ReadS [TemplatesResponse]
$creadList :: ReadS [TemplatesResponse]
readsPrec :: Int -> ReadS TemplatesResponse
$creadsPrec :: Int -> ReadS TemplatesResponse
Prelude.Read, Int -> TemplatesResponse -> ShowS
[TemplatesResponse] -> ShowS
TemplatesResponse -> String
(Int -> TemplatesResponse -> ShowS)
-> (TemplatesResponse -> String)
-> ([TemplatesResponse] -> ShowS)
-> Show TemplatesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TemplatesResponse] -> ShowS
$cshowList :: [TemplatesResponse] -> ShowS
show :: TemplatesResponse -> String
$cshow :: TemplatesResponse -> String
showsPrec :: Int -> TemplatesResponse -> ShowS
$cshowsPrec :: Int -> TemplatesResponse -> ShowS
Prelude.Show, (forall x. TemplatesResponse -> Rep TemplatesResponse x)
-> (forall x. Rep TemplatesResponse x -> TemplatesResponse)
-> Generic TemplatesResponse
forall x. Rep TemplatesResponse x -> TemplatesResponse
forall x. TemplatesResponse -> Rep TemplatesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TemplatesResponse x -> TemplatesResponse
$cfrom :: forall x. TemplatesResponse -> Rep TemplatesResponse x
Prelude.Generic)

-- |
-- Create a value of 'TemplatesResponse' 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', 'templatesResponse_nextToken' - The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
--
-- 'item', 'templatesResponse_item' - An array of responses, one for each message template that\'s associated
-- with your Amazon Pinpoint account and meets any filter criteria that you
-- specified in the request.
newTemplatesResponse ::
  TemplatesResponse
newTemplatesResponse :: TemplatesResponse
newTemplatesResponse =
  TemplatesResponse' :: Maybe Text -> [TemplateResponse] -> TemplatesResponse
TemplatesResponse'
    { $sel:nextToken:TemplatesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:item:TemplatesResponse' :: [TemplateResponse]
item = [TemplateResponse]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The string to use in a subsequent request to get the next page of
-- results in a paginated response. This value is null if there are no
-- additional pages.
templatesResponse_nextToken :: Lens.Lens' TemplatesResponse (Prelude.Maybe Prelude.Text)
templatesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> TemplatesResponse -> f TemplatesResponse
templatesResponse_nextToken = (TemplatesResponse -> Maybe Text)
-> (TemplatesResponse -> Maybe Text -> TemplatesResponse)
-> Lens
     TemplatesResponse TemplatesResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplatesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:TemplatesResponse' :: TemplatesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: TemplatesResponse
s@TemplatesResponse' {} Maybe Text
a -> TemplatesResponse
s {$sel:nextToken:TemplatesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: TemplatesResponse)

-- | An array of responses, one for each message template that\'s associated
-- with your Amazon Pinpoint account and meets any filter criteria that you
-- specified in the request.
templatesResponse_item :: Lens.Lens' TemplatesResponse [TemplateResponse]
templatesResponse_item :: ([TemplateResponse] -> f [TemplateResponse])
-> TemplatesResponse -> f TemplatesResponse
templatesResponse_item = (TemplatesResponse -> [TemplateResponse])
-> (TemplatesResponse -> [TemplateResponse] -> TemplatesResponse)
-> Lens
     TemplatesResponse
     TemplatesResponse
     [TemplateResponse]
     [TemplateResponse]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplatesResponse' {[TemplateResponse]
item :: [TemplateResponse]
$sel:item:TemplatesResponse' :: TemplatesResponse -> [TemplateResponse]
item} -> [TemplateResponse]
item) (\s :: TemplatesResponse
s@TemplatesResponse' {} [TemplateResponse]
a -> TemplatesResponse
s {$sel:item:TemplatesResponse' :: [TemplateResponse]
item = [TemplateResponse]
a} :: TemplatesResponse) (([TemplateResponse] -> f [TemplateResponse])
 -> TemplatesResponse -> f TemplatesResponse)
-> (([TemplateResponse] -> f [TemplateResponse])
    -> [TemplateResponse] -> f [TemplateResponse])
-> ([TemplateResponse] -> f [TemplateResponse])
-> TemplatesResponse
-> f TemplatesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TemplateResponse] -> f [TemplateResponse])
-> [TemplateResponse] -> f [TemplateResponse]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON TemplatesResponse where
  parseJSON :: Value -> Parser TemplatesResponse
parseJSON =
    String
-> (Object -> Parser TemplatesResponse)
-> Value
-> Parser TemplatesResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TemplatesResponse"
      ( \Object
x ->
          Maybe Text -> [TemplateResponse] -> TemplatesResponse
TemplatesResponse'
            (Maybe Text -> [TemplateResponse] -> TemplatesResponse)
-> Parser (Maybe Text)
-> Parser ([TemplateResponse] -> TemplatesResponse)
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 ([TemplateResponse] -> TemplatesResponse)
-> Parser [TemplateResponse] -> Parser TemplatesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [TemplateResponse])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Item" Parser (Maybe [TemplateResponse])
-> [TemplateResponse] -> Parser [TemplateResponse]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [TemplateResponse]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TemplatesResponse

instance Prelude.NFData TemplatesResponse