{-# 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.RandomSplitEntry
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pinpoint.Types.RandomSplitEntry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Specifies the settings for a path in a random split activity in a
-- journey.
--
-- /See:/ 'newRandomSplitEntry' smart constructor.
data RandomSplitEntry = RandomSplitEntry'
  { -- | The unique identifier for the next activity to perform, after completing
    -- the activity for the path.
    RandomSplitEntry -> Maybe Text
nextActivity :: Prelude.Maybe Prelude.Text,
    -- | The percentage of participants to send down the activity path.
    --
    -- To determine which participants are sent down each path, Amazon Pinpoint
    -- applies a probability-based algorithm to the percentages that you
    -- specify for the paths. Therefore, the actual percentage of participants
    -- who are sent down a path may not be equal to the percentage that you
    -- specify.
    RandomSplitEntry -> Maybe Int
percentage :: Prelude.Maybe Prelude.Int
  }
  deriving (RandomSplitEntry -> RandomSplitEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RandomSplitEntry -> RandomSplitEntry -> Bool
$c/= :: RandomSplitEntry -> RandomSplitEntry -> Bool
== :: RandomSplitEntry -> RandomSplitEntry -> Bool
$c== :: RandomSplitEntry -> RandomSplitEntry -> Bool
Prelude.Eq, ReadPrec [RandomSplitEntry]
ReadPrec RandomSplitEntry
Int -> ReadS RandomSplitEntry
ReadS [RandomSplitEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RandomSplitEntry]
$creadListPrec :: ReadPrec [RandomSplitEntry]
readPrec :: ReadPrec RandomSplitEntry
$creadPrec :: ReadPrec RandomSplitEntry
readList :: ReadS [RandomSplitEntry]
$creadList :: ReadS [RandomSplitEntry]
readsPrec :: Int -> ReadS RandomSplitEntry
$creadsPrec :: Int -> ReadS RandomSplitEntry
Prelude.Read, Int -> RandomSplitEntry -> ShowS
[RandomSplitEntry] -> ShowS
RandomSplitEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RandomSplitEntry] -> ShowS
$cshowList :: [RandomSplitEntry] -> ShowS
show :: RandomSplitEntry -> String
$cshow :: RandomSplitEntry -> String
showsPrec :: Int -> RandomSplitEntry -> ShowS
$cshowsPrec :: Int -> RandomSplitEntry -> ShowS
Prelude.Show, forall x. Rep RandomSplitEntry x -> RandomSplitEntry
forall x. RandomSplitEntry -> Rep RandomSplitEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RandomSplitEntry x -> RandomSplitEntry
$cfrom :: forall x. RandomSplitEntry -> Rep RandomSplitEntry x
Prelude.Generic)

-- |
-- Create a value of 'RandomSplitEntry' 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:
--
-- 'nextActivity', 'randomSplitEntry_nextActivity' - The unique identifier for the next activity to perform, after completing
-- the activity for the path.
--
-- 'percentage', 'randomSplitEntry_percentage' - The percentage of participants to send down the activity path.
--
-- To determine which participants are sent down each path, Amazon Pinpoint
-- applies a probability-based algorithm to the percentages that you
-- specify for the paths. Therefore, the actual percentage of participants
-- who are sent down a path may not be equal to the percentage that you
-- specify.
newRandomSplitEntry ::
  RandomSplitEntry
newRandomSplitEntry :: RandomSplitEntry
newRandomSplitEntry =
  RandomSplitEntry'
    { $sel:nextActivity:RandomSplitEntry' :: Maybe Text
nextActivity = forall a. Maybe a
Prelude.Nothing,
      $sel:percentage:RandomSplitEntry' :: Maybe Int
percentage = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the next activity to perform, after completing
-- the activity for the path.
randomSplitEntry_nextActivity :: Lens.Lens' RandomSplitEntry (Prelude.Maybe Prelude.Text)
randomSplitEntry_nextActivity :: Lens' RandomSplitEntry (Maybe Text)
randomSplitEntry_nextActivity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RandomSplitEntry' {Maybe Text
nextActivity :: Maybe Text
$sel:nextActivity:RandomSplitEntry' :: RandomSplitEntry -> Maybe Text
nextActivity} -> Maybe Text
nextActivity) (\s :: RandomSplitEntry
s@RandomSplitEntry' {} Maybe Text
a -> RandomSplitEntry
s {$sel:nextActivity:RandomSplitEntry' :: Maybe Text
nextActivity = Maybe Text
a} :: RandomSplitEntry)

-- | The percentage of participants to send down the activity path.
--
-- To determine which participants are sent down each path, Amazon Pinpoint
-- applies a probability-based algorithm to the percentages that you
-- specify for the paths. Therefore, the actual percentage of participants
-- who are sent down a path may not be equal to the percentage that you
-- specify.
randomSplitEntry_percentage :: Lens.Lens' RandomSplitEntry (Prelude.Maybe Prelude.Int)
randomSplitEntry_percentage :: Lens' RandomSplitEntry (Maybe Int)
randomSplitEntry_percentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RandomSplitEntry' {Maybe Int
percentage :: Maybe Int
$sel:percentage:RandomSplitEntry' :: RandomSplitEntry -> Maybe Int
percentage} -> Maybe Int
percentage) (\s :: RandomSplitEntry
s@RandomSplitEntry' {} Maybe Int
a -> RandomSplitEntry
s {$sel:percentage:RandomSplitEntry' :: Maybe Int
percentage = Maybe Int
a} :: RandomSplitEntry)

instance Data.FromJSON RandomSplitEntry where
  parseJSON :: Value -> Parser RandomSplitEntry
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RandomSplitEntry"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> RandomSplitEntry
RandomSplitEntry'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NextActivity")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Percentage")
      )

instance Prelude.Hashable RandomSplitEntry where
  hashWithSalt :: Int -> RandomSplitEntry -> Int
hashWithSalt Int
_salt RandomSplitEntry' {Maybe Int
Maybe Text
percentage :: Maybe Int
nextActivity :: Maybe Text
$sel:percentage:RandomSplitEntry' :: RandomSplitEntry -> Maybe Int
$sel:nextActivity:RandomSplitEntry' :: RandomSplitEntry -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextActivity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
percentage

instance Prelude.NFData RandomSplitEntry where
  rnf :: RandomSplitEntry -> ()
rnf RandomSplitEntry' {Maybe Int
Maybe Text
percentage :: Maybe Int
nextActivity :: Maybe Text
$sel:percentage:RandomSplitEntry' :: RandomSplitEntry -> Maybe Int
$sel:nextActivity:RandomSplitEntry' :: RandomSplitEntry -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextActivity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
percentage

instance Data.ToJSON RandomSplitEntry where
  toJSON :: RandomSplitEntry -> Value
toJSON RandomSplitEntry' {Maybe Int
Maybe Text
percentage :: Maybe Int
nextActivity :: Maybe Text
$sel:percentage:RandomSplitEntry' :: RandomSplitEntry -> Maybe Int
$sel:nextActivity:RandomSplitEntry' :: RandomSplitEntry -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"NextActivity" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextActivity,
            (Key
"Percentage" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
percentage
          ]
      )