{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CustomerProfiles.Types.AutoMerging
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CustomerProfiles.Types.AutoMerging where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.CustomerProfiles.Types.ConflictResolution
import Amazonka.CustomerProfiles.Types.Consolidation
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Configuration settings for how to perform the auto-merging of profiles.
--
-- /See:/ 'newAutoMerging' smart constructor.
data AutoMerging = AutoMerging'
  { -- | How the auto-merging process should resolve conflicts between different
    -- profiles. For example, if Profile A and Profile B have the same
    -- @FirstName@ and @LastName@ (and that is the matching criteria), which
    -- @EmailAddress@ should be used?
    AutoMerging -> Maybe ConflictResolution
conflictResolution :: Prelude.Maybe ConflictResolution,
    -- | A list of matching attributes that represent matching criteria. If two
    -- profiles meet at least one of the requirements in the matching
    -- attributes list, they will be merged.
    AutoMerging -> Maybe Consolidation
consolidation :: Prelude.Maybe Consolidation,
    -- | A number between 0 and 1 that represents the minimum confidence score
    -- required for profiles within a matching group to be merged during the
    -- auto-merge process. A higher score means higher similarity required to
    -- merge profiles.
    AutoMerging -> Maybe Double
minAllowedConfidenceScoreForMerging :: Prelude.Maybe Prelude.Double,
    -- | The flag that enables the auto-merging of duplicate profiles.
    AutoMerging -> Bool
enabled :: Prelude.Bool
  }
  deriving (AutoMerging -> AutoMerging -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoMerging -> AutoMerging -> Bool
$c/= :: AutoMerging -> AutoMerging -> Bool
== :: AutoMerging -> AutoMerging -> Bool
$c== :: AutoMerging -> AutoMerging -> Bool
Prelude.Eq, ReadPrec [AutoMerging]
ReadPrec AutoMerging
Int -> ReadS AutoMerging
ReadS [AutoMerging]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoMerging]
$creadListPrec :: ReadPrec [AutoMerging]
readPrec :: ReadPrec AutoMerging
$creadPrec :: ReadPrec AutoMerging
readList :: ReadS [AutoMerging]
$creadList :: ReadS [AutoMerging]
readsPrec :: Int -> ReadS AutoMerging
$creadsPrec :: Int -> ReadS AutoMerging
Prelude.Read, Int -> AutoMerging -> ShowS
[AutoMerging] -> ShowS
AutoMerging -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoMerging] -> ShowS
$cshowList :: [AutoMerging] -> ShowS
show :: AutoMerging -> String
$cshow :: AutoMerging -> String
showsPrec :: Int -> AutoMerging -> ShowS
$cshowsPrec :: Int -> AutoMerging -> ShowS
Prelude.Show, forall x. Rep AutoMerging x -> AutoMerging
forall x. AutoMerging -> Rep AutoMerging x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoMerging x -> AutoMerging
$cfrom :: forall x. AutoMerging -> Rep AutoMerging x
Prelude.Generic)

-- |
-- Create a value of 'AutoMerging' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'conflictResolution', 'autoMerging_conflictResolution' - How the auto-merging process should resolve conflicts between different
-- profiles. For example, if Profile A and Profile B have the same
-- @FirstName@ and @LastName@ (and that is the matching criteria), which
-- @EmailAddress@ should be used?
--
-- 'consolidation', 'autoMerging_consolidation' - A list of matching attributes that represent matching criteria. If two
-- profiles meet at least one of the requirements in the matching
-- attributes list, they will be merged.
--
-- 'minAllowedConfidenceScoreForMerging', 'autoMerging_minAllowedConfidenceScoreForMerging' - A number between 0 and 1 that represents the minimum confidence score
-- required for profiles within a matching group to be merged during the
-- auto-merge process. A higher score means higher similarity required to
-- merge profiles.
--
-- 'enabled', 'autoMerging_enabled' - The flag that enables the auto-merging of duplicate profiles.
newAutoMerging ::
  -- | 'enabled'
  Prelude.Bool ->
  AutoMerging
