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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.CampaignHook
import Amazonka.Pinpoint.Types.CampaignLimits
import Amazonka.Pinpoint.Types.QuietTime
import qualified Amazonka.Prelude as Prelude

-- | Specifies the default settings for an application.
--
-- /See:/ 'newWriteApplicationSettingsRequest' smart constructor.
data WriteApplicationSettingsRequest = WriteApplicationSettingsRequest'
  { WriteApplicationSettingsRequest -> Maybe Bool
eventTaggingEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Specifies whether to enable application-related alarms in Amazon
    -- CloudWatch.
    WriteApplicationSettingsRequest -> Maybe Bool
cloudWatchMetricsEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The default sending limits for campaigns in the application. To override
    -- these limits and define custom limits for a specific campaign or
    -- journey, use the Campaign resource or the Journey resource,
    -- respectively.
    WriteApplicationSettingsRequest -> Maybe CampaignLimits
limits :: Prelude.Maybe CampaignLimits,
    -- | The default quiet time for campaigns in the application. Quiet time is a
    -- specific time range when messages aren\'t sent to endpoints, if all the
    -- following conditions are met:
    --
    -- -   The EndpointDemographic.Timezone property of the endpoint is set to
    --     a valid value.
    --
    -- -   The current time in the endpoint\'s time zone is later than or equal
    --     to the time specified by the QuietTime.Start property for the
    --     application (or a campaign or journey that has custom quiet time
    --     settings).
    --
    -- -   The current time in the endpoint\'s time zone is earlier than or
    --     equal to the time specified by the QuietTime.End property for the
    --     application (or a campaign or journey that has custom quiet time
    --     settings).
    --
    -- If any of the preceding conditions isn\'t met, the endpoint will receive
    -- messages from a campaign or journey, even if quiet time is enabled.
    --
    -- To override the default quiet time settings for a specific campaign or
    -- journey, use the Campaign resource or the Journey resource to define a
    -- custom quiet time for the campaign or journey.
    WriteApplicationSettingsRequest -> Maybe QuietTime
quietTime :: Prelude.Maybe QuietTime,
    -- | The settings for the AWS Lambda function to invoke by default as a code
    -- hook for campaigns in the application. You can use this hook to
    -- customize segments that are used by campaigns in the application.
    --
    -- To override these settings and define custom settings for a specific
    -- campaign, use the CampaignHook object of the Campaign resource.
    WriteApplicationSettingsRequest -> Maybe CampaignHook
campaignHook :: Prelude.Maybe CampaignHook
  }
  deriving (WriteApplicationSettingsRequest
-> WriteApplicationSettingsRequest -> Bool
(WriteApplicationSettingsRequest
 -> WriteApplicationSettingsRequest -> Bool)
-> (WriteApplicationSettingsRequest
    -> WriteApplicationSettingsRequest -> Bool)
-> Eq WriteApplicationSettingsRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WriteApplicationSettingsRequest
-> WriteApplicationSettingsRequest -> Bool
$c/= :: WriteApplicationSettingsRequest
-> WriteApplicationSettingsRequest -> Bool
== :: WriteApplicationSettingsRequest
-> WriteApplicationSettingsRequest -> Bool
$c== :: WriteApplicationSettingsRequest
-> WriteApplicationSettingsRequest -> Bool
Prelude.Eq, ReadPrec [WriteApplicationSettingsRequest]
ReadPrec WriteApplicationSettingsRequest
Int -> ReadS WriteApplicationSettingsRequest
ReadS [WriteApplicationSettingsRequest]
(Int -> ReadS WriteApplicationSettingsRequest)
-> ReadS [WriteApplicationSettingsRequest]
-> ReadPrec WriteApplicationSettingsRequest
-> ReadPrec [WriteApplicationSettingsRequest]
-> Read WriteApplicationSettingsRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WriteApplicationSettingsRequest]
$creadListPrec :: ReadPrec [WriteApplicationSettingsRequest]
readPrec :: ReadPrec WriteApplicationSettingsRequest
$creadPrec :: ReadPrec WriteApplicationSettingsRequest
readList :: ReadS [WriteApplicationSettingsRequest]
$creadList :: ReadS [WriteApplicationSettingsRequest]
readsPrec :: Int -> ReadS WriteApplicationSettingsRequest
$creadsPrec :: Int -> ReadS WriteApplicationSettingsRequest
Prelude.Read, Int -> WriteApplicationSettingsRequest -> ShowS
[WriteApplicationSettingsRequest] -> ShowS
WriteApplicationSettingsRequest -> String
(Int -> WriteApplicationSettingsRequest -> ShowS)
-> (WriteApplicationSettingsRequest -> String)
-> ([WriteApplicationSettingsRequest] -> ShowS)
-> Show WriteApplicationSettingsRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WriteApplicationSettingsRequest] -> ShowS
$cshowList :: [WriteApplicationSettingsRequest] -> ShowS
show :: WriteApplicationSettingsRequest -> String
$cshow :: WriteApplicationSettingsRequest -> String
showsPrec :: Int -> WriteApplicationSettingsRequest -> ShowS
$cshowsPrec :: Int -> WriteApplicationSettingsRequest -> ShowS
Prelude.Show, (forall x.
 WriteApplicationSettingsRequest
 -> Rep WriteApplicationSettingsRequest x)
-> (forall x.
    Rep WriteApplicationSettingsRequest x
    -> WriteApplicationSettingsRequest)
-> Generic WriteApplicationSettingsRequest
forall x.
Rep WriteApplicationSettingsRequest x
-> WriteApplicationSettingsRequest
forall x.
WriteApplicationSettingsRequest
-> Rep WriteApplicationSettingsRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep WriteApplicationSettingsRequest x
-> WriteApplicationSettingsRequest
$cfrom :: forall x.
WriteApplicationSettingsRequest
-> Rep WriteApplicationSettingsRequest x
Prelude.Generic)

-- |
-- Create a value of 'WriteApplicationSettingsRequest' 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:
--
-- 'eventTaggingEnabled', 'writeApplicationSettingsRequest_eventTaggingEnabled' - Undocumented member.
--
-- 'cloudWatchMetricsEnabled', 'writeApplicationSettingsRequest_cloudWatchMetricsEnabled' - Specifies whether to enable application-related alarms in Amazon
-- CloudWatch.
--
-- 'limits', 'writeApplicationSettingsRequest_limits' - The default sending limits for campaigns in the application. To override
-- these limits and define custom limits for a specific campaign or
-- journey, use the Campaign resource or the Journey resource,
-- respectively.
--
-- 'quietTime', 'writeApplicationSettingsRequest_quietTime' - The default quiet time for campaigns in the application. Quiet time is a
-- specific time range when messages aren\'t sent to endpoints, if all the
-- following conditions are met:
--
-- -   The EndpointDemographic.Timezone property of the endpoint is set to
--     a valid value.
--
-- -   The current time in the endpoint\'s time zone is later than or equal
--     to the time specified by the QuietTime.Start property for the
--     application (or a campaign or journey that has custom quiet time
--     settings).
--
-- -   The current time in the endpoint\'s time zone is earlier than or
--     equal to the time specified by the QuietTime.End property for the
--     application (or a campaign or journey that has custom quiet time
--     settings).
--
-- If any of the preceding conditions isn\'t met, the endpoint will receive
-- messages from a campaign or journey, even if quiet time is enabled.
--
-- To override the default quiet time settings for a specific campaign or
-- journey, use the Campaign resource or the Journey resource to define a
-- custom quiet time for the campaign or journey.
--
-- 'campaignHook', 'writeApplicationSettingsRequest_campaignHook' - The settings for the AWS Lambda function to invoke by default as a code
-- hook for campaigns in the application. You can use this hook to
-- customize segments that are used by campaigns in the application.
--
-- To override these settings and define custom settings for a specific
-- campaign, use the CampaignHook object of the Campaign resource.
newWriteApplicationSettingsRequest ::
  WriteApplicationSettingsRequest
newWriteApplicationSettingsRequest :: WriteApplicationSettingsRequest
newWriteApplicationSettingsRequest =
  WriteApplicationSettingsRequest' :: Maybe Bool
-> Maybe Bool
-> Maybe CampaignLimits
-> Maybe QuietTime
-> Maybe CampaignHook
-> WriteApplicationSettingsRequest
WriteApplicationSettingsRequest'
    { $sel:eventTaggingEnabled:WriteApplicationSettingsRequest' :: Maybe Bool
eventTaggingEnabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudWatchMetricsEnabled:WriteApplicationSettingsRequest' :: Maybe Bool
cloudWatchMetricsEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:limits:WriteApplicationSettingsRequest' :: Maybe CampaignLimits
limits = Maybe CampaignLimits
forall a. Maybe a
Prelude.Nothing,
      $sel:quietTime:WriteApplicationSettingsRequest' :: Maybe QuietTime
quietTime = Maybe QuietTime
forall a. Maybe a
Prelude.Nothing,
      $sel:campaignHook:WriteApplicationSettingsRequest' :: Maybe CampaignHook
campaignHook = Maybe CampaignHook
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
writeApplicationSettingsRequest_eventTaggingEnabled :: Lens.Lens' WriteApplicationSettingsRequest (Prelude.Maybe Prelude.Bool)
writeApplicationSettingsRequest_eventTaggingEnabled :: (Maybe Bool -> f (Maybe Bool))
-> WriteApplicationSettingsRequest
-> f WriteApplicationSettingsRequest
writeApplicationSettingsRequest_eventTaggingEnabled = (WriteApplicationSettingsRequest -> Maybe Bool)
-> (WriteApplicationSettingsRequest
    -> Maybe Bool -> WriteApplicationSettingsRequest)
-> Lens
     WriteApplicationSettingsRequest
     WriteApplicationSettingsRequest
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteApplicationSettingsRequest' {Maybe Bool
eventTaggingEnabled :: Maybe Bool
$sel:eventTaggingEnabled:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe Bool
eventTaggingEnabled} -> Maybe Bool
eventTaggingEnabled) (\s :: WriteApplicationSettingsRequest
s@WriteApplicationSettingsRequest' {} Maybe Bool
a -> WriteApplicationSettingsRequest
s {$sel:eventTaggingEnabled:WriteApplicationSettingsRequest' :: Maybe Bool
eventTaggingEnabled = Maybe Bool
a} :: WriteApplicationSettingsRequest)

-- | Specifies whether to enable application-related alarms in Amazon
-- CloudWatch.
writeApplicationSettingsRequest_cloudWatchMetricsEnabled :: Lens.Lens' WriteApplicationSettingsRequest (Prelude.Maybe Prelude.Bool)
writeApplicationSettingsRequest_cloudWatchMetricsEnabled :: (Maybe Bool -> f (Maybe Bool))
-> WriteApplicationSettingsRequest
-> f WriteApplicationSettingsRequest
writeApplicationSettingsRequest_cloudWatchMetricsEnabled = (WriteApplicationSettingsRequest -> Maybe Bool)
-> (WriteApplicationSettingsRequest
    -> Maybe Bool -> WriteApplicationSettingsRequest)
-> Lens
     WriteApplicationSettingsRequest
     WriteApplicationSettingsRequest
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteApplicationSettingsRequest' {Maybe Bool
cloudWatchMetricsEnabled :: Maybe Bool
$sel:cloudWatchMetricsEnabled:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe Bool
cloudWatchMetricsEnabled} -> Maybe Bool
cloudWatchMetricsEnabled) (\s :: WriteApplicationSettingsRequest
s@WriteApplicationSettingsRequest' {} Maybe Bool
a -> WriteApplicationSettingsRequest
s {$sel:cloudWatchMetricsEnabled:WriteApplicationSettingsRequest' :: Maybe Bool
cloudWatchMetricsEnabled = Maybe Bool
a} :: WriteApplicationSettingsRequest)

-- | The default sending limits for campaigns in the application. To override
-- these limits and define custom limits for a specific campaign or
-- journey, use the Campaign resource or the Journey resource,
-- respectively.
writeApplicationSettingsRequest_limits :: Lens.Lens' WriteApplicationSettingsRequest (Prelude.Maybe CampaignLimits)
writeApplicationSettingsRequest_limits :: (Maybe CampaignLimits -> f (Maybe CampaignLimits))
-> WriteApplicationSettingsRequest
-> f WriteApplicationSettingsRequest
writeApplicationSettingsRequest_limits = (WriteApplicationSettingsRequest -> Maybe CampaignLimits)
-> (WriteApplicationSettingsRequest
    -> Maybe CampaignLimits -> WriteApplicationSettingsRequest)
-> Lens
     WriteApplicationSettingsRequest
     WriteApplicationSettingsRequest
     (Maybe CampaignLimits)
     (Maybe CampaignLimits)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteApplicationSettingsRequest' {Maybe CampaignLimits
limits :: Maybe CampaignLimits
$sel:limits:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe CampaignLimits
limits} -> Maybe CampaignLimits
limits) (\s :: WriteApplicationSettingsRequest
s@WriteApplicationSettingsRequest' {} Maybe CampaignLimits
a -> WriteApplicationSettingsRequest
s {$sel:limits:WriteApplicationSettingsRequest' :: Maybe CampaignLimits
limits = Maybe CampaignLimits
a} :: WriteApplicationSettingsRequest)

-- | The default quiet time for campaigns in the application. Quiet time is a
-- specific time range when messages aren\'t sent to endpoints, if all the
-- following conditions are met:
--
-- -   The EndpointDemographic.Timezone property of the endpoint is set to
--     a valid value.
--
-- -   The current time in the endpoint\'s time zone is later than or equal
--     to the time specified by the QuietTime.Start property for the
--     application (or a campaign or journey that has custom quiet time
--     settings).
--
-- -   The current time in the endpoint\'s time zone is earlier than or
--     equal to the time specified by the QuietTime.End property for the
--     application (or a campaign or journey that has custom quiet time
--     settings).
--
-- If any of the preceding conditions isn\'t met, the endpoint will receive
-- messages from a campaign or journey, even if quiet time is enabled.
--
-- To override the default quiet time settings for a specific campaign or
-- journey, use the Campaign resource or the Journey resource to define a
-- custom quiet time for the campaign or journey.
writeApplicationSettingsRequest_quietTime :: Lens.Lens' WriteApplicationSettingsRequest (Prelude.Maybe QuietTime)
writeApplicationSettingsRequest_quietTime :: (Maybe QuietTime -> f (Maybe QuietTime))
-> WriteApplicationSettingsRequest
-> f WriteApplicationSettingsRequest
writeApplicationSettingsRequest_quietTime = (WriteApplicationSettingsRequest -> Maybe QuietTime)
-> (WriteApplicationSettingsRequest
    -> Maybe QuietTime -> WriteApplicationSettingsRequest)
-> Lens
     WriteApplicationSettingsRequest
     WriteApplicationSettingsRequest
     (Maybe QuietTime)
     (Maybe QuietTime)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteApplicationSettingsRequest' {Maybe QuietTime
quietTime :: Maybe QuietTime
$sel:quietTime:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe QuietTime
quietTime} -> Maybe QuietTime
quietTime) (\s :: WriteApplicationSettingsRequest
s@WriteApplicationSettingsRequest' {} Maybe QuietTime
a -> WriteApplicationSettingsRequest
s {$sel:quietTime:WriteApplicationSettingsRequest' :: Maybe QuietTime
quietTime = Maybe QuietTime
a} :: WriteApplicationSettingsRequest)

-- | The settings for the AWS Lambda function to invoke by default as a code
-- hook for campaigns in the application. You can use this hook to
-- customize segments that are used by campaigns in the application.
--
-- To override these settings and define custom settings for a specific
-- campaign, use the CampaignHook object of the Campaign resource.
writeApplicationSettingsRequest_campaignHook :: Lens.Lens' WriteApplicationSettingsRequest (Prelude.Maybe CampaignHook)
writeApplicationSettingsRequest_campaignHook :: (Maybe CampaignHook -> f (Maybe CampaignHook))
-> WriteApplicationSettingsRequest
-> f WriteApplicationSettingsRequest
writeApplicationSettingsRequest_campaignHook = (WriteApplicationSettingsRequest -> Maybe CampaignHook)
-> (WriteApplicationSettingsRequest
    -> Maybe CampaignHook -> WriteApplicationSettingsRequest)
-> Lens
     WriteApplicationSettingsRequest
     WriteApplicationSettingsRequest
     (Maybe CampaignHook)
     (Maybe CampaignHook)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteApplicationSettingsRequest' {Maybe CampaignHook
campaignHook :: Maybe CampaignHook
$sel:campaignHook:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe CampaignHook
campaignHook} -> Maybe CampaignHook
campaignHook) (\s :: WriteApplicationSettingsRequest
s@WriteApplicationSettingsRequest' {} Maybe CampaignHook
a -> WriteApplicationSettingsRequest
s {$sel:campaignHook:WriteApplicationSettingsRequest' :: Maybe CampaignHook
campaignHook = Maybe CampaignHook
a} :: WriteApplicationSettingsRequest)

instance
  Prelude.Hashable
    WriteApplicationSettingsRequest

instance
  Prelude.NFData
    WriteApplicationSettingsRequest

instance Core.ToJSON WriteApplicationSettingsRequest where
  toJSON :: WriteApplicationSettingsRequest -> Value
toJSON WriteApplicationSettingsRequest' {Maybe Bool
Maybe CampaignLimits
Maybe CampaignHook
Maybe QuietTime
campaignHook :: Maybe CampaignHook
quietTime :: Maybe QuietTime
limits :: Maybe CampaignLimits
cloudWatchMetricsEnabled :: Maybe Bool
eventTaggingEnabled :: Maybe Bool
$sel:campaignHook:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe CampaignHook
$sel:quietTime:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe QuietTime
$sel:limits:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe CampaignLimits
$sel:cloudWatchMetricsEnabled:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe Bool
$sel:eventTaggingEnabled:WriteApplicationSettingsRequest' :: WriteApplicationSettingsRequest -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EventTaggingEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
eventTaggingEnabled,
            (Text
"CloudWatchMetricsEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
cloudWatchMetricsEnabled,
            (Text
"Limits" Text -> CampaignLimits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CampaignLimits -> Pair) -> Maybe CampaignLimits -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CampaignLimits
limits,
            (Text
"QuietTime" Text -> QuietTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (QuietTime -> Pair) -> Maybe QuietTime -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe QuietTime
quietTime,
            (Text
"CampaignHook" Text -> CampaignHook -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CampaignHook -> Pair) -> Maybe CampaignHook -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CampaignHook
campaignHook
          ]
      )