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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Specifies the start and end times that define a time range when messages
-- aren\'t sent to endpoints.
--
-- /See:/ 'newQuietTime' smart constructor.
data QuietTime = QuietTime'
  { -- | The specific time when quiet time ends. This value has to use 24-hour
    -- notation and be in HH:MM format, where HH is the hour (with a leading
    -- zero, if applicable) and MM is the minutes. For example, use 02:30 to
    -- represent 2:30 AM, or 14:30 to represent 2:30 PM.
    QuietTime -> Maybe Text
end :: Prelude.Maybe Prelude.Text,
    -- | The specific time when quiet time begins. This value has to use 24-hour
    -- notation and be in HH:MM format, where HH is the hour (with a leading
    -- zero, if applicable) and MM is the minutes. For example, use 02:30 to
    -- represent 2:30 AM, or 14:30 to represent 2:30 PM.
    QuietTime -> Maybe Text
start :: Prelude.Maybe Prelude.Text
  }
  deriving (QuietTime -> QuietTime -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QuietTime -> QuietTime -> Bool
$c/= :: QuietTime -> QuietTime -> Bool
== :: QuietTime -> QuietTime -> Bool
$c== :: QuietTime -> QuietTime -> Bool
Prelude.Eq, ReadPrec [QuietTime]
ReadPrec QuietTime
Int -> ReadS QuietTime
ReadS [QuietTime]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QuietTime]
$creadListPrec :: ReadPrec [QuietTime]
readPrec :: ReadPrec QuietTime
$creadPrec :: ReadPrec QuietTime
readList :: ReadS [QuietTime]
$creadList :: ReadS [QuietTime]
readsPrec :: Int -> ReadS QuietTime
$creadsPrec :: Int -> ReadS QuietTime
Prelude.Read, Int -> QuietTime -> ShowS
[QuietTime] -> ShowS
QuietTime -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QuietTime] -> ShowS
$cshowList :: [QuietTime] -> ShowS
show :: QuietTime -> String
$cshow :: QuietTime -> String
showsPrec :: Int -> QuietTime -> ShowS
$cshowsPrec :: Int -> QuietTime -> ShowS
Prelude.Show, forall x. Rep QuietTime x -> QuietTime
forall x. QuietTime -> Rep QuietTime x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QuietTime x -> QuietTime
$cfrom :: forall x. QuietTime -> Rep QuietTime x
Prelude.Generic)

-- |
-- Create a value of 'QuietTime' 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:
--
-- 'end', 'quietTime_end' - The specific time when quiet time ends. This value has to use 24-hour
-- notation and be in HH:MM format, where HH is the hour (with a leading
-- zero, if applicable) and MM is the minutes. For example, use 02:30 to
-- represent 2:30 AM, or 14:30 to represent 2:30 PM.
--
-- 'start', 'quietTime_start' - The specific time when quiet time begins. This value has to use 24-hour
-- notation and be in HH:MM format, where HH is the hour (with a leading
-- zero, if applicable) and MM is the minutes. For example, use 02:30 to
-- represent 2:30 AM, or 14:30 to represent 2:30 PM.
newQuietTime ::
  QuietTime
newQuietTime :: QuietTime
newQuietTime =
  QuietTime'
    { $sel:end:QuietTime' :: Maybe Text
end = forall a. Maybe a
Prelude.Nothing,
      $sel:start:QuietTime' :: Maybe Text
start = forall a. Maybe a
Prelude.Nothing
    }

-- | The specific time when quiet time ends. This value has to use 24-hour
-- notation and be in HH:MM format, where HH is the hour (with a leading
-- zero, if applicable) and MM is the minutes. For example, use 02:30 to
-- represent 2:30 AM, or 14:30 to represent 2:30 PM.
quietTime_end :: Lens.Lens' QuietTime (Prelude.Maybe Prelude.Text)
quietTime_end :: Lens' QuietTime (Maybe Text)
quietTime_end = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QuietTime' {Maybe Text
end :: Maybe Text
$sel:end:QuietTime' :: QuietTime -> Maybe Text
end} -> Maybe Text
end) (\s :: QuietTime
s@QuietTime' {} Maybe Text
a -> QuietTime
s {$sel:end:QuietTime' :: Maybe Text
end = Maybe Text
a} :: QuietTime)

-- | The specific time when quiet time begins. This value has to use 24-hour
-- notation and be in HH:MM format, where HH is the hour (with a leading
-- zero, if applicable) and MM is the minutes. For example, use 02:30 to
-- represent 2:30 AM, or 14:30 to represent 2:30 PM.
quietTime_start :: Lens.Lens' QuietTime (Prelude.Maybe Prelude.Text)
quietTime_start :: Lens' QuietTime (Maybe Text)
quietTime_start = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QuietTime' {Maybe Text
start :: Maybe Text
$sel:start:QuietTime' :: QuietTime -> Maybe Text
start} -> Maybe Text
start) (\s :: QuietTime
s@QuietTime' {} Maybe Text
a -> QuietTime
s {$sel:start:QuietTime' :: Maybe Text
start = Maybe Text
a} :: QuietTime)

instance Data.FromJSON QuietTime where
  parseJSON :: Value -> Parser QuietTime
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"QuietTime"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> QuietTime
QuietTime'
            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
"End")
            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
"Start")
      )

instance Prelude.Hashable QuietTime where
  hashWithSalt :: Int -> QuietTime -> Int
hashWithSalt Int
_salt QuietTime' {Maybe Text
start :: Maybe Text
end :: Maybe Text
$sel:start:QuietTime' :: QuietTime -> Maybe Text
$sel:end:QuietTime' :: QuietTime -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
end
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
start

instance Prelude.NFData QuietTime where
  rnf :: QuietTime -> ()
rnf QuietTime' {Maybe Text
start :: Maybe Text
end :: Maybe Text
$sel:start:QuietTime' :: QuietTime -> Maybe Text
$sel:end:QuietTime' :: QuietTime -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
end seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
start

instance Data.ToJSON QuietTime where
  toJSON :: QuietTime -> Value
toJSON QuietTime' {Maybe Text
start :: Maybe Text
end :: Maybe Text
$sel:start:QuietTime' :: QuietTime -> Maybe Text
$sel:end:QuietTime' :: QuietTime -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"End" 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 Text
end,
            (Key
"Start" 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 Text
start
          ]
      )