{-# 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 #-}
module Amazonka.Budgets.Types.Spend where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Spend = Spend'
{
Spend -> Text
amount :: Prelude.Text,
Spend -> Text
unit :: Prelude.Text
}
deriving (Spend -> Spend -> Bool
(Spend -> Spend -> Bool) -> (Spend -> Spend -> Bool) -> Eq Spend
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Spend -> Spend -> Bool
$c/= :: Spend -> Spend -> Bool
== :: Spend -> Spend -> Bool
$c== :: Spend -> Spend -> Bool
Prelude.Eq, ReadPrec [Spend]
ReadPrec Spend
Int -> ReadS Spend
ReadS [Spend]
(Int -> ReadS Spend)
-> ReadS [Spend]
-> ReadPrec Spend
-> ReadPrec [Spend]
-> Read Spend
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Spend]
$creadListPrec :: ReadPrec [Spend]
readPrec :: ReadPrec Spend
$creadPrec :: ReadPrec Spend
readList :: ReadS [Spend]
$creadList :: ReadS [Spend]
readsPrec :: Int -> ReadS Spend
$creadsPrec :: Int -> ReadS Spend
Prelude.Read, Int -> Spend -> ShowS
[Spend] -> ShowS
Spend -> String
(Int -> Spend -> ShowS)
-> (Spend -> String) -> ([Spend] -> ShowS) -> Show Spend
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Spend] -> ShowS
$cshowList :: [Spend] -> ShowS
show :: Spend -> String
$cshow :: Spend -> String
showsPrec :: Int -> Spend -> ShowS
$cshowsPrec :: Int -> Spend -> ShowS
Prelude.Show, (forall x. Spend -> Rep Spend x)
-> (forall x. Rep Spend x -> Spend) -> Generic Spend
forall x. Rep Spend x -> Spend
forall x. Spend -> Rep Spend x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Spend x -> Spend
$cfrom :: forall x. Spend -> Rep Spend x
Prelude.Generic)
newSpend ::
Prelude.Text ->
Prelude.Text ->
Spend
newSpend :: Text -> Text -> Spend
newSpend Text
pAmount_ Text
pUnit_ =
Spend' :: Text -> Text -> Spend
Spend' {$sel:amount:Spend' :: Text
amount = Text
pAmount_, $sel:unit:Spend' :: Text
unit = Text
pUnit_}
spend_amount :: Lens.Lens' Spend Prelude.Text
spend_amount :: (Text -> f Text) -> Spend -> f Spend
spend_amount = (Spend -> Text)
-> (Spend -> Text -> Spend) -> Lens Spend Spend Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Spend' {Text
amount :: Text
$sel:amount:Spend' :: Spend -> Text
amount} -> Text
amount) (\s :: Spend
s@Spend' {} Text
a -> Spend
s {$sel:amount:Spend' :: Text
amount = Text
a} :: Spend)
spend_unit :: Lens.Lens' Spend Prelude.Text
spend_unit :: (Text -> f Text) -> Spend -> f Spend
spend_unit = (Spend -> Text)
-> (Spend -> Text -> Spend) -> Lens Spend Spend Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Spend' {Text
unit :: Text
$sel:unit:Spend' :: Spend -> Text
unit} -> Text
unit) (\s :: Spend
s@Spend' {} Text
a -> Spend
s {$sel:unit:Spend' :: Text
unit = Text
a} :: Spend)
instance Core.FromJSON Spend where
parseJSON :: Value -> Parser Spend
parseJSON =
String -> (Object -> Parser Spend) -> Value -> Parser Spend
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Spend"
( \Object
x ->
Text -> Text -> Spend
Spend'
(Text -> Text -> Spend) -> Parser Text -> Parser (Text -> Spend)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Amount") Parser (Text -> Spend) -> Parser Text -> Parser Spend
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Unit")
)
instance Prelude.Hashable Spend
instance Prelude.NFData Spend
instance Core.ToJSON Spend where
toJSON :: Spend -> Value
toJSON Spend' {Text
unit :: Text
amount :: Text
$sel:unit:Spend' :: Spend -> Text
$sel:amount:Spend' :: Spend -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Amount" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
amount),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Unit" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
unit)
]
)