{-# 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.Pinpoint.Types.CustomDeliveryConfiguration
-- 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.Pinpoint.Types.CustomDeliveryConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types.EndpointTypesElement
import qualified Amazonka.Prelude as Prelude

-- | Specifies the delivery configuration settings for sending a campaign or
-- campaign treatment through a custom channel. This object is required if
-- you use the CampaignCustomMessage object to define the message to send
-- for the campaign or campaign treatment.
--
-- /See:/ 'newCustomDeliveryConfiguration' smart constructor.
data CustomDeliveryConfiguration = CustomDeliveryConfiguration'
  { -- | The types of endpoints to send the campaign or treatment to. Each valid
    -- value maps to a type of channel that you can associate with an endpoint
    -- by using the ChannelType property of an endpoint.
    CustomDeliveryConfiguration -> Maybe [EndpointTypesElement]
endpointTypes :: Prelude.Maybe [EndpointTypesElement],
    -- | The destination to send the campaign or treatment to. This value can be
    -- one of the following:
    --
    -- -   The name or Amazon Resource Name (ARN) of an AWS Lambda function to
    --     invoke to handle delivery of the campaign or treatment.
    --
    -- -   The URL for a web application or service that supports HTTPS and can
    --     receive the message. The URL has to be a full URL, including the
    --     HTTPS protocol.
    CustomDeliveryConfiguration -> Text
deliveryUri :: Prelude.Text
  }
  deriving (CustomDeliveryConfiguration -> CustomDeliveryConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomDeliveryConfiguration -> CustomDeliveryConfiguration -> Bool
$c/= :: CustomDeliveryConfiguration -> CustomDeliveryConfiguration -> Bool
== :: CustomDeliveryConfiguration -> CustomDeliveryConfiguration -> Bool
$c== :: CustomDeliveryConfiguration -> CustomDeliveryConfiguration -> Bool
Prelude.Eq, ReadPrec [CustomDeliveryConfiguration]
ReadPrec CustomDeliveryConfiguration
Int -> ReadS CustomDeliveryConfiguration
ReadS [CustomDeliveryConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomDeliveryConfiguration]
$creadListPrec :: ReadPrec [CustomDeliveryConfiguration]
readPrec :: ReadPrec CustomDeliveryConfiguration
$creadPrec :: ReadPrec CustomDeliveryConfiguration
readList :: ReadS [CustomDeliveryConfiguration]
$creadList :: ReadS [CustomDeliveryConfiguration]
readsPrec :: Int -> ReadS CustomDeliveryConfiguration
$creadsPrec :: Int -> ReadS CustomDeliveryConfiguration
Prelude.Read, Int -> CustomDeliveryConfiguration -> ShowS
[CustomDeliveryConfiguration] -> ShowS
CustomDeliveryConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomDeliveryConfiguration] -> ShowS
$cshowList :: [CustomDeliveryConfiguration] -> ShowS
show :: CustomDeliveryConfiguration -> String
$cshow :: CustomDeliveryConfiguration -> String
showsPrec :: Int -> CustomDeliveryConfiguration -> ShowS
$cshowsPrec :: Int -> CustomDeliveryConfiguration -> ShowS
Prelude.Show, forall x.
Rep CustomDeliveryConfiguration x -> CustomDeliveryConfiguration
forall x.
CustomDeliveryConfiguration -> Rep CustomDeliveryConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomDeliveryConfiguration x -> CustomDeliveryConfiguration
$cfrom :: forall x.
CustomDeliveryConfiguration -> Rep CustomDeliveryConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CustomDeliveryConfiguration' 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:
--
-- 'endpointTypes', 'customDeliveryConfiguration_endpointTypes' - The types of endpoints to send the campaign or treatment to. Each valid
-- value maps to a type of channel that you can associate with an endpoint
-- by using the ChannelType property of an endpoint.
--
-- 'deliveryUri', 'customDeliveryConfiguration_deliveryUri' - The destination to send the campaign or treatment to. This value can be
-- one of the following:
--
-- -   The name or Amazon Resource Name (ARN) of an AWS Lambda function to
--     invoke to handle delivery of the campaign or treatment.
--
-- -   The URL for a web application or service that supports HTTPS and can
--     receive the message. The URL has to be a full URL, including the
--     HTTPS protocol.
newCustomDeliveryConfiguration ::
  -- | 'deliveryUri'
  Prelude.Text ->
  CustomDeliveryConfiguration
newCustomDeliveryConfiguration :: Text -> CustomDeliveryConfiguration
newCustomDeliveryConfiguration Text
pDeliveryUri_ =
  CustomDeliveryConfiguration'
    { $sel:endpointTypes:CustomDeliveryConfiguration' :: Maybe [EndpointTypesElement]
endpointTypes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:deliveryUri:CustomDeliveryConfiguration' :: Text
deliveryUri = Text
pDeliveryUri_
    }

-- | The types of endpoints to send the campaign or treatment to. Each valid
-- value maps to a type of channel that you can associate with an endpoint
-- by using the ChannelType property of an endpoint.
customDeliveryConfiguration_endpointTypes :: Lens.Lens' CustomDeliveryConfiguration (Prelude.Maybe [EndpointTypesElement])
customDeliveryConfiguration_endpointTypes :: Lens' CustomDeliveryConfiguration (Maybe [EndpointTypesElement])
customDeliveryConfiguration_endpointTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDeliveryConfiguration' {Maybe [EndpointTypesElement]
endpointTypes :: Maybe [EndpointTypesElement]
$sel:endpointTypes:CustomDeliveryConfiguration' :: CustomDeliveryConfiguration -> Maybe [EndpointTypesElement]
endpointTypes} -> Maybe [EndpointTypesElement]
endpointTypes) (\s :: CustomDeliveryConfiguration
s@CustomDeliveryConfiguration' {} Maybe [EndpointTypesElement]
a -> CustomDeliveryConfiguration
s {$sel:endpointTypes:CustomDeliveryConfiguration' :: Maybe [EndpointTypesElement]
endpointTypes = Maybe [EndpointTypesElement]
a} :: CustomDeliveryConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The destination to send the campaign or treatment to. This value can be
-- one of the following:
--
-- -   The name or Amazon Resource Name (ARN) of an AWS Lambda function to
--     invoke to handle delivery of the campaign or treatment.
--
-- -   The URL for a web application or service that supports HTTPS and can
--     receive the message. The URL has to be a full URL, including the
--     HTTPS protocol.
customDeliveryConfiguration_deliveryUri :: Lens.Lens' CustomDeliveryConfiguration Prelude.Text
customDeliveryConfiguration_deliveryUri :: Lens' CustomDeliveryConfiguration Text
customDeliveryConfiguration_deliveryUri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDeliveryConfiguration' {Text
deliveryUri :: Text
$sel:deliveryUri:CustomDeliveryConfiguration' :: CustomDeliveryConfiguration -> Text
deliveryUri} -> Text
deliveryUri) (\s :: CustomDeliveryConfiguration
s@CustomDeliveryConfiguration' {} Text
a -> CustomDeliveryConfiguration
s {$sel:deliveryUri:CustomDeliveryConfiguration' :: Text
deliveryUri = Text
a} :: CustomDeliveryConfiguration)

