{-# 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.JourneySchedule
-- 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.JourneySchedule 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 schedule settings for a journey.
--
-- /See:/ 'newJourneySchedule' smart constructor.
data JourneySchedule = JourneySchedule'
  { -- | The scheduled time, in ISO 8601 format, when the journey ended or will
    -- end.
    JourneySchedule -> Maybe ISO8601
endTime :: Prelude.Maybe Data.ISO8601,
    -- | The scheduled time, in ISO 8601 format, when the journey began or will
    -- begin.
    JourneySchedule -> Maybe ISO8601
startTime :: Prelude.Maybe Data.ISO8601,
    -- | The starting UTC offset for the journey schedule, if the value of the
    -- journey\'s LocalTime property is true. Valid values are: UTC, UTC+01,
    -- UTC+02, UTC+03, UTC+03:30, UTC+04, UTC+04:30, UTC+05, UTC+05:30,
    -- UTC+05:45, UTC+06, UTC+06:30, UTC+07, UTC+08, UTC+08:45, UTC+09,
    -- UTC+09:30, UTC+10, UTC+10:30, UTC+11, UTC+12, UTC+12:45, UTC+13,
    -- UTC+13:45, UTC-02, UTC-02:30, UTC-03, UTC-03:30, UTC-04, UTC-05, UTC-06,
    -- UTC-07, UTC-08, UTC-09, UTC-09:30, UTC-10, and UTC-11.
    JourneySchedule -> Maybe Text
timezone :: Prelude.Maybe Prelude.Text
  }
  deriving (JourneySchedule -> JourneySchedule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JourneySchedule -> JourneySchedule -> Bool
$c/= :: JourneySchedule -> JourneySchedule -> Bool
== :: JourneySchedule -> JourneySchedule -> Bool
$c== :: JourneySchedule -> JourneySchedule -> Bool
Prelude.Eq, ReadPrec [JourneySchedule]
ReadPrec JourneySchedule
Int -> ReadS JourneySchedule
ReadS [JourneySchedule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JourneySchedule]
$creadListPrec :: ReadPrec [JourneySchedule]
readPrec :: ReadPrec JourneySchedule
$creadPrec :: ReadPrec JourneySchedule
readList :: ReadS [JourneySchedule]
$creadList :: ReadS [JourneySchedule]
readsPrec :: Int -> ReadS JourneySchedule
$creadsPrec :: Int -> ReadS JourneySchedule
Prelude.Read, Int -> JourneySchedule -> ShowS
[JourneySchedule] -> ShowS
JourneySchedule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JourneySchedule] -> ShowS
$cshowList :: [JourneySchedule] -> ShowS
show :: JourneySchedule -> String
$cshow :: JourneySchedule -> String
showsPrec :: Int -> JourneySchedule -> ShowS
$cshowsPrec :: Int -> JourneySchedule -> ShowS
Prelude.Show, forall x. Rep JourneySchedule x -> JourneySchedule
forall x. JourneySchedule -> Rep JourneySchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JourneySchedule x -> JourneySchedule
$cfrom :: forall x. JourneySchedule -> Rep JourneySchedule x
Prelude.Generic)

-- |
-- Create a value of 'JourneySchedule' 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:
--
-- 'endTime', 'journeySchedule_endTime' - The scheduled time, in ISO 8601 format, when the journey ended or will
-- end.
--
-- 'startTime', 'journeySchedule_startTime' - The scheduled time, in ISO 8601 format, when the journey began or will
-- begin.
--
-- 'timezone', 'journeySchedule_timezone' - The starting UTC offset for the journey schedule, if the value of the
-- journey\'s LocalTime property is true. Valid values are: UTC, UTC+01,
-- UTC+02, UTC+03, UTC+03:30, UTC+04, UTC+04:30, UTC+05, UTC+05:30,
-- UTC+05:45, UTC+06, UTC+06:30, UTC+07, UTC+08, UTC+08:45, UTC+09,
-- UTC+09:30, UTC+10, UTC+10:30, UTC+11, UTC+12, UTC+12:45, UTC+13,
-- UTC+13:45, UTC-02, UTC-02:30, UTC-03, UTC-03:30, UTC-04, UTC-05, UTC-06,
-- UTC-07, UTC-08, UTC-09, UTC-09:30, UTC-10, and UTC-11.
newJourneySchedule ::
  JourneySchedule
newJourneySchedule :: JourneySchedule
newJourneySchedule =
  JourneySchedule'
    { $sel:endTime:JourneySchedule' :: Maybe ISO8601
endTime = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:JourneySchedule' :: Maybe ISO8601
startTime = forall a. Maybe a
Prelude.Nothing,
      $sel:timezone:JourneySchedule' :: Maybe Text
timezone = forall a. Maybe a
Prelude.Nothing
    }

-- | The scheduled time, in ISO 8601 format, when the journey ended or will
-- end.
journeySchedule_endTime :: Lens.Lens' JourneySchedule (Prelude.Maybe Prelude.UTCTime)
journeySchedule_endTime :: Lens' JourneySchedule (Maybe UTCTime)
journeySchedule_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneySchedule' {Maybe ISO8601
endTime :: Maybe ISO8601
$sel:endTime:JourneySchedule' :: JourneySchedule -> Maybe ISO8601
endTime} -> Maybe ISO8601
endTime) (\s :: JourneySchedule
s@JourneySchedule' {} Maybe ISO8601
a -> JourneySchedule
s {$sel:endTime:JourneySchedule' :: Maybe ISO8601
endTime = Maybe ISO8601
a} :: JourneySchedule) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The scheduled time, in ISO 8601 format, when the journey began or will
-- begin.
journeySchedule_startTime :: Lens.Lens' JourneySchedule (Prelude.Maybe Prelude.UTCTime)
journeySchedule_startTime :: Lens' JourneySchedule (Maybe UTCTime)
journeySchedule_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneySchedule' {Maybe ISO8601
startTime :: Maybe ISO8601
$sel:startTime:JourneySchedule' :: JourneySchedule -> Maybe ISO8601
startTime} -> Maybe ISO8601
startTime) (\s :: JourneySchedule
s@JourneySchedule' {} Maybe ISO8601
a -> JourneySchedule
s {$sel:startTime:JourneySchedule' :: Maybe ISO8601
startTime = Maybe ISO8601
a} :: JourneySchedule) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The starting UTC offset for the journey schedule, if the value of the
-- journey\'s LocalTime property is true. Valid values are: UTC, UTC+01,
-- UTC+02, UTC+03, UTC+03:30, UTC+04, UTC+04:30, UTC+05, UTC+05:30,
-- UTC+05:45, UTC+06, UTC+06:30, UTC+07, UTC+08, UTC+08:45, UTC+09,
-- UTC+09:30, UTC+10, UTC+10:30, UTC+11, UTC+12, UTC+12:45, UTC+13,
-- UTC+13:45, UTC-02, UTC-02:30, UTC-03, UTC-03:30, UTC-04, UTC-05, UTC-06,
-- UTC-07, UTC-08, UTC-09, UTC-09:30, UTC-10, and UTC-11.
journeySchedule_timezone :: Lens.Lens' JourneySchedule (Prelude.Maybe Prelude.Text)
journeySchedule_timezone :: Lens' JourneySchedule (Maybe Text)
journeySchedule_timezone = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneySchedule' {Maybe Text
timezone :: Maybe Text
$sel:timezone:JourneySchedule' :: JourneySchedule -> Maybe Text
timezone} -> Maybe Text
timezone) (\s :: JourneySchedule
s@JourneySchedule' {} Maybe Text
a -> JourneySchedule
s {$sel:timezone:JourneySchedule' :: Maybe Text
timezone = Maybe Text
a} :: JourneySchedule)

instance Data.FromJSON JourneySchedule where
  parseJSON :: Value -> Parser JourneySchedule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JourneySchedule"
      ( \Object
x ->
          Maybe ISO8601 -> Maybe ISO8601 -> Maybe Text -> JourneySchedule
JourneySchedule'
            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
"EndTime")
            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
"StartTime")
            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
"Timezone")
      )

instance Prelude.Hashable JourneySchedule where
  hashWithSalt :: Int -> JourneySchedule -> Int
hashWithSalt Int
_salt JourneySchedule' {Maybe Text
Maybe ISO8601
timezone :: Maybe Text
startTime :: Maybe ISO8601
endTime :: Maybe ISO8601
$sel:timezone:JourneySchedule' :: JourneySchedule -> Maybe Text
$sel:startTime:JourneySchedule' :: JourneySchedule -> Maybe ISO8601
$sel:endTime:JourneySchedule' :: JourneySchedule -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
endTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
timezone

instance Prelude.NFData JourneySchedule where
  rnf :: JourneySchedule -> ()
rnf JourneySchedule' {Maybe Text
Maybe ISO8601
timezone :: Maybe Text
startTime :: Maybe ISO8601
endTime :: Maybe ISO8601
$sel:timezone:JourneySchedule' :: JourneySchedule -> Maybe Text
$sel:startTime:JourneySchedule' :: JourneySchedule -> Maybe ISO8601
$sel:endTime:JourneySchedule' :: JourneySchedule -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
endTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
timezone

instance Data.ToJSON JourneySchedule where
  toJSON :: JourneySchedule -> Value
toJSON JourneySchedule' {Maybe Text
Maybe ISO8601
timezone :: Maybe Text
startTime :: Maybe ISO8601
endTime :: Maybe ISO8601
$sel:timezone:JourneySchedule' :: JourneySchedule -> Maybe Text
$sel:startTime:JourneySchedule' :: JourneySchedule -> Maybe ISO8601
$sel:endTime:JourneySchedule' :: JourneySchedule -> Maybe ISO8601
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EndTime" 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 ISO8601
endTime,
            (Key
"StartTime" 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 ISO8601
startTime,
            (Key
"Timezone" 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
timezone
          ]
      )