{-# 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 #-}
module Amazonka.Pinpoint.Types.RandomSplitEntry where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data RandomSplitEntry = RandomSplitEntry'
{
RandomSplitEntry -> Maybe Text
nextActivity :: Prelude.Maybe Prelude.Text,
RandomSplitEntry -> Maybe Int
percentage :: Prelude.Maybe Prelude.Int
}
deriving (RandomSplitEntry -> RandomSplitEntry -> Bool
(RandomSplitEntry -> RandomSplitEntry -> Bool)
-> (RandomSplitEntry -> RandomSplitEntry -> Bool)
-> Eq RandomSplitEntry
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]
(Int -> ReadS RandomSplitEntry)
-> ReadS [RandomSplitEntry]
-> ReadPrec RandomSplitEntry
-> ReadPrec [RandomSplitEntry]
-> Read 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
(Int -> RandomSplitEntry -> ShowS)
-> (RandomSplitEntry -> String)
-> ([RandomSplitEntry] -> ShowS)
-> Show RandomSplitEntry
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. RandomSplitEntry -> Rep RandomSplitEntry x)
-> (forall x. Rep RandomSplitEntry x -> RandomSplitEntry)
-> Generic RandomSplitEntry
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)
newRandomSplitEntry ::
RandomSplitEntry
newRandomSplitEntry :: RandomSplitEntry
newRandomSplitEntry =
RandomSplitEntry' :: Maybe Text -> Maybe Int -> RandomSplitEntry
RandomSplitEntry'
{ $sel:nextActivity:RandomSplitEntry' :: Maybe Text
nextActivity = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:percentage:RandomSplitEntry' :: Maybe Int
percentage = Maybe Int
forall a. Maybe a
Prelude.Nothing
}
randomSplitEntry_nextActivity :: Lens.Lens' RandomSplitEntry (Prelude.Maybe Prelude.Text)
randomSplitEntry_nextActivity :: (Maybe Text -> f (Maybe Text))
-> RandomSplitEntry -> f RandomSplitEntry
randomSplitEntry_nextActivity = (RandomSplitEntry -> Maybe Text)
-> (RandomSplitEntry -> Maybe Text -> RandomSplitEntry)
-> Lens RandomSplitEntry RandomSplitEntry (Maybe Text) (Maybe Text)
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)
randomSplitEntry_percentage :: Lens.Lens' RandomSplitEntry (Prelude.Maybe Prelude.Int)
randomSplitEntry_percentage :: (Maybe Int -> f (Maybe Int))
-> RandomSplitEntry -> f RandomSplitEntry
randomSplitEntry_percentage = (RandomSplitEntry -> Maybe Int)
-> (RandomSplitEntry -> Maybe Int -> RandomSplitEntry)
-> Lens RandomSplitEntry RandomSplitEntry (Maybe Int) (Maybe Int)
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 Core.FromJSON RandomSplitEntry where
parseJSON :: Value -> Parser RandomSplitEntry
parseJSON =
String
-> (Object -> Parser RandomSplitEntry)
-> Value
-> Parser RandomSplitEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RandomSplitEntry"
( \Object
x ->
Maybe Text -> Maybe Int -> RandomSplitEntry
RandomSplitEntry'
(Maybe Text -> Maybe Int -> RandomSplitEntry)
-> Parser (Maybe Text) -> Parser (Maybe Int -> RandomSplitEntry)
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
"NextActivity")
Parser (Maybe Int -> RandomSplitEntry)
-> Parser (Maybe Int) -> Parser RandomSplitEntry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Percentage")
)
instance Prelude.Hashable RandomSplitEntry
instance Prelude.NFData RandomSplitEntry
instance Core.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
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"NextActivity" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextActivity,
(Text
"Percentage" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
percentage
]
)