{-# 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-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)
--
-- 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.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:/ '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
(GetEmailChannel -> GetEmailChannel -> Bool)
-> (GetEmailChannel -> GetEmailChannel -> Bool)
-> Eq GetEmailChannel
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]
(Int -> ReadS GetEmailChannel)
-> ReadS [GetEmailChannel]
-> ReadPrec GetEmailChannel
-> ReadPrec [GetEmailChannel]
-> Read 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
(Int -> GetEmailChannel -> ShowS)
-> (GetEmailChannel -> String)
-> ([GetEmailChannel] -> ShowS)
-> Show GetEmailChannel
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. GetEmailChannel -> Rep GetEmailChannel x)
-> (forall x. Rep GetEmailChannel x -> GetEmailChannel)
-> Generic GetEmailChannel
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' :: Text -> GetEmailChannel
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 :: (Text -> f Text) -> GetEmailChannel -> f GetEmailChannel
getEmailChannel_applicationId = (GetEmailChannel -> Text)
-> (GetEmailChannel -> Text -> GetEmailChannel)
-> Lens GetEmailChannel GetEmailChannel Text Text
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 :: GetEmailChannel -> Request GetEmailChannel
request = Service -> GetEmailChannel -> Request GetEmailChannel
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetEmailChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEmailChannel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetEmailChannel))
-> Logger
-> Service
-> Proxy GetEmailChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEmailChannel)))
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 -> EmailChannelResponse -> GetEmailChannelResponse
GetEmailChannelResponse'
            (Int -> EmailChannelResponse -> GetEmailChannelResponse)
-> Either String Int
-> Either String (EmailChannelResponse -> GetEmailChannelResponse)
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 (EmailChannelResponse -> GetEmailChannelResponse)
-> Either String EmailChannelResponse
-> Either String GetEmailChannelResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String EmailChannelResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable GetEmailChannel

instance Prelude.NFData GetEmailChannel

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

instance Core.ToQuery GetEmailChannel where
  toQuery :: GetEmailChannel -> QueryString
toQuery = QueryString -> GetEmailChannel -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetEmailChannelResponse -> GetEmailChannelResponse -> Bool)
-> (GetEmailChannelResponse -> GetEmailChannelResponse -> Bool)
-> Eq GetEmailChannelResponse
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]
(Int -> ReadS GetEmailChannelResponse)
-> ReadS [GetEmailChannelResponse]
-> ReadPrec GetEmailChannelResponse
-> ReadPrec [GetEmailChannelResponse]
-> Read 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
(Int -> GetEmailChannelResponse -> ShowS)
-> (GetEmailChannelResponse -> String)
-> ([GetEmailChannelResponse] -> ShowS)
-> Show GetEmailChannelResponse
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.
 GetEmailChannelResponse -> Rep GetEmailChannelResponse x)
-> (forall x.
    Rep GetEmailChannelResponse x -> GetEmailChannelResponse)
-> Generic GetEmailChannelResponse
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' :: Int -> EmailChannelResponse -> GetEmailChannelResponse
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 :: (Int -> f Int)
-> GetEmailChannelResponse -> f GetEmailChannelResponse
getEmailChannelResponse_httpStatus = (GetEmailChannelResponse -> Int)
-> (GetEmailChannelResponse -> Int -> GetEmailChannelResponse)
-> Lens GetEmailChannelResponse GetEmailChannelResponse Int Int
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 :: (EmailChannelResponse -> f EmailChannelResponse)
-> GetEmailChannelResponse -> f GetEmailChannelResponse
getEmailChannelResponse_emailChannelResponse = (GetEmailChannelResponse -> EmailChannelResponse)
-> (GetEmailChannelResponse
    -> EmailChannelResponse -> GetEmailChannelResponse)
-> Lens
     GetEmailChannelResponse
     GetEmailChannelResponse
     EmailChannelResponse
     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