{-# 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.InterruptionFilter
-- 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.InterruptionFilter 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

-- | An object that enables you to configure your category to be applied to
-- call analytics jobs where either the customer or agent was interrupted.
--
-- /See:/ 'newInterruptionFilter' smart constructor.
data InterruptionFilter = InterruptionFilter'
  { -- | Indicates whether the caller or customer was interrupting.
    InterruptionFilter -> Maybe ParticipantRole
participantRole :: Prelude.Maybe ParticipantRole,
    -- | An object that allows percentages to specify the proportion of the call
    -- where there was a interruption. For example, you can specify the first
    -- half of the call. You can also specify the period of time between
    -- halfway through to three-quarters of the way through the call. Because
    -- the length of conversation can vary between calls, you can apply
    -- relative time ranges across all calls.
    InterruptionFilter -> Maybe RelativeTimeRange
relativeTimeRange :: Prelude.Maybe RelativeTimeRange,
    -- | Set to @TRUE@ to look for a time period where there was no interruption.
    InterruptionFilter -> Maybe Bool
negate :: Prelude.Maybe Prelude.Bool,
    -- | The duration of the interruption.
    InterruptionFilter -> Maybe Natural
threshold :: Prelude.Maybe Prelude.Natural,
    -- | An object you can use to specify a time range (in milliseconds) for when
    -- you\'d want to find the interruption. For example, you could search for
    -- an interruption between the 30,000 millisecond mark and the 45,000
    -- millisecond mark. You could also specify the time period as the first
    -- 15,000 milliseconds or the last 15,000 milliseconds.
    InterruptionFilter -> Maybe AbsoluteTimeRange
absoluteTimeRange :: Prelude.Maybe AbsoluteTimeRange
  }
  deriving (InterruptionFilter -> InterruptionFilter -> Bool
(InterruptionFilter -> InterruptionFilter -> Bool)
-> (InterruptionFilter -> InterruptionFilter -> Bool)
-> Eq InterruptionFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InterruptionFilter -> InterruptionFilter -> Bool
$c/= :: InterruptionFilter -> InterruptionFilter -> Bool
== :: InterruptionFilter -> InterruptionFilter -> Bool
$c== :: InterruptionFilter -> InterruptionFilter -> Bool
Prelude.Eq, ReadPrec [InterruptionFilter]
ReadPrec InterruptionFilter
Int -> ReadS InterruptionFilter
ReadS [InterruptionFilter]
(Int -> ReadS InterruptionFilter)
-> ReadS [InterruptionFilter]
-> ReadPrec InterruptionFilter
-> ReadPrec [InterruptionFilter]
-> Read InterruptionFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InterruptionFilter]
$creadListPrec :: ReadPrec [InterruptionFilter]
readPrec :: ReadPrec InterruptionFilter
$creadPrec :: ReadPrec InterruptionFilter
readList :: ReadS [InterruptionFilter]
$creadList :: ReadS [InterruptionFilter]
readsPrec :: Int -> ReadS InterruptionFilter
$creadsPrec :: Int -> ReadS InterruptionFilter
Prelude.Read, Int -> InterruptionFilter -> ShowS
[InterruptionFilter] -> ShowS
InterruptionFilter -> String
(Int -> InterruptionFilter -> ShowS)
-> (InterruptionFilter -> String)
-> ([InterruptionFilter] -> ShowS)
-> Show InterruptionFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InterruptionFilter] -> ShowS
$cshowList :: [InterruptionFilter] -> ShowS
show :: InterruptionFilter -> String
$cshow :: InterruptionFilter -> String
showsPrec :: Int -> InterruptionFilter -> ShowS
$cshowsPrec :: Int -> InterruptionFilter -> ShowS
Prelude.Show, (forall x. InterruptionFilter -> Rep InterruptionFilter x)
-> (forall x. Rep InterruptionFilter x -> InterruptionFilter)
-> Generic InterruptionFilter
forall x. Rep InterruptionFilter x -> InterruptionFilter
forall x. InterruptionFilter -> Rep InterruptionFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InterruptionFilter x -> InterruptionFilter
$cfrom :: forall x. InterruptionFilter -> Rep InterruptionFilter x
Prelude.Generic)

