{-# 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.GetGcmChannel
-- 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 GCM channel
-- for an application.
module Amazonka.Pinpoint.GetGcmChannel
  ( -- * Creating a Request
    GetGcmChannel (..),
    newGetGcmChannel,

    -- * Request Lenses
    getGcmChannel_applicationId,

    -- * Destructuring the Response
    GetGcmChannelResponse (..),
    newGetGcmChannelResponse,

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

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

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

instance Core.AWSRequest GetGcmChannel where
  type
    AWSResponse GetGcmChannel =
      GetGcmChannelResponse
  request :: (Service -> Service) -> GetGcmChannel -> Request GetGcmChannel
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 GetGcmChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetGcmChannel)))
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 -> GCMChannelResponse -> GetGcmChannelResponse
GetGcmChannelResponse'
            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 GetGcmChannel where
  hashWithSalt :: Int -> GetGcmChannel -> Int
hashWithSalt Int
_salt GetGcmChannel' {Text
applicationId :: Text
$sel:applicationId:GetGcmChannel' :: GetGcmChannel -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId

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

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

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

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

-- |
-- Create a value of 'GetGcmChannelResponse' 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', 'getGcmChannelResponse_httpStatus' - The response's http status code.
--
-- 'gCMChannelResponse', 'getGcmChannelResponse_gCMChannelResponse' - Undocumented member.
newGetGcmChannelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'gCMChannelResponse'
  GCMChannelResponse ->
  GetGcmChannelResponse
newGetGcmChannelResponse :: Int -> GCMChannelResponse -> GetGcmChannelResponse
newGetGcmChannelResponse
  Int
pHttpStatus_
  GCMChannelResponse
pGCMChannelResponse_ =
    GetGcmChannelResponse'
      { $sel:httpStatus:GetGcmChannelResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:gCMChannelResponse:GetGcmChannelResponse' :: GCMChannelResponse
gCMChannelResponse = GCMChannelResponse
pGCMChannelResponse_
      }

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

-- | Undocumented member.
getGcmChannelResponse_gCMChannelResponse :: Lens.Lens' GetGcmChannelResponse GCMChannelResponse
getGcmChannelResponse_gCMChannelResponse :: Lens' GetGcmChannelResponse GCMChannelResponse
getGcmChannelResponse_gCMChannelResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGcmChannelResponse' {GCMChannelResponse
gCMChannelResponse :: GCMChannelResponse
$sel:gCMChannelResponse:GetGcmChannelResponse' :: GetGcmChannelResponse -> GCMChannelResponse
gCMChannelResponse} -> GCMChannelResponse
gCMChannelResponse) (\s :: GetGcmChannelResponse
s@GetGcmChannelResponse' {} GCMChannelResponse
a -> GetGcmChannelResponse
s {$sel:gCMChannelResponse:GetGcmChannelResponse' :: GCMChannelResponse
gCMChannelResponse = GCMChannelResponse
a} :: GetGcmChannelResponse)

instance Prelude.NFData GetGcmChannelResponse where
  rnf :: GetGcmChannelResponse -> ()
rnf GetGcmChannelResponse' {Int
GCMChannelResponse
gCMChannelResponse :: GCMChannelResponse
httpStatus :: Int
$sel:gCMChannelResponse:GetGcmChannelResponse' :: GetGcmChannelResponse -> GCMChannelResponse
$sel:httpStatus:GetGcmChannelResponse' :: GetGcmChannelResponse -> 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 GCMChannelResponse
gCMChannelResponse