{-# 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.Pinpoint.Types.RecencyDimension where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.Duration
import Amazonka.Pinpoint.Types.RecencyType
import qualified Amazonka.Prelude as Prelude
data RecencyDimension = RecencyDimension'
{
RecencyDimension -> Duration
duration :: Duration,
RecencyDimension -> RecencyType
recencyType :: RecencyType
}
deriving (RecencyDimension -> RecencyDimension -> Bool
(RecencyDimension -> RecencyDimension -> Bool)
-> (RecencyDimension -> RecencyDimension -> Bool)
-> Eq RecencyDimension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecencyDimension -> RecencyDimension -> Bool
$c/= :: RecencyDimension -> RecencyDimension -> Bool
== :: RecencyDimension -> RecencyDimension -> Bool
$c== :: RecencyDimension -> RecencyDimension -> Bool
Prelude.Eq, ReadPrec [RecencyDimension]
ReadPrec RecencyDimension
Int -> ReadS RecencyDimension
ReadS [RecencyDimension]
(Int -> ReadS RecencyDimension)
-> ReadS [RecencyDimension]
-> ReadPrec RecencyDimension
-> ReadPrec [RecencyDimension]
-> Read RecencyDimension
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecencyDimension]
$creadListPrec :: ReadPrec [RecencyDimension]
readPrec :: ReadPrec RecencyDimension
$creadPrec :: ReadPrec RecencyDimension
readList :: ReadS [RecencyDimension]
$creadList :: ReadS [RecencyDimension]
readsPrec :: Int -> ReadS RecencyDimension
$creadsPrec :: Int -> ReadS RecencyDimension
Prelude.Read, Int -> RecencyDimension -> ShowS
[RecencyDimension] -> ShowS
RecencyDimension -> String
(Int -> RecencyDimension -> ShowS)
-> (RecencyDimension -> String)
-> ([RecencyDimension] -> ShowS)
-> Show RecencyDimension
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecencyDimension] -> ShowS
$cshowList :: [RecencyDimension] -> ShowS
show :: RecencyDimension -> String
$cshow :: RecencyDimension -> String
showsPrec :: Int -> RecencyDimension -> ShowS
$cshowsPrec :: Int -> RecencyDimension -> ShowS
Prelude.Show, (forall x. RecencyDimension -> Rep RecencyDimension x)
-> (forall x. Rep RecencyDimension x -> RecencyDimension)
-> Generic RecencyDimension
forall x. Rep RecencyDimension x -> RecencyDimension
forall x. RecencyDimension -> Rep RecencyDimension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecencyDimension x -> RecencyDimension
$cfrom :: forall x. RecencyDimension -> Rep RecencyDimension x
Prelude.Generic)
newRecencyDimension ::
Duration ->
RecencyType ->
RecencyDimension
newRecencyDimension :: Duration -> RecencyType -> RecencyDimension
newRecencyDimension Duration
pDuration_ RecencyType
pRecencyType_ =
RecencyDimension' :: Duration -> RecencyType -> RecencyDimension
RecencyDimension'
{ $sel:duration:RecencyDimension' :: Duration
duration = Duration
pDuration_,
$sel:recencyType:RecencyDimension' :: RecencyType
recencyType = RecencyType
pRecencyType_
}
recencyDimension_duration :: Lens.Lens' RecencyDimension Duration
recencyDimension_duration :: (Duration -> f Duration) -> RecencyDimension -> f RecencyDimension
recencyDimension_duration = (RecencyDimension -> Duration)
-> (RecencyDimension -> Duration -> RecencyDimension)
-> Lens RecencyDimension RecencyDimension Duration Duration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecencyDimension' {Duration
duration :: Duration
$sel:duration:RecencyDimension' :: RecencyDimension -> Duration
duration} -> Duration
duration) (\s :: RecencyDimension
s@RecencyDimension' {} Duration
a -> RecencyDimension
s {$sel:duration:RecencyDimension' :: Duration
duration = Duration
a} :: RecencyDimension)
recencyDimension_recencyType :: Lens.Lens' RecencyDimension RecencyType
recencyDimension_recencyType :: (RecencyType -> f RecencyType)
-> RecencyDimension -> f RecencyDimension
recencyDimension_recencyType = (RecencyDimension -> RecencyType)
-> (RecencyDimension -> RecencyType -> RecencyDimension)
-> Lens RecencyDimension RecencyDimension RecencyType RecencyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecencyDimension' {RecencyType
recencyType :: RecencyType
$sel:recencyType:RecencyDimension' :: RecencyDimension -> RecencyType
recencyType} -> RecencyType
recencyType) (\s :: RecencyDimension
s@RecencyDimension' {} RecencyType
a -> RecencyDimension
s {$sel:recencyType:RecencyDimension' :: RecencyType
recencyType = RecencyType
a} :: RecencyDimension)
instance Core.FromJSON RecencyDimension where
parseJSON :: Value -> Parser RecencyDimension
parseJSON =
String
-> (Object -> Parser RecencyDimension)
-> Value
-> Parser RecencyDimension
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RecencyDimension"
( \Object
x ->
Duration -> RecencyType -> RecencyDimension
RecencyDimension'
(Duration -> RecencyType -> RecencyDimension)
-> Parser Duration -> Parser (RecencyType -> RecencyDimension)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Duration
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Duration")
Parser (RecencyType -> RecencyDimension)
-> Parser RecencyType -> Parser RecencyDimension
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser RecencyType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RecencyType")
)
instance Prelude.Hashable RecencyDimension
instance Prelude.NFData RecencyDimension
instance Core.ToJSON RecencyDimension where
toJSON :: RecencyDimension -> Value
toJSON RecencyDimension' {Duration
RecencyType
recencyType :: RecencyType
duration :: Duration
$sel:recencyType:RecencyDimension' :: RecencyDimension -> RecencyType
$sel:duration:RecencyDimension' :: RecencyDimension -> Duration
..} =
[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
"Duration" Text -> Duration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Duration
duration),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RecencyType" Text -> RecencyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RecencyType
recencyType)
]
)