{-# 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.HoldoutActivity where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data HoldoutActivity = HoldoutActivity'
{
HoldoutActivity -> Maybe Text
nextActivity :: Prelude.Maybe Prelude.Text,
HoldoutActivity -> Int
percentage :: Prelude.Int
}
deriving (HoldoutActivity -> HoldoutActivity -> Bool
(HoldoutActivity -> HoldoutActivity -> Bool)
-> (HoldoutActivity -> HoldoutActivity -> Bool)
-> Eq HoldoutActivity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HoldoutActivity -> HoldoutActivity -> Bool
$c/= :: HoldoutActivity -> HoldoutActivity -> Bool
== :: HoldoutActivity -> HoldoutActivity -> Bool
$c== :: HoldoutActivity -> HoldoutActivity -> Bool
Prelude.Eq, ReadPrec [HoldoutActivity]
ReadPrec HoldoutActivity
Int -> ReadS HoldoutActivity
ReadS [HoldoutActivity]
(Int -> ReadS HoldoutActivity)
-> ReadS [HoldoutActivity]
-> ReadPrec HoldoutActivity
-> ReadPrec [HoldoutActivity]
-> Read HoldoutActivity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HoldoutActivity]
$creadListPrec :: ReadPrec [HoldoutActivity]
readPrec :: ReadPrec HoldoutActivity
$creadPrec :: ReadPrec HoldoutActivity
readList :: ReadS [HoldoutActivity]
$creadList :: ReadS [HoldoutActivity]
readsPrec :: Int -> ReadS HoldoutActivity
$creadsPrec :: Int -> ReadS HoldoutActivity
Prelude.Read, Int -> HoldoutActivity -> ShowS
[HoldoutActivity] -> ShowS
HoldoutActivity -> String
(Int -> HoldoutActivity -> ShowS)
-> (HoldoutActivity -> String)
-> ([HoldoutActivity] -> ShowS)
-> Show HoldoutActivity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HoldoutActivity] -> ShowS
$cshowList :: [HoldoutActivity] -> ShowS
show :: HoldoutActivity -> String
$cshow :: HoldoutActivity -> String
showsPrec :: Int -> HoldoutActivity -> ShowS
$cshowsPrec :: Int -> HoldoutActivity -> ShowS
Prelude.Show, (forall x. HoldoutActivity -> Rep HoldoutActivity x)
-> (forall x. Rep HoldoutActivity x -> HoldoutActivity)
-> Generic HoldoutActivity
forall x. Rep HoldoutActivity x -> HoldoutActivity
forall x. HoldoutActivity -> Rep HoldoutActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HoldoutActivity x -> HoldoutActivity
$cfrom :: forall x. HoldoutActivity -> Rep HoldoutActivity x
Prelude.Generic)
newHoldoutActivity ::
Prelude.Int ->
HoldoutActivity
newHoldoutActivity :: Int -> HoldoutActivity
newHoldoutActivity Int
pPercentage_ =
HoldoutActivity' :: Maybe Text -> Int -> HoldoutActivity
HoldoutActivity'
{ $sel:nextActivity:HoldoutActivity' :: Maybe Text
nextActivity = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:percentage:HoldoutActivity' :: Int
percentage = Int
pPercentage_
}
holdoutActivity_nextActivity :: Lens.Lens' HoldoutActivity (Prelude.Maybe Prelude.Text)
holdoutActivity_nextActivity :: (Maybe Text -> f (Maybe Text))
-> HoldoutActivity -> f HoldoutActivity
holdoutActivity_nextActivity = (HoldoutActivity -> Maybe Text)
-> (HoldoutActivity -> Maybe Text -> HoldoutActivity)
-> Lens HoldoutActivity HoldoutActivity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HoldoutActivity' {Maybe Text
nextActivity :: Maybe Text
$sel:nextActivity:HoldoutActivity' :: HoldoutActivity -> Maybe Text
nextActivity} -> Maybe Text
nextActivity) (\s :: HoldoutActivity
s@HoldoutActivity' {} Maybe Text
a -> HoldoutActivity
s {$sel:nextActivity:HoldoutActivity' :: Maybe Text
nextActivity = Maybe Text
a} :: HoldoutActivity)
holdoutActivity_percentage :: Lens.Lens' HoldoutActivity Prelude.Int
holdoutActivity_percentage :: (Int -> f Int) -> HoldoutActivity -> f HoldoutActivity
holdoutActivity_percentage = (HoldoutActivity -> Int)
-> (HoldoutActivity -> Int -> HoldoutActivity)
-> Lens HoldoutActivity HoldoutActivity Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HoldoutActivity' {Int
percentage :: Int
$sel:percentage:HoldoutActivity' :: HoldoutActivity -> Int
percentage} -> Int
percentage) (\s :: HoldoutActivity
s@HoldoutActivity' {} Int
a -> HoldoutActivity
s {$sel:percentage:HoldoutActivity' :: Int
percentage = Int
a} :: HoldoutActivity)
instance Core.FromJSON HoldoutActivity where
parseJSON :: Value -> Parser HoldoutActivity
parseJSON =
String
-> (Object -> Parser HoldoutActivity)
-> Value
-> Parser HoldoutActivity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"HoldoutActivity"
( \Object
x ->
Maybe Text -> Int -> HoldoutActivity
HoldoutActivity'
(Maybe Text -> Int -> HoldoutActivity)
-> Parser (Maybe Text) -> Parser (Int -> HoldoutActivity)
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 (Int -> HoldoutActivity)
-> Parser Int -> Parser HoldoutActivity
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Percentage")
)
instance Prelude.Hashable HoldoutActivity
instance Prelude.NFData HoldoutActivity
instance Core.ToJSON HoldoutActivity where
toJSON :: HoldoutActivity -> Value
toJSON HoldoutActivity' {Int
Maybe Text
percentage :: Int
nextActivity :: Maybe Text
$sel:percentage:HoldoutActivity' :: HoldoutActivity -> Int
$sel:nextActivity:HoldoutActivity' :: HoldoutActivity -> 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,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Percentage" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
percentage)
]
)