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

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

-- | An object representing a Bonus payment paid to a Worker.
--
-- /See:/ 'newBonusPayment' smart constructor.
data BonusPayment = BonusPayment'
  { -- | The Reason text given when the bonus was granted, if any.
    BonusPayment -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The date and time of when the bonus was granted.
    BonusPayment -> Maybe POSIX
grantTime :: Prelude.Maybe Core.POSIX,
    -- | The ID of the Worker to whom the bonus was paid.
    BonusPayment -> Maybe Text
workerId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the assignment associated with this bonus payment.
    BonusPayment -> Maybe Text
assignmentId :: Prelude.Maybe Prelude.Text,
    BonusPayment -> Maybe Text
bonusAmount :: Prelude.Maybe Prelude.Text
  }
  deriving (BonusPayment -> BonusPayment -> Bool
(BonusPayment -> BonusPayment -> Bool)
-> (BonusPayment -> BonusPayment -> Bool) -> Eq BonusPayment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BonusPayment -> BonusPayment -> Bool
$c/= :: BonusPayment -> BonusPayment -> Bool
== :: BonusPayment -> BonusPayment -> Bool
$c== :: BonusPayment -> BonusPayment -> Bool
Prelude.Eq, ReadPrec [BonusPayment]
ReadPrec BonusPayment
Int -> ReadS BonusPayment
ReadS [BonusPayment]
(Int -> ReadS BonusPayment)
-> ReadS [BonusPayment]
-> ReadPrec BonusPayment
-> ReadPrec [BonusPayment]
-> Read BonusPayment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BonusPayment]
$creadListPrec :: ReadPrec [BonusPayment]
readPrec :: ReadPrec BonusPayment
$creadPrec :: ReadPrec BonusPayment
readList :: ReadS [BonusPayment]
$creadList :: ReadS [BonusPayment]
readsPrec :: Int -> ReadS BonusPayment
$creadsPrec :: Int -> ReadS BonusPayment
Prelude.Read, Int -> BonusPayment -> ShowS
[BonusPayment] -> ShowS
BonusPayment -> String
(Int -> BonusPayment -> ShowS)
-> (BonusPayment -> String)
-> ([BonusPayment] -> ShowS)
-> Show BonusPayment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BonusPayment] -> ShowS
$cshowList :: [BonusPayment] -> ShowS
show :: BonusPayment -> String
$cshow :: BonusPayment -> String
showsPrec :: Int -> BonusPayment -> ShowS
$cshowsPrec :: Int -> BonusPayment -> ShowS
Prelude.Show, (forall x. BonusPayment -> Rep BonusPayment x)
-> (forall x. Rep BonusPayment x -> BonusPayment)
-> Generic BonusPayment
forall x. Rep BonusPayment x -> BonusPayment
forall x. BonusPayment -> Rep BonusPayment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BonusPayment x -> BonusPayment
$cfrom :: forall x. BonusPayment -> Rep BonusPayment x
Prelude.Generic)

-- |
-- Create a value of 'BonusPayment' 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:
--
-- 'reason', 'bonusPayment_reason' - The Reason text given when the bonus was granted, if any.
--
-- 'grantTime', 'bonusPayment_grantTime' - The date and time of when the bonus was granted.
--
-- 'workerId', 'bonusPayment_workerId' - The ID of the Worker to whom the bonus was paid.
--
-- 'assignmentId', 'bonusPayment_assignmentId' - The ID of the assignment associated with this bonus payment.
--
-- 'bonusAmount', 'bonusPayment_bonusAmount' - Undocumented member.
newBonusPayment ::
  BonusPayment
newBonusPayment :: BonusPayment
newBonusPayment =
  BonusPayment' :: Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> BonusPayment
BonusPayment'
    { $sel:reason:BonusPayment' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:grantTime:BonusPayment' :: Maybe POSIX
grantTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:workerId:BonusPayment' :: Maybe Text
workerId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:assignmentId:BonusPayment' :: Maybe Text
assignmentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bonusAmount:BonusPayment' :: Maybe Text
bonusAmount = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Reason text given when the bonus was granted, if any.
bonusPayment_reason :: Lens.Lens' BonusPayment (Prelude.Maybe Prelude.Text)
bonusPayment_reason :: (Maybe Text -> f (Maybe Text)) -> BonusPayment -> f BonusPayment
bonusPayment_reason = (BonusPayment -> Maybe Text)
-> (BonusPayment -> Maybe Text -> BonusPayment)
-> Lens BonusPayment BonusPayment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BonusPayment' {Maybe Text
reason :: Maybe Text
$sel:reason:BonusPayment' :: BonusPayment -> Maybe Text
reason} -> Maybe Text
reason) (\s :: BonusPayment
s@BonusPayment' {} Maybe Text
a -> BonusPayment
s {$sel:reason:BonusPayment' :: Maybe Text
reason = Maybe Text
a} :: BonusPayment)

-- | The date and time of when the bonus was granted.
bonusPayment_grantTime :: Lens.Lens' BonusPayment (Prelude.Maybe Prelude.UTCTime)
bonusPayment_grantTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> BonusPayment -> f BonusPayment
bonusPayment_grantTime = (BonusPayment -> Maybe POSIX)
-> (BonusPayment -> Maybe POSIX -> BonusPayment)
-> Lens BonusPayment BonusPayment (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BonusPayment' {Maybe POSIX
grantTime :: Maybe POSIX
$sel:grantTime:BonusPayment' :: BonusPayment -> Maybe POSIX
grantTime} -> Maybe POSIX
grantTime) (\s :: BonusPayment
s@BonusPayment' {} Maybe POSIX
a -> BonusPayment
s {$sel:grantTime:BonusPayment' :: Maybe POSIX
grantTime = Maybe POSIX
a} :: BonusPayment) ((Maybe POSIX -> f (Maybe POSIX))
 -> BonusPayment -> f BonusPayment)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> BonusPayment
-> f BonusPayment
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 to whom the bonus was paid.
bonusPayment_workerId :: Lens.Lens' BonusPayment (Prelude.Maybe Prelude.Text)
bonusPayment_workerId :: (Maybe Text -> f (Maybe Text)) -> BonusPayment -> f BonusPayment
bonusPayment_workerId = (BonusPayment -> Maybe Text)
-> (BonusPayment -> Maybe Text -> BonusPayment)
-> Lens BonusPayment BonusPayment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BonusPayment' {Maybe Text
workerId :: Maybe Text
$sel:workerId:BonusPayment' :: BonusPayment -> Maybe Text
workerId} -> Maybe Text
workerId) (\s :: BonusPayment
s@BonusPayment' {} Maybe Text
a -> BonusPayment
s {$sel:workerId:BonusPayment' :: Maybe Text
workerId = Maybe Text
a} :: BonusPayment)

-- | The ID of the assignment associated with this bonus payment.
bonusPayment_assignmentId :: Lens.Lens' BonusPayment (Prelude.Maybe Prelude.Text)
bonusPayment_assignmentId :: (Maybe Text -> f (Maybe Text)) -> BonusPayment -> f BonusPayment
bonusPayment_assignmentId = (BonusPayment -> Maybe Text)
-> (BonusPayment -> Maybe Text -> BonusPayment)
-> Lens BonusPayment BonusPayment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BonusPayment' {Maybe Text
assignmentId :: Maybe Text
$sel:assignmentId:BonusPayment' :: BonusPayment -> Maybe Text
assignmentId} -> Maybe Text
assignmentId) (\s :: BonusPayment
s@BonusPayment' {} Maybe Text
a -> BonusPayment
s {$sel:assignmentId:BonusPayment' :: Maybe Text
assignmentId = Maybe Text
a} :: BonusPayment)

-- | Undocumented member.
bonusPayment_bonusAmount :: Lens.Lens' BonusPayment (Prelude.Maybe Prelude.Text)
bonusPayment_bonusAmount :: (Maybe Text -> f (Maybe Text)) -> BonusPayment -> f BonusPayment
bonusPayment_bonusAmount = (BonusPayment -> Maybe Text)
-> (BonusPayment -> Maybe Text -> BonusPayment)
-> Lens BonusPayment BonusPayment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BonusPayment' {Maybe Text
bonusAmount :: Maybe Text
$sel:bonusAmount:BonusPayment' :: BonusPayment -> Maybe Text
bonusAmount} -> Maybe Text
bonusAmount) (\s :: BonusPayment
s@BonusPayment' {} Maybe Text
a -> BonusPayment
s {$sel:bonusAmount:BonusPayment' :: Maybe Text
bonusAmount = Maybe Text
a} :: BonusPayment)

instance Core.FromJSON BonusPayment where
  parseJSON :: Value -> Parser BonusPayment
parseJSON =
    String
-> (Object -> Parser BonusPayment) -> Value -> Parser BonusPayment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BonusPayment"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> BonusPayment
BonusPayment'
            (Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> BonusPayment)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe Text -> Maybe Text -> BonusPayment)
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
"Reason")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe Text -> Maybe Text -> BonusPayment)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> BonusPayment)
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 -> Maybe Text -> Maybe Text -> BonusPayment)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> BonusPayment)
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 Text -> Maybe Text -> BonusPayment)
-> Parser (Maybe Text) -> Parser (Maybe Text -> BonusPayment)
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
"AssignmentId")
            Parser (Maybe Text -> BonusPayment)
-> Parser (Maybe Text) -> Parser BonusPayment
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
"BonusAmount")
      )

instance Prelude.Hashable BonusPayment

instance Prelude.NFData BonusPayment