{-# 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.GetQualificationScore
-- 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 @GetQualificationScore@ operation returns the value of a Worker\'s
-- Qualification for a given Qualification type.
--
-- To get a Worker\'s Qualification, you must know the Worker\'s ID. The
-- Worker\'s ID is included in the assignment data returned by the
-- @ListAssignmentsForHIT@ operation.
--
-- Only the owner of a Qualification type can query the value of a
-- Worker\'s Qualification of that type.
module Amazonka.MechanicalTurk.GetQualificationScore
  ( -- * Creating a Request
    GetQualificationScore (..),
    newGetQualificationScore,

    -- * Request Lenses
    getQualificationScore_qualificationTypeId,
    getQualificationScore_workerId,

    -- * Destructuring the Response
    GetQualificationScoreResponse (..),
    newGetQualificationScoreResponse,

    -- * Response Lenses
    getQualificationScoreResponse_qualification,
    getQualificationScoreResponse_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:/ 'newGetQualificationScore' smart constructor.
data GetQualificationScore = GetQualificationScore'
  { -- | The ID of the QualificationType.
    GetQualificationScore -> Text
qualificationTypeId :: Prelude.Text,
    -- | The ID of the Worker whose Qualification is being updated.
    GetQualificationScore -> Text
workerId :: Prelude.Text
  }
  deriving (GetQualificationScore -> GetQualificationScore -> Bool
(GetQualificationScore -> GetQualificationScore -> Bool)
-> (GetQualificationScore -> GetQualificationScore -> Bool)
-> Eq GetQualificationScore
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetQualificationScore -> GetQualificationScore -> Bool
$c/= :: GetQualificationScore -> GetQualificationScore -> Bool
== :: GetQualificationScore -> GetQualificationScore -> Bool
$c== :: GetQualificationScore -> GetQualificationScore -> Bool
Prelude.Eq, ReadPrec [GetQualificationScore]
ReadPrec GetQualificationScore
Int -> ReadS GetQualificationScore
ReadS [GetQualificationScore]
(Int -> ReadS GetQualificationScore)
-> ReadS [GetQualificationScore]
-> ReadPrec GetQualificationScore
-> ReadPrec [GetQualificationScore]
-> Read GetQualificationScore
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetQualificationScore]
$creadListPrec :: ReadPrec [GetQualificationScore]
readPrec :: ReadPrec GetQualificationScore
$creadPrec :: ReadPrec GetQualificationScore
readList :: ReadS [GetQualificationScore]
$creadList :: ReadS [GetQualificationScore]
readsPrec :: Int -> ReadS GetQualificationScore
$creadsPrec :: Int -> ReadS GetQualificationScore
Prelude.Read, Int -> GetQualificationScore -> ShowS
[GetQualificationScore] -> ShowS
GetQualificationScore -> String
(Int -> GetQualificationScore -> ShowS)
-> (GetQualificationScore -> String)
-> ([GetQualificationScore] -> ShowS)
-> Show GetQualificationScore
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetQualificationScore] -> ShowS
$cshowList :: [GetQualificationScore] -> ShowS
show :: GetQualificationScore -> String
$cshow :: GetQualificationScore -> String
showsPrec :: Int -> GetQualificationScore -> ShowS
$cshowsPrec :: Int -> GetQualificationScore -> ShowS
Prelude.Show, (forall x. GetQualificationScore -> Rep GetQualificationScore x)
-> (forall x. Rep GetQualificationScore x -> GetQualificationScore)
-> Generic GetQualificationScore
forall x. Rep GetQualificationScore x -> GetQualificationScore
forall x. GetQualificationScore -> Rep GetQualificationScore x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetQualificationScore x -> GetQualificationScore
$cfrom :: forall x. GetQualificationScore -> Rep GetQualificationScore x
Prelude.Generic)

-- |
-- Create a value of 'GetQualificationScore' 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:
--
-- 'qualificationTypeId', 'getQualificationScore_qualificationTypeId' - The ID of the QualificationType.
--
-- 'workerId', 'getQualificationScore_workerId' - The ID of the Worker whose Qualification is being updated.
newGetQualificationScore ::
  -- | 'qualificationTypeId'
  Prelude.Text ->
  -- | 'workerId'
  Prelude.Text ->
  GetQualificationScore
newGetQualificationScore :: Text -> Text -> GetQualificationScore
newGetQualificationScore
  Text
pQualificationTypeId_
  Text
pWorkerId_ =
    GetQualificationScore' :: Text -> Text -> GetQualificationScore
GetQualificationScore'
      { $sel:qualificationTypeId:GetQualificationScore' :: Text
qualificationTypeId =
          Text
pQualificationTypeId_,
        $sel:workerId:GetQualificationScore' :: Text
workerId = Text
pWorkerId_
      }

-- | The ID of the QualificationType.
getQualificationScore_qualificationTypeId :: Lens.Lens' GetQualificationScore Prelude.Text
getQualificationScore_qualificationTypeId :: (Text -> f Text)
-> GetQualificationScore -> f GetQualificationScore
getQualificationScore_qualificationTypeId = (GetQualificationScore -> Text)
-> (GetQualificationScore -> Text -> GetQualificationScore)
-> Lens GetQualificationScore GetQualificationScore Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetQualificationScore' {Text
qualificationTypeId :: Text
$sel:qualificationTypeId:GetQualificationScore' :: GetQualificationScore -> Text
qualificationTypeId} -> Text
qualificationTypeId) (\s :: GetQualificationScore
s@GetQualificationScore' {} Text
a -> GetQualificationScore
s {$sel:qualificationTypeId:GetQualificationScore' :: Text
qualificationTypeId = Text
a} :: GetQualificationScore)

-- | The ID of the Worker whose Qualification is being updated.
getQualificationScore_workerId :: Lens.Lens' GetQualificationScore Prelude.Text
getQualificationScore_workerId :: (Text -> f Text)
-> GetQualificationScore -> f GetQualificationScore
getQualificationScore_workerId = (GetQualificationScore -> Text)
-> (GetQualificationScore -> Text -> GetQualificationScore)
-> Lens GetQualificationScore GetQualificationScore Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetQualificationScore' {Text
workerId :: Text
$sel:workerId:GetQualificationScore' :: GetQualificationScore -> Text
workerId} -> Text
workerId) (\s :: GetQualificationScore
s@GetQualificationScore' {} Text
a -> GetQualificationScore
s {$sel:workerId:GetQualificationScore' :: Text
workerId = Text
a} :: GetQualificationScore)

instance Core.AWSRequest GetQualificationScore where
  type
    AWSResponse GetQualificationScore =
      GetQualificationScoreResponse
  request :: GetQualificationScore -> Request GetQualificationScore
request = Service -> GetQualificationScore -> Request GetQualificationScore
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetQualificationScore
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetQualificationScore)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetQualificationScore))
-> Logger
-> Service
-> Proxy GetQualificationScore
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetQualificationScore)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Qualification -> Int -> GetQualificationScoreResponse
GetQualificationScoreResponse'
            (Maybe Qualification -> Int -> GetQualificationScoreResponse)
-> Either String (Maybe Qualification)
-> Either String (Int -> GetQualificationScoreResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Qualification)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Qualification")
            Either String (Int -> GetQualificationScoreResponse)
-> Either String Int -> Either String GetQualificationScoreResponse
forall (f :: * -> *) a b. Applicative f => 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 GetQualificationScore

instance Prelude.NFData GetQualificationScore

instance Core.ToHeaders GetQualificationScore where
  toHeaders :: GetQualificationScore -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetQualificationScore -> 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.GetQualificationScore" ::
                          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 GetQualificationScore where
  toJSON :: GetQualificationScore -> Value
toJSON GetQualificationScore' {Text
workerId :: Text
qualificationTypeId :: Text
$sel:workerId:GetQualificationScore' :: GetQualificationScore -> Text
$sel:qualificationTypeId:GetQualificationScore' :: GetQualificationScore -> 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
"QualificationTypeId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
qualificationTypeId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"WorkerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workerId)
          ]
      )

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

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

-- | /See:/ 'newGetQualificationScoreResponse' smart constructor.
data GetQualificationScoreResponse = GetQualificationScoreResponse'
  { -- | The Qualification data structure of the Qualification assigned to a
    -- user, including the Qualification type and the value (score).
    GetQualificationScoreResponse -> Maybe Qualification
qualification :: Prelude.Maybe Qualification,
    -- | The response's http status code.
    GetQualificationScoreResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetQualificationScoreResponse
-> GetQualificationScoreResponse -> Bool
(GetQualificationScoreResponse
 -> GetQualificationScoreResponse -> Bool)
-> (GetQualificationScoreResponse
    -> GetQualificationScoreResponse -> Bool)
-> Eq GetQualificationScoreResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetQualificationScoreResponse
-> GetQualificationScoreResponse -> Bool
$c/= :: GetQualificationScoreResponse
-> GetQualificationScoreResponse -> Bool
== :: GetQualificationScoreResponse
-> GetQualificationScoreResponse -> Bool
$c== :: GetQualificationScoreResponse
-> GetQualificationScoreResponse -> Bool
Prelude.Eq, ReadPrec [GetQualificationScoreResponse]
ReadPrec GetQualificationScoreResponse
Int -> ReadS GetQualificationScoreResponse
ReadS [GetQualificationScoreResponse]
(Int -> ReadS GetQualificationScoreResponse)
-> ReadS [GetQualificationScoreResponse]
-> ReadPrec GetQualificationScoreResponse
-> ReadPrec [GetQualificationScoreResponse]
-> Read GetQualificationScoreResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetQualificationScoreResponse]
$creadListPrec :: ReadPrec [GetQualificationScoreResponse]
readPrec :: ReadPrec GetQualificationScoreResponse
$creadPrec :: ReadPrec GetQualificationScoreResponse
readList :: ReadS [GetQualificationScoreResponse]
$creadList :: ReadS [GetQualificationScoreResponse]
readsPrec :: Int -> ReadS GetQualificationScoreResponse
$creadsPrec :: Int -> ReadS GetQualificationScoreResponse
Prelude.Read, Int -> GetQualificationScoreResponse -> ShowS
[GetQualificationScoreResponse] -> ShowS
GetQualificationScoreResponse -> String
(Int -> GetQualificationScoreResponse -> ShowS)
-> (GetQualificationScoreResponse -> String)
-> ([GetQualificationScoreResponse] -> ShowS)
-> Show GetQualificationScoreResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetQualificationScoreResponse] -> ShowS
$cshowList :: [GetQualificationScoreResponse] -> ShowS
show :: GetQualificationScoreResponse -> String
$cshow :: GetQualificationScoreResponse -> String
showsPrec :: Int -> GetQualificationScoreResponse -> ShowS
$cshowsPrec :: Int -> GetQualificationScoreResponse -> ShowS
Prelude.Show, (forall x.
 GetQualificationScoreResponse
 -> Rep GetQualificationScoreResponse x)
-> (forall x.
    Rep GetQualificationScoreResponse x
    -> GetQualificationScoreResponse)
-> Generic GetQualificationScoreResponse
forall x.
Rep GetQualificationScoreResponse x
-> GetQualificationScoreResponse
forall x.
GetQualificationScoreResponse
-> Rep GetQualificationScoreResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetQualificationScoreResponse x
-> GetQualificationScoreResponse
$cfrom :: forall x.
GetQualificationScoreResponse
-> Rep GetQualificationScoreResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetQualificationScoreResponse' 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:
--
-- 'qualification', 'getQualificationScoreResponse_qualification' - The Qualification data structure of the Qualification assigned to a
-- user, including the Qualification type and the value (score).
--
-- 'httpStatus', 'getQualificationScoreResponse_httpStatus' - The response's http status code.
newGetQualificationScoreResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetQualificationScoreResponse
newGetQualificationScoreResponse :: Int -> GetQualificationScoreResponse
newGetQualificationScoreResponse Int
pHttpStatus_ =
  GetQualificationScoreResponse' :: Maybe Qualification -> Int -> GetQualificationScoreResponse
GetQualificationScoreResponse'
    { $sel:qualification:GetQualificationScoreResponse' :: Maybe Qualification
qualification =
        Maybe Qualification
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetQualificationScoreResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Qualification data structure of the Qualification assigned to a
-- user, including the Qualification type and the value (score).
getQualificationScoreResponse_qualification :: Lens.Lens' GetQualificationScoreResponse (Prelude.Maybe Qualification)
getQualificationScoreResponse_qualification :: (Maybe Qualification -> f (Maybe Qualification))
-> GetQualificationScoreResponse -> f GetQualificationScoreResponse
getQualificationScoreResponse_qualification = (GetQualificationScoreResponse -> Maybe Qualification)
-> (GetQualificationScoreResponse
    -> Maybe Qualification -> GetQualificationScoreResponse)
-> Lens
     GetQualificationScoreResponse
     GetQualificationScoreResponse
     (Maybe Qualification)
     (Maybe Qualification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetQualificationScoreResponse' {Maybe Qualification
qualification :: Maybe Qualification
$sel:qualification:GetQualificationScoreResponse' :: GetQualificationScoreResponse -> Maybe Qualification
qualification} -> Maybe Qualification
qualification) (\s :: GetQualificationScoreResponse
s@GetQualificationScoreResponse' {} Maybe Qualification
a -> GetQualificationScoreResponse
s {$sel:qualification:GetQualificationScoreResponse' :: Maybe Qualification
qualification = Maybe Qualification
a} :: GetQualificationScoreResponse)

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

instance Prelude.NFData GetQualificationScoreResponse