{-# 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.PersonalizeRuntime.GetRecommendations
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of recommended items. For campaigns, the campaign\'s
-- Amazon Resource Name (ARN) is required and the required user and item
-- input depends on the recipe type used to create the solution backing the
-- campaign as follows:
--
-- -   USER_PERSONALIZATION - @userId@ required, @itemId@ not used
--
-- -   RELATED_ITEMS - @itemId@ required, @userId@ not used
--
-- Campaigns that are backed by a solution created using a recipe of type
-- PERSONALIZED_RANKING use the API.
--
-- For recommenders, the recommender\'s ARN is required and the required
-- item and user input depends on the use case (domain-based recipe)
-- backing the recommender. For information on use case requirements see
-- <https://docs.aws.amazon.com/personalize/latest/dg/domain-use-cases.html Choosing recommender use cases>.
module Amazonka.PersonalizeRuntime.GetRecommendations
  ( -- * Creating a Request
    GetRecommendations (..),
    newGetRecommendations,

    -- * Request Lenses
    getRecommendations_campaignArn,
    getRecommendations_context,
    getRecommendations_filterArn,
    getRecommendations_filterValues,
    getRecommendations_itemId,
    getRecommendations_numResults,
    getRecommendations_promotions,
    getRecommendations_recommenderArn,
    getRecommendations_userId,

    -- * Destructuring the Response
    GetRecommendationsResponse (..),
    newGetRecommendationsResponse,

    -- * Response Lenses
    getRecommendationsResponse_itemList,
    getRecommendationsResponse_recommendationId,
    getRecommendationsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetRecommendations' smart constructor.
data GetRecommendations = GetRecommendations'
  { -- | The Amazon Resource Name (ARN) of the campaign to use for getting
    -- recommendations.
    GetRecommendations -> Maybe Text
campaignArn :: Prelude.Maybe Prelude.Text,
    -- | The contextual metadata to use when getting recommendations. Contextual
    -- metadata includes any interaction information that might be relevant
    -- when getting a user\'s recommendations, such as the user\'s current
    -- location or device type.
    GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
context :: Prelude.Maybe (Prelude.HashMap Prelude.Text (Data.Sensitive Prelude.Text)),
    -- | The ARN of the filter to apply to the returned recommendations. For more
    -- information, see
    -- <https://docs.aws.amazon.com/personalize/latest/dg/filter.html Filtering Recommendations>.
    --
    -- When using this parameter, be sure the filter resource is @ACTIVE@.
    GetRecommendations -> Maybe Text
filterArn :: Prelude.Maybe Prelude.Text,
    -- | The values to use when filtering recommendations. For each placeholder
    -- parameter in your filter expression, provide the parameter name (in
    -- matching case) as a key and the filter value(s) as the corresponding
    -- value. Separate multiple values for one parameter with a comma.
    --
    -- For filter expressions that use an @INCLUDE@ element to include items,
    -- you must provide values for all parameters that are defined in the
    -- expression. For filters with expressions that use an @EXCLUDE@ element
    -- to exclude items, you can omit the @filter-values@.In this case, Amazon
    -- Personalize doesn\'t use that portion of the expression to filter
    -- recommendations.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/personalize/latest/dg/filter.html Filtering recommendations and user segments>.
    GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
filterValues :: Prelude.Maybe (Prelude.HashMap Prelude.Text (Data.Sensitive Prelude.Text)),
    -- | The item ID to provide recommendations for.
    --
    -- Required for @RELATED_ITEMS@ recipe type.
    GetRecommendations -> Maybe Text
itemId :: Prelude.Maybe Prelude.Text,
    -- | The number of results to return. The default is 25. The maximum is 500.
    GetRecommendations -> Maybe Natural
numResults :: Prelude.Maybe Prelude.Natural,
    -- | The promotions to apply to the recommendation request. A promotion
    -- defines additional business rules that apply to a configurable subset of
    -- recommended items.
    GetRecommendations -> Maybe [Promotion]
promotions :: Prelude.Maybe [Promotion],
    -- | The Amazon Resource Name (ARN) of the recommender to use to get
    -- recommendations. Provide a recommender ARN if you created a Domain
    -- dataset group with a recommender for a domain use case.
    GetRecommendations -> Maybe Text
recommenderArn :: Prelude.Maybe Prelude.Text,
    -- | The user ID to provide recommendations for.
    --
    -- Required for @USER_PERSONALIZATION@ recipe type.
    GetRecommendations -> Maybe Text
userId :: Prelude.Maybe Prelude.Text
  }
  deriving (GetRecommendations -> GetRecommendations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRecommendations -> GetRecommendations -> Bool
$c/= :: GetRecommendations -> GetRecommendations -> Bool
== :: GetRecommendations -> GetRecommendations -> Bool
$c== :: GetRecommendations -> GetRecommendations -> Bool
Prelude.Eq, Int -> GetRecommendations -> ShowS
[GetRecommendations] -> ShowS
GetRecommendations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRecommendations] -> ShowS
$cshowList :: [GetRecommendations] -> ShowS
show :: GetRecommendations -> String
$cshow :: GetRecommendations -> String
showsPrec :: Int -> GetRecommendations -> ShowS
$cshowsPrec :: Int -> GetRecommendations -> ShowS
Prelude.Show, forall x. Rep GetRecommendations x -> GetRecommendations
forall x. GetRecommendations -> Rep GetRecommendations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRecommendations x -> GetRecommendations
$cfrom :: forall x. GetRecommendations -> Rep GetRecommendations x
Prelude.Generic)

-- |
-- Create a value of 'GetRecommendations' 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:
--
-- 'campaignArn', 'getRecommendations_campaignArn' - The Amazon Resource Name (ARN) of the campaign to use for getting
-- recommendations.
--
-- 'context', 'getRecommendations_context' - The contextual metadata to use when getting recommendations. Contextual
-- metadata includes any interaction information that might be relevant
-- when getting a user\'s recommendations, such as the user\'s current
-- location or device type.
--
-- 'filterArn', 'getRecommendations_filterArn' - The ARN of the filter to apply to the returned recommendations. For more
-- information, see
-- <https://docs.aws.amazon.com/personalize/latest/dg/filter.html Filtering Recommendations>.
--
-- When using this parameter, be sure the filter resource is @ACTIVE@.
--
-- 'filterValues', 'getRecommendations_filterValues' - The values to use when filtering recommendations. For each placeholder
-- parameter in your filter expression, provide the parameter name (in
-- matching case) as a key and the filter value(s) as the corresponding
-- value. Separate multiple values for one parameter with a comma.
--
-- For filter expressions that use an @INCLUDE@ element to include items,
-- you must provide values for all parameters that are defined in the
-- expression. For filters with expressions that use an @EXCLUDE@ element
-- to exclude items, you can omit the @filter-values@.In this case, Amazon
-- Personalize doesn\'t use that portion of the expression to filter
-- recommendations.
--
-- For more information, see
-- <https://docs.aws.amazon.com/personalize/latest/dg/filter.html Filtering recommendations and user segments>.
--
-- 'itemId', 'getRecommendations_itemId' - The item ID to provide recommendations for.
--
-- Required for @RELATED_ITEMS@ recipe type.
--
-- 'numResults', 'getRecommendations_numResults' - The number of results to return. The default is 25. The maximum is 500.
--
-- 'promotions', 'getRecommendations_promotions' - The promotions to apply to the recommendation request. A promotion
-- defines additional business rules that apply to a configurable subset of
-- recommended items.
--
-- 'recommenderArn', 'getRecommendations_recommenderArn' - The Amazon Resource Name (ARN) of the recommender to use to get
-- recommendations. Provide a recommender ARN if you created a Domain
-- dataset group with a recommender for a domain use case.
--
-- 'userId', 'getRecommendations_userId' - The user ID to provide recommendations for.
--
-- Required for @USER_PERSONALIZATION@ recipe type.
newGetRecommendations ::
  GetRecommendations
newGetRecommendations :: GetRecommendations
newGetRecommendations =
  GetRecommendations'
    { $sel:campaignArn:GetRecommendations' :: Maybe Text
campaignArn = forall a. Maybe a
Prelude.Nothing,
      $sel:context:GetRecommendations' :: Maybe (HashMap Text (Sensitive Text))
context = forall a. Maybe a
Prelude.Nothing,
      $sel:filterArn:GetRecommendations' :: Maybe Text
filterArn = forall a. Maybe a
Prelude.Nothing,
      $sel:filterValues:GetRecommendations' :: Maybe (HashMap Text (Sensitive Text))
filterValues = forall a. Maybe a
Prelude.Nothing,
      $sel:itemId:GetRecommendations' :: Maybe Text
itemId = forall a. Maybe a
Prelude.Nothing,
      $sel:numResults:GetRecommendations' :: Maybe Natural
numResults = forall a. Maybe a
Prelude.Nothing,
      $sel:promotions:GetRecommendations' :: Maybe [Promotion]
promotions = forall a. Maybe a
Prelude.Nothing,
      $sel:recommenderArn:GetRecommendations' :: Maybe Text
recommenderArn = forall a. Maybe a
Prelude.Nothing,
      $sel:userId:GetRecommendations' :: Maybe Text
userId = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the campaign to use for getting
-- recommendations.
getRecommendations_campaignArn :: Lens.Lens' GetRecommendations (Prelude.Maybe Prelude.Text)
getRecommendations_campaignArn :: Lens' GetRecommendations (Maybe Text)
getRecommendations_campaignArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendations' {Maybe Text
campaignArn :: Maybe Text
$sel:campaignArn:GetRecommendations' :: GetRecommendations -> Maybe Text
campaignArn} -> Maybe Text
campaignArn) (\s :: GetRecommendations
s@GetRecommendations' {} Maybe Text
a -> GetRecommendations
s {$sel:campaignArn:GetRecommendations' :: Maybe Text
campaignArn = Maybe Text
a} :: GetRecommendations)

-- | The contextual metadata to use when getting recommendations. Contextual
-- metadata includes any interaction information that might be relevant
-- when getting a user\'s recommendations, such as the user\'s current
-- location or device type.
getRecommendations_context :: Lens.Lens' GetRecommendations (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
getRecommendations_context :: Lens' GetRecommendations (Maybe (HashMap Text Text))
getRecommendations_context = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendations' {Maybe (HashMap Text (Sensitive Text))
context :: Maybe (HashMap Text (Sensitive Text))
$sel:context:GetRecommendations' :: GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
context} -> Maybe (HashMap Text (Sensitive Text))
context) (\s :: GetRecommendations
s@GetRecommendations' {} Maybe (HashMap Text (Sensitive Text))
a -> GetRecommendations
s {$sel:context:GetRecommendations' :: Maybe (HashMap Text (Sensitive Text))
context = Maybe (HashMap Text (Sensitive Text))
a} :: GetRecommendations) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the filter to apply to the returned recommendations. For more
-- information, see
-- <https://docs.aws.amazon.com/personalize/latest/dg/filter.html Filtering Recommendations>.
--
-- When using this parameter, be sure the filter resource is @ACTIVE@.
getRecommendations_filterArn :: Lens.Lens' GetRecommendations (Prelude.Maybe Prelude.Text)
getRecommendations_filterArn :: Lens' GetRecommendations (Maybe Text)
getRecommendations_filterArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendations' {Maybe Text
filterArn :: Maybe Text
$sel:filterArn:GetRecommendations' :: GetRecommendations -> Maybe Text
filterArn} -> Maybe Text
filterArn) (\s :: GetRecommendations
s@GetRecommendations' {} Maybe Text
a -> GetRecommendations
s {$sel:filterArn:GetRecommendations' :: Maybe Text
filterArn = Maybe Text
a} :: GetRecommendations)

-- | The values to use when filtering recommendations. For each placeholder
-- parameter in your filter expression, provide the parameter name (in
-- matching case) as a key and the filter value(s) as the corresponding
-- value. Separate multiple values for one parameter with a comma.
--
-- For filter expressions that use an @INCLUDE@ element to include items,
-- you must provide values for all parameters that are defined in the
-- expression. For filters with expressions that use an @EXCLUDE@ element
-- to exclude items, you can omit the @filter-values@.In this case, Amazon
-- Personalize doesn\'t use that portion of the expression to filter
-- recommendations.
--
-- For more information, see
-- <https://docs.aws.amazon.com/personalize/latest/dg/filter.html Filtering recommendations and user segments>.
getRecommendations_filterValues :: Lens.Lens' GetRecommendations (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
getRecommendations_filterValues :: Lens' GetRecommendations (Maybe (HashMap Text Text))
getRecommendations_filterValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendations' {Maybe (HashMap Text (Sensitive Text))
filterValues :: Maybe (HashMap Text (Sensitive Text))
$sel:filterValues:GetRecommendations' :: GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
filterValues} -> Maybe (HashMap Text (Sensitive Text))
filterValues) (\s :: GetRecommendations
s@GetRecommendations' {} Maybe (HashMap Text (Sensitive Text))
a -> GetRecommendations
s {$sel:filterValues:GetRecommendations' :: Maybe (HashMap Text (Sensitive Text))
filterValues = Maybe (HashMap Text (Sensitive Text))
a} :: GetRecommendations) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The item ID to provide recommendations for.
--
-- Required for @RELATED_ITEMS@ recipe type.
getRecommendations_itemId :: Lens.Lens' GetRecommendations (Prelude.Maybe Prelude.Text)
getRecommendations_itemId :: Lens' GetRecommendations (Maybe Text)
getRecommendations_itemId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendations' {Maybe Text
itemId :: Maybe Text
$sel:itemId:GetRecommendations' :: GetRecommendations -> Maybe Text
itemId} -> Maybe Text
itemId) (\s :: GetRecommendations
s@GetRecommendations' {} Maybe Text
a -> GetRecommendations
s {$sel:itemId:GetRecommendations' :: Maybe Text
itemId = Maybe Text
a} :: GetRecommendations)

-- | The number of results to return. The default is 25. The maximum is 500.
getRecommendations_numResults :: Lens.Lens' GetRecommendations (Prelude.Maybe Prelude.Natural)
getRecommendations_numResults :: Lens' GetRecommendations (Maybe Natural)
getRecommendations_numResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendations' {Maybe Natural
numResults :: Maybe Natural
$sel:numResults:GetRecommendations' :: GetRecommendations -> Maybe Natural
numResults} -> Maybe Natural
numResults) (\s :: GetRecommendations
s@GetRecommendations' {} Maybe Natural
a -> GetRecommendations
s {$sel:numResults:GetRecommendations' :: Maybe Natural
numResults = Maybe Natural
a} :: GetRecommendations)

-- | The promotions to apply to the recommendation request. A promotion
-- defines additional business rules that apply to a configurable subset of
-- recommended items.
getRecommendations_promotions :: Lens.Lens' GetRecommendations (Prelude.Maybe [Promotion])
getRecommendations_promotions :: Lens' GetRecommendations (Maybe [Promotion])
getRecommendations_promotions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendations' {Maybe [Promotion]
promotions :: Maybe [Promotion]
$sel:promotions:GetRecommendations' :: GetRecommendations -> Maybe [Promotion]
promotions} -> Maybe [Promotion]
promotions) (\s :: GetRecommendations
s@GetRecommendations' {} Maybe [Promotion]
a -> GetRecommendations
s {$sel:promotions:GetRecommendations' :: Maybe [Promotion]
promotions = Maybe [Promotion]
a} :: GetRecommendations) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the recommender to use to get
-- recommendations. Provide a recommender ARN if you created a Domain
-- dataset group with a recommender for a domain use case.
getRecommendations_recommenderArn :: Lens.Lens' GetRecommendations (Prelude.Maybe Prelude.Text)
getRecommendations_recommenderArn :: Lens' GetRecommendations (Maybe Text)
getRecommendations_recommenderArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendations' {Maybe Text
recommenderArn :: Maybe Text
$sel:recommenderArn:GetRecommendations' :: GetRecommendations -> Maybe Text
recommenderArn} -> Maybe Text
recommenderArn) (\s :: GetRecommendations
s@GetRecommendations' {} Maybe Text
a -> GetRecommendations
s {$sel:recommenderArn:GetRecommendations' :: Maybe Text
recommenderArn = Maybe Text
a} :: GetRecommendations)

-- | The user ID to provide recommendations for.
--
-- Required for @USER_PERSONALIZATION@ recipe type.
getRecommendations_userId :: Lens.Lens' GetRecommendations (Prelude.Maybe Prelude.Text)
getRecommendations_userId :: Lens' GetRecommendations (Maybe Text)
getRecommendations_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendations' {Maybe Text
userId :: Maybe Text
$sel:userId:GetRecommendations' :: GetRecommendations -> Maybe Text
userId} -> Maybe Text
userId) (\s :: GetRecommendations
s@GetRecommendations' {} Maybe Text
a -> GetRecommendations
s {$sel:userId:GetRecommendations' :: Maybe Text
userId = Maybe Text
a} :: GetRecommendations)

instance Core.AWSRequest GetRecommendations where
  type
    AWSResponse GetRecommendations =
      GetRecommendationsResponse
  request :: (Service -> Service)
-> GetRecommendations -> Request GetRecommendations
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetRecommendations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRecommendations)))
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 ->
          Maybe [PredictedItem]
-> Maybe Text -> Int -> GetRecommendationsResponse
GetRecommendationsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"itemList" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"recommendationId")
            forall (f :: * -> *) a b. Applicative f => 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 GetRecommendations where
  hashWithSalt :: Int -> GetRecommendations -> Int
hashWithSalt Int
_salt GetRecommendations' {Maybe Natural
Maybe [Promotion]
Maybe Text
Maybe (HashMap Text (Sensitive Text))
userId :: Maybe Text
recommenderArn :: Maybe Text
promotions :: Maybe [Promotion]
numResults :: Maybe Natural
itemId :: Maybe Text
filterValues :: Maybe (HashMap Text (Sensitive Text))
filterArn :: Maybe Text
context :: Maybe (HashMap Text (Sensitive Text))
campaignArn :: Maybe Text
$sel:userId:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:recommenderArn:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:promotions:GetRecommendations' :: GetRecommendations -> Maybe [Promotion]
$sel:numResults:GetRecommendations' :: GetRecommendations -> Maybe Natural
$sel:itemId:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:filterValues:GetRecommendations' :: GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
$sel:filterArn:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:context:GetRecommendations' :: GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
$sel:campaignArn:GetRecommendations' :: GetRecommendations -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
campaignArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text (Sensitive Text))
context
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
filterArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text (Sensitive Text))
filterValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
itemId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
numResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Promotion]
promotions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recommenderArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userId

instance Prelude.NFData GetRecommendations where
  rnf :: GetRecommendations -> ()
rnf GetRecommendations' {Maybe Natural
Maybe [Promotion]
Maybe Text
Maybe (HashMap Text (Sensitive Text))
userId :: Maybe Text
recommenderArn :: Maybe Text
promotions :: Maybe [Promotion]
numResults :: Maybe Natural
itemId :: Maybe Text
filterValues :: Maybe (HashMap Text (Sensitive Text))
filterArn :: Maybe Text
context :: Maybe (HashMap Text (Sensitive Text))
campaignArn :: Maybe Text
$sel:userId:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:recommenderArn:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:promotions:GetRecommendations' :: GetRecommendations -> Maybe [Promotion]
$sel:numResults:GetRecommendations' :: GetRecommendations -> Maybe Natural
$sel:itemId:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:filterValues:GetRecommendations' :: GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
$sel:filterArn:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:context:GetRecommendations' :: GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
$sel:campaignArn:GetRecommendations' :: GetRecommendations -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
campaignArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text (Sensitive Text))
context
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
filterArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text (Sensitive Text))
filterValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
itemId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
numResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Promotion]
promotions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recommenderArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userId

instance Data.ToHeaders GetRecommendations where
  toHeaders :: GetRecommendations -> 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 GetRecommendations where
  toJSON :: GetRecommendations -> Value
toJSON GetRecommendations' {Maybe Natural
Maybe [Promotion]
Maybe Text
Maybe (HashMap Text (Sensitive Text))
userId :: Maybe Text
recommenderArn :: Maybe Text
promotions :: Maybe [Promotion]
numResults :: Maybe Natural
itemId :: Maybe Text
filterValues :: Maybe (HashMap Text (Sensitive Text))
filterArn :: Maybe Text
context :: Maybe (HashMap Text (Sensitive Text))
campaignArn :: Maybe Text
$sel:userId:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:recommenderArn:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:promotions:GetRecommendations' :: GetRecommendations -> Maybe [Promotion]
$sel:numResults:GetRecommendations' :: GetRecommendations -> Maybe Natural
$sel:itemId:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:filterValues:GetRecommendations' :: GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
$sel:filterArn:GetRecommendations' :: GetRecommendations -> Maybe Text
$sel:context:GetRecommendations' :: GetRecommendations -> Maybe (HashMap Text (Sensitive Text))
$sel:campaignArn:GetRecommendations' :: GetRecommendations -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"campaignArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
campaignArn,
            (Key
"context" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text (Sensitive Text))
context,
            (Key
"filterArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
filterArn,
            (Key
"filterValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text (Sensitive Text))
filterValues,
            (Key
"itemId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
itemId,
            (Key
"numResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
numResults,
            (Key
"promotions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Promotion]
promotions,
            (Key
"recommenderArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
recommenderArn,
            (Key
"userId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
userId
          ]
      )

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

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

-- | /See:/ 'newGetRecommendationsResponse' smart constructor.
data GetRecommendationsResponse = GetRecommendationsResponse'
  { -- | A list of recommendations sorted in descending order by prediction
    -- score. There can be a maximum of 500 items in the list.
    GetRecommendationsResponse -> Maybe [PredictedItem]
itemList :: Prelude.Maybe [PredictedItem],
    -- | The ID of the recommendation.
    GetRecommendationsResponse -> Maybe Text
recommendationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetRecommendationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetRecommendationsResponse -> GetRecommendationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRecommendationsResponse -> GetRecommendationsResponse -> Bool
$c/= :: GetRecommendationsResponse -> GetRecommendationsResponse -> Bool
== :: GetRecommendationsResponse -> GetRecommendationsResponse -> Bool
$c== :: GetRecommendationsResponse -> GetRecommendationsResponse -> Bool
Prelude.Eq, ReadPrec [GetRecommendationsResponse]
ReadPrec GetRecommendationsResponse
Int -> ReadS GetRecommendationsResponse
ReadS [GetRecommendationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRecommendationsResponse]
$creadListPrec :: ReadPrec [GetRecommendationsResponse]
readPrec :: ReadPrec GetRecommendationsResponse
$creadPrec :: ReadPrec GetRecommendationsResponse
readList :: ReadS [GetRecommendationsResponse]
$creadList :: ReadS [GetRecommendationsResponse]
readsPrec :: Int -> ReadS GetRecommendationsResponse
$creadsPrec :: Int -> ReadS GetRecommendationsResponse
Prelude.Read, Int -> GetRecommendationsResponse -> ShowS
[GetRecommendationsResponse] -> ShowS
GetRecommendationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRecommendationsResponse] -> ShowS
$cshowList :: [GetRecommendationsResponse] -> ShowS
show :: GetRecommendationsResponse -> String
$cshow :: GetRecommendationsResponse -> String
showsPrec :: Int -> GetRecommendationsResponse -> ShowS
$cshowsPrec :: Int -> GetRecommendationsResponse -> ShowS
Prelude.Show, forall x.
Rep GetRecommendationsResponse x -> GetRecommendationsResponse
forall x.
GetRecommendationsResponse -> Rep GetRecommendationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRecommendationsResponse x -> GetRecommendationsResponse
$cfrom :: forall x.
GetRecommendationsResponse -> Rep GetRecommendationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRecommendationsResponse' 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:
--
-- 'itemList', 'getRecommendationsResponse_itemList' - A list of recommendations sorted in descending order by prediction
-- score. There can be a maximum of 500 items in the list.
--
-- 'recommendationId', 'getRecommendationsResponse_recommendationId' - The ID of the recommendation.
--
-- 'httpStatus', 'getRecommendationsResponse_httpStatus' - The response's http status code.
newGetRecommendationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRecommendationsResponse
newGetRecommendationsResponse :: Int -> GetRecommendationsResponse
newGetRecommendationsResponse Int
pHttpStatus_ =
  GetRecommendationsResponse'
    { $sel:itemList:GetRecommendationsResponse' :: Maybe [PredictedItem]
itemList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:recommendationId:GetRecommendationsResponse' :: Maybe Text
recommendationId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRecommendationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of recommendations sorted in descending order by prediction
-- score. There can be a maximum of 500 items in the list.
getRecommendationsResponse_itemList :: Lens.Lens' GetRecommendationsResponse (Prelude.Maybe [PredictedItem])
getRecommendationsResponse_itemList :: Lens' GetRecommendationsResponse (Maybe [PredictedItem])
getRecommendationsResponse_itemList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendationsResponse' {Maybe [PredictedItem]
itemList :: Maybe [PredictedItem]
$sel:itemList:GetRecommendationsResponse' :: GetRecommendationsResponse -> Maybe [PredictedItem]
itemList} -> Maybe [PredictedItem]
itemList) (\s :: GetRecommendationsResponse
s@GetRecommendationsResponse' {} Maybe [PredictedItem]
a -> GetRecommendationsResponse
s {$sel:itemList:GetRecommendationsResponse' :: Maybe [PredictedItem]
itemList = Maybe [PredictedItem]
a} :: GetRecommendationsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the recommendation.
getRecommendationsResponse_recommendationId :: Lens.Lens' GetRecommendationsResponse (Prelude.Maybe Prelude.Text)
getRecommendationsResponse_recommendationId :: Lens' GetRecommendationsResponse (Maybe Text)
getRecommendationsResponse_recommendationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendationsResponse' {Maybe Text
recommendationId :: Maybe Text
$sel:recommendationId:GetRecommendationsResponse' :: GetRecommendationsResponse -> Maybe Text
recommendationId} -> Maybe Text
recommendationId) (\s :: GetRecommendationsResponse
s@GetRecommendationsResponse' {} Maybe Text
a -> GetRecommendationsResponse
s {$sel:recommendationId:GetRecommendationsResponse' :: Maybe Text
recommendationId = Maybe Text
a} :: GetRecommendationsResponse)

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

instance Prelude.NFData GetRecommendationsResponse where
  rnf :: GetRecommendationsResponse -> ()
rnf GetRecommendationsResponse' {Int
Maybe [PredictedItem]
Maybe Text
httpStatus :: Int
recommendationId :: Maybe Text
itemList :: Maybe [PredictedItem]
$sel:httpStatus:GetRecommendationsResponse' :: GetRecommendationsResponse -> Int
$sel:recommendationId:GetRecommendationsResponse' :: GetRecommendationsResponse -> Maybe Text
$sel:itemList:GetRecommendationsResponse' :: GetRecommendationsResponse -> Maybe [PredictedItem]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PredictedItem]
itemList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recommendationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus