{-# 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.CreateVoiceTemplate
-- 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)
--
-- Creates a message template for messages that are sent through the voice
-- channel.
module Amazonka.Pinpoint.CreateVoiceTemplate
  ( -- * Creating a Request
    CreateVoiceTemplate (..),
    newCreateVoiceTemplate,

    -- * Request Lenses
    createVoiceTemplate_templateName,
    createVoiceTemplate_voiceTemplateRequest,

    -- * Destructuring the Response
    CreateVoiceTemplateResponse (..),
    newCreateVoiceTemplateResponse,

    -- * Response Lenses
    createVoiceTemplateResponse_httpStatus,
    createVoiceTemplateResponse_createTemplateMessageBody,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateVoiceTemplate' smart constructor.
data CreateVoiceTemplate = CreateVoiceTemplate'
  { -- | 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.
    CreateVoiceTemplate -> Text
templateName :: Prelude.Text,
    CreateVoiceTemplate -> VoiceTemplateRequest
voiceTemplateRequest :: VoiceTemplateRequest
  }
  deriving (CreateVoiceTemplate -> CreateVoiceTemplate -> Bool
(CreateVoiceTemplate -> CreateVoiceTemplate -> Bool)
-> (CreateVoiceTemplate -> CreateVoiceTemplate -> Bool)
-> Eq CreateVoiceTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateVoiceTemplate -> CreateVoiceTemplate -> Bool
$c/= :: CreateVoiceTemplate -> CreateVoiceTemplate -> Bool
== :: CreateVoiceTemplate -> CreateVoiceTemplate -> Bool
$c== :: CreateVoiceTemplate -> CreateVoiceTemplate -> Bool
Prelude.Eq, ReadPrec [CreateVoiceTemplate]
ReadPrec CreateVoiceTemplate
Int -> ReadS CreateVoiceTemplate
ReadS [CreateVoiceTemplate]
(Int -> ReadS CreateVoiceTemplate)
-> ReadS [CreateVoiceTemplate]
-> ReadPrec CreateVoiceTemplate
-> ReadPrec [CreateVoiceTemplate]
-> Read CreateVoiceTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateVoiceTemplate]
$creadListPrec :: ReadPrec [CreateVoiceTemplate]
readPrec :: ReadPrec CreateVoiceTemplate
$creadPrec :: ReadPrec CreateVoiceTemplate
readList :: ReadS [CreateVoiceTemplate]
$creadList :: ReadS [CreateVoiceTemplate]
readsPrec :: Int -> ReadS CreateVoiceTemplate
$creadsPrec :: Int -> ReadS CreateVoiceTemplate
Prelude.Read, Int -> CreateVoiceTemplate -> ShowS
[CreateVoiceTemplate] -> ShowS
CreateVoiceTemplate -> String
(Int -> CreateVoiceTemplate -> ShowS)
-> (CreateVoiceTemplate -> String)
-> ([CreateVoiceTemplate] -> ShowS)
-> Show CreateVoiceTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateVoiceTemplate] -> ShowS
$cshowList :: [CreateVoiceTemplate] -> ShowS
show :: CreateVoiceTemplate -> String
$cshow :: CreateVoiceTemplate -> String
showsPrec :: Int -> CreateVoiceTemplate -> ShowS
$cshowsPrec :: Int -> CreateVoiceTemplate -> ShowS
Prelude.Show, (forall x. CreateVoiceTemplate -> Rep CreateVoiceTemplate x)
-> (forall x. Rep CreateVoiceTemplate x -> CreateVoiceTemplate)
-> Generic CreateVoiceTemplate
forall x. Rep CreateVoiceTemplate x -> CreateVoiceTemplate
forall x. CreateVoiceTemplate -> Rep CreateVoiceTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateVoiceTemplate x -> CreateVoiceTemplate
$cfrom :: forall x. CreateVoiceTemplate -> Rep CreateVoiceTemplate x
Prelude.Generic)

-- |
-- Create a value of 'CreateVoiceTemplate' 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:
--
-- 'templateName', 'createVoiceTemplate_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.
--
-- 'voiceTemplateRequest', 'createVoiceTemplate_voiceTemplateRequest' - Undocumented member.
newCreateVoiceTemplate ::
  -- | 'templateName'
  Prelude.Text ->
  -- | 'voiceTemplateRequest'
  VoiceTemplateRequest ->
  CreateVoiceTemplate
