{-# 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 PortalPaymentMethodUpdate
module StripeAPI.Types.PortalPaymentMethodUpdate 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.portal_payment_method_update@ in the specification.
data PortalPaymentMethodUpdate = PortalPaymentMethodUpdate
  { -- | enabled: Whether the feature is enabled.
    PortalPaymentMethodUpdate -> Bool
portalPaymentMethodUpdateEnabled :: GHC.Types.Bool
  }
  deriving
    ( Int -> PortalPaymentMethodUpdate -> ShowS
[PortalPaymentMethodUpdate] -> ShowS
PortalPaymentMethodUpdate -> String
(Int -> PortalPaymentMethodUpdate -> ShowS)
-> (PortalPaymentMethodUpdate -> String)
-> ([PortalPaymentMethodUpdate] -> ShowS)
-> Show PortalPaymentMethodUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortalPaymentMethodUpdate] -> ShowS
$cshowList :: [PortalPaymentMethodUpdate] -> ShowS
show :: PortalPaymentMethodUpdate -> String
$cshow :: PortalPaymentMethodUpdate -> String
showsPrec :: Int -> PortalPaymentMethodUpdate -> ShowS
$cshowsPrec :: Int -> PortalPaymentMethodUpdate -> ShowS
GHC.Show.Show,
      PortalPaymentMethodUpdate -> PortalPaymentMethodUpdate -> Bool
(PortalPaymentMethodUpdate -> PortalPaymentMethodUpdate -> Bool)
-> (PortalPaymentMethodUpdate -> PortalPaymentMethodUpdate -> Bool)
-> Eq PortalPaymentMethodUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortalPaymentMethodUpdate -> PortalPaymentMethodUpdate -> Bool
$c/= :: PortalPaymentMethodUpdate -> PortalPaymentMethodUpdate -> Bool
== :: PortalPaymentMethodUpdate -> PortalPaymentMethodUpdate -> Bool
$c== :: PortalPaymentMethodUpdate -> PortalPaymentMethodUpdate -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PortalPaymentMethodUpdate where
  toJSON :: PortalPaymentMethodUpdate -> Value
toJSON PortalPaymentMethodUpdate
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalPaymentMethodUpdate -> Bool
portalPaymentMethodUpdateEnabled PortalPaymentMethodUpdate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PortalPaymentMethodUpdate -> Encoding
toEncoding PortalPaymentMethodUpdate
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs (Text
"enabled" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalPaymentMethodUpdate -> Bool
portalPaymentMethodUpdateEnabled PortalPaymentMethodUpdate
obj)

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

-- | Create a new 'PortalPaymentMethodUpdate' with all required fields.
mkPortalPaymentMethodUpdate ::
  -- | 'portalPaymentMethodUpdateEnabled'
  GHC.Types.Bool ->
  PortalPaymentMethodUpdate
mkPortalPaymentMethodUpdate :: Bool -> PortalPaymentMethodUpdate
mkPortalPaymentMethodUpdate Bool
portalPaymentMethodUpdateEnabled = PortalPaymentMethodUpdate :: Bool -> PortalPaymentMethodUpdate
PortalPaymentMethodUpdate {portalPaymentMethodUpdateEnabled :: Bool
portalPaymentMethodUpdateEnabled = Bool
portalPaymentMethodUpdateEnabled}