{-# 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 MandateSepaDebit
module StripeAPI.Types.MandateSepaDebit 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.mandate_sepa_debit@ in the specification.
data MandateSepaDebit = MandateSepaDebit
  { -- | reference: The unique reference of the mandate.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    MandateSepaDebit -> Text
mandateSepaDebitReference :: Data.Text.Internal.Text,
    -- | url: The URL of the mandate. This URL generally contains sensitive information about the customer and should be shared with them exclusively.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    MandateSepaDebit -> Text
mandateSepaDebitUrl :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> MandateSepaDebit -> ShowS
[MandateSepaDebit] -> ShowS
MandateSepaDebit -> String
(Int -> MandateSepaDebit -> ShowS)
-> (MandateSepaDebit -> String)
-> ([MandateSepaDebit] -> ShowS)
-> Show MandateSepaDebit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MandateSepaDebit] -> ShowS
$cshowList :: [MandateSepaDebit] -> ShowS
show :: MandateSepaDebit -> String
$cshow :: MandateSepaDebit -> String
showsPrec :: Int -> MandateSepaDebit -> ShowS
$cshowsPrec :: Int -> MandateSepaDebit -> ShowS
GHC.Show.Show,
      MandateSepaDebit -> MandateSepaDebit -> Bool
(MandateSepaDebit -> MandateSepaDebit -> Bool)
-> (MandateSepaDebit -> MandateSepaDebit -> Bool)
-> Eq MandateSepaDebit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MandateSepaDebit -> MandateSepaDebit -> Bool
$c/= :: MandateSepaDebit -> MandateSepaDebit -> Bool
== :: MandateSepaDebit -> MandateSepaDebit -> Bool
$c== :: MandateSepaDebit -> MandateSepaDebit -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON MandateSepaDebit where
  toJSON :: MandateSepaDebit -> Value
toJSON MandateSepaDebit
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"reference" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= MandateSepaDebit -> Text
mandateSepaDebitReference MandateSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"url" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= MandateSepaDebit -> Text
mandateSepaDebitUrl MandateSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: MandateSepaDebit -> Encoding
toEncoding MandateSepaDebit
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"reference" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= MandateSepaDebit -> Text
mandateSepaDebitReference MandateSepaDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"url" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= MandateSepaDebit -> Text
mandateSepaDebitUrl MandateSepaDebit
obj))

instance Data.Aeson.Types.FromJSON.FromJSON MandateSepaDebit where
  parseJSON :: Value -> Parser MandateSepaDebit
parseJSON = String
-> (Object -> Parser MandateSepaDebit)
-> Value
-> Parser MandateSepaDebit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"MandateSepaDebit" (\Object
obj -> ((Text -> Text -> MandateSepaDebit)
-> Parser (Text -> Text -> MandateSepaDebit)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Text -> Text -> MandateSepaDebit
MandateSepaDebit Parser (Text -> Text -> MandateSepaDebit)
-> Parser Text -> Parser (Text -> MandateSepaDebit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"reference")) Parser (Text -> MandateSepaDebit)
-> Parser Text -> Parser MandateSepaDebit
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"url"))

-- | Create a new 'MandateSepaDebit' with all required fields.
mkMandateSepaDebit ::
  -- | 'mandateSepaDebitReference'
  Data.Text.Internal.Text ->
  -- | 'mandateSepaDebitUrl'
  Data.Text.Internal.Text ->
  MandateSepaDebit
mkMandateSepaDebit :: Text -> Text -> MandateSepaDebit
mkMandateSepaDebit Text
mandateSepaDebitReference Text
mandateSepaDebitUrl =
  MandateSepaDebit :: Text -> Text -> MandateSepaDebit
MandateSepaDebit
    { mandateSepaDebitReference :: Text
mandateSepaDebitReference = Text
mandateSepaDebitReference,
      mandateSepaDebitUrl :: Text
mandateSepaDebitUrl = Text
mandateSepaDebitUrl
    }