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

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

-- | This data structure is the data type for the AnswerKey parameter of the
-- ScoreMyKnownAnswers\/2011-09-01 Review Policy.
--
-- /See:/ 'newParameterMapEntry' smart constructor.
data ParameterMapEntry = ParameterMapEntry'
  { -- | The list of answers to the question specified in the MapEntry Key
    -- element. The Worker must match all values in order for the answer to be
    -- scored correctly.
    ParameterMapEntry -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    -- | The QuestionID from the HIT that is used to identify which question
    -- requires Mechanical Turk to score as part of the
    -- ScoreMyKnownAnswers\/2011-09-01 Review Policy.
    ParameterMapEntry -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (ParameterMapEntry -> ParameterMapEntry -> Bool
(ParameterMapEntry -> ParameterMapEntry -> Bool)
-> (ParameterMapEntry -> ParameterMapEntry -> Bool)
-> Eq ParameterMapEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterMapEntry -> ParameterMapEntry -> Bool
$c/= :: ParameterMapEntry -> ParameterMapEntry -> Bool
== :: ParameterMapEntry -> ParameterMapEntry -> Bool
$c== :: ParameterMapEntry -> ParameterMapEntry -> Bool
Prelude.Eq, ReadPrec [ParameterMapEntry]
ReadPrec ParameterMapEntry
Int -> ReadS ParameterMapEntry
ReadS [ParameterMapEntry]
(Int -> ReadS ParameterMapEntry)
-> ReadS [ParameterMapEntry]
-> ReadPrec ParameterMapEntry
-> ReadPrec [ParameterMapEntry]
-> Read ParameterMapEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParameterMapEntry]
$creadListPrec :: ReadPrec [ParameterMapEntry]
readPrec :: ReadPrec ParameterMapEntry
$creadPrec :: ReadPrec ParameterMapEntry
readList :: ReadS [ParameterMapEntry]
$creadList :: ReadS [ParameterMapEntry]
readsPrec :: Int -> ReadS ParameterMapEntry
$creadsPrec :: Int -> ReadS ParameterMapEntry
Prelude.Read, Int -> ParameterMapEntry -> ShowS
[ParameterMapEntry] -> ShowS
ParameterMapEntry -> String
(Int -> ParameterMapEntry -> ShowS)
-> (ParameterMapEntry -> String)
-> ([ParameterMapEntry] -> ShowS)
-> Show ParameterMapEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterMapEntry] -> ShowS
$cshowList :: [ParameterMapEntry] -> ShowS
show :: ParameterMapEntry -> String
$cshow :: ParameterMapEntry -> String
showsPrec :: Int -> ParameterMapEntry -> ShowS
$cshowsPrec :: Int -> ParameterMapEntry -> ShowS
Prelude.Show, (forall x. ParameterMapEntry -> Rep ParameterMapEntry x)
-> (forall x. Rep ParameterMapEntry x -> ParameterMapEntry)
-> Generic ParameterMapEntry
forall x. Rep ParameterMapEntry x -> ParameterMapEntry
forall x. ParameterMapEntry -> Rep ParameterMapEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParameterMapEntry x -> ParameterMapEntry
$cfrom :: forall x. ParameterMapEntry -> Rep ParameterMapEntry x
Prelude.Generic)

-- |
-- Create a value of 'ParameterMapEntry' 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:
--
-- 'values', 'parameterMapEntry_values' - The list of answers to the question specified in the MapEntry Key
-- element. The Worker must match all values in order for the answer to be
-- scored correctly.
--
-- 'key', 'parameterMapEntry_key' - The QuestionID from the HIT that is used to identify which question
-- requires Mechanical Turk to score as part of the
-- ScoreMyKnownAnswers\/2011-09-01 Review Policy.
newParameterMapEntry ::
  ParameterMapEntry
newParameterMapEntry :: ParameterMapEntry
newParameterMapEntry =
  ParameterMapEntry' :: Maybe [Text] -> Maybe Text -> ParameterMapEntry
ParameterMapEntry'
    { $sel:values:ParameterMapEntry' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:key:ParameterMapEntry' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of answers to the question specified in the MapEntry Key
-- element. The Worker must match all values in order for the answer to be
-- scored correctly.
parameterMapEntry_values :: Lens.Lens' ParameterMapEntry (Prelude.Maybe [Prelude.Text])
parameterMapEntry_values :: (Maybe [Text] -> f (Maybe [Text]))
-> ParameterMapEntry -> f ParameterMapEntry
parameterMapEntry_values = (ParameterMapEntry -> Maybe [Text])
-> (ParameterMapEntry -> Maybe [Text] -> ParameterMapEntry)
-> Lens
     ParameterMapEntry ParameterMapEntry (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterMapEntry' {Maybe [Text]
values :: Maybe [Text]
$sel:values:ParameterMapEntry' :: ParameterMapEntry -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: ParameterMapEntry
s@ParameterMapEntry' {} Maybe [Text]
a -> ParameterMapEntry
s {$sel:values:ParameterMapEntry' :: Maybe [Text]
values = Maybe [Text]
a} :: ParameterMapEntry) ((Maybe [Text] -> f (Maybe [Text]))
 -> ParameterMapEntry -> f ParameterMapEntry)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ParameterMapEntry
-> f ParameterMapEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The QuestionID from the HIT that is used to identify which question
-- requires Mechanical Turk to score as part of the
-- ScoreMyKnownAnswers\/2011-09-01 Review Policy.
parameterMapEntry_key :: Lens.Lens' ParameterMapEntry (Prelude.Maybe Prelude.Text)
parameterMapEntry_key :: (Maybe Text -> f (Maybe Text))
-> ParameterMapEntry -> f ParameterMapEntry
parameterMapEntry_key = (ParameterMapEntry -> Maybe Text)
-> (ParameterMapEntry -> Maybe Text -> ParameterMapEntry)
-> Lens
     ParameterMapEntry ParameterMapEntry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterMapEntry' {Maybe Text
key :: Maybe Text
$sel:key:ParameterMapEntry' :: ParameterMapEntry -> Maybe Text
key} -> Maybe Text
key) (\s :: ParameterMapEntry
s@ParameterMapEntry' {} Maybe Text
a -> ParameterMapEntry
s {$sel:key:ParameterMapEntry' :: Maybe Text
key = Maybe Text
a} :: ParameterMapEntry)

instance Core.FromJSON ParameterMapEntry where
  parseJSON :: Value -> Parser ParameterMapEntry
parseJSON =
    String
-> (Object -> Parser ParameterMapEntry)
-> Value
-> Parser ParameterMapEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ParameterMapEntry"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> ParameterMapEntry
ParameterMapEntry'
            (Maybe [Text] -> Maybe Text -> ParameterMapEntry)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> ParameterMapEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Values" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> ParameterMapEntry)
-> Parser (Maybe Text) -> Parser ParameterMapEntry
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
"Key")
      )

instance Prelude.Hashable ParameterMapEntry

instance Prelude.NFData ParameterMapEntry

instance Core.ToJSON ParameterMapEntry where
  toJSON :: ParameterMapEntry -> Value
toJSON ParameterMapEntry' {Maybe [Text]
Maybe Text
key :: Maybe Text
values :: Maybe [Text]
$sel:key:ParameterMapEntry' :: ParameterMapEntry -> Maybe Text
$sel:values:ParameterMapEntry' :: ParameterMapEntry -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Values" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
values,
            (Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
key
          ]
      )