{-# 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 BillingPortal_Configuration
module StripeAPI.Types.BillingPortal_Configuration 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.PortalBusinessProfile
import {-# SOURCE #-} StripeAPI.Types.PortalFeatures
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.billing_portal.configuration@ in the specification.
--
-- A portal configuration describes the functionality and behavior of a portal session.
data BillingPortal'configuration = BillingPortal'configuration
  { -- | active: Whether the configuration is active and can be used to create portal sessions.
    BillingPortal'configuration -> Bool
billingPortal'configurationActive :: GHC.Types.Bool,
    -- | application: ID of the Connect Application that created the configuration.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    BillingPortal'configuration -> Maybe Text
billingPortal'configurationApplication :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | business_profile:
    BillingPortal'configuration -> PortalBusinessProfile
billingPortal'configurationBusinessProfile :: PortalBusinessProfile,
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    BillingPortal'configuration -> Int
billingPortal'configurationCreated :: GHC.Types.Int,
    -- | default_return_url: The default URL to redirect customers to when they click on the portal\'s link to return to your website. This can be [overriden](https:\/\/stripe.com\/docs\/api\/customer_portal\/sessions\/create\#create_portal_session-return_url) when creating the session.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    BillingPortal'configuration -> Maybe Text
billingPortal'configurationDefaultReturnUrl :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | features:
    BillingPortal'configuration -> PortalFeatures
billingPortal'configurationFeatures :: PortalFeatures,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    BillingPortal'configuration -> Text
billingPortal'configurationId :: Data.Text.Internal.Text,
    -- | is_default: Whether the configuration is the default. If \`true\`, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session.
    BillingPortal'configuration -> Bool
billingPortal'configurationIsDefault :: GHC.Types.Bool,
    -- | livemode: Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.
    BillingPortal'configuration -> Bool
billingPortal'configurationLivemode :: GHC.Types.Bool,
    -- | updated: Time at which the object was last updated. Measured in seconds since the Unix epoch.
    BillingPortal'configuration -> Int
billingPortal'configurationUpdated :: GHC.Types.Int
  }
  deriving
    ( Int -> BillingPortal'configuration -> ShowS
[BillingPortal'configuration] -> ShowS
BillingPortal'configuration -> String
(Int -> BillingPortal'configuration -> ShowS)
-> (BillingPortal'configuration -> String)
-> ([BillingPortal'configuration] -> ShowS)
-> Show BillingPortal'configuration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BillingPortal'configuration] -> ShowS
$cshowList :: [BillingPortal'configuration] -> ShowS
show :: BillingPortal'configuration -> String
$cshow :: BillingPortal'configuration -> String
showsPrec :: Int -> BillingPortal'configuration -> ShowS
$cshowsPrec :: Int -> BillingPortal'configuration -> ShowS
GHC.Show.Show,
      BillingPortal'configuration -> BillingPortal'configuration -> Bool
(BillingPortal'configuration
 -> BillingPortal'configuration -> Bool)
-> (BillingPortal'configuration
    -> BillingPortal'configuration -> Bool)
-> Eq BillingPortal'configuration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BillingPortal'configuration -> BillingPortal'configuration -> Bool
$c/= :: BillingPortal'configuration -> BillingPortal'configuration -> Bool
== :: BillingPortal'configuration -> BillingPortal'configuration -> Bool
$c== :: BillingPortal'configuration -> BillingPortal'configuration -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON BillingPortal'configuration where
  toJSON :: BillingPortal'configuration -> Value
toJSON BillingPortal'configuration
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"active" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Bool
billingPortal'configurationActive BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"application" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Maybe Text
billingPortal'configurationApplication BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"business_profile" Text -> PortalBusinessProfile -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> PortalBusinessProfile
billingPortal'configurationBusinessProfile BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Int
billingPortal'configurationCreated BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"default_return_url" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Maybe Text
billingPortal'configurationDefaultReturnUrl BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"features" Text -> PortalFeatures -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> PortalFeatures
billingPortal'configurationFeatures BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Text
billingPortal'configurationId BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"is_default" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Bool
billingPortal'configurationIsDefault BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"livemode" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Bool
billingPortal'configurationLivemode BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"updated" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Int
billingPortal'configurationUpdated BillingPortal'configuration
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"object" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"billing_portal.configuration" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: BillingPortal'configuration -> Encoding
toEncoding BillingPortal'configuration
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"active" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Bool
billingPortal'configurationActive BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"application" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Maybe Text
billingPortal'configurationApplication BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"business_profile" Text -> PortalBusinessProfile -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> PortalBusinessProfile
billingPortal'configurationBusinessProfile BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Int
billingPortal'configurationCreated BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"default_return_url" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Maybe Text
billingPortal'configurationDefaultReturnUrl BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"features" Text -> PortalFeatures -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> PortalFeatures
billingPortal'configurationFeatures BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"id" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Text
billingPortal'configurationId BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"is_default" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Bool
billingPortal'configurationIsDefault BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"livemode" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Bool
billingPortal'configurationLivemode BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"updated" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BillingPortal'configuration -> Int
billingPortal'configurationUpdated BillingPortal'configuration
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"object" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"billing_portal.configuration")))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON BillingPortal'configuration where
  parseJSON :: Value -> Parser BillingPortal'configuration
parseJSON = String
-> (Object -> Parser BillingPortal'configuration)
-> Value
-> Parser BillingPortal'configuration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"BillingPortal'configuration" (\Object
obj -> ((((((((((Bool
 -> Maybe Text
 -> PortalBusinessProfile
 -> Int
 -> Maybe Text
 -> PortalFeatures
 -> Text
 -> Bool
 -> Bool
 -> Int
 -> BillingPortal'configuration)
-> Parser
     (Bool
      -> Maybe Text
      -> PortalBusinessProfile
      -> Int
      -> Maybe Text
      -> PortalFeatures
      -> Text
      -> Bool
      -> Bool
      -> Int
      -> BillingPortal'configuration)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Bool
-> Maybe Text
-> PortalBusinessProfile
-> Int
-> Maybe Text
-> PortalFeatures
-> Text
-> Bool
-> Bool
-> Int
-> BillingPortal'configuration
BillingPortal'configuration Parser
  (Bool
   -> Maybe Text
   -> PortalBusinessProfile
   -> Int
   -> Maybe Text
   -> PortalFeatures
   -> Text
   -> Bool
   -> Bool
   -> Int
   -> BillingPortal'configuration)
-> Parser Bool
-> Parser
     (Maybe Text
      -> PortalBusinessProfile
      -> Int
      -> Maybe Text
      -> PortalFeatures
      -> Text
      -> Bool
      -> Bool
      -> Int
      -> BillingPortal'configuration)
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
"active")) Parser
  (Maybe Text
   -> PortalBusinessProfile
   -> Int
   -> Maybe Text
   -> PortalFeatures
   -> Text
   -> Bool
   -> Bool
   -> Int
   -> BillingPortal'configuration)
-> Parser (Maybe Text)
-> Parser
     (PortalBusinessProfile
      -> Int
      -> Maybe Text
      -> PortalFeatures
      -> Text
      -> Bool
      -> Bool
      -> Int
      -> BillingPortal'configuration)
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
"application")) Parser
  (PortalBusinessProfile
   -> Int
   -> Maybe Text
   -> PortalFeatures
   -> Text
   -> Bool
   -> Bool
   -> Int
   -> BillingPortal'configuration)
-> Parser PortalBusinessProfile
-> Parser
     (Int
      -> Maybe Text
      -> PortalFeatures
      -> Text
      -> Bool
      -> Bool
      -> Int
      -> BillingPortal'configuration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalBusinessProfile
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"business_profile")) Parser
  (Int
   -> Maybe Text
   -> PortalFeatures
   -> Text
   -> Bool
   -> Bool
   -> Int
   -> BillingPortal'configuration)
-> Parser Int
-> Parser
     (Maybe Text
      -> PortalFeatures
      -> Text
      -> Bool
      -> Bool
      -> Int
      -> BillingPortal'configuration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"created")) Parser
  (Maybe Text
   -> PortalFeatures
   -> Text
   -> Bool
   -> Bool
   -> Int
   -> BillingPortal'configuration)
-> Parser (Maybe Text)
-> Parser
     (PortalFeatures
      -> Text -> Bool -> Bool -> Int -> BillingPortal'configuration)
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
"default_return_url")) Parser
  (PortalFeatures
   -> Text -> Bool -> Bool -> Int -> BillingPortal'configuration)
-> Parser PortalFeatures
-> Parser
     (Text -> Bool -> Bool -> Int -> BillingPortal'configuration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalFeatures
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"features")) Parser (Text -> Bool -> Bool -> Int -> BillingPortal'configuration)
-> Parser Text
-> Parser (Bool -> Bool -> Int -> BillingPortal'configuration)
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
"id")) Parser (Bool -> Bool -> Int -> BillingPortal'configuration)
-> Parser Bool
-> Parser (Bool -> Int -> BillingPortal'configuration)
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
"is_default")) Parser (Bool -> Int -> BillingPortal'configuration)
-> Parser Bool -> Parser (Int -> BillingPortal'configuration)
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
"livemode")) Parser (Int -> BillingPortal'configuration)
-> Parser Int -> Parser BillingPortal'configuration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"updated"))

-- | Create a new 'BillingPortal'configuration' with all required fields.
mkBillingPortal'configuration ::
  -- | 'billingPortal'configurationActive'
  GHC.Types.Bool ->
  -- | 'billingPortal'configurationBusinessProfile'
  PortalBusinessProfile ->
  -- | 'billingPortal'configurationCreated'
  GHC.Types.Int ->
  -- | 'billingPortal'configurationFeatures'
  PortalFeatures ->
  -- | 'billingPortal'configurationId'
  Data.Text.Internal.Text ->
  -- | 'billingPortal'configurationIsDefault'
  GHC.Types.Bool ->
  -- | 'billingPortal'configurationLivemode'
  GHC.Types.Bool ->
  -- | 'billingPortal'configurationUpdated'
  GHC.Types.Int ->
  BillingPortal'configuration
mkBillingPortal'configuration :: Bool
-> PortalBusinessProfile
-> Int
-> PortalFeatures
-> Text
-> Bool
-> Bool
-> Int
-> BillingPortal'configuration
mkBillingPortal'configuration Bool
billingPortal'configurationActive PortalBusinessProfile
billingPortal'configurationBusinessProfile Int
billingPortal'configurationCreated PortalFeatures
billingPortal'configurationFeatures Text
billingPortal'configurationId Bool
billingPortal'configurationIsDefault Bool
billingPortal'configurationLivemode Int
billingPortal'configurationUpdated =
  BillingPortal'configuration :: Bool
-> Maybe Text
-> PortalBusinessProfile
-> Int
-> Maybe Text
-> PortalFeatures
-> Text
-> Bool
-> Bool
-> Int
-> BillingPortal'configuration
BillingPortal'configuration
    { billingPortal'configurationActive :: Bool
billingPortal'configurationActive = Bool
billingPortal'configurationActive,
      billingPortal'configurationApplication :: Maybe Text
billingPortal'configurationApplication = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      billingPortal'configurationBusinessProfile :: PortalBusinessProfile
billingPortal'configurationBusinessProfile = PortalBusinessProfile
billingPortal'configurationBusinessProfile,
      billingPortal'configurationCreated :: Int
billingPortal'configurationCreated = Int
billingPortal'configurationCreated,
      billingPortal'configurationDefaultReturnUrl :: Maybe Text
billingPortal'configurationDefaultReturnUrl = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      billingPortal'configurationFeatures :: PortalFeatures
billingPortal'configurationFeatures = PortalFeatures
billingPortal'configurationFeatures,
      billingPortal'configurationId :: Text
billingPortal'configurationId = Text
billingPortal'configurationId,
      billingPortal'configurationIsDefault :: Bool
billingPortal'configurationIsDefault = Bool
billingPortal'configurationIsDefault,
      billingPortal'configurationLivemode :: Bool
billingPortal'configurationLivemode = Bool
billingPortal'configurationLivemode,
      billingPortal'configurationUpdated :: Int
billingPortal'configurationUpdated = Int
billingPortal'configurationUpdated
    }