{-# 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 PaymentMethodCardChecks
module StripeAPI.Types.PaymentMethodCardChecks 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.payment_method_card_checks@ in the specification.
data PaymentMethodCardChecks = PaymentMethodCardChecks
  { -- | address_line1_check: If a address line1 was provided, results of the check, one of \`pass\`, \`fail\`, \`unavailable\`, or \`unchecked\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodCardChecks -> Maybe Text
paymentMethodCardChecksAddressLine1Check :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | address_postal_code_check: If a address postal code was provided, results of the check, one of \`pass\`, \`fail\`, \`unavailable\`, or \`unchecked\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodCardChecks -> Maybe Text
paymentMethodCardChecksAddressPostalCodeCheck :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | cvc_check: If a CVC was provided, results of the check, one of \`pass\`, \`fail\`, \`unavailable\`, or \`unchecked\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodCardChecks -> Maybe Text
paymentMethodCardChecksCvcCheck :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> PaymentMethodCardChecks -> ShowS
[PaymentMethodCardChecks] -> ShowS
PaymentMethodCardChecks -> String
(Int -> PaymentMethodCardChecks -> ShowS)
-> (PaymentMethodCardChecks -> String)
-> ([PaymentMethodCardChecks] -> ShowS)
-> Show PaymentMethodCardChecks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodCardChecks] -> ShowS
$cshowList :: [PaymentMethodCardChecks] -> ShowS
show :: PaymentMethodCardChecks -> String
$cshow :: PaymentMethodCardChecks -> String
showsPrec :: Int -> PaymentMethodCardChecks -> ShowS
$cshowsPrec :: Int -> PaymentMethodCardChecks -> ShowS
GHC.Show.Show,
      PaymentMethodCardChecks -> PaymentMethodCardChecks -> Bool
(PaymentMethodCardChecks -> PaymentMethodCardChecks -> Bool)
-> (PaymentMethodCardChecks -> PaymentMethodCardChecks -> Bool)
-> Eq PaymentMethodCardChecks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodCardChecks -> PaymentMethodCardChecks -> Bool
$c/= :: PaymentMethodCardChecks -> PaymentMethodCardChecks -> Bool
== :: PaymentMethodCardChecks -> PaymentMethodCardChecks -> Bool
$c== :: PaymentMethodCardChecks -> PaymentMethodCardChecks -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodCardChecks where
  toJSON :: PaymentMethodCardChecks -> Value
toJSON PaymentMethodCardChecks
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"address_line1_check" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodCardChecks -> Maybe Text
paymentMethodCardChecksAddressLine1Check PaymentMethodCardChecks
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"address_postal_code_check" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodCardChecks -> Maybe Text
paymentMethodCardChecksAddressPostalCodeCheck PaymentMethodCardChecks
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"cvc_check" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodCardChecks -> Maybe Text
paymentMethodCardChecksCvcCheck PaymentMethodCardChecks
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentMethodCardChecks -> Encoding
toEncoding PaymentMethodCardChecks
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"address_line1_check" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodCardChecks -> Maybe Text
paymentMethodCardChecksAddressLine1Check PaymentMethodCardChecks
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"address_postal_code_check" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodCardChecks -> Maybe Text
paymentMethodCardChecksAddressPostalCodeCheck PaymentMethodCardChecks
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"cvc_check" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodCardChecks -> Maybe Text
paymentMethodCardChecksCvcCheck PaymentMethodCardChecks
obj)))

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

-- | Create a new 'PaymentMethodCardChecks' with all required fields.
mkPaymentMethodCardChecks :: PaymentMethodCardChecks
mkPaymentMethodCardChecks :: PaymentMethodCardChecks
mkPaymentMethodCardChecks =
  PaymentMethodCardChecks :: Maybe Text -> Maybe Text -> Maybe Text -> PaymentMethodCardChecks
PaymentMethodCardChecks
    { paymentMethodCardChecksAddressLine1Check :: Maybe Text
paymentMethodCardChecksAddressLine1Check = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodCardChecksAddressPostalCodeCheck :: Maybe Text
paymentMethodCardChecksAddressPostalCodeCheck = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodCardChecksCvcCheck :: Maybe Text
paymentMethodCardChecksCvcCheck = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }