{-# 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.ApplicationSettingsResource
-- 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.ApplicationSettingsResource 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

-- | Provides information about an application, including the default
-- settings for an application.
--
-- /See:/ 'newApplicationSettingsResource' smart constructor.
data ApplicationSettingsResource = ApplicationSettingsResource'
  { -- | The date and time, in ISO 8601 format, when the application\'s settings
    -- were last modified.
    ApplicationSettingsResource -> Maybe Text
lastModifiedDate :: Prelude.Maybe Prelude.Text,
    -- | The default sending limits for campaigns in the application.
    ApplicationSettingsResource -> 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.
    ApplicationSettingsResource -> 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.
    ApplicationSettingsResource -> Maybe CampaignHook
campaignHook :: Prelude.Maybe CampaignHook,
    -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    ApplicationSettingsResource -> Text
applicationId :: Prelude.Text
  }
  deriving (ApplicationSettingsResource -> ApplicationSettingsResource -> Bool
(ApplicationSettingsResource
 -> ApplicationSettingsResource -> Bool)
-> (ApplicationSettingsResource
    -> ApplicationSettingsResource -> Bool)
-> Eq ApplicationSettingsResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationSettingsResource -> ApplicationSettingsResource -> Bool
$c/= :: ApplicationSettingsResource -> ApplicationSettingsResource -> Bool
== :: ApplicationSettingsResource -> ApplicationSettingsResource -> Bool
$c== :: ApplicationSettingsResource -> ApplicationSettingsResource -> Bool
Prelude.Eq, ReadPrec [ApplicationSettingsResource]
ReadPrec ApplicationSettingsResource
Int -> ReadS ApplicationSettingsResource
ReadS [ApplicationSettingsResource]
(Int -> ReadS ApplicationSettingsResource)
-> ReadS [ApplicationSettingsResource]
-> ReadPrec ApplicationSettingsResource
-> ReadPrec [ApplicationSettingsResource]
-> Read ApplicationSettingsResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplicationSettingsResource]
$creadListPrec :: ReadPrec [ApplicationSettingsResource]
readPrec :: ReadPrec ApplicationSettingsResource
$creadPrec :: ReadPrec ApplicationSettingsResource
readList :: ReadS [ApplicationSettingsResource]
$creadList :: ReadS [ApplicationSettingsResource]
readsPrec :: Int -> ReadS ApplicationSettingsResource
$creadsPrec :: Int -> ReadS ApplicationSettingsResource
Prelude.Read, Int -> ApplicationSettingsResource -> ShowS
[ApplicationSettingsResource] -> ShowS
ApplicationSettingsResource -> String
(Int -> ApplicationSettingsResource -> ShowS)
-> (ApplicationSettingsResource -> String)
-> ([ApplicationSettingsResource] -> ShowS)
-> Show ApplicationSettingsResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationSettingsResource] -> ShowS
$cshowList :: [ApplicationSettingsResource] -> ShowS
show :: ApplicationSettingsResource -> String
$cshow :: ApplicationSettingsResource -> String
showsPrec :: Int -> ApplicationSettingsResource -> ShowS
$cshowsPrec :: Int -> ApplicationSettingsResource -> ShowS
Prelude.Show, (forall x.
 ApplicationSettingsResource -> Rep ApplicationSettingsResource x)
-> (forall x.
    Rep ApplicationSettingsResource x -> ApplicationSettingsResource)
-> Generic ApplicationSettingsResource
forall x.
Rep ApplicationSettingsResource x -> ApplicationSettingsResource
forall x.
ApplicationSettingsResource -> Rep ApplicationSettingsResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ApplicationSettingsResource x -> ApplicationSettingsResource
$cfrom :: forall x.
ApplicationSettingsResource -> Rep ApplicationSettingsResource x
Prelude.Generic)

-- |
-- Create a value of 'ApplicationSettingsResource' 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:
--
-- 'lastModifiedDate', 'applicationSettingsResource_lastModifiedDate' - The date and time, in ISO 8601 format, when the application\'s settings
-- were last modified.
--
-- 'limits', 'applicationSettingsResource_limits' - The default sending limits for campaigns in the application.
--
-- 'quietTime', 'applicationSettingsResource_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.
--
-- 'campaignHook', 'applicationSettingsResource_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.
--
-- 'applicationId', 'applicationSettingsResource_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newApplicationSettingsResource ::
  -- | 'applicationId'
  Prelude.Text ->
  ApplicationSettingsResource
newApplicationSettingsResource :: Text -> ApplicationSettingsResource
newApplicationSettingsResource Text
pApplicationId_ =
  ApplicationSettingsResource' :: Maybe Text
-> Maybe CampaignLimits
-> Maybe QuietTime
-> Maybe CampaignHook
-> Text
-> ApplicationSettingsResource
ApplicationSettingsResource'
    { $sel:lastModifiedDate:ApplicationSettingsResource' :: Maybe Text
lastModifiedDate =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limits:ApplicationSettingsResource' :: Maybe CampaignLimits
limits = Maybe CampaignLimits
forall a. Maybe a
Prelude.Nothing,
      $sel:quietTime:ApplicationSettingsResource' :: Maybe QuietTime
quietTime = Maybe QuietTime
forall a. Maybe a
Prelude.Nothing,
      $sel:campaignHook:ApplicationSettingsResource' :: Maybe CampaignHook
campaignHook = Maybe CampaignHook
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:ApplicationSettingsResource' :: Text
applicationId = Text
pApplicationId_
    }

-- | The date and time, in ISO 8601 format, when the application\'s settings
-- were last modified.
applicationSettingsResource_lastModifiedDate :: Lens.Lens' ApplicationSettingsResource (Prelude.Maybe Prelude.Text)
applicationSettingsResource_lastModifiedDate :: (Maybe Text -> f (Maybe Text))
-> ApplicationSettingsResource -> f ApplicationSettingsResource
applicationSettingsResource_lastModifiedDate = (ApplicationSettingsResource -> Maybe Text)
-> (ApplicationSettingsResource
    -> Maybe Text -> ApplicationSettingsResource)
-> Lens
     ApplicationSettingsResource
     ApplicationSettingsResource
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationSettingsResource' {Maybe Text
lastModifiedDate :: Maybe Text
$sel:lastModifiedDate:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe Text
lastModifiedDate} -> Maybe Text
lastModifiedDate) (\s :: ApplicationSettingsResource
s@ApplicationSettingsResource' {} Maybe Text
a -> ApplicationSettingsResource
s {$sel:lastModifiedDate:ApplicationSettingsResource' :: Maybe Text
lastModifiedDate = Maybe Text
a} :: ApplicationSettingsResource)

-- | The default sending limits for campaigns in the application.
applicationSettingsResource_limits :: Lens.Lens' ApplicationSettingsResource (Prelude.Maybe CampaignLimits)
applicationSettingsResource_limits :: (Maybe CampaignLimits -> f (Maybe CampaignLimits))
-> ApplicationSettingsResource -> f ApplicationSettingsResource
applicationSettingsResource_limits = (ApplicationSettingsResource -> Maybe CampaignLimits)
-> (ApplicationSettingsResource
    -> Maybe CampaignLimits -> ApplicationSettingsResource)
-> Lens
     ApplicationSettingsResource
     ApplicationSettingsResource
     (Maybe CampaignLimits)
     (Maybe CampaignLimits)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationSettingsResource' {Maybe CampaignLimits
limits :: Maybe CampaignLimits
$sel:limits:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe CampaignLimits
limits} -> Maybe CampaignLimits
limits) (\s :: ApplicationSettingsResource
s@ApplicationSettingsResource' {} Maybe CampaignLimits
a -> ApplicationSettingsResource
s {$sel:limits:ApplicationSettingsResource' :: Maybe CampaignLimits
limits = Maybe CampaignLimits
a} :: ApplicationSettingsResource)

-- | 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.
applicationSettingsResource_quietTime :: Lens.Lens' ApplicationSettingsResource (Prelude.Maybe QuietTime)
applicationSettingsResource_quietTime :: (Maybe QuietTime -> f (Maybe QuietTime))
-> ApplicationSettingsResource -> f ApplicationSettingsResource
applicationSettingsResource_quietTime = (ApplicationSettingsResource -> Maybe QuietTime)
-> (ApplicationSettingsResource
    -> Maybe QuietTime -> ApplicationSettingsResource)
-> Lens
     ApplicationSettingsResource
     ApplicationSettingsResource
     (Maybe QuietTime)
     (Maybe QuietTime)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationSettingsResource' {Maybe QuietTime
quietTime :: Maybe QuietTime
$sel:quietTime:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe QuietTime
quietTime} -> Maybe QuietTime
quietTime) (\s :: ApplicationSettingsResource
s@ApplicationSettingsResource' {} Maybe QuietTime
a -> ApplicationSettingsResource
s {$sel:quietTime:ApplicationSettingsResource' :: Maybe QuietTime
quietTime = Maybe QuietTime
a} :: ApplicationSettingsResource)

-- | 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.
applicationSettingsResource_campaignHook :: Lens.Lens' ApplicationSettingsResource (Prelude.Maybe CampaignHook)
applicationSettingsResource_campaignHook :: (Maybe CampaignHook -> f (Maybe CampaignHook))
-> ApplicationSettingsResource -> f ApplicationSettingsResource
applicationSettingsResource_campaignHook = (ApplicationSettingsResource -> Maybe CampaignHook)
-> (ApplicationSettingsResource
    -> Maybe CampaignHook -> ApplicationSettingsResource)
-> Lens
     ApplicationSettingsResource
     ApplicationSettingsResource
     (Maybe CampaignHook)
     (Maybe CampaignHook)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationSettingsResource' {Maybe CampaignHook
campaignHook :: Maybe CampaignHook
$sel:campaignHook:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe CampaignHook
campaignHook} -> Maybe CampaignHook
campaignHook) (\s :: ApplicationSettingsResource
s@ApplicationSettingsResource' {} Maybe CampaignHook
a -> ApplicationSettingsResource
s {$sel:campaignHook:ApplicationSettingsResource' :: Maybe CampaignHook
campaignHook = Maybe CampaignHook
a} :: ApplicationSettingsResource)

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
applicationSettingsResource_applicationId :: Lens.Lens' ApplicationSettingsResource Prelude.Text
applicationSettingsResource_applicationId :: (Text -> f Text)
-> ApplicationSettingsResource -> f ApplicationSettingsResource
applicationSettingsResource_applicationId = (ApplicationSettingsResource -> Text)
-> (ApplicationSettingsResource
    -> Text -> ApplicationSettingsResource)
-> Lens
     ApplicationSettingsResource ApplicationSettingsResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationSettingsResource' {Text
applicationId :: Text
$sel:applicationId:ApplicationSettingsResource' :: ApplicationSettingsResource -> Text
applicationId} -> Text
applicationId) (\s :: ApplicationSettingsResource
s@ApplicationSettingsResource' {} Text
a -> ApplicationSettingsResource
s {$sel:applicationId:ApplicationSettingsResource' :: Text
applicationId = Text
a} :: ApplicationSettingsResource)

instance Core.FromJSON ApplicationSettingsResource where
  parseJSON :: Value -> Parser ApplicationSettingsResource
parseJSON =
    String
-> (Object -> Parser ApplicationSettingsResource)
-> Value
-> Parser ApplicationSettingsResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ApplicationSettingsResource"
      ( \Object
x ->
          Maybe Text
-> Maybe CampaignLimits
-> Maybe QuietTime
-> Maybe CampaignHook
-> Text
-> ApplicationSettingsResource
ApplicationSettingsResource'
            (Maybe Text
 -> Maybe CampaignLimits
 -> Maybe QuietTime
 -> Maybe CampaignHook
 -> Text
 -> ApplicationSettingsResource)
-> Parser (Maybe Text)
-> Parser
     (Maybe CampaignLimits
      -> Maybe QuietTime
      -> Maybe CampaignHook
      -> Text
      -> ApplicationSettingsResource)
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
"LastModifiedDate")
            Parser
  (Maybe CampaignLimits
   -> Maybe QuietTime
   -> Maybe CampaignHook
   -> Text
   -> ApplicationSettingsResource)
-> Parser (Maybe CampaignLimits)
-> Parser
     (Maybe QuietTime
      -> Maybe CampaignHook -> Text -> ApplicationSettingsResource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CampaignLimits)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Limits")
            Parser
  (Maybe QuietTime
   -> Maybe CampaignHook -> Text -> ApplicationSettingsResource)
-> Parser (Maybe QuietTime)
-> Parser
     (Maybe CampaignHook -> Text -> ApplicationSettingsResource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe QuietTime)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"QuietTime")
            Parser (Maybe CampaignHook -> Text -> ApplicationSettingsResource)
-> Parser (Maybe CampaignHook)
-> Parser (Text -> ApplicationSettingsResource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CampaignHook)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CampaignHook")
            Parser (Text -> ApplicationSettingsResource)
-> Parser Text -> Parser ApplicationSettingsResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ApplicationId")
      )

instance Prelude.Hashable ApplicationSettingsResource

instance Prelude.NFData ApplicationSettingsResource