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

    -- * Request Lenses
    updateBaiduChannel_applicationId,
    updateBaiduChannel_baiduChannelRequest,

    -- * Destructuring the Response
    UpdateBaiduChannelResponse (..),
    newUpdateBaiduChannelResponse,

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

-- |
-- Create a value of 'UpdateBaiduChannel' 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', 'updateBaiduChannel_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'baiduChannelRequest', 'updateBaiduChannel_baiduChannelRequest' - Undocumented member.
newUpdateBaiduChannel ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'baiduChannelRequest'
  BaiduChannelRequest ->
  UpdateBaiduChannel
newUpdateBaiduChannel :: Text -> BaiduChannelRequest -> UpdateBaiduChannel
newUpdateBaiduChannel
  Text
pApplicationId_
  BaiduChannelRequest
pBaiduChannelRequest_ =
    UpdateBaiduChannel'
      { $sel:applicationId:UpdateBaiduChannel' :: Text
applicationId =
          Text
pApplicationId_,
        $sel:baiduChannelRequest:UpdateBaiduChannel' :: BaiduChannelRequest
baiduChannelRequest = BaiduChannelRequest
pBaiduChannelRequest_
      }

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

-- | Undocumented member.
updateBaiduChannel_baiduChannelRequest :: Lens.Lens' UpdateBaiduChannel BaiduChannelRequest
updateBaiduChannel_baiduChannelRequest :: Lens' UpdateBaiduChannel BaiduChannelRequest
updateBaiduChannel_baiduChannelRequest = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBaiduChannel' {BaiduChannelRequest
baiduChannelRequest :: BaiduChannelRequest
$sel:baiduChannelRequest:UpdateBaiduChannel' :: UpdateBaiduChannel -> BaiduChannelRequest
baiduChannelRequest} -> BaiduChannelRequest
baiduChannelRequest) (\s :: UpdateBaiduChannel
s@UpdateBaiduChannel' {} BaiduChannelRequest
a -> UpdateBaiduChannel
s {$sel:baiduChannelRequest:UpdateBaiduChannel' :: BaiduChannelRequest
baiduChannelRequest = BaiduChannelRequest
a} :: UpdateBaiduChannel)

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

instance Prelude.NFData UpdateBaiduChannel where
  rnf :: UpdateBaiduChannel -> ()
rnf UpdateBaiduChannel' {Text
BaiduChannelRequest
baiduChannelRequest :: BaiduChannelRequest
applicationId :: Text
$sel:baiduChannelRequest:UpdateBaiduChannel' :: UpdateBaiduChannel -> BaiduChannelRequest
$sel:applicationId:UpdateBaiduChannel' :: UpdateBaiduChannel -> 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 BaiduChannelRequest
baiduChannelRequest

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

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

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

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

-- |
-- Create a value of 'UpdateBaiduChannelResponse' 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', 'updateBaiduChannelResponse_httpStatus' - The response's http status code.
--
-- 'baiduChannelResponse', 'updateBaiduChannelResponse_baiduChannelResponse' - Undocumented member.
newUpdateBaiduChannelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'baiduChannelResponse'
  BaiduChannelResponse ->
  UpdateBaiduChannelResponse
newUpdateBaiduChannelResponse :: Int -> BaiduChannelResponse -> UpdateBaiduChannelResponse
newUpdateBaiduChannelResponse
  Int
pHttpStatus_
  BaiduChannelResponse
pBaiduChannelResponse_ =
    UpdateBaiduChannelResponse'
      { $sel:httpStatus:UpdateBaiduChannelResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:baiduChannelResponse:UpdateBaiduChannelResponse' :: BaiduChannelResponse
baiduChannelResponse = BaiduChannelResponse
pBaiduChannelResponse_
      }

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

-- | Undocumented member.
updateBaiduChannelResponse_baiduChannelResponse :: Lens.Lens' UpdateBaiduChannelResponse BaiduChannelResponse
updateBaiduChannelResponse_baiduChannelResponse :: Lens' UpdateBaiduChannelResponse BaiduChannelResponse
updateBaiduChannelResponse_baiduChannelResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateBaiduChannelResponse' {BaiduChannelResponse
baiduChannelResponse :: BaiduChannelResponse
$sel:baiduChannelResponse:UpdateBaiduChannelResponse' :: UpdateBaiduChannelResponse -> BaiduChannelResponse
baiduChannelResponse} -> BaiduChannelResponse
baiduChannelResponse) (\s :: UpdateBaiduChannelResponse
s@UpdateBaiduChannelResponse' {} BaiduChannelResponse
a -> UpdateBaiduChannelResponse
s {$sel:baiduChannelResponse:UpdateBaiduChannelResponse' :: BaiduChannelResponse
baiduChannelResponse = BaiduChannelResponse
a} :: UpdateBaiduChannelResponse)

instance Prelude.NFData UpdateBaiduChannelResponse where
  rnf :: UpdateBaiduChannelResponse -> ()
rnf UpdateBaiduChannelResponse' {Int
BaiduChannelResponse
baiduChannelResponse :: BaiduChannelResponse
httpStatus :: Int
$sel:baiduChannelResponse:UpdateBaiduChannelResponse' :: UpdateBaiduChannelResponse -> BaiduChannelResponse
$sel:httpStatus:UpdateBaiduChannelResponse' :: UpdateBaiduChannelResponse -> 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 BaiduChannelResponse
baiduChannelResponse