{-# 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 SubscriptionAutomaticTax
module StripeAPI.Types.SubscriptionAutomaticTax 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.subscription_automatic_tax@ in the specification.
data SubscriptionAutomaticTax = SubscriptionAutomaticTax
  { -- | enabled: Whether Stripe automatically computes tax on this subscription.
    SubscriptionAutomaticTax -> Bool
subscriptionAutomaticTaxEnabled :: GHC.Types.Bool
  }
  deriving
    ( Int -> SubscriptionAutomaticTax -> ShowS
[SubscriptionAutomaticTax] -> ShowS
SubscriptionAutomaticTax -> String
(Int -> SubscriptionAutomaticTax -> ShowS)
-> (SubscriptionAutomaticTax -> String)
-> ([SubscriptionAutomaticTax] -> ShowS)
-> Show SubscriptionAutomaticTax
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubscriptionAutomaticTax] -> ShowS
$cshowList :: [SubscriptionAutomaticTax] -> ShowS
show :: SubscriptionAutomaticTax -> String
$cshow :: SubscriptionAutomaticTax -> String
showsPrec :: Int -> SubscriptionAutomaticTax -> ShowS
$cshowsPrec :: Int -> SubscriptionAutomaticTax -> ShowS
GHC.Show.Show,
      SubscriptionAutomaticTax -> SubscriptionAutomaticTax -> Bool
(SubscriptionAutomaticTax -> SubscriptionAutomaticTax -> Bool)
-> (SubscriptionAutomaticTax -> SubscriptionAutomaticTax -> Bool)
-> Eq SubscriptionAutomaticTax
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubscriptionAutomaticTax -> SubscriptionAutomaticTax -> Bool
$c/= :: SubscriptionAutomaticTax -> SubscriptionAutomaticTax -> Bool
== :: SubscriptionAutomaticTax -> SubscriptionAutomaticTax -> Bool
$c== :: SubscriptionAutomaticTax -> SubscriptionAutomaticTax -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionAutomaticTax where
  toJSON :: SubscriptionAutomaticTax -> Value
toJSON SubscriptionAutomaticTax
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..= SubscriptionAutomaticTax -> Bool
subscriptionAutomaticTaxEnabled SubscriptionAutomaticTax
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: SubscriptionAutomaticTax -> Encoding
toEncoding SubscriptionAutomaticTax
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..= SubscriptionAutomaticTax -> Bool
subscriptionAutomaticTaxEnabled SubscriptionAutomaticTax
obj)

instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionAutomaticTax where
  parseJSON :: Value -> Parser SubscriptionAutomaticTax
parseJSON = String
-> (Object -> Parser SubscriptionAutomaticTax)
-> Value
-> Parser SubscriptionAutomaticTax
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SubscriptionAutomaticTax" (\Object
obj -> (Bool -> SubscriptionAutomaticTax)
-> Parser (Bool -> SubscriptionAutomaticTax)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Bool -> SubscriptionAutomaticTax
SubscriptionAutomaticTax Parser (Bool -> SubscriptionAutomaticTax)
-> Parser Bool -> Parser SubscriptionAutomaticTax
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 'SubscriptionAutomaticTax' with all required fields.
mkSubscriptionAutomaticTax ::
  -- | 'subscriptionAutomaticTaxEnabled'
  GHC.Types.Bool ->
  SubscriptionAutomaticTax
mkSubscriptionAutomaticTax :: Bool -> SubscriptionAutomaticTax
mkSubscriptionAutomaticTax Bool
subscriptionAutomaticTaxEnabled = SubscriptionAutomaticTax :: Bool -> SubscriptionAutomaticTax
SubscriptionAutomaticTax {subscriptionAutomaticTaxEnabled :: Bool
subscriptionAutomaticTaxEnabled = Bool
subscriptionAutomaticTaxEnabled}