{-# 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 PlatformTaxFee
module StripeAPI.Types.PlatformTaxFee 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.platform_tax_fee@ in the specification.
data PlatformTaxFee = PlatformTaxFee
  { -- | account: The Connected account that incurred this charge.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PlatformTaxFee -> Text
platformTaxFeeAccount :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PlatformTaxFee -> Text
platformTaxFeeId :: Data.Text.Internal.Text,
    -- | source_transaction: The payment object that caused this tax to be inflicted.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PlatformTaxFee -> Text
platformTaxFeeSourceTransaction :: Data.Text.Internal.Text,
    -- | type: The type of tax (VAT).
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PlatformTaxFee -> Text
platformTaxFeeType :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> PlatformTaxFee -> ShowS
[PlatformTaxFee] -> ShowS
PlatformTaxFee -> String
(Int -> PlatformTaxFee -> ShowS)
-> (PlatformTaxFee -> String)
-> ([PlatformTaxFee] -> ShowS)
-> Show PlatformTaxFee
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlatformTaxFee] -> ShowS
$cshowList :: [PlatformTaxFee] -> ShowS
show :: PlatformTaxFee -> String
$cshow :: PlatformTaxFee -> String
showsPrec :: Int -> PlatformTaxFee -> ShowS
$cshowsPrec :: Int -> PlatformTaxFee -> ShowS
GHC.Show.Show,
      PlatformTaxFee -> PlatformTaxFee -> Bool
(PlatformTaxFee -> PlatformTaxFee -> Bool)
-> (PlatformTaxFee -> PlatformTaxFee -> Bool) -> Eq PlatformTaxFee
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlatformTaxFee -> PlatformTaxFee -> Bool
$c/= :: PlatformTaxFee -> PlatformTaxFee -> Bool
== :: PlatformTaxFee -> PlatformTaxFee -> Bool
$c== :: PlatformTaxFee -> PlatformTaxFee -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PlatformTaxFee where
  toJSON :: PlatformTaxFee -> Value
toJSON PlatformTaxFee
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"account" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PlatformTaxFee -> Text
platformTaxFeeAccount PlatformTaxFee
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..= PlatformTaxFee -> Text
platformTaxFeeId PlatformTaxFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"source_transaction" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PlatformTaxFee -> Text
platformTaxFeeSourceTransaction PlatformTaxFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PlatformTaxFee -> Text
platformTaxFeeType PlatformTaxFee
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
"platform_tax_fee" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PlatformTaxFee -> Encoding
toEncoding PlatformTaxFee
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"account" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PlatformTaxFee -> Text
platformTaxFeeAccount PlatformTaxFee
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..= PlatformTaxFee -> Text
platformTaxFeeId PlatformTaxFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"source_transaction" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PlatformTaxFee -> Text
platformTaxFeeSourceTransaction PlatformTaxFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"type" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PlatformTaxFee -> Text
platformTaxFeeType PlatformTaxFee
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
"platform_tax_fee")))))

instance Data.Aeson.Types.FromJSON.FromJSON PlatformTaxFee where
  parseJSON :: Value -> Parser PlatformTaxFee
parseJSON = String
-> (Object -> Parser PlatformTaxFee)
-> Value
-> Parser PlatformTaxFee
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PlatformTaxFee" (\Object
obj -> ((((Text -> Text -> Text -> Text -> PlatformTaxFee)
-> Parser (Text -> Text -> Text -> Text -> PlatformTaxFee)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Text -> Text -> Text -> Text -> PlatformTaxFee
PlatformTaxFee Parser (Text -> Text -> Text -> Text -> PlatformTaxFee)
-> Parser Text -> Parser (Text -> Text -> Text -> PlatformTaxFee)
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
"account")) Parser (Text -> Text -> Text -> PlatformTaxFee)
-> Parser Text -> Parser (Text -> Text -> PlatformTaxFee)
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 (Text -> Text -> PlatformTaxFee)
-> Parser Text -> Parser (Text -> PlatformTaxFee)
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
"source_transaction")) Parser (Text -> PlatformTaxFee)
-> Parser Text -> Parser PlatformTaxFee
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
"type"))

-- | Create a new 'PlatformTaxFee' with all required fields.
mkPlatformTaxFee ::
  -- | 'platformTaxFeeAccount'
  Data.Text.Internal.Text ->
  -- | 'platformTaxFeeId'
  Data.Text.Internal.Text ->
  -- | 'platformTaxFeeSourceTransaction'
  Data.Text.Internal.Text ->
  -- | 'platformTaxFeeType'
  Data.Text.Internal.Text ->
  PlatformTaxFee
mkPlatformTaxFee :: Text -> Text -> Text -> Text -> PlatformTaxFee
mkPlatformTaxFee Text
platformTaxFeeAccount Text
platformTaxFeeId Text
platformTaxFeeSourceTransaction Text
platformTaxFeeType =
  PlatformTaxFee :: Text -> Text -> Text -> Text -> PlatformTaxFee
PlatformTaxFee
    { platformTaxFeeAccount :: Text
platformTaxFeeAccount = Text
platformTaxFeeAccount,
      platformTaxFeeId :: Text
platformTaxFeeId = Text
platformTaxFeeId,
      platformTaxFeeSourceTransaction :: Text
platformTaxFeeSourceTransaction = Text
platformTaxFeeSourceTransaction,
      platformTaxFeeType :: Text
platformTaxFeeType = Text
platformTaxFeeType
    }