{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.DeleteInAppTemplate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a message template for messages sent using the in-app message
-- channel.
module Amazonka.Pinpoint.DeleteInAppTemplate
  ( -- * Creating a Request
    DeleteInAppTemplate (..),
    newDeleteInAppTemplate,

    -- * Request Lenses
    deleteInAppTemplate_version,
    deleteInAppTemplate_templateName,

    -- * Destructuring the Response
    DeleteInAppTemplateResponse (..),
    newDeleteInAppTemplateResponse,

    -- * Response Lenses
    deleteInAppTemplateResponse_httpStatus,
    deleteInAppTemplateResponse_messageBody,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteInAppTemplate' smart constructor.
data DeleteInAppTemplate = DeleteInAppTemplate'
  { -- | The unique identifier for the version of the message template to update,
    -- retrieve information about, or delete. To retrieve identifiers and other
    -- information for all the versions of a template, use the Template
    -- Versions resource.
    --
    -- If specified, this value must match the identifier for an existing
    -- template version. If specified for an update operation, this value must
    -- match the identifier for the latest existing version of the template.
    -- This restriction helps ensure that race conditions don\'t occur.
    --
    -- If you don\'t specify a value for this parameter, Amazon Pinpoint does
    -- the following:
    --
    -- -   For a get operation, retrieves information about the active version
    --     of the template.
    --
    -- -   For an update operation, saves the updates to (overwrites) the
    --     latest existing version of the template, if the create-new-version
    --     parameter isn\'t used or is set to false.
    --
    -- -   For a delete operation, deletes the template, including all versions
    --     of the template.
    DeleteInAppTemplate -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The name of the message template. A template name must start with an
    -- alphanumeric character and can contain a maximum of 128 characters. The
    -- characters can be alphanumeric characters, underscores (_), or hyphens
    -- (-). Template names are case sensitive.
    DeleteInAppTemplate -> Text
templateName :: Prelude.Text
  }
  deriving (DeleteInAppTemplate -> DeleteInAppTemplate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInAppTemplate -> DeleteInAppTemplate -> Bool
$c/= :: DeleteInAppTemplate -> DeleteInAppTemplate -> Bool
== :: DeleteInAppTemplate -> DeleteInAppTemplate -> Bool
$c== :: DeleteInAppTemplate -> DeleteInAppTemplate -> Bool
Prelude.Eq, ReadPrec [DeleteInAppTemplate]
ReadPrec DeleteInAppTemplate
Int -> ReadS DeleteInAppTemplate
ReadS [DeleteInAppTemplate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInAppTemplate]
$creadListPrec :: ReadPrec [DeleteInAppTemplate]
readPrec :: ReadPrec DeleteInAppTemplate
$creadPrec :: ReadPrec DeleteInAppTemplate
readList :: ReadS [DeleteInAppTemplate]
$creadList :: ReadS [DeleteInAppTemplate]
readsPrec :: Int -> ReadS DeleteInAppTemplate
$creadsPrec :: Int -> ReadS DeleteInAppTemplate
Prelude.Read, Int -> DeleteInAppTemplate -> ShowS
[DeleteInAppTemplate] -> ShowS
DeleteInAppTemplate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInAppTemplate] -> ShowS
$cshowList :: [DeleteInAppTemplate] -> ShowS
show :: DeleteInAppTemplate -> String
$cshow :: DeleteInAppTemplate -> String
showsPrec :: Int -> DeleteInAppTemplate -> ShowS
$cshowsPrec :: Int -> DeleteInAppTemplate -> ShowS
Prelude.Show, forall x. Rep DeleteInAppTemplate x -> DeleteInAppTemplate
forall x. DeleteInAppTemplate -> Rep DeleteInAppTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteInAppTemplate x -> DeleteInAppTemplate
$cfrom :: forall x. DeleteInAppTemplate -> Rep DeleteInAppTemplate x
Prelude.Generic)

-- |
-- Create a value of 'DeleteInAppTemplate' 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:
--
-- 'version', 'deleteInAppTemplate_version' - The unique identifier for the version of the message template to update,
-- retrieve information about, or delete. To retrieve identifiers and other
-- information for all the versions of a template, use the Template
-- Versions resource.
--
-- If specified, this value must match the identifier for an existing
-- template version. If specified for an update operation, this value must
-- match the identifier for the latest existing version of the template.
-- This restriction helps ensure that race conditions don\'t occur.
--
-- If you don\'t specify a value for this parameter, Amazon Pinpoint does
-- the following:
--
-- -   For a get operation, retrieves information about the active version
--     of the template.
--
-- -   For an update operation, saves the updates to (overwrites) the
--     latest existing version of the template, if the create-new-version
--     parameter isn\'t used or is set to false.
--
-- -   For a delete operation, deletes the template, including all versions
--     of the template.
--
-- 'templateName', 'deleteInAppTemplate_templateName' - The name of the message template. A template name must start with an
-- alphanumeric character and can contain a maximum of 128 characters. The
-- characters can be alphanumeric characters, underscores (_), or hyphens
-- (-). Template names are case sensitive.
newDeleteInAppTemplate ::
  -- | 'templateName'
  Prelude.Text ->
  DeleteInAppTemplate
newDeleteInAppTemplate :: Text -> DeleteInAppTemplate
newDeleteInAppTemplate Text
pTemplateName_ =
  DeleteInAppTemplate'
    { $sel:version:DeleteInAppTemplate' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing,
      $sel:templateName:DeleteInAppTemplate' :: Text
templateName = Text
pTemplateName_
    }

-- | The unique identifier for the version of the message template to update,
-- retrieve information about, or delete. To retrieve identifiers and other
-- information for all the versions of a template, use the Template
-- Versions resource.
--
-- If specified, this value must match the identifier for an existing
-- template version. If specified for an update operation, this value must
-- match the identifier for the latest existing version of the template.
-- This restriction helps ensure that race conditions don\'t occur.
--
-- If you don\'t specify a value for this parameter, Amazon Pinpoint does
-- the following:
--
-- -   For a get operation, retrieves information about the active version
--     of the template.
--
-- -   For an update operation, saves the updates to (overwrites) the
--     latest existing version of the template, if the create-new-version
--     parameter isn\'t used or is set to false.
--
-- -   For a delete operation, deletes the template, including all versions
--     of the template.
deleteInAppTemplate_version :: Lens.Lens' DeleteInAppTemplate (Prelude.Maybe Prelude.Text)
deleteInAppTemplate_version :: Lens' DeleteInAppTemplate (Maybe Text)
deleteInAppTemplate_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInAppTemplate' {Maybe Text
version :: Maybe Text
$sel:version:DeleteInAppTemplate' :: DeleteInAppTemplate -> Maybe Text
version} -> Maybe Text
version) (\s :: DeleteInAppTemplate
s@DeleteInAppTemplate' {} Maybe Text
a -> DeleteInAppTemplate
s {$sel:version:DeleteInAppTemplate' :: Maybe Text
version = Maybe Text
a} :: DeleteInAppTemplate)

