{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.QualificationRequest
-- 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)
module Amazonka.MechanicalTurk.Types.QualificationRequest where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The QualificationRequest data structure represents a request a Worker
-- has made for a Qualification.
--
-- /See:/ 'newQualificationRequest' smart constructor.
data QualificationRequest = QualificationRequest'
  { -- | The ID of the Qualification request, a unique identifier generated when
    -- the request was submitted.
    QualificationRequest -> Maybe Text
qualificationRequestId :: Prelude.Maybe Prelude.Text,
    -- | The contents of the Qualification test that was presented to the Worker,
    -- if the type has a test and the Worker has submitted answers. This value
    -- is identical to the QuestionForm associated with the Qualification type
    -- at the time the Worker requests the Qualification.
    QualificationRequest -> Maybe Text
test :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Qualification type the Worker is requesting, as returned
    -- by the CreateQualificationType operation.
    QualificationRequest -> Maybe Text
qualificationTypeId :: Prelude.Maybe Prelude.Text,
    -- | The Worker\'s answers for the Qualification type\'s test contained in a
    -- QuestionFormAnswers document, if the type has a test and the Worker has
    -- submitted answers. If the Worker does not provide any answers, Answer
    -- may be empty.
    QualificationRequest -> Maybe Text
answer :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Worker requesting the Qualification.
    QualificationRequest -> Maybe Text
workerId :: Prelude.Maybe Prelude.Text,
    -- | The date and time the Qualification request had a status of Submitted.
    -- This is either the time the Worker submitted answers for a Qualification
    -- test, or the time the Worker requested the Qualification if the
    -- Qualification type does not have a test.
    QualificationRequest -> Maybe POSIX
submitTime :: Prelude.Maybe Core.POSIX
  }
  deriving (QualificationRequest -> QualificationRequest -> Bool
(QualificationRequest -> QualificationRequest -> Bool)
-> (QualificationRequest -> QualificationRequest -> Bool)
-> Eq QualificationRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QualificationRequest -> QualificationRequest -> Bool
$c/= :: QualificationRequest -> QualificationRequest -> Bool
== :: QualificationRequest -> QualificationRequest -> Bool
$c== :: QualificationRequest -> QualificationRequest -> Bool
Prelude.Eq, ReadPrec [QualificationRequest]
ReadPrec QualificationRequest
Int -> ReadS QualificationRequest
ReadS [QualificationRequest]
(Int -> ReadS QualificationRequest)
-> ReadS [QualificationRequest]
-> ReadPrec QualificationRequest
-> ReadPrec [QualificationRequest]
-> Read QualificationRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QualificationRequest]
$creadListPrec :: ReadPrec [QualificationRequest]
readPrec :: ReadPrec QualificationRequest
$creadPrec :: ReadPrec QualificationRequest
readList :: ReadS [QualificationRequest]
$creadList :: ReadS [QualificationRequest]
readsPrec :: Int -> ReadS QualificationRequest
$creadsPrec :: Int -> ReadS QualificationRequest
Prelude.Read, Int -> QualificationRequest -> ShowS
[QualificationRequest] -> ShowS
QualificationRequest -> String
(Int -> QualificationRequest -> ShowS)
-> (QualificationRequest -> String)
-> ([QualificationRequest] -> ShowS)
-> Show QualificationRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QualificationRequest] -> ShowS
$cshowList :: [QualificationRequest] -> ShowS
show :: QualificationRequest -> String
$cshow :: QualificationRequest -> String
showsPrec :: Int -> QualificationRequest -> ShowS
$cshowsPrec :: Int -> QualificationRequest -> ShowS
Prelude.Show, (forall x. QualificationRequest -> Rep QualificationRequest x)
-> (forall x. Rep QualificationRequest x -> QualificationRequest)
-> Generic QualificationRequest
forall x. Rep QualificationRequest x -> QualificationRequest
forall x. QualificationRequest -> Rep QualificationRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QualificationRequest x -> QualificationRequest
$cfrom :: forall x. QualificationRequest -> Rep QualificationRequest x
Prelude.Generic)

-- |
-- Create a value of 'QualificationRequest' 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:
--
-- 'qualificationRequestId', 'qualificationRequest_qualificationRequestId' - The ID of the Qualification request, a unique identifier generated when
-- the request was submitted.
--
-- 'test', 'qualificationRequest_test' - The contents of the Qualification test that was presented to the Worker,
-- if the type has a test and the Worker has submitted answers. This value
-- is identical to the QuestionForm associated with the Qualification type
-- at the time the Worker requests the Qualification.
--
-- 'qualificationTypeId', 'qualificationRequest_qualificationTypeId' - The ID of the Qualification type the Worker is requesting, as returned
-- by the CreateQualificationType operation.
--
-- 'answer', 'qualificationRequest_answer' - The Worker\'s answers for the Qualification type\'s test contained in a
-- QuestionFormAnswers document, if the type has a test and the Worker has
-- submitted answers. If the Worker does not provide any answers, Answer
-- may be empty.
--
-- 'workerId', 'qualificationRequest_workerId' - The ID of the Worker requesting the Qualification.
--
-- 'submitTime', 'qualificationRequest_submitTime' - The date and time the Qualification request had a status of Submitted.
-- This is either the time the Worker submitted answers for a Qualification
-- test, or the time the Worker requested the Qualification if the
-- Qualification type does not have a test.
newQualificationRequest ::
  QualificationRequest
newQualificationRequest :: QualificationRequest
newQualificationRequest =
  QualificationRequest' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> QualificationRequest
QualificationRequest'
    { $sel:qualificationRequestId:QualificationRequest' :: Maybe Text
qualificationRequestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:test:QualificationRequest' :: Maybe Text
test = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:qualificationTypeId:QualificationRequest' :: Maybe Text
qualificationTypeId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:answer:QualificationRequest' :: Maybe Text
answer = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:workerId:QualificationRequest' :: Maybe Text
workerId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:submitTime:QualificationRequest' :: Maybe POSIX
submitTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Qualification request, a unique identifier generated when
-- the request was submitted.
qualificationRequest_qualificationRequestId :: Lens.Lens' QualificationRequest (Prelude.Maybe Prelude.Text)
qualificationRequest_qualificationRequestId :: (Maybe Text -> f (Maybe Text))
-> QualificationRequest -> f QualificationRequest
qualificationRequest_qualificationRequestId = (QualificationRequest -> Maybe Text)
-> (QualificationRequest -> Maybe Text -> QualificationRequest)
-> Lens
     QualificationRequest QualificationRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QualificationRequest' {Maybe Text
qualificationRequestId :: Maybe Text
$sel:qualificationRequestId:QualificationRequest' :: QualificationRequest -> Maybe Text
qualificationRequestId} -> Maybe Text
qualificationRequestId) (\s :: QualificationRequest
s@QualificationRequest' {} Maybe Text
a -> QualificationRequest
s {$sel:qualificationRequestId:QualificationRequest' :: Maybe Text
qualificationRequestId = Maybe Text
a} :: QualificationRequest)

-- | The contents of the Qualification test that was presented to the Worker,
-- if the type has a test and the Worker has submitted answers. This value
-- is identical to the QuestionForm associated with the Qualification type
-- at the time the Worker requests the Qualification.
qualificationRequest_test :: Lens.Lens' QualificationRequest (Prelude.Maybe Prelude.Text)
qualificationRequest_test :: (Maybe Text -> f (Maybe Text))
-> QualificationRequest -> f QualificationRequest
qualificationRequest_test = (QualificationRequest -> Maybe Text)
-> (QualificationRequest -> Maybe Text -> QualificationRequest)
-> Lens
     QualificationRequest QualificationRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QualificationRequest' {Maybe Text
test :: Maybe Text
$sel:test:QualificationRequest' :: QualificationRequest -> Maybe Text
test} -> Maybe Text
test) (\s :: QualificationRequest
s@QualificationRequest' {} Maybe Text
a -> QualificationRequest
s {$sel:test:QualificationRequest' :: Maybe Text
test = Maybe Text
a} :: QualificationRequest)

-- | The ID of the Qualification type the Worker is requesting, as returned
-- by the CreateQualificationType operation.
qualificationRequest_qualificationTypeId :: Lens.Lens' QualificationRequest (Prelude.Maybe Prelude.Text)
qualificationRequest_qualificationTypeId :: (Maybe Text -> f (Maybe Text))
-> QualificationRequest -> f QualificationRequest
qualificationRequest_qualificationTypeId = (QualificationRequest -> Maybe Text)
-> (QualificationRequest -> Maybe Text -> QualificationRequest)
-> Lens
     QualificationRequest QualificationRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QualificationRequest' {Maybe Text
qualificationTypeId :: Maybe Text
$sel:qualificationTypeId:QualificationRequest' :: QualificationRequest -> Maybe Text
qualificationTypeId} -> Maybe Text
qualificationTypeId) (\s :: QualificationRequest
s@QualificationRequest' {} Maybe Text
a -> QualificationRequest
s {$sel:qualificationTypeId:QualificationRequest' :: Maybe Text
qualificationTypeId = Maybe Text
a} :: QualificationRequest)

