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

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

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

-- |
-- Create a value of 'JourneysResponse' 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', 'journeysResponse_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', 'journeysResponse_item' - An array of responses, one for each journey that\'s associated with the
-- application.
newJourneysResponse ::
  JourneysResponse
newJourneysResponse :: JourneysResponse
newJourneysResponse =
  JourneysResponse' :: Maybe Text -> [JourneyResponse] -> JourneysResponse
JourneysResponse'
    { $sel:nextToken:JourneysResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:item:JourneysResponse' :: [JourneyResponse]
item = [JourneyResponse]
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.
journeysResponse_nextToken :: Lens.Lens' JourneysResponse (Prelude.Maybe Prelude.Text)
journeysResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> JourneysResponse -> f JourneysResponse
journeysResponse_nextToken = (JourneysResponse -> Maybe Text)
-> (JourneysResponse -> Maybe Text -> JourneysResponse)
-> Lens JourneysResponse JourneysResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneysResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:JourneysResponse' :: JourneysResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: JourneysResponse
s@JourneysResponse' {} Maybe Text
a -> JourneysResponse
s {$sel:nextToken:JourneysResponse' :: Maybe Text
nextToken = Maybe Text
a} :: JourneysResponse)

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

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

instance Prelude.Hashable JourneysResponse

instance Prelude.NFData JourneysResponse