{-# LANGUAGE MultiWayIf #-}
-- CHANGE WITH CAUTION: This is a generated code file generated by https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator.
{-# LANGUAGE OverloadedStrings #-}

-- | Contains the types generated from the schema Event
module StripeAPI.Types.Event where

import qualified Control.Monad.Fail
import qualified Data.Aeson
import qualified Data.Aeson as Data.Aeson.Encoding.Internal
import qualified Data.Aeson as Data.Aeson.Types
import qualified Data.Aeson as Data.Aeson.Types.FromJSON
import qualified Data.Aeson as Data.Aeson.Types.Internal
import qualified Data.Aeson as Data.Aeson.Types.ToJSON
import qualified Data.ByteString.Char8
import qualified Data.ByteString.Char8 as Data.ByteString.Internal
import qualified Data.Functor
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text.Internal
import qualified Data.Time.Calendar as Data.Time.Calendar.Days
import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified StripeAPI.Common
import StripeAPI.TypeAlias
import {-# SOURCE #-} StripeAPI.Types.NotificationEventData
import {-# SOURCE #-} StripeAPI.Types.NotificationEventRequest
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.event@ in the specification.
--
-- Events are our way of letting you know when something interesting happens in
-- your account. When an interesting event occurs, we create a new \`Event\`
-- object. For example, when a charge succeeds, we create a \`charge.succeeded\`
-- event; and when an invoice payment attempt fails, we create an
-- \`invoice.payment_failed\` event. Note that many API requests may cause multiple
-- events to be created. For example, if you create a new subscription for a
-- customer, you will receive both a \`customer.subscription.created\` event and a
-- \`charge.succeeded\` event.
--
-- Events occur when the state of another API resource changes. The state of that
-- resource at the time of the change is embedded in the event\'s data field. For
-- example, a \`charge.succeeded\` event will contain a charge, and an
-- \`invoice.payment_failed\` event will contain an invoice.
--
-- As with other API resources, you can use endpoints to retrieve an
-- [individual event](https:\/\/stripe.com\/docs\/api\#retrieve_event) or a [list of events](https:\/\/stripe.com\/docs\/api\#list_events)
-- from the API. We also have a separate
-- [webhooks](http:\/\/en.wikipedia.org\/wiki\/Webhook) system for sending the
-- \`Event\` objects directly to an endpoint on your server. Webhooks are managed
-- in your
-- [account settings](https:\/\/dashboard.stripe.com\/account\/webhooks),
-- and our [Using Webhooks](https:\/\/stripe.com\/docs\/webhooks) guide will help you get set up.
--
-- When using [Connect](https:\/\/stripe.com\/docs\/connect), you can also receive notifications of
-- events that occur in connected accounts. For these events, there will be an
-- additional \`account\` attribute in the received \`Event\` object.
--
-- **NOTE:** Right now, access to events through the [Retrieve Event API](https:\/\/stripe.com\/docs\/api\#retrieve_event) is
-- guaranteed only for 30 days.
data Event = Event
  { -- | account: The connected account that originated the event.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Event -> Maybe Text
eventAccount :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | api_version: The Stripe API version used to render \`data\`. *Note: This property is populated only for events on or after October 31, 2014*.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Event -> Maybe Text
eventApiVersion :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    Event -> Int
eventCreated :: GHC.Types.Int,
    -- | data:
    Event -> NotificationEventData
eventData :: NotificationEventData,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Event -> Text
eventId :: Data.Text.Internal.Text,
    -- | livemode: Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.
    Event -> Bool
eventLivemode :: GHC.Types.Bool,
    -- | pending_webhooks: Number of webhooks that have yet to be successfully delivered (i.e., to return a 20x response) to the URLs you\'ve specified.
    Event -> Int
eventPendingWebhooks :: GHC.Types.Int,
    -- | request: Information on the API request that instigated the event.
    Event -> Maybe EventRequest'
eventRequest :: (GHC.Maybe.Maybe EventRequest'),
    -- | type: Description of the event (e.g., \`invoice.created\` or \`charge.refunded\`).
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Event -> Text
eventType :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> Event -> ShowS
[Event] -> ShowS
Event -> String
(Int -> Event -> ShowS)
-> (Event -> String) -> ([Event] -> ShowS) -> Show Event
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Event] -> ShowS
$cshowList :: [Event] -> ShowS
show :: Event -> String
$cshow :: Event -> String
showsPrec :: Int -> Event -> ShowS
$cshowsPrec :: Int -> Event -> ShowS
GHC.Show.Show,
      Event -> Event -> Bool
(Event -> Event -> Bool) -> (Event -> Event -> Bool) -> Eq Event
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Event -> Event -> Bool
$c/= :: Event -> Event -> Bool
== :: Event -> Event -> Bool
$c== :: Event -> Event -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON Event where
  toJSON :: Event -> Value
toJSON Event
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"account" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Maybe Text
eventAccount Event
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"api_version" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Maybe Text
eventApiVersion Event
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Int
eventCreated Event
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"data" Text -> NotificationEventData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> NotificationEventData
eventData Event
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Text
eventId Event
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"livemode" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Bool
eventLivemode Event
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"pending_webhooks" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Int
eventPendingWebhooks Event
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"request" Text -> Maybe EventRequest' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Maybe EventRequest'
eventRequest Event
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Text
eventType Event
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"object" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"event" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: Event -> Encoding
toEncoding Event
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"account" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Maybe Text
eventAccount Event
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"api_version" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Maybe Text
eventApiVersion Event
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Int
eventCreated Event
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"data" Text -> NotificationEventData -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> NotificationEventData
eventData Event
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"id" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Text
eventId Event
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"livemode" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Bool
eventLivemode Event
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"pending_webhooks" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Int
eventPendingWebhooks Event
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"request" Text -> Maybe EventRequest' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Maybe EventRequest'
eventRequest Event
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"type" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Event -> Text
eventType Event
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"object" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"event"))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON Event where
  parseJSON :: Value -> Parser Event
parseJSON = String -> (Object -> Parser Event) -> Value -> Parser Event
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Event" (\Object
obj -> (((((((((Maybe Text
 -> Maybe Text
 -> Int
 -> NotificationEventData
 -> Text
 -> Bool
 -> Int
 -> Maybe EventRequest'
 -> Text
 -> Event)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Int
      -> NotificationEventData
      -> Text
      -> Bool
      -> Int
      -> Maybe EventRequest'
      -> Text
      -> Event)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Maybe Text
-> Int
-> NotificationEventData
-> Text
-> Bool
-> Int
-> Maybe EventRequest'
-> Text
-> Event
Event Parser
  (Maybe Text
   -> Maybe Text
   -> Int
   -> NotificationEventData
   -> Text
   -> Bool
   -> Int
   -> Maybe EventRequest'
   -> Text
   -> Event)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Int
      -> NotificationEventData
      -> Text
      -> Bool
      -> Int
      -> Maybe EventRequest'
      -> Text
      -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"account")) Parser
  (Maybe Text
   -> Int
   -> NotificationEventData
   -> Text
   -> Bool
   -> Int
   -> Maybe EventRequest'
   -> Text
   -> Event)
-> Parser (Maybe Text)
-> Parser
     (Int
      -> NotificationEventData
      -> Text
      -> Bool
      -> Int
      -> Maybe EventRequest'
      -> Text
      -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"api_version")) Parser
  (Int
   -> NotificationEventData
   -> Text
   -> Bool
   -> Int
   -> Maybe EventRequest'
   -> Text
   -> Event)
-> Parser Int
-> Parser
     (NotificationEventData
      -> Text -> Bool -> Int -> Maybe EventRequest' -> Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"created")) Parser
  (NotificationEventData
   -> Text -> Bool -> Int -> Maybe EventRequest' -> Text -> Event)
-> Parser NotificationEventData
-> Parser
     (Text -> Bool -> Int -> Maybe EventRequest' -> Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser NotificationEventData
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"data")) Parser
  (Text -> Bool -> Int -> Maybe EventRequest' -> Text -> Event)
-> Parser Text
-> Parser (Bool -> Int -> Maybe EventRequest' -> Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"id")) Parser (Bool -> Int -> Maybe EventRequest' -> Text -> Event)
-> Parser Bool
-> Parser (Int -> Maybe EventRequest' -> Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"livemode")) Parser (Int -> Maybe EventRequest' -> Text -> Event)
-> Parser Int -> Parser (Maybe EventRequest' -> Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"pending_webhooks")) Parser (Maybe EventRequest' -> Text -> Event)
-> Parser (Maybe EventRequest') -> Parser (Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe EventRequest')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"request")) Parser (Text -> Event) -> Parser Text -> Parser Event
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"type"))

-- | Create a new 'Event' with all required fields.
mkEvent ::
  -- | 'eventCreated'
  GHC.Types.Int ->
  -- | 'eventData'
  NotificationEventData ->
  -- | 'eventId'
  Data.Text.Internal.Text ->
  -- | 'eventLivemode'
  GHC.Types.Bool ->
  -- | 'eventPendingWebhooks'
  GHC.Types.Int ->
  -- | 'eventType'
  Data.Text.Internal.Text ->
  Event
mkEvent :: Int
-> NotificationEventData -> Text -> Bool -> Int -> Text -> Event
mkEvent Int
eventCreated NotificationEventData
eventData Text
eventId Bool
eventLivemode Int
eventPendingWebhooks Text
eventType =
  Event :: Maybe Text
-> Maybe Text
-> Int
-> NotificationEventData
-> Text
-> Bool
-> Int
-> Maybe EventRequest'
-> Text
-> Event
Event
    { eventAccount :: Maybe Text
eventAccount = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      eventApiVersion :: Maybe Text
eventApiVersion = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      eventCreated :: Int
eventCreated = Int
eventCreated,
      eventData :: NotificationEventData
eventData = NotificationEventData
eventData,
      eventId :: Text
eventId = Text
eventId,
      eventLivemode :: Bool
eventLivemode = Bool
eventLivemode,
      eventPendingWebhooks :: Int
eventPendingWebhooks = Int
eventPendingWebhooks,
      eventRequest :: Maybe EventRequest'
eventRequest = Maybe EventRequest'
forall a. Maybe a
GHC.Maybe.Nothing,
      eventType :: Text
eventType = Text
eventType
    }

-- | Defines the object schema located at @components.schemas.event.properties.request.anyOf@ in the specification.
--
-- Information on the API request that instigated the event.
data EventRequest' = EventRequest'
  { -- | id: ID of the API request that caused the event. If null, the event was automatic (e.g., Stripe\'s automatic subscription handling). Request logs are available in the [dashboard](https:\/\/dashboard.stripe.com\/logs), but currently not in the API.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    EventRequest' -> Maybe Text
eventRequest'Id :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | idempotency_key: The idempotency key transmitted during the request, if any. *Note: This property is populated only for events on or after May 23, 2017*.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    EventRequest' -> Maybe Text
eventRequest'IdempotencyKey :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> EventRequest' -> ShowS
[EventRequest'] -> ShowS
EventRequest' -> String
(Int -> EventRequest' -> ShowS)
-> (EventRequest' -> String)
-> ([EventRequest'] -> ShowS)
-> Show EventRequest'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventRequest'] -> ShowS
$cshowList :: [EventRequest'] -> ShowS
show :: EventRequest' -> String
$cshow :: EventRequest' -> String
showsPrec :: Int -> EventRequest' -> ShowS
$cshowsPrec :: Int -> EventRequest' -> ShowS
GHC.Show.Show,
      EventRequest' -> EventRequest' -> Bool
(EventRequest' -> EventRequest' -> Bool)
-> (EventRequest' -> EventRequest' -> Bool) -> Eq EventRequest'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventRequest' -> EventRequest' -> Bool
$c/= :: EventRequest' -> EventRequest' -> Bool
== :: EventRequest' -> EventRequest' -> Bool
$c== :: EventRequest' -> EventRequest' -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON EventRequest' where
  toJSON :: EventRequest' -> Value
toJSON EventRequest'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"id" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= EventRequest' -> Maybe Text
eventRequest'Id EventRequest'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"idempotency_key" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= EventRequest' -> Maybe Text
eventRequest'IdempotencyKey EventRequest'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: EventRequest' -> Encoding
toEncoding EventRequest'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"id" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= EventRequest' -> Maybe Text
eventRequest'Id EventRequest'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"idempotency_key" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= EventRequest' -> Maybe Text
eventRequest'IdempotencyKey EventRequest'
obj))

instance Data.Aeson.Types.FromJSON.FromJSON EventRequest' where
  parseJSON :: Value -> Parser EventRequest'
parseJSON = String
-> (Object -> Parser EventRequest')
-> Value
-> Parser EventRequest'
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"EventRequest'" (\Object
obj -> ((Maybe Text -> Maybe Text -> EventRequest')
-> Parser (Maybe Text -> Maybe Text -> EventRequest')
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text -> Maybe Text -> EventRequest'
EventRequest' Parser (Maybe Text -> Maybe Text -> EventRequest')
-> Parser (Maybe Text) -> Parser (Maybe Text -> EventRequest')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"id")) Parser (Maybe Text -> EventRequest')
-> Parser (Maybe Text) -> Parser EventRequest'
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"idempotency_key"))

-- | Create a new 'EventRequest'' with all required fields.
mkEventRequest' :: EventRequest'
mkEventRequest' :: EventRequest'
mkEventRequest' =
  EventRequest' :: Maybe Text -> Maybe Text -> EventRequest'
EventRequest'
    { eventRequest'Id :: Maybe Text
eventRequest'Id = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      eventRequest'IdempotencyKey :: Maybe Text
eventRequest'IdempotencyKey = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }