{-# 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.MatchItem
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CustomerProfiles.Types.MatchItem where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The Match group object.
--
-- /See:/ 'newMatchItem' smart constructor.
data MatchItem = MatchItem'
  { -- | A list of identifiers for profiles that match.
    MatchItem -> Maybe [Text]
profileIds :: Prelude.Maybe [Prelude.Text],
    -- | The unique identifiers for this group of profiles that match.
    MatchItem -> Maybe Text
matchId :: Prelude.Maybe Prelude.Text
  }
  deriving (MatchItem -> MatchItem -> Bool
(MatchItem -> MatchItem -> Bool)
-> (MatchItem -> MatchItem -> Bool) -> Eq MatchItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MatchItem -> MatchItem -> Bool
$c/= :: MatchItem -> MatchItem -> Bool
== :: MatchItem -> MatchItem -> Bool
$c== :: MatchItem -> MatchItem -> Bool
Prelude.Eq, ReadPrec [MatchItem]
ReadPrec MatchItem
Int -> ReadS MatchItem
ReadS [MatchItem]
(Int -> ReadS MatchItem)
-> ReadS [MatchItem]
-> ReadPrec MatchItem
-> ReadPrec [MatchItem]
-> Read MatchItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MatchItem]
$creadListPrec :: ReadPrec [MatchItem]
readPrec :: ReadPrec MatchItem
$creadPrec :: ReadPrec MatchItem
readList :: ReadS [MatchItem]
$creadList :: ReadS [MatchItem]
readsPrec :: Int -> ReadS MatchItem
$creadsPrec :: Int -> ReadS MatchItem
Prelude.Read, Int -> MatchItem -> ShowS
[MatchItem] -> ShowS
MatchItem -> String
(Int -> MatchItem -> ShowS)
-> (MatchItem -> String)
-> ([MatchItem] -> ShowS)
-> Show MatchItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MatchItem] -> ShowS
$cshowList :: [MatchItem] -> ShowS
show :: MatchItem -> String
$cshow :: MatchItem -> String
showsPrec :: Int -> MatchItem -> ShowS
$cshowsPrec :: Int -> MatchItem -> ShowS
Prelude.Show, (forall x. MatchItem -> Rep MatchItem x)
-> (forall x. Rep MatchItem x -> MatchItem) -> Generic MatchItem
forall x. Rep MatchItem x -> MatchItem
forall x. MatchItem -> Rep MatchItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MatchItem x -> MatchItem
$cfrom :: forall x. MatchItem -> Rep MatchItem x
Prelude.Generic)

-- |
-- Create a value of 'MatchItem' 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:
--
-- 'profileIds', 'matchItem_profileIds' - A list of identifiers for profiles that match.
--
-- 'matchId', 'matchItem_matchId' - The unique identifiers for this group of profiles that match.
newMatchItem ::
  MatchItem
newMatchItem :: MatchItem
newMatchItem =
  MatchItem' :: Maybe [Text] -> Maybe Text -> MatchItem
MatchItem'
    { $sel:profileIds:MatchItem' :: Maybe [Text]
profileIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:matchId:MatchItem' :: Maybe Text
matchId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of identifiers for profiles that match.
matchItem_profileIds :: Lens.Lens' MatchItem (Prelude.Maybe [Prelude.Text])
matchItem_profileIds :: (Maybe [Text] -> f (Maybe [Text])) -> MatchItem -> f MatchItem
matchItem_profileIds = (MatchItem -> Maybe [Text])
-> (MatchItem -> Maybe [Text] -> MatchItem)
-> Lens MatchItem MatchItem (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchItem' {Maybe [Text]
profileIds :: Maybe [Text]
$sel:profileIds:MatchItem' :: MatchItem -> Maybe [Text]
profileIds} -> Maybe [Text]
profileIds) (\s :: MatchItem
s@MatchItem' {} Maybe [Text]
a -> MatchItem
s {$sel:profileIds:MatchItem' :: Maybe [Text]
profileIds = Maybe [Text]
a} :: MatchItem) ((Maybe [Text] -> f (Maybe [Text])) -> MatchItem -> f MatchItem)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> MatchItem
-> f MatchItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique identifiers for this group of profiles that match.
matchItem_matchId :: Lens.Lens' MatchItem (Prelude.Maybe Prelude.Text)
matchItem_matchId :: (Maybe Text -> f (Maybe Text)) -> MatchItem -> f MatchItem
matchItem_matchId = (MatchItem -> Maybe Text)
-> (MatchItem -> Maybe Text -> MatchItem)
-> Lens MatchItem MatchItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchItem' {Maybe Text
matchId :: Maybe Text
$sel:matchId:MatchItem' :: MatchItem -> Maybe Text
matchId} -> Maybe Text
matchId) (\s :: MatchItem
s@MatchItem' {} Maybe Text
a -> MatchItem
s {$sel:matchId:MatchItem' :: Maybe Text
matchId = Maybe Text
a} :: MatchItem)

instance Core.FromJSON MatchItem where
  parseJSON :: Value -> Parser MatchItem
parseJSON =
    String -> (Object -> Parser MatchItem) -> Value -> Parser MatchItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MatchItem"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> MatchItem
MatchItem'
            (Maybe [Text] -> Maybe Text -> MatchItem)
-> Parser (Maybe [Text]) -> Parser (Maybe Text -> MatchItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProfileIds" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> MatchItem)
-> Parser (Maybe Text) -> Parser MatchItem
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MatchId")
      )

instance Prelude.Hashable MatchItem

instance Prelude.NFData MatchItem