{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Connect.UpdateContactSchedule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the scheduled time of a task contact that is already scheduled.
module Amazonka.Connect.UpdateContactSchedule
  ( -- * Creating a Request
    UpdateContactSchedule (..),
    newUpdateContactSchedule,

    -- * Request Lenses
    updateContactSchedule_instanceId,
    updateContactSchedule_contactId,
    updateContactSchedule_scheduledTime,

    -- * Destructuring the Response
    UpdateContactScheduleResponse (..),
    newUpdateContactScheduleResponse,

    -- * Response Lenses
    updateContactScheduleResponse_httpStatus,
  )
where

import Amazonka.Connect.Types
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateContactSchedule' smart constructor.
data UpdateContactSchedule = UpdateContactSchedule'
  { -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    UpdateContactSchedule -> Text
instanceId :: Prelude.Text,
    -- | The identifier of the contact.
    UpdateContactSchedule -> Text
contactId :: Prelude.Text,
    -- | The timestamp, in Unix Epoch seconds format, at which to start running
    -- the inbound flow. The scheduled time cannot be in the past. It must be
    -- within up to 6 days in future.
    UpdateContactSchedule -> POSIX
scheduledTime :: Data.POSIX
  }
  deriving (UpdateContactSchedule -> UpdateContactSchedule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateContactSchedule -> UpdateContactSchedule -> Bool
$c/= :: UpdateContactSchedule -> UpdateContactSchedule -> Bool
== :: UpdateContactSchedule -> UpdateContactSchedule -> Bool
$c== :: UpdateContactSchedule -> UpdateContactSchedule -> Bool
Prelude.Eq, ReadPrec [UpdateContactSchedule]
ReadPrec UpdateContactSchedule
Int -> ReadS UpdateContactSchedule
ReadS [UpdateContactSchedule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateContactSchedule]
$creadListPrec :: ReadPrec [UpdateContactSchedule]
readPrec :: ReadPrec UpdateContactSchedule
$creadPrec :: ReadPrec UpdateContactSchedule
readList :: ReadS [UpdateContactSchedule]
$creadList :: ReadS [UpdateContactSchedule]
readsPrec :: Int -> ReadS UpdateContactSchedule
$creadsPrec :: Int -> ReadS UpdateContactSchedule
Prelude.Read, Int -> UpdateContactSchedule -> ShowS
[UpdateContactSchedule] -> ShowS
UpdateContactSchedule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateContactSchedule] -> ShowS
$cshowList :: [UpdateContactSchedule] -> ShowS
show :: UpdateContactSchedule -> String
$cshow :: UpdateContactSchedule -> String
showsPrec :: Int -> UpdateContactSchedule -> ShowS
$cshowsPrec :: Int -> UpdateContactSchedule -> ShowS
Prelude.Show, forall x. Rep UpdateContactSchedule x -> UpdateContactSchedule
forall x. UpdateContactSchedule -> Rep UpdateContactSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateContactSchedule x -> UpdateContactSchedule
$cfrom :: forall x. UpdateContactSchedule -> Rep UpdateContactSchedule x
Prelude.Generic)

-- |
-- Create a value of 'UpdateContactSchedule' 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:
--
-- 'instanceId', 'updateContactSchedule_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
--
-- 'contactId', 'updateContactSchedule_contactId' - The identifier of the contact.
--
-- 'scheduledTime', 'updateContactSchedule_scheduledTime' - The timestamp, in Unix Epoch seconds format, at which to start running
-- the inbound flow. The scheduled time cannot be in the past. It must be
-- within up to 6 days in future.
newUpdateContactSchedule ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'contactId'
  Prelude.Text ->
  -- | 'scheduledTime'
  Prelude.UTCTime ->
  UpdateContactSchedule
newUpdateContactSchedule :: Text -> Text -> UTCTime -> UpdateContactSchedule
newUpdateContactSchedule
  Text
pInstanceId_
  Text
pContactId_
  UTCTime
pScheduledTime_ =
    UpdateContactSchedule'
      { $sel:instanceId:UpdateContactSchedule' :: Text
instanceId = Text
pInstanceId_,
        $sel:contactId:UpdateContactSchedule' :: Text
contactId = Text
pContactId_,
        $sel:scheduledTime:UpdateContactSchedule' :: POSIX
scheduledTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pScheduledTime_
      }

