{-# 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 GelatoDocumentReportError
module StripeAPI.Types.GelatoDocumentReportError 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_document_report_error@ in the specification.
data GelatoDocumentReportError = GelatoDocumentReportError
  { -- | code: A short machine-readable string giving the reason for the verification failure.
    GelatoDocumentReportError -> Maybe GelatoDocumentReportErrorCode'
gelatoDocumentReportErrorCode :: (GHC.Maybe.Maybe GelatoDocumentReportErrorCode'),
    -- | reason: A human-readable message giving the reason for the failure. These messages can be shown to your users.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    GelatoDocumentReportError -> Maybe Text
gelatoDocumentReportErrorReason :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> GelatoDocumentReportError -> ShowS
[GelatoDocumentReportError] -> ShowS
GelatoDocumentReportError -> String
(Int -> GelatoDocumentReportError -> ShowS)
-> (GelatoDocumentReportError -> String)
-> ([GelatoDocumentReportError] -> ShowS)
-> Show GelatoDocumentReportError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GelatoDocumentReportError] -> ShowS
$cshowList :: [GelatoDocumentReportError] -> ShowS
show :: GelatoDocumentReportError -> String
$cshow :: GelatoDocumentReportError -> String
showsPrec :: Int -> GelatoDocumentReportError -> ShowS
$cshowsPrec :: Int -> GelatoDocumentReportError -> ShowS
GHC.Show.Show,
      GelatoDocumentReportError -> GelatoDocumentReportError -> Bool
(GelatoDocumentReportError -> GelatoDocumentReportError -> Bool)
-> (GelatoDocumentReportError -> GelatoDocumentReportError -> Bool)
-> Eq GelatoDocumentReportError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GelatoDocumentReportError -> GelatoDocumentReportError -> Bool
$c/= :: GelatoDocumentReportError -> GelatoDocumentReportError -> Bool
== :: GelatoDocumentReportError -> GelatoDocumentReportError -> Bool
$c== :: GelatoDocumentReportError -> GelatoDocumentReportError -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON GelatoDocumentReportError where
  toJSON :: GelatoDocumentReportError -> Value
toJSON GelatoDocumentReportError
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"code" Text -> Maybe GelatoDocumentReportErrorCode' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDocumentReportError -> Maybe GelatoDocumentReportErrorCode'
gelatoDocumentReportErrorCode GelatoDocumentReportError
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"reason" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDocumentReportError -> Maybe Text
gelatoDocumentReportErrorReason GelatoDocumentReportError
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: GelatoDocumentReportError -> Encoding
toEncoding GelatoDocumentReportError
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"code" Text -> Maybe GelatoDocumentReportErrorCode' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDocumentReportError -> Maybe GelatoDocumentReportErrorCode'
gelatoDocumentReportErrorCode GelatoDocumentReportError
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"reason" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoDocumentReportError -> Maybe Text
gelatoDocumentReportErrorReason GelatoDocumentReportError
obj))

instance Data.Aeson.Types.FromJSON.FromJSON GelatoDocumentReportError where
  parseJSON :: Value -> Parser GelatoDocumentReportError
parseJSON = String
-> (Object -> Parser GelatoDocumentReportError)
-> Value
-> Parser GelatoDocumentReportError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"GelatoDocumentReportError" (\Object
obj -> ((Maybe GelatoDocumentReportErrorCode'
 -> Maybe Text -> GelatoDocumentReportError)
-> Parser
     (Maybe GelatoDocumentReportErrorCode'
      -> Maybe Text -> GelatoDocumentReportError)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe GelatoDocumentReportErrorCode'
-> Maybe Text -> GelatoDocumentReportError
GelatoDocumentReportError Parser
  (Maybe GelatoDocumentReportErrorCode'
   -> Maybe Text -> GelatoDocumentReportError)
-> Parser (Maybe GelatoDocumentReportErrorCode')
-> Parser (Maybe Text -> GelatoDocumentReportError)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe GelatoDocumentReportErrorCode')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"code")) Parser (Maybe Text -> GelatoDocumentReportError)
-> Parser (Maybe Text) -> Parser GelatoDocumentReportError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"reason"))

-- | Create a new 'GelatoDocumentReportError' with all required fields.
mkGelatoDocumentReportError :: GelatoDocumentReportError
mkGelatoDocumentReportError :: GelatoDocumentReportError
mkGelatoDocumentReportError =
  GelatoDocumentReportError :: Maybe GelatoDocumentReportErrorCode'
-> Maybe Text -> GelatoDocumentReportError
GelatoDocumentReportError
    { gelatoDocumentReportErrorCode :: Maybe GelatoDocumentReportErrorCode'
gelatoDocumentReportErrorCode = Maybe GelatoDocumentReportErrorCode'
forall a. Maybe a
GHC.Maybe.Nothing,
      gelatoDocumentReportErrorReason :: Maybe Text
gelatoDocumentReportErrorReason = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @components.schemas.gelato_document_report_error.properties.code@ in the specification.
--
-- A short machine-readable string giving the reason for the verification failure.
data GelatoDocumentReportErrorCode'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    GelatoDocumentReportErrorCode'Other Data.Aeson.Types.Internal.Value
  | -- | This constructor can be used to send values to the server which are not present in the specification yet.
    GelatoDocumentReportErrorCode'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"document_expired"@
    GelatoDocumentReportErrorCode'EnumDocumentExpired
  | -- | Represents the JSON value @"document_type_not_supported"@
    GelatoDocumentReportErrorCode'EnumDocumentTypeNotSupported
  | -- | Represents the JSON value @"document_unverified_other"@
    GelatoDocumentReportErrorCode'EnumDocumentUnverifiedOther
  deriving (Int -> GelatoDocumentReportErrorCode' -> ShowS
[GelatoDocumentReportErrorCode'] -> ShowS
GelatoDocumentReportErrorCode' -> String
(Int -> GelatoDocumentReportErrorCode' -> ShowS)
-> (GelatoDocumentReportErrorCode' -> String)
-> ([GelatoDocumentReportErrorCode'] -> ShowS)
-> Show GelatoDocumentReportErrorCode'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GelatoDocumentReportErrorCode'] -> ShowS
$cshowList :: [GelatoDocumentReportErrorCode'] -> ShowS
show :: GelatoDocumentReportErrorCode' -> String
$cshow :: GelatoDocumentReportErrorCode' -> String
showsPrec :: Int -> GelatoDocumentReportErrorCode' -> ShowS
$cshowsPrec :: Int -> GelatoDocumentReportErrorCode' -> ShowS
GHC.Show.Show, GelatoDocumentReportErrorCode'
-> GelatoDocumentReportErrorCode' -> Bool
(GelatoDocumentReportErrorCode'
 -> GelatoDocumentReportErrorCode' -> Bool)
-> (GelatoDocumentReportErrorCode'
    -> GelatoDocumentReportErrorCode' -> Bool)
-> Eq GelatoDocumentReportErrorCode'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GelatoDocumentReportErrorCode'
-> GelatoDocumentReportErrorCode' -> Bool
$c/= :: GelatoDocumentReportErrorCode'
-> GelatoDocumentReportErrorCode' -> Bool
== :: GelatoDocumentReportErrorCode'
-> GelatoDocumentReportErrorCode' -> Bool
$c== :: GelatoDocumentReportErrorCode'
-> GelatoDocumentReportErrorCode' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON GelatoDocumentReportErrorCode' where
  toJSON :: GelatoDocumentReportErrorCode' -> Value
toJSON (GelatoDocumentReportErrorCode'Other Value
val) = Value
val
  toJSON (GelatoDocumentReportErrorCode'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (GelatoDocumentReportErrorCode'
GelatoDocumentReportErrorCode'EnumDocumentExpired) = Value
"document_expired"
  toJSON (GelatoDocumentReportErrorCode'
GelatoDocumentReportErrorCode'EnumDocumentTypeNotSupported) = Value
"document_type_not_supported"
  toJSON (GelatoDocumentReportErrorCode'
GelatoDocumentReportErrorCode'EnumDocumentUnverifiedOther) = Value
"document_unverified_other"

instance Data.Aeson.Types.FromJSON.FromJSON GelatoDocumentReportErrorCode' where
  parseJSON :: Value -> Parser GelatoDocumentReportErrorCode'
parseJSON Value
val =
    GelatoDocumentReportErrorCode'
-> Parser GelatoDocumentReportErrorCode'
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure
      ( if
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"document_expired" -> GelatoDocumentReportErrorCode'
GelatoDocumentReportErrorCode'EnumDocumentExpired
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"document_type_not_supported" -> GelatoDocumentReportErrorCode'
GelatoDocumentReportErrorCode'EnumDocumentTypeNotSupported
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"document_unverified_other" -> GelatoDocumentReportErrorCode'
GelatoDocumentReportErrorCode'EnumDocumentUnverifiedOther
            | Bool
GHC.Base.otherwise -> Value -> GelatoDocumentReportErrorCode'
GelatoDocumentReportErrorCode'Other Value
val
      )