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

instance Data.Aeson.Types.ToJSON.ToJSON GelatoDataVerifiedOutputsDate where
  toJSON :: GelatoDataVerifiedOutputsDate -> Value
toJSON GelatoDataVerifiedOutputsDate
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..= GelatoDataVerifiedOutputsDate -> Maybe Int
gelatoDataVerifiedOutputsDateDay GelatoDataVerifiedOutputsDate
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..= GelatoDataVerifiedOutputsDate -> Maybe Int
gelatoDataVerifiedOutputsDateMonth GelatoDataVerifiedOutputsDate
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..= GelatoDataVerifiedOutputsDate -> Maybe Int
gelatoDataVerifiedOutputsDateYear GelatoDataVerifiedOutputsDate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: GelatoDataVerifiedOutputsDate -> Encoding
toEncoding GelatoDataVerifiedOutputsDate
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..= GelatoDataVerifiedOutputsDate -> Maybe Int
gelatoDataVerifiedOutputsDateDay GelatoDataVerifiedOutputsDate
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..= GelatoDataVerifiedOutputsDate -> Maybe Int
gelatoDataVerifiedOutputsDateMonth GelatoDataVerifiedOutputsDate
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..= GelatoDataVerifiedOutputsDate -> Maybe Int
gelatoDataVerifiedOutputsDateYear GelatoDataVerifiedOutputsDate
obj)))

instance Data.Aeson.Types.FromJSON.FromJSON GelatoDataVerifiedOutputsDate where
  parseJSON :: Value -> Parser GelatoDataVerifiedOutputsDate
parseJSON = String
-> (Object -> Parser GelatoDataVerifiedOutputsDate)
-> Value
-> Parser GelatoDataVerifiedOutputsDate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"GelatoDataVerifiedOutputsDate" (\Object
obj -> (((Maybe Int
 -> Maybe Int -> Maybe Int -> GelatoDataVerifiedOutputsDate)
-> Parser
     (Maybe Int
      -> Maybe Int -> Maybe Int -> GelatoDataVerifiedOutputsDate)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int
-> Maybe Int -> Maybe Int -> GelatoDataVerifiedOutputsDate
GelatoDataVerifiedOutputsDate Parser
  (Maybe Int
   -> Maybe Int -> Maybe Int -> GelatoDataVerifiedOutputsDate)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> Maybe Int -> GelatoDataVerifiedOutputsDate)
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 -> GelatoDataVerifiedOutputsDate)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> GelatoDataVerifiedOutputsDate)
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 -> GelatoDataVerifiedOutputsDate)
-> Parser (Maybe Int) -> Parser GelatoDataVerifiedOutputsDate
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 'GelatoDataVerifiedOutputsDate' with all required fields.
mkGelatoDataVerifiedOutputsDate :: GelatoDataVerifiedOutputsDate
mkGelatoDataVerifiedOutputsDate :: GelatoDataVerifiedOutputsDate
mkGelatoDataVerifiedOutputsDate =
  GelatoDataVerifiedOutputsDate :: Maybe Int
-> Maybe Int -> Maybe Int -> GelatoDataVerifiedOutputsDate
GelatoDataVerifiedOutputsDate
    { gelatoDataVerifiedOutputsDateDay :: Maybe Int
gelatoDataVerifiedOutputsDateDay = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      gelatoDataVerifiedOutputsDateMonth :: Maybe Int
gelatoDataVerifiedOutputsDateMonth = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      gelatoDataVerifiedOutputsDateYear :: Maybe Int
gelatoDataVerifiedOutputsDateYear = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
    }