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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 began or will
    -- begin.
    JourneySchedule -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | The scheduled time, in ISO 8601 format, when the journey ended or will
    -- end.
    JourneySchedule -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX,
    -- | 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
(JourneySchedule -> JourneySchedule -> Bool)
-> (JourneySchedule -> JourneySchedule -> Bool)
-> Eq JourneySchedule
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]
(Int -> ReadS JourneySchedule)
-> ReadS [JourneySchedule]
-> ReadPrec JourneySchedule
-> ReadPrec [JourneySchedule]
-> Read 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
(Int -> JourneySchedule -> ShowS)
-> (JourneySchedule -> String)
-> ([JourneySchedule] -> ShowS)
-> Show JourneySchedule
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. JourneySchedule -> Rep JourneySchedule x)
-> (forall x. Rep JourneySchedule x -> JourneySchedule)
-> Generic JourneySchedule
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:
--
-- 'startTime', 'journeySchedule_startTime' - The scheduled time, in ISO 8601 format, when the journey began or will
-- begin.
--
-- 'endTime', 'journeySchedule_endTime' - The scheduled time, in ISO 8601 format, when the journey ended or will
-- end.
--
-- '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' :: Maybe POSIX -> Maybe POSIX -> Maybe Text -> JourneySchedule
JourneySchedule'
    { $sel:startTime:JourneySchedule' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:JourneySchedule' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:timezone:JourneySchedule' :: Maybe Text
timezone = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> JourneySchedule -> f JourneySchedule
journeySchedule_startTime = (JourneySchedule -> Maybe POSIX)
-> (JourneySchedule -> Maybe POSIX -> JourneySchedule)
-> Lens JourneySchedule JourneySchedule (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneySchedule' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:JourneySchedule' :: JourneySchedule -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: JourneySchedule
s@JourneySchedule' {} Maybe POSIX
a -> JourneySchedule
s {$sel:startTime:JourneySchedule' :: Maybe POSIX
startTime = Maybe POSIX
a} :: JourneySchedule) ((Maybe POSIX -> f (Maybe POSIX))
 -> JourneySchedule -> f JourneySchedule)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> JourneySchedule
-> f JourneySchedule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | 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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> JourneySchedule -> f JourneySchedule
journeySchedule_endTime = (JourneySchedule -> Maybe POSIX)
-> (JourneySchedule -> Maybe POSIX -> JourneySchedule)
-> Lens JourneySchedule JourneySchedule (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneySchedule' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:JourneySchedule' :: JourneySchedule -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: JourneySchedule
s@JourneySchedule' {} Maybe POSIX
a -> JourneySchedule
s {$sel:endTime:JourneySchedule' :: Maybe POSIX
endTime = Maybe POSIX
a} :: JourneySchedule) ((Maybe POSIX -> f (Maybe POSIX))
 -> JourneySchedule -> f JourneySchedule)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> JourneySchedule
-> f JourneySchedule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._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 :: (Maybe Text -> f (Maybe Text))
-> JourneySchedule -> f JourneySchedule
journeySchedule_timezone = (JourneySchedule -> Maybe Text)
-> (JourneySchedule -> Maybe Text -> JourneySchedule)
-> Lens JourneySchedule JourneySchedule (Maybe Text) (Maybe Text)
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 Core.FromJSON JourneySchedule where
  parseJSON :: Value -> Parser JourneySchedule
parseJSON =
    String
-> (Object -> Parser JourneySchedule)
-> Value
-> Parser JourneySchedule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JourneySchedule"
      ( \Object
x ->
          Maybe POSIX -> Maybe POSIX -> Maybe Text -> JourneySchedule
JourneySchedule'
            (Maybe POSIX -> Maybe POSIX -> Maybe Text -> JourneySchedule)
-> Parser (Maybe POSIX)
-> Parser (Maybe POSIX -> Maybe Text -> JourneySchedule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartTime")
            Parser (Maybe POSIX -> Maybe Text -> JourneySchedule)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> JourneySchedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EndTime")
            Parser (Maybe Text -> JourneySchedule)
-> Parser (Maybe Text) -> Parser JourneySchedule
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
"Timezone")
      )

instance Prelude.Hashable JourneySchedule

instance Prelude.NFData JourneySchedule

instance Core.ToJSON JourneySchedule where
  toJSON :: JourneySchedule -> Value
toJSON JourneySchedule' {Maybe Text
Maybe POSIX
timezone :: Maybe Text
endTime :: Maybe POSIX
startTime :: Maybe POSIX
$sel:timezone:JourneySchedule' :: JourneySchedule -> Maybe Text
$sel:endTime:JourneySchedule' :: JourneySchedule -> Maybe POSIX
$sel:startTime:JourneySchedule' :: JourneySchedule -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StartTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
startTime,
            (Text
"EndTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
endTime,
            (Text
"Timezone" 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
timezone
          ]
      )