{-# 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.WriteTreatmentResource
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pinpoint.Types.WriteTreatmentResource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.CustomDeliveryConfiguration
import Amazonka.Pinpoint.Types.MessageConfiguration
import Amazonka.Pinpoint.Types.Schedule
import Amazonka.Pinpoint.Types.TemplateConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Specifies the settings for a campaign treatment. A /treatment/ is a
-- variation of a campaign that\'s used for A\/B testing of a campaign.
--
-- /See:/ 'newWriteTreatmentResource' smart constructor.
data WriteTreatmentResource = WriteTreatmentResource'
  { -- | The delivery configuration settings for sending the treatment through a
    -- custom channel. This object is required if the MessageConfiguration
    -- object for the treatment specifies a CustomMessage object.
    WriteTreatmentResource -> Maybe CustomDeliveryConfiguration
customDeliveryConfiguration :: Prelude.Maybe CustomDeliveryConfiguration,
    -- | The schedule settings for the treatment.
    WriteTreatmentResource -> Maybe Schedule
schedule :: Prelude.Maybe Schedule,
    -- | The message template to use for the treatment.
    WriteTreatmentResource -> Maybe TemplateConfiguration
templateConfiguration :: Prelude.Maybe TemplateConfiguration,
    -- | A custom name for the treatment.
    WriteTreatmentResource -> Maybe Text
treatmentName :: Prelude.Maybe Prelude.Text,
    -- | A custom description of the treatment.
    WriteTreatmentResource -> Maybe Text
treatmentDescription :: Prelude.Maybe Prelude.Text,
    -- | The message configuration settings for the treatment.
    WriteTreatmentResource -> Maybe MessageConfiguration
messageConfiguration :: Prelude.Maybe MessageConfiguration,
    -- | The allocated percentage of users (segment members) to send the
    -- treatment to.
    WriteTreatmentResource -> Int
sizePercent :: Prelude.Int
  }
  deriving (WriteTreatmentResource -> WriteTreatmentResource -> Bool
(WriteTreatmentResource -> WriteTreatmentResource -> Bool)
-> (WriteTreatmentResource -> WriteTreatmentResource -> Bool)
-> Eq WriteTreatmentResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WriteTreatmentResource -> WriteTreatmentResource -> Bool
$c/= :: WriteTreatmentResource -> WriteTreatmentResource -> Bool
== :: WriteTreatmentResource -> WriteTreatmentResource -> Bool
$c== :: WriteTreatmentResource -> WriteTreatmentResource -> Bool
Prelude.Eq, ReadPrec [WriteTreatmentResource]
ReadPrec WriteTreatmentResource
Int -> ReadS WriteTreatmentResource
ReadS [WriteTreatmentResource]
(Int -> ReadS WriteTreatmentResource)
-> ReadS [WriteTreatmentResource]
-> ReadPrec WriteTreatmentResource
-> ReadPrec [WriteTreatmentResource]
-> Read WriteTreatmentResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WriteTreatmentResource]
$creadListPrec :: ReadPrec [WriteTreatmentResource]
readPrec :: ReadPrec WriteTreatmentResource
$creadPrec :: ReadPrec WriteTreatmentResource
readList :: ReadS [WriteTreatmentResource]
$creadList :: ReadS [WriteTreatmentResource]
readsPrec :: Int -> ReadS WriteTreatmentResource
$creadsPrec :: Int -> ReadS WriteTreatmentResource
Prelude.Read, Int -> WriteTreatmentResource -> ShowS
[WriteTreatmentResource] -> ShowS
WriteTreatmentResource -> String
(Int -> WriteTreatmentResource -> ShowS)
-> (WriteTreatmentResource -> String)
-> ([WriteTreatmentResource] -> ShowS)
-> Show WriteTreatmentResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WriteTreatmentResource] -> ShowS
$cshowList :: [WriteTreatmentResource] -> ShowS
show :: WriteTreatmentResource -> String
$cshow :: WriteTreatmentResource -> String
showsPrec :: Int -> WriteTreatmentResource -> ShowS
$cshowsPrec :: Int -> WriteTreatmentResource -> ShowS
Prelude.Show, (forall x. WriteTreatmentResource -> Rep WriteTreatmentResource x)
-> (forall x.
    Rep WriteTreatmentResource x -> WriteTreatmentResource)
