{-# 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.Transcribe.Types.SentimentFilter
-- 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.Transcribe.Types.SentimentFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Transcribe.Types.AbsoluteTimeRange
import Amazonka.Transcribe.Types.ParticipantRole
import Amazonka.Transcribe.Types.RelativeTimeRange
import Amazonka.Transcribe.Types.SentimentValue

-- | An object that enables you to specify a particular customer or agent
-- sentiment. If at least 50 percent of the conversation turns (the
-- back-and-forth between two speakers) in a specified time period match
-- the specified sentiment, Amazon Transcribe will consider the sentiment a
-- match.
--
-- /See:/ 'newSentimentFilter' smart constructor.
data SentimentFilter = SentimentFilter'
  { -- | A value that determines whether the sentiment belongs to the customer or
    -- the agent.
    SentimentFilter -> Maybe ParticipantRole
participantRole :: Prelude.Maybe ParticipantRole,
    -- | The time range, set in percentages, that correspond to proportion of the
    -- call.
    SentimentFilter -> Maybe RelativeTimeRange
relativeTimeRange :: Prelude.Maybe RelativeTimeRange,
    -- | Set to @TRUE@ to look for sentiments that weren\'t specified in the
    -- request.
    SentimentFilter -> Maybe Bool
negate :: Prelude.Maybe Prelude.Bool,
    -- | The time range, measured in seconds, of the sentiment.
    SentimentFilter -> Maybe AbsoluteTimeRange
absoluteTimeRange :: Prelude.Maybe AbsoluteTimeRange,
    -- | An array that enables you to specify sentiments for the customer or
    -- agent. You can specify one or more values.
    SentimentFilter -> NonEmpty SentimentValue
sentiments :: Prelude.NonEmpty SentimentValue
  }
  deriving (SentimentFilter -> SentimentFilter -> Bool
(SentimentFilter -> SentimentFilter -> Bool)
-> (SentimentFilter -> SentimentFilter -> Bool)
-> Eq SentimentFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SentimentFilter -> SentimentFilter -> Bool
$c/= :: SentimentFilter -> SentimentFilter -> Bool
== :: SentimentFilter -> SentimentFilter -> Bool
$c== :: SentimentFilter -> SentimentFilter -> Bool
Prelude.Eq, ReadPrec [SentimentFilter]
ReadPrec SentimentFilter
Int -> ReadS SentimentFilter
ReadS [SentimentFilter]
(Int -> ReadS SentimentFilter)
-> ReadS [SentimentFilter]
-> ReadPrec SentimentFilter
-> ReadPrec [SentimentFilter]
-> Read SentimentFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SentimentFilter]
$creadListPrec :: ReadPrec [SentimentFilter]
readPrec :: ReadPrec SentimentFilter
$creadPrec :: ReadPrec SentimentFilter
readList :: ReadS [SentimentFilter]
$creadList :: ReadS [SentimentFilter]
readsPrec :: Int -> ReadS SentimentFilter
$creadsPrec :: Int -> ReadS SentimentFilter
Prelude.Read, Int -> SentimentFilter -> ShowS
[SentimentFilter] -> ShowS
SentimentFilter -> String
(Int -> SentimentFilter -> ShowS)
-> (SentimentFilter -> String)
-> ([SentimentFilter] -> ShowS)
-> Show SentimentFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SentimentFilter] -> ShowS
$cshowList :: [SentimentFilter] -> ShowS
show :: SentimentFilter -> String
$cshow :: SentimentFilter -> String
showsPrec :: Int -> SentimentFilter -> ShowS
$cshowsPrec :: Int -> SentimentFilter -> ShowS
Prelude.Show, (forall x. SentimentFilter -> Rep SentimentFilter x)
-> (forall x. Rep SentimentFilter x -> SentimentFilter)
-> Generic SentimentFilter
forall x. Rep SentimentFilter x -> SentimentFilter
forall x. SentimentFilter -> Rep SentimentFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SentimentFilter x -> SentimentFilter
$cfrom :: forall x. SentimentFilter -> Rep SentimentFilter x
Prelude.Generic)

-- |
-- Create a value of 'SentimentFilter' 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:
--
-- 'participantRole', 'sentimentFilter_participantRole' - A value that determines whether the sentiment belongs to the customer or
-- the agent.
--
-- 'relativeTimeRange', 'sentimentFilter_relativeTimeRange' - The time range, set in percentages, that correspond to proportion of the
-- call.
--
-- 'negate', 'sentimentFilter_negate' - Set to @TRUE@ to look for sentiments that weren\'t specified in the
-- request.
--
-- 'absoluteTimeRange', 'sentimentFilter_absoluteTimeRange' - The time range, measured in seconds, of the sentiment.
--
-- 'sentiments', 'sentimentFilter_sentiments' - An array that enables you to specify sentiments for the customer or
-- agent. You can specify one or more values.
newSentimentFilter ::
  -- | 'sentiments'
  Prelude.NonEmpty SentimentValue ->
  SentimentFilter
newSentimentFilter :: NonEmpty SentimentValue -> SentimentFilter
newSentimentFilter NonEmpty SentimentValue
pSentiments_ =
  SentimentFilter' :: Maybe ParticipantRole
-> Maybe RelativeTimeRange
-> Maybe Bool
-> Maybe AbsoluteTimeRange
-> NonEmpty SentimentValue
-> SentimentFilter
SentimentFilter'
    { $sel:participantRole:SentimentFilter' :: Maybe ParticipantRole
participantRole = Maybe ParticipantRole
forall a. Maybe a
Prelude.Nothing,
      $sel:relativeTimeRange:SentimentFilter' :: Maybe RelativeTimeRange
relativeTimeRange = Maybe RelativeTimeRange
forall a. Maybe a
Prelude.Nothing,
      $sel:negate:SentimentFilter' :: Maybe Bool
negate = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:absoluteTimeRange:SentimentFilter' :: Maybe AbsoluteTimeRange
absoluteTimeRange = Maybe AbsoluteTimeRange
forall a. Maybe a
Prelude.Nothing,
      $sel:sentiments:SentimentFilter' :: NonEmpty SentimentValue
sentiments = Tagged
  (NonEmpty SentimentValue) (Identity (NonEmpty SentimentValue))
-> Tagged
     (NonEmpty SentimentValue) (Identity (NonEmpty SentimentValue))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty SentimentValue) (Identity (NonEmpty SentimentValue))
 -> Tagged
      (NonEmpty SentimentValue) (Identity (NonEmpty SentimentValue)))
-> NonEmpty SentimentValue -> NonEmpty SentimentValue
forall t b. AReview t b -> b -> t
Lens.# NonEmpty SentimentValue
pSentiments_
    }

-- | A value that determines whether the sentiment belongs to the customer or
-- the agent.
sentimentFilter_participantRole :: Lens.Lens' SentimentFilter (Prelude.Maybe ParticipantRole)
sentimentFilter_participantRole :: (Maybe ParticipantRole -> f (Maybe ParticipantRole))
-> SentimentFilter -> f SentimentFilter
sentimentFilter_participantRole = (SentimentFilter -> Maybe ParticipantRole)
-> (SentimentFilter -> Maybe ParticipantRole -> SentimentFilter)
-> Lens
     SentimentFilter
     SentimentFilter
     (Maybe ParticipantRole)
     (Maybe ParticipantRole)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentFilter' {Maybe ParticipantRole
participantRole :: Maybe ParticipantRole
$sel:participantRole:SentimentFilter' :: SentimentFilter -> Maybe ParticipantRole
participantRole} -> Maybe ParticipantRole
participantRole) (\s :: SentimentFilter
s@SentimentFilter' {} Maybe ParticipantRole
a -> SentimentFilter
s {$sel:participantRole:SentimentFilter' :: Maybe ParticipantRole
participantRole = Maybe ParticipantRole
a} :: SentimentFilter)

-- | The time range, set in percentages, that correspond to proportion of the
-- call.
sentimentFilter_relativeTimeRange :: Lens.Lens' SentimentFilter (Prelude.Maybe RelativeTimeRange)
sentimentFilter_relativeTimeRange :: (Maybe RelativeTimeRange -> f (Maybe RelativeTimeRange))
-> SentimentFilter -> f SentimentFilter
sentimentFilter_relativeTimeRange = (SentimentFilter -> Maybe RelativeTimeRange)
-> (SentimentFilter -> Maybe RelativeTimeRange -> SentimentFilter)
-> Lens
     SentimentFilter
     SentimentFilter
     (Maybe RelativeTimeRange)
     (Maybe RelativeTimeRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentFilter' {Maybe RelativeTimeRange
relativeTimeRange :: Maybe RelativeTimeRange
$sel:relativeTimeRange:SentimentFilter' :: SentimentFilter -> Maybe RelativeTimeRange
relativeTimeRange} -> Maybe RelativeTimeRange
relativeTimeRange) (\s :: SentimentFilter
s@SentimentFilter' {} Maybe RelativeTimeRange
a -> SentimentFilter
s {$sel:relativeTimeRange:SentimentFilter' :: Maybe RelativeTimeRange
relativeTimeRange = Maybe RelativeTimeRange
a} :: SentimentFilter)

-- | Set to @TRUE@ to look for sentiments that weren\'t specified in the
-- request.
sentimentFilter_negate :: Lens.Lens' SentimentFilter (Prelude.Maybe Prelude.Bool)
sentimentFilter_negate :: (Maybe Bool -> f (Maybe Bool))
-> SentimentFilter -> f SentimentFilter
sentimentFilter_negate = (SentimentFilter -> Maybe Bool)
-> (SentimentFilter -> Maybe Bool -> SentimentFilter)
-> Lens SentimentFilter SentimentFilter (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentFilter' {Maybe Bool
negate :: Maybe Bool
$sel:negate:SentimentFilter' :: SentimentFilter -> Maybe Bool
negate} -> Maybe Bool
negate) (\s :: SentimentFilter
s@SentimentFilter' {} Maybe Bool
a -> SentimentFilter
s {$sel:negate:SentimentFilter' :: Maybe Bool
negate = Maybe Bool
a} :: SentimentFilter)

-- | The time range, measured in seconds, of the sentiment.
sentimentFilter_absoluteTimeRange :: Lens.Lens' SentimentFilter (Prelude.Maybe AbsoluteTimeRange)
sentimentFilter_absoluteTimeRange :: (Maybe AbsoluteTimeRange -> f (Maybe AbsoluteTimeRange))
-> SentimentFilter -> f SentimentFilter
sentimentFilter_absoluteTimeRange = (SentimentFilter -> Maybe AbsoluteTimeRange)
-> (SentimentFilter -> Maybe AbsoluteTimeRange -> SentimentFilter)
-> Lens
     SentimentFilter
     SentimentFilter
     (Maybe AbsoluteTimeRange)
     (Maybe AbsoluteTimeRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentFilter' {Maybe AbsoluteTimeRange
absoluteTimeRange :: Maybe AbsoluteTimeRange
$sel:absoluteTimeRange:SentimentFilter' :: SentimentFilter -> Maybe AbsoluteTimeRange
absoluteTimeRange} -> Maybe AbsoluteTimeRange
absoluteTimeRange) (\s :: SentimentFilter
s@SentimentFilter' {} Maybe AbsoluteTimeRange
a -> SentimentFilter
s {$sel:absoluteTimeRange:SentimentFilter' :: Maybe AbsoluteTimeRange
absoluteTimeRange = Maybe AbsoluteTimeRange
a} :: SentimentFilter)

-- | An array that enables you to specify sentiments for the customer or
-- agent. You can specify one or more values.
sentimentFilter_sentiments :: Lens.Lens' SentimentFilter (Prelude.NonEmpty SentimentValue)
sentimentFilter_sentiments :: (NonEmpty SentimentValue -> f (NonEmpty SentimentValue))
-> SentimentFilter -> f SentimentFilter
sentimentFilter_sentiments = (SentimentFilter -> NonEmpty SentimentValue)
-> (SentimentFilter -> NonEmpty SentimentValue -> SentimentFilter)
-> Lens
     SentimentFilter
     SentimentFilter
     (NonEmpty SentimentValue)
     (NonEmpty SentimentValue)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SentimentFilter' {NonEmpty SentimentValue
sentiments :: NonEmpty SentimentValue
$sel:sentiments:SentimentFilter' :: SentimentFilter -> NonEmpty SentimentValue
sentiments} -> NonEmpty SentimentValue
sentiments) (\s :: SentimentFilter
s@SentimentFilter' {} NonEmpty SentimentValue
a -> SentimentFilter
s {$sel:sentiments:SentimentFilter' :: NonEmpty SentimentValue
sentiments = NonEmpty SentimentValue
a} :: SentimentFilter) ((NonEmpty SentimentValue -> f (NonEmpty SentimentValue))
 -> SentimentFilter -> f SentimentFilter)
-> ((NonEmpty SentimentValue -> f (NonEmpty SentimentValue))
    -> NonEmpty SentimentValue -> f (NonEmpty SentimentValue))
-> (NonEmpty SentimentValue -> f (NonEmpty SentimentValue))
-> SentimentFilter
-> f SentimentFilter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty SentimentValue -> f (NonEmpty SentimentValue))
-> NonEmpty SentimentValue -> f (NonEmpty SentimentValue)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SentimentFilter where
  parseJSON :: Value -> Parser SentimentFilter
parseJSON =
    String
-> (Object -> Parser SentimentFilter)
-> Value
-> Parser SentimentFilter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SentimentFilter"
      ( \Object
x ->
          Maybe ParticipantRole
-> Maybe RelativeTimeRange
-> Maybe Bool
-> Maybe AbsoluteTimeRange
-> NonEmpty SentimentValue
-> SentimentFilter
SentimentFilter'
            (Maybe ParticipantRole
 -> Maybe RelativeTimeRange
 -> Maybe Bool
 -> Maybe AbsoluteTimeRange
 -> NonEmpty SentimentValue
 -> SentimentFilter)
-> Parser (Maybe ParticipantRole)
-> Parser
     (Maybe RelativeTimeRange
      -> Maybe Bool
      -> Maybe AbsoluteTimeRange
      -> NonEmpty SentimentValue
      -> SentimentFilter)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ParticipantRole)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ParticipantRole")
            Parser
  (Maybe RelativeTimeRange
   -> Maybe Bool
   -> Maybe AbsoluteTimeRange
   -> NonEmpty SentimentValue
   -> SentimentFilter)
-> Parser (Maybe RelativeTimeRange)
-> Parser
     (Maybe Bool
      -> Maybe AbsoluteTimeRange
      -> NonEmpty SentimentValue
      -> SentimentFilter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RelativeTimeRange)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RelativeTimeRange")
            Parser
  (Maybe Bool
   -> Maybe AbsoluteTimeRange
   -> NonEmpty SentimentValue
   -> SentimentFilter)
-> Parser (Maybe Bool)
-> Parser
     (Maybe AbsoluteTimeRange
      -> NonEmpty SentimentValue -> SentimentFilter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Negate")
            Parser
  (Maybe AbsoluteTimeRange
   -> NonEmpty SentimentValue -> SentimentFilter)
-> Parser (Maybe AbsoluteTimeRange)
-> Parser (NonEmpty SentimentValue -> SentimentFilter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AbsoluteTimeRange)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AbsoluteTimeRange")
            Parser (NonEmpty SentimentValue -> SentimentFilter)
-> Parser (NonEmpty SentimentValue) -> Parser SentimentFilter
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty SentimentValue)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Sentiments")
      )

instance Prelude.Hashable SentimentFilter

instance Prelude.NFData SentimentFilter

instance Core.ToJSON SentimentFilter where
  toJSON :: SentimentFilter -> Value
toJSON SentimentFilter' {Maybe Bool
Maybe AbsoluteTimeRange
Maybe ParticipantRole
Maybe RelativeTimeRange
NonEmpty SentimentValue
sentiments :: NonEmpty SentimentValue
absoluteTimeRange :: Maybe AbsoluteTimeRange
negate :: Maybe Bool
relativeTimeRange :: Maybe RelativeTimeRange
participantRole :: Maybe ParticipantRole
$sel:sentiments:SentimentFilter' :: SentimentFilter -> NonEmpty SentimentValue
$sel:absoluteTimeRange:SentimentFilter' :: SentimentFilter -> Maybe AbsoluteTimeRange
$sel:negate:SentimentFilter' :: SentimentFilter -> Maybe Bool
$sel:relativeTimeRange:SentimentFilter' :: SentimentFilter -> Maybe RelativeTimeRange
$sel:participantRole:SentimentFilter' :: SentimentFilter -> Maybe ParticipantRole
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ParticipantRole" Text -> ParticipantRole -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ParticipantRole -> Pair) -> Maybe ParticipantRole -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ParticipantRole
participantRole,
            (Text
"RelativeTimeRange" Text -> RelativeTimeRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RelativeTimeRange -> Pair)
-> Maybe RelativeTimeRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RelativeTimeRange
relativeTimeRange,
            (Text
"Negate" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
negate,
            (Text
"AbsoluteTimeRange" Text -> AbsoluteTimeRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AbsoluteTimeRange -> Pair)
-> Maybe AbsoluteTimeRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AbsoluteTimeRange
absoluteTimeRange,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Sentiments" Text -> NonEmpty SentimentValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty SentimentValue
sentiments)
          ]
      )