{-# 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 #-}
module Amazonka.PersonalizeEvents.Types.Item where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Item = Item'
{
Item -> Maybe Text
properties :: Prelude.Maybe Prelude.Text,
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)
newItem ::
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_
}
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)
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)
]
)