{-# 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.DeviceFarm.Types.OfferingTransaction
-- 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.DeviceFarm.Types.OfferingTransaction where

import qualified Amazonka.Core as Core
import Amazonka.DeviceFarm.Types.MonetaryAmount
import Amazonka.DeviceFarm.Types.OfferingStatus
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the metadata of an offering transaction.
--
-- /See:/ 'newOfferingTransaction' smart constructor.
data OfferingTransaction = OfferingTransaction'
  { -- | The status of an offering transaction.
    OfferingTransaction -> Maybe OfferingStatus
offeringStatus :: Prelude.Maybe OfferingStatus,
    -- | The cost of an offering transaction.
    OfferingTransaction -> Maybe MonetaryAmount
cost :: Prelude.Maybe MonetaryAmount,
    -- | The transaction ID of the offering transaction.
    OfferingTransaction -> Maybe Text
transactionId :: Prelude.Maybe Prelude.Text,
    -- | The ID that corresponds to a device offering promotion.
    OfferingTransaction -> Maybe Text
offeringPromotionId :: Prelude.Maybe Prelude.Text,
    -- | The date on which an offering transaction was created.
    OfferingTransaction -> Maybe POSIX
createdOn :: Prelude.Maybe Core.POSIX
  }
  deriving (OfferingTransaction -> OfferingTransaction -> Bool
(OfferingTransaction -> OfferingTransaction -> Bool)
-> (OfferingTransaction -> OfferingTransaction -> Bool)
-> Eq OfferingTransaction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OfferingTransaction -> OfferingTransaction -> Bool
$c/= :: OfferingTransaction -> OfferingTransaction -> Bool
== :: OfferingTransaction -> OfferingTransaction -> Bool
$c== :: OfferingTransaction -> OfferingTransaction -> Bool
Prelude.Eq, ReadPrec [OfferingTransaction]
ReadPrec OfferingTransaction
Int -> ReadS OfferingTransaction
ReadS [OfferingTransaction]
(Int -> ReadS OfferingTransaction)
-> ReadS [OfferingTransaction]
-> ReadPrec OfferingTransaction
-> ReadPrec [OfferingTransaction]
-> Read OfferingTransaction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OfferingTransaction]
$creadListPrec :: ReadPrec [OfferingTransaction]
readPrec :: ReadPrec OfferingTransaction
$creadPrec :: ReadPrec OfferingTransaction
readList :: ReadS [OfferingTransaction]
$creadList :: ReadS [OfferingTransaction]
readsPrec :: Int -> ReadS OfferingTransaction
$creadsPrec :: Int -> ReadS OfferingTransaction
Prelude.Read, Int -> OfferingTransaction -> ShowS
[OfferingTransaction] -> ShowS
OfferingTransaction -> String
(Int -> OfferingTransaction -> ShowS)
-> (OfferingTransaction -> String)
-> ([OfferingTransaction] -> ShowS)
-> Show OfferingTransaction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OfferingTransaction] -> ShowS
$cshowList :: [OfferingTransaction] -> ShowS
show :: OfferingTransaction -> String
$cshow :: OfferingTransaction -> String
showsPrec :: Int -> OfferingTransaction -> ShowS
$cshowsPrec :: Int -> OfferingTransaction -> ShowS
Prelude.Show, (forall x. OfferingTransaction -> Rep OfferingTransaction x)
-> (forall x. Rep OfferingTransaction x -> OfferingTransaction)
-> Generic OfferingTransaction
forall x. Rep OfferingTransaction x -> OfferingTransaction
forall x. OfferingTransaction -> Rep OfferingTransaction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OfferingTransaction x -> OfferingTransaction
$cfrom :: forall x. OfferingTransaction -> Rep OfferingTransaction x
Prelude.Generic)

-- |
-- Create a value of 'OfferingTransaction' 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:
--
-- 'offeringStatus', 'offeringTransaction_offeringStatus' - The status of an offering transaction.
--
-- 'cost', 'offeringTransaction_cost' - The cost of an offering transaction.
--
-- 'transactionId', 'offeringTransaction_transactionId' - The transaction ID of the offering transaction.
--
-- 'offeringPromotionId', 'offeringTransaction_offeringPromotionId' - The ID that corresponds to a device offering promotion.
--
-- 'createdOn', 'offeringTransaction_createdOn' - The date on which an offering transaction was created.
newOfferingTransaction ::
  OfferingTransaction
newOfferingTransaction :: OfferingTransaction
newOfferingTransaction =
  OfferingTransaction' :: Maybe OfferingStatus
-> Maybe MonetaryAmount
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> OfferingTransaction
OfferingTransaction'
    { $sel:offeringStatus:OfferingTransaction' :: Maybe OfferingStatus
offeringStatus =
        Maybe OfferingStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:cost:OfferingTransaction' :: Maybe MonetaryAmount
cost = Maybe MonetaryAmount
forall a. Maybe a
Prelude.Nothing,
      $sel:transactionId:OfferingTransaction' :: Maybe Text
transactionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:offeringPromotionId:OfferingTransaction' :: Maybe Text
offeringPromotionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdOn:OfferingTransaction' :: Maybe POSIX
createdOn = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of an offering transaction.
offeringTransaction_offeringStatus :: Lens.Lens' OfferingTransaction (Prelude.Maybe OfferingStatus)
offeringTransaction_offeringStatus :: (Maybe OfferingStatus -> f (Maybe OfferingStatus))
-> OfferingTransaction -> f OfferingTransaction
offeringTransaction_offeringStatus = (OfferingTransaction -> Maybe OfferingStatus)
-> (OfferingTransaction
    -> Maybe OfferingStatus -> OfferingTransaction)
-> Lens
     OfferingTransaction
     OfferingTransaction
     (Maybe OfferingStatus)
     (Maybe OfferingStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OfferingTransaction' {Maybe OfferingStatus
offeringStatus :: Maybe OfferingStatus
$sel:offeringStatus:OfferingTransaction' :: OfferingTransaction -> Maybe OfferingStatus
offeringStatus} -> Maybe OfferingStatus
offeringStatus) (\s :: OfferingTransaction
s@OfferingTransaction' {} Maybe OfferingStatus
a -> OfferingTransaction
s {$sel:offeringStatus:OfferingTransaction' :: Maybe OfferingStatus
offeringStatus = Maybe OfferingStatus
a} :: OfferingTransaction)

-- | The cost of an offering transaction.
offeringTransaction_cost :: Lens.Lens' OfferingTransaction (Prelude.Maybe MonetaryAmount)
offeringTransaction_cost :: (Maybe MonetaryAmount -> f (Maybe MonetaryAmount))
-> OfferingTransaction -> f OfferingTransaction
offeringTransaction_cost = (OfferingTransaction -> Maybe MonetaryAmount)
-> (OfferingTransaction
    -> Maybe MonetaryAmount -> OfferingTransaction)
-> Lens
     OfferingTransaction
     OfferingTransaction
     (Maybe MonetaryAmount)
     (Maybe MonetaryAmount)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OfferingTransaction' {Maybe MonetaryAmount
cost :: Maybe MonetaryAmount
$sel:cost:OfferingTransaction' :: OfferingTransaction -> Maybe MonetaryAmount
cost} -> Maybe MonetaryAmount
cost) (\s :: OfferingTransaction
s@OfferingTransaction' {} Maybe MonetaryAmount
a -> OfferingTransaction
s {$sel:cost:OfferingTransaction' :: Maybe MonetaryAmount
cost = Maybe MonetaryAmount
a} :: OfferingTransaction)

-- | The transaction ID of the offering transaction.
offeringTransaction_transactionId :: Lens.Lens' OfferingTransaction (Prelude.Maybe Prelude.Text)
offeringTransaction_transactionId :: (Maybe Text -> f (Maybe Text))
-> OfferingTransaction -> f OfferingTransaction
offeringTransaction_transactionId = (OfferingTransaction -> Maybe Text)
-> (OfferingTransaction -> Maybe Text -> OfferingTransaction)
-> Lens
     OfferingTransaction OfferingTransaction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OfferingTransaction' {Maybe Text
transactionId :: Maybe Text
$sel:transactionId:OfferingTransaction' :: OfferingTransaction -> Maybe Text
transactionId} -> Maybe Text
transactionId) (\s :: OfferingTransaction
s@OfferingTransaction' {} Maybe Text
a -> OfferingTransaction
s {$sel:transactionId:OfferingTransaction' :: Maybe Text
transactionId = Maybe Text
a} :: OfferingTransaction)

-- | The ID that corresponds to a device offering promotion.
offeringTransaction_offeringPromotionId :: Lens.Lens' OfferingTransaction (Prelude.Maybe Prelude.Text)
offeringTransaction_offeringPromotionId :: (Maybe Text -> f (Maybe Text))
-> OfferingTransaction -> f OfferingTransaction
offeringTransaction_offeringPromotionId = (OfferingTransaction -> Maybe Text)
-> (OfferingTransaction -> Maybe Text -> OfferingTransaction)
-> Lens
     OfferingTransaction OfferingTransaction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OfferingTransaction' {Maybe Text
offeringPromotionId :: Maybe Text
$sel:offeringPromotionId:OfferingTransaction' :: OfferingTransaction -> Maybe Text
offeringPromotionId} -> Maybe Text
offeringPromotionId) (\s :: OfferingTransaction
s@OfferingTransaction' {} Maybe Text
a -> OfferingTransaction
s {$sel:offeringPromotionId:OfferingTransaction' :: Maybe Text
offeringPromotionId = Maybe Text
a} :: OfferingTransaction)

-- | The date on which an offering transaction was created.
offeringTransaction_createdOn :: Lens.Lens' OfferingTransaction (Prelude.Maybe Prelude.UTCTime)
offeringTransaction_createdOn :: (Maybe UTCTime -> f (Maybe UTCTime))
-> OfferingTransaction -> f OfferingTransaction
offeringTransaction_createdOn = (OfferingTransaction -> Maybe POSIX)
-> (OfferingTransaction -> Maybe POSIX -> OfferingTransaction)
-> Lens
     OfferingTransaction OfferingTransaction (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OfferingTransaction' {Maybe POSIX
createdOn :: Maybe POSIX
$sel:createdOn:OfferingTransaction' :: OfferingTransaction -> Maybe POSIX
createdOn} -> Maybe POSIX
createdOn) (\s :: OfferingTransaction
s@OfferingTransaction' {} Maybe POSIX
a -> OfferingTransaction
s {$sel:createdOn:OfferingTransaction' :: Maybe POSIX
createdOn = Maybe POSIX
a} :: OfferingTransaction) ((Maybe POSIX -> f (Maybe POSIX))
 -> OfferingTransaction -> f OfferingTransaction)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> OfferingTransaction
-> f OfferingTransaction
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 OfferingTransaction where
  parseJSON :: Value -> Parser OfferingTransaction
parseJSON =
    String
-> (Object -> Parser OfferingTransaction)
-> Value
-> Parser OfferingTransaction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OfferingTransaction"
      ( \Object
x ->
          Maybe OfferingStatus
-> Maybe MonetaryAmount
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> OfferingTransaction
OfferingTransaction'
            (Maybe OfferingStatus
 -> Maybe MonetaryAmount
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> OfferingTransaction)
-> Parser (Maybe OfferingStatus)
-> Parser
     (Maybe MonetaryAmount
      -> Maybe Text -> Maybe Text -> Maybe POSIX -> OfferingTransaction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe OfferingStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"offeringStatus")
            Parser
  (Maybe MonetaryAmount
   -> Maybe Text -> Maybe Text -> Maybe POSIX -> OfferingTransaction)
-> Parser (Maybe MonetaryAmount)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe POSIX -> OfferingTransaction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MonetaryAmount)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cost")
            Parser
  (Maybe Text -> Maybe Text -> Maybe POSIX -> OfferingTransaction)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> OfferingTransaction)
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
"transactionId")
            Parser (Maybe Text -> Maybe POSIX -> OfferingTransaction)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> OfferingTransaction)
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
"offeringPromotionId")
            Parser (Maybe POSIX -> OfferingTransaction)
-> Parser (Maybe POSIX) -> Parser OfferingTransaction
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
"createdOn")
      )

instance Prelude.Hashable OfferingTransaction

instance Prelude.NFData OfferingTransaction