{-# 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.ChannelDefinition
-- 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.ChannelDefinition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Transcribe.Types.ParticipantRole

-- | For a call analytics job, an object that indicates the audio channel
-- that belongs to the agent and the audio channel that belongs to the
-- customer.
--
-- /See:/ 'newChannelDefinition' smart constructor.
data ChannelDefinition = ChannelDefinition'
  { -- | Indicates whether the person speaking on the audio channel is the agent
    -- or customer.
    ChannelDefinition -> Maybe ParticipantRole
participantRole :: Prelude.Maybe ParticipantRole,
    -- | A value that indicates the audio channel.
    ChannelDefinition -> Maybe Natural
channelId :: Prelude.Maybe Prelude.Natural
  }
  deriving (ChannelDefinition -> ChannelDefinition -> Bool
(ChannelDefinition -> ChannelDefinition -> Bool)
-> (ChannelDefinition -> ChannelDefinition -> Bool)
-> Eq ChannelDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelDefinition -> ChannelDefinition -> Bool
$c/= :: ChannelDefinition -> ChannelDefinition -> Bool
== :: ChannelDefinition -> ChannelDefinition -> Bool
$c== :: ChannelDefinition -> ChannelDefinition -> Bool
Prelude.Eq, ReadPrec [ChannelDefinition]
ReadPrec ChannelDefinition
Int -> ReadS ChannelDefinition
ReadS [ChannelDefinition]
(Int -> ReadS ChannelDefinition)
-> ReadS [ChannelDefinition]
-> ReadPrec ChannelDefinition
-> ReadPrec [ChannelDefinition]
-> Read ChannelDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChannelDefinition]
$creadListPrec :: ReadPrec [ChannelDefinition]
readPrec :: ReadPrec ChannelDefinition
$creadPrec :: ReadPrec ChannelDefinition
readList :: ReadS [ChannelDefinition]
$creadList :: ReadS [ChannelDefinition]
readsPrec :: Int -> ReadS ChannelDefinition
$creadsPrec :: Int -> ReadS ChannelDefinition
Prelude.Read, Int -> ChannelDefinition -> ShowS
[ChannelDefinition] -> ShowS
ChannelDefinition -> String
(Int -> ChannelDefinition -> ShowS)
-> (ChannelDefinition -> String)
-> ([ChannelDefinition] -> ShowS)
-> Show ChannelDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelDefinition] -> ShowS
$cshowList :: [ChannelDefinition] -> ShowS
show :: ChannelDefinition -> String
$cshow :: ChannelDefinition -> String
showsPrec :: Int -> ChannelDefinition -> ShowS
$cshowsPrec :: Int -> ChannelDefinition -> ShowS
Prelude.Show, (forall x. ChannelDefinition -> Rep ChannelDefinition x)
-> (forall x. Rep ChannelDefinition x -> ChannelDefinition)
-> Generic ChannelDefinition
forall x. Rep ChannelDefinition x -> ChannelDefinition
forall x. ChannelDefinition -> Rep ChannelDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelDefinition x -> ChannelDefinition
$cfrom :: forall x. ChannelDefinition -> Rep ChannelDefinition x
Prelude.Generic)

-- |
-- Create a value of 'ChannelDefinition' 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', 'channelDefinition_participantRole' - Indicates whether the person speaking on the audio channel is the agent
-- or customer.
--
-- 'channelId', 'channelDefinition_channelId' - A value that indicates the audio channel.
newChannelDefinition ::
  ChannelDefinition
newChannelDefinition :: ChannelDefinition
newChannelDefinition =
  ChannelDefinition' :: Maybe ParticipantRole -> Maybe Natural -> ChannelDefinition
ChannelDefinition'
    { $sel:participantRole:ChannelDefinition' :: Maybe ParticipantRole
participantRole =
        Maybe ParticipantRole
forall a. Maybe a
Prelude.Nothing,
      $sel:channelId:ChannelDefinition' :: Maybe Natural
channelId = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether the person speaking on the audio channel is the agent
-- or customer.
channelDefinition_participantRole :: Lens.Lens' ChannelDefinition (Prelude.Maybe ParticipantRole)
channelDefinition_participantRole :: (Maybe ParticipantRole -> f (Maybe ParticipantRole))
-> ChannelDefinition -> f ChannelDefinition
channelDefinition_participantRole = (ChannelDefinition -> Maybe ParticipantRole)
-> (ChannelDefinition
    -> Maybe ParticipantRole -> ChannelDefinition)
-> Lens
     ChannelDefinition
     ChannelDefinition
     (Maybe ParticipantRole)
     (Maybe ParticipantRole)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelDefinition' {Maybe ParticipantRole
participantRole :: Maybe ParticipantRole
$sel:participantRole:ChannelDefinition' :: ChannelDefinition -> Maybe ParticipantRole
participantRole} -> Maybe ParticipantRole
participantRole) (\s :: ChannelDefinition
s@ChannelDefinition' {} Maybe ParticipantRole
a -> ChannelDefinition
s {$sel:participantRole:ChannelDefinition' :: Maybe ParticipantRole
participantRole = Maybe ParticipantRole
a} :: ChannelDefinition)

-- | A value that indicates the audio channel.
channelDefinition_channelId :: Lens.Lens' ChannelDefinition (Prelude.Maybe Prelude.Natural)
channelDefinition_channelId :: (Maybe Natural -> f (Maybe Natural))
-> ChannelDefinition -> f ChannelDefinition
channelDefinition_channelId = (ChannelDefinition -> Maybe Natural)
-> (ChannelDefinition -> Maybe Natural -> ChannelDefinition)
-> Lens
     ChannelDefinition ChannelDefinition (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelDefinition' {Maybe Natural
channelId :: Maybe Natural
$sel:channelId:ChannelDefinition' :: ChannelDefinition -> Maybe Natural
channelId} -> Maybe Natural
channelId) (\s :: ChannelDefinition
s@ChannelDefinition' {} Maybe Natural
a -> ChannelDefinition
s {$sel:channelId:ChannelDefinition' :: Maybe Natural
channelId = Maybe Natural
a} :: ChannelDefinition)

instance Core.FromJSON ChannelDefinition where
  parseJSON :: Value -> Parser ChannelDefinition
parseJSON =
    String
-> (Object -> Parser ChannelDefinition)
-> Value
-> Parser ChannelDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ChannelDefinition"
      ( \Object
x ->
          Maybe ParticipantRole -> Maybe Natural -> ChannelDefinition
ChannelDefinition'
            (Maybe ParticipantRole -> Maybe Natural -> ChannelDefinition)
-> Parser (Maybe ParticipantRole)
-> Parser (Maybe Natural -> ChannelDefinition)
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 Natural -> ChannelDefinition)
-> Parser (Maybe Natural) -> Parser ChannelDefinition
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
"ChannelId")
      )

instance Prelude.Hashable ChannelDefinition

instance Prelude.NFData ChannelDefinition

instance Core.ToJSON ChannelDefinition where
  toJSON :: ChannelDefinition -> Value
toJSON ChannelDefinition' {Maybe Natural
Maybe ParticipantRole
channelId :: Maybe Natural
participantRole :: Maybe ParticipantRole
$sel:channelId:ChannelDefinition' :: ChannelDefinition -> Maybe Natural
$sel:participantRole:ChannelDefinition' :: ChannelDefinition -> 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
"ChannelId" 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
channelId
          ]
      )