{-# 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 GelatoSessionDocumentOptions
module StripeAPI.Types.GelatoSessionDocumentOptions 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_session_document_options@ in the specification.
data GelatoSessionDocumentOptions = GelatoSessionDocumentOptions
  { -- | allowed_types: Array of strings of allowed identity document types. If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code.
    GelatoSessionDocumentOptions
-> Maybe [GelatoSessionDocumentOptionsAllowedTypes']
gelatoSessionDocumentOptionsAllowedTypes :: (GHC.Maybe.Maybe ([GelatoSessionDocumentOptionsAllowedTypes'])),
    -- | require_id_number: Collect an ID number and perform an [ID number check](https:\/\/stripe.com\/docs\/identity\/verification-checks?type=id-number) with the document’s extracted name and date of birth.
    GelatoSessionDocumentOptions -> Maybe Bool
gelatoSessionDocumentOptionsRequireIdNumber :: (GHC.Maybe.Maybe GHC.Types.Bool),
    -- | require_live_capture: Disable image uploads, identity document images have to be captured using the device’s camera.
    GelatoSessionDocumentOptions -> Maybe Bool
gelatoSessionDocumentOptionsRequireLiveCapture :: (GHC.Maybe.Maybe GHC.Types.Bool),
    -- | require_matching_selfie: Capture a face image and perform a [selfie check](https:\/\/stripe.com\/docs\/identity\/verification-checks?type=selfie) comparing a photo ID and a picture of your user’s face. [Learn more](https:\/\/stripe.com\/docs\/identity\/selfie).
    GelatoSessionDocumentOptions -> Maybe Bool
gelatoSessionDocumentOptionsRequireMatchingSelfie :: (GHC.Maybe.Maybe GHC.Types.Bool)
  }
  deriving
    ( Int -> GelatoSessionDocumentOptions -> ShowS
[GelatoSessionDocumentOptions] -> ShowS
GelatoSessionDocumentOptions -> String
(Int -> GelatoSessionDocumentOptions -> ShowS)
-> (GelatoSessionDocumentOptions -> String)
-> ([GelatoSessionDocumentOptions] -> ShowS)
-> Show GelatoSessionDocumentOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GelatoSessionDocumentOptions] -> ShowS
$cshowList :: [GelatoSessionDocumentOptions] -> ShowS
show :: GelatoSessionDocumentOptions -> String
$cshow :: GelatoSessionDocumentOptions -> String
showsPrec :: Int -> GelatoSessionDocumentOptions -> ShowS
$cshowsPrec :: Int -> GelatoSessionDocumentOptions -> ShowS
GHC.Show.Show,
      GelatoSessionDocumentOptions
-> GelatoSessionDocumentOptions -> Bool
(GelatoSessionDocumentOptions
 -> GelatoSessionDocumentOptions -> Bool)
-> (GelatoSessionDocumentOptions
    -> GelatoSessionDocumentOptions -> Bool)
-> Eq GelatoSessionDocumentOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GelatoSessionDocumentOptions
-> GelatoSessionDocumentOptions -> Bool
$c/= :: GelatoSessionDocumentOptions
-> GelatoSessionDocumentOptions -> Bool
== :: GelatoSessionDocumentOptions
-> GelatoSessionDocumentOptions -> Bool
$c== :: GelatoSessionDocumentOptions
-> GelatoSessionDocumentOptions -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON GelatoSessionDocumentOptions where
  toJSON :: GelatoSessionDocumentOptions -> Value
toJSON GelatoSessionDocumentOptions
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"allowed_types" Text -> Maybe [GelatoSessionDocumentOptionsAllowedTypes'] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoSessionDocumentOptions
-> Maybe [GelatoSessionDocumentOptionsAllowedTypes']
gelatoSessionDocumentOptionsAllowedTypes GelatoSessionDocumentOptions
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"require_id_number" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoSessionDocumentOptions -> Maybe Bool
gelatoSessionDocumentOptionsRequireIdNumber GelatoSessionDocumentOptions
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"require_live_capture" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoSessionDocumentOptions -> Maybe Bool
gelatoSessionDocumentOptionsRequireLiveCapture GelatoSessionDocumentOptions
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"require_matching_selfie" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoSessionDocumentOptions -> Maybe Bool
gelatoSessionDocumentOptionsRequireMatchingSelfie GelatoSessionDocumentOptions
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: GelatoSessionDocumentOptions -> Encoding
toEncoding GelatoSessionDocumentOptions
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"allowed_types" Text -> Maybe [GelatoSessionDocumentOptionsAllowedTypes'] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoSessionDocumentOptions
-> Maybe [GelatoSessionDocumentOptionsAllowedTypes']
gelatoSessionDocumentOptionsAllowedTypes GelatoSessionDocumentOptions
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"require_id_number" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoSessionDocumentOptions -> Maybe Bool
gelatoSessionDocumentOptionsRequireIdNumber GelatoSessionDocumentOptions
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"require_live_capture" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoSessionDocumentOptions -> Maybe Bool
gelatoSessionDocumentOptionsRequireLiveCapture GelatoSessionDocumentOptions
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"require_matching_selfie" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= GelatoSessionDocumentOptions -> Maybe Bool
gelatoSessionDocumentOptionsRequireMatchingSelfie GelatoSessionDocumentOptions
obj))))

instance Data.Aeson.Types.FromJSON.FromJSON GelatoSessionDocumentOptions where
  parseJSON :: Value -> Parser GelatoSessionDocumentOptions
parseJSON = String
-> (Object -> Parser GelatoSessionDocumentOptions)
-> Value
-> Parser GelatoSessionDocumentOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"GelatoSessionDocumentOptions" (\Object
obj -> ((((Maybe [GelatoSessionDocumentOptionsAllowedTypes']
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> GelatoSessionDocumentOptions)
-> Parser
     (Maybe [GelatoSessionDocumentOptionsAllowedTypes']
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> GelatoSessionDocumentOptions)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe [GelatoSessionDocumentOptionsAllowedTypes']
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> GelatoSessionDocumentOptions
GelatoSessionDocumentOptions Parser
  (Maybe [GelatoSessionDocumentOptionsAllowedTypes']
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> GelatoSessionDocumentOptions)
-> Parser (Maybe [GelatoSessionDocumentOptionsAllowedTypes'])
-> Parser
     (Maybe Bool
      -> Maybe Bool -> Maybe Bool -> GelatoSessionDocumentOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe [GelatoSessionDocumentOptionsAllowedTypes'])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"allowed_types")) Parser
  (Maybe Bool
   -> Maybe Bool -> Maybe Bool -> GelatoSessionDocumentOptions)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool -> Maybe Bool -> GelatoSessionDocumentOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"require_id_number")) Parser (Maybe Bool -> Maybe Bool -> GelatoSessionDocumentOptions)
-> Parser (Maybe Bool)
-> Parser (Maybe Bool -> GelatoSessionDocumentOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"require_live_capture")) Parser (Maybe Bool -> GelatoSessionDocumentOptions)
-> Parser (Maybe Bool) -> Parser GelatoSessionDocumentOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"require_matching_selfie"))

-- | Create a new 'GelatoSessionDocumentOptions' with all required fields.
mkGelatoSessionDocumentOptions :: GelatoSessionDocumentOptions
mkGelatoSessionDocumentOptions :: GelatoSessionDocumentOptions
mkGelatoSessionDocumentOptions =
  GelatoSessionDocumentOptions :: Maybe [GelatoSessionDocumentOptionsAllowedTypes']
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> GelatoSessionDocumentOptions
GelatoSessionDocumentOptions
    { gelatoSessionDocumentOptionsAllowedTypes :: Maybe [GelatoSessionDocumentOptionsAllowedTypes']
gelatoSessionDocumentOptionsAllowedTypes = Maybe [GelatoSessionDocumentOptionsAllowedTypes']
forall a. Maybe a
GHC.Maybe.Nothing,
      gelatoSessionDocumentOptionsRequireIdNumber :: Maybe Bool
gelatoSessionDocumentOptionsRequireIdNumber = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
      gelatoSessionDocumentOptionsRequireLiveCapture :: Maybe Bool
gelatoSessionDocumentOptionsRequireLiveCapture = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
      gelatoSessionDocumentOptionsRequireMatchingSelfie :: Maybe Bool
gelatoSessionDocumentOptionsRequireMatchingSelfie = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @components.schemas.gelato_session_document_options.properties.allowed_types.items@ in the specification.
data GelatoSessionDocumentOptionsAllowedTypes'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    GelatoSessionDocumentOptionsAllowedTypes'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.
    GelatoSessionDocumentOptionsAllowedTypes'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"driving_license"@
    GelatoSessionDocumentOptionsAllowedTypes'EnumDrivingLicense
  | -- | Represents the JSON value @"id_card"@
    GelatoSessionDocumentOptionsAllowedTypes'EnumIdCard
  | -- | Represents the JSON value @"passport"@
    GelatoSessionDocumentOptionsAllowedTypes'EnumPassport
  deriving (Int -> GelatoSessionDocumentOptionsAllowedTypes' -> ShowS
[GelatoSessionDocumentOptionsAllowedTypes'] -> ShowS
GelatoSessionDocumentOptionsAllowedTypes' -> String
(Int -> GelatoSessionDocumentOptionsAllowedTypes' -> ShowS)
-> (GelatoSessionDocumentOptionsAllowedTypes' -> String)
-> ([GelatoSessionDocumentOptionsAllowedTypes'] -> ShowS)
-> Show GelatoSessionDocumentOptionsAllowedTypes'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GelatoSessionDocumentOptionsAllowedTypes'] -> ShowS
$cshowList :: [GelatoSessionDocumentOptionsAllowedTypes'] -> ShowS
show :: GelatoSessionDocumentOptionsAllowedTypes' -> String
$cshow :: GelatoSessionDocumentOptionsAllowedTypes' -> String
showsPrec :: Int -> GelatoSessionDocumentOptionsAllowedTypes' -> ShowS
$cshowsPrec :: Int -> GelatoSessionDocumentOptionsAllowedTypes' -> ShowS
GHC.Show.Show, GelatoSessionDocumentOptionsAllowedTypes'
-> GelatoSessionDocumentOptionsAllowedTypes' -> Bool
(GelatoSessionDocumentOptionsAllowedTypes'
 -> GelatoSessionDocumentOptionsAllowedTypes' -> Bool)
-> (GelatoSessionDocumentOptionsAllowedTypes'
    -> GelatoSessionDocumentOptionsAllowedTypes' -> Bool)
-> Eq GelatoSessionDocumentOptionsAllowedTypes'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GelatoSessionDocumentOptionsAllowedTypes'
-> GelatoSessionDocumentOptionsAllowedTypes' -> Bool
$c/= :: GelatoSessionDocumentOptionsAllowedTypes'
-> GelatoSessionDocumentOptionsAllowedTypes' -> Bool
== :: GelatoSessionDocumentOptionsAllowedTypes'
-> GelatoSessionDocumentOptionsAllowedTypes' -> Bool
$c== :: GelatoSessionDocumentOptionsAllowedTypes'
-> GelatoSessionDocumentOptionsAllowedTypes' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON GelatoSessionDocumentOptionsAllowedTypes' where
  toJSON :: GelatoSessionDocumentOptionsAllowedTypes' -> Value
toJSON (GelatoSessionDocumentOptionsAllowedTypes'Other Value
val) = Value
val
  toJSON (GelatoSessionDocumentOptionsAllowedTypes'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (GelatoSessionDocumentOptionsAllowedTypes'
GelatoSessionDocumentOptionsAllowedTypes'EnumDrivingLicense) = Value
"driving_license"
  toJSON (GelatoSessionDocumentOptionsAllowedTypes'
GelatoSessionDocumentOptionsAllowedTypes'EnumIdCard) = Value
"id_card"
  toJSON (GelatoSessionDocumentOptionsAllowedTypes'
GelatoSessionDocumentOptionsAllowedTypes'EnumPassport) = Value
"passport"

instance Data.Aeson.Types.FromJSON.FromJSON GelatoSessionDocumentOptionsAllowedTypes' where
  parseJSON :: Value -> Parser GelatoSessionDocumentOptionsAllowedTypes'
parseJSON Value
val =
    GelatoSessionDocumentOptionsAllowedTypes'
-> Parser GelatoSessionDocumentOptionsAllowedTypes'
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
"driving_license" -> GelatoSessionDocumentOptionsAllowedTypes'
GelatoSessionDocumentOptionsAllowedTypes'EnumDrivingLicense
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"id_card" -> GelatoSessionDocumentOptionsAllowedTypes'
GelatoSessionDocumentOptionsAllowedTypes'EnumIdCard
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"passport" -> GelatoSessionDocumentOptionsAllowedTypes'
GelatoSessionDocumentOptionsAllowedTypes'EnumPassport
            | Bool
GHC.Base.otherwise -> Value -> GelatoSessionDocumentOptionsAllowedTypes'
GelatoSessionDocumentOptionsAllowedTypes'Other Value
val
      )