-- |
-- Create a value of 'InterruptionFilter' 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', 'interruptionFilter_participantRole' - Indicates whether the caller or customer was interrupting.
--
-- 'relativeTimeRange', 'interruptionFilter_relativeTimeRange' - An object that allows percentages to specify the proportion of the call
-- where there was a interruption. For example, you can specify the first
-- half of the call. You can also specify the period of time between
-- halfway through to three-quarters of the way through the call. Because
-- the length of conversation can vary between calls, you can apply
-- relative time ranges across all calls.
--
-- 'negate', 'interruptionFilter_negate' - Set to @TRUE@ to look for a time period where there was no interruption.
--
-- 'threshold', 'interruptionFilter_threshold' - The duration of the interruption.
--
-- 'absoluteTimeRange', 'interruptionFilter_absoluteTimeRange' - An object you can use to specify a time range (in milliseconds) for when
-- you\'d want to find the interruption. For example, you could search for
-- an interruption between the 30,000 millisecond mark and the 45,000
-- millisecond mark. You could also specify the time period as the first
-- 15,000 milliseconds or the last 15,000 milliseconds.
newInterruptionFilter ::
  InterruptionFilter
newInterruptionFilter :: InterruptionFilter
newInterruptionFilter =
  InterruptionFilter' :: Maybe ParticipantRole
-> Maybe RelativeTimeRange
-> Maybe Bool
-> Maybe Natural
-> Maybe AbsoluteTimeRange
-> InterruptionFilter
InterruptionFilter'
    { $sel:participantRole:InterruptionFilter' :: Maybe ParticipantRole
participantRole =
        Maybe ParticipantRole
forall a. Maybe a
Prelude.Nothing,
      $sel:relativeTimeRange:InterruptionFilter' :: Maybe RelativeTimeRange
relativeTimeRange = Maybe RelativeTimeRange
forall a. Maybe a
Prelude.Nothing,
      $sel:negate:InterruptionFilter' :: Maybe Bool
negate = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:threshold:InterruptionFilter' :: Maybe Natural
threshold = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:absoluteTimeRange:InterruptionFilter' :: Maybe AbsoluteTimeRange
absoluteTimeRange = Maybe AbsoluteTimeRange
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether the caller or customer was interrupting.
interruptionFilter_participantRole :: Lens.Lens' InterruptionFilter (Prelude.Maybe ParticipantRole)
interruptionFilter_participantRole :: (Maybe ParticipantRole -> f (Maybe ParticipantRole))
-> InterruptionFilter -> f InterruptionFilter
interruptionFilter_participantRole = (InterruptionFilter -> Maybe ParticipantRole)
-> (InterruptionFilter
    -> Maybe ParticipantRole -> InterruptionFilter)
-> Lens
     InterruptionFilter
     InterruptionFilter
     (Maybe ParticipantRole)
     (Maybe ParticipantRole)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InterruptionFilter' {Maybe ParticipantRole
participantRole :: Maybe ParticipantRole
$sel:participantRole:InterruptionFilter' :: InterruptionFilter -> Maybe ParticipantRole
participantRole} -> Maybe ParticipantRole
participantRole) (\s :: InterruptionFilter
s@InterruptionFilter' {} Maybe ParticipantRole
a -> InterruptionFilter
s {$sel:participantRole:InterruptionFilter' :: Maybe ParticipantRole
participantRole = Maybe ParticipantRole
a} :: InterruptionFilter)

