{-# 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.CodeGuruReviewer.PutRecommendationFeedback
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stores customer feedback for a CodeGuru Reviewer recommendation. When
-- this API is called again with different reactions the previous feedback
-- is overwritten.
module Amazonka.CodeGuruReviewer.PutRecommendationFeedback
  ( -- * Creating a Request
    PutRecommendationFeedback (..),
    newPutRecommendationFeedback,

    -- * Request Lenses
    putRecommendationFeedback_codeReviewArn,
    putRecommendationFeedback_recommendationId,
    putRecommendationFeedback_reactions,

    -- * Destructuring the Response
    PutRecommendationFeedbackResponse (..),
    newPutRecommendationFeedbackResponse,

    -- * Response Lenses
    putRecommendationFeedbackResponse_httpStatus,
  )
where

import Amazonka.CodeGuruReviewer.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPutRecommendationFeedback' smart constructor.
data PutRecommendationFeedback = PutRecommendationFeedback'
  { -- | The Amazon Resource Name (ARN) of the
    -- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CodeReview.html CodeReview>
    -- object.
    PutRecommendationFeedback -> Text
codeReviewArn :: Prelude.Text,
    -- | The recommendation ID that can be used to track the provided
    -- recommendations and then to collect the feedback.
    PutRecommendationFeedback -> Text
recommendationId :: Prelude.Text,
    -- | List for storing reactions. Reactions are utf-8 text code for emojis. If
    -- you send an empty list it clears all your feedback.
    PutRecommendationFeedback -> [Reaction]
reactions :: [Reaction]
  }
  deriving (PutRecommendationFeedback -> PutRecommendationFeedback -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRecommendationFeedback -> PutRecommendationFeedback -> Bool
$c/= :: PutRecommendationFeedback -> PutRecommendationFeedback -> Bool
== :: PutRecommendationFeedback -> PutRecommendationFeedback -> Bool
$c== :: PutRecommendationFeedback -> PutRecommendationFeedback -> Bool
Prelude.Eq, ReadPrec [PutRecommendationFeedback]
ReadPrec PutRecommendationFeedback
Int -> ReadS PutRecommendationFeedback
ReadS [PutRecommendationFeedback]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRecommendationFeedback]
$creadListPrec :: ReadPrec [PutRecommendationFeedback]
readPrec :: ReadPrec PutRecommendationFeedback
$creadPrec :: ReadPrec PutRecommendationFeedback
readList :: ReadS [PutRecommendationFeedback]
$creadList :: ReadS [PutRecommendationFeedback]
readsPrec :: Int -> ReadS PutRecommendationFeedback
$creadsPrec :: Int -> ReadS PutRecommendationFeedback
Prelude.Read, Int -> PutRecommendationFeedback -> ShowS
[PutRecommendationFeedback] -> ShowS
PutRecommendationFeedback -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRecommendationFeedback] -> ShowS
$cshowList :: [PutRecommendationFeedback] -> ShowS
show :: PutRecommendationFeedback -> String
$cshow :: PutRecommendationFeedback -> String
showsPrec :: Int -> PutRecommendationFeedback -> ShowS
$cshowsPrec :: Int -> PutRecommendationFeedback -> ShowS
Prelude.Show, forall x.
Rep PutRecommendationFeedback x -> PutRecommendationFeedback
forall x.
PutRecommendationFeedback -> Rep PutRecommendationFeedback x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutRecommendationFeedback x -> PutRecommendationFeedback
$cfrom :: forall x.
PutRecommendationFeedback -> Rep PutRecommendationFeedback x
Prelude.Generic)

-- |
-- Create a value of 'PutRecommendationFeedback' 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:
--
-- 'codeReviewArn', 'putRecommendationFeedback_codeReviewArn' - The Amazon Resource Name (ARN) of the
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CodeReview.html CodeReview>
-- object.
--
-- 'recommendationId', 'putRecommendationFeedback_recommendationId' - The recommendation ID that can be used to track the provided
-- recommendations and then to collect the feedback.
--
-- 'reactions', 'putRecommendationFeedback_reactions' - List for storing reactions. Reactions are utf-8 text code for emojis. If
-- you send an empty list it clears all your feedback.
newPutRecommendationFeedback ::
  -- | 'codeReviewArn'
  Prelude.Text ->
  -- | 'recommendationId'
  Prelude.Text ->
  PutRecommendationFeedback
newPutRecommendationFeedback :: Text -> Text -> PutRecommendationFeedback
newPutRecommendationFeedback
  Text
pCodeReviewArn_
  Text
pRecommendationId_ =
    PutRecommendationFeedback'
      { $sel:codeReviewArn:PutRecommendationFeedback' :: Text
codeReviewArn =
          Text
pCodeReviewArn_,
        $sel:recommendationId:PutRecommendationFeedback' :: Text
recommendationId = Text
pRecommendationId_,
        $sel:reactions:PutRecommendationFeedback' :: [Reaction]
reactions = forall a. Monoid a => a
Prelude.mempty
      }

-- | The Amazon Resource Name (ARN) of the
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CodeReview.html CodeReview>
-- object.
putRecommendationFeedback_codeReviewArn :: Lens.Lens' PutRecommendationFeedback Prelude.Text
putRecommendationFeedback_codeReviewArn :: Lens' PutRecommendationFeedback Text
putRecommendationFeedback_codeReviewArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecommendationFeedback' {Text
codeReviewArn :: Text
$sel:codeReviewArn:PutRecommendationFeedback' :: PutRecommendationFeedback -> Text
codeReviewArn} -> Text
codeReviewArn) (\s :: PutRecommendationFeedback
s@PutRecommendationFeedback' {} Text
a -> PutRecommendationFeedback
s {$sel:codeReviewArn:PutRecommendationFeedback' :: Text
codeReviewArn = Text
a} :: PutRecommendationFeedback)

-- | The recommendation ID that can be used to track the provided
-- recommendations and then to collect the feedback.
putRecommendationFeedback_recommendationId :: Lens.Lens' PutRecommendationFeedback Prelude.Text
putRecommendationFeedback_recommendationId :: Lens' PutRecommendationFeedback Text
putRecommendationFeedback_recommendationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecommendationFeedback' {Text
recommendationId :: Text
$sel:recommendationId:PutRecommendationFeedback' :: PutRecommendationFeedback -> Text
recommendationId} -> Text
recommendationId) (\s :: PutRecommendationFeedback
s@PutRecommendationFeedback' {} Text
a -> PutRecommendationFeedback
s {$sel:recommendationId:PutRecommendationFeedback' :: Text
recommendationId = Text
a} :: PutRecommendationFeedback)

-- | List for storing reactions. Reactions are utf-8 text code for emojis. If
-- you send an empty list it clears all your feedback.
putRecommendationFeedback_reactions :: Lens.Lens' PutRecommendationFeedback [Reaction]
putRecommendationFeedback_reactions :: Lens' PutRecommendationFeedback [Reaction]
putRecommendationFeedback_reactions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRecommendationFeedback' {[Reaction]
reactions :: [Reaction]
$sel:reactions:PutRecommendationFeedback' :: PutRecommendationFeedback -> [Reaction]
reactions} -> [Reaction]
reactions) (\s :: PutRecommendationFeedback
s@PutRecommendationFeedback' {} [Reaction]
a -> PutRecommendationFeedback
s {$sel:reactions:PutRecommendationFeedback' :: [Reaction]
reactions = [Reaction]
a} :: PutRecommendationFeedback) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest PutRecommendationFeedback where
  type
    AWSResponse PutRecommendationFeedback =
      PutRecommendationFeedbackResponse
  request :: (Service -> Service)
-> PutRecommendationFeedback -> Request PutRecommendationFeedback
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 PutRecommendationFeedback
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutRecommendationFeedback)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutRecommendationFeedbackResponse
PutRecommendationFeedbackResponse'
            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))
      )

instance Prelude.Hashable PutRecommendationFeedback where
  hashWithSalt :: Int -> PutRecommendationFeedback -> Int
hashWithSalt Int
_salt PutRecommendationFeedback' {[Reaction]
Text
reactions :: [Reaction]
recommendationId :: Text
codeReviewArn :: Text
$sel:reactions:PutRecommendationFeedback' :: PutRecommendationFeedback -> [Reaction]
$sel:recommendationId:PutRecommendationFeedback' :: PutRecommendationFeedback -> Text
$sel:codeReviewArn:PutRecommendationFeedback' :: PutRecommendationFeedback -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
codeReviewArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
recommendationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Reaction]
reactions

instance Prelude.NFData PutRecommendationFeedback where
  rnf :: PutRecommendationFeedback -> ()
rnf PutRecommendationFeedback' {[Reaction]
Text
reactions :: [Reaction]
recommendationId :: Text
codeReviewArn :: Text
$sel:reactions:PutRecommendationFeedback' :: PutRecommendationFeedback -> [Reaction]
$sel:recommendationId:PutRecommendationFeedback' :: PutRecommendationFeedback -> Text
$sel:codeReviewArn:PutRecommendationFeedback' :: PutRecommendationFeedback -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
codeReviewArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
recommendationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Reaction]
reactions

instance Data.ToHeaders PutRecommendationFeedback where
  toHeaders :: PutRecommendationFeedback -> 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 PutRecommendationFeedback where
  toJSON :: PutRecommendationFeedback -> Value
toJSON PutRecommendationFeedback' {[Reaction]
Text
reactions :: [Reaction]
recommendationId :: Text
codeReviewArn :: Text
$sel:reactions:PutRecommendationFeedback' :: PutRecommendationFeedback -> [Reaction]
$sel:recommendationId:PutRecommendationFeedback' :: PutRecommendationFeedback -> Text
$sel:codeReviewArn:PutRecommendationFeedback' :: PutRecommendationFeedback -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"CodeReviewArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
codeReviewArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"RecommendationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
recommendationId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Reactions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Reaction]
reactions)
          ]
      )

instance Data.ToPath PutRecommendationFeedback where
  toPath :: PutRecommendationFeedback -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/feedback"

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

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

-- |
-- Create a value of 'PutRecommendationFeedbackResponse' 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', 'putRecommendationFeedbackResponse_httpStatus' - The response's http status code.
newPutRecommendationFeedbackResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutRecommendationFeedbackResponse
newPutRecommendationFeedbackResponse :: Int -> PutRecommendationFeedbackResponse
newPutRecommendationFeedbackResponse Int
pHttpStatus_ =
  PutRecommendationFeedbackResponse'
    { $sel:httpStatus:PutRecommendationFeedbackResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    PutRecommendationFeedbackResponse
  where
  rnf :: PutRecommendationFeedbackResponse -> ()
rnf PutRecommendationFeedbackResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutRecommendationFeedbackResponse' :: PutRecommendationFeedbackResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus