{-# 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.SageMaker.Types.USD
-- 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.SageMaker.Types.USD where

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

-- | Represents an amount of money in United States dollars.
--
-- /See:/ 'newUSD' smart constructor.
data USD = USD'
  { -- | The fractional portion, in cents, of the amount.
    USD -> Maybe Natural
cents :: Prelude.Maybe Prelude.Natural,
    -- | The whole number of dollars in the amount.
    USD -> Maybe Natural
dollars :: Prelude.Maybe Prelude.Natural,
    -- | Fractions of a cent, in tenths.
    USD -> Maybe Natural
tenthFractionsOfACent :: Prelude.Maybe Prelude.Natural
  }
  deriving (USD -> USD -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: USD -> USD -> Bool
$c/= :: USD -> USD -> Bool
== :: USD -> USD -> Bool
$c== :: USD -> USD -> Bool
Prelude.Eq, ReadPrec [USD]
ReadPrec USD
Int -> ReadS USD
ReadS [USD]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [USD]
$creadListPrec :: ReadPrec [USD]
readPrec :: ReadPrec USD
$creadPrec :: ReadPrec USD
readList :: ReadS [USD]
$creadList :: ReadS [USD]
readsPrec :: Int -> ReadS USD
$creadsPrec :: Int -> ReadS USD
Prelude.Read, Int -> USD -> ShowS
[USD] -> ShowS
USD -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [USD] -> ShowS
$cshowList :: [USD] -> ShowS
show :: USD -> String
$cshow :: USD -> String
showsPrec :: Int -> USD -> ShowS
$cshowsPrec :: Int -> USD -> ShowS
Prelude.Show, forall x. Rep USD x -> USD
forall x. USD -> Rep USD x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep USD x -> USD
$cfrom :: forall x. USD -> Rep USD x
Prelude.Generic)

-- |
-- Create a value of 'USD' 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:
--
-- 'cents', 'usd_cents' - The fractional portion, in cents, of the amount.
--
-- 'dollars', 'usd_dollars' - The whole number of dollars in the amount.
--
-- 'tenthFractionsOfACent', 'usd_tenthFractionsOfACent' - Fractions of a cent, in tenths.
newUSD ::
  USD
newUSD :: USD
newUSD =
  USD'
    { $sel:cents:USD' :: Maybe Natural
cents = forall a. Maybe a
Prelude.Nothing,
      $sel:dollars:USD' :: Maybe Natural
dollars = forall a. Maybe a
Prelude.Nothing,
      $sel:tenthFractionsOfACent:USD' :: Maybe Natural
tenthFractionsOfACent = forall a. Maybe a
Prelude.Nothing
    }

-- | The fractional portion, in cents, of the amount.
usd_cents :: Lens.Lens' USD (Prelude.Maybe Prelude.Natural)
usd_cents :: Lens' USD (Maybe Natural)
usd_cents = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\USD' {Maybe Natural
cents :: Maybe Natural
$sel:cents:USD' :: USD -> Maybe Natural
cents} -> Maybe Natural
cents) (\s :: USD
s@USD' {} Maybe Natural
a -> USD
s {$sel:cents:USD' :: Maybe Natural
cents = Maybe Natural
a} :: USD)

-- | The whole number of dollars in the amount.
usd_dollars :: Lens.Lens' USD (Prelude.Maybe Prelude.Natural)
usd_dollars :: Lens' USD (Maybe Natural)
usd_dollars = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\USD' {Maybe Natural
dollars :: Maybe Natural
$sel:dollars:USD' :: USD -> Maybe Natural
dollars} -> Maybe Natural
dollars) (\s :: USD
s@USD' {} Maybe Natural
a -> USD
s {$sel:dollars:USD' :: Maybe Natural
dollars = Maybe Natural
a} :: USD)

-- | Fractions of a cent, in tenths.
usd_tenthFractionsOfACent :: Lens.Lens' USD (Prelude.Maybe Prelude.Natural)
usd_tenthFractionsOfACent :: Lens' USD (Maybe Natural)
usd_tenthFractionsOfACent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\USD' {Maybe Natural
tenthFractionsOfACent :: Maybe Natural
$sel:tenthFractionsOfACent:USD' :: USD -> Maybe Natural
tenthFractionsOfACent} -> Maybe Natural
tenthFractionsOfACent) (\s :: USD
s@USD' {} Maybe Natural
a -> USD
s {$sel:tenthFractionsOfACent:USD' :: Maybe Natural
tenthFractionsOfACent = Maybe Natural
a} :: USD)

instance Data.FromJSON USD where
  parseJSON :: Value -> Parser USD
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"USD"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> Maybe Natural -> USD
USD'
            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
"Cents")
            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
"Dollars")
            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
"TenthFractionsOfACent")
      )

instance Prelude.Hashable USD where
  hashWithSalt :: Int -> USD -> Int
hashWithSalt Int
_salt USD' {Maybe Natural
tenthFractionsOfACent :: Maybe Natural
dollars :: Maybe Natural
cents :: Maybe Natural
$sel:tenthFractionsOfACent:USD' :: USD -> Maybe Natural
$sel:dollars:USD' :: USD -> Maybe Natural
$sel:cents:USD' :: USD -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
cents
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
dollars
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
tenthFractionsOfACent

instance Prelude.NFData USD where
  rnf :: USD -> ()
rnf USD' {Maybe Natural
tenthFractionsOfACent :: Maybe Natural
dollars :: Maybe Natural
cents :: Maybe Natural
$sel:tenthFractionsOfACent:USD' :: USD -> Maybe Natural
$sel:dollars:USD' :: USD -> Maybe Natural
$sel:cents:USD' :: USD -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
cents
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
dollars
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
tenthFractionsOfACent

instance Data.ToJSON USD where
  toJSON :: USD -> Value
toJSON USD' {Maybe Natural
tenthFractionsOfACent :: Maybe Natural
dollars :: Maybe Natural
cents :: Maybe Natural
$sel:tenthFractionsOfACent:USD' :: USD -> Maybe Natural
$sel:dollars:USD' :: USD -> Maybe Natural
$sel:cents:USD' :: USD -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Cents" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
cents,
            (Key
"Dollars" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
dollars,
            (Key
"TenthFractionsOfACent" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
tenthFractionsOfACent
          ]
      )