instance Data.FromJSON CustomDeliveryConfiguration where
  parseJSON :: Value -> Parser CustomDeliveryConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomDeliveryConfiguration"
      ( \Object
x ->
          Maybe [EndpointTypesElement] -> Text -> CustomDeliveryConfiguration
CustomDeliveryConfiguration'
            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
"EndpointTypes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DeliveryUri")
      )

instance Prelude.Hashable CustomDeliveryConfiguration where
  hashWithSalt :: Int -> CustomDeliveryConfiguration -> Int
hashWithSalt Int
_salt CustomDeliveryConfiguration' {Maybe [EndpointTypesElement]
Text
deliveryUri :: Text
endpointTypes :: Maybe [EndpointTypesElement]
$sel:deliveryUri:CustomDeliveryConfiguration' :: CustomDeliveryConfiguration -> Text
$sel:endpointTypes:CustomDeliveryConfiguration' :: CustomDeliveryConfiguration -> Maybe [EndpointTypesElement]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EndpointTypesElement]
endpointTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deliveryUri

instance Prelude.NFData CustomDeliveryConfiguration where
  rnf :: CustomDeliveryConfiguration -> ()
rnf CustomDeliveryConfiguration' {Maybe [EndpointTypesElement]
Text
deliveryUri :: Text
endpointTypes :: Maybe [EndpointTypesElement]
$sel:deliveryUri:CustomDeliveryConfiguration' :: CustomDeliveryConfiguration -> Text
$sel:endpointTypes:CustomDeliveryConfiguration' :: CustomDeliveryConfiguration -> Maybe [EndpointTypesElement]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [EndpointTypesElement]
endpointTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
deliveryUri

instance Data.ToJSON CustomDeliveryConfiguration where
  toJSON :: CustomDeliveryConfiguration -> Value
toJSON CustomDeliveryConfiguration' {Maybe [EndpointTypesElement]
Text
deliveryUri :: Text
endpointTypes :: Maybe [EndpointTypesElement]
$sel:deliveryUri:CustomDeliveryConfiguration' :: CustomDeliveryConfiguration -> Text
$sel:endpointTypes:CustomDeliveryConfiguration' :: CustomDeliveryConfiguration -> Maybe [EndpointTypesElement]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EndpointTypes" 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 [EndpointTypesElement]
endpointTypes,
            forall a. a -> Maybe a
Prelude.Just (Key
"DeliveryUri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
deliveryUri)
          ]
      )