newCreateVoiceTemplate :: Text -> VoiceTemplateRequest -> CreateVoiceTemplate
newCreateVoiceTemplate
  Text
pTemplateName_
  VoiceTemplateRequest
pVoiceTemplateRequest_ =
    CreateVoiceTemplate' :: Text -> VoiceTemplateRequest -> CreateVoiceTemplate
CreateVoiceTemplate'
      { $sel:templateName:CreateVoiceTemplate' :: Text
templateName = Text
pTemplateName_,
        $sel:voiceTemplateRequest:CreateVoiceTemplate' :: VoiceTemplateRequest
voiceTemplateRequest = VoiceTemplateRequest
pVoiceTemplateRequest_
      }

-- | 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.
createVoiceTemplate_templateName :: Lens.Lens' CreateVoiceTemplate Prelude.Text
createVoiceTemplate_templateName :: (Text -> f Text) -> CreateVoiceTemplate -> f CreateVoiceTemplate
createVoiceTemplate_templateName = (CreateVoiceTemplate -> Text)
-> (CreateVoiceTemplate -> Text -> CreateVoiceTemplate)
-> Lens CreateVoiceTemplate CreateVoiceTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVoiceTemplate' {Text
templateName :: Text
$sel:templateName:CreateVoiceTemplate' :: CreateVoiceTemplate -> Text
templateName} -> Text
templateName) (\s :: CreateVoiceTemplate
s@CreateVoiceTemplate' {} Text
a -> CreateVoiceTemplate
s {$sel:templateName:CreateVoiceTemplate' :: Text
templateName = Text
a} :: CreateVoiceTemplate)

-- | Undocumented member.
createVoiceTemplate_voiceTemplateRequest :: Lens.Lens' CreateVoiceTemplate VoiceTemplateRequest
createVoiceTemplate_voiceTemplateRequest :: (VoiceTemplateRequest -> f VoiceTemplateRequest)
-> CreateVoiceTemplate -> f CreateVoiceTemplate
createVoiceTemplate_voiceTemplateRequest = (CreateVoiceTemplate -> VoiceTemplateRequest)
-> (CreateVoiceTemplate
    -> VoiceTemplateRequest -> CreateVoiceTemplate)
-> Lens
     CreateVoiceTemplate
     CreateVoiceTemplate
     VoiceTemplateRequest
     VoiceTemplateRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVoiceTemplate' {VoiceTemplateRequest
voiceTemplateRequest :: VoiceTemplateRequest
$sel:voiceTemplateRequest:CreateVoiceTemplate' :: CreateVoiceTemplate -> VoiceTemplateRequest
voiceTemplateRequest} -> VoiceTemplateRequest
voiceTemplateRequest) (\s :: CreateVoiceTemplate
s@CreateVoiceTemplate' {} VoiceTemplateRequest
a -> CreateVoiceTemplate
s {$sel:voiceTemplateRequest:CreateVoiceTemplate' :: VoiceTemplateRequest
voiceTemplateRequest = VoiceTemplateRequest
a} :: CreateVoiceTemplate)

instance Core.AWSRequest CreateVoiceTemplate where
  type
    AWSResponse CreateVoiceTemplate =
      CreateVoiceTemplateResponse
  request :: CreateVoiceTemplate -> Request CreateVoiceTemplate
request = Service -> CreateVoiceTemplate -> Request CreateVoiceTemplate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateVoiceTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateVoiceTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateVoiceTemplate))
-> Logger
-> Service
-> Proxy CreateVoiceTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateVoiceTemplate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> CreateTemplateMessageBody -> CreateVoiceTemplateResponse
CreateVoiceTemplateResponse'
            (Int -> CreateTemplateMessageBody -> CreateVoiceTemplateResponse)
-> Either String Int
-> Either
     String (CreateTemplateMessageBody -> CreateVoiceTemplateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String (CreateTemplateMessageBody -> CreateVoiceTemplateResponse)
-> Either String CreateTemplateMessageBody
-> Either String CreateVoiceTemplateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String CreateTemplateMessageBody
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable CreateVoiceTemplate

instance Prelude.NFData CreateVoiceTemplate

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

instance Core.ToJSON CreateVoiceTemplate where
  toJSON :: CreateVoiceTemplate -> Value
toJSON CreateVoiceTemplate' {Text
VoiceTemplateRequest
voiceTemplateRequest :: VoiceTemplateRequest
templateName :: Text
$sel:voiceTemplateRequest:CreateVoiceTemplate' :: CreateVoiceTemplate -> VoiceTemplateRequest
$sel:templateName:CreateVoiceTemplate' :: CreateVoiceTemplate -> Text
..} =
    [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
"VoiceTemplateRequest"
                  Text -> VoiceTemplateRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= VoiceTemplateRequest
voiceTemplateRequest
              )
          ]
      )

instance Core.ToPath CreateVoiceTemplate where
  toPath :: CreateVoiceTemplate -> ByteString
toPath CreateVoiceTemplate' {Text
VoiceTemplateRequest
voiceTemplateRequest :: VoiceTemplateRequest
templateName :: Text
$sel:voiceTemplateRequest:CreateVoiceTemplate' :: CreateVoiceTemplate -> VoiceTemplateRequest
$sel:templateName:CreateVoiceTemplate' :: CreateVoiceTemplate -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/templates/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
templateName, ByteString
"/voice"]

instance Core.ToQuery CreateVoiceTemplate where
  toQuery :: CreateVoiceTemplate -> QueryString
toQuery = QueryString -> CreateVoiceTemplate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'CreateVoiceTemplateResponse' 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', 'createVoiceTemplateResponse_httpStatus' - The response's http status code.
--
-- 'createTemplateMessageBody', 'createVoiceTemplateResponse_createTemplateMessageBody' - Undocumented member.
newCreateVoiceTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'createTemplateMessageBody'
  CreateTemplateMessageBody ->
  CreateVoiceTemplateResponse
newCreateVoiceTemplateResponse :: Int -> CreateTemplateMessageBody -> CreateVoiceTemplateResponse
newCreateVoiceTemplateResponse
  Int
pHttpStatus_
  CreateTemplateMessageBody
pCreateTemplateMessageBody_ =
    CreateVoiceTemplateResponse' :: Int -> CreateTemplateMessageBody -> CreateVoiceTemplateResponse
CreateVoiceTemplateResponse'
      { $sel:httpStatus:CreateVoiceTemplateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:createTemplateMessageBody:CreateVoiceTemplateResponse' :: CreateTemplateMessageBody
createTemplateMessageBody =
          CreateTemplateMessageBody
pCreateTemplateMessageBody_
      }

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

-- | Undocumented member.
createVoiceTemplateResponse_createTemplateMessageBody :: Lens.Lens' CreateVoiceTemplateResponse CreateTemplateMessageBody
createVoiceTemplateResponse_createTemplateMessageBody :: (CreateTemplateMessageBody -> f CreateTemplateMessageBody)
-> CreateVoiceTemplateResponse -> f CreateVoiceTemplateResponse
createVoiceTemplateResponse_createTemplateMessageBody = (CreateVoiceTemplateResponse -> CreateTemplateMessageBody)
-> (CreateVoiceTemplateResponse
    -> CreateTemplateMessageBody -> CreateVoiceTemplateResponse)
-> Lens
     CreateVoiceTemplateResponse
     CreateVoiceTemplateResponse
     CreateTemplateMessageBody
     CreateTemplateMessageBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVoiceTemplateResponse' {CreateTemplateMessageBody
createTemplateMessageBody :: CreateTemplateMessageBody
$sel:createTemplateMessageBody:CreateVoiceTemplateResponse' :: CreateVoiceTemplateResponse -> CreateTemplateMessageBody
createTemplateMessageBody} -> CreateTemplateMessageBody
createTemplateMessageBody) (\s :: CreateVoiceTemplateResponse
s@CreateVoiceTemplateResponse' {} CreateTemplateMessageBody
a -> CreateVoiceTemplateResponse
s {$sel:createTemplateMessageBody:CreateVoiceTemplateResponse' :: CreateTemplateMessageBody
createTemplateMessageBody = CreateTemplateMessageBody
a} :: CreateVoiceTemplateResponse)

instance Prelude.NFData CreateVoiceTemplateResponse