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

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

-- | Provides information about the configuration and other settings for all
-- the campaigns that are associated with an application.
--
-- /See:/ 'newCampaignsResponse' smart constructor.
data CampaignsResponse = CampaignsResponse'
  { -- | 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.
    CampaignsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of responses, one for each campaign that\'s associated with the
    -- application.
    CampaignsResponse -> [CampaignResponse]
item :: [CampaignResponse]
  }
  deriving (CampaignsResponse -> CampaignsResponse -> Bool
(CampaignsResponse -> CampaignsResponse -> Bool)
-> (CampaignsResponse -> CampaignsResponse -> Bool)
-> Eq CampaignsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CampaignsResponse -> CampaignsResponse -> Bool
$c/= :: CampaignsResponse -> CampaignsResponse -> Bool
== :: CampaignsResponse -> CampaignsResponse -> Bool
$c== :: CampaignsResponse -> CampaignsResponse -> Bool
Prelude.Eq, ReadPrec [CampaignsResponse]
ReadPrec CampaignsResponse
Int -> ReadS CampaignsResponse
ReadS [CampaignsResponse]
(Int -> ReadS CampaignsResponse)
-> ReadS [CampaignsResponse]
-> ReadPrec CampaignsResponse
-> ReadPrec [CampaignsResponse]
-> Read CampaignsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CampaignsResponse]
$creadListPrec :: ReadPrec [CampaignsResponse]
readPrec :: ReadPrec CampaignsResponse
$creadPrec :: ReadPrec CampaignsResponse
readList :: ReadS [CampaignsResponse]
$creadList :: ReadS [CampaignsResponse]
readsPrec :: Int -> ReadS CampaignsResponse
$creadsPrec :: Int -> ReadS CampaignsResponse
Prelude.Read, Int -> CampaignsResponse -> ShowS
[CampaignsResponse] -> ShowS
CampaignsResponse -> String
(Int -> CampaignsResponse -> ShowS)
-> (CampaignsResponse -> String)
-> ([CampaignsResponse] -> ShowS)
-> Show CampaignsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CampaignsResponse] -> ShowS
$cshowList :: [CampaignsResponse] -> ShowS
show :: CampaignsResponse -> String
$cshow :: CampaignsResponse -> String
showsPrec :: Int -> CampaignsResponse -> ShowS
$cshowsPrec :: Int -> CampaignsResponse -> ShowS
Prelude.Show, (forall x. CampaignsResponse -> Rep CampaignsResponse x)
-> (forall x. Rep CampaignsResponse x -> CampaignsResponse)
-> Generic CampaignsResponse
forall x. Rep CampaignsResponse x -> CampaignsResponse
forall x. CampaignsResponse -> Rep CampaignsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CampaignsResponse x -> CampaignsResponse
$cfrom :: forall x. CampaignsResponse -> Rep CampaignsResponse x
Prelude.Generic)

-- |
-- Create a value of 'CampaignsResponse' 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', 'campaignsResponse_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', 'campaignsResponse_item' - An array of responses, one for each campaign that\'s associated with the
-- application.
newCampaignsResponse ::
  CampaignsResponse
newCampaignsResponse :: CampaignsResponse
newCampaignsResponse =
  CampaignsResponse' :: Maybe Text -> [CampaignResponse] -> CampaignsResponse
CampaignsResponse'
    { $sel:nextToken:CampaignsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:item:CampaignsResponse' :: [CampaignResponse]
item = [CampaignResponse]
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.
campaignsResponse_nextToken :: Lens.Lens' CampaignsResponse (Prelude.Maybe Prelude.Text)
campaignsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> CampaignsResponse -> f CampaignsResponse
campaignsResponse_nextToken = (CampaignsResponse -> Maybe Text)
-> (CampaignsResponse -> Maybe Text -> CampaignsResponse)
-> Lens
     CampaignsResponse CampaignsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:CampaignsResponse' :: CampaignsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: CampaignsResponse
s@CampaignsResponse' {} Maybe Text
a -> CampaignsResponse
s {$sel:nextToken:CampaignsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: CampaignsResponse)

-- | An array of responses, one for each campaign that\'s associated with the
-- application.
campaignsResponse_item :: Lens.Lens' CampaignsResponse [CampaignResponse]
campaignsResponse_item :: ([CampaignResponse] -> f [CampaignResponse])
-> CampaignsResponse -> f CampaignsResponse
campaignsResponse_item = (CampaignsResponse -> [CampaignResponse])
-> (CampaignsResponse -> [CampaignResponse] -> CampaignsResponse)
-> Lens
     CampaignsResponse
     CampaignsResponse
     [CampaignResponse]
     [CampaignResponse]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignsResponse' {[CampaignResponse]
item :: [CampaignResponse]
$sel:item:CampaignsResponse' :: CampaignsResponse -> [CampaignResponse]
item} -> [CampaignResponse]
item) (\s :: CampaignsResponse
s@CampaignsResponse' {} [CampaignResponse]
a -> CampaignsResponse
s {$sel:item:CampaignsResponse' :: [CampaignResponse]
item = [CampaignResponse]
a} :: CampaignsResponse) (([CampaignResponse] -> f [CampaignResponse])
 -> CampaignsResponse -> f CampaignsResponse)
-> (([CampaignResponse] -> f [CampaignResponse])
    -> [CampaignResponse] -> f [CampaignResponse])
-> ([CampaignResponse] -> f [CampaignResponse])
-> CampaignsResponse
-> f CampaignsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([CampaignResponse] -> f [CampaignResponse])
-> [CampaignResponse] -> f [CampaignResponse]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable CampaignsResponse

instance Prelude.NFData CampaignsResponse