{-# 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.ConnectContactLens.Types.Categories
-- 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.ConnectContactLens.Types.Categories where

import Amazonka.ConnectContactLens.Types.CategoryDetails
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides the category rules that are used to automatically categorize
-- contacts based on uttered keywords and phrases.
--
-- /See:/ 'newCategories' smart constructor.
data Categories = Categories'
  { -- | The category rules that have been matched in the analyzed segment.
    Categories -> [Text]
matchedCategories :: [Prelude.Text],
    -- | The category rule that was matched and when it occurred in the
    -- transcript.
    Categories -> HashMap Text CategoryDetails
matchedDetails :: Prelude.HashMap Prelude.Text CategoryDetails
  }
  deriving (Categories -> Categories -> Bool
(Categories -> Categories -> Bool)
-> (Categories -> Categories -> Bool) -> Eq Categories
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Categories -> Categories -> Bool
$c/= :: Categories -> Categories -> Bool
== :: Categories -> Categories -> Bool
$c== :: Categories -> Categories -> Bool
Prelude.Eq, ReadPrec [Categories]
ReadPrec Categories
Int -> ReadS Categories
ReadS [Categories]
(Int -> ReadS Categories)
-> ReadS [Categories]
-> ReadPrec Categories
-> ReadPrec [Categories]
-> Read Categories
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Categories]
$creadListPrec :: ReadPrec [Categories]
readPrec :: ReadPrec Categories
$creadPrec :: ReadPrec Categories
readList :: ReadS [Categories]
$creadList :: ReadS [Categories]
readsPrec :: Int -> ReadS Categories
$creadsPrec :: Int -> ReadS Categories
Prelude.Read, Int -> Categories -> ShowS
[Categories] -> ShowS
Categories -> String
(Int -> Categories -> ShowS)
-> (Categories -> String)
-> ([Categories] -> ShowS)
-> Show Categories
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Categories] -> ShowS
$cshowList :: [Categories] -> ShowS
show :: Categories -> String
$cshow :: Categories -> String
showsPrec :: Int -> Categories -> ShowS
$cshowsPrec :: Int -> Categories -> ShowS
Prelude.Show, (forall x. Categories -> Rep Categories x)
-> (forall x. Rep Categories x -> Categories) -> Generic Categories
forall x. Rep Categories x -> Categories
forall x. Categories -> Rep Categories x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Categories x -> Categories
$cfrom :: forall x. Categories -> Rep Categories x
Prelude.Generic)

-- |
-- Create a value of 'Categories' 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:
--
-- 'matchedCategories', 'categories_matchedCategories' - The category rules that have been matched in the analyzed segment.
--
-- 'matchedDetails', 'categories_matchedDetails' - The category rule that was matched and when it occurred in the
-- transcript.
newCategories ::
  Categories
newCategories :: Categories
newCategories =
  Categories' :: [Text] -> HashMap Text CategoryDetails -> Categories
Categories'
    { $sel:matchedCategories:Categories' :: [Text]
matchedCategories = [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:matchedDetails:Categories' :: HashMap Text CategoryDetails
matchedDetails = HashMap Text CategoryDetails
forall a. Monoid a => a
Prelude.mempty
    }

-- | The category rules that have been matched in the analyzed segment.
categories_matchedCategories :: Lens.Lens' Categories [Prelude.Text]
categories_matchedCategories :: ([Text] -> f [Text]) -> Categories -> f Categories
categories_matchedCategories = (Categories -> [Text])
-> (Categories -> [Text] -> Categories)
-> Lens Categories Categories [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Categories' {[Text]
matchedCategories :: [Text]
$sel:matchedCategories:Categories' :: Categories -> [Text]
matchedCategories} -> [Text]
matchedCategories) (\s :: Categories
s@Categories' {} [Text]
a -> Categories
s {$sel:matchedCategories:Categories' :: [Text]
matchedCategories = [Text]
a} :: Categories) (([Text] -> f [Text]) -> Categories -> f Categories)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> Categories
-> f Categories
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The category rule that was matched and when it occurred in the
-- transcript.
categories_matchedDetails :: Lens.Lens' Categories (Prelude.HashMap Prelude.Text CategoryDetails)
categories_matchedDetails :: (HashMap Text CategoryDetails -> f (HashMap Text CategoryDetails))
-> Categories -> f Categories
categories_matchedDetails = (Categories -> HashMap Text CategoryDetails)
-> (Categories -> HashMap Text CategoryDetails -> Categories)
-> Lens
     Categories
     Categories
     (HashMap Text CategoryDetails)
     (HashMap Text CategoryDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Categories' {HashMap Text CategoryDetails
matchedDetails :: HashMap Text CategoryDetails
$sel:matchedDetails:Categories' :: Categories -> HashMap Text CategoryDetails
matchedDetails} -> HashMap Text CategoryDetails
matchedDetails) (\s :: Categories
s@Categories' {} HashMap Text CategoryDetails
a -> Categories
s {$sel:matchedDetails:Categories' :: HashMap Text CategoryDetails
matchedDetails = HashMap Text CategoryDetails
a} :: Categories) ((HashMap Text CategoryDetails -> f (HashMap Text CategoryDetails))
 -> Categories -> f Categories)
-> ((HashMap Text CategoryDetails
     -> f (HashMap Text CategoryDetails))
    -> HashMap Text CategoryDetails
    -> f (HashMap Text CategoryDetails))
-> (HashMap Text CategoryDetails
    -> f (HashMap Text CategoryDetails))
-> Categories
-> f Categories
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text CategoryDetails -> f (HashMap Text CategoryDetails))
-> HashMap Text CategoryDetails -> f (HashMap Text CategoryDetails)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Categories where
  parseJSON :: Value -> Parser Categories
parseJSON =
    String
-> (Object -> Parser Categories) -> Value -> Parser Categories
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Categories"
      ( \Object
x ->
          [Text] -> HashMap Text CategoryDetails -> Categories
Categories'
            ([Text] -> HashMap Text CategoryDetails -> Categories)
-> Parser [Text]
-> Parser (HashMap Text CategoryDetails -> Categories)
forall (f :: * -> *) a b. Functor 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
"MatchedCategories"
                            Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (HashMap Text CategoryDetails -> Categories)
-> Parser (HashMap Text CategoryDetails) -> Parser Categories
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (HashMap Text CategoryDetails))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MatchedDetails"
                            Parser (Maybe (HashMap Text CategoryDetails))
-> HashMap Text CategoryDetails
-> Parser (HashMap Text CategoryDetails)
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= HashMap Text CategoryDetails
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable Categories

instance Prelude.NFData Categories