{-# 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-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)
--
-- 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.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:/ '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
(UpdateGcmChannel -> UpdateGcmChannel -> Bool)
-> (UpdateGcmChannel -> UpdateGcmChannel -> Bool)
-> Eq UpdateGcmChannel
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]
(Int -> ReadS UpdateGcmChannel)
-> ReadS [UpdateGcmChannel]
-> ReadPrec UpdateGcmChannel
-> ReadPrec [UpdateGcmChannel]
-> Read 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
(Int -> UpdateGcmChannel -> ShowS)
-> (UpdateGcmChannel -> String)
-> ([UpdateGcmChannel] -> ShowS)
-> Show UpdateGcmChannel
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. UpdateGcmChannel -> Rep UpdateGcmChannel x)
-> (forall x. Rep UpdateGcmChannel x -> UpdateGcmChannel)
-> Generic UpdateGcmChannel
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' :: Text -> GCMChannelRequest -> UpdateGcmChannel
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 :: (Text -> f Text) -> UpdateGcmChannel -> f UpdateGcmChannel
updateGcmChannel_applicationId = (UpdateGcmChannel -> Text)
-> (UpdateGcmChannel -> Text -> UpdateGcmChannel)
-> Lens UpdateGcmChannel UpdateGcmChannel Text Text
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 :: (GCMChannelRequest -> f GCMChannelRequest)
-> UpdateGcmChannel -> f UpdateGcmChannel
updateGcmChannel_gCMChannelRequest = (UpdateGcmChannel -> GCMChannelRequest)
-> (UpdateGcmChannel -> GCMChannelRequest -> UpdateGcmChannel)
-> Lens
     UpdateGcmChannel
     UpdateGcmChannel
     GCMChannelRequest
     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 :: UpdateGcmChannel -> Request UpdateGcmChannel
request = Service -> UpdateGcmChannel -> Request UpdateGcmChannel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateGcmChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateGcmChannel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateGcmChannel))
-> Logger
-> Service
-> Proxy UpdateGcmChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateGcmChannel)))
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 -> UpdateGcmChannelResponse
UpdateGcmChannelResponse'
            (Int -> GCMChannelResponse -> UpdateGcmChannelResponse)
-> Either String Int
-> Either String (GCMChannelResponse -> UpdateGcmChannelResponse)
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 -> UpdateGcmChannelResponse)
-> Either String GCMChannelResponse
-> Either String UpdateGcmChannelResponse
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 UpdateGcmChannel

instance Prelude.NFData UpdateGcmChannel

instance Core.ToHeaders UpdateGcmChannel where
  toHeaders :: UpdateGcmChannel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateGcmChannel -> 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.ToJSON UpdateGcmChannel where
  toJSON :: UpdateGcmChannel -> Value
toJSON UpdateGcmChannel' {Text
GCMChannelRequest
gCMChannelRequest :: GCMChannelRequest
applicationId :: Text
$sel:gCMChannelRequest:UpdateGcmChannel' :: UpdateGcmChannel -> GCMChannelRequest
$sel:applicationId:UpdateGcmChannel' :: UpdateGcmChannel -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"GCMChannelRequest" Text -> GCMChannelRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= GCMChannelRequest
gCMChannelRequest)
          ]
      )

instance Core.ToPath UpdateGcmChannel where
  toPath :: UpdateGcmChannel -> ByteString
toPath UpdateGcmChannel' {Text
GCMChannelRequest
gCMChannelRequest :: GCMChannelRequest
applicationId :: Text
$sel:gCMChannelRequest:UpdateGcmChannel' :: UpdateGcmChannel -> GCMChannelRequest
$sel:applicationId:UpdateGcmChannel' :: UpdateGcmChannel -> 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 UpdateGcmChannel where
  toQuery :: UpdateGcmChannel -> QueryString
toQuery = QueryString -> UpdateGcmChannel -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateGcmChannelResponse -> UpdateGcmChannelResponse -> Bool)
-> (UpdateGcmChannelResponse -> UpdateGcmChannelResponse -> Bool)
-> Eq UpdateGcmChannelResponse
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]
(Int -> ReadS UpdateGcmChannelResponse)
-> ReadS [UpdateGcmChannelResponse]
-> ReadPrec UpdateGcmChannelResponse
-> ReadPrec [UpdateGcmChannelResponse]
-> Read 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
(Int -> UpdateGcmChannelResponse -> ShowS)
-> (UpdateGcmChannelResponse -> String)
-> ([UpdateGcmChannelResponse] -> ShowS)
-> Show UpdateGcmChannelResponse
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.
 UpdateGcmChannelResponse -> Rep UpdateGcmChannelResponse x)
-> (forall x.
    Rep UpdateGcmChannelResponse x -> UpdateGcmChannelResponse)
-> Generic UpdateGcmChannelResponse
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' :: Int -> GCMChannelResponse -> UpdateGcmChannelResponse
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 :: (Int -> f Int)
-> UpdateGcmChannelResponse -> f UpdateGcmChannelResponse
updateGcmChannelResponse_httpStatus = (UpdateGcmChannelResponse -> Int)
-> (UpdateGcmChannelResponse -> Int -> UpdateGcmChannelResponse)
-> Lens UpdateGcmChannelResponse UpdateGcmChannelResponse Int Int
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 :: (GCMChannelResponse -> f GCMChannelResponse)
-> UpdateGcmChannelResponse -> f UpdateGcmChannelResponse
updateGcmChannelResponse_gCMChannelResponse = (UpdateGcmChannelResponse -> GCMChannelResponse)
-> (UpdateGcmChannelResponse
    -> GCMChannelResponse -> UpdateGcmChannelResponse)
-> Lens
     UpdateGcmChannelResponse
     UpdateGcmChannelResponse
     GCMChannelResponse
     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