-- | An object that allows percentages to specify the proportion of the call
-- where there was a interruption. For example, you can specify the first
-- half of the call. You can also specify the period of time between
-- halfway through to three-quarters of the way through the call. Because
-- the length of conversation can vary between calls, you can apply
-- relative time ranges across all calls.
interruptionFilter_relativeTimeRange :: Lens.Lens' InterruptionFilter (Prelude.Maybe RelativeTimeRange)
interruptionFilter_relativeTimeRange :: (Maybe RelativeTimeRange -> f (Maybe RelativeTimeRange))
-> InterruptionFilter -> f InterruptionFilter
interruptionFilter_relativeTimeRange = (InterruptionFilter -> Maybe RelativeTimeRange)
-> (InterruptionFilter
    -> Maybe RelativeTimeRange -> InterruptionFilter)
-> Lens
     InterruptionFilter
     InterruptionFilter
     (Maybe RelativeTimeRange)
     (Maybe RelativeTimeRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InterruptionFilter' {Maybe RelativeTimeRange
relativeTimeRange :: Maybe RelativeTimeRange
$sel:relativeTimeRange:InterruptionFilter' :: InterruptionFilter -> Maybe RelativeTimeRange
relativeTimeRange} -> Maybe RelativeTimeRange
relativeTimeRange) (\s :: InterruptionFilter
s@InterruptionFilter' {} Maybe RelativeTimeRange
a -> InterruptionFilter
s {$sel:relativeTimeRange:InterruptionFilter' :: Maybe RelativeTimeRange
relativeTimeRange = Maybe RelativeTimeRange
a} :: InterruptionFilter)

-- | Set to @TRUE@ to look for a time period where there was no interruption.
interruptionFilter_negate :: Lens.Lens' InterruptionFilter (Prelude.Maybe Prelude.Bool)
interruptionFilter_negate :: (Maybe Bool -> f (Maybe Bool))
-> InterruptionFilter -> f InterruptionFilter
interruptionFilter_negate = (InterruptionFilter -> Maybe Bool)
-> (InterruptionFilter -> Maybe Bool -> InterruptionFilter)
-> Lens
     InterruptionFilter InterruptionFilter (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InterruptionFilter' {Maybe Bool
negate :: Maybe Bool
$sel:negate:InterruptionFilter' :: InterruptionFilter -> Maybe Bool
negate} -> Maybe Bool
negate) (\s :: InterruptionFilter
s@InterruptionFilter' {} Maybe Bool
a -> InterruptionFilter
s {$sel:negate:InterruptionFilter' :: Maybe Bool
negate = Maybe Bool
a} :: InterruptionFilter)

-- | The duration of the interruption.
interruptionFilter_threshold :: Lens.Lens' InterruptionFilter (Prelude.Maybe Prelude.Natural)
interruptionFilter_threshold :: (Maybe Natural -> f (Maybe Natural))
-> InterruptionFilter -> f InterruptionFilter
interruptionFilter_threshold = (InterruptionFilter -> Maybe Natural)
-> (InterruptionFilter -> Maybe Natural -> InterruptionFilter)
-> Lens
     InterruptionFilter
     InterruptionFilter
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InterruptionFilter' {Maybe Natural
threshold :: Maybe Natural
$sel:threshold:InterruptionFilter' :: InterruptionFilter -> Maybe Natural
threshold} -> Maybe Natural
threshold) (\s :: InterruptionFilter
s@InterruptionFilter' {} Maybe Natural
a -> InterruptionFilter
s {$sel:threshold:InterruptionFilter' :: Maybe Natural
threshold = Maybe Natural
a} :: InterruptionFilter)

-- | An object you can use to specify a time range (in milliseconds) for when
-- you\'d want to find the interruption. For example, you could search for
-- an interruption between the 30,000 millisecond mark and the 45,000
-- millisecond mark. You could also specify the time period as the first
-- 15,000 milliseconds or the last 15,000 milliseconds.
interruptionFilter_absoluteTimeRange :: Lens.Lens' InterruptionFilter (Prelude.Maybe AbsoluteTimeRange)
interruptionFilter_absoluteTimeRange :: (Maybe AbsoluteTimeRange -> f (Maybe AbsoluteTimeRange))
-> InterruptionFilter -> f InterruptionFilter
interruptionFilter_absoluteTimeRange = (InterruptionFilter -> Maybe AbsoluteTimeRange)
-> (InterruptionFilter
    -> Maybe AbsoluteTimeRange -> InterruptionFilter)
