{-# 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.MechanicalTurk.RejectAssignment
-- 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)
--
-- The @RejectAssignment@ operation rejects the results of a completed
-- assignment.
--
-- You can include an optional feedback message with the rejection, which
-- the Worker can see in the Status section of the web site. When you
-- include a feedback message with the rejection, it helps the Worker
-- understand why the assignment was rejected, and can improve the quality
-- of the results the Worker submits in the future.
--
-- Only the Requester who created the HIT can reject an assignment for the
-- HIT.
module Amazonka.MechanicalTurk.RejectAssignment
  ( -- * Creating a Request
    RejectAssignment (..),
    newRejectAssignment,

    -- * Request Lenses
    rejectAssignment_assignmentId,
    rejectAssignment_requesterFeedback,

    -- * Destructuring the Response
    RejectAssignmentResponse (..),
    newRejectAssignmentResponse,

    -- * Response Lenses
    rejectAssignmentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MechanicalTurk.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newRejectAssignment' smart constructor.
data RejectAssignment = RejectAssignment'
  { -- | The ID of the assignment. The assignment must correspond to a HIT
    -- created by the Requester.
    RejectAssignment -> Text
assignmentId :: Prelude.Text,
    -- | A message for the Worker, which the Worker can see in the Status section
    -- of the web site.
    RejectAssignment -> Text
requesterFeedback :: Prelude.Text
  }
  deriving (RejectAssignment -> RejectAssignment -> Bool
(RejectAssignment -> RejectAssignment -> Bool)
-> (RejectAssignment -> RejectAssignment -> Bool)
-> Eq RejectAssignment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RejectAssignment -> RejectAssignment -> Bool
$c/= :: RejectAssignment -> RejectAssignment -> Bool
== :: RejectAssignment -> RejectAssignment -> Bool
$c== :: RejectAssignment -> RejectAssignment -> Bool
Prelude.Eq, ReadPrec [RejectAssignment]
ReadPrec RejectAssignment
Int -> ReadS RejectAssignment
ReadS [RejectAssignment]
(Int -> ReadS RejectAssignment)
-> ReadS [RejectAssignment]
-> ReadPrec RejectAssignment
-> ReadPrec [RejectAssignment]
-> Read RejectAssignment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RejectAssignment]
$creadListPrec :: ReadPrec [RejectAssignment]
readPrec :: ReadPrec RejectAssignment
$creadPrec :: ReadPrec RejectAssignment
readList :: ReadS [RejectAssignment]
$creadList :: ReadS [RejectAssignment]
readsPrec :: Int -> ReadS RejectAssignment
$creadsPrec :: Int -> ReadS RejectAssignment
Prelude.Read, Int -> RejectAssignment -> ShowS
[RejectAssignment] -> ShowS
RejectAssignment -> String
(Int -> RejectAssignment -> ShowS)
-> (RejectAssignment -> String)
-> ([RejectAssignment] -> ShowS)
-> Show RejectAssignment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RejectAssignment] -> ShowS
$cshowList :: [RejectAssignment] -> ShowS
show :: RejectAssignment -> String
$cshow :: RejectAssignment -> String
showsPrec :: Int -> RejectAssignment -> ShowS
$cshowsPrec :: Int -> RejectAssignment -> ShowS
Prelude.Show, (forall x. RejectAssignment -> Rep RejectAssignment x)
-> (forall x. Rep RejectAssignment x -> RejectAssignment)
-> Generic RejectAssignment
forall x. Rep RejectAssignment x -> RejectAssignment
forall x. RejectAssignment -> Rep RejectAssignment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RejectAssignment x -> RejectAssignment
$cfrom :: forall x. RejectAssignment -> Rep RejectAssignment x
Prelude.Generic)

-- |
-- Create a value of 'RejectAssignment' 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:
--
-- 'assignmentId', 'rejectAssignment_assignmentId' - The ID of the assignment. The assignment must correspond to a HIT
-- created by the Requester.
--
-- 'requesterFeedback', 'rejectAssignment_requesterFeedback' - A message for the Worker, which the Worker can see in the Status section
-- of the web site.
newRejectAssignment ::
  -- | 'assignmentId'
  Prelude.Text ->
  -- | 'requesterFeedback'
  Prelude.Text ->
  RejectAssignment
newRejectAssignment :: Text -> Text -> RejectAssignment
newRejectAssignment
  Text
pAssignmentId_
  Text
pRequesterFeedback_ =
    RejectAssignment' :: Text -> Text -> RejectAssignment
RejectAssignment'
      { $sel:assignmentId:RejectAssignment' :: Text
assignmentId = Text
pAssignmentId_,
        $sel:requesterFeedback:RejectAssignment' :: Text
requesterFeedback = Text
pRequesterFeedback_
      }

-- | The ID of the assignment. The assignment must correspond to a HIT
-- created by the Requester.
rejectAssignment_assignmentId :: Lens.Lens' RejectAssignment Prelude.Text
rejectAssignment_assignmentId :: (Text -> f Text) -> RejectAssignment -> f RejectAssignment
rejectAssignment_assignmentId = (RejectAssignment -> Text)
-> (RejectAssignment -> Text -> RejectAssignment)
-> Lens RejectAssignment RejectAssignment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectAssignment' {Text
assignmentId :: Text
$sel:assignmentId:RejectAssignment' :: RejectAssignment -> Text
assignmentId} -> Text
assignmentId) (\s :: RejectAssignment
s@RejectAssignment' {} Text
a -> RejectAssignment
s {$sel:assignmentId:RejectAssignment' :: Text
assignmentId = Text
a} :: RejectAssignment)

-- | A message for the Worker, which the Worker can see in the Status section
-- of the web site.
rejectAssignment_requesterFeedback :: Lens.Lens' RejectAssignment Prelude.Text
rejectAssignment_requesterFeedback :: (Text -> f Text) -> RejectAssignment -> f RejectAssignment
rejectAssignment_requesterFeedback = (RejectAssignment -> Text)
-> (RejectAssignment -> Text -> RejectAssignment)
-> Lens RejectAssignment RejectAssignment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectAssignment' {Text
requesterFeedback :: Text
$sel:requesterFeedback:RejectAssignment' :: RejectAssignment -> Text
requesterFeedback} -> Text
requesterFeedback) (\s :: RejectAssignment
s@RejectAssignment' {} Text
a -> RejectAssignment
s {$sel:requesterFeedback:RejectAssignment' :: Text
requesterFeedback = Text
a} :: RejectAssignment)

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

instance Prelude.Hashable RejectAssignment

instance Prelude.NFData RejectAssignment

instance Core.ToHeaders RejectAssignment where
  toHeaders :: RejectAssignment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RejectAssignment -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"MTurkRequesterServiceV20170117.RejectAssignment" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON RejectAssignment where
  toJSON :: RejectAssignment -> Value
toJSON RejectAssignment' {Text
requesterFeedback :: Text
assignmentId :: Text
$sel:requesterFeedback:RejectAssignment' :: RejectAssignment -> Text
$sel:assignmentId:RejectAssignment' :: RejectAssignment -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AssignmentId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
assignmentId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RequesterFeedback" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
requesterFeedback)
          ]
      )

instance Core.ToPath RejectAssignment where
  toPath :: RejectAssignment -> ByteString
toPath = ByteString -> RejectAssignment -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData RejectAssignmentResponse