{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MechanicalTurk.Types.Qualification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 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 Data.POSIX,
    -- | 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 status of the Qualification. Valid values are Granted | Revoked.
    Qualification -> Maybe QualificationStatus
status :: Prelude.Maybe QualificationStatus,
    -- | The ID of the Worker who possesses the Qualification.
    Qualification -> Maybe Text
workerId :: Prelude.Maybe Prelude.Text
  }
  deriving (Qualification -> Qualification -> Bool
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]
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
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. 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:
--
-- '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.
--
-- '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.
--
-- 'status', 'qualification_status' - The status of the Qualification. Valid values are Granted | Revoked.
--
-- 'workerId', 'qualification_workerId' - The ID of the Worker who possesses the Qualification.
newQualification ::
  Qualification
newQualification :: Qualification
newQualification =
  Qualification'
    { $sel:grantTime:Qualification' :: Maybe POSIX
grantTime = forall a. Maybe a
Prelude.Nothing,
      $sel:integerValue:Qualification' :: Maybe Int
integerValue = forall a. Maybe a
Prelude.Nothing,
      $sel:localeValue:Qualification' :: Maybe Locale
localeValue = forall a. Maybe a
Prelude.Nothing,
      $sel:qualificationTypeId:Qualification' :: Maybe Text
qualificationTypeId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Qualification' :: Maybe QualificationStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:workerId:Qualification' :: Maybe Text
workerId = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' Qualification (Maybe UTCTime)
qualification_grantTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The value (score) of the Qualification, if the Qualification has an
-- integer value.
qualification_integerValue :: Lens.Lens' Qualification (Prelude.Maybe Prelude.Int)
qualification_integerValue :: Lens' Qualification (Maybe Int)
qualification_integerValue = 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 :: Lens' Qualification (Maybe Locale)
qualification_localeValue = 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 :: Lens' Qualification (Maybe Text)
qualification_qualificationTypeId = 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 status of the Qualification. Valid values are Granted | Revoked.
qualification_status :: Lens.Lens' Qualification (Prelude.Maybe QualificationStatus)
qualification_status :: Lens' Qualification (Maybe QualificationStatus)
qualification_status = 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 ID of the Worker who possesses the Qualification.
qualification_workerId :: Lens.Lens' Qualification (Prelude.Maybe Prelude.Text)
qualification_workerId :: Lens' Qualification (Maybe Text)
qualification_workerId = 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 Data.FromJSON Qualification where
  parseJSON :: Value -> Parser Qualification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Qualification"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Int
-> Maybe Locale
-> Maybe Text
-> Maybe QualificationStatus
-> Maybe Text
-> Qualification
Qualification'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"GrantTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IntegerValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LocaleValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"QualificationTypeId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"WorkerId")
      )

instance Prelude.Hashable Qualification where
  hashWithSalt :: Int -> Qualification -> Int
hashWithSalt Int
_salt Qualification' {Maybe Int
Maybe Text
Maybe POSIX
Maybe Locale
Maybe QualificationStatus
workerId :: Maybe Text
status :: Maybe QualificationStatus
qualificationTypeId :: Maybe Text
localeValue :: Maybe Locale
integerValue :: Maybe Int
grantTime :: Maybe POSIX
$sel:workerId:Qualification' :: Qualification -> Maybe Text
$sel:status:Qualification' :: Qualification -> Maybe QualificationStatus
$sel:qualificationTypeId:Qualification' :: Qualification -> Maybe Text
$sel:localeValue:Qualification' :: Qualification -> Maybe Locale
$sel:integerValue:Qualification' :: Qualification -> Maybe Int
$sel:grantTime:Qualification' :: Qualification -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
grantTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
integerValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Locale
localeValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
qualificationTypeId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QualificationStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
workerId

instance Prelude.NFData Qualification where
  rnf :: Qualification -> ()
rnf Qualification' {Maybe Int
Maybe Text
Maybe POSIX
Maybe Locale
Maybe QualificationStatus
workerId :: Maybe Text
status :: Maybe QualificationStatus
qualificationTypeId :: Maybe Text
localeValue :: Maybe Locale
integerValue :: Maybe Int
grantTime :: Maybe POSIX
$sel:workerId:Qualification' :: Qualification -> Maybe Text
$sel:status:Qualification' :: Qualification -> Maybe QualificationStatus
$sel:qualificationTypeId:Qualification' :: Qualification -> Maybe Text
$sel:localeValue:Qualification' :: Qualification -> Maybe Locale
$sel:integerValue:Qualification' :: Qualification -> Maybe Int
$sel:grantTime:Qualification' :: Qualification -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
grantTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
integerValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Locale
localeValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
qualificationTypeId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe QualificationStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
workerId