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

instance Prelude.Hashable UpdateApnsChannel

instance Prelude.NFData UpdateApnsChannel

instance Core.ToHeaders UpdateApnsChannel where
  toHeaders :: UpdateApnsChannel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateApnsChannel -> 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 UpdateApnsChannel where
  toJSON :: UpdateApnsChannel -> Value
toJSON UpdateApnsChannel' {Text
APNSChannelRequest
aPNSChannelRequest :: APNSChannelRequest
applicationId :: Text
$sel:aPNSChannelRequest:UpdateApnsChannel' :: UpdateApnsChannel -> APNSChannelRequest
$sel:applicationId:UpdateApnsChannel' :: UpdateApnsChannel -> 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
"APNSChannelRequest" Text -> APNSChannelRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= APNSChannelRequest
aPNSChannelRequest)
          ]
      )

instance Core.ToPath UpdateApnsChannel where
  toPath :: UpdateApnsChannel -> ByteString
toPath UpdateApnsChannel' {Text
APNSChannelRequest
aPNSChannelRequest :: APNSChannelRequest
applicationId :: Text
$sel:aPNSChannelRequest:UpdateApnsChannel' :: UpdateApnsChannel -> APNSChannelRequest
$sel:applicationId:UpdateApnsChannel' :: UpdateApnsChannel -> 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/apns"
      ]

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