{-# 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 IssuingTransactionLodgingData
module StripeAPI.Types.IssuingTransactionLodgingData 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.issuing_transaction_lodging_data@ in the specification.
data IssuingTransactionLodgingData = IssuingTransactionLodgingData
  { -- | check_in_at: The time of checking into the lodging.
    IssuingTransactionLodgingData -> Maybe Int
issuingTransactionLodgingDataCheckInAt :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | nights: The number of nights stayed at the lodging.
    IssuingTransactionLodgingData -> Maybe Int
issuingTransactionLodgingDataNights :: (GHC.Maybe.Maybe GHC.Types.Int)
  }
  deriving
    ( Int -> IssuingTransactionLodgingData -> ShowS
[IssuingTransactionLodgingData] -> ShowS
IssuingTransactionLodgingData -> String
(Int -> IssuingTransactionLodgingData -> ShowS)
-> (IssuingTransactionLodgingData -> String)
-> ([IssuingTransactionLodgingData] -> ShowS)
-> Show IssuingTransactionLodgingData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IssuingTransactionLodgingData] -> ShowS
$cshowList :: [IssuingTransactionLodgingData] -> ShowS
show :: IssuingTransactionLodgingData -> String
$cshow :: IssuingTransactionLodgingData -> String
showsPrec :: Int -> IssuingTransactionLodgingData -> ShowS
$cshowsPrec :: Int -> IssuingTransactionLodgingData -> ShowS
GHC.Show.Show,
      IssuingTransactionLodgingData
-> IssuingTransactionLodgingData -> Bool
(IssuingTransactionLodgingData
 -> IssuingTransactionLodgingData -> Bool)
-> (IssuingTransactionLodgingData
    -> IssuingTransactionLodgingData -> Bool)
-> Eq IssuingTransactionLodgingData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IssuingTransactionLodgingData
-> IssuingTransactionLodgingData -> Bool
$c/= :: IssuingTransactionLodgingData
-> IssuingTransactionLodgingData -> Bool
== :: IssuingTransactionLodgingData
-> IssuingTransactionLodgingData -> Bool
$c== :: IssuingTransactionLodgingData
-> IssuingTransactionLodgingData -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON IssuingTransactionLodgingData where
  toJSON :: IssuingTransactionLodgingData -> Value
toJSON IssuingTransactionLodgingData
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"check_in_at" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= IssuingTransactionLodgingData -> Maybe Int
issuingTransactionLodgingDataCheckInAt IssuingTransactionLodgingData
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"nights" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= IssuingTransactionLodgingData -> Maybe Int
issuingTransactionLodgingDataNights IssuingTransactionLodgingData
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: IssuingTransactionLodgingData -> Encoding
toEncoding IssuingTransactionLodgingData
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"check_in_at" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= IssuingTransactionLodgingData -> Maybe Int
issuingTransactionLodgingDataCheckInAt IssuingTransactionLodgingData
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"nights" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= IssuingTransactionLodgingData -> Maybe Int
issuingTransactionLodgingDataNights IssuingTransactionLodgingData
obj))

instance Data.Aeson.Types.FromJSON.FromJSON IssuingTransactionLodgingData where
  parseJSON :: Value -> Parser IssuingTransactionLodgingData
parseJSON = String
-> (Object -> Parser IssuingTransactionLodgingData)
-> Value
-> Parser IssuingTransactionLodgingData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"IssuingTransactionLodgingData" (\Object
obj -> ((Maybe Int -> Maybe Int -> IssuingTransactionLodgingData)
-> Parser (Maybe Int -> Maybe Int -> IssuingTransactionLodgingData)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int -> Maybe Int -> IssuingTransactionLodgingData
IssuingTransactionLodgingData Parser (Maybe Int -> Maybe Int -> IssuingTransactionLodgingData)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> IssuingTransactionLodgingData)
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
"check_in_at")) Parser (Maybe Int -> IssuingTransactionLodgingData)
-> Parser (Maybe Int) -> Parser IssuingTransactionLodgingData
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
"nights"))

-- | Create a new 'IssuingTransactionLodgingData' with all required fields.
mkIssuingTransactionLodgingData :: IssuingTransactionLodgingData
mkIssuingTransactionLodgingData :: IssuingTransactionLodgingData
mkIssuingTransactionLodgingData =
  IssuingTransactionLodgingData :: Maybe Int -> Maybe Int -> IssuingTransactionLodgingData
IssuingTransactionLodgingData
    { issuingTransactionLodgingDataCheckInAt :: Maybe Int
issuingTransactionLodgingDataCheckInAt = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      issuingTransactionLodgingDataNights :: Maybe Int
issuingTransactionLodgingDataNights = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
    }