-- | The Worker\'s answers for the Qualification type\'s test contained in a
-- QuestionFormAnswers document, if the type has a test and the Worker has
-- submitted answers. If the Worker does not provide any answers, Answer
-- may be empty.
qualificationRequest_answer :: Lens.Lens' QualificationRequest (Prelude.Maybe Prelude.Text)
qualificationRequest_answer :: (Maybe Text -> f (Maybe Text))
-> QualificationRequest -> f QualificationRequest
qualificationRequest_answer = (QualificationRequest -> Maybe Text)
-> (QualificationRequest -> Maybe Text -> QualificationRequest)
-> Lens
     QualificationRequest QualificationRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QualificationRequest' {Maybe Text
answer :: Maybe Text
$sel:answer:QualificationRequest' :: QualificationRequest -> Maybe Text
answer} -> Maybe Text
answer) (\s :: QualificationRequest
s@QualificationRequest' {} Maybe Text
a -> QualificationRequest
s {$sel:answer:QualificationRequest' :: Maybe Text
answer = Maybe Text
a} :: QualificationRequest)

-- | The ID of the Worker requesting the Qualification.
qualificationRequest_workerId :: Lens.Lens' QualificationRequest (Prelude.Maybe Prelude.Text)
qualificationRequest_workerId :: (Maybe Text -> f (Maybe Text))
-> QualificationRequest -> f QualificationRequest
qualificationRequest_workerId = (QualificationRequest -> Maybe Text)
-> (QualificationRequest -> Maybe Text -> QualificationRequest)
-> Lens
     QualificationRequest QualificationRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QualificationRequest' {Maybe Text
workerId :: Maybe Text
$sel:workerId:QualificationRequest' :: QualificationRequest -> Maybe Text
workerId} -> Maybe Text
workerId) (\s :: QualificationRequest
s@QualificationRequest' {} Maybe Text
a -> QualificationRequest
s {$sel:workerId:QualificationRequest' :: Maybe Text
workerId = Maybe Text
a} :: QualificationRequest)

-- | The date and time the Qualification request had a status of Submitted.
-- This is either the time the Worker submitted answers for a Qualification
-- test, or the time the Worker requested the Qualification if the
-- Qualification type does not have a test.
qualificationRequest_submitTime :: Lens.Lens' QualificationRequest (Prelude.Maybe Prelude.UTCTime)
qualificationRequest_submitTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> QualificationRequest -> f QualificationRequest
qualificationRequest_submitTime = (QualificationRequest -> Maybe POSIX)
-> (QualificationRequest -> Maybe POSIX -> QualificationRequest)
-> Lens
     QualificationRequest
     QualificationRequest
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QualificationRequest' {Maybe POSIX
submitTime :: Maybe POSIX
$sel:submitTime:QualificationRequest' :: QualificationRequest -> Maybe POSIX
submitTime} -> Maybe POSIX
submitTime) (\s :: QualificationRequest
s@QualificationRequest' {} Maybe POSIX
a -> QualificationRequest
s {$sel:submitTime:QualificationRequest' :: Maybe POSIX
submitTime = Maybe POSIX
a} :: QualificationRequest) ((Maybe POSIX -> f (Maybe POSIX))
 -> QualificationRequest -> f QualificationRequest)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> QualificationRequest
-> f QualificationRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON QualificationRequest where
  parseJSON :: Value -> Parser QualificationRequest
parseJSON =
    String
-> (Object -> Parser QualificationRequest)
-> Value
-> Parser QualificationRequest
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"QualificationRequest"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> QualificationRequest
QualificationRequest'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> QualificationRequest)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> QualificationRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"QualificationRequestId")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> QualificationRequest)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe POSIX -> QualificationRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Test")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe POSIX -> QualificationRequest)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe POSIX -> QualificationRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"QualificationTypeId")
            Parser
  (Maybe Text -> Maybe Text -> Maybe POSIX -> QualificationRequest)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> QualificationRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Answer")
            Parser (Maybe Text -> Maybe POSIX -> QualificationRequest)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> QualificationRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"WorkerId")
            Parser (Maybe POSIX -> QualificationRequest)
-> Parser (Maybe POSIX) -> Parser QualificationRequest
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SubmitTime")
      )

instance Prelude.Hashable QualificationRequest

instance Prelude.NFData QualificationRequest