-- 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 Pet
module OpenAPI.Types.Pet 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
import {-# SOURCE #-} OpenAPI.Types.Category
import {-# SOURCE #-} OpenAPI.Types.Tag

-- | Defines the object schema located at @components.schemas.Pet@ in the specification.
-- 
-- 
data Pet = Pet {
  -- | category
  petCategory :: (GHC.Maybe.Maybe Category)
  -- | id
  , petId :: (GHC.Maybe.Maybe GHC.Int.Int64)
  -- | name
  , petName :: Data.Text.Internal.Text
  -- | photoUrls
  , petPhotoUrls :: [Data.Text.Internal.Text]
  -- | status: pet status in the store
  , petStatus :: (GHC.Maybe.Maybe PetStatus)
  -- | tags
  , petTags :: (GHC.Maybe.Maybe [Tag])
  } deriving (GHC.Show.Show
  , GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON Pet
    where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("category" Data.Aeson.Types.ToJSON..=)) (petCategory obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (petId obj) : ["name" Data.Aeson.Types.ToJSON..= petName obj] : ["photoUrls" Data.Aeson.Types.ToJSON..= petPhotoUrls obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (petStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("tags" Data.Aeson.Types.ToJSON..=)) (petTags 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.. ("category" Data.Aeson.Types.ToJSON..=)) (petCategory obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (petId obj) : ["name" Data.Aeson.Types.ToJSON..= petName obj] : ["photoUrls" Data.Aeson.Types.ToJSON..= petPhotoUrls obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (petStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("tags" Data.Aeson.Types.ToJSON..=)) (petTags obj) : GHC.Base.mempty)))}
instance Data.Aeson.Types.FromJSON.FromJSON Pet
    where {parseJSON = Data.Aeson.Types.FromJSON.withObject "Pet" (\obj -> (((((GHC.Base.pure Pet GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "category")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "name")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "photoUrls")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "status")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "tags"))}
-- | Create a new 'Pet' with all required fields.
mkPet :: Data.Text.Internal.Text -- ^ 'petName'
  -> [Data.Text.Internal.Text] -- ^ 'petPhotoUrls'
  -> Pet
mkPet petName petPhotoUrls = Pet{petCategory = GHC.Maybe.Nothing,
                                 petId = GHC.Maybe.Nothing,
                                 petName = petName,
                                 petPhotoUrls = petPhotoUrls,
                                 petStatus = GHC.Maybe.Nothing,
                                 petTags = GHC.Maybe.Nothing}
-- | Defines the enum schema located at @components.schemas.Pet.properties.status@ in the specification.
-- 
-- pet status in the store
data PetStatus =
   PetStatusOther 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.
  | PetStatusTyped Data.Text.Internal.Text -- ^ This constructor can be used to send values to the server which are not present in the specification yet.
  | PetStatusEnumAvailable -- ^ Represents the JSON value @"available"@
  | PetStatusEnumPending -- ^ Represents the JSON value @"pending"@
  | PetStatusEnumSold -- ^ Represents the JSON value @"sold"@
  deriving (GHC.Show.Show, GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON PetStatus
    where {toJSON (PetStatusOther val) = val;
           toJSON (PetStatusTyped val) = Data.Aeson.Types.ToJSON.toJSON val;
           toJSON (PetStatusEnumAvailable) = "available";
           toJSON (PetStatusEnumPending) = "pending";
           toJSON (PetStatusEnumSold) = "sold"}
instance Data.Aeson.Types.FromJSON.FromJSON PetStatus
    where {parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "available" -> PetStatusEnumAvailable
                                             | val GHC.Classes.== "pending" -> PetStatusEnumPending
                                             | val GHC.Classes.== "sold" -> PetStatusEnumSold
                                             | GHC.Base.otherwise -> PetStatusOther val)}