-- | The name of the message template. A template name must start with an
-- alphanumeric character and can contain a maximum of 128 characters. The
-- characters can be alphanumeric characters, underscores (_), or hyphens
-- (-). Template names are case sensitive.
deleteInAppTemplate_templateName :: Lens.Lens' DeleteInAppTemplate Prelude.Text
deleteInAppTemplate_templateName :: Lens' DeleteInAppTemplate Text
deleteInAppTemplate_templateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInAppTemplate' {Text
templateName :: Text
$sel:templateName:DeleteInAppTemplate' :: DeleteInAppTemplate -> Text
templateName} -> Text
templateName) (\s :: DeleteInAppTemplate
s@DeleteInAppTemplate' {} Text
a -> DeleteInAppTemplate
s {$sel:templateName:DeleteInAppTemplate' :: Text
templateName = Text
a} :: DeleteInAppTemplate)

instance Core.AWSRequest DeleteInAppTemplate where
  type
    AWSResponse DeleteInAppTemplate =
      DeleteInAppTemplateResponse
  request :: (Service -> Service)
-> DeleteInAppTemplate -> Request DeleteInAppTemplate
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteInAppTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteInAppTemplate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> MessageBody -> DeleteInAppTemplateResponse
DeleteInAppTemplateResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)
      )

instance Prelude.Hashable DeleteInAppTemplate where
  hashWithSalt :: Int -> DeleteInAppTemplate -> Int
hashWithSalt Int
_salt DeleteInAppTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteInAppTemplate' :: DeleteInAppTemplate -> Text
$sel:version:DeleteInAppTemplate' :: DeleteInAppTemplate -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
version
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
templateName

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

instance Data.ToHeaders DeleteInAppTemplate where
  toHeaders :: DeleteInAppTemplate -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath DeleteInAppTemplate where
  toPath :: DeleteInAppTemplate -> ByteString
toPath DeleteInAppTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteInAppTemplate' :: DeleteInAppTemplate -> Text
$sel:version:DeleteInAppTemplate' :: DeleteInAppTemplate -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/templates/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
templateName, ByteString
"/inapp"]

instance Data.ToQuery DeleteInAppTemplate where
  toQuery :: DeleteInAppTemplate -> QueryString
toQuery DeleteInAppTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:DeleteInAppTemplate' :: DeleteInAppTemplate -> Text
$sel:version:DeleteInAppTemplate' :: DeleteInAppTemplate -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"version" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
version]

-- | /See:/ 'newDeleteInAppTemplateResponse' smart constructor.
data DeleteInAppTemplateResponse = DeleteInAppTemplateResponse'
  { -- | The response's http status code.
    DeleteInAppTemplateResponse -> Int
httpStatus :: Prelude.Int,
    DeleteInAppTemplateResponse -> MessageBody
messageBody :: MessageBody
  }
  deriving (DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
$c/= :: DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
== :: DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
$c== :: DeleteInAppTemplateResponse -> DeleteInAppTemplateResponse -> Bool
Prelude.Eq, ReadPrec [DeleteInAppTemplateResponse]
ReadPrec DeleteInAppTemplateResponse
Int -> ReadS DeleteInAppTemplateResponse
ReadS [DeleteInAppTemplateResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteInAppTemplateResponse]
$creadListPrec :: ReadPrec [DeleteInAppTemplateResponse]
readPrec :: ReadPrec DeleteInAppTemplateResponse
$creadPrec :: ReadPrec DeleteInAppTemplateResponse
readList :: ReadS [DeleteInAppTemplateResponse]
$creadList :: ReadS [DeleteInAppTemplateResponse]
readsPrec :: Int -> ReadS DeleteInAppTemplateResponse
$creadsPrec :: Int -> ReadS DeleteInAppTemplateResponse
Prelude.Read, Int -> DeleteInAppTemplateResponse -> ShowS
[DeleteInAppTemplateResponse] -> ShowS
DeleteInAppTemplateResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteInAppTemplateResponse] -> ShowS
$cshowList :: [DeleteInAppTemplateResponse] -> ShowS
show :: DeleteInAppTemplateResponse -> String
$cshow :: DeleteInAppTemplateResponse -> String
showsPrec :: Int -> DeleteInAppTemplateResponse -> ShowS
$cshowsPrec :: Int -> DeleteInAppTemplateResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteInAppTemplateResponse x -> DeleteInAppTemplateResponse
forall x.
DeleteInAppTemplateResponse -> Rep DeleteInAppTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteInAppTemplateResponse x -> DeleteInAppTemplateResponse
$cfrom :: forall x.
DeleteInAppTemplateResponse -> Rep DeleteInAppTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteInAppTemplateResponse' 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:
--
-- 'httpStatus', 'deleteInAppTemplateResponse_httpStatus' - The response's http status code.
--
-- 'messageBody', 'deleteInAppTemplateResponse_messageBody' - Undocumented member.
newDeleteInAppTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'messageBody'
  MessageBody ->
  DeleteInAppTemplateResponse
newDeleteInAppTemplateResponse :: Int -> MessageBody -> DeleteInAppTemplateResponse
newDeleteInAppTemplateResponse
  Int
pHttpStatus_
  MessageBody
pMessageBody_ =
    DeleteInAppTemplateResponse'
      { $sel:httpStatus:DeleteInAppTemplateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:messageBody:DeleteInAppTemplateResponse' :: MessageBody
messageBody = MessageBody
pMessageBody_
      }

-- | The response's http status code.
deleteInAppTemplateResponse_httpStatus :: Lens.Lens' DeleteInAppTemplateResponse Prelude.Int
deleteInAppTemplateResponse_httpStatus :: Lens' DeleteInAppTemplateResponse Int
deleteInAppTemplateResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInAppTemplateResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteInAppTemplateResponse' :: DeleteInAppTemplateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteInAppTemplateResponse
s@DeleteInAppTemplateResponse' {} Int
a -> DeleteInAppTemplateResponse
s {$sel:httpStatus:DeleteInAppTemplateResponse' :: Int
httpStatus = Int
a} :: DeleteInAppTemplateResponse)

-- | Undocumented member.
deleteInAppTemplateResponse_messageBody :: Lens.Lens' DeleteInAppTemplateResponse MessageBody
deleteInAppTemplateResponse_messageBody :: Lens' DeleteInAppTemplateResponse MessageBody
deleteInAppTemplateResponse_messageBody = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteInAppTemplateResponse' {MessageBody
messageBody :: MessageBody
$sel:messageBody:DeleteInAppTemplateResponse' :: DeleteInAppTemplateResponse -> MessageBody
messageBody} -> MessageBody
messageBody) (\s :: DeleteInAppTemplateResponse
s@DeleteInAppTemplateResponse' {} MessageBody
a -> DeleteInAppTemplateResponse
s {$sel:messageBody:DeleteInAppTemplateResponse' :: MessageBody
messageBody = MessageBody
a} :: DeleteInAppTemplateResponse)

instance Prelude.NFData DeleteInAppTemplateResponse where
  rnf :: DeleteInAppTemplateResponse -> ()
rnf DeleteInAppTemplateResponse' {Int
MessageBody
messageBody :: MessageBody
httpStatus :: Int
$sel:messageBody:DeleteInAppTemplateResponse' :: DeleteInAppTemplateResponse -> MessageBody
$sel:httpStatus:DeleteInAppTemplateResponse' :: DeleteInAppTemplateResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MessageBody
messageBody