-- | The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
updateContactSchedule_instanceId :: Lens.Lens' UpdateContactSchedule Prelude.Text
updateContactSchedule_instanceId :: Lens' UpdateContactSchedule Text
updateContactSchedule_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactSchedule' {Text
instanceId :: Text
$sel:instanceId:UpdateContactSchedule' :: UpdateContactSchedule -> Text
instanceId} -> Text
instanceId) (\s :: UpdateContactSchedule
s@UpdateContactSchedule' {} Text
a -> UpdateContactSchedule
s {$sel:instanceId:UpdateContactSchedule' :: Text
instanceId = Text
a} :: UpdateContactSchedule)

-- | The identifier of the contact.
updateContactSchedule_contactId :: Lens.Lens' UpdateContactSchedule Prelude.Text
updateContactSchedule_contactId :: Lens' UpdateContactSchedule Text
updateContactSchedule_contactId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactSchedule' {Text
contactId :: Text
$sel:contactId:UpdateContactSchedule' :: UpdateContactSchedule -> Text
contactId} -> Text
contactId) (\s :: UpdateContactSchedule
s@UpdateContactSchedule' {} Text
a -> UpdateContactSchedule
s {$sel:contactId:UpdateContactSchedule' :: Text
contactId = Text
a} :: UpdateContactSchedule)

-- | The timestamp, in Unix Epoch seconds format, at which to start running
-- the inbound flow. The scheduled time cannot be in the past. It must be
-- within up to 6 days in future.
updateContactSchedule_scheduledTime :: Lens.Lens' UpdateContactSchedule Prelude.UTCTime
updateContactSchedule_scheduledTime :: Lens' UpdateContactSchedule UTCTime
updateContactSchedule_scheduledTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactSchedule' {POSIX
scheduledTime :: POSIX
$sel:scheduledTime:UpdateContactSchedule' :: UpdateContactSchedule -> POSIX
scheduledTime} -> POSIX
scheduledTime) (\s :: UpdateContactSchedule
s@UpdateContactSchedule' {} POSIX
a -> UpdateContactSchedule
s {$sel:scheduledTime:UpdateContactSchedule' :: POSIX
scheduledTime = POSIX
a} :: UpdateContactSchedule) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Core.AWSRequest UpdateContactSchedule where
  type
    AWSResponse UpdateContactSchedule =
      UpdateContactScheduleResponse
  request :: (Service -> Service)
-> UpdateContactSchedule -> Request UpdateContactSchedule
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateContactSchedule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateContactSchedule)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateContactScheduleResponse
UpdateContactScheduleResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateContactSchedule where
  hashWithSalt :: Int -> UpdateContactSchedule -> Int
hashWithSalt Int
_salt UpdateContactSchedule' {Text
POSIX
scheduledTime :: POSIX
contactId :: Text
instanceId :: Text
$sel:scheduledTime:UpdateContactSchedule' :: UpdateContactSchedule -> POSIX
$sel:contactId:UpdateContactSchedule' :: UpdateContactSchedule -> Text
$sel:instanceId:UpdateContactSchedule' :: UpdateContactSchedule -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contactId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
scheduledTime

instance Prelude.NFData UpdateContactSchedule where
  rnf :: UpdateContactSchedule -> ()
rnf UpdateContactSchedule' {Text
POSIX
scheduledTime :: POSIX
contactId :: Text
instanceId :: Text
$sel:scheduledTime:UpdateContactSchedule' :: UpdateContactSchedule -> POSIX
$sel:contactId:UpdateContactSchedule' :: UpdateContactSchedule -> Text
$sel:instanceId:UpdateContactSchedule' :: UpdateContactSchedule -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
contactId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
scheduledTime

instance Data.ToHeaders UpdateContactSchedule where
  toHeaders :: UpdateContactSchedule -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateContactSchedule where
  toJSON :: UpdateContactSchedule -> Value
