{-# 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.RejectQualificationRequest
-- 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 @RejectQualificationRequest@ operation rejects a user\'s request for
-- a Qualification.
--
-- You can provide a text message explaining why the request was rejected.
-- The Worker who made the request can see this message.
module Amazonka.MechanicalTurk.RejectQualificationRequest
  ( -- * Creating a Request
    RejectQualificationRequest (..),
    newRejectQualificationRequest,

    -- * Request Lenses
    rejectQualificationRequest_reason,
    rejectQualificationRequest_qualificationRequestId,

    -- * Destructuring the Response
    RejectQualificationRequestResponse (..),
    newRejectQualificationRequestResponse,

    -- * Response Lenses
    rejectQualificationRequestResponse_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:/ 'newRejectQualificationRequest' smart constructor.
data RejectQualificationRequest = RejectQualificationRequest'
  { -- | A text message explaining why the request was rejected, to be shown to
    -- the Worker who made the request.
    RejectQualificationRequest -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Qualification request, as returned by the
    -- @ListQualificationRequests@ operation.
    RejectQualificationRequest -> Text
qualificationRequestId :: Prelude.Text
  }
  deriving (RejectQualificationRequest -> RejectQualificationRequest -> Bool
(RejectQualificationRequest -> RejectQualificationRequest -> Bool)
-> (RejectQualificationRequest
    -> RejectQualificationRequest -> Bool)
-> Eq RejectQualificationRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RejectQualificationRequest -> RejectQualificationRequest -> Bool
$c/= :: RejectQualificationRequest -> RejectQualificationRequest -> Bool
== :: RejectQualificationRequest -> RejectQualificationRequest -> Bool
$c== :: RejectQualificationRequest -> RejectQualificationRequest -> Bool
Prelude.Eq, ReadPrec [RejectQualificationRequest]
ReadPrec RejectQualificationRequest
Int -> ReadS RejectQualificationRequest
ReadS [RejectQualificationRequest]
(Int -> ReadS RejectQualificationRequest)
-> ReadS [RejectQualificationRequest]
-> ReadPrec RejectQualificationRequest
-> ReadPrec [RejectQualificationRequest]
-> Read RejectQualificationRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RejectQualificationRequest]
$creadListPrec :: ReadPrec [RejectQualificationRequest]
readPrec :: ReadPrec RejectQualificationRequest
$creadPrec :: ReadPrec RejectQualificationRequest
readList :: ReadS [RejectQualificationRequest]
$creadList :: ReadS [RejectQualificationRequest]
readsPrec :: Int -> ReadS RejectQualificationRequest
$creadsPrec :: Int -> ReadS RejectQualificationRequest
Prelude.Read, Int -> RejectQualificationRequest -> ShowS
[RejectQualificationRequest] -> ShowS
RejectQualificationRequest -> String
(Int -> RejectQualificationRequest -> ShowS)
-> (RejectQualificationRequest -> String)
-> ([RejectQualificationRequest] -> ShowS)
-> Show RejectQualificationRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RejectQualificationRequest] -> ShowS
$cshowList :: [RejectQualificationRequest] -> ShowS
show :: RejectQualificationRequest -> String
$cshow :: RejectQualificationRequest -> String
showsPrec :: Int -> RejectQualificationRequest -> ShowS
$cshowsPrec :: Int -> RejectQualificationRequest -> ShowS
Prelude.Show, (forall x.
 RejectQualificationRequest -> Rep RejectQualificationRequest x)
-> (forall x.
    Rep RejectQualificationRequest x -> RejectQualificationRequest)
-> Generic RejectQualificationRequest
forall x.
Rep RejectQualificationRequest x -> RejectQualificationRequest
forall x.
RejectQualificationRequest -> Rep RejectQualificationRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RejectQualificationRequest x -> RejectQualificationRequest
$cfrom :: forall x.
RejectQualificationRequest -> Rep RejectQualificationRequest x
Prelude.Generic)

-- |
-- Create a value of 'RejectQualificationRequest' 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:
--
-- 'reason', 'rejectQualificationRequest_reason' - A text message explaining why the request was rejected, to be shown to
-- the Worker who made the request.
--
-- 'qualificationRequestId', 'rejectQualificationRequest_qualificationRequestId' - The ID of the Qualification request, as returned by the
-- @ListQualificationRequests@ operation.
newRejectQualificationRequest ::
  -- | 'qualificationRequestId'
  Prelude.Text ->
  RejectQualificationRequest
