{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
data Entity = Entity'
{
Entity -> Text
entityType :: Prelude.Text,
Entity -> Text
entityId :: Prelude.Text
}
deriving (Entity -> Entity -> Bool
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
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. 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'
{ $sel:entityType:Entity' :: Text
entityType = Text
pEntityType_,
$sel:entityId:Entity' :: Text
entityId = Text
pEntityId_
}
entity_entityType :: Lens.Lens' Entity Prelude.Text
entity_entityType :: Lens' Entity Text
entity_entityType = 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 :: Lens' Entity Text
entity_entityId = 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 Data.FromJSON Entity where
parseJSON :: Value -> Parser Entity
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Entity"
( \Object
x ->
Text -> Text -> Entity
Entity'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"entityType")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"entityId")
)
instance Prelude.Hashable Entity where
hashWithSalt :: Int -> Entity -> Int
hashWithSalt Int
_salt Entity' {Text
entityId :: Text
entityType :: Text
$sel:entityId:Entity' :: Entity -> Text
$sel:entityType:Entity' :: Entity -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entityType
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entityId
instance Prelude.NFData Entity where
rnf :: Entity -> ()
rnf Entity' {Text
entityId :: Text
entityType :: Text
$sel:entityId:Entity' :: Entity -> Text
$sel:entityType:Entity' :: Entity -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
entityType
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
entityId
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"entityType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
entityType),
forall a. a -> Maybe a
Prelude.Just (Key
"entityId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
entityId)
]
)