{-# 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.AcceptQualificationRequest
-- 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 @AcceptQualificationRequest@ operation approves a Worker\'s request
-- for a Qualification.
--
-- Only the owner of the Qualification type can grant a Qualification
-- request for that type.
--
-- A successful request for the @AcceptQualificationRequest@ operation
-- returns with no errors and an empty body.
module Amazonka.MechanicalTurk.AcceptQualificationRequest
  ( -- * Creating a Request
    AcceptQualificationRequest (..),
    newAcceptQualificationRequest,

    -- * Request Lenses
    acceptQualificationRequest_integerValue,
    acceptQualificationRequest_qualificationRequestId,

    -- * Destructuring the Response
    AcceptQualificationRequestResponse (..),
    newAcceptQualificationRequestResponse,

    -- * Response Lenses
    acceptQualificationRequestResponse_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:/ 'newAcceptQualificationRequest' smart constructor.
data AcceptQualificationRequest = AcceptQualificationRequest'
  { -- | The value of the Qualification. You can omit this value if you are using
    -- the presence or absence of the Qualification as the basis for a HIT
    -- requirement.
    AcceptQualificationRequest -> Maybe Int
integerValue :: Prelude.Maybe Prelude.Int,
    -- | The ID of the Qualification request, as returned by the
    -- @GetQualificationRequests@ operation.
    AcceptQualificationRequest -> Text
qualificationRequestId :: Prelude.Text
  }
  deriving (AcceptQualificationRequest -> AcceptQualificationRequest -> Bool
(AcceptQualificationRequest -> AcceptQualificationRequest -> Bool)
-> (AcceptQualificationRequest
    -> AcceptQualificationRequest -> Bool)
-> Eq AcceptQualificationRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceptQualificationRequest -> AcceptQualificationRequest -> Bool
$c/= :: AcceptQualificationRequest -> AcceptQualificationRequest -> Bool
== :: AcceptQualificationRequest -> AcceptQualificationRequest -> Bool
$c== :: AcceptQualificationRequest -> AcceptQualificationRequest -> Bool
Prelude.Eq, ReadPrec [AcceptQualificationRequest]
ReadPrec AcceptQualificationRequest
Int -> ReadS AcceptQualificationRequest
ReadS [AcceptQualificationRequest]
(Int -> ReadS AcceptQualificationRequest)
-> ReadS [AcceptQualificationRequest]
-> ReadPrec AcceptQualificationRequest
-> ReadPrec [AcceptQualificationRequest]
-> Read AcceptQualificationRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcceptQualificationRequest]
$creadListPrec :: ReadPrec [AcceptQualificationRequest]
readPrec :: ReadPrec AcceptQualificationRequest
$creadPrec :: ReadPrec AcceptQualificationRequest
readList :: ReadS [AcceptQualificationRequest]
$creadList :: ReadS [AcceptQualificationRequest]
readsPrec :: Int -> ReadS AcceptQualificationRequest
$creadsPrec :: Int -> ReadS AcceptQualificationRequest
Prelude.Read, Int -> AcceptQualificationRequest -> ShowS
[AcceptQualificationRequest] -> ShowS
AcceptQualificationRequest -> String
(Int -> AcceptQualificationRequest -> ShowS)
-> (AcceptQualificationRequest -> String)
-> ([AcceptQualificationRequest] -> ShowS)
-> Show AcceptQualificationRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceptQualificationRequest] -> ShowS
$cshowList :: [AcceptQualificationRequest] -> ShowS
show :: AcceptQualificationRequest -> String
$cshow :: AcceptQualificationRequest -> String
showsPrec :: Int -> AcceptQualificationRequest -> ShowS
$cshowsPrec :: Int -> AcceptQualificationRequest -> ShowS
Prelude.Show, (forall x.
 AcceptQualificationRequest -> Rep AcceptQualificationRequest x)
-> (forall x.
    Rep AcceptQualificationRequest x -> AcceptQualificationRequest)
-> Generic AcceptQualificationRequest
forall x.
Rep AcceptQualificationRequest x -> AcceptQualificationRequest
forall x.
AcceptQualificationRequest -> Rep AcceptQualificationRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AcceptQualificationRequest x -> AcceptQualificationRequest
$cfrom :: forall x.
AcceptQualificationRequest -> Rep AcceptQualificationRequest x
Prelude.Generic)

-- |
-- Create a value of 'AcceptQualificationRequest' 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:
--
-- 'integerValue', 'acceptQualificationRequest_integerValue' - The value of the Qualification. You can omit this value if you are using
-- the presence or absence of the Qualification as the basis for a HIT
-- requirement.
--
-- 'qualificationRequestId', 'acceptQualificationRequest_qualificationRequestId' - The ID of the Qualification request, as returned by the
-- @GetQualificationRequests@ operation.
newAcceptQualificationRequest ::
  -- | 'qualificationRequestId'
  Prelude.Text ->
  AcceptQualificationRequest
newAcceptQualificationRequest :: Text -> AcceptQualificationRequest
newAcceptQualificationRequest
  Text
pQualificationRequestId_ =
    AcceptQualificationRequest' :: Maybe Int -> Text -> AcceptQualificationRequest
AcceptQualificationRequest'
      { $sel:integerValue:AcceptQualificationRequest' :: Maybe Int
integerValue =
          Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:qualificationRequestId:AcceptQualificationRequest' :: Text
qualificationRequestId =
          Text
pQualificationRequestId_
      }

-- | The value of the Qualification. You can omit this value if you are using
-- the presence or absence of the Qualification as the basis for a HIT
-- requirement.
acceptQualificationRequest_integerValue :: Lens.Lens' AcceptQualificationRequest (Prelude.Maybe Prelude.Int)
acceptQualificationRequest_integerValue :: (Maybe Int -> f (Maybe Int))
-> AcceptQualificationRequest -> f AcceptQualificationRequest
acceptQualificationRequest_integerValue = (AcceptQualificationRequest -> Maybe Int)
-> (AcceptQualificationRequest
    -> Maybe Int -> AcceptQualificationRequest)
-> Lens
     AcceptQualificationRequest
     AcceptQualificationRequest
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptQualificationRequest' {Maybe Int
integerValue :: Maybe Int
$sel:integerValue:AcceptQualificationRequest' :: AcceptQualificationRequest -> Maybe Int
integerValue} -> Maybe Int
integerValue) (\s :: AcceptQualificationRequest
s@AcceptQualificationRequest' {} Maybe Int
a -> AcceptQualificationRequest
s {$sel:integerValue:AcceptQualificationRequest' :: Maybe Int
integerValue = Maybe Int
a} :: AcceptQualificationRequest)

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

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

instance Prelude.NFData AcceptQualificationRequest

instance Core.ToHeaders AcceptQualificationRequest where
  toHeaders :: AcceptQualificationRequest -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AcceptQualificationRequest -> 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.AcceptQualificationRequest" ::
                          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 AcceptQualificationRequest where
  toJSON :: AcceptQualificationRequest -> Value
toJSON AcceptQualificationRequest' {Maybe Int
Text
qualificationRequestId :: Text
integerValue :: Maybe Int
$sel:qualificationRequestId:AcceptQualificationRequest' :: AcceptQualificationRequest -> Text
$sel:integerValue:AcceptQualificationRequest' :: AcceptQualificationRequest -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IntegerValue" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
integerValue,
            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 AcceptQualificationRequest where
  toPath :: AcceptQualificationRequest -> ByteString
toPath = ByteString -> AcceptQualificationRequest -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance
  Prelude.NFData
    AcceptQualificationRequestResponse