{-# 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.FraudDetector.Types.Entity where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Entity = Entity'
{
Entity -> Text
entityType :: Prelude.Text,
Entity -> Text
entityId :: Prelude.Text
}
deriving (Entity -> Entity -> Bool
(Entity -> Entity -> Bool)
-> (Entity -> Entity -> Bool) -> Eq Entity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Entity -> Entity -> Bool
$c/= :: Entity -> Entity -> Bool
== :: Entity -> Entity -> Bool
$c== :: Entity -> Entity -> Bool
Prelude.Eq, Int -> Entity -> ShowS
[Entity] -> ShowS
Entity -> String
(Int -> Entity -> ShowS)
-> (Entity -> String) -> ([Entity] -> ShowS) -> Show Entity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Entity] -> ShowS
$cshowList :: [Entity] -> ShowS
show :: Entity -> String
$cshow :: Entity -> String
showsPrec :: Int -> Entity -> ShowS
$cshowsPrec :: Int -> Entity -> ShowS
Prelude.Show, (forall x. Entity -> Rep Entity x)
-> (forall x. Rep Entity x -> Entity) -> Generic Entity
forall x. Rep Entity x -> Entity
forall x. Entity -> Rep Entity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Entity x -> Entity
$cfrom :: forall x. Entity -> Rep Entity x
Prelude.Generic)
newEntity ::
Prelude.Text ->
Prelude.Text ->
Entity
newEntity :: Text -> Text -> Entity
newEntity Text
pEntityType_ Text
pEntityId_ =
Entity' :: Text -> Text -> Entity
Entity'
{ $sel:entityType:Entity' :: Text
entityType = Text
pEntityType_,
$sel:entityId:Entity' :: Text
entityId = Text
pEntityId_
}
entity_entityType :: Lens.Lens' Entity Prelude.Text
entity_entityType :: (Text -> f Text) -> Entity -> f Entity
entity_entityType = (Entity -> Text)
-> (Entity -> Text -> Entity) -> Lens Entity Entity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entity' {Text
entityType :: Text
$sel:entityType:Entity' :: Entity -> Text
entityType} -> Text
entityType) (\s :: Entity
s@Entity' {} Text
a -> Entity
s {$sel:entityType:Entity' :: Text
entityType = Text
a} :: Entity)
entity_entityId :: Lens.Lens' Entity Prelude.Text
entity_entityId :: (Text -> f Text) -> Entity -> f Entity
entity_entityId = (Entity -> Text)
-> (Entity -> Text -> Entity) -> Lens Entity Entity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Entity' {Text
entityId :: Text
$sel:entityId:Entity' :: Entity -> Text
entityId} -> Text
entityId) (\s :: Entity
s@Entity' {} Text
a -> Entity
s {$sel:entityId:Entity' :: Text
entityId = Text
a} :: Entity)
instance Core.FromJSON Entity where
parseJSON :: Value -> Parser Entity
parseJSON =
String -> (Object -> Parser Entity) -> Value -> Parser Entity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Entity"
( \Object
x ->
Text -> Text -> Entity
Entity'
(Text -> Text -> Entity) -> Parser Text -> Parser (Text -> Entity)
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
"entityType")
Parser (Text -> Entity) -> Parser Text -> Parser Entity
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
"entityId")
)
instance Prelude.Hashable Entity
instance Prelude.NFData Entity
instance Core.ToJSON Entity where
toJSON :: Entity -> Value
toJSON Entity' {Text
entityId :: Text
entityType :: Text
$sel:entityId:Entity' :: Entity -> Text
$sel:entityType:Entity' :: Entity -> 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
"entityType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
entityType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"entityId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
entityId)
]
)