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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types.EventCondition
import Amazonka.Pinpoint.Types.SegmentCondition
import Amazonka.Pinpoint.Types.SegmentDimensions
import qualified Amazonka.Prelude as Prelude

-- | Specifies a condition to evaluate for an activity in a journey.
--
-- /See:/ 'newSimpleCondition' smart constructor.
data SimpleCondition = SimpleCondition'
  { -- | The dimension settings for the event that\'s associated with the
    -- activity.
    SimpleCondition -> Maybe EventCondition
eventCondition :: Prelude.Maybe EventCondition,
    -- | The segment that\'s associated with the activity.
    SimpleCondition -> Maybe SegmentCondition
segmentCondition :: Prelude.Maybe SegmentCondition,
    -- | The dimension settings for the segment that\'s associated with the
    -- activity.
    SimpleCondition -> Maybe SegmentDimensions
segmentDimensions :: Prelude.Maybe SegmentDimensions
  }
  deriving (SimpleCondition -> SimpleCondition -> Bool
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]
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
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. 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)

-- |
-- Create a value of 'SimpleCondition' 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:
--
-- 'eventCondition', 'simpleCondition_eventCondition' - The dimension settings for the event that\'s associated with the
-- activity.
--
-- 'segmentCondition', 'simpleCondition_segmentCondition' - The segment that\'s associated with the activity.
--
-- 'segmentDimensions', 'simpleCondition_segmentDimensions' - The dimension settings for the segment that\'s associated with the
-- activity.
newSimpleCondition ::
  SimpleCondition
newSimpleCondition :: SimpleCondition
newSimpleCondition =
  SimpleCondition'
    { $sel:eventCondition:SimpleCondition' :: Maybe EventCondition
eventCondition = forall a. Maybe a
Prelude.Nothing,
      $sel:segmentCondition:SimpleCondition' :: Maybe SegmentCondition
segmentCondition = forall a. Maybe a
Prelude.Nothing,
      $sel:segmentDimensions:SimpleCondition' :: Maybe SegmentDimensions
segmentDimensions = forall a. Maybe a
Prelude.Nothing
    }

-- | The dimension settings for the event that\'s associated with the
-- activity.
simpleCondition_eventCondition :: Lens.Lens' SimpleCondition (Prelude.Maybe EventCondition)
simpleCondition_eventCondition :: Lens' SimpleCondition (Maybe EventCondition)
simpleCondition_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)

-- | The segment that\'s associated with the activity.
simpleCondition_segmentCondition :: Lens.Lens' SimpleCondition (Prelude.Maybe SegmentCondition)
simpleCondition_segmentCondition :: Lens' SimpleCondition (Maybe SegmentCondition)
simpleCondition_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)

-- | The dimension settings for the segment that\'s associated with the
-- activity.
simpleCondition_segmentDimensions :: Lens.Lens' SimpleCondition (Prelude.Maybe SegmentDimensions)
simpleCondition_segmentDimensions :: Lens' SimpleCondition (Maybe SegmentDimensions)
simpleCondition_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)

instance Data.FromJSON SimpleCondition where
  parseJSON :: Value -> Parser SimpleCondition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SimpleCondition"
      ( \Object
x ->
          Maybe EventCondition
-> Maybe SegmentCondition
-> Maybe SegmentDimensions
-> SimpleCondition
SimpleCondition'
            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
"EventCondition")
            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
"SegmentCondition")
            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
"segmentDimensions")
      )

instance Prelude.Hashable SimpleCondition where
  hashWithSalt :: Int -> SimpleCondition -> Int
hashWithSalt Int
_salt SimpleCondition' {Maybe SegmentCondition
Maybe SegmentDimensions
Maybe EventCondition
segmentDimensions :: Maybe SegmentDimensions
segmentCondition :: Maybe SegmentCondition
eventCondition :: Maybe EventCondition
$sel:segmentDimensions:SimpleCondition' :: SimpleCondition -> Maybe SegmentDimensions
$sel:segmentCondition:SimpleCondition' :: SimpleCondition -> Maybe SegmentCondition
$sel:eventCondition:SimpleCondition' :: SimpleCondition -> Maybe EventCondition
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EventCondition
eventCondition
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SegmentCondition
segmentCondition
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SegmentDimensions
segmentDimensions

instance Prelude.NFData SimpleCondition where
  rnf :: SimpleCondition -> ()
rnf SimpleCondition' {Maybe SegmentCondition
Maybe SegmentDimensions
Maybe EventCondition
segmentDimensions :: Maybe SegmentDimensions
segmentCondition :: Maybe SegmentCondition
eventCondition :: Maybe EventCondition
$sel:segmentDimensions:SimpleCondition' :: SimpleCondition -> Maybe SegmentDimensions
$sel:segmentCondition:SimpleCondition' :: SimpleCondition -> Maybe SegmentCondition
$sel:eventCondition:SimpleCondition' :: SimpleCondition -> Maybe EventCondition
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EventCondition
eventCondition
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SegmentCondition
segmentCondition
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SegmentDimensions
segmentDimensions

instance Data.ToJSON SimpleCondition where
  toJSON :: SimpleCondition -> Value
toJSON SimpleCondition' {Maybe SegmentCondition
Maybe SegmentDimensions
Maybe EventCondition
segmentDimensions :: Maybe SegmentDimensions
segmentCondition :: Maybe SegmentCondition
eventCondition :: Maybe EventCondition
$sel:segmentDimensions:SimpleCondition' :: SimpleCondition -> Maybe SegmentDimensions
$sel:segmentCondition:SimpleCondition' :: SimpleCondition -> Maybe SegmentCondition
$sel:eventCondition:SimpleCondition' :: SimpleCondition -> Maybe EventCondition
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EventCondition" 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 EventCondition
eventCondition,
            (Key
"SegmentCondition" 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 SegmentCondition
segmentCondition,
            (Key
"segmentDimensions" 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 SegmentDimensions
segmentDimensions
          ]
      )