{-# 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.GetEmailChannel
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves information about the status and settings of the email channel
-- for an application.
module Amazonka.Pinpoint.GetEmailChannel
  ( -- * Creating a Request
    GetEmailChannel (..),
    newGetEmailChannel,

    -- * Request Lenses
    getEmailChannel_applicationId,

    -- * Destructuring the Response
    GetEmailChannelResponse (..),
    newGetEmailChannelResponse,

    -- * Response Lenses
    getEmailChannelResponse_httpStatus,
    getEmailChannelResponse_emailChannelResponse,
  )
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:/ 'newGetEmailChannel' smart constructor.
data GetEmailChannel = GetEmailChannel'
  { -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    GetEmailChannel -> Text
applicationId :: Prelude.Text
  }
  deriving (GetEmailChannel -> GetEmailChannel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEmailChannel -> GetEmailChannel -> Bool
$c/= :: GetEmailChannel -> GetEmailChannel -> Bool
== :: GetEmailChannel -> GetEmailChannel -> Bool
$c== :: GetEmailChannel -> GetEmailChannel -> Bool
Prelude.Eq, ReadPrec [GetEmailChannel]
ReadPrec GetEmailChannel
Int -> ReadS GetEmailChannel
ReadS [GetEmailChannel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEmailChannel]
$creadListPrec :: ReadPrec [GetEmailChannel]
readPrec :: ReadPrec GetEmailChannel
$creadPrec :: ReadPrec GetEmailChannel
readList :: ReadS [GetEmailChannel]
$creadList :: ReadS [GetEmailChannel]
readsPrec :: Int -> ReadS GetEmailChannel
$creadsPrec :: Int -> ReadS GetEmailChannel
Prelude.Read, Int -> GetEmailChannel -> ShowS
[GetEmailChannel] -> ShowS
GetEmailChannel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEmailChannel] -> ShowS
$cshowList :: [GetEmailChannel] -> ShowS
show :: GetEmailChannel -> String
$cshow :: GetEmailChannel -> String
showsPrec :: Int -> GetEmailChannel -> ShowS
$cshowsPrec :: Int -> GetEmailChannel -> ShowS
Prelude.Show, forall x. Rep GetEmailChannel x -> GetEmailChannel
forall x. GetEmailChannel -> Rep GetEmailChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEmailChannel x -> GetEmailChannel
$cfrom :: forall x. GetEmailChannel -> Rep GetEmailChannel x
Prelude.Generic)

-- |
-- Create a value of 'GetEmailChannel' 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:
--
-- 'applicationId', 'getEmailChannel_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newGetEmailChannel ::
  -- | 'applicationId'
  Prelude.Text ->
  GetEmailChannel
newGetEmailChannel :: Text -> GetEmailChannel
newGetEmailChannel Text
pApplicationId_ =
  GetEmailChannel' {$sel:applicationId:GetEmailChannel' :: Text
applicationId = Text
pApplicationId_}

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
getEmailChannel_applicationId :: Lens.Lens' GetEmailChannel Prelude.Text
getEmailChannel_applicationId :: Lens' GetEmailChannel Text
getEmailChannel_applicationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEmailChannel' {Text
applicationId :: Text
$sel:applicationId:GetEmailChannel' :: GetEmailChannel -> Text
applicationId} -> Text
applicationId) (\s :: GetEmailChannel
s@GetEmailChannel' {} Text
a -> GetEmailChannel
s {$sel:applicationId:GetEmailChannel' :: Text
applicationId = Text
a} :: GetEmailChannel)

instance Core.AWSRequest GetEmailChannel where
  type
    AWSResponse GetEmailChannel =
      GetEmailChannelResponse
  request :: (Service -> Service) -> GetEmailChannel -> Request GetEmailChannel
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetEmailChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEmailChannel)))
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 -> EmailChannelResponse -> GetEmailChannelResponse
GetEmailChannelResponse'
            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 GetEmailChannel where
  hashWithSalt :: Int -> GetEmailChannel -> Int
hashWithSalt Int
_salt GetEmailChannel' {Text
applicationId :: Text
$sel:applicationId:GetEmailChannel' :: GetEmailChannel -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId

instance Prelude.NFData GetEmailChannel where
  rnf :: GetEmailChannel -> ()
rnf GetEmailChannel' {Text
applicationId :: Text
$sel:applicationId:GetEmailChannel' :: GetEmailChannel -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId

instance Data.ToHeaders GetEmailChannel where
  toHeaders :: GetEmailChannel -> 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 GetEmailChannel where
  toPath :: GetEmailChannel -> ByteString
toPath GetEmailChannel' {Text
applicationId :: Text
$sel:applicationId:GetEmailChannel' :: GetEmailChannel -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apps/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
applicationId,
        ByteString
"/channels/email"
      ]

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

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

-- |
-- Create a value of 'GetEmailChannelResponse' 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', 'getEmailChannelResponse_httpStatus' - The response's http status code.
--
-- 'emailChannelResponse', 'getEmailChannelResponse_emailChannelResponse' - Undocumented member.
newGetEmailChannelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'emailChannelResponse'
  EmailChannelResponse ->
  GetEmailChannelResponse
newGetEmailChannelResponse :: Int -> EmailChannelResponse -> GetEmailChannelResponse
newGetEmailChannelResponse
  Int
pHttpStatus_
  EmailChannelResponse
pEmailChannelResponse_ =
    GetEmailChannelResponse'
      { $sel:httpStatus:GetEmailChannelResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:emailChannelResponse:GetEmailChannelResponse' :: EmailChannelResponse
emailChannelResponse = EmailChannelResponse
pEmailChannelResponse_
      }

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

-- | Undocumented member.
getEmailChannelResponse_emailChannelResponse :: Lens.Lens' GetEmailChannelResponse EmailChannelResponse
getEmailChannelResponse_emailChannelResponse :: Lens' GetEmailChannelResponse EmailChannelResponse
getEmailChannelResponse_emailChannelResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEmailChannelResponse' {EmailChannelResponse
emailChannelResponse :: EmailChannelResponse
$sel:emailChannelResponse:GetEmailChannelResponse' :: GetEmailChannelResponse -> EmailChannelResponse
emailChannelResponse} -> EmailChannelResponse
emailChannelResponse) (\s :: GetEmailChannelResponse
s@GetEmailChannelResponse' {} EmailChannelResponse
a -> GetEmailChannelResponse
s {$sel:emailChannelResponse:GetEmailChannelResponse' :: EmailChannelResponse
emailChannelResponse = EmailChannelResponse
a} :: GetEmailChannelResponse)

instance Prelude.NFData GetEmailChannelResponse where
  rnf :: GetEmailChannelResponse -> ()
rnf GetEmailChannelResponse' {Int
EmailChannelResponse
emailChannelResponse :: EmailChannelResponse
httpStatus :: Int
$sel:emailChannelResponse:GetEmailChannelResponse' :: GetEmailChannelResponse -> EmailChannelResponse
$sel:httpStatus:GetEmailChannelResponse' :: GetEmailChannelResponse -> 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 EmailChannelResponse
emailChannelResponse