{-# 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 PortalFeatures
module StripeAPI.Types.PortalFeatures 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 {-# SOURCE #-} StripeAPI.Types.PortalCustomerUpdate
import {-# SOURCE #-} StripeAPI.Types.PortalInvoiceList
import {-# SOURCE #-} StripeAPI.Types.PortalPaymentMethodUpdate
import {-# SOURCE #-} StripeAPI.Types.PortalSubscriptionCancel
import {-# SOURCE #-} StripeAPI.Types.PortalSubscriptionPause
import {-# SOURCE #-} StripeAPI.Types.PortalSubscriptionUpdate
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.portal_features@ in the specification.
data PortalFeatures = PortalFeatures
  { -- | customer_update:
    PortalFeatures -> PortalCustomerUpdate
portalFeaturesCustomerUpdate :: PortalCustomerUpdate,
    -- | invoice_history:
    PortalFeatures -> PortalInvoiceList
portalFeaturesInvoiceHistory :: PortalInvoiceList,
    -- | payment_method_update:
    PortalFeatures -> PortalPaymentMethodUpdate
portalFeaturesPaymentMethodUpdate :: PortalPaymentMethodUpdate,
    -- | subscription_cancel:
    PortalFeatures -> PortalSubscriptionCancel
portalFeaturesSubscriptionCancel :: PortalSubscriptionCancel,
    -- | subscription_pause:
    PortalFeatures -> PortalSubscriptionPause
portalFeaturesSubscriptionPause :: PortalSubscriptionPause,
    -- | subscription_update:
    PortalFeatures -> PortalSubscriptionUpdate
portalFeaturesSubscriptionUpdate :: PortalSubscriptionUpdate
  }
  deriving
    ( Int -> PortalFeatures -> ShowS
[PortalFeatures] -> ShowS
PortalFeatures -> String
(Int -> PortalFeatures -> ShowS)
-> (PortalFeatures -> String)
-> ([PortalFeatures] -> ShowS)
-> Show PortalFeatures
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortalFeatures] -> ShowS
$cshowList :: [PortalFeatures] -> ShowS
show :: PortalFeatures -> String
$cshow :: PortalFeatures -> String
showsPrec :: Int -> PortalFeatures -> ShowS
$cshowsPrec :: Int -> PortalFeatures -> ShowS
GHC.Show.Show,
      PortalFeatures -> PortalFeatures -> Bool
(PortalFeatures -> PortalFeatures -> Bool)
-> (PortalFeatures -> PortalFeatures -> Bool) -> Eq PortalFeatures
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortalFeatures -> PortalFeatures -> Bool
$c/= :: PortalFeatures -> PortalFeatures -> Bool
== :: PortalFeatures -> PortalFeatures -> Bool
$c== :: PortalFeatures -> PortalFeatures -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PortalFeatures where
  toJSON :: PortalFeatures -> Value
toJSON PortalFeatures
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"customer_update" Text -> PortalCustomerUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalCustomerUpdate
portalFeaturesCustomerUpdate PortalFeatures
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"invoice_history" Text -> PortalInvoiceList -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalInvoiceList
portalFeaturesInvoiceHistory PortalFeatures
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"payment_method_update" Text -> PortalPaymentMethodUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalPaymentMethodUpdate
portalFeaturesPaymentMethodUpdate PortalFeatures
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"subscription_cancel" Text -> PortalSubscriptionCancel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalSubscriptionCancel
portalFeaturesSubscriptionCancel PortalFeatures
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"subscription_pause" Text -> PortalSubscriptionPause -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalSubscriptionPause
portalFeaturesSubscriptionPause PortalFeatures
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"subscription_update" Text -> PortalSubscriptionUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalSubscriptionUpdate
portalFeaturesSubscriptionUpdate PortalFeatures
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PortalFeatures -> Encoding
toEncoding PortalFeatures
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"customer_update" Text -> PortalCustomerUpdate -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalCustomerUpdate
portalFeaturesCustomerUpdate PortalFeatures
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"invoice_history" Text -> PortalInvoiceList -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalInvoiceList
portalFeaturesInvoiceHistory PortalFeatures
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"payment_method_update" Text -> PortalPaymentMethodUpdate -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalPaymentMethodUpdate
portalFeaturesPaymentMethodUpdate PortalFeatures
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"subscription_cancel" Text -> PortalSubscriptionCancel -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalSubscriptionCancel
portalFeaturesSubscriptionCancel PortalFeatures
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"subscription_pause" Text -> PortalSubscriptionPause -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalSubscriptionPause
portalFeaturesSubscriptionPause PortalFeatures
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"subscription_update" Text -> PortalSubscriptionUpdate -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalFeatures -> PortalSubscriptionUpdate
portalFeaturesSubscriptionUpdate PortalFeatures
obj))))))

instance Data.Aeson.Types.FromJSON.FromJSON PortalFeatures where
  parseJSON :: Value -> Parser PortalFeatures
parseJSON = String
-> (Object -> Parser PortalFeatures)
-> Value
-> Parser PortalFeatures
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PortalFeatures" (\Object
obj -> ((((((PortalCustomerUpdate
 -> PortalInvoiceList
 -> PortalPaymentMethodUpdate
 -> PortalSubscriptionCancel
 -> PortalSubscriptionPause
 -> PortalSubscriptionUpdate
 -> PortalFeatures)
-> Parser
     (PortalCustomerUpdate
      -> PortalInvoiceList
      -> PortalPaymentMethodUpdate
      -> PortalSubscriptionCancel
      -> PortalSubscriptionPause
      -> PortalSubscriptionUpdate
      -> PortalFeatures)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PortalCustomerUpdate
-> PortalInvoiceList
-> PortalPaymentMethodUpdate
-> PortalSubscriptionCancel
-> PortalSubscriptionPause
-> PortalSubscriptionUpdate
-> PortalFeatures
PortalFeatures Parser
  (PortalCustomerUpdate
   -> PortalInvoiceList
   -> PortalPaymentMethodUpdate
   -> PortalSubscriptionCancel
   -> PortalSubscriptionPause
   -> PortalSubscriptionUpdate
   -> PortalFeatures)
-> Parser PortalCustomerUpdate
-> Parser
     (PortalInvoiceList
      -> PortalPaymentMethodUpdate
      -> PortalSubscriptionCancel
      -> PortalSubscriptionPause
      -> PortalSubscriptionUpdate
      -> PortalFeatures)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalCustomerUpdate
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"customer_update")) Parser
  (PortalInvoiceList
   -> PortalPaymentMethodUpdate
   -> PortalSubscriptionCancel
   -> PortalSubscriptionPause
   -> PortalSubscriptionUpdate
   -> PortalFeatures)
-> Parser PortalInvoiceList
-> Parser
     (PortalPaymentMethodUpdate
      -> PortalSubscriptionCancel
      -> PortalSubscriptionPause
      -> PortalSubscriptionUpdate
      -> PortalFeatures)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalInvoiceList
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"invoice_history")) Parser
  (PortalPaymentMethodUpdate
   -> PortalSubscriptionCancel
   -> PortalSubscriptionPause
   -> PortalSubscriptionUpdate
   -> PortalFeatures)
-> Parser PortalPaymentMethodUpdate
-> Parser
     (PortalSubscriptionCancel
      -> PortalSubscriptionPause
      -> PortalSubscriptionUpdate
      -> PortalFeatures)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalPaymentMethodUpdate
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"payment_method_update")) Parser
  (PortalSubscriptionCancel
   -> PortalSubscriptionPause
   -> PortalSubscriptionUpdate
   -> PortalFeatures)
-> Parser PortalSubscriptionCancel
-> Parser
     (PortalSubscriptionPause
      -> PortalSubscriptionUpdate -> PortalFeatures)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalSubscriptionCancel
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"subscription_cancel")) Parser
  (PortalSubscriptionPause
   -> PortalSubscriptionUpdate -> PortalFeatures)
-> Parser PortalSubscriptionPause
-> Parser (PortalSubscriptionUpdate -> PortalFeatures)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalSubscriptionPause
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"subscription_pause")) Parser (PortalSubscriptionUpdate -> PortalFeatures)
-> Parser PortalSubscriptionUpdate -> Parser PortalFeatures
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalSubscriptionUpdate
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"subscription_update"))

-- | Create a new 'PortalFeatures' with all required fields.
mkPortalFeatures ::
  -- | 'portalFeaturesCustomerUpdate'
  PortalCustomerUpdate ->
  -- | 'portalFeaturesInvoiceHistory'
  PortalInvoiceList ->
  -- | 'portalFeaturesPaymentMethodUpdate'
  PortalPaymentMethodUpdate ->
  -- | 'portalFeaturesSubscriptionCancel'
  PortalSubscriptionCancel ->
  -- | 'portalFeaturesSubscriptionPause'
  PortalSubscriptionPause ->
  -- | 'portalFeaturesSubscriptionUpdate'
  PortalSubscriptionUpdate ->
  PortalFeatures
mkPortalFeatures :: PortalCustomerUpdate
-> PortalInvoiceList
-> PortalPaymentMethodUpdate
-> PortalSubscriptionCancel
-> PortalSubscriptionPause
-> PortalSubscriptionUpdate
-> PortalFeatures
mkPortalFeatures PortalCustomerUpdate
portalFeaturesCustomerUpdate PortalInvoiceList
portalFeaturesInvoiceHistory PortalPaymentMethodUpdate
portalFeaturesPaymentMethodUpdate PortalSubscriptionCancel
portalFeaturesSubscriptionCancel PortalSubscriptionPause
portalFeaturesSubscriptionPause PortalSubscriptionUpdate
portalFeaturesSubscriptionUpdate =
  PortalFeatures :: PortalCustomerUpdate
-> PortalInvoiceList
-> PortalPaymentMethodUpdate
-> PortalSubscriptionCancel
-> PortalSubscriptionPause
-> PortalSubscriptionUpdate
-> PortalFeatures
PortalFeatures
    { portalFeaturesCustomerUpdate :: PortalCustomerUpdate
portalFeaturesCustomerUpdate = PortalCustomerUpdate
portalFeaturesCustomerUpdate,
      portalFeaturesInvoiceHistory :: PortalInvoiceList
portalFeaturesInvoiceHistory = PortalInvoiceList
portalFeaturesInvoiceHistory,
      portalFeaturesPaymentMethodUpdate :: PortalPaymentMethodUpdate
portalFeaturesPaymentMethodUpdate = PortalPaymentMethodUpdate
portalFeaturesPaymentMethodUpdate,
      portalFeaturesSubscriptionCancel :: PortalSubscriptionCancel
portalFeaturesSubscriptionCancel = PortalSubscriptionCancel
portalFeaturesSubscriptionCancel,
      portalFeaturesSubscriptionPause :: PortalSubscriptionPause
portalFeaturesSubscriptionPause = PortalSubscriptionPause
portalFeaturesSubscriptionPause,
      portalFeaturesSubscriptionUpdate :: PortalSubscriptionUpdate
portalFeaturesSubscriptionUpdate = PortalSubscriptionUpdate
portalFeaturesSubscriptionUpdate
    }