toJSON UpdateContactSchedule' {Text
POSIX
scheduledTime :: POSIX
contactId :: Text
instanceId :: Text
$sel:scheduledTime:UpdateContactSchedule' :: UpdateContactSchedule -> POSIX
$sel:contactId:UpdateContactSchedule' :: UpdateContactSchedule -> Text
$sel:instanceId:UpdateContactSchedule' :: UpdateContactSchedule -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"InstanceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
instanceId),
            forall a. a -> Maybe a
Prelude.Just (Key
"ContactId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
contactId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ScheduledTime" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= POSIX
scheduledTime)
          ]
      )

instance Data.ToPath UpdateContactSchedule where
  toPath :: UpdateContactSchedule -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/contact/schedule"

instance Data.ToQuery UpdateContactSchedule where
  toQuery :: UpdateContactSchedule -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateContactScheduleResponse' smart constructor.
data UpdateContactScheduleResponse = UpdateContactScheduleResponse'
  { -- | The response's http status code.
    UpdateContactScheduleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateContactScheduleResponse
-> UpdateContactScheduleResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateContactScheduleResponse
-> UpdateContactScheduleResponse -> Bool
$c/= :: UpdateContactScheduleResponse
-> UpdateContactScheduleResponse -> Bool
== :: UpdateContactScheduleResponse
-> UpdateContactScheduleResponse -> Bool
$c== :: UpdateContactScheduleResponse
-> UpdateContactScheduleResponse -> Bool
Prelude.Eq, ReadPrec [UpdateContactScheduleResponse]
ReadPrec UpdateContactScheduleResponse
Int -> ReadS UpdateContactScheduleResponse
ReadS [UpdateContactScheduleResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateContactScheduleResponse]
$creadListPrec :: ReadPrec [UpdateContactScheduleResponse]
readPrec :: ReadPrec UpdateContactScheduleResponse
$creadPrec :: ReadPrec UpdateContactScheduleResponse
readList :: ReadS [UpdateContactScheduleResponse]
$creadList :: ReadS [UpdateContactScheduleResponse]
readsPrec :: Int -> ReadS UpdateContactScheduleResponse
$creadsPrec :: Int -> ReadS UpdateContactScheduleResponse
Prelude.Read, Int -> UpdateContactScheduleResponse -> ShowS
[UpdateContactScheduleResponse] -> ShowS
UpdateContactScheduleResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateContactScheduleResponse] -> ShowS
$cshowList :: [UpdateContactScheduleResponse] -> ShowS
show :: UpdateContactScheduleResponse -> String
$cshow :: UpdateContactScheduleResponse -> String
showsPrec :: Int -> UpdateContactScheduleResponse -> ShowS
$cshowsPrec :: Int -> UpdateContactScheduleResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateContactScheduleResponse x
-> UpdateContactScheduleResponse
forall x.
UpdateContactScheduleResponse
-> Rep UpdateContactScheduleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateContactScheduleResponse x
-> UpdateContactScheduleResponse
$cfrom :: forall x.
UpdateContactScheduleResponse
-> Rep UpdateContactScheduleResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateContactScheduleResponse' 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:
--
-- 'httpStatus', 'updateContactScheduleResponse_httpStatus' - The response's http status code.
newUpdateContactScheduleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateContactScheduleResponse
newUpdateContactScheduleResponse :: Int -> UpdateContactScheduleResponse
newUpdateContactScheduleResponse Int
pHttpStatus_ =
  UpdateContactScheduleResponse'
    { $sel:httpStatus:UpdateContactScheduleResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateContactScheduleResponse_httpStatus :: Lens.Lens' UpdateContactScheduleResponse Prelude.Int
updateContactScheduleResponse_httpStatus :: Lens' UpdateContactScheduleResponse Int
updateContactScheduleResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactScheduleResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateContactScheduleResponse' :: UpdateContactScheduleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateContactScheduleResponse
s@UpdateContactScheduleResponse' {} Int
a -> UpdateContactScheduleResponse
s {$sel:httpStatus:UpdateContactScheduleResponse' :: Int
httpStatus = Int
a} :: UpdateContactScheduleResponse)

instance Prelude.NFData UpdateContactScheduleResponse where
  rnf :: UpdateContactScheduleResponse -> ()
rnf UpdateContactScheduleResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateContactScheduleResponse' :: UpdateContactScheduleResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus