{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
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
data Event = Event
{
Event -> Maybe Text
eventAccount :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Event -> Maybe Text
eventApiVersion :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Event -> Int
eventCreated :: GHC.Types.Int,
Event -> NotificationEventData
eventData :: NotificationEventData,
Event -> Text
eventId :: Data.Text.Internal.Text,
Event -> Bool
eventLivemode :: GHC.Types.Bool,
Event -> Int
eventPendingWebhooks :: GHC.Types.Int,
Event -> Maybe EventRequest'
eventRequest :: (GHC.Maybe.Maybe EventRequest'),
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"))
mkEvent ::
GHC.Types.Int ->
NotificationEventData ->
Data.Text.Internal.Text ->
GHC.Types.Bool ->
GHC.Types.Int ->
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
}
data EventRequest' = EventRequest'
{
EventRequest' -> Maybe Text
eventRequest'Id :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
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"))
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
}