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

instance Prelude.Hashable UpdateBaiduChannel

instance Prelude.NFData UpdateBaiduChannel

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

instance Core.ToPath UpdateBaiduChannel where
  toPath :: UpdateBaiduChannel -> ByteString
toPath UpdateBaiduChannel' {Text
BaiduChannelRequest
baiduChannelRequest :: BaiduChannelRequest
applicationId :: Text
$sel:baiduChannelRequest:UpdateBaiduChannel' :: UpdateBaiduChannel -> BaiduChannelRequest
$sel:applicationId:UpdateBaiduChannel' :: UpdateBaiduChannel -> 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/baidu"
      ]

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