-- 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 #-}
{-# LANGUAGE MultiWayIf #-}

-- | Contains the types generated from the schema PetByType
module OpenAPI.Types.PetByType where

import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
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.ToJSON
import qualified Data.Aeson as Data.Aeson.Types.Internal
import qualified Data.ByteString
import qualified Data.ByteString as Data.ByteString.Internal
import qualified Data.Foldable
import qualified Data.Functor
import qualified Data.Maybe
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text as 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 OpenAPI.Common
import OpenAPI.TypeAlias

-- | Defines the object schema located at @components.schemas.PetByType@ in the specification.
-- 
-- 
data PetByType = PetByType {
  -- | hunts
  petByTypeHunts :: (GHC.Maybe.Maybe GHC.Types.Bool)
  -- | pet_type
  , petByTypePet_type :: PetByTypePet_type
  } deriving (GHC.Show.Show
  , GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON PetByType
    where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("hunts" Data.Aeson.Types.ToJSON..=)) (petByTypeHunts obj) : ["pet_type" Data.Aeson.Types.ToJSON..= petByTypePet_type obj] : GHC.Base.mempty));
           toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("hunts" Data.Aeson.Types.ToJSON..=)) (petByTypeHunts obj) : ["pet_type" Data.Aeson.Types.ToJSON..= petByTypePet_type obj] : GHC.Base.mempty)))}
instance Data.Aeson.Types.FromJSON.FromJSON PetByType
    where {parseJSON = Data.Aeson.Types.FromJSON.withObject "PetByType" (\obj -> (GHC.Base.pure PetByType GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "hunts")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "pet_type"))}
-- | Create a new 'PetByType' with all required fields.
mkPetByType :: PetByTypePet_type -- ^ 'petByTypePet_type'
  -> PetByType
mkPetByType petByTypePet_type = PetByType{petByTypeHunts = GHC.Maybe.Nothing,
                                          petByTypePet_type = petByTypePet_type}
-- | Defines the enum schema located at @components.schemas.PetByType.properties.pet_type@ in the specification.
-- 
-- 
data PetByTypePet_type =
   PetByTypePet_typeOther Data.Aeson.Types.Internal.Value -- ^ This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
  | PetByTypePet_typeTyped Data.Text.Internal.Text -- ^ This constructor can be used to send values to the server which are not present in the specification yet.
  | PetByTypePet_typeEnumCat -- ^ Represents the JSON value @"Cat"@
  | PetByTypePet_typeEnumDog -- ^ Represents the JSON value @"Dog"@
  deriving (GHC.Show.Show, GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON PetByTypePet_type
    where {toJSON (PetByTypePet_typeOther val) = val;
           toJSON (PetByTypePet_typeTyped val) = Data.Aeson.Types.ToJSON.toJSON val;
           toJSON (PetByTypePet_typeEnumCat) = "Cat";
           toJSON (PetByTypePet_typeEnumDog) = "Dog"}
instance Data.Aeson.Types.FromJSON.FromJSON PetByTypePet_type
    where {parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "Cat" -> PetByTypePet_typeEnumCat
                                             | val GHC.Classes.== "Dog" -> PetByTypePet_typeEnumDog
                                             | GHC.Base.otherwise -> PetByTypePet_typeOther val)}
