{-# 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-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.PersonalizeEvents.Types.Item where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 Text
properties :: Prelude.Maybe Prelude.Text,
    -- | The ID associated with the item.
    Item -> Text
itemId :: Prelude.Text
  }
  deriving (Item -> Item -> Bool
(Item -> Item -> Bool) -> (Item -> Item -> Bool) -> Eq Item
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, ReadPrec [Item]
ReadPrec Item
Int -> ReadS Item
ReadS [Item]
(Int -> ReadS Item)
-> ReadS [Item] -> ReadPrec Item -> ReadPrec [Item] -> Read Item
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Item]
$creadListPrec :: ReadPrec [Item]
readPrec :: ReadPrec Item
$creadPrec :: ReadPrec Item
readList :: ReadS [Item]
$creadList :: ReadS [Item]
readsPrec :: Int -> ReadS Item
$creadsPrec :: Int -> ReadS Item
Prelude.Read, Int -> Item -> ShowS
[Item] -> ShowS
Item -> String
(Int -> Item -> ShowS)
-> (Item -> String) -> ([Item] -> ShowS) -> Show Item
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. Item -> Rep Item x)
-> (forall x. Rep Item x -> Item) -> Generic Item
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' :: Maybe Text -> Text -> Item
Item'
    { $sel:properties:Item' :: Maybe Text
properties = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> Item -> f Item
item_properties = (Item -> Maybe Text)
-> (Item -> Maybe Text -> Item)
-> Lens Item Item (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe Text
properties :: Maybe Text
$sel:properties:Item' :: Item -> Maybe Text
properties} -> Maybe Text
properties) (\s :: Item
s@Item' {} Maybe Text
a -> Item
s {$sel:properties:Item' :: Maybe Text
properties = Maybe Text
a} :: Item)

-- | The ID associated with the item.
item_itemId :: Lens.Lens' Item Prelude.Text
item_itemId :: (Text -> f Text) -> Item -> f Item
item_itemId = (Item -> Text)
-> (Item -> Text -> Item) -> Lens Item Item Text Text
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

instance Prelude.NFData Item

instance Core.ToJSON Item where
  toJSON :: Item -> Value
toJSON Item' {Maybe Text
Text
itemId :: Text
properties :: Maybe Text
$sel:itemId:Item' :: Item -> Text
$sel:properties:Item' :: Item -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"properties" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
properties,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"itemId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
itemId)
          ]
      )