{-# 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 Reporting_ReportType
module StripeAPI.Types.Reporting_ReportType 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 qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.reporting.report_type@ in the specification.
--
-- The Report Type resource corresponds to a particular type of report, such as
-- the \"Activity summary\" or \"Itemized payouts\" reports. These objects are
-- identified by an ID belonging to a set of enumerated values. See
-- [API Access to Reports documentation](https:\/\/stripe.com\/docs\/reporting\/statements\/api)
-- for those Report Type IDs, along with required and optional parameters.
--
-- Note that certain report types can only be run based on your live-mode data (not test-mode
-- data), and will error when queried without a [live-mode API key](https:\/\/stripe.com\/docs\/keys\#test-live-modes).
data Reporting'reportType = Reporting'reportType
  { -- | data_available_end: Most recent time for which this Report Type is available. Measured in seconds since the Unix epoch.
    Reporting'reportType -> Int
reporting'reportTypeDataAvailableEnd :: GHC.Types.Int,
    -- | data_available_start: Earliest time for which this Report Type is available. Measured in seconds since the Unix epoch.
    Reporting'reportType -> Int
reporting'reportTypeDataAvailableStart :: GHC.Types.Int,
    -- | default_columns: List of column names that are included by default when this Report Type gets run. (If the Report Type doesn\'t support the \`columns\` parameter, this will be null.)
    Reporting'reportType -> Maybe [Text]
reporting'reportTypeDefaultColumns :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | id: The [ID of the Report Type](https:\/\/stripe.com\/docs\/reporting\/statements\/api\#available-report-types), such as \`balance.summary.1\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Reporting'reportType -> Text
reporting'reportTypeId :: Data.Text.Internal.Text,
    -- | name: Human-readable name of the Report Type
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Reporting'reportType -> Text
reporting'reportTypeName :: Data.Text.Internal.Text,
    -- | updated: When this Report Type was latest updated. Measured in seconds since the Unix epoch.
    Reporting'reportType -> Int
reporting'reportTypeUpdated :: GHC.Types.Int,
    -- | version: Version of the Report Type. Different versions report with the same ID will have the same purpose, but may take different run parameters or have different result schemas.
    Reporting'reportType -> Int
reporting'reportTypeVersion :: GHC.Types.Int
  }
  deriving
    ( Int -> Reporting'reportType -> ShowS
[Reporting'reportType] -> ShowS
Reporting'reportType -> String
(Int -> Reporting'reportType -> ShowS)
-> (Reporting'reportType -> String)
-> ([Reporting'reportType] -> ShowS)
-> Show Reporting'reportType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Reporting'reportType] -> ShowS
$cshowList :: [Reporting'reportType] -> ShowS
show :: Reporting'reportType -> String
$cshow :: Reporting'reportType -> String
showsPrec :: Int -> Reporting'reportType -> ShowS
$cshowsPrec :: Int -> Reporting'reportType -> ShowS
GHC.Show.Show,
      Reporting'reportType -> Reporting'reportType -> Bool
(Reporting'reportType -> Reporting'reportType -> Bool)
-> (Reporting'reportType -> Reporting'reportType -> Bool)
-> Eq Reporting'reportType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Reporting'reportType -> Reporting'reportType -> Bool
$c/= :: Reporting'reportType -> Reporting'reportType -> Bool
== :: Reporting'reportType -> Reporting'reportType -> Bool
$c== :: Reporting'reportType -> Reporting'reportType -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON Reporting'reportType where
  toJSON :: Reporting'reportType -> Value
toJSON Reporting'reportType
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"data_available_end" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Int
reporting'reportTypeDataAvailableEnd Reporting'reportType
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"data_available_start" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Int
reporting'reportTypeDataAvailableStart Reporting'reportType
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"default_columns" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Maybe [Text]
reporting'reportTypeDefaultColumns Reporting'reportType
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..= Reporting'reportType -> Text
reporting'reportTypeId Reporting'reportType
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Text
reporting'reportTypeName Reporting'reportType
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"updated" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Int
reporting'reportTypeUpdated Reporting'reportType
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"version" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Int
reporting'reportTypeVersion Reporting'reportType
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
"reporting.report_type" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: Reporting'reportType -> Encoding
toEncoding Reporting'reportType
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"data_available_end" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Int
reporting'reportTypeDataAvailableEnd Reporting'reportType
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"data_available_start" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Int
reporting'reportTypeDataAvailableStart Reporting'reportType
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"default_columns" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Maybe [Text]
reporting'reportTypeDefaultColumns Reporting'reportType
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..= Reporting'reportType -> Text
reporting'reportTypeId Reporting'reportType
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"name" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Text
reporting'reportTypeName Reporting'reportType
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"updated" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Int
reporting'reportTypeUpdated Reporting'reportType
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"version" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Reporting'reportType -> Int
reporting'reportTypeVersion Reporting'reportType
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
"reporting.report_type"))))))))

instance Data.Aeson.Types.FromJSON.FromJSON Reporting'reportType where
  parseJSON :: Value -> Parser Reporting'reportType
parseJSON = String
-> (Object -> Parser Reporting'reportType)
-> Value
-> Parser Reporting'reportType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Reporting'reportType" (\Object
obj -> (((((((Int
 -> Int
 -> Maybe [Text]
 -> Text
 -> Text
 -> Int
 -> Int
 -> Reporting'reportType)
-> Parser
     (Int
      -> Int
      -> Maybe [Text]
      -> Text
      -> Text
      -> Int
      -> Int
      -> Reporting'reportType)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int
-> Int
-> Maybe [Text]
-> Text
-> Text
-> Int
-> Int
-> Reporting'reportType
Reporting'reportType Parser
  (Int
   -> Int
   -> Maybe [Text]
   -> Text
   -> Text
   -> Int
   -> Int
   -> Reporting'reportType)
-> Parser Int
-> Parser
     (Int
      -> Maybe [Text]
      -> Text
      -> Text
      -> Int
      -> Int
      -> Reporting'reportType)
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
"data_available_end")) Parser
  (Int
   -> Maybe [Text]
   -> Text
   -> Text
   -> Int
   -> Int
   -> Reporting'reportType)
-> Parser Int
-> Parser
     (Maybe [Text]
      -> Text -> Text -> Int -> Int -> Reporting'reportType)
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
"data_available_start")) Parser
  (Maybe [Text]
   -> Text -> Text -> Int -> Int -> Reporting'reportType)
-> Parser (Maybe [Text])
-> Parser (Text -> Text -> Int -> Int -> Reporting'reportType)
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
"default_columns")) Parser (Text -> Text -> Int -> Int -> Reporting'reportType)
-> Parser Text
-> Parser (Text -> Int -> Int -> Reporting'reportType)
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 (Text -> Int -> Int -> Reporting'reportType)
-> Parser Text -> Parser (Int -> Int -> Reporting'reportType)
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
"name")) Parser (Int -> Int -> Reporting'reportType)
-> Parser Int -> Parser (Int -> Reporting'reportType)
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
"updated")) Parser (Int -> Reporting'reportType)
-> Parser Int -> Parser Reporting'reportType
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
"version"))

-- | Create a new 'Reporting'reportType' with all required fields.
mkReporting'reportType ::
  -- | 'reporting'reportTypeDataAvailableEnd'
  GHC.Types.Int ->
  -- | 'reporting'reportTypeDataAvailableStart'
  GHC.Types.Int ->
  -- | 'reporting'reportTypeId'
  Data.Text.Internal.Text ->
  -- | 'reporting'reportTypeName'
  Data.Text.Internal.Text ->
  -- | 'reporting'reportTypeUpdated'
  GHC.Types.Int ->
  -- | 'reporting'reportTypeVersion'
  GHC.Types.Int ->
  Reporting'reportType
mkReporting'reportType :: Int -> Int -> Text -> Text -> Int -> Int -> Reporting'reportType
mkReporting'reportType Int
reporting'reportTypeDataAvailableEnd Int
reporting'reportTypeDataAvailableStart Text
reporting'reportTypeId Text
reporting'reportTypeName Int
reporting'reportTypeUpdated Int
reporting'reportTypeVersion =
  Reporting'reportType :: Int
-> Int
-> Maybe [Text]
-> Text
-> Text
-> Int
-> Int
-> Reporting'reportType
Reporting'reportType
    { reporting'reportTypeDataAvailableEnd :: Int
reporting'reportTypeDataAvailableEnd = Int
reporting'reportTypeDataAvailableEnd,
      reporting'reportTypeDataAvailableStart :: Int
reporting'reportTypeDataAvailableStart = Int
reporting'reportTypeDataAvailableStart,
      reporting'reportTypeDefaultColumns :: Maybe [Text]
reporting'reportTypeDefaultColumns = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      reporting'reportTypeId :: Text
reporting'reportTypeId = Text
reporting'reportTypeId,
      reporting'reportTypeName :: Text
reporting'reportTypeName = Text
reporting'reportTypeName,
      reporting'reportTypeUpdated :: Int
reporting'reportTypeUpdated = Int
reporting'reportTypeUpdated,
      reporting'reportTypeVersion :: Int
reporting'reportTypeVersion = Int
reporting'reportTypeVersion
    }