{-# 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.SimpleCondition where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.EventCondition
import Amazonka.Pinpoint.Types.SegmentCondition
import Amazonka.Pinpoint.Types.SegmentDimensions
import qualified Amazonka.Prelude as Prelude
data SimpleCondition = SimpleCondition'
{
SimpleCondition -> Maybe SegmentDimensions
segmentDimensions :: Prelude.Maybe SegmentDimensions,
SimpleCondition -> Maybe EventCondition
eventCondition :: Prelude.Maybe EventCondition,
SimpleCondition -> Maybe SegmentCondition
segmentCondition :: Prelude.Maybe SegmentCondition
}
deriving (SimpleCondition -> SimpleCondition -> Bool
(SimpleCondition -> SimpleCondition -> Bool)
-> (SimpleCondition -> SimpleCondition -> Bool)
-> Eq SimpleCondition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SimpleCondition -> SimpleCondition -> Bool
$c/= :: SimpleCondition -> SimpleCondition -> Bool
== :: SimpleCondition -> SimpleCondition -> Bool
$c== :: SimpleCondition -> SimpleCondition -> Bool
Prelude.Eq, ReadPrec [SimpleCondition]
ReadPrec SimpleCondition
Int -> ReadS SimpleCondition
ReadS [SimpleCondition]
(Int -> ReadS SimpleCondition)
-> ReadS [SimpleCondition]
-> ReadPrec SimpleCondition
-> ReadPrec [SimpleCondition]
-> Read SimpleCondition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimpleCondition]
$creadListPrec :: ReadPrec [SimpleCondition]
readPrec :: ReadPrec SimpleCondition
$creadPrec :: ReadPrec SimpleCondition
readList :: ReadS [SimpleCondition]
$creadList :: ReadS [SimpleCondition]
readsPrec :: Int -> ReadS SimpleCondition
$creadsPrec :: Int -> ReadS SimpleCondition
Prelude.Read, Int -> SimpleCondition -> ShowS
[SimpleCondition] -> ShowS
SimpleCondition -> String
(Int -> SimpleCondition -> ShowS)
-> (SimpleCondition -> String)
-> ([SimpleCondition] -> ShowS)
-> Show SimpleCondition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimpleCondition] -> ShowS
$cshowList :: [SimpleCondition] -> ShowS
show :: SimpleCondition -> String
$cshow :: SimpleCondition -> String
showsPrec :: Int -> SimpleCondition -> ShowS
$cshowsPrec :: Int -> SimpleCondition -> ShowS
Prelude.Show, (forall x. SimpleCondition -> Rep SimpleCondition x)
-> (forall x. Rep SimpleCondition x -> SimpleCondition)
-> Generic SimpleCondition
forall x. Rep SimpleCondition x -> SimpleCondition
forall x. SimpleCondition -> Rep SimpleCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SimpleCondition x -> SimpleCondition
$cfrom :: forall x. SimpleCondition -> Rep SimpleCondition x
Prelude.Generic)
newSimpleCondition ::
SimpleCondition
newSimpleCondition :: SimpleCondition
newSimpleCondition =
SimpleCondition' :: Maybe SegmentDimensions
-> Maybe EventCondition
-> Maybe SegmentCondition
-> SimpleCondition
SimpleCondition'
{ $sel:segmentDimensions:SimpleCondition' :: Maybe SegmentDimensions
segmentDimensions =
Maybe SegmentDimensions
forall a. Maybe a
Prelude.Nothing,
$sel:eventCondition:SimpleCondition' :: Maybe EventCondition
eventCondition = Maybe EventCondition
forall a. Maybe a
Prelude.Nothing,
$sel:segmentCondition:SimpleCondition' :: Maybe SegmentCondition
segmentCondition = Maybe SegmentCondition
forall a. Maybe a
Prelude.Nothing
}
simpleCondition_segmentDimensions :: Lens.Lens' SimpleCondition (Prelude.Maybe SegmentDimensions)
simpleCondition_segmentDimensions :: (Maybe SegmentDimensions -> f (Maybe SegmentDimensions))
-> SimpleCondition -> f SimpleCondition
simpleCondition_segmentDimensions = (SimpleCondition -> Maybe SegmentDimensions)
-> (SimpleCondition -> Maybe SegmentDimensions -> SimpleCondition)
-> Lens
SimpleCondition
SimpleCondition
(Maybe SegmentDimensions)
(Maybe SegmentDimensions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleCondition' {Maybe SegmentDimensions
segmentDimensions :: Maybe SegmentDimensions
$sel:segmentDimensions:SimpleCondition' :: SimpleCondition -> Maybe SegmentDimensions
segmentDimensions} -> Maybe SegmentDimensions
segmentDimensions) (\s :: SimpleCondition
s@SimpleCondition' {} Maybe SegmentDimensions
a -> SimpleCondition
s {$sel:segmentDimensions:SimpleCondition' :: Maybe SegmentDimensions
segmentDimensions = Maybe SegmentDimensions
a} :: SimpleCondition)
simpleCondition_eventCondition :: Lens.Lens' SimpleCondition (Prelude.Maybe EventCondition)
simpleCondition_eventCondition :: (Maybe EventCondition -> f (Maybe EventCondition))
-> SimpleCondition -> f SimpleCondition
simpleCondition_eventCondition = (SimpleCondition -> Maybe EventCondition)
-> (SimpleCondition -> Maybe EventCondition -> SimpleCondition)
-> Lens
SimpleCondition
SimpleCondition
(Maybe EventCondition)
(Maybe EventCondition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleCondition' {Maybe EventCondition
eventCondition :: Maybe EventCondition
$sel:eventCondition:SimpleCondition' :: SimpleCondition -> Maybe EventCondition
eventCondition} -> Maybe EventCondition
eventCondition) (\s :: SimpleCondition
s@SimpleCondition' {} Maybe EventCondition
a -> SimpleCondition
s {$sel:eventCondition:SimpleCondition' :: Maybe EventCondition
eventCondition = Maybe EventCondition
a} :: SimpleCondition)
simpleCondition_segmentCondition :: Lens.Lens' SimpleCondition (Prelude.Maybe SegmentCondition)
simpleCondition_segmentCondition :: (Maybe SegmentCondition -> f (Maybe SegmentCondition))
-> SimpleCondition -> f SimpleCondition
simpleCondition_segmentCondition = (SimpleCondition -> Maybe SegmentCondition)
-> (SimpleCondition -> Maybe SegmentCondition -> SimpleCondition)
-> Lens
SimpleCondition
SimpleCondition
(Maybe SegmentCondition)
(Maybe SegmentCondition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleCondition' {Maybe SegmentCondition
segmentCondition :: Maybe SegmentCondition
$sel:segmentCondition:SimpleCondition' :: SimpleCondition -> Maybe SegmentCondition
segmentCondition} -> Maybe SegmentCondition
segmentCondition) (\s :: SimpleCondition
s@SimpleCondition' {} Maybe SegmentCondition
a -> SimpleCondition
s {$sel:segmentCondition:SimpleCondition' :: Maybe SegmentCondition
segmentCondition = Maybe SegmentCondition
a} :: SimpleCondition)
instance Core.FromJSON SimpleCondition where
parseJSON :: Value -> Parser SimpleCondition
parseJSON =
String
-> (Object -> Parser SimpleCondition)
-> Value
-> Parser SimpleCondition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"SimpleCondition"
( \Object
x ->
Maybe SegmentDimensions
-> Maybe EventCondition
-> Maybe SegmentCondition
-> SimpleCondition
SimpleCondition'
(Maybe SegmentDimensions
-> Maybe EventCondition
-> Maybe SegmentCondition
-> SimpleCondition)
-> Parser (Maybe SegmentDimensions)
-> Parser
(Maybe EventCondition -> Maybe SegmentCondition -> SimpleCondition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SegmentDimensions)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"segmentDimensions")
Parser
(Maybe EventCondition -> Maybe SegmentCondition -> SimpleCondition)
-> Parser (Maybe EventCondition)
-> Parser (Maybe SegmentCondition -> SimpleCondition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EventCondition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EventCondition")
Parser (Maybe SegmentCondition -> SimpleCondition)
-> Parser (Maybe SegmentCondition) -> Parser SimpleCondition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SegmentCondition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SegmentCondition")
)
instance Prelude.Hashable SimpleCondition
instance Prelude.NFData SimpleCondition
instance Core.ToJSON SimpleCondition where
toJSON :: SimpleCondition -> Value
toJSON SimpleCondition' {Maybe SegmentCondition
Maybe SegmentDimensions
Maybe EventCondition
segmentCondition :: Maybe SegmentCondition
eventCondition :: Maybe EventCondition
segmentDimensions :: Maybe SegmentDimensions
$sel:segmentCondition:SimpleCondition' :: SimpleCondition -> Maybe SegmentCondition
$sel:eventCondition:SimpleCondition' :: SimpleCondition -> Maybe EventCondition
$sel:segmentDimensions:SimpleCondition' :: SimpleCondition -> Maybe SegmentDimensions
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"segmentDimensions" Text -> SegmentDimensions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(SegmentDimensions -> Pair)
-> Maybe SegmentDimensions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SegmentDimensions
segmentDimensions,
(Text
"EventCondition" Text -> EventCondition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(EventCondition -> Pair) -> Maybe EventCondition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EventCondition
eventCondition,
(Text
"SegmentCondition" Text -> SegmentCondition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(SegmentCondition -> Pair) -> Maybe SegmentCondition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SegmentCondition
segmentCondition
]
)