newRejectQualificationRequest :: Text -> RejectQualificationRequest
newRejectQualificationRequest
  Text
pQualificationRequestId_ =
    RejectQualificationRequest' :: Maybe Text -> Text -> RejectQualificationRequest
RejectQualificationRequest'
      { $sel:reason:RejectQualificationRequest' :: Maybe Text
reason =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:qualificationRequestId:RejectQualificationRequest' :: Text
qualificationRequestId =
          Text
pQualificationRequestId_
      }

-- | A text message explaining why the request was rejected, to be shown to
-- the Worker who made the request.
rejectQualificationRequest_reason :: Lens.Lens' RejectQualificationRequest (Prelude.Maybe Prelude.Text)
rejectQualificationRequest_reason :: (Maybe Text -> f (Maybe Text))
-> RejectQualificationRequest -> f RejectQualificationRequest
rejectQualificationRequest_reason = (RejectQualificationRequest -> Maybe Text)
-> (RejectQualificationRequest
    -> Maybe Text -> RejectQualificationRequest)
-> Lens
     RejectQualificationRequest
     RejectQualificationRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectQualificationRequest' {Maybe Text
reason :: Maybe Text
$sel:reason:RejectQualificationRequest' :: RejectQualificationRequest -> Maybe Text
reason} -> Maybe Text
reason) (\s :: RejectQualificationRequest
s@RejectQualificationRequest' {} Maybe Text
a -> RejectQualificationRequest
s {$sel:reason:RejectQualificationRequest' :: Maybe Text
reason = Maybe Text
a} :: RejectQualificationRequest)

-- | The ID of the Qualification request, as returned by the
-- @ListQualificationRequests@ operation.
rejectQualificationRequest_qualificationRequestId :: Lens.Lens' RejectQualificationRequest Prelude.Text
rejectQualificationRequest_qualificationRequestId :: (Text -> f Text)
-> RejectQualificationRequest -> f RejectQualificationRequest
rejectQualificationRequest_qualificationRequestId = (RejectQualificationRequest -> Text)
-> (RejectQualificationRequest
    -> Text -> RejectQualificationRequest)
-> Lens
     RejectQualificationRequest RejectQualificationRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectQualificationRequest' {Text
qualificationRequestId :: Text
$sel:qualificationRequestId:RejectQualificationRequest' :: RejectQualificationRequest -> Text
qualificationRequestId} -> Text
qualificationRequestId) (\s :: RejectQualificationRequest
s@RejectQualificationRequest' {} Text
a -> RejectQualificationRequest
s {$sel:qualificationRequestId:RejectQualificationRequest' :: Text
qualificationRequestId = Text
a} :: RejectQualificationRequest)

instance Core.AWSRequest RejectQualificationRequest where
  type
    AWSResponse RejectQualificationRequest =
      RejectQualificationRequestResponse
  request :: RejectQualificationRequest -> Request RejectQualificationRequest
request = Service
-> RejectQualificationRequest -> Request RejectQualificationRequest
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RejectQualificationRequest
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RejectQualificationRequest)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse RejectQualificationRequest))
-> Logger
-> Service
-> Proxy RejectQualificationRequest
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RejectQualificationRequest)))
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 -> RejectQualificationRequestResponse
RejectQualificationRequestResponse'
            (Int -> RejectQualificationRequestResponse)
-> Either String Int
-> Either String RejectQualificationRequestResponse
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 RejectQualificationRequest

instance Prelude.NFData RejectQualificationRequest

instance Core.ToHeaders RejectQualificationRequest where
  toHeaders :: RejectQualificationRequest -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RejectQualificationRequest -> 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.RejectQualificationRequest" ::
                          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 RejectQualificationRequest where
  toJSON :: RejectQualificationRequest -> Value
toJSON RejectQualificationRequest' {Maybe Text
Text
qualificationRequestId :: Text
reason :: Maybe Text
$sel:qualificationRequestId:RejectQualificationRequest' :: RejectQualificationRequest -> Text
$sel:reason:RejectQualificationRequest' :: RejectQualificationRequest -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Reason" 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
reason,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"QualificationRequestId"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
qualificationRequestId
              )
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    RejectQualificationRequestResponse