-> Generic WriteTreatmentResource
forall x. Rep WriteTreatmentResource x -> WriteTreatmentResource
forall x. WriteTreatmentResource -> Rep WriteTreatmentResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WriteTreatmentResource x -> WriteTreatmentResource
$cfrom :: forall x. WriteTreatmentResource -> Rep WriteTreatmentResource x
Prelude.Generic)

-- |
-- Create a value of 'WriteTreatmentResource' 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:
--
-- 'customDeliveryConfiguration', 'writeTreatmentResource_customDeliveryConfiguration' - The delivery configuration settings for sending the treatment through a
-- custom channel. This object is required if the MessageConfiguration
-- object for the treatment specifies a CustomMessage object.
--
-- 'schedule', 'writeTreatmentResource_schedule' - The schedule settings for the treatment.
--
-- 'templateConfiguration', 'writeTreatmentResource_templateConfiguration' - The message template to use for the treatment.
--
-- 'treatmentName', 'writeTreatmentResource_treatmentName' - A custom name for the treatment.
--
-- 'treatmentDescription', 'writeTreatmentResource_treatmentDescription' - A custom description of the treatment.
--
-- 'messageConfiguration', 'writeTreatmentResource_messageConfiguration' - The message configuration settings for the treatment.
--
-- 'sizePercent', 'writeTreatmentResource_sizePercent' - The allocated percentage of users (segment members) to send the
-- treatment to.
newWriteTreatmentResource ::
  -- | 'sizePercent'
  Prelude.Int ->
  WriteTreatmentResource
newWriteTreatmentResource :: Int -> WriteTreatmentResource
newWriteTreatmentResource Int
pSizePercent_ =
  WriteTreatmentResource' :: Maybe CustomDeliveryConfiguration
-> Maybe Schedule
-> Maybe TemplateConfiguration
-> Maybe Text
-> Maybe Text
-> Maybe MessageConfiguration
-> Int
-> WriteTreatmentResource
WriteTreatmentResource'
    { $sel:customDeliveryConfiguration:WriteTreatmentResource' :: Maybe CustomDeliveryConfiguration
customDeliveryConfiguration =
        Maybe CustomDeliveryConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:schedule:WriteTreatmentResource' :: Maybe Schedule
schedule = Maybe Schedule
forall a. Maybe a
Prelude.Nothing,
      $sel:templateConfiguration:WriteTreatmentResource' :: Maybe TemplateConfiguration
templateConfiguration = Maybe TemplateConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:treatmentName:WriteTreatmentResource' :: Maybe Text
treatmentName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:treatmentDescription:WriteTreatmentResource' :: Maybe Text
treatmentDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:messageConfiguration:WriteTreatmentResource' :: Maybe MessageConfiguration
messageConfiguration = Maybe MessageConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:sizePercent:WriteTreatmentResource' :: Int
sizePercent = Int
pSizePercent_
    }

-- | The delivery configuration settings for sending the treatment through a
-- custom channel. This object is required if the MessageConfiguration
-- object for the treatment specifies a CustomMessage object.
writeTreatmentResource_customDeliveryConfiguration :: Lens.Lens' WriteTreatmentResource (Prelude.Maybe CustomDeliveryConfiguration)
writeTreatmentResource_customDeliveryConfiguration :: (Maybe CustomDeliveryConfiguration
 -> f (Maybe CustomDeliveryConfiguration))
-> WriteTreatmentResource -> f WriteTreatmentResource
writeTreatmentResource_customDeliveryConfiguration = (WriteTreatmentResource -> Maybe CustomDeliveryConfiguration)
-> (WriteTreatmentResource
    -> Maybe CustomDeliveryConfiguration -> WriteTreatmentResource)
-> Lens
     WriteTreatmentResource
     WriteTreatmentResource
     (Maybe CustomDeliveryConfiguration)
     (Maybe CustomDeliveryConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteTreatmentResource' {Maybe CustomDeliveryConfiguration
customDeliveryConfiguration :: Maybe CustomDeliveryConfiguration
$sel:customDeliveryConfiguration:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe CustomDeliveryConfiguration
customDeliveryConfiguration} -> Maybe CustomDeliveryConfiguration
customDeliveryConfiguration) (\s :: WriteTreatmentResource
s@WriteTreatmentResource' {} Maybe CustomDeliveryConfiguration
a -> WriteTreatmentResource
s {$sel:customDeliveryConfiguration:WriteTreatmentResource' :: Maybe CustomDeliveryConfiguration
customDeliveryConfiguration = Maybe CustomDeliveryConfiguration
a} :: WriteTreatmentResource)

-- | The schedule settings for the treatment.
writeTreatmentResource_schedule :: Lens.Lens' WriteTreatmentResource (Prelude.Maybe Schedule)
writeTreatmentResource_schedule :: (Maybe Schedule -> f (Maybe Schedule))
-> WriteTreatmentResource -> f WriteTreatmentResource
writeTreatmentResource_schedule = (WriteTreatmentResource -> Maybe Schedule)
-> (WriteTreatmentResource
    -> Maybe Schedule -> WriteTreatmentResource)
-> Lens
     WriteTreatmentResource
     WriteTreatmentResource
     (Maybe Schedule)
     (Maybe Schedule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteTreatmentResource' {Maybe Schedule
schedule :: Maybe Schedule
$sel:schedule:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe Schedule
schedule} -> Maybe Schedule
schedule) (\s :: WriteTreatmentResource
s@WriteTreatmentResource' {} Maybe Schedule
a -> WriteTreatmentResource
s {$sel:schedule:WriteTreatmentResource' :: Maybe Schedule
schedule = Maybe Schedule
a} :: WriteTreatmentResource)

-- | The message template to use for the treatment.
writeTreatmentResource_templateConfiguration :: Lens.Lens' WriteTreatmentResource (Prelude.Maybe TemplateConfiguration)
writeTreatmentResource_templateConfiguration :: (Maybe TemplateConfiguration -> f (Maybe TemplateConfiguration))
-> WriteTreatmentResource -> f WriteTreatmentResource
writeTreatmentResource_templateConfiguration = (WriteTreatmentResource -> Maybe TemplateConfiguration)
-> (WriteTreatmentResource
    -> Maybe TemplateConfiguration -> WriteTreatmentResource)
-> Lens
     WriteTreatmentResource
     WriteTreatmentResource
     (Maybe TemplateConfiguration)
     (Maybe TemplateConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteTreatmentResource' {Maybe TemplateConfiguration
templateConfiguration :: Maybe TemplateConfiguration
$sel:templateConfiguration:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe TemplateConfiguration
templateConfiguration} -> Maybe TemplateConfiguration
templateConfiguration) (\s :: WriteTreatmentResource
s@WriteTreatmentResource' {} Maybe TemplateConfiguration
a -> WriteTreatmentResource
s {$sel:templateConfiguration:WriteTreatmentResource' :: Maybe TemplateConfiguration
templateConfiguration = Maybe TemplateConfiguration
a} :: WriteTreatmentResource)

-- | A custom name for the treatment.
writeTreatmentResource_treatmentName :: Lens.Lens' WriteTreatmentResource (Prelude.Maybe Prelude.Text)
writeTreatmentResource_treatmentName :: (Maybe Text -> f (Maybe Text))
-> WriteTreatmentResource -> f WriteTreatmentResource
writeTreatmentResource_treatmentName = (WriteTreatmentResource -> Maybe Text)
-> (WriteTreatmentResource -> Maybe Text -> WriteTreatmentResource)
-> Lens
     WriteTreatmentResource
     WriteTreatmentResource
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteTreatmentResource' {Maybe Text
treatmentName :: Maybe Text
$sel:treatmentName:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe Text
treatmentName} -> Maybe Text
treatmentName) (\s :: WriteTreatmentResource
s@WriteTreatmentResource' {} Maybe Text
a -> WriteTreatmentResource
s {$sel:treatmentName:WriteTreatmentResource' :: Maybe Text
treatmentName = Maybe Text
a} :: WriteTreatmentResource)

-- | A custom description of the treatment.
writeTreatmentResource_treatmentDescription :: Lens.Lens' WriteTreatmentResource (Prelude.Maybe Prelude.Text)
writeTreatmentResource_treatmentDescription :: (Maybe Text -> f (Maybe Text))
-> WriteTreatmentResource -> f WriteTreatmentResource
writeTreatmentResource_treatmentDescription = (WriteTreatmentResource -> Maybe Text)
-> (WriteTreatmentResource -> Maybe Text -> WriteTreatmentResource)
-> Lens
     WriteTreatmentResource
     WriteTreatmentResource
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteTreatmentResource' {Maybe Text
treatmentDescription :: Maybe Text
$sel:treatmentDescription:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe Text
treatmentDescription} -> Maybe Text
treatmentDescription) (\s :: WriteTreatmentResource
s@WriteTreatmentResource' {} Maybe Text
a -> WriteTreatmentResource
s {$sel:treatmentDescription:WriteTreatmentResource' :: Maybe Text
treatmentDescription = Maybe Text
a} :: WriteTreatmentResource)

-- | The message configuration settings for the treatment.
writeTreatmentResource_messageConfiguration :: Lens.Lens' WriteTreatmentResource (Prelude.Maybe MessageConfiguration)
writeTreatmentResource_messageConfiguration :: (Maybe MessageConfiguration -> f (Maybe MessageConfiguration))
-> WriteTreatmentResource -> f WriteTreatmentResource
writeTreatmentResource_messageConfiguration = (WriteTreatmentResource -> Maybe MessageConfiguration)
-> (WriteTreatmentResource
    -> Maybe MessageConfiguration -> WriteTreatmentResource)
-> Lens
     WriteTreatmentResource
     WriteTreatmentResource
     (Maybe MessageConfiguration)
     (Maybe MessageConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteTreatmentResource' {Maybe MessageConfiguration
messageConfiguration :: Maybe MessageConfiguration
$sel:messageConfiguration:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe MessageConfiguration
messageConfiguration} -> Maybe MessageConfiguration
messageConfiguration) (\s :: WriteTreatmentResource
s@WriteTreatmentResource' {} Maybe MessageConfiguration
a -> WriteTreatmentResource
s {$sel:messageConfiguration:WriteTreatmentResource' :: Maybe MessageConfiguration
messageConfiguration = Maybe MessageConfiguration
a} :: WriteTreatmentResource)

-- | The allocated percentage of users (segment members) to send the
-- treatment to.
writeTreatmentResource_sizePercent :: Lens.Lens' WriteTreatmentResource Prelude.Int
writeTreatmentResource_sizePercent :: (Int -> f Int)
-> WriteTreatmentResource -> f WriteTreatmentResource
writeTreatmentResource_sizePercent = (WriteTreatmentResource -> Int)
-> (WriteTreatmentResource -> Int -> WriteTreatmentResource)
-> Lens WriteTreatmentResource WriteTreatmentResource Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteTreatmentResource' {Int
sizePercent :: Int
$sel:sizePercent:WriteTreatmentResource' :: WriteTreatmentResource -> Int
sizePercent} -> Int
sizePercent) (\s :: WriteTreatmentResource
s@WriteTreatmentResource' {} Int
a -> WriteTreatmentResource
s {$sel:sizePercent:WriteTreatmentResource' :: Int
sizePercent = Int
a} :: WriteTreatmentResource)

instance Prelude.Hashable WriteTreatmentResource

instance Prelude.NFData WriteTreatmentResource

instance Core.ToJSON WriteTreatmentResource where
  toJSON :: WriteTreatmentResource -> Value
toJSON WriteTreatmentResource' {Int
Maybe Text
Maybe CustomDeliveryConfiguration
Maybe MessageConfiguration
Maybe Schedule
Maybe TemplateConfiguration
sizePercent :: Int
messageConfiguration :: Maybe MessageConfiguration
treatmentDescription :: Maybe Text
treatmentName :: Maybe Text
templateConfiguration :: Maybe TemplateConfiguration
schedule :: Maybe Schedule
customDeliveryConfiguration :: Maybe CustomDeliveryConfiguration
$sel:sizePercent:WriteTreatmentResource' :: WriteTreatmentResource -> Int
$sel:messageConfiguration:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe MessageConfiguration
$sel:treatmentDescription:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe Text
$sel:treatmentName:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe Text
$sel:templateConfiguration:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe TemplateConfiguration
$sel:schedule:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe Schedule
$sel:customDeliveryConfiguration:WriteTreatmentResource' :: WriteTreatmentResource -> Maybe CustomDeliveryConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CustomDeliveryConfiguration" Text -> CustomDeliveryConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CustomDeliveryConfiguration -> Pair)
-> Maybe CustomDeliveryConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CustomDeliveryConfiguration
customDeliveryConfiguration,
            (Text
"Schedule" Text -> Schedule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Schedule -> Pair) -> Maybe Schedule -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Schedule
schedule,
            (Text
"TemplateConfiguration" Text -> TemplateConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TemplateConfiguration -> Pair)
-> Maybe TemplateConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TemplateConfiguration
templateConfiguration,
            (Text
"TreatmentName" 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
treatmentName,
            (Text
"TreatmentDescription" 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
treatmentDescription,
            (Text
"MessageConfiguration" Text -> MessageConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (MessageConfiguration -> Pair)
-> Maybe MessageConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MessageConfiguration
messageConfiguration,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SizePercent" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
sizePercent)
          ]
      )