{-# 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.Pinpoint.Types.EventsBatch
-- 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.Pinpoint.Types.EventsBatch where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.Event
import Amazonka.Pinpoint.Types.PublicEndpoint
import qualified Amazonka.Prelude as Prelude

-- | Specifies a batch of endpoints and events to process.
--
-- /See:/ 'newEventsBatch' smart constructor.
data EventsBatch = EventsBatch'
  { -- | A set of properties and attributes that are associated with the
    -- endpoint.
    EventsBatch -> PublicEndpoint
endpoint :: PublicEndpoint,
    -- | A set of properties that are associated with the event.
    EventsBatch -> HashMap Text Event
events :: Prelude.HashMap Prelude.Text Event
  }
  deriving (EventsBatch -> EventsBatch -> Bool
(EventsBatch -> EventsBatch -> Bool)
-> (EventsBatch -> EventsBatch -> Bool) -> Eq EventsBatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventsBatch -> EventsBatch -> Bool
$c/= :: EventsBatch -> EventsBatch -> Bool
== :: EventsBatch -> EventsBatch -> Bool
$c== :: EventsBatch -> EventsBatch -> Bool
Prelude.Eq, ReadPrec [EventsBatch]
ReadPrec EventsBatch
Int -> ReadS EventsBatch
ReadS [EventsBatch]
(Int -> ReadS EventsBatch)
-> ReadS [EventsBatch]
-> ReadPrec EventsBatch
-> ReadPrec [EventsBatch]
-> Read EventsBatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventsBatch]
$creadListPrec :: ReadPrec [EventsBatch]
readPrec :: ReadPrec EventsBatch
$creadPrec :: ReadPrec EventsBatch
readList :: ReadS [EventsBatch]
$creadList :: ReadS [EventsBatch]
readsPrec :: Int -> ReadS EventsBatch
$creadsPrec :: Int -> ReadS EventsBatch
Prelude.Read, Int -> EventsBatch -> ShowS
[EventsBatch] -> ShowS
EventsBatch -> String
(Int -> EventsBatch -> ShowS)
-> (EventsBatch -> String)
-> ([EventsBatch] -> ShowS)
-> Show EventsBatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventsBatch] -> ShowS
$cshowList :: [EventsBatch] -> ShowS
show :: EventsBatch -> String
$cshow :: EventsBatch -> String
showsPrec :: Int -> EventsBatch -> ShowS
$cshowsPrec :: Int -> EventsBatch -> ShowS
Prelude.Show, (forall x. EventsBatch -> Rep EventsBatch x)
-> (forall x. Rep EventsBatch x -> EventsBatch)
-> Generic EventsBatch
forall x. Rep EventsBatch x -> EventsBatch
forall x. EventsBatch -> Rep EventsBatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventsBatch x -> EventsBatch
$cfrom :: forall x. EventsBatch -> Rep EventsBatch x
Prelude.Generic)

-- |
-- Create a value of 'EventsBatch' 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:
--
-- 'endpoint', 'eventsBatch_endpoint' - A set of properties and attributes that are associated with the
-- endpoint.
--
-- 'events', 'eventsBatch_events' - A set of properties that are associated with the event.
newEventsBatch ::
  -- | 'endpoint'
  PublicEndpoint ->
  EventsBatch
newEventsBatch :: PublicEndpoint -> EventsBatch
newEventsBatch PublicEndpoint
pEndpoint_ =
  EventsBatch' :: PublicEndpoint -> HashMap Text Event -> EventsBatch
EventsBatch'
    { $sel:endpoint:EventsBatch' :: PublicEndpoint
endpoint = PublicEndpoint
pEndpoint_,
      $sel:events:EventsBatch' :: HashMap Text Event
events = HashMap Text Event
forall a. Monoid a => a
Prelude.mempty
    }

-- | A set of properties and attributes that are associated with the
-- endpoint.
eventsBatch_endpoint :: Lens.Lens' EventsBatch PublicEndpoint
eventsBatch_endpoint :: (PublicEndpoint -> f PublicEndpoint)
-> EventsBatch -> f EventsBatch
eventsBatch_endpoint = (EventsBatch -> PublicEndpoint)
-> (EventsBatch -> PublicEndpoint -> EventsBatch)
-> Lens EventsBatch EventsBatch PublicEndpoint PublicEndpoint
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventsBatch' {PublicEndpoint
endpoint :: PublicEndpoint
$sel:endpoint:EventsBatch' :: EventsBatch -> PublicEndpoint
endpoint} -> PublicEndpoint
endpoint) (\s :: EventsBatch
s@EventsBatch' {} PublicEndpoint
a -> EventsBatch
s {$sel:endpoint:EventsBatch' :: PublicEndpoint
endpoint = PublicEndpoint
a} :: EventsBatch)

-- | A set of properties that are associated with the event.
eventsBatch_events :: Lens.Lens' EventsBatch (Prelude.HashMap Prelude.Text Event)
eventsBatch_events :: (HashMap Text Event -> f (HashMap Text Event))
-> EventsBatch -> f EventsBatch
eventsBatch_events = (EventsBatch -> HashMap Text Event)
-> (EventsBatch -> HashMap Text Event -> EventsBatch)
-> Lens
     EventsBatch EventsBatch (HashMap Text Event) (HashMap Text Event)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventsBatch' {HashMap Text Event
events :: HashMap Text Event
$sel:events:EventsBatch' :: EventsBatch -> HashMap Text Event
events} -> HashMap Text Event
events) (\s :: EventsBatch
s@EventsBatch' {} HashMap Text Event
a -> EventsBatch
s {$sel:events:EventsBatch' :: HashMap Text Event
events = HashMap Text Event
a} :: EventsBatch) ((HashMap Text Event -> f (HashMap Text Event))
 -> EventsBatch -> f EventsBatch)
-> ((HashMap Text Event -> f (HashMap Text Event))
    -> HashMap Text Event -> f (HashMap Text Event))
-> (HashMap Text Event -> f (HashMap Text Event))
-> EventsBatch
-> f EventsBatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Event -> f (HashMap Text Event))
-> HashMap Text Event -> f (HashMap Text Event)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable EventsBatch

instance Prelude.NFData EventsBatch

instance Core.ToJSON EventsBatch where
  toJSON :: EventsBatch -> Value
toJSON EventsBatch' {HashMap Text Event
PublicEndpoint
events :: HashMap Text Event
endpoint :: PublicEndpoint
$sel:events:EventsBatch' :: EventsBatch -> HashMap Text Event
$sel:endpoint:EventsBatch' :: EventsBatch -> PublicEndpoint
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Endpoint" Text -> PublicEndpoint -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PublicEndpoint
endpoint),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Events" Text -> HashMap Text Event -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Event
events)
          ]
      )