{-# 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.ConnectParticipant.Types.StartPosition
-- 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.ConnectParticipant.Types.StartPosition 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

-- | A filtering option for where to start. For example, if you sent 100
-- messages, start with message 50.
--
-- /See:/ 'newStartPosition' smart constructor.
data StartPosition = StartPosition'
  { -- | The time in ISO format where to start.
    --
    -- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
    -- example, 2019-11-08T02:41:28.172Z.
    StartPosition -> Maybe Text
absoluteTime :: Prelude.Maybe Prelude.Text,
    -- | The ID of the message or event where to start.
    StartPosition -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The start position of the most recent message where you want to start.
    StartPosition -> Maybe Natural
mostRecent :: Prelude.Maybe Prelude.Natural
  }
  deriving (StartPosition -> StartPosition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartPosition -> StartPosition -> Bool
$c/= :: StartPosition -> StartPosition -> Bool
== :: StartPosition -> StartPosition -> Bool
$c== :: StartPosition -> StartPosition -> Bool
Prelude.Eq, ReadPrec [StartPosition]
ReadPrec StartPosition
Int -> ReadS StartPosition
ReadS [StartPosition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartPosition]
$creadListPrec :: ReadPrec [StartPosition]
readPrec :: ReadPrec StartPosition
$creadPrec :: ReadPrec StartPosition
readList :: ReadS [StartPosition]
$creadList :: ReadS [StartPosition]
readsPrec :: Int -> ReadS StartPosition
$creadsPrec :: Int -> ReadS StartPosition
Prelude.Read, Int -> StartPosition -> ShowS
[StartPosition] -> ShowS
StartPosition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartPosition] -> ShowS
$cshowList :: [StartPosition] -> ShowS
show :: StartPosition -> String
$cshow :: StartPosition -> String
showsPrec :: Int -> StartPosition -> ShowS
$cshowsPrec :: Int -> StartPosition -> ShowS
Prelude.Show, forall x. Rep StartPosition x -> StartPosition
forall x. StartPosition -> Rep StartPosition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartPosition x -> StartPosition
$cfrom :: forall x. StartPosition -> Rep StartPosition x
Prelude.Generic)

-- |
-- Create a value of 'StartPosition' 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:
--
-- 'absoluteTime', 'startPosition_absoluteTime' - The time in ISO format where to start.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
--
-- 'id', 'startPosition_id' - The ID of the message or event where to start.
--
-- 'mostRecent', 'startPosition_mostRecent' - The start position of the most recent message where you want to start.
newStartPosition ::
  StartPosition
newStartPosition :: StartPosition
newStartPosition =
  StartPosition'
    { $sel:absoluteTime:StartPosition' :: Maybe Text
absoluteTime = forall a. Maybe a
Prelude.Nothing,
      $sel:id:StartPosition' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:mostRecent:StartPosition' :: Maybe Natural
mostRecent = forall a. Maybe a
Prelude.Nothing
    }

-- | The time in ISO format where to start.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
startPosition_absoluteTime :: Lens.Lens' StartPosition (Prelude.Maybe Prelude.Text)
startPosition_absoluteTime :: Lens' StartPosition (Maybe Text)
startPosition_absoluteTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPosition' {Maybe Text
absoluteTime :: Maybe Text
$sel:absoluteTime:StartPosition' :: StartPosition -> Maybe Text
absoluteTime} -> Maybe Text
absoluteTime) (\s :: StartPosition
s@StartPosition' {} Maybe Text
a -> StartPosition
s {$sel:absoluteTime:StartPosition' :: Maybe Text
absoluteTime = Maybe Text
a} :: StartPosition)

-- | The ID of the message or event where to start.
startPosition_id :: Lens.Lens' StartPosition (Prelude.Maybe Prelude.Text)
startPosition_id :: Lens' StartPosition (Maybe Text)
startPosition_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPosition' {Maybe Text
id :: Maybe Text
$sel:id:StartPosition' :: StartPosition -> Maybe Text
id} -> Maybe Text
id) (\s :: StartPosition
s@StartPosition' {} Maybe Text
a -> StartPosition
s {$sel:id:StartPosition' :: Maybe Text
id = Maybe Text
a} :: StartPosition)

-- | The start position of the most recent message where you want to start.
startPosition_mostRecent :: Lens.Lens' StartPosition (Prelude.Maybe Prelude.Natural)
startPosition_mostRecent :: Lens' StartPosition (Maybe Natural)
startPosition_mostRecent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPosition' {Maybe Natural
mostRecent :: Maybe Natural
$sel:mostRecent:StartPosition' :: StartPosition -> Maybe Natural
mostRecent} -> Maybe Natural
mostRecent) (\s :: StartPosition
s@StartPosition' {} Maybe Natural
a -> StartPosition
s {$sel:mostRecent:StartPosition' :: Maybe Natural
mostRecent = Maybe Natural
a} :: StartPosition)

instance Prelude.Hashable StartPosition where
  hashWithSalt :: Int -> StartPosition -> Int
hashWithSalt Int
_salt StartPosition' {Maybe Natural
Maybe Text
mostRecent :: Maybe Natural
id :: Maybe Text
absoluteTime :: Maybe Text
$sel:mostRecent:StartPosition' :: StartPosition -> Maybe Natural
$sel:id:StartPosition' :: StartPosition -> Maybe Text
$sel:absoluteTime:StartPosition' :: StartPosition -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
absoluteTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
mostRecent

instance Prelude.NFData StartPosition where
  rnf :: StartPosition -> ()
rnf StartPosition' {Maybe Natural
Maybe Text
mostRecent :: Maybe Natural
id :: Maybe Text
absoluteTime :: Maybe Text
$sel:mostRecent:StartPosition' :: StartPosition -> Maybe Natural
$sel:id:StartPosition' :: StartPosition -> Maybe Text
$sel:absoluteTime:StartPosition' :: StartPosition -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
absoluteTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
mostRecent

instance Data.ToJSON StartPosition where
  toJSON :: StartPosition -> Value
toJSON StartPosition' {Maybe Natural
Maybe Text
mostRecent :: Maybe Natural
id :: Maybe Text
absoluteTime :: Maybe Text
$sel:mostRecent:StartPosition' :: StartPosition -> Maybe Natural
$sel:id:StartPosition' :: StartPosition -> Maybe Text
$sel:absoluteTime:StartPosition' :: StartPosition -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AbsoluteTime" 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
absoluteTime,
            (Key
"Id" 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
id,
            (Key
"MostRecent" 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 Natural
mostRecent
          ]
      )