{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.Comprehend.DetectSentiment
(
detectSentiment
, DetectSentiment
, dsText
, dsLanguageCode
, detectSentimentResponse
, DetectSentimentResponse
, dsrsSentiment
, dsrsSentimentScore
, dsrsResponseStatus
) where
import Network.AWS.Comprehend.Types
import Network.AWS.Comprehend.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data DetectSentiment = DetectSentiment'
{ _dsText :: !Text
, _dsLanguageCode :: !LanguageCode
} deriving (Eq, Read, Show, Data, Typeable, Generic)
detectSentiment
:: Text
-> LanguageCode
-> DetectSentiment
detectSentiment pText_ pLanguageCode_ =
DetectSentiment' {_dsText = pText_, _dsLanguageCode = pLanguageCode_}
dsText :: Lens' DetectSentiment Text
dsText = lens _dsText (\ s a -> s{_dsText = a})
dsLanguageCode :: Lens' DetectSentiment LanguageCode
dsLanguageCode = lens _dsLanguageCode (\ s a -> s{_dsLanguageCode = a})
instance AWSRequest DetectSentiment where
type Rs DetectSentiment = DetectSentimentResponse
request = postJSON comprehend
response
= receiveJSON
(\ s h x ->
DetectSentimentResponse' <$>
(x .?> "Sentiment") <*> (x .?> "SentimentScore") <*>
(pure (fromEnum s)))
instance Hashable DetectSentiment where
instance NFData DetectSentiment where
instance ToHeaders DetectSentiment where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Comprehend_20171127.DetectSentiment" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON DetectSentiment where
toJSON DetectSentiment'{..}
= object
(catMaybes
[Just ("Text" .= _dsText),
Just ("LanguageCode" .= _dsLanguageCode)])
instance ToPath DetectSentiment where
toPath = const "/"
instance ToQuery DetectSentiment where
toQuery = const mempty
data DetectSentimentResponse = DetectSentimentResponse'
{ _dsrsSentiment :: !(Maybe SentimentType)
, _dsrsSentimentScore :: !(Maybe SentimentScore)
, _dsrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
detectSentimentResponse
:: Int
-> DetectSentimentResponse
detectSentimentResponse pResponseStatus_ =
DetectSentimentResponse'
{ _dsrsSentiment = Nothing
, _dsrsSentimentScore = Nothing
, _dsrsResponseStatus = pResponseStatus_
}
dsrsSentiment :: Lens' DetectSentimentResponse (Maybe SentimentType)
dsrsSentiment = lens _dsrsSentiment (\ s a -> s{_dsrsSentiment = a})
dsrsSentimentScore :: Lens' DetectSentimentResponse (Maybe SentimentScore)
dsrsSentimentScore = lens _dsrsSentimentScore (\ s a -> s{_dsrsSentimentScore = a})
dsrsResponseStatus :: Lens' DetectSentimentResponse Int
dsrsResponseStatus = lens _dsrsResponseStatus (\ s a -> s{_dsrsResponseStatus = a})
instance NFData DetectSentimentResponse where