{-# 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-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.ApplicationSettingsResource 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.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 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 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 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
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]
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
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.
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:
--
-- '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.
--
-- '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.
--
-- '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'
    { $sel:campaignHook:ApplicationSettingsResource' :: Maybe CampaignHook
campaignHook =
        forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedDate:ApplicationSettingsResource' :: Maybe Text
lastModifiedDate = forall a. Maybe a
Prelude.Nothing,
      $sel:limits:ApplicationSettingsResource' :: Maybe CampaignLimits
limits = forall a. Maybe a
Prelude.Nothing,
      $sel:quietTime:ApplicationSettingsResource' :: Maybe QuietTime
quietTime = forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:ApplicationSettingsResource' :: Text
applicationId = Text
pApplicationId_
    }

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

instance Prelude.Hashable ApplicationSettingsResource where
  hashWithSalt :: Int -> ApplicationSettingsResource -> Int
hashWithSalt Int
_salt ApplicationSettingsResource' {Maybe Text
Maybe CampaignLimits
Maybe CampaignHook
Maybe QuietTime
Text
applicationId :: Text
quietTime :: Maybe QuietTime
limits :: Maybe CampaignLimits
lastModifiedDate :: Maybe Text
campaignHook :: Maybe CampaignHook
$sel:applicationId:ApplicationSettingsResource' :: ApplicationSettingsResource -> Text
$sel:quietTime:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe QuietTime
$sel:limits:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe CampaignLimits
$sel:lastModifiedDate:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe Text
$sel:campaignHook:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe CampaignHook
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CampaignHook
campaignHook
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
lastModifiedDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CampaignLimits
limits
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QuietTime
quietTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId

instance Prelude.NFData ApplicationSettingsResource where
  rnf :: ApplicationSettingsResource -> ()
rnf ApplicationSettingsResource' {Maybe Text
Maybe CampaignLimits
Maybe CampaignHook
Maybe QuietTime
Text
applicationId :: Text
quietTime :: Maybe QuietTime
limits :: Maybe CampaignLimits
lastModifiedDate :: Maybe Text
campaignHook :: Maybe CampaignHook
$sel:applicationId:ApplicationSettingsResource' :: ApplicationSettingsResource -> Text
$sel:quietTime:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe QuietTime
$sel:limits:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe CampaignLimits
$sel:lastModifiedDate:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe Text
$sel:campaignHook:ApplicationSettingsResource' :: ApplicationSettingsResource -> Maybe CampaignHook
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CampaignHook
campaignHook
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
lastModifiedDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CampaignLimits
limits
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe QuietTime
quietTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId