{-# 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.UpdateApnsChannel
-- 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 APNs channel for an application or updates the status and
-- settings of the APNs channel for an application.
module Amazonka.Pinpoint.UpdateApnsChannel
  ( -- * Creating a Request
    UpdateApnsChannel (..),
    newUpdateApnsChannel,

    -- * Request Lenses
    updateApnsChannel_applicationId,
    updateApnsChannel_aPNSChannelRequest,

    -- * Destructuring the Response
    UpdateApnsChannelResponse (..),
    newUpdateApnsChannelResponse,

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

-- |
-- Create a value of 'UpdateApnsChannel' 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', 'updateApnsChannel_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'aPNSChannelRequest', 'updateApnsChannel_aPNSChannelRequest' - Undocumented member.
newUpdateApnsChannel ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'aPNSChannelRequest'
  APNSChannelRequest ->
  UpdateApnsChannel
newUpdateApnsChannel :: Text -> APNSChannelRequest -> UpdateApnsChannel
newUpdateApnsChannel
  Text
pApplicationId_
  APNSChannelRequest
pAPNSChannelRequest_ =
    UpdateApnsChannel'
      { $sel:applicationId:UpdateApnsChannel' :: Text
applicationId = Text
pApplicationId_,
        $sel:aPNSChannelRequest:UpdateApnsChannel' :: APNSChannelRequest
aPNSChannelRequest = APNSChannelRequest
pAPNSChannelRequest_
      }

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

-- | Undocumented member.
updateApnsChannel_aPNSChannelRequest :: Lens.Lens' UpdateApnsChannel APNSChannelRequest
updateApnsChannel_aPNSChannelRequest :: Lens' UpdateApnsChannel APNSChannelRequest
updateApnsChannel_aPNSChannelRequest = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApnsChannel' {APNSChannelRequest
aPNSChannelRequest :: APNSChannelRequest
$sel:aPNSChannelRequest:UpdateApnsChannel' :: UpdateApnsChannel -> APNSChannelRequest
aPNSChannelRequest} -> APNSChannelRequest
aPNSChannelRequest) (\s :: UpdateApnsChannel
s@UpdateApnsChannel' {} APNSChannelRequest
a -> UpdateApnsChannel
s {$sel:aPNSChannelRequest:UpdateApnsChannel' :: APNSChannelRequest
aPNSChannelRequest = APNSChannelRequest
a} :: UpdateApnsChannel)

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

instance Prelude.NFData UpdateApnsChannel where
  rnf :: UpdateApnsChannel -> ()
rnf UpdateApnsChannel' {Text
APNSChannelRequest
aPNSChannelRequest :: APNSChannelRequest
applicationId :: Text
$sel:aPNSChannelRequest:UpdateApnsChannel' :: UpdateApnsChannel -> APNSChannelRequest
$sel:applicationId:UpdateApnsChannel' :: UpdateApnsChannel -> 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 APNSChannelRequest
aPNSChannelRequest

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

instance Data.ToPath UpdateApnsChannel where
  toPath :: UpdateApnsChannel -> ByteString
toPath UpdateApnsChannel' {Text
APNSChannelRequest
aPNSChannelRequest :: APNSChannelRequest
applicationId :: Text
$sel:aPNSChannelRequest:UpdateApnsChannel' :: UpdateApnsChannel -> APNSChannelRequest
$sel:applicationId:UpdateApnsChannel' :: UpdateApnsChannel -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apps/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
applicationId,
        ByteString
"/channels/apns"
      ]

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

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

-- |
-- Create a value of 'UpdateApnsChannelResponse' 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', 'updateApnsChannelResponse_httpStatus' - The response's http status code.
--
-- 'aPNSChannelResponse', 'updateApnsChannelResponse_aPNSChannelResponse' - Undocumented member.
newUpdateApnsChannelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'aPNSChannelResponse'
  APNSChannelResponse ->
  UpdateApnsChannelResponse
newUpdateApnsChannelResponse :: Int -> APNSChannelResponse -> UpdateApnsChannelResponse
newUpdateApnsChannelResponse
  Int
pHttpStatus_
  APNSChannelResponse
pAPNSChannelResponse_ =
    UpdateApnsChannelResponse'
      { $sel:httpStatus:UpdateApnsChannelResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:aPNSChannelResponse:UpdateApnsChannelResponse' :: APNSChannelResponse
aPNSChannelResponse = APNSChannelResponse
pAPNSChannelResponse_
      }

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

-- | Undocumented member.
updateApnsChannelResponse_aPNSChannelResponse :: Lens.Lens' UpdateApnsChannelResponse APNSChannelResponse
updateApnsChannelResponse_aPNSChannelResponse :: Lens' UpdateApnsChannelResponse APNSChannelResponse
updateApnsChannelResponse_aPNSChannelResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApnsChannelResponse' {APNSChannelResponse
aPNSChannelResponse :: APNSChannelResponse
$sel:aPNSChannelResponse:UpdateApnsChannelResponse' :: UpdateApnsChannelResponse -> APNSChannelResponse
aPNSChannelResponse} -> APNSChannelResponse
aPNSChannelResponse) (\s :: UpdateApnsChannelResponse
s@UpdateApnsChannelResponse' {} APNSChannelResponse
a -> UpdateApnsChannelResponse
s {$sel:aPNSChannelResponse:UpdateApnsChannelResponse' :: APNSChannelResponse
aPNSChannelResponse = APNSChannelResponse
a} :: UpdateApnsChannelResponse)

instance Prelude.NFData UpdateApnsChannelResponse where
  rnf :: UpdateApnsChannelResponse -> ()
rnf UpdateApnsChannelResponse' {Int
APNSChannelResponse
aPNSChannelResponse :: APNSChannelResponse
httpStatus :: Int
$sel:aPNSChannelResponse:UpdateApnsChannelResponse' :: UpdateApnsChannelResponse -> APNSChannelResponse
$sel:httpStatus:UpdateApnsChannelResponse' :: UpdateApnsChannelResponse -> 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 APNSChannelResponse
aPNSChannelResponse