{-# 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 GelatoDataDocumentReportExpirationDate
module StripeAPI.Types.GelatoDataDocumentReportExpirationDate 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.gelato_data_document_report_expiration_date@ in the specification.
--
-- Point in Time
data GelatoDataDocumentReportExpirationDate = GelatoDataDocumentReportExpirationDate
  { -- | day: Numerical day between 1 and 31.
    GelatoDataDocumentReportExpirationDate -> Maybe Int
gelatoDataDocumentReportExpirationDateDay :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | month: Numerical month between 1 and 12.
    GelatoDataDocumentReportExpirationDate -> Maybe Int
gelatoDataDocumentReportExpirationDateMonth :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | year: The four-digit year.
    GelatoDataDocumentReportExpirationDate -> Maybe Int
gelatoDataDocumentReportExpirationDateYear :: (GHC.Maybe.Maybe GHC.Types.Int)
  }
  deriving
    ( Int -> GelatoDataDocumentReportExpirationDate -> ShowS
[GelatoDataDocumentReportExpirationDate] -> ShowS
GelatoDataDocumentReportExpirationDate -> String
(Int -> GelatoDataDocumentReportExpirationDate -> ShowS)
-> (GelatoDataDocumentReportExpirationDate -> String)
-> ([GelatoDataDocumentReportExpirationDate] -> ShowS)
-> Show GelatoDataDocumentReportExpirationDate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GelatoDataDocumentReportExpirationDate] -> ShowS
$cshowList :: [GelatoDataDocumentReportExpirationDate] -> ShowS
show :: GelatoDataDocumentReportExpirationDate -> String
$cshow :: GelatoDataDocumentReportExpirationDate -> String
showsPrec :: Int -> GelatoDataDocumentReportExpirationDate -> ShowS
$cshowsPrec :: Int -> GelatoDataDocumentReportExpirationDate -> ShowS
GHC.Show.Show,
      GelatoDataDocumentReportExpirationDate
-> GelatoDataDocumentReportExpirationDate -> Bool
(GelatoDataDocumentReportExpirationDate
 -> GelatoDataDocumentReportExpirationDate -> Bool)
-> (GelatoDataDocumentReportExpirationDate
    -> GelatoDataDocumentReportExpirationDate -> Bool)
-> Eq GelatoDataDocumentReportExpirationDate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GelatoDataDocumentReportExpirationDate
-> GelatoDataDocumentReportExpirationDate -> Bool
$c/= :: GelatoDataDocumentReportExpirationDate
-> GelatoDataDocumentReportExpirationDate -> Bool
== :: GelatoDataDocumentReportExpirationDate
-> GelatoDataDocumentReportExpirationDate -> Bool
$c== :: GelatoDataDocumentReportExpirationDate
-> GelatoDataDocumentReportExpirationDate -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON GelatoDataDocumentReportExpirationDate where
  toJSON :: GelatoDataDocumentReportExpirationDate -> Value
toJSON GelatoDataDocumentReportExpirationDate
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"day" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDataDocumentReportExpirationDate -> Maybe Int
gelatoDataDocumentReportExpirationDateDay GelatoDataDocumentReportExpirationDate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"month" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDataDocumentReportExpirationDate -> Maybe Int
gelatoDataDocumentReportExpirationDateMonth GelatoDataDocumentReportExpirationDate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"year" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDataDocumentReportExpirationDate -> Maybe Int
gelatoDataDocumentReportExpirationDateYear GelatoDataDocumentReportExpirationDate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: GelatoDataDocumentReportExpirationDate -> Encoding
toEncoding GelatoDataDocumentReportExpirationDate
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"day" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDataDocumentReportExpirationDate -> Maybe Int
gelatoDataDocumentReportExpirationDateDay GelatoDataDocumentReportExpirationDate
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"month" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDataDocumentReportExpirationDate -> Maybe Int
gelatoDataDocumentReportExpirationDateMonth GelatoDataDocumentReportExpirationDate
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"year" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDataDocumentReportExpirationDate -> Maybe Int
gelatoDataDocumentReportExpirationDateYear GelatoDataDocumentReportExpirationDate
obj)))

instance Data.Aeson.Types.FromJSON.FromJSON GelatoDataDocumentReportExpirationDate where
  parseJSON :: Value -> Parser GelatoDataDocumentReportExpirationDate
parseJSON = String
-> (Object -> Parser GelatoDataDocumentReportExpirationDate)
-> Value
-> Parser GelatoDataDocumentReportExpirationDate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"GelatoDataDocumentReportExpirationDate" (\Object
obj -> (((Maybe Int
 -> Maybe Int
 -> Maybe Int
 -> GelatoDataDocumentReportExpirationDate)
-> Parser
     (Maybe Int
      -> Maybe Int
      -> Maybe Int
      -> GelatoDataDocumentReportExpirationDate)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int
-> Maybe Int -> Maybe Int -> GelatoDataDocumentReportExpirationDate
GelatoDataDocumentReportExpirationDate Parser
  (Maybe Int
   -> Maybe Int
   -> Maybe Int
   -> GelatoDataDocumentReportExpirationDate)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int -> Maybe Int -> GelatoDataDocumentReportExpirationDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"day")) Parser
  (Maybe Int -> Maybe Int -> GelatoDataDocumentReportExpirationDate)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> GelatoDataDocumentReportExpirationDate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"month")) Parser (Maybe Int -> GelatoDataDocumentReportExpirationDate)
-> Parser (Maybe Int)
-> Parser GelatoDataDocumentReportExpirationDate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"year"))

-- | Create a new 'GelatoDataDocumentReportExpirationDate' with all required fields.
mkGelatoDataDocumentReportExpirationDate :: GelatoDataDocumentReportExpirationDate
mkGelatoDataDocumentReportExpirationDate :: GelatoDataDocumentReportExpirationDate
mkGelatoDataDocumentReportExpirationDate =
  GelatoDataDocumentReportExpirationDate :: Maybe Int
-> Maybe Int -> Maybe Int -> GelatoDataDocumentReportExpirationDate
GelatoDataDocumentReportExpirationDate
    { gelatoDataDocumentReportExpirationDateDay :: Maybe Int
gelatoDataDocumentReportExpirationDateDay = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      gelatoDataDocumentReportExpirationDateMonth :: Maybe Int
gelatoDataDocumentReportExpirationDateMonth = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      gelatoDataDocumentReportExpirationDateYear :: Maybe Int
gelatoDataDocumentReportExpirationDateYear = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
    }