{-# 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.OpenHours
-- 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.OpenHours 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.DayOfWeek
import Amazonka.Pinpoint.Types.OpenHoursRule
import qualified Amazonka.Prelude as Prelude

-- | The time when journey allow to send messages. QuietTime should be
-- configured first and SendingSchedule should be set to true.
--
-- /See:/ 'newOpenHours' smart constructor.
data OpenHours = OpenHours'
  { -- | Rules for Custom Channel.
    OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
custom :: Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule]),
    -- | Rules for Email Channel.
    OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
email :: Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule]),
    -- | Rules for Push Channel.
    OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
push :: Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule]),
    -- | Rules for SMS Channel.
    OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
sms :: Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule]),
    -- | Rules for Voice Channel.
    OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
voice :: Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule])
  }
  deriving (OpenHours -> OpenHours -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpenHours -> OpenHours -> Bool
$c/= :: OpenHours -> OpenHours -> Bool
== :: OpenHours -> OpenHours -> Bool
$c== :: OpenHours -> OpenHours -> Bool
Prelude.Eq, ReadPrec [OpenHours]
ReadPrec OpenHours
Int -> ReadS OpenHours
ReadS [OpenHours]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpenHours]
$creadListPrec :: ReadPrec [OpenHours]
readPrec :: ReadPrec OpenHours
$creadPrec :: ReadPrec OpenHours
readList :: ReadS [OpenHours]
$creadList :: ReadS [OpenHours]
readsPrec :: Int -> ReadS OpenHours
$creadsPrec :: Int -> ReadS OpenHours
Prelude.Read, Int -> OpenHours -> ShowS
[OpenHours] -> ShowS
OpenHours -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpenHours] -> ShowS
$cshowList :: [OpenHours] -> ShowS
show :: OpenHours -> String
$cshow :: OpenHours -> String
showsPrec :: Int -> OpenHours -> ShowS
$cshowsPrec :: Int -> OpenHours -> ShowS
Prelude.Show, forall x. Rep OpenHours x -> OpenHours
forall x. OpenHours -> Rep OpenHours x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpenHours x -> OpenHours
$cfrom :: forall x. OpenHours -> Rep OpenHours x
Prelude.Generic)

-- |
-- Create a value of 'OpenHours' 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:
--
-- 'custom', 'openHours_custom' - Rules for Custom Channel.
--
-- 'email', 'openHours_email' - Rules for Email Channel.
--
-- 'push', 'openHours_push' - Rules for Push Channel.
--
-- 'sms', 'openHours_sms' - Rules for SMS Channel.
--
-- 'voice', 'openHours_voice' - Rules for Voice Channel.
newOpenHours ::
  OpenHours
newOpenHours :: OpenHours
newOpenHours =
  OpenHours'
    { $sel:custom:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
custom = forall a. Maybe a
Prelude.Nothing,
      $sel:email:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
email = forall a. Maybe a
Prelude.Nothing,
      $sel:push:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
push = forall a. Maybe a
Prelude.Nothing,
      $sel:sms:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
sms = forall a. Maybe a
Prelude.Nothing,
      $sel:voice:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
voice = forall a. Maybe a
Prelude.Nothing
    }

-- | Rules for Custom Channel.
openHours_custom :: Lens.Lens' OpenHours (Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule]))
openHours_custom :: Lens' OpenHours (Maybe (HashMap DayOfWeek [OpenHoursRule]))
openHours_custom = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpenHours' {Maybe (HashMap DayOfWeek [OpenHoursRule])
custom :: Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:custom:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
custom} -> Maybe (HashMap DayOfWeek [OpenHoursRule])
custom) (\s :: OpenHours
s@OpenHours' {} Maybe (HashMap DayOfWeek [OpenHoursRule])
a -> OpenHours
s {$sel:custom:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
custom = Maybe (HashMap DayOfWeek [OpenHoursRule])
a} :: OpenHours) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Rules for Email Channel.
openHours_email :: Lens.Lens' OpenHours (Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule]))
openHours_email :: Lens' OpenHours (Maybe (HashMap DayOfWeek [OpenHoursRule]))
openHours_email = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpenHours' {Maybe (HashMap DayOfWeek [OpenHoursRule])
email :: Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:email:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
email} -> Maybe (HashMap DayOfWeek [OpenHoursRule])
email) (\s :: OpenHours
s@OpenHours' {} Maybe (HashMap DayOfWeek [OpenHoursRule])
a -> OpenHours
s {$sel:email:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
email = Maybe (HashMap DayOfWeek [OpenHoursRule])
a} :: OpenHours) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Rules for Push Channel.
openHours_push :: Lens.Lens' OpenHours (Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule]))
openHours_push :: Lens' OpenHours (Maybe (HashMap DayOfWeek [OpenHoursRule]))
openHours_push = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpenHours' {Maybe (HashMap DayOfWeek [OpenHoursRule])
push :: Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:push:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
push} -> Maybe (HashMap DayOfWeek [OpenHoursRule])
push) (\s :: OpenHours
s@OpenHours' {} Maybe (HashMap DayOfWeek [OpenHoursRule])
a -> OpenHours
s {$sel:push:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
push = Maybe (HashMap DayOfWeek [OpenHoursRule])
a} :: OpenHours) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Rules for SMS Channel.
openHours_sms :: Lens.Lens' OpenHours (Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule]))
openHours_sms :: Lens' OpenHours (Maybe (HashMap DayOfWeek [OpenHoursRule]))
openHours_sms = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpenHours' {Maybe (HashMap DayOfWeek [OpenHoursRule])
sms :: Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:sms:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
sms} -> Maybe (HashMap DayOfWeek [OpenHoursRule])
sms) (\s :: OpenHours
s@OpenHours' {} Maybe (HashMap DayOfWeek [OpenHoursRule])
a -> OpenHours
s {$sel:sms:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
sms = Maybe (HashMap DayOfWeek [OpenHoursRule])
a} :: OpenHours) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Rules for Voice Channel.
openHours_voice :: Lens.Lens' OpenHours (Prelude.Maybe (Prelude.HashMap DayOfWeek [OpenHoursRule]))
openHours_voice :: Lens' OpenHours (Maybe (HashMap DayOfWeek [OpenHoursRule]))
openHours_voice = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpenHours' {Maybe (HashMap DayOfWeek [OpenHoursRule])
voice :: Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:voice:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
voice} -> Maybe (HashMap DayOfWeek [OpenHoursRule])
voice) (\s :: OpenHours
s@OpenHours' {} Maybe (HashMap DayOfWeek [OpenHoursRule])
a -> OpenHours
s {$sel:voice:OpenHours' :: Maybe (HashMap DayOfWeek [OpenHoursRule])
voice = Maybe (HashMap DayOfWeek [OpenHoursRule])
a} :: OpenHours) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON OpenHours where
  parseJSON :: Value -> Parser OpenHours
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OpenHours"
      ( \Object
x ->
          Maybe (HashMap DayOfWeek [OpenHoursRule])
-> Maybe (HashMap DayOfWeek [OpenHoursRule])
-> Maybe (HashMap DayOfWeek [OpenHoursRule])
-> Maybe (HashMap DayOfWeek [OpenHoursRule])
-> Maybe (HashMap DayOfWeek [OpenHoursRule])
-> OpenHours
OpenHours'
            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
"CUSTOM" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"EMAIL" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"PUSH" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"SMS" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"VOICE" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable OpenHours where
  hashWithSalt :: Int -> OpenHours -> Int
hashWithSalt Int
_salt OpenHours' {Maybe (HashMap DayOfWeek [OpenHoursRule])
voice :: Maybe (HashMap DayOfWeek [OpenHoursRule])
sms :: Maybe (HashMap DayOfWeek [OpenHoursRule])
push :: Maybe (HashMap DayOfWeek [OpenHoursRule])
email :: Maybe (HashMap DayOfWeek [OpenHoursRule])
custom :: Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:voice:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:sms:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:push:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:email:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:custom:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap DayOfWeek [OpenHoursRule])
custom
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap DayOfWeek [OpenHoursRule])
email
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap DayOfWeek [OpenHoursRule])
push
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap DayOfWeek [OpenHoursRule])
sms
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap DayOfWeek [OpenHoursRule])
voice

instance Prelude.NFData OpenHours where
  rnf :: OpenHours -> ()
rnf OpenHours' {Maybe (HashMap DayOfWeek [OpenHoursRule])
voice :: Maybe (HashMap DayOfWeek [OpenHoursRule])
sms :: Maybe (HashMap DayOfWeek [OpenHoursRule])
push :: Maybe (HashMap DayOfWeek [OpenHoursRule])
email :: Maybe (HashMap DayOfWeek [OpenHoursRule])
custom :: Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:voice:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:sms:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:push:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:email:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:custom:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap DayOfWeek [OpenHoursRule])
custom
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap DayOfWeek [OpenHoursRule])
email
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap DayOfWeek [OpenHoursRule])
push
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap DayOfWeek [OpenHoursRule])
sms
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap DayOfWeek [OpenHoursRule])
voice

instance Data.ToJSON OpenHours where
  toJSON :: OpenHours -> Value
toJSON OpenHours' {Maybe (HashMap DayOfWeek [OpenHoursRule])
voice :: Maybe (HashMap DayOfWeek [OpenHoursRule])
sms :: Maybe (HashMap DayOfWeek [OpenHoursRule])
push :: Maybe (HashMap DayOfWeek [OpenHoursRule])
email :: Maybe (HashMap DayOfWeek [OpenHoursRule])
custom :: Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:voice:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:sms:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:push:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:email:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
$sel:custom:OpenHours' :: OpenHours -> Maybe (HashMap DayOfWeek [OpenHoursRule])
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CUSTOM" 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 (HashMap DayOfWeek [OpenHoursRule])
custom,
            (Key
"EMAIL" 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 (HashMap DayOfWeek [OpenHoursRule])
email,
            (Key
"PUSH" 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 (HashMap DayOfWeek [OpenHoursRule])
push,
            (Key
"SMS" 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 (HashMap DayOfWeek [OpenHoursRule])
sms,
            (Key
"VOICE" 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 (HashMap DayOfWeek [OpenHoursRule])
voice
          ]
      )