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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (QuietTime -> QuietTime -> Bool
(QuietTime -> QuietTime -> Bool)
-> (QuietTime -> QuietTime -> Bool) -> Eq QuietTime
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]
(Int -> ReadS QuietTime)
-> ReadS [QuietTime]
-> ReadPrec QuietTime
-> ReadPrec [QuietTime]
-> Read 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
(Int -> QuietTime -> ShowS)
-> (QuietTime -> String)
-> ([QuietTime] -> ShowS)
-> Show QuietTime
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. QuietTime -> Rep QuietTime x)
-> (forall x. Rep QuietTime x -> QuietTime) -> Generic QuietTime
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:
--
-- '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.
--
-- '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.
newQuietTime ::
  QuietTime
newQuietTime :: QuietTime
newQuietTime =
  QuietTime' :: Maybe Text -> Maybe Text -> QuietTime
QuietTime'
    { $sel:start:QuietTime' :: Maybe Text
start = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:end:QuietTime' :: Maybe Text
end = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> QuietTime -> f QuietTime
quietTime_start = (QuietTime -> Maybe Text)
-> (QuietTime -> Maybe Text -> QuietTime)
-> Lens QuietTime QuietTime (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> QuietTime -> f QuietTime
quietTime_end = (QuietTime -> Maybe Text)
-> (QuietTime -> Maybe Text -> QuietTime)
-> Lens QuietTime QuietTime (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable QuietTime

instance Prelude.NFData QuietTime

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