{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.PredictedItem
-- 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)
module Amazonka.PersonalizeRuntime.Types.PredictedItem where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that identifies an item.
--
-- The and APIs return a list of @PredictedItem@s.
--
-- /See:/ 'newPredictedItem' smart constructor.
data PredictedItem = PredictedItem'
  { -- | A numeric representation of the model\'s certainty that the item will be
    -- the next user selection. For more information on scoring logic, see
    -- how-scores-work.
    PredictedItem -> Maybe Double
score :: Prelude.Maybe Prelude.Double,
    -- | The recommended item ID.
    PredictedItem -> Maybe Text
itemId :: Prelude.Maybe Prelude.Text
  }
  deriving (PredictedItem -> PredictedItem -> Bool
(PredictedItem -> PredictedItem -> Bool)
-> (PredictedItem -> PredictedItem -> Bool) -> Eq PredictedItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredictedItem -> PredictedItem -> Bool
$c/= :: PredictedItem -> PredictedItem -> Bool
== :: PredictedItem -> PredictedItem -> Bool
$c== :: PredictedItem -> PredictedItem -> Bool
Prelude.Eq, ReadPrec [PredictedItem]
ReadPrec PredictedItem
Int -> ReadS PredictedItem
ReadS [PredictedItem]
(Int -> ReadS PredictedItem)
-> ReadS [PredictedItem]
-> ReadPrec PredictedItem
-> ReadPrec [PredictedItem]
-> Read PredictedItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredictedItem]
$creadListPrec :: ReadPrec [PredictedItem]
readPrec :: ReadPrec PredictedItem
$creadPrec :: ReadPrec PredictedItem
readList :: ReadS [PredictedItem]
$creadList :: ReadS [PredictedItem]
readsPrec :: Int -> ReadS PredictedItem
$creadsPrec :: Int -> ReadS PredictedItem
Prelude.Read, Int -> PredictedItem -> ShowS
[PredictedItem] -> ShowS
PredictedItem -> String
(Int -> PredictedItem -> ShowS)
-> (PredictedItem -> String)
-> ([PredictedItem] -> ShowS)
-> Show PredictedItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredictedItem] -> ShowS
$cshowList :: [PredictedItem] -> ShowS
show :: PredictedItem -> String
$cshow :: PredictedItem -> String
showsPrec :: Int -> PredictedItem -> ShowS
$cshowsPrec :: Int -> PredictedItem -> ShowS
Prelude.Show, (forall x. PredictedItem -> Rep PredictedItem x)
-> (forall x. Rep PredictedItem x -> PredictedItem)
-> Generic PredictedItem
forall x. Rep PredictedItem x -> PredictedItem
forall x. PredictedItem -> Rep PredictedItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PredictedItem x -> PredictedItem
$cfrom :: forall x. PredictedItem -> Rep PredictedItem x
Prelude.Generic)

-- |
-- Create a value of 'PredictedItem' 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:
--
-- 'score', 'predictedItem_score' - A numeric representation of the model\'s certainty that the item will be
-- the next user selection. For more information on scoring logic, see
-- how-scores-work.
--
-- 'itemId', 'predictedItem_itemId' - The recommended item ID.
newPredictedItem ::
  PredictedItem
newPredictedItem :: PredictedItem
newPredictedItem =
  PredictedItem' :: Maybe Double -> Maybe Text -> PredictedItem
PredictedItem'
    { $sel:score:PredictedItem' :: Maybe Double
score = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:itemId:PredictedItem' :: Maybe Text
itemId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A numeric representation of the model\'s certainty that the item will be
-- the next user selection. For more information on scoring logic, see
-- how-scores-work.
predictedItem_score :: Lens.Lens' PredictedItem (Prelude.Maybe Prelude.Double)
predictedItem_score :: (Maybe Double -> f (Maybe Double))
-> PredictedItem -> f PredictedItem
predictedItem_score = (PredictedItem -> Maybe Double)
-> (PredictedItem -> Maybe Double -> PredictedItem)
-> Lens PredictedItem PredictedItem (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictedItem' {Maybe Double
score :: Maybe Double
$sel:score:PredictedItem' :: PredictedItem -> Maybe Double
score} -> Maybe Double
score) (\s :: PredictedItem
s@PredictedItem' {} Maybe Double
a -> PredictedItem
s {$sel:score:PredictedItem' :: Maybe Double
score = Maybe Double
a} :: PredictedItem)

-- | The recommended item ID.
predictedItem_itemId :: Lens.Lens' PredictedItem (Prelude.Maybe Prelude.Text)
predictedItem_itemId :: (Maybe Text -> f (Maybe Text)) -> PredictedItem -> f PredictedItem
predictedItem_itemId = (PredictedItem -> Maybe Text)
-> (PredictedItem -> Maybe Text -> PredictedItem)
-> Lens PredictedItem PredictedItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictedItem' {Maybe Text
itemId :: Maybe Text
$sel:itemId:PredictedItem' :: PredictedItem -> Maybe Text
itemId} -> Maybe Text
itemId) (\s :: PredictedItem
s@PredictedItem' {} Maybe Text
a -> PredictedItem
s {$sel:itemId:PredictedItem' :: Maybe Text
itemId = Maybe Text
a} :: PredictedItem)

instance Core.FromJSON PredictedItem where
  parseJSON :: Value -> Parser PredictedItem
parseJSON =
    String
-> (Object -> Parser PredictedItem)
-> Value
-> Parser PredictedItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PredictedItem"
      ( \Object
x ->
          Maybe Double -> Maybe Text -> PredictedItem
PredictedItem'
            (Maybe Double -> Maybe Text -> PredictedItem)
-> Parser (Maybe Double) -> Parser (Maybe Text -> PredictedItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"score")
            Parser (Maybe Text -> PredictedItem)
-> Parser (Maybe Text) -> Parser PredictedItem
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"itemId")
      )

instance Prelude.Hashable PredictedItem

instance Prelude.NFData PredictedItem