{-# 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-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)
--
-- 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.Lens as Lens
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
(PutRecommendationFeedback -> PutRecommendationFeedback -> Bool)
-> (PutRecommendationFeedback -> PutRecommendationFeedback -> Bool)
-> Eq PutRecommendationFeedback
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]
(Int -> ReadS PutRecommendationFeedback)
-> ReadS [PutRecommendationFeedback]
-> ReadPrec PutRecommendationFeedback
-> ReadPrec [PutRecommendationFeedback]
-> Read 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
(Int -> PutRecommendationFeedback -> ShowS)
-> (PutRecommendationFeedback -> String)
-> ([PutRecommendationFeedback] -> ShowS)
-> Show PutRecommendationFeedback
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.
 PutRecommendationFeedback -> Rep PutRecommendationFeedback x)
-> (forall x.
    Rep PutRecommendationFeedback x -> PutRecommendationFeedback)
-> Generic PutRecommendationFeedback
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' :: Text -> Text -> [Reaction] -> PutRecommendationFeedback
PutRecommendationFeedback'
      { $sel:codeReviewArn:PutRecommendationFeedback' :: Text
codeReviewArn =
          Text
pCodeReviewArn_,
        $sel:recommendationId:PutRecommendationFeedback' :: Text
recommendationId = Text
pRecommendationId_,
        $sel:reactions:PutRecommendationFeedback' :: [Reaction]
reactions = [Reaction]
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 :: (Text -> f Text)
-> PutRecommendationFeedback -> f PutRecommendationFeedback
putRecommendationFeedback_codeReviewArn = (PutRecommendationFeedback -> Text)
-> (PutRecommendationFeedback -> Text -> PutRecommendationFeedback)
-> Lens
     PutRecommendationFeedback PutRecommendationFeedback Text Text
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 :: (Text -> f Text)
-> PutRecommendationFeedback -> f PutRecommendationFeedback
putRecommendationFeedback_recommendationId = (PutRecommendationFeedback -> Text)
-> (PutRecommendationFeedback -> Text -> PutRecommendationFeedback)
-> Lens
     PutRecommendationFeedback PutRecommendationFeedback Text Text
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 :: ([Reaction] -> f [Reaction])
-> PutRecommendationFeedback -> f PutRecommendationFeedback
putRecommendationFeedback_reactions = (PutRecommendationFeedback -> [Reaction])
-> (PutRecommendationFeedback
    -> [Reaction] -> PutRecommendationFeedback)
-> Lens
     PutRecommendationFeedback
     PutRecommendationFeedback
     [Reaction]
     [Reaction]
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) (([Reaction] -> f [Reaction])
 -> PutRecommendationFeedback -> f PutRecommendationFeedback)
-> (([Reaction] -> f [Reaction]) -> [Reaction] -> f [Reaction])
-> ([Reaction] -> f [Reaction])
-> PutRecommendationFeedback
-> f PutRecommendationFeedback
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Reaction] -> f [Reaction]) -> [Reaction] -> f [Reaction]
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 :: PutRecommendationFeedback -> Request PutRecommendationFeedback
request = Service
-> PutRecommendationFeedback -> Request PutRecommendationFeedback
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutRecommendationFeedback
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutRecommendationFeedback)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutRecommendationFeedback))
-> Logger
-> Service
-> Proxy PutRecommendationFeedback
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutRecommendationFeedback)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutRecommendationFeedbackResponse
PutRecommendationFeedbackResponse'
            (Int -> PutRecommendationFeedbackResponse)
-> Either String Int
-> Either String PutRecommendationFeedbackResponse
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))
      )

instance Prelude.Hashable PutRecommendationFeedback

instance Prelude.NFData PutRecommendationFeedback

instance Core.ToHeaders PutRecommendationFeedback where
  toHeaders :: PutRecommendationFeedback -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutRecommendationFeedback -> 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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CodeReviewArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
codeReviewArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RecommendationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
recommendationId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Reactions" Text -> [Reaction] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Reaction]
reactions)
          ]
      )

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

instance Core.ToQuery PutRecommendationFeedback where
  toQuery :: PutRecommendationFeedback -> QueryString
toQuery = QueryString -> PutRecommendationFeedback -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PutRecommendationFeedbackResponse
 -> PutRecommendationFeedbackResponse -> Bool)
-> (PutRecommendationFeedbackResponse
    -> PutRecommendationFeedbackResponse -> Bool)
-> Eq PutRecommendationFeedbackResponse
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]
(Int -> ReadS PutRecommendationFeedbackResponse)
-> ReadS [PutRecommendationFeedbackResponse]
-> ReadPrec PutRecommendationFeedbackResponse
-> ReadPrec [PutRecommendationFeedbackResponse]
-> Read 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
(Int -> PutRecommendationFeedbackResponse -> ShowS)
-> (PutRecommendationFeedbackResponse -> String)
-> ([PutRecommendationFeedbackResponse] -> ShowS)
-> Show PutRecommendationFeedbackResponse
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.
 PutRecommendationFeedbackResponse
 -> Rep PutRecommendationFeedbackResponse x)
-> (forall x.
    Rep PutRecommendationFeedbackResponse x
    -> PutRecommendationFeedbackResponse)
-> Generic PutRecommendationFeedbackResponse
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' :: Int -> PutRecommendationFeedbackResponse
PutRecommendationFeedbackResponse'
    { $sel:httpStatus:PutRecommendationFeedbackResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
putRecommendationFeedbackResponse_httpStatus :: Lens.Lens' PutRecommendationFeedbackResponse Prelude.Int
putRecommendationFeedbackResponse_httpStatus :: (Int -> f Int)
-> PutRecommendationFeedbackResponse
-> f PutRecommendationFeedbackResponse
putRecommendationFeedbackResponse_httpStatus = (PutRecommendationFeedbackResponse -> Int)
-> (PutRecommendationFeedbackResponse
    -> Int -> PutRecommendationFeedbackResponse)
-> Lens
     PutRecommendationFeedbackResponse
     PutRecommendationFeedbackResponse
     Int
     Int
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