{-# 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.PersonalizeEvents.Types.Item
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.PersonalizeEvents.Types.Item where

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

-- | Represents item metadata added to an Items dataset using the @PutItems@
-- API. For more information see
-- <https://docs.aws.amazon.com/personalize/latest/dg/importing-items.html Importing Items Incrementally>.
--
-- /See:/ 'newItem' smart constructor.
data Item = Item'
  { -- | A string map of item-specific metadata. Each element in the map consists
    -- of a key-value pair. For example, @{\"numberOfRatings\": \"12\"}@.
    --
    -- The keys use camel case names that match the fields in the schema for
    -- the Items dataset. In the previous example, the @numberOfRatings@
    -- matches the \'NUMBER_OF_RATINGS\' field defined in the Items schema. For
    -- categorical string data, to include multiple categories for a single
    -- item, separate each category with a pipe separator (@|@). For example,
    -- @\\\"Horror|Action\\\"@.
    Item -> Maybe (Sensitive Text)
properties :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The ID associated with the item.
    Item -> Text
itemId :: Prelude.Text
  }
  deriving (Item -> Item -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Item -> Item -> Bool
$c/= :: Item -> Item -> Bool
== :: Item -> Item -> Bool
$c== :: Item -> Item -> Bool
Prelude.Eq, Int -> Item -> ShowS
[Item] -> ShowS
Item -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Item] -> ShowS
$cshowList :: [Item] -> ShowS
show :: Item -> String
$cshow :: Item -> String
showsPrec :: Int -> Item -> ShowS
$cshowsPrec :: Int -> Item -> ShowS
Prelude.Show, forall x. Rep Item x -> Item
forall x. Item -> Rep Item x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Item x -> Item
$cfrom :: forall x. Item -> Rep Item x
Prelude.Generic)

-- |
-- Create a value of 'Item' 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:
--
-- 'properties', 'item_properties' - A string map of item-specific metadata. Each element in the map consists
-- of a key-value pair. For example, @{\"numberOfRatings\": \"12\"}@.
--
-- The keys use camel case names that match the fields in the schema for
-- the Items dataset. In the previous example, the @numberOfRatings@
-- matches the \'NUMBER_OF_RATINGS\' field defined in the Items schema. For
-- categorical string data, to include multiple categories for a single
-- item, separate each category with a pipe separator (@|@). For example,
-- @\\\"Horror|Action\\\"@.
--
-- 'itemId', 'item_itemId' - The ID associated with the item.
newItem ::
  -- | 'itemId'
  Prelude.Text ->
  Item
newItem :: Text -> Item
newItem Text
pItemId_ =
  Item'
    { $sel:properties:Item' :: Maybe (Sensitive Text)
properties = forall a. Maybe a
Prelude.Nothing,
      $sel:itemId:Item' :: Text
itemId = Text
pItemId_
    }

-- | A string map of item-specific metadata. Each element in the map consists
-- of a key-value pair. For example, @{\"numberOfRatings\": \"12\"}@.
--
-- The keys use camel case names that match the fields in the schema for
-- the Items dataset. In the previous example, the @numberOfRatings@
-- matches the \'NUMBER_OF_RATINGS\' field defined in the Items schema. For
-- categorical string data, to include multiple categories for a single
-- item, separate each category with a pipe separator (@|@). For example,
-- @\\\"Horror|Action\\\"@.
item_properties :: Lens.Lens' Item (Prelude.Maybe Prelude.Text)
item_properties :: Lens' Item (Maybe Text)
item_properties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe (Sensitive Text)
properties :: Maybe (Sensitive Text)
$sel:properties:Item' :: Item -> Maybe (Sensitive Text)
properties} -> Maybe (Sensitive Text)
properties) (\s :: Item
s@Item' {} Maybe (Sensitive Text)
a -> Item
s {$sel:properties:Item' :: Maybe (Sensitive Text)
properties = Maybe (Sensitive Text)
a} :: Item) 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 a. Iso' (Sensitive a) a
Data._Sensitive

-- | The ID associated with the item.
item_itemId :: Lens.Lens' Item Prelude.Text
item_itemId :: Lens' Item Text
item_itemId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Text
itemId :: Text
$sel:itemId:Item' :: Item -> Text
itemId} -> Text
itemId) (\s :: Item
s@Item' {} Text
a -> Item
s {$sel:itemId:Item' :: Text
itemId = Text
a} :: Item)

instance Prelude.Hashable Item where
  hashWithSalt :: Int -> Item -> Int
hashWithSalt Int
_salt Item' {Maybe (Sensitive Text)
Text
itemId :: Text
properties :: Maybe (Sensitive Text)
$sel:itemId:Item' :: Item -> Text
$sel:properties:Item' :: Item -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
properties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
itemId

instance Prelude.NFData Item where
  rnf :: Item -> ()
rnf Item' {Maybe (Sensitive Text)
Text
itemId :: Text
properties :: Maybe (Sensitive Text)
$sel:itemId:Item' :: Item -> Text
$sel:properties:Item' :: Item -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
properties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
itemId

instance Data.ToJSON Item where
  toJSON :: Item -> Value
toJSON Item' {Maybe (Sensitive Text)
Text
itemId :: Text
properties :: Maybe (Sensitive Text)
$sel:itemId:Item' :: Item -> Text
$sel:properties:Item' :: Item -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"properties" 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 (Sensitive Text)
properties,
            forall a. a -> Maybe a
Prelude.Just (Key
"itemId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
itemId)
          ]
      )