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

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

-- | Provides information about the activities that were performed by a
-- campaign.
--
-- /See:/ 'newActivitiesResponse' smart constructor.
data ActivitiesResponse = ActivitiesResponse'
  { -- | 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.
    ActivitiesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of responses, one for each activity that was performed by the
    -- campaign.
    ActivitiesResponse -> [ActivityResponse]
item :: [ActivityResponse]
  }
  deriving (ActivitiesResponse -> ActivitiesResponse -> Bool
(ActivitiesResponse -> ActivitiesResponse -> Bool)
-> (ActivitiesResponse -> ActivitiesResponse -> Bool)
-> Eq ActivitiesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActivitiesResponse -> ActivitiesResponse -> Bool
$c/= :: ActivitiesResponse -> ActivitiesResponse -> Bool
== :: ActivitiesResponse -> ActivitiesResponse -> Bool
$c== :: ActivitiesResponse -> ActivitiesResponse -> Bool
Prelude.Eq, ReadPrec [ActivitiesResponse]
ReadPrec ActivitiesResponse
Int -> ReadS ActivitiesResponse
ReadS [ActivitiesResponse]
(Int -> ReadS ActivitiesResponse)
-> ReadS [ActivitiesResponse]
-> ReadPrec ActivitiesResponse
-> ReadPrec [ActivitiesResponse]
-> Read ActivitiesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActivitiesResponse]
$creadListPrec :: ReadPrec [ActivitiesResponse]
readPrec :: ReadPrec ActivitiesResponse
$creadPrec :: ReadPrec ActivitiesResponse
readList :: ReadS [ActivitiesResponse]
$creadList :: ReadS [ActivitiesResponse]
readsPrec :: Int -> ReadS ActivitiesResponse
$creadsPrec :: Int -> ReadS ActivitiesResponse
Prelude.Read, Int -> ActivitiesResponse -> ShowS
[ActivitiesResponse] -> ShowS
ActivitiesResponse -> String
(Int -> ActivitiesResponse -> ShowS)
-> (ActivitiesResponse -> String)
-> ([ActivitiesResponse] -> ShowS)
-> Show ActivitiesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActivitiesResponse] -> ShowS
$cshowList :: [ActivitiesResponse] -> ShowS
show :: ActivitiesResponse -> String
$cshow :: ActivitiesResponse -> String
showsPrec :: Int -> ActivitiesResponse -> ShowS
$cshowsPrec :: Int -> ActivitiesResponse -> ShowS
Prelude.Show, (forall x. ActivitiesResponse -> Rep ActivitiesResponse x)
-> (forall x. Rep ActivitiesResponse x -> ActivitiesResponse)
-> Generic ActivitiesResponse
forall x. Rep ActivitiesResponse x -> ActivitiesResponse
forall x. ActivitiesResponse -> Rep ActivitiesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActivitiesResponse x -> ActivitiesResponse
$cfrom :: forall x. ActivitiesResponse -> Rep ActivitiesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ActivitiesResponse' 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', 'activitiesResponse_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', 'activitiesResponse_item' - An array of responses, one for each activity that was performed by the
-- campaign.
newActivitiesResponse ::
  ActivitiesResponse
newActivitiesResponse :: ActivitiesResponse
newActivitiesResponse =
  ActivitiesResponse' :: Maybe Text -> [ActivityResponse] -> ActivitiesResponse
ActivitiesResponse'
    { $sel:nextToken:ActivitiesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:item:ActivitiesResponse' :: [ActivityResponse]
item = [ActivityResponse]
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.
activitiesResponse_nextToken :: Lens.Lens' ActivitiesResponse (Prelude.Maybe Prelude.Text)
activitiesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ActivitiesResponse -> f ActivitiesResponse
activitiesResponse_nextToken = (ActivitiesResponse -> Maybe Text)
-> (ActivitiesResponse -> Maybe Text -> ActivitiesResponse)
-> Lens
     ActivitiesResponse ActivitiesResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivitiesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ActivitiesResponse' :: ActivitiesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ActivitiesResponse
s@ActivitiesResponse' {} Maybe Text
a -> ActivitiesResponse
s {$sel:nextToken:ActivitiesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ActivitiesResponse)

-- | An array of responses, one for each activity that was performed by the
-- campaign.
activitiesResponse_item :: Lens.Lens' ActivitiesResponse [ActivityResponse]
activitiesResponse_item :: ([ActivityResponse] -> f [ActivityResponse])
-> ActivitiesResponse -> f ActivitiesResponse
activitiesResponse_item = (ActivitiesResponse -> [ActivityResponse])
-> (ActivitiesResponse -> [ActivityResponse] -> ActivitiesResponse)
-> Lens
     ActivitiesResponse
     ActivitiesResponse
     [ActivityResponse]
     [ActivityResponse]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivitiesResponse' {[ActivityResponse]
item :: [ActivityResponse]
$sel:item:ActivitiesResponse' :: ActivitiesResponse -> [ActivityResponse]
item} -> [ActivityResponse]
item) (\s :: ActivitiesResponse
s@ActivitiesResponse' {} [ActivityResponse]
a -> ActivitiesResponse
s {$sel:item:ActivitiesResponse' :: [ActivityResponse]
item = [ActivityResponse]
a} :: ActivitiesResponse) (([ActivityResponse] -> f [ActivityResponse])
 -> ActivitiesResponse -> f ActivitiesResponse)
-> (([ActivityResponse] -> f [ActivityResponse])
    -> [ActivityResponse] -> f [ActivityResponse])
-> ([ActivityResponse] -> f [ActivityResponse])
-> ActivitiesResponse
-> f ActivitiesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ActivityResponse] -> f [ActivityResponse])
-> [ActivityResponse] -> f [ActivityResponse]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ActivitiesResponse

instance Prelude.NFData ActivitiesResponse