-> Lens
     InterruptionFilter
     InterruptionFilter
     (Maybe AbsoluteTimeRange)
     (Maybe AbsoluteTimeRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InterruptionFilter' {Maybe AbsoluteTimeRange
absoluteTimeRange :: Maybe AbsoluteTimeRange
$sel:absoluteTimeRange:InterruptionFilter' :: InterruptionFilter -> Maybe AbsoluteTimeRange
absoluteTimeRange} -> Maybe AbsoluteTimeRange
absoluteTimeRange) (\s :: InterruptionFilter
s@InterruptionFilter' {} Maybe AbsoluteTimeRange
a -> InterruptionFilter
s {$sel:absoluteTimeRange:InterruptionFilter' :: Maybe AbsoluteTimeRange
absoluteTimeRange = Maybe AbsoluteTimeRange
a} :: InterruptionFilter)

instance Core.FromJSON InterruptionFilter where
  parseJSON :: Value -> Parser InterruptionFilter
parseJSON =
    String
-> (Object -> Parser InterruptionFilter)
-> Value
-> Parser InterruptionFilter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InterruptionFilter"
      ( \Object
x ->
          Maybe ParticipantRole
-> Maybe RelativeTimeRange
-> Maybe Bool
-> Maybe Natural
-> Maybe AbsoluteTimeRange
-> InterruptionFilter
InterruptionFilter'
            (Maybe ParticipantRole
 -> Maybe RelativeTimeRange
 -> Maybe Bool
 -> Maybe Natural
 -> Maybe AbsoluteTimeRange
 -> InterruptionFilter)
-> Parser (Maybe ParticipantRole)
-> Parser
     (Maybe RelativeTimeRange
      -> Maybe Bool
      -> Maybe Natural
      -> Maybe AbsoluteTimeRange
      -> InterruptionFilter)
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 Natural
   -> Maybe AbsoluteTimeRange
   -> InterruptionFilter)
-> Parser (Maybe RelativeTimeRange)
-> Parser
     (Maybe Bool
      -> Maybe Natural -> Maybe AbsoluteTimeRange -> InterruptionFilter)
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 Natural -> Maybe AbsoluteTimeRange -> InterruptionFilter)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Natural -> Maybe AbsoluteTimeRange -> InterruptionFilter)
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 Natural -> Maybe AbsoluteTimeRange -> InterruptionFilter)
-> Parser (Maybe Natural)
-> Parser (Maybe AbsoluteTimeRange -> InterruptionFilter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Threshold")
            Parser (Maybe AbsoluteTimeRange -> InterruptionFilter)
-> Parser (Maybe AbsoluteTimeRange) -> Parser InterruptionFilter
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")
      )

instance Prelude.Hashable InterruptionFilter

instance Prelude.NFData InterruptionFilter

instance Core.ToJSON InterruptionFilter where
  toJSON :: InterruptionFilter -> Value
toJSON InterruptionFilter' {Maybe Bool
Maybe Natural
Maybe AbsoluteTimeRange
Maybe ParticipantRole
Maybe RelativeTimeRange
absoluteTimeRange :: Maybe AbsoluteTimeRange
threshold :: Maybe Natural
negate :: Maybe Bool
relativeTimeRange :: Maybe RelativeTimeRange
participantRole :: Maybe ParticipantRole
$sel:absoluteTimeRange:InterruptionFilter' :: InterruptionFilter -> Maybe AbsoluteTimeRange
$sel:threshold:InterruptionFilter' :: InterruptionFilter -> Maybe Natural
$sel:negate:InterruptionFilter' :: InterruptionFilter -> Maybe Bool
$sel:relativeTimeRange:InterruptionFilter' :: InterruptionFilter -> Maybe RelativeTimeRange
$sel:participantRole:InterruptionFilter' :: InterruptionFilter -> 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
"Threshold" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
threshold,
            (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
          ]
      )