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

    -- * Request Lenses
    updateGcmChannel_applicationId,
    updateGcmChannel_gCMChannelRequest,

    -- * Destructuring the Response
    UpdateGcmChannelResponse (..),
    newUpdateGcmChannelResponse,

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

-- |
-- Create a value of 'UpdateGcmChannel' 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', 'updateGcmChannel_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'gCMChannelRequest', 'updateGcmChannel_gCMChannelRequest' - Undocumented member.
newUpdateGcmChannel ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'gCMChannelRequest'
  GCMChannelRequest ->
  UpdateGcmChannel
newUpdateGcmChannel :: Text -> GCMChannelRequest -> UpdateGcmChannel
newUpdateGcmChannel
  Text
pApplicationId_
  GCMChannelRequest
pGCMChannelRequest_ =
    UpdateGcmChannel'
      { $sel:applicationId:UpdateGcmChannel' :: Text
applicationId = Text
pApplicationId_,
        $sel:gCMChannelRequest:UpdateGcmChannel' :: GCMChannelRequest
gCMChannelRequest = GCMChannelRequest
pGCMChannelRequest_
      }

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

-- | Undocumented member.
updateGcmChannel_gCMChannelRequest :: Lens.Lens' UpdateGcmChannel GCMChannelRequest
updateGcmChannel_gCMChannelRequest :: Lens' UpdateGcmChannel GCMChannelRequest
updateGcmChannel_gCMChannelRequest = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGcmChannel' {GCMChannelRequest
gCMChannelRequest :: GCMChannelRequest
$sel:gCMChannelRequest:UpdateGcmChannel' :: UpdateGcmChannel -> GCMChannelRequest
gCMChannelRequest} -> GCMChannelRequest
gCMChannelRequest) (\s :: UpdateGcmChannel
s@UpdateGcmChannel' {} GCMChannelRequest
a -> UpdateGcmChannel
s {$sel:gCMChannelRequest:UpdateGcmChannel' :: GCMChannelRequest
gCMChannelRequest = GCMChannelRequest
a} :: UpdateGcmChannel)

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

instance Prelude.NFData UpdateGcmChannel where
  rnf :: UpdateGcmChannel -> ()
rnf UpdateGcmChannel' {Text
GCMChannelRequest
gCMChannelRequest :: GCMChannelRequest
applicationId :: Text
$sel:gCMChannelRequest:UpdateGcmChannel' :: UpdateGcmChannel -> GCMChannelRequest
$sel:applicationId:UpdateGcmChannel' :: UpdateGcmChannel -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf GCMChannelRequest
gCMChannelRequest

instance Data.ToHeaders UpdateGcmChannel where
  toHeaders :: UpdateGcmChannel -> 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.ToJSON UpdateGcmChannel where
  toJSON :: UpdateGcmChannel -> Value
toJSON UpdateGcmChannel' {Text
GCMChannelRequest
gCMChannelRequest :: GCMChannelRequest
applicationId :: Text
$sel:gCMChannelRequest:UpdateGcmChannel' :: UpdateGcmChannel -> GCMChannelRequest
$sel:applicationId:UpdateGcmChannel' :: UpdateGcmChannel -> Text
..} =
    forall a. ToJSON a => a -> Value
Data.toJSON GCMChannelRequest
gCMChannelRequest

instance Data.ToPath UpdateGcmChannel where
  toPath :: UpdateGcmChannel -> ByteString
toPath UpdateGcmChannel' {Text
GCMChannelRequest
gCMChannelRequest :: GCMChannelRequest
applicationId :: Text
$sel:gCMChannelRequest:UpdateGcmChannel' :: UpdateGcmChannel -> GCMChannelRequest
$sel:applicationId:UpdateGcmChannel' :: UpdateGcmChannel -> 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 UpdateGcmChannel where
  toQuery :: UpdateGcmChannel -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

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

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

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

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