{-# 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.MediaTailor.Types.Bumper
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaTailor.Types.Bumper where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The configuration for bumpers. Bumpers are short audio or video clips
-- that play at the start or before the end of an ad break. To learn more
-- about bumpers, see
-- <https://docs.aws.amazon.com/mediatailor/latest/ug/bumpers.html Bumpers>.
--
-- /See:/ 'newBumper' smart constructor.
data Bumper = Bumper'
  { -- | The URL for the end bumper asset.
    Bumper -> Maybe Text
endUrl :: Prelude.Maybe Prelude.Text,
    -- | The URL for the start bumper asset.
    Bumper -> Maybe Text
startUrl :: Prelude.Maybe Prelude.Text
  }
  deriving (Bumper -> Bumper -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Bumper -> Bumper -> Bool
$c/= :: Bumper -> Bumper -> Bool
== :: Bumper -> Bumper -> Bool
$c== :: Bumper -> Bumper -> Bool
Prelude.Eq, ReadPrec [Bumper]
ReadPrec Bumper
Int -> ReadS Bumper
ReadS [Bumper]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Bumper]
$creadListPrec :: ReadPrec [Bumper]
readPrec :: ReadPrec Bumper
$creadPrec :: ReadPrec Bumper
readList :: ReadS [Bumper]
$creadList :: ReadS [Bumper]
readsPrec :: Int -> ReadS Bumper
$creadsPrec :: Int -> ReadS Bumper
Prelude.Read, Int -> Bumper -> ShowS
[Bumper] -> ShowS
Bumper -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Bumper] -> ShowS
$cshowList :: [Bumper] -> ShowS
show :: Bumper -> String
$cshow :: Bumper -> String
showsPrec :: Int -> Bumper -> ShowS
$cshowsPrec :: Int -> Bumper -> ShowS
Prelude.Show, forall x. Rep Bumper x -> Bumper
forall x. Bumper -> Rep Bumper x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Bumper x -> Bumper
$cfrom :: forall x. Bumper -> Rep Bumper x
Prelude.Generic)

-- |
-- Create a value of 'Bumper' 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:
--
-- 'endUrl', 'bumper_endUrl' - The URL for the end bumper asset.
--
-- 'startUrl', 'bumper_startUrl' - The URL for the start bumper asset.
newBumper ::
  Bumper
newBumper :: Bumper
newBumper =
  Bumper'
    { $sel:endUrl:Bumper' :: Maybe Text
endUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:startUrl:Bumper' :: Maybe Text
startUrl = forall a. Maybe a
Prelude.Nothing
    }

-- | The URL for the end bumper asset.
bumper_endUrl :: Lens.Lens' Bumper (Prelude.Maybe Prelude.Text)
bumper_endUrl :: Lens' Bumper (Maybe Text)
bumper_endUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Bumper' {Maybe Text
endUrl :: Maybe Text
$sel:endUrl:Bumper' :: Bumper -> Maybe Text
endUrl} -> Maybe Text
endUrl) (\s :: Bumper
s@Bumper' {} Maybe Text
a -> Bumper
s {$sel:endUrl:Bumper' :: Maybe Text
endUrl = Maybe Text
a} :: Bumper)

-- | The URL for the start bumper asset.
bumper_startUrl :: Lens.Lens' Bumper (Prelude.Maybe Prelude.Text)
bumper_startUrl :: Lens' Bumper (Maybe Text)
bumper_startUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Bumper' {Maybe Text
startUrl :: Maybe Text
$sel:startUrl:Bumper' :: Bumper -> Maybe Text
startUrl} -> Maybe Text
startUrl) (\s :: Bumper
s@Bumper' {} Maybe Text
a -> Bumper
s {$sel:startUrl:Bumper' :: Maybe Text
startUrl = Maybe Text
a} :: Bumper)

instance Data.FromJSON Bumper where
  parseJSON :: Value -> Parser Bumper
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Bumper"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Bumper
Bumper'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EndUrl")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StartUrl")
      )

instance Prelude.Hashable Bumper where
  hashWithSalt :: Int -> Bumper -> Int
hashWithSalt Int
_salt Bumper' {Maybe Text
startUrl :: Maybe Text
endUrl :: Maybe Text
$sel:startUrl:Bumper' :: Bumper -> Maybe Text
$sel:endUrl:Bumper' :: Bumper -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
endUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
startUrl

instance Prelude.NFData Bumper where
  rnf :: Bumper -> ()
rnf Bumper' {Maybe Text
startUrl :: Maybe Text
endUrl :: Maybe Text
$sel:startUrl:Bumper' :: Bumper -> Maybe Text
$sel:endUrl:Bumper' :: Bumper -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
endUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
startUrl

instance Data.ToJSON Bumper where
  toJSON :: Bumper -> Value
toJSON Bumper' {Maybe Text
startUrl :: Maybe Text
endUrl :: Maybe Text
$sel:startUrl:Bumper' :: Bumper -> Maybe Text
$sel:endUrl:Bumper' :: Bumper -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EndUrl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
endUrl,
            (Key
"StartUrl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
startUrl
          ]
      )