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

instance Prelude.Hashable GetGcmChannel

instance Prelude.NFData GetGcmChannel

instance Core.ToHeaders GetGcmChannel where
  toHeaders :: GetGcmChannel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetGcmChannel -> 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 GetGcmChannel where
  toPath :: GetGcmChannel -> ByteString
toPath GetGcmChannel' {Text
applicationId :: Text
$sel:applicationId:GetGcmChannel' :: GetGcmChannel -> 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/gcm"
      ]

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