{-# 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.Subscriber where
import Amazonka.Budgets.Types.SubscriptionType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Subscriber = Subscriber'
{
Subscriber -> SubscriptionType
subscriptionType :: SubscriptionType,
Subscriber -> Sensitive Text
address :: Core.Sensitive Prelude.Text
}
deriving (Subscriber -> Subscriber -> Bool
(Subscriber -> Subscriber -> Bool)
-> (Subscriber -> Subscriber -> Bool) -> Eq Subscriber
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Subscriber -> Subscriber -> Bool
$c/= :: Subscriber -> Subscriber -> Bool
== :: Subscriber -> Subscriber -> Bool
$c== :: Subscriber -> Subscriber -> Bool
Prelude.Eq, Int -> Subscriber -> ShowS
[Subscriber] -> ShowS
Subscriber -> String
(Int -> Subscriber -> ShowS)
-> (Subscriber -> String)
-> ([Subscriber] -> ShowS)
-> Show Subscriber
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Subscriber] -> ShowS
$cshowList :: [Subscriber] -> ShowS
show :: Subscriber -> String
$cshow :: Subscriber -> String
showsPrec :: Int -> Subscriber -> ShowS
$cshowsPrec :: Int -> Subscriber -> ShowS
Prelude.Show, (forall x. Subscriber -> Rep Subscriber x)
-> (forall x. Rep Subscriber x -> Subscriber) -> Generic Subscriber
forall x. Rep Subscriber x -> Subscriber
forall x. Subscriber -> Rep Subscriber x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Subscriber x -> Subscriber
$cfrom :: forall x. Subscriber -> Rep Subscriber x
Prelude.Generic)
newSubscriber ::
SubscriptionType ->
Prelude.Text ->
Subscriber
newSubscriber :: SubscriptionType -> Text -> Subscriber
newSubscriber SubscriptionType
pSubscriptionType_ Text
pAddress_ =
Subscriber' :: SubscriptionType -> Sensitive Text -> Subscriber
Subscriber'
{ $sel:subscriptionType:Subscriber' :: SubscriptionType
subscriptionType = SubscriptionType
pSubscriptionType_,
$sel:address:Subscriber' :: Sensitive Text
address = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pAddress_
}
subscriber_subscriptionType :: Lens.Lens' Subscriber SubscriptionType
subscriber_subscriptionType :: (SubscriptionType -> f SubscriptionType)
-> Subscriber -> f Subscriber
subscriber_subscriptionType = (Subscriber -> SubscriptionType)
-> (Subscriber -> SubscriptionType -> Subscriber)
-> Lens Subscriber Subscriber SubscriptionType SubscriptionType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscriber' {SubscriptionType
subscriptionType :: SubscriptionType
$sel:subscriptionType:Subscriber' :: Subscriber -> SubscriptionType
subscriptionType} -> SubscriptionType
subscriptionType) (\s :: Subscriber
s@Subscriber' {} SubscriptionType
a -> Subscriber
s {$sel:subscriptionType:Subscriber' :: SubscriptionType
subscriptionType = SubscriptionType
a} :: Subscriber)
subscriber_address :: Lens.Lens' Subscriber Prelude.Text
subscriber_address :: (Text -> f Text) -> Subscriber -> f Subscriber
subscriber_address = (Subscriber -> Sensitive Text)
-> (Subscriber -> Sensitive Text -> Subscriber)
-> Lens Subscriber Subscriber (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscriber' {Sensitive Text
address :: Sensitive Text
$sel:address:Subscriber' :: Subscriber -> Sensitive Text
address} -> Sensitive Text
address) (\s :: Subscriber
s@Subscriber' {} Sensitive Text
a -> Subscriber
s {$sel:address:Subscriber' :: Sensitive Text
address = Sensitive Text
a} :: Subscriber) ((Sensitive Text -> f (Sensitive Text))
-> Subscriber -> f Subscriber)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> Subscriber
-> f Subscriber
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
instance Core.FromJSON Subscriber where
parseJSON :: Value -> Parser Subscriber
parseJSON =
String
-> (Object -> Parser Subscriber) -> Value -> Parser Subscriber
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Subscriber"
( \Object
x ->
SubscriptionType -> Sensitive Text -> Subscriber
Subscriber'
(SubscriptionType -> Sensitive Text -> Subscriber)
-> Parser SubscriptionType -> Parser (Sensitive Text -> Subscriber)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser SubscriptionType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SubscriptionType")
Parser (Sensitive Text -> Subscriber)
-> Parser (Sensitive Text) -> Parser Subscriber
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Address")
)
instance Prelude.Hashable Subscriber
instance Prelude.NFData Subscriber
instance Core.ToJSON Subscriber where
toJSON :: Subscriber -> Value
toJSON Subscriber' {Sensitive Text
SubscriptionType
address :: Sensitive Text
subscriptionType :: SubscriptionType
$sel:address:Subscriber' :: Subscriber -> Sensitive Text
$sel:subscriptionType:Subscriber' :: Subscriber -> SubscriptionType
..} =
[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
"SubscriptionType" Text -> SubscriptionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SubscriptionType
subscriptionType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Address" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
address)
]
)