{-# 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.Qualification
-- 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.Qualification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MechanicalTurk.Types.Locale
import Amazonka.MechanicalTurk.Types.QualificationStatus
import qualified Amazonka.Prelude as Prelude

-- | The Qualification data structure represents a Qualification assigned to
-- a user, including the Qualification type and the value (score).
--
-- /See:/ 'newQualification' smart constructor.
data Qualification = Qualification'
  { -- | The status of the Qualification. Valid values are Granted | Revoked.
    Qualification -> Maybe QualificationStatus
status :: Prelude.Maybe QualificationStatus,
    -- | The value (score) of the Qualification, if the Qualification has an
    -- integer value.
    Qualification -> Maybe Int
integerValue :: Prelude.Maybe Prelude.Int,
    Qualification -> Maybe Locale
localeValue :: Prelude.Maybe Locale,
    -- | The ID of the Qualification type for the Qualification.
    Qualification -> Maybe Text
qualificationTypeId :: Prelude.Maybe Prelude.Text,
    -- | The date and time the Qualification was granted to the Worker. If the
    -- Worker\'s Qualification was revoked, and then re-granted based on a new
    -- Qualification request, GrantTime is the date and time of the last call
    -- to the AcceptQualificationRequest operation.
    Qualification -> Maybe POSIX
grantTime :: Prelude.Maybe Core.POSIX,
    -- | The ID of the Worker who possesses the Qualification.
    Qualification -> Maybe Text
workerId :: Prelude.Maybe Prelude.Text
  }
  deriving (Qualification -> Qualification -> Bool
(Qualification -> Qualification -> Bool)
-> (Qualification -> Qualification -> Bool) -> Eq Qualification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Qualification -> Qualification -> Bool
$c/= :: Qualification -> Qualification -> Bool
== :: Qualification -> Qualification -> Bool
$c== :: Qualification -> Qualification -> Bool
Prelude.Eq, ReadPrec [Qualification]
ReadPrec Qualification
Int -> ReadS Qualification
ReadS [Qualification]
(Int -> ReadS Qualification)
-> ReadS [Qualification]
-> ReadPrec Qualification
-> ReadPrec [Qualification]
-> Read Qualification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Qualification]
$creadListPrec :: ReadPrec [Qualification]
readPrec :: ReadPrec Qualification
$creadPrec :: ReadPrec Qualification
readList :: ReadS [Qualification]
$creadList :: ReadS [Qualification]
readsPrec :: Int -> ReadS Qualification
$creadsPrec :: Int -> ReadS Qualification
Prelude.Read, Int -> Qualification -> ShowS
[Qualification] -> ShowS
Qualification -> String
(Int -> Qualification -> ShowS)
-> (Qualification -> String)
-> ([Qualification] -> ShowS)
-> Show Qualification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Qualification] -> ShowS
$cshowList :: [Qualification] -> ShowS
show :: Qualification -> String
$cshow :: Qualification -> String
showsPrec :: Int -> Qualification -> ShowS
$cshowsPrec :: Int -> Qualification -> ShowS
Prelude.Show, (forall x. Qualification -> Rep Qualification x)
-> (forall x. Rep Qualification x -> Qualification)
-> Generic Qualification
forall x. Rep Qualification x -> Qualification
forall x. Qualification -> Rep Qualification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Qualification x -> Qualification
$cfrom :: forall x. Qualification -> Rep Qualification x
Prelude.Generic)

-- |
-- Create a value of 'Qualification' 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:
--
-- 'status', 'qualification_status' - The status of the Qualification. Valid values are Granted | Revoked.
--
-- 'integerValue', 'qualification_integerValue' - The value (score) of the Qualification, if the Qualification has an
-- integer value.
--
-- 'localeValue', 'qualification_localeValue' - Undocumented member.
--
-- 'qualificationTypeId', 'qualification_qualificationTypeId' - The ID of the Qualification type for the Qualification.
--
-- 'grantTime', 'qualification_grantTime' - The date and time the Qualification was granted to the Worker. If the
-- Worker\'s Qualification was revoked, and then re-granted based on a new
-- Qualification request, GrantTime is the date and time of the last call
-- to the AcceptQualificationRequest operation.
--
-- 'workerId', 'qualification_workerId' - The ID of the Worker who possesses the Qualification.
newQualification ::
  Qualification
newQualification :: Qualification
newQualification =
  Qualification' :: Maybe QualificationStatus
-> Maybe Int
-> Maybe Locale
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Qualification
Qualification'
    { $sel:status:Qualification' :: Maybe QualificationStatus
status = Maybe QualificationStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:integerValue:Qualification' :: Maybe Int
integerValue = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:localeValue:Qualification' :: Maybe Locale
localeValue = Maybe Locale
forall a. Maybe a
Prelude.Nothing,
      $sel:qualificationTypeId:Qualification' :: Maybe Text
qualificationTypeId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:grantTime:Qualification' :: Maybe POSIX
grantTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:workerId:Qualification' :: Maybe Text
workerId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the Qualification. Valid values are Granted | Revoked.
qualification_status :: Lens.Lens' Qualification (Prelude.Maybe QualificationStatus)
qualification_status :: (Maybe QualificationStatus -> f (Maybe QualificationStatus))
-> Qualification -> f Qualification
qualification_status = (Qualification -> Maybe QualificationStatus)
-> (Qualification -> Maybe QualificationStatus -> Qualification)
-> Lens
     Qualification
     Qualification
     (Maybe QualificationStatus)
     (Maybe QualificationStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Qualification' {Maybe QualificationStatus
status :: Maybe QualificationStatus
$sel:status:Qualification' :: Qualification -> Maybe QualificationStatus
status} -> Maybe QualificationStatus
status) (\s :: Qualification
s@Qualification' {} Maybe QualificationStatus
a -> Qualification
s {$sel:status:Qualification' :: Maybe QualificationStatus
status = Maybe QualificationStatus
a} :: Qualification)

-- | The value (score) of the Qualification, if the Qualification has an
-- integer value.
qualification_integerValue :: Lens.Lens' Qualification (Prelude.Maybe Prelude.Int)
qualification_integerValue :: (Maybe Int -> f (Maybe Int)) -> Qualification -> f Qualification
qualification_integerValue = (Qualification -> Maybe Int)
-> (Qualification -> Maybe Int -> Qualification)
-> Lens Qualification Qualification (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Qualification' {Maybe Int
integerValue :: Maybe Int
$sel:integerValue:Qualification' :: Qualification -> Maybe Int
integerValue} -> Maybe Int
integerValue) (\s :: Qualification
s@Qualification' {} Maybe Int
a -> Qualification
s {$sel:integerValue:Qualification' :: Maybe Int
integerValue = Maybe Int
a} :: Qualification)

-- | Undocumented member.
qualification_localeValue :: Lens.Lens' Qualification (Prelude.Maybe Locale)
qualification_localeValue :: (Maybe Locale -> f (Maybe Locale))
-> Qualification -> f Qualification
qualification_localeValue = (Qualification -> Maybe Locale)
-> (Qualification -> Maybe Locale -> Qualification)
-> Lens Qualification Qualification (Maybe Locale) (Maybe Locale)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Qualification' {Maybe Locale
localeValue :: Maybe Locale
$sel:localeValue:Qualification' :: Qualification -> Maybe Locale
localeValue} -> Maybe Locale
localeValue) (\s :: Qualification
s@Qualification' {} Maybe Locale
a -> Qualification
s {$sel:localeValue:Qualification' :: Maybe Locale
localeValue = Maybe Locale
a} :: Qualification)

-- | The ID of the Qualification type for the Qualification.
qualification_qualificationTypeId :: Lens.Lens' Qualification (Prelude.Maybe Prelude.Text)
qualification_qualificationTypeId :: (Maybe Text -> f (Maybe Text)) -> Qualification -> f Qualification
qualification_qualificationTypeId = (Qualification -> Maybe Text)
-> (Qualification -> Maybe Text -> Qualification)
-> Lens Qualification Qualification (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Qualification' {Maybe Text
qualificationTypeId :: Maybe Text
$sel:qualificationTypeId:Qualification' :: Qualification -> Maybe Text
qualificationTypeId} -> Maybe Text
qualificationTypeId) (\s :: Qualification
s@Qualification' {} Maybe Text
a -> Qualification
s {$sel:qualificationTypeId:Qualification' :: Maybe Text
qualificationTypeId = Maybe Text
a} :: Qualification)

-- | The date and time the Qualification was granted to the Worker. If the
-- Worker\'s Qualification was revoked, and then re-granted based on a new
-- Qualification request, GrantTime is the date and time of the last call
-- to the AcceptQualificationRequest operation.
qualification_grantTime :: Lens.Lens' Qualification (Prelude.Maybe Prelude.UTCTime)
qualification_grantTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> Qualification -> f Qualification
qualification_grantTime = (Qualification -> Maybe POSIX)
-> (Qualification -> Maybe POSIX -> Qualification)
-> Lens Qualification Qualification (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Qualification' {Maybe POSIX
grantTime :: Maybe POSIX
$sel:grantTime:Qualification' :: Qualification -> Maybe POSIX
grantTime} -> Maybe POSIX
grantTime) (\s :: Qualification
s@Qualification' {} Maybe POSIX
a -> Qualification
s {$sel:grantTime:Qualification' :: Maybe POSIX
grantTime = Maybe POSIX
a} :: Qualification) ((Maybe POSIX -> f (Maybe POSIX))
 -> Qualification -> f Qualification)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Qualification
-> f Qualification
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

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

instance Core.FromJSON Qualification where
  parseJSON :: Value -> Parser Qualification
parseJSON =
    String
-> (Object -> Parser Qualification)
-> Value
-> Parser Qualification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Qualification"
      ( \Object
x ->
          Maybe QualificationStatus
-> Maybe Int
-> Maybe Locale
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Qualification
Qualification'
            (Maybe QualificationStatus
 -> Maybe Int
 -> Maybe Locale
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Qualification)
-> Parser (Maybe QualificationStatus)
-> Parser
     (Maybe Int
      -> Maybe Locale
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Qualification)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe QualificationStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Int
   -> Maybe Locale
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Qualification)
-> Parser (Maybe Int)
-> Parser
     (Maybe Locale
      -> Maybe Text -> Maybe POSIX -> Maybe Text -> Qualification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IntegerValue")
            Parser
  (Maybe Locale
   -> Maybe Text -> Maybe POSIX -> Maybe Text -> Qualification)
-> Parser (Maybe Locale)
-> Parser
     (Maybe Text -> Maybe POSIX -> Maybe Text -> Qualification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Locale)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LocaleValue")
            Parser (Maybe Text -> Maybe POSIX -> Maybe Text -> Qualification)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> Qualification)
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 POSIX -> Maybe Text -> Qualification)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> Qualification)
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
"GrantTime")
            Parser (Maybe Text -> Qualification)
-> Parser (Maybe Text) -> Parser Qualification
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")
      )

instance Prelude.Hashable Qualification

instance Prelude.NFData Qualification