newAutoMerging :: Bool -> AutoMerging
newAutoMerging Bool
pEnabled_ =
  AutoMerging'
    { $sel:conflictResolution:AutoMerging' :: Maybe ConflictResolution
conflictResolution = forall a. Maybe a
Prelude.Nothing,
      $sel:consolidation:AutoMerging' :: Maybe Consolidation
consolidation = forall a. Maybe a
Prelude.Nothing,
      $sel:minAllowedConfidenceScoreForMerging:AutoMerging' :: Maybe Double
minAllowedConfidenceScoreForMerging =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:AutoMerging' :: Bool
enabled = Bool
pEnabled_
    }

-- | How the auto-merging process should resolve conflicts between different
-- profiles. For example, if Profile A and Profile B have the same
-- @FirstName@ and @LastName@ (and that is the matching criteria), which
-- @EmailAddress@ should be used?
autoMerging_conflictResolution :: Lens.Lens' AutoMerging (Prelude.Maybe ConflictResolution)
autoMerging_conflictResolution :: Lens' AutoMerging (Maybe ConflictResolution)
autoMerging_conflictResolution = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoMerging' {Maybe ConflictResolution
conflictResolution :: Maybe ConflictResolution
$sel:conflictResolution:AutoMerging' :: AutoMerging -> Maybe ConflictResolution
conflictResolution} -> Maybe ConflictResolution
conflictResolution) (\s :: AutoMerging
s@AutoMerging' {} Maybe ConflictResolution
a -> AutoMerging
s {$sel:conflictResolution:AutoMerging' :: Maybe ConflictResolution
conflictResolution = Maybe ConflictResolution
a} :: AutoMerging)

-- | A list of matching attributes that represent matching criteria. If two
-- profiles meet at least one of the requirements in the matching
-- attributes list, they will be merged.
autoMerging_consolidation :: Lens.Lens' AutoMerging (Prelude.Maybe Consolidation)
autoMerging_consolidation :: Lens' AutoMerging (Maybe Consolidation)
autoMerging_consolidation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoMerging' {Maybe Consolidation
consolidation :: Maybe Consolidation
$sel:consolidation:AutoMerging' :: AutoMerging -> Maybe Consolidation
consolidation} -> Maybe Consolidation
consolidation) (\s :: AutoMerging
s@AutoMerging' {} Maybe Consolidation
a -> AutoMerging
s {$sel:consolidation:AutoMerging' :: Maybe Consolidation
consolidation = Maybe Consolidation
a} :: AutoMerging)

-- | A number between 0 and 1 that represents the minimum confidence score
-- required for profiles within a matching group to be merged during the
-- auto-merge process. A higher score means higher similarity required to
-- merge profiles.
autoMerging_minAllowedConfidenceScoreForMerging :: Lens.Lens' AutoMerging (Prelude.Maybe Prelude.Double)
autoMerging_minAllowedConfidenceScoreForMerging :: Lens' AutoMerging (Maybe Double)
autoMerging_minAllowedConfidenceScoreForMerging = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoMerging' {Maybe Double
minAllowedConfidenceScoreForMerging :: Maybe Double
$sel:minAllowedConfidenceScoreForMerging:AutoMerging' :: AutoMerging -> Maybe Double
minAllowedConfidenceScoreForMerging} -> Maybe Double
minAllowedConfidenceScoreForMerging) (\s :: AutoMerging
s@AutoMerging' {} Maybe Double
a -> AutoMerging
s {$sel:minAllowedConfidenceScoreForMerging:AutoMerging' :: Maybe Double
minAllowedConfidenceScoreForMerging = Maybe Double
a} :: AutoMerging)

