{-# 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.AlexaBusiness.Types.Audio
-- 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.AlexaBusiness.Types.Audio where

import Amazonka.AlexaBusiness.Types.Locale
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The audio message. There is a 1 MB limit on the audio file input and the
-- only supported format is MP3. To convert your MP3 audio files to an
-- Alexa-friendly,
--
-- required codec version (MPEG version 2) and bit rate (48 kbps), you
-- might use converter software. One option for this is a command-line
-- tool, FFmpeg. For more information, see
-- <https://www.ffmpeg.org/ FFmpeg>. The following command converts the
-- provided \<input-file> to an MP3 file that is played in the
-- announcement:
--
-- @ffmpeg -i \<input-file> -ac 2 -codec:a libmp3lame -b:a 48k -ar 16000 \<output-file.mp3>@
--
-- /See:/ 'newAudio' smart constructor.
data Audio = Audio'
  { -- | The locale of the audio message. Currently, en-US is supported.
    Audio -> Locale
locale :: Locale,
    -- | The location of the audio file. Currently, S3 URLs are supported. Only
    -- S3 locations comprised of safe characters are valid. For more
    -- information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#Safe%20Characters Safe Characters>.
    Audio -> Text
location :: Prelude.Text
  }
  deriving (Audio -> Audio -> Bool
(Audio -> Audio -> Bool) -> (Audio -> Audio -> Bool) -> Eq Audio
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Audio -> Audio -> Bool
$c/= :: Audio -> Audio -> Bool
== :: Audio -> Audio -> Bool
$c== :: Audio -> Audio -> Bool
Prelude.Eq, ReadPrec [Audio]
ReadPrec Audio
Int -> ReadS Audio
ReadS [Audio]
(Int -> ReadS Audio)
-> ReadS [Audio]
-> ReadPrec Audio
-> ReadPrec [Audio]
-> Read Audio
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Audio]
$creadListPrec :: ReadPrec [Audio]
readPrec :: ReadPrec Audio
$creadPrec :: ReadPrec Audio
readList :: ReadS [Audio]
$creadList :: ReadS [Audio]
readsPrec :: Int -> ReadS Audio
$creadsPrec :: Int -> ReadS Audio
Prelude.Read, Int -> Audio -> ShowS
[Audio] -> ShowS
Audio -> String
(Int -> Audio -> ShowS)
-> (Audio -> String) -> ([Audio] -> ShowS) -> Show Audio
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Audio] -> ShowS
$cshowList :: [Audio] -> ShowS
show :: Audio -> String
$cshow :: Audio -> String
showsPrec :: Int -> Audio -> ShowS
$cshowsPrec :: Int -> Audio -> ShowS
Prelude.Show, (forall x. Audio -> Rep Audio x)
-> (forall x. Rep Audio x -> Audio) -> Generic Audio
forall x. Rep Audio x -> Audio
forall x. Audio -> Rep Audio x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Audio x -> Audio
$cfrom :: forall x. Audio -> Rep Audio x
Prelude.Generic)

-- |
-- Create a value of 'Audio' 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:
--
-- 'locale', 'audio_locale' - The locale of the audio message. Currently, en-US is supported.
--
-- 'location', 'audio_location' - The location of the audio file. Currently, S3 URLs are supported. Only
-- S3 locations comprised of safe characters are valid. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#Safe%20Characters Safe Characters>.
newAudio ::
  -- | 'locale'
  Locale ->
  -- | 'location'
  Prelude.Text ->
  Audio
newAudio :: Locale -> Text -> Audio
newAudio Locale
pLocale_ Text
pLocation_ =
  Audio' :: Locale -> Text -> Audio
Audio' {$sel:locale:Audio' :: Locale
locale = Locale
pLocale_, $sel:location:Audio' :: Text
location = Text
pLocation_}

-- | The locale of the audio message. Currently, en-US is supported.
audio_locale :: Lens.Lens' Audio Locale
audio_locale :: (Locale -> f Locale) -> Audio -> f Audio
audio_locale = (Audio -> Locale)
-> (Audio -> Locale -> Audio) -> Lens Audio Audio Locale Locale
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Audio' {Locale
locale :: Locale
$sel:locale:Audio' :: Audio -> Locale
locale} -> Locale
locale) (\s :: Audio
s@Audio' {} Locale
a -> Audio
s {$sel:locale:Audio' :: Locale
locale = Locale
a} :: Audio)

-- | The location of the audio file. Currently, S3 URLs are supported. Only
-- S3 locations comprised of safe characters are valid. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#Safe%20Characters Safe Characters>.
audio_location :: Lens.Lens' Audio Prelude.Text
audio_location :: (Text -> f Text) -> Audio -> f Audio
audio_location = (Audio -> Text)
-> (Audio -> Text -> Audio) -> Lens Audio Audio Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Audio' {Text
location :: Text
$sel:location:Audio' :: Audio -> Text
location} -> Text
location) (\s :: Audio
s@Audio' {} Text
a -> Audio
s {$sel:location:Audio' :: Text
location = Text
a} :: Audio)

instance Prelude.Hashable Audio

instance Prelude.NFData Audio

instance Core.ToJSON Audio where
  toJSON :: Audio -> Value
toJSON Audio' {Text
Locale
location :: Text
locale :: Locale
$sel:location:Audio' :: Audio -> Text
$sel:locale:Audio' :: Audio -> Locale
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Locale" Text -> Locale -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Locale
locale),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Location" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
location)
          ]
      )