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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DeviceFarm.Types.CurrencyCode
import qualified Amazonka.Prelude as Prelude

-- | A number that represents the monetary amount for an offering or
-- transaction.
--
-- /See:/ 'newMonetaryAmount' smart constructor.
data MonetaryAmount = MonetaryAmount'
  { -- | The numerical amount of an offering or transaction.
    MonetaryAmount -> Maybe Double
amount :: Prelude.Maybe Prelude.Double,
    -- | The currency code of a monetary amount. For example, @USD@ means U.S.
    -- dollars.
    MonetaryAmount -> Maybe CurrencyCode
currencyCode :: Prelude.Maybe CurrencyCode
  }
  deriving (MonetaryAmount -> MonetaryAmount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MonetaryAmount -> MonetaryAmount -> Bool
$c/= :: MonetaryAmount -> MonetaryAmount -> Bool
== :: MonetaryAmount -> MonetaryAmount -> Bool
$c== :: MonetaryAmount -> MonetaryAmount -> Bool
Prelude.Eq, ReadPrec [MonetaryAmount]
ReadPrec MonetaryAmount
Int -> ReadS MonetaryAmount
ReadS [MonetaryAmount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MonetaryAmount]
$creadListPrec :: ReadPrec [MonetaryAmount]
readPrec :: ReadPrec MonetaryAmount
$creadPrec :: ReadPrec MonetaryAmount
readList :: ReadS [MonetaryAmount]
$creadList :: ReadS [MonetaryAmount]
readsPrec :: Int -> ReadS MonetaryAmount
$creadsPrec :: Int -> ReadS MonetaryAmount
Prelude.Read, Int -> MonetaryAmount -> ShowS
[MonetaryAmount] -> ShowS
MonetaryAmount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MonetaryAmount] -> ShowS
$cshowList :: [MonetaryAmount] -> ShowS
show :: MonetaryAmount -> String
$cshow :: MonetaryAmount -> String
showsPrec :: Int -> MonetaryAmount -> ShowS
$cshowsPrec :: Int -> MonetaryAmount -> ShowS
Prelude.Show, forall x. Rep MonetaryAmount x -> MonetaryAmount
forall x. MonetaryAmount -> Rep MonetaryAmount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MonetaryAmount x -> MonetaryAmount
$cfrom :: forall x. MonetaryAmount -> Rep MonetaryAmount x
Prelude.Generic)

-- |
-- Create a value of 'MonetaryAmount' 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:
--
-- 'amount', 'monetaryAmount_amount' - The numerical amount of an offering or transaction.
--
-- 'currencyCode', 'monetaryAmount_currencyCode' - The currency code of a monetary amount. For example, @USD@ means U.S.
-- dollars.
newMonetaryAmount ::
  MonetaryAmount
newMonetaryAmount :: MonetaryAmount
newMonetaryAmount =
  MonetaryAmount'
    { $sel:amount:MonetaryAmount' :: Maybe Double
amount = forall a. Maybe a
Prelude.Nothing,
      $sel:currencyCode:MonetaryAmount' :: Maybe CurrencyCode
currencyCode = forall a. Maybe a
Prelude.Nothing
    }

-- | The numerical amount of an offering or transaction.
monetaryAmount_amount :: Lens.Lens' MonetaryAmount (Prelude.Maybe Prelude.Double)
monetaryAmount_amount :: Lens' MonetaryAmount (Maybe Double)
monetaryAmount_amount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonetaryAmount' {Maybe Double
amount :: Maybe Double
$sel:amount:MonetaryAmount' :: MonetaryAmount -> Maybe Double
amount} -> Maybe Double
amount) (\s :: MonetaryAmount
s@MonetaryAmount' {} Maybe Double
a -> MonetaryAmount
s {$sel:amount:MonetaryAmount' :: Maybe Double
amount = Maybe Double
a} :: MonetaryAmount)

-- | The currency code of a monetary amount. For example, @USD@ means U.S.
-- dollars.
monetaryAmount_currencyCode :: Lens.Lens' MonetaryAmount (Prelude.Maybe CurrencyCode)
monetaryAmount_currencyCode :: Lens' MonetaryAmount (Maybe CurrencyCode)
monetaryAmount_currencyCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonetaryAmount' {Maybe CurrencyCode
currencyCode :: Maybe CurrencyCode
$sel:currencyCode:MonetaryAmount' :: MonetaryAmount -> Maybe CurrencyCode
currencyCode} -> Maybe CurrencyCode
currencyCode) (\s :: MonetaryAmount
s@MonetaryAmount' {} Maybe CurrencyCode
a -> MonetaryAmount
s {$sel:currencyCode:MonetaryAmount' :: Maybe CurrencyCode
currencyCode = Maybe CurrencyCode
a} :: MonetaryAmount)

instance Data.FromJSON MonetaryAmount where
  parseJSON :: Value -> Parser MonetaryAmount
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MonetaryAmount"
      ( \Object
x ->
          Maybe Double -> Maybe CurrencyCode -> MonetaryAmount
MonetaryAmount'
            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
"amount")
            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
"currencyCode")
      )

instance Prelude.Hashable MonetaryAmount where
  hashWithSalt :: Int -> MonetaryAmount -> Int
hashWithSalt Int
_salt MonetaryAmount' {Maybe Double
Maybe CurrencyCode
currencyCode :: Maybe CurrencyCode
amount :: Maybe Double
$sel:currencyCode:MonetaryAmount' :: MonetaryAmount -> Maybe CurrencyCode
$sel:amount:MonetaryAmount' :: MonetaryAmount -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
amount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CurrencyCode
currencyCode

instance Prelude.NFData MonetaryAmount where
  rnf :: MonetaryAmount -> ()
rnf MonetaryAmount' {Maybe Double
Maybe CurrencyCode
currencyCode :: Maybe CurrencyCode
amount :: Maybe Double
$sel:currencyCode:MonetaryAmount' :: MonetaryAmount -> Maybe CurrencyCode
$sel:amount:MonetaryAmount' :: MonetaryAmount -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
amount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CurrencyCode
currencyCode