-- | The flag that enables the auto-merging of duplicate profiles.
autoMerging_enabled :: Lens.Lens' AutoMerging Prelude.Bool
autoMerging_enabled :: Lens' AutoMerging Bool
autoMerging_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoMerging' {Bool
enabled :: Bool
$sel:enabled:AutoMerging' :: AutoMerging -> Bool
enabled} -> Bool
enabled) (\s :: AutoMerging
s@AutoMerging' {} Bool
a -> AutoMerging
s {$sel:enabled:AutoMerging' :: Bool
enabled = Bool
a} :: AutoMerging)

instance Data.FromJSON AutoMerging where
  parseJSON :: Value -> Parser AutoMerging
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AutoMerging"
      ( \Object
x ->
          Maybe ConflictResolution
-> Maybe Consolidation -> Maybe Double -> Bool -> AutoMerging
AutoMerging'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ConflictResolution")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Consolidation")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MinAllowedConfidenceScoreForMerging")
            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
"Enabled")
      )

instance Prelude.Hashable AutoMerging where
  hashWithSalt :: Int -> AutoMerging -> Int
hashWithSalt Int
_salt AutoMerging' {Bool
Maybe Double
Maybe ConflictResolution
Maybe Consolidation
enabled :: Bool
minAllowedConfidenceScoreForMerging :: Maybe Double
consolidation :: Maybe Consolidation
conflictResolution :: Maybe ConflictResolution
$sel:enabled:AutoMerging' :: AutoMerging -> Bool
$sel:minAllowedConfidenceScoreForMerging:AutoMerging' :: AutoMerging -> Maybe Double
$sel:consolidation:AutoMerging' :: AutoMerging -> Maybe Consolidation
$sel:conflictResolution:AutoMerging' :: AutoMerging -> Maybe ConflictResolution
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConflictResolution
conflictResolution
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Consolidation
consolidation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
minAllowedConfidenceScoreForMerging
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enabled

instance Prelude.NFData AutoMerging where
  rnf :: AutoMerging -> ()
rnf AutoMerging' {Bool
Maybe Double
Maybe ConflictResolution
Maybe Consolidation
enabled :: Bool
minAllowedConfidenceScoreForMerging :: Maybe Double
consolidation :: Maybe Consolidation
conflictResolution :: Maybe ConflictResolution
$sel:enabled:AutoMerging' :: AutoMerging -> Bool
$sel:minAllowedConfidenceScoreForMerging:AutoMerging' :: AutoMerging -> Maybe Double
$sel:consolidation:AutoMerging' :: AutoMerging -> Maybe Consolidation
$sel:conflictResolution:AutoMerging' :: AutoMerging -> Maybe ConflictResolution
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ConflictResolution
conflictResolution
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Consolidation
consolidation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
minAllowedConfidenceScoreForMerging
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
enabled

instance Data.ToJSON AutoMerging where
  toJSON :: AutoMerging -> Value
toJSON AutoMerging' {Bool
Maybe Double
Maybe ConflictResolution
Maybe Consolidation
enabled :: Bool
minAllowedConfidenceScoreForMerging :: Maybe Double
consolidation :: Maybe Consolidation
conflictResolution :: Maybe ConflictResolution
$sel:enabled:AutoMerging' :: AutoMerging -> Bool
$sel:minAllowedConfidenceScoreForMerging:AutoMerging' :: AutoMerging -> Maybe Double
$sel:consolidation:AutoMerging' :: AutoMerging -> Maybe Consolidation
$sel:conflictResolution:AutoMerging' :: AutoMerging -> Maybe ConflictResolution
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ConflictResolution" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ConflictResolution
conflictResolution,
            (Key
"Consolidation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Consolidation
consolidation,
            (Key
"MinAllowedConfidenceScoreForMerging" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
minAllowedConfidenceScoreForMerging,
            forall a. a -> Maybe a
Prelude.Just (Key
"Enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
enabled)
          ]
      )