{-# 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 ApplicationFee
module StripeAPI.Types.ApplicationFee 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.Account
import {-# SOURCE #-} StripeAPI.Types.Application
import {-# SOURCE #-} StripeAPI.Types.BalanceTransaction
import {-# SOURCE #-} StripeAPI.Types.Charge
import {-# SOURCE #-} StripeAPI.Types.FeeRefund
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.application_fee@ in the specification.
data ApplicationFee = ApplicationFee
  { -- | account: ID of the Stripe account this fee was taken from.
    ApplicationFee -> ApplicationFeeAccount'Variants
applicationFeeAccount :: ApplicationFeeAccount'Variants,
    -- | amount: Amount earned, in %s.
    ApplicationFee -> Int
applicationFeeAmount :: GHC.Types.Int,
    -- | amount_refunded: Amount in %s refunded (can be less than the amount attribute on the fee if a partial refund was issued)
    ApplicationFee -> Int
applicationFeeAmountRefunded :: GHC.Types.Int,
    -- | application: ID of the Connect application that earned the fee.
    ApplicationFee -> ApplicationFeeApplication'Variants
applicationFeeApplication :: ApplicationFeeApplication'Variants,
    -- | balance_transaction: Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).
    ApplicationFee -> Maybe ApplicationFeeBalanceTransaction'Variants
applicationFeeBalanceTransaction :: (GHC.Maybe.Maybe ApplicationFeeBalanceTransaction'Variants),
    -- | charge: ID of the charge that the application fee was taken from.
    ApplicationFee -> ApplicationFeeCharge'Variants
applicationFeeCharge :: ApplicationFeeCharge'Variants,
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    ApplicationFee -> Int
applicationFeeCreated :: GHC.Types.Int,
    -- | currency: Three-letter [ISO currency code](https:\/\/www.iso.org\/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https:\/\/stripe.com\/docs\/currencies).
    ApplicationFee -> Text
applicationFeeCurrency :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    ApplicationFee -> Text
applicationFeeId :: Data.Text.Internal.Text,
    -- | livemode: Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.
    ApplicationFee -> Bool
applicationFeeLivemode :: GHC.Types.Bool,
    -- | originating_transaction: ID of the corresponding charge on the platform account, if this fee was the result of a charge using the \`destination\` parameter.
    ApplicationFee
-> Maybe ApplicationFeeOriginatingTransaction'Variants
applicationFeeOriginatingTransaction :: (GHC.Maybe.Maybe ApplicationFeeOriginatingTransaction'Variants),
    -- | refunded: Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false.
    ApplicationFee -> Bool
applicationFeeRefunded :: GHC.Types.Bool,
    -- | refunds: A list of refunds that have been applied to the fee.
    ApplicationFee -> ApplicationFeeRefunds'
applicationFeeRefunds :: ApplicationFeeRefunds'
  }
  deriving
    ( Int -> ApplicationFee -> ShowS
[ApplicationFee] -> ShowS
ApplicationFee -> String
(Int -> ApplicationFee -> ShowS)
-> (ApplicationFee -> String)
-> ([ApplicationFee] -> ShowS)
-> Show ApplicationFee
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationFee] -> ShowS
$cshowList :: [ApplicationFee] -> ShowS
show :: ApplicationFee -> String
$cshow :: ApplicationFee -> String
showsPrec :: Int -> ApplicationFee -> ShowS
$cshowsPrec :: Int -> ApplicationFee -> ShowS
GHC.Show.Show,
      ApplicationFee -> ApplicationFee -> Bool
(ApplicationFee -> ApplicationFee -> Bool)
-> (ApplicationFee -> ApplicationFee -> Bool) -> Eq ApplicationFee
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationFee -> ApplicationFee -> Bool
$c/= :: ApplicationFee -> ApplicationFee -> Bool
== :: ApplicationFee -> ApplicationFee -> Bool
$c== :: ApplicationFee -> ApplicationFee -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON ApplicationFee where
  toJSON :: ApplicationFee -> Value
toJSON ApplicationFee
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"account" Text -> ApplicationFeeAccount'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> ApplicationFeeAccount'Variants
applicationFeeAccount ApplicationFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"amount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Int
applicationFeeAmount ApplicationFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"amount_refunded" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Int
applicationFeeAmountRefunded ApplicationFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"application" Text -> ApplicationFeeApplication'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> ApplicationFeeApplication'Variants
applicationFeeApplication ApplicationFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"balance_transaction" Text -> Maybe ApplicationFeeBalanceTransaction'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Maybe ApplicationFeeBalanceTransaction'Variants
applicationFeeBalanceTransaction ApplicationFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"charge" Text -> ApplicationFeeCharge'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> ApplicationFeeCharge'Variants
applicationFeeCharge ApplicationFee
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..= ApplicationFee -> Int
applicationFeeCreated ApplicationFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"currency" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Text
applicationFeeCurrency ApplicationFee
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..= ApplicationFee -> Text
applicationFeeId ApplicationFee
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..= ApplicationFee -> Bool
applicationFeeLivemode ApplicationFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"originating_transaction" Text -> Maybe ApplicationFeeOriginatingTransaction'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee
-> Maybe ApplicationFeeOriginatingTransaction'Variants
applicationFeeOriginatingTransaction ApplicationFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refunded" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Bool
applicationFeeRefunded ApplicationFee
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refunds" Text -> ApplicationFeeRefunds' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> ApplicationFeeRefunds'
applicationFeeRefunds ApplicationFee
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
"application_fee" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: ApplicationFee -> Encoding
toEncoding ApplicationFee
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"account" Text -> ApplicationFeeAccount'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> ApplicationFeeAccount'Variants
applicationFeeAccount ApplicationFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"amount" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Int
applicationFeeAmount ApplicationFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"amount_refunded" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Int
applicationFeeAmountRefunded ApplicationFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"application" Text -> ApplicationFeeApplication'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> ApplicationFeeApplication'Variants
applicationFeeApplication ApplicationFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"balance_transaction" Text -> Maybe ApplicationFeeBalanceTransaction'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Maybe ApplicationFeeBalanceTransaction'Variants
applicationFeeBalanceTransaction ApplicationFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"charge" Text -> ApplicationFeeCharge'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> ApplicationFeeCharge'Variants
applicationFeeCharge ApplicationFee
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..= ApplicationFee -> Int
applicationFeeCreated ApplicationFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"currency" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Text
applicationFeeCurrency ApplicationFee
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..= ApplicationFee -> Text
applicationFeeId ApplicationFee
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..= ApplicationFee -> Bool
applicationFeeLivemode ApplicationFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"originating_transaction" Text
-> Maybe ApplicationFeeOriginatingTransaction'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee
-> Maybe ApplicationFeeOriginatingTransaction'Variants
applicationFeeOriginatingTransaction ApplicationFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"refunded" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> Bool
applicationFeeRefunded ApplicationFee
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"refunds" Text -> ApplicationFeeRefunds' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFee -> ApplicationFeeRefunds'
applicationFeeRefunds ApplicationFee
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
"application_fee"))))))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON ApplicationFee where
  parseJSON :: Value -> Parser ApplicationFee
parseJSON = String
-> (Object -> Parser ApplicationFee)
-> Value
-> Parser ApplicationFee
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"ApplicationFee" (\Object
obj -> (((((((((((((ApplicationFeeAccount'Variants
 -> Int
 -> Int
 -> ApplicationFeeApplication'Variants
 -> Maybe ApplicationFeeBalanceTransaction'Variants
 -> ApplicationFeeCharge'Variants
 -> Int
 -> Text
 -> Text
 -> Bool
 -> Maybe ApplicationFeeOriginatingTransaction'Variants
 -> Bool
 -> ApplicationFeeRefunds'
 -> ApplicationFee)
-> Parser
     (ApplicationFeeAccount'Variants
      -> Int
      -> Int
      -> ApplicationFeeApplication'Variants
      -> Maybe ApplicationFeeBalanceTransaction'Variants
      -> ApplicationFeeCharge'Variants
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure ApplicationFeeAccount'Variants
-> Int
-> Int
-> ApplicationFeeApplication'Variants
-> Maybe ApplicationFeeBalanceTransaction'Variants
-> ApplicationFeeCharge'Variants
-> Int
-> Text
-> Text
-> Bool
-> Maybe ApplicationFeeOriginatingTransaction'Variants
-> Bool
-> ApplicationFeeRefunds'
-> ApplicationFee
ApplicationFee Parser
  (ApplicationFeeAccount'Variants
   -> Int
   -> Int
   -> ApplicationFeeApplication'Variants
   -> Maybe ApplicationFeeBalanceTransaction'Variants
   -> ApplicationFeeCharge'Variants
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser ApplicationFeeAccount'Variants
-> Parser
     (Int
      -> Int
      -> ApplicationFeeApplication'Variants
      -> Maybe ApplicationFeeBalanceTransaction'Variants
      -> ApplicationFeeCharge'Variants
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser ApplicationFeeAccount'Variants
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"account")) Parser
  (Int
   -> Int
   -> ApplicationFeeApplication'Variants
   -> Maybe ApplicationFeeBalanceTransaction'Variants
   -> ApplicationFeeCharge'Variants
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser Int
-> Parser
     (Int
      -> ApplicationFeeApplication'Variants
      -> Maybe ApplicationFeeBalanceTransaction'Variants
      -> ApplicationFeeCharge'Variants
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
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
"amount")) Parser
  (Int
   -> ApplicationFeeApplication'Variants
   -> Maybe ApplicationFeeBalanceTransaction'Variants
   -> ApplicationFeeCharge'Variants
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser Int
-> Parser
     (ApplicationFeeApplication'Variants
      -> Maybe ApplicationFeeBalanceTransaction'Variants
      -> ApplicationFeeCharge'Variants
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
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
"amount_refunded")) Parser
  (ApplicationFeeApplication'Variants
   -> Maybe ApplicationFeeBalanceTransaction'Variants
   -> ApplicationFeeCharge'Variants
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser ApplicationFeeApplication'Variants
-> Parser
     (Maybe ApplicationFeeBalanceTransaction'Variants
      -> ApplicationFeeCharge'Variants
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser ApplicationFeeApplication'Variants
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"application")) Parser
  (Maybe ApplicationFeeBalanceTransaction'Variants
   -> ApplicationFeeCharge'Variants
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser (Maybe ApplicationFeeBalanceTransaction'Variants)
-> Parser
     (ApplicationFeeCharge'Variants
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe ApplicationFeeBalanceTransaction'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"balance_transaction")) Parser
  (ApplicationFeeCharge'Variants
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser ApplicationFeeCharge'Variants
-> Parser
     (Int
      -> Text
      -> Text
      -> Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser ApplicationFeeCharge'Variants
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"charge")) Parser
  (Int
   -> Text
   -> Text
   -> Bool
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser Int
-> Parser
     (Text
      -> Text
      -> Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
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
  (Text
   -> Text
   -> Bool
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser Text
-> Parser
     (Text
      -> Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
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
"currency")) Parser
  (Text
   -> Bool
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser Text
-> Parser
     (Bool
      -> Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool
      -> ApplicationFeeRefunds'
      -> ApplicationFee)
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
   -> Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool
   -> ApplicationFeeRefunds'
   -> ApplicationFee)
-> Parser Bool
-> Parser
     (Maybe ApplicationFeeOriginatingTransaction'Variants
      -> Bool -> ApplicationFeeRefunds' -> ApplicationFee)
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
  (Maybe ApplicationFeeOriginatingTransaction'Variants
   -> Bool -> ApplicationFeeRefunds' -> ApplicationFee)
-> Parser (Maybe ApplicationFeeOriginatingTransaction'Variants)
-> Parser (Bool -> ApplicationFeeRefunds' -> ApplicationFee)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe ApplicationFeeOriginatingTransaction'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"originating_transaction")) Parser (Bool -> ApplicationFeeRefunds' -> ApplicationFee)
-> Parser Bool -> Parser (ApplicationFeeRefunds' -> ApplicationFee)
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
"refunded")) Parser (ApplicationFeeRefunds' -> ApplicationFee)
-> Parser ApplicationFeeRefunds' -> Parser ApplicationFee
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser ApplicationFeeRefunds'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"refunds"))

-- | Create a new 'ApplicationFee' with all required fields.
mkApplicationFee ::
  -- | 'applicationFeeAccount'
  ApplicationFeeAccount'Variants ->
  -- | 'applicationFeeAmount'
  GHC.Types.Int ->
  -- | 'applicationFeeAmountRefunded'
  GHC.Types.Int ->
  -- | 'applicationFeeApplication'
  ApplicationFeeApplication'Variants ->
  -- | 'applicationFeeCharge'
  ApplicationFeeCharge'Variants ->
  -- | 'applicationFeeCreated'
  GHC.Types.Int ->
  -- | 'applicationFeeCurrency'
  Data.Text.Internal.Text ->
  -- | 'applicationFeeId'
  Data.Text.Internal.Text ->
  -- | 'applicationFeeLivemode'
  GHC.Types.Bool ->
  -- | 'applicationFeeRefunded'
  GHC.Types.Bool ->
  -- | 'applicationFeeRefunds'
  ApplicationFeeRefunds' ->
  ApplicationFee
mkApplicationFee :: ApplicationFeeAccount'Variants
-> Int
-> Int
-> ApplicationFeeApplication'Variants
-> ApplicationFeeCharge'Variants
-> Int
-> Text
-> Text
-> Bool
-> Bool
-> ApplicationFeeRefunds'
-> ApplicationFee
mkApplicationFee ApplicationFeeAccount'Variants
applicationFeeAccount Int
applicationFeeAmount Int
applicationFeeAmountRefunded ApplicationFeeApplication'Variants
applicationFeeApplication ApplicationFeeCharge'Variants
applicationFeeCharge Int
applicationFeeCreated Text
applicationFeeCurrency Text
applicationFeeId Bool
applicationFeeLivemode Bool
applicationFeeRefunded ApplicationFeeRefunds'
applicationFeeRefunds =
  ApplicationFee :: ApplicationFeeAccount'Variants
-> Int
-> Int
-> ApplicationFeeApplication'Variants
-> Maybe ApplicationFeeBalanceTransaction'Variants
-> ApplicationFeeCharge'Variants
-> Int
-> Text
-> Text
-> Bool
-> Maybe ApplicationFeeOriginatingTransaction'Variants
-> Bool
-> ApplicationFeeRefunds'
-> ApplicationFee
ApplicationFee
    { applicationFeeAccount :: ApplicationFeeAccount'Variants
applicationFeeAccount = ApplicationFeeAccount'Variants
applicationFeeAccount,
      applicationFeeAmount :: Int
applicationFeeAmount = Int
applicationFeeAmount,
      applicationFeeAmountRefunded :: Int
applicationFeeAmountRefunded = Int
applicationFeeAmountRefunded,
      applicationFeeApplication :: ApplicationFeeApplication'Variants
applicationFeeApplication = ApplicationFeeApplication'Variants
applicationFeeApplication,
      applicationFeeBalanceTransaction :: Maybe ApplicationFeeBalanceTransaction'Variants
applicationFeeBalanceTransaction = Maybe ApplicationFeeBalanceTransaction'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      applicationFeeCharge :: ApplicationFeeCharge'Variants
applicationFeeCharge = ApplicationFeeCharge'Variants
applicationFeeCharge,
      applicationFeeCreated :: Int
applicationFeeCreated = Int
applicationFeeCreated,
      applicationFeeCurrency :: Text
applicationFeeCurrency = Text
applicationFeeCurrency,
      applicationFeeId :: Text
applicationFeeId = Text
applicationFeeId,
      applicationFeeLivemode :: Bool
applicationFeeLivemode = Bool
applicationFeeLivemode,
      applicationFeeOriginatingTransaction :: Maybe ApplicationFeeOriginatingTransaction'Variants
applicationFeeOriginatingTransaction = Maybe ApplicationFeeOriginatingTransaction'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      applicationFeeRefunded :: Bool
applicationFeeRefunded = Bool
applicationFeeRefunded,
      applicationFeeRefunds :: ApplicationFeeRefunds'
applicationFeeRefunds = ApplicationFeeRefunds'
applicationFeeRefunds
    }

-- | Defines the oneOf schema located at @components.schemas.application_fee.properties.account.anyOf@ in the specification.
--
-- ID of the Stripe account this fee was taken from.
data ApplicationFeeAccount'Variants
  = ApplicationFeeAccount'Text Data.Text.Internal.Text
  | ApplicationFeeAccount'Account Account
  deriving (Int -> ApplicationFeeAccount'Variants -> ShowS
[ApplicationFeeAccount'Variants] -> ShowS
ApplicationFeeAccount'Variants -> String
(Int -> ApplicationFeeAccount'Variants -> ShowS)
-> (ApplicationFeeAccount'Variants -> String)
-> ([ApplicationFeeAccount'Variants] -> ShowS)
-> Show ApplicationFeeAccount'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationFeeAccount'Variants] -> ShowS
$cshowList :: [ApplicationFeeAccount'Variants] -> ShowS
show :: ApplicationFeeAccount'Variants -> String
$cshow :: ApplicationFeeAccount'Variants -> String
showsPrec :: Int -> ApplicationFeeAccount'Variants -> ShowS
$cshowsPrec :: Int -> ApplicationFeeAccount'Variants -> ShowS
GHC.Show.Show, ApplicationFeeAccount'Variants
-> ApplicationFeeAccount'Variants -> Bool
(ApplicationFeeAccount'Variants
 -> ApplicationFeeAccount'Variants -> Bool)
-> (ApplicationFeeAccount'Variants
    -> ApplicationFeeAccount'Variants -> Bool)
-> Eq ApplicationFeeAccount'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationFeeAccount'Variants
-> ApplicationFeeAccount'Variants -> Bool
$c/= :: ApplicationFeeAccount'Variants
-> ApplicationFeeAccount'Variants -> Bool
== :: ApplicationFeeAccount'Variants
-> ApplicationFeeAccount'Variants -> Bool
$c== :: ApplicationFeeAccount'Variants
-> ApplicationFeeAccount'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON ApplicationFeeAccount'Variants where
  toJSON :: ApplicationFeeAccount'Variants -> Value
toJSON (ApplicationFeeAccount'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (ApplicationFeeAccount'Account Account
a) = Account -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Account
a

instance Data.Aeson.Types.FromJSON.FromJSON ApplicationFeeAccount'Variants where
  parseJSON :: Value -> Parser ApplicationFeeAccount'Variants
parseJSON Value
val = case (Text -> ApplicationFeeAccount'Variants
ApplicationFeeAccount'Text (Text -> ApplicationFeeAccount'Variants)
-> Result Text -> Result ApplicationFeeAccount'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeAccount'Variants
-> Result ApplicationFeeAccount'Variants
-> Result ApplicationFeeAccount'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((Account -> ApplicationFeeAccount'Variants
ApplicationFeeAccount'Account (Account -> ApplicationFeeAccount'Variants)
-> Result Account -> Result ApplicationFeeAccount'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Account
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeAccount'Variants
-> Result ApplicationFeeAccount'Variants
-> Result ApplicationFeeAccount'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result ApplicationFeeAccount'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched") of
    Data.Aeson.Types.Internal.Success ApplicationFeeAccount'Variants
a -> ApplicationFeeAccount'Variants
-> Parser ApplicationFeeAccount'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure ApplicationFeeAccount'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String -> Parser ApplicationFeeAccount'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Defines the oneOf schema located at @components.schemas.application_fee.properties.application.anyOf@ in the specification.
--
-- ID of the Connect application that earned the fee.
data ApplicationFeeApplication'Variants
  = ApplicationFeeApplication'Text Data.Text.Internal.Text
  | ApplicationFeeApplication'Application Application
  deriving (Int -> ApplicationFeeApplication'Variants -> ShowS
[ApplicationFeeApplication'Variants] -> ShowS
ApplicationFeeApplication'Variants -> String
(Int -> ApplicationFeeApplication'Variants -> ShowS)
-> (ApplicationFeeApplication'Variants -> String)
-> ([ApplicationFeeApplication'Variants] -> ShowS)
-> Show ApplicationFeeApplication'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationFeeApplication'Variants] -> ShowS
$cshowList :: [ApplicationFeeApplication'Variants] -> ShowS
show :: ApplicationFeeApplication'Variants -> String
$cshow :: ApplicationFeeApplication'Variants -> String
showsPrec :: Int -> ApplicationFeeApplication'Variants -> ShowS
$cshowsPrec :: Int -> ApplicationFeeApplication'Variants -> ShowS
GHC.Show.Show, ApplicationFeeApplication'Variants
-> ApplicationFeeApplication'Variants -> Bool
(ApplicationFeeApplication'Variants
 -> ApplicationFeeApplication'Variants -> Bool)
-> (ApplicationFeeApplication'Variants
    -> ApplicationFeeApplication'Variants -> Bool)
-> Eq ApplicationFeeApplication'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationFeeApplication'Variants
-> ApplicationFeeApplication'Variants -> Bool
$c/= :: ApplicationFeeApplication'Variants
-> ApplicationFeeApplication'Variants -> Bool
== :: ApplicationFeeApplication'Variants
-> ApplicationFeeApplication'Variants -> Bool
$c== :: ApplicationFeeApplication'Variants
-> ApplicationFeeApplication'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON ApplicationFeeApplication'Variants where
  toJSON :: ApplicationFeeApplication'Variants -> Value
toJSON (ApplicationFeeApplication'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (ApplicationFeeApplication'Application Application
a) = Application -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Application
a

instance Data.Aeson.Types.FromJSON.FromJSON ApplicationFeeApplication'Variants where
  parseJSON :: Value -> Parser ApplicationFeeApplication'Variants
parseJSON Value
val = case (Text -> ApplicationFeeApplication'Variants
ApplicationFeeApplication'Text (Text -> ApplicationFeeApplication'Variants)
-> Result Text -> Result ApplicationFeeApplication'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeApplication'Variants
-> Result ApplicationFeeApplication'Variants
-> Result ApplicationFeeApplication'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((Application -> ApplicationFeeApplication'Variants
ApplicationFeeApplication'Application (Application -> ApplicationFeeApplication'Variants)
-> Result Application -> Result ApplicationFeeApplication'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Application
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeApplication'Variants
-> Result ApplicationFeeApplication'Variants
-> Result ApplicationFeeApplication'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result ApplicationFeeApplication'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched") of
    Data.Aeson.Types.Internal.Success ApplicationFeeApplication'Variants
a -> ApplicationFeeApplication'Variants
-> Parser ApplicationFeeApplication'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure ApplicationFeeApplication'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String -> Parser ApplicationFeeApplication'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Defines the oneOf schema located at @components.schemas.application_fee.properties.balance_transaction.anyOf@ in the specification.
--
-- Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).
data ApplicationFeeBalanceTransaction'Variants
  = ApplicationFeeBalanceTransaction'Text Data.Text.Internal.Text
  | ApplicationFeeBalanceTransaction'BalanceTransaction BalanceTransaction
  deriving (Int -> ApplicationFeeBalanceTransaction'Variants -> ShowS
[ApplicationFeeBalanceTransaction'Variants] -> ShowS
ApplicationFeeBalanceTransaction'Variants -> String
(Int -> ApplicationFeeBalanceTransaction'Variants -> ShowS)
-> (ApplicationFeeBalanceTransaction'Variants -> String)
-> ([ApplicationFeeBalanceTransaction'Variants] -> ShowS)
-> Show ApplicationFeeBalanceTransaction'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationFeeBalanceTransaction'Variants] -> ShowS
$cshowList :: [ApplicationFeeBalanceTransaction'Variants] -> ShowS
show :: ApplicationFeeBalanceTransaction'Variants -> String
$cshow :: ApplicationFeeBalanceTransaction'Variants -> String
showsPrec :: Int -> ApplicationFeeBalanceTransaction'Variants -> ShowS
$cshowsPrec :: Int -> ApplicationFeeBalanceTransaction'Variants -> ShowS
GHC.Show.Show, ApplicationFeeBalanceTransaction'Variants
-> ApplicationFeeBalanceTransaction'Variants -> Bool
(ApplicationFeeBalanceTransaction'Variants
 -> ApplicationFeeBalanceTransaction'Variants -> Bool)
-> (ApplicationFeeBalanceTransaction'Variants
    -> ApplicationFeeBalanceTransaction'Variants -> Bool)
-> Eq ApplicationFeeBalanceTransaction'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationFeeBalanceTransaction'Variants
-> ApplicationFeeBalanceTransaction'Variants -> Bool
$c/= :: ApplicationFeeBalanceTransaction'Variants
-> ApplicationFeeBalanceTransaction'Variants -> Bool
== :: ApplicationFeeBalanceTransaction'Variants
-> ApplicationFeeBalanceTransaction'Variants -> Bool
$c== :: ApplicationFeeBalanceTransaction'Variants
-> ApplicationFeeBalanceTransaction'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON ApplicationFeeBalanceTransaction'Variants where
  toJSON :: ApplicationFeeBalanceTransaction'Variants -> Value
toJSON (ApplicationFeeBalanceTransaction'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (ApplicationFeeBalanceTransaction'BalanceTransaction BalanceTransaction
a) = BalanceTransaction -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON BalanceTransaction
a

instance Data.Aeson.Types.FromJSON.FromJSON ApplicationFeeBalanceTransaction'Variants where
  parseJSON :: Value -> Parser ApplicationFeeBalanceTransaction'Variants
parseJSON Value
val = case (Text -> ApplicationFeeBalanceTransaction'Variants
ApplicationFeeBalanceTransaction'Text (Text -> ApplicationFeeBalanceTransaction'Variants)
-> Result Text -> Result ApplicationFeeBalanceTransaction'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeBalanceTransaction'Variants
-> Result ApplicationFeeBalanceTransaction'Variants
-> Result ApplicationFeeBalanceTransaction'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((BalanceTransaction -> ApplicationFeeBalanceTransaction'Variants
ApplicationFeeBalanceTransaction'BalanceTransaction (BalanceTransaction -> ApplicationFeeBalanceTransaction'Variants)
-> Result BalanceTransaction
-> Result ApplicationFeeBalanceTransaction'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result BalanceTransaction
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeBalanceTransaction'Variants
-> Result ApplicationFeeBalanceTransaction'Variants
-> Result ApplicationFeeBalanceTransaction'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result ApplicationFeeBalanceTransaction'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched") of
    Data.Aeson.Types.Internal.Success ApplicationFeeBalanceTransaction'Variants
a -> ApplicationFeeBalanceTransaction'Variants
-> Parser ApplicationFeeBalanceTransaction'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure ApplicationFeeBalanceTransaction'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String -> Parser ApplicationFeeBalanceTransaction'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Defines the oneOf schema located at @components.schemas.application_fee.properties.charge.anyOf@ in the specification.
--
-- ID of the charge that the application fee was taken from.
data ApplicationFeeCharge'Variants
  = ApplicationFeeCharge'Text Data.Text.Internal.Text
  | ApplicationFeeCharge'Charge Charge
  deriving (Int -> ApplicationFeeCharge'Variants -> ShowS
[ApplicationFeeCharge'Variants] -> ShowS
ApplicationFeeCharge'Variants -> String
(Int -> ApplicationFeeCharge'Variants -> ShowS)
-> (ApplicationFeeCharge'Variants -> String)
-> ([ApplicationFeeCharge'Variants] -> ShowS)
-> Show ApplicationFeeCharge'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationFeeCharge'Variants] -> ShowS
$cshowList :: [ApplicationFeeCharge'Variants] -> ShowS
show :: ApplicationFeeCharge'Variants -> String
$cshow :: ApplicationFeeCharge'Variants -> String
showsPrec :: Int -> ApplicationFeeCharge'Variants -> ShowS
$cshowsPrec :: Int -> ApplicationFeeCharge'Variants -> ShowS
GHC.Show.Show, ApplicationFeeCharge'Variants
-> ApplicationFeeCharge'Variants -> Bool
(ApplicationFeeCharge'Variants
 -> ApplicationFeeCharge'Variants -> Bool)
-> (ApplicationFeeCharge'Variants
    -> ApplicationFeeCharge'Variants -> Bool)
-> Eq ApplicationFeeCharge'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationFeeCharge'Variants
-> ApplicationFeeCharge'Variants -> Bool
$c/= :: ApplicationFeeCharge'Variants
-> ApplicationFeeCharge'Variants -> Bool
== :: ApplicationFeeCharge'Variants
-> ApplicationFeeCharge'Variants -> Bool
$c== :: ApplicationFeeCharge'Variants
-> ApplicationFeeCharge'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON ApplicationFeeCharge'Variants where
  toJSON :: ApplicationFeeCharge'Variants -> Value
toJSON (ApplicationFeeCharge'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (ApplicationFeeCharge'Charge Charge
a) = Charge -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Charge
a

instance Data.Aeson.Types.FromJSON.FromJSON ApplicationFeeCharge'Variants where
  parseJSON :: Value -> Parser ApplicationFeeCharge'Variants
parseJSON Value
val = case (Text -> ApplicationFeeCharge'Variants
ApplicationFeeCharge'Text (Text -> ApplicationFeeCharge'Variants)
-> Result Text -> Result ApplicationFeeCharge'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeCharge'Variants
-> Result ApplicationFeeCharge'Variants
-> Result ApplicationFeeCharge'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((Charge -> ApplicationFeeCharge'Variants
ApplicationFeeCharge'Charge (Charge -> ApplicationFeeCharge'Variants)
-> Result Charge -> Result ApplicationFeeCharge'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Charge
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeCharge'Variants
-> Result ApplicationFeeCharge'Variants
-> Result ApplicationFeeCharge'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result ApplicationFeeCharge'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched") of
    Data.Aeson.Types.Internal.Success ApplicationFeeCharge'Variants
a -> ApplicationFeeCharge'Variants
-> Parser ApplicationFeeCharge'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure ApplicationFeeCharge'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String -> Parser ApplicationFeeCharge'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Defines the oneOf schema located at @components.schemas.application_fee.properties.originating_transaction.anyOf@ in the specification.
--
-- ID of the corresponding charge on the platform account, if this fee was the result of a charge using the \`destination\` parameter.
data ApplicationFeeOriginatingTransaction'Variants
  = ApplicationFeeOriginatingTransaction'Text Data.Text.Internal.Text
  | ApplicationFeeOriginatingTransaction'Charge Charge
  deriving (Int -> ApplicationFeeOriginatingTransaction'Variants -> ShowS
[ApplicationFeeOriginatingTransaction'Variants] -> ShowS
ApplicationFeeOriginatingTransaction'Variants -> String
(Int -> ApplicationFeeOriginatingTransaction'Variants -> ShowS)
-> (ApplicationFeeOriginatingTransaction'Variants -> String)
-> ([ApplicationFeeOriginatingTransaction'Variants] -> ShowS)
-> Show ApplicationFeeOriginatingTransaction'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationFeeOriginatingTransaction'Variants] -> ShowS
$cshowList :: [ApplicationFeeOriginatingTransaction'Variants] -> ShowS
show :: ApplicationFeeOriginatingTransaction'Variants -> String
$cshow :: ApplicationFeeOriginatingTransaction'Variants -> String
showsPrec :: Int -> ApplicationFeeOriginatingTransaction'Variants -> ShowS
$cshowsPrec :: Int -> ApplicationFeeOriginatingTransaction'Variants -> ShowS
GHC.Show.Show, ApplicationFeeOriginatingTransaction'Variants
-> ApplicationFeeOriginatingTransaction'Variants -> Bool
(ApplicationFeeOriginatingTransaction'Variants
 -> ApplicationFeeOriginatingTransaction'Variants -> Bool)
-> (ApplicationFeeOriginatingTransaction'Variants
    -> ApplicationFeeOriginatingTransaction'Variants -> Bool)
-> Eq ApplicationFeeOriginatingTransaction'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationFeeOriginatingTransaction'Variants
-> ApplicationFeeOriginatingTransaction'Variants -> Bool
$c/= :: ApplicationFeeOriginatingTransaction'Variants
-> ApplicationFeeOriginatingTransaction'Variants -> Bool
== :: ApplicationFeeOriginatingTransaction'Variants
-> ApplicationFeeOriginatingTransaction'Variants -> Bool
$c== :: ApplicationFeeOriginatingTransaction'Variants
-> ApplicationFeeOriginatingTransaction'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON ApplicationFeeOriginatingTransaction'Variants where
  toJSON :: ApplicationFeeOriginatingTransaction'Variants -> Value
toJSON (ApplicationFeeOriginatingTransaction'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (ApplicationFeeOriginatingTransaction'Charge Charge
a) = Charge -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Charge
a

instance Data.Aeson.Types.FromJSON.FromJSON ApplicationFeeOriginatingTransaction'Variants where
  parseJSON :: Value -> Parser ApplicationFeeOriginatingTransaction'Variants
parseJSON Value
val = case (Text -> ApplicationFeeOriginatingTransaction'Variants
ApplicationFeeOriginatingTransaction'Text (Text -> ApplicationFeeOriginatingTransaction'Variants)
-> Result Text
-> Result ApplicationFeeOriginatingTransaction'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeOriginatingTransaction'Variants
-> Result ApplicationFeeOriginatingTransaction'Variants
-> Result ApplicationFeeOriginatingTransaction'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((Charge -> ApplicationFeeOriginatingTransaction'Variants
ApplicationFeeOriginatingTransaction'Charge (Charge -> ApplicationFeeOriginatingTransaction'Variants)
-> Result Charge
-> Result ApplicationFeeOriginatingTransaction'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Charge
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result ApplicationFeeOriginatingTransaction'Variants
-> Result ApplicationFeeOriginatingTransaction'Variants
-> Result ApplicationFeeOriginatingTransaction'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result ApplicationFeeOriginatingTransaction'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched") of
    Data.Aeson.Types.Internal.Success ApplicationFeeOriginatingTransaction'Variants
a -> ApplicationFeeOriginatingTransaction'Variants
-> Parser ApplicationFeeOriginatingTransaction'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure ApplicationFeeOriginatingTransaction'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String -> Parser ApplicationFeeOriginatingTransaction'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Defines the object schema located at @components.schemas.application_fee.properties.refunds@ in the specification.
--
-- A list of refunds that have been applied to the fee.
data ApplicationFeeRefunds' = ApplicationFeeRefunds'
  { -- | data: Details about each object.
    ApplicationFeeRefunds' -> [FeeRefund]
applicationFeeRefunds'Data :: ([FeeRefund]),
    -- | has_more: True if this list has another page of items after this one that can be fetched.
    ApplicationFeeRefunds' -> Bool
applicationFeeRefunds'HasMore :: GHC.Types.Bool,
    -- | url: The URL where this list can be accessed.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    ApplicationFeeRefunds' -> Text
applicationFeeRefunds'Url :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> ApplicationFeeRefunds' -> ShowS
[ApplicationFeeRefunds'] -> ShowS
ApplicationFeeRefunds' -> String
(Int -> ApplicationFeeRefunds' -> ShowS)
-> (ApplicationFeeRefunds' -> String)
-> ([ApplicationFeeRefunds'] -> ShowS)
-> Show ApplicationFeeRefunds'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationFeeRefunds'] -> ShowS
$cshowList :: [ApplicationFeeRefunds'] -> ShowS
show :: ApplicationFeeRefunds' -> String
$cshow :: ApplicationFeeRefunds' -> String
showsPrec :: Int -> ApplicationFeeRefunds' -> ShowS
$cshowsPrec :: Int -> ApplicationFeeRefunds' -> ShowS
GHC.Show.Show,
      ApplicationFeeRefunds' -> ApplicationFeeRefunds' -> Bool
(ApplicationFeeRefunds' -> ApplicationFeeRefunds' -> Bool)
-> (ApplicationFeeRefunds' -> ApplicationFeeRefunds' -> Bool)
-> Eq ApplicationFeeRefunds'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationFeeRefunds' -> ApplicationFeeRefunds' -> Bool
$c/= :: ApplicationFeeRefunds' -> ApplicationFeeRefunds' -> Bool
== :: ApplicationFeeRefunds' -> ApplicationFeeRefunds' -> Bool
$c== :: ApplicationFeeRefunds' -> ApplicationFeeRefunds' -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON ApplicationFeeRefunds' where
  toJSON :: ApplicationFeeRefunds' -> Value
toJSON ApplicationFeeRefunds'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"data" Text -> [FeeRefund] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFeeRefunds' -> [FeeRefund]
applicationFeeRefunds'Data ApplicationFeeRefunds'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"has_more" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFeeRefunds' -> Bool
applicationFeeRefunds'HasMore ApplicationFeeRefunds'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"url" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFeeRefunds' -> Text
applicationFeeRefunds'Url ApplicationFeeRefunds'
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
"list" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: ApplicationFeeRefunds' -> Encoding
toEncoding ApplicationFeeRefunds'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"data" Text -> [FeeRefund] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFeeRefunds' -> [FeeRefund]
applicationFeeRefunds'Data ApplicationFeeRefunds'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"has_more" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFeeRefunds' -> Bool
applicationFeeRefunds'HasMore ApplicationFeeRefunds'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"url" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ApplicationFeeRefunds' -> Text
applicationFeeRefunds'Url ApplicationFeeRefunds'
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
"list"))))

instance Data.Aeson.Types.FromJSON.FromJSON ApplicationFeeRefunds' where
  parseJSON :: Value -> Parser ApplicationFeeRefunds'
parseJSON = String
-> (Object -> Parser ApplicationFeeRefunds')
-> Value
-> Parser ApplicationFeeRefunds'
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"ApplicationFeeRefunds'" (\Object
obj -> ((([FeeRefund] -> Bool -> Text -> ApplicationFeeRefunds')
-> Parser ([FeeRefund] -> Bool -> Text -> ApplicationFeeRefunds')
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure [FeeRefund] -> Bool -> Text -> ApplicationFeeRefunds'
ApplicationFeeRefunds' Parser ([FeeRefund] -> Bool -> Text -> ApplicationFeeRefunds')
-> Parser [FeeRefund]
-> Parser (Bool -> Text -> ApplicationFeeRefunds')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser [FeeRefund]
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"data")) Parser (Bool -> Text -> ApplicationFeeRefunds')
-> Parser Bool -> Parser (Text -> ApplicationFeeRefunds')
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
"has_more")) Parser (Text -> ApplicationFeeRefunds')
-> Parser Text -> Parser ApplicationFeeRefunds'
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
"url"))

-- | Create a new 'ApplicationFeeRefunds'' with all required fields.
mkApplicationFeeRefunds' ::
  -- | 'applicationFeeRefunds'Data'
  [FeeRefund] ->
  -- | 'applicationFeeRefunds'HasMore'
  GHC.Types.Bool ->
  -- | 'applicationFeeRefunds'Url'
  Data.Text.Internal.Text ->
  ApplicationFeeRefunds'
mkApplicationFeeRefunds' :: [FeeRefund] -> Bool -> Text -> ApplicationFeeRefunds'
mkApplicationFeeRefunds' [FeeRefund]
applicationFeeRefunds'Data Bool
applicationFeeRefunds'HasMore Text
applicationFeeRefunds'Url =
  ApplicationFeeRefunds' :: [FeeRefund] -> Bool -> Text -> ApplicationFeeRefunds'
ApplicationFeeRefunds'
    { applicationFeeRefunds'Data :: [FeeRefund]
applicationFeeRefunds'Data = [FeeRefund]
applicationFeeRefunds'Data,
      applicationFeeRefunds'HasMore :: Bool
applicationFeeRefunds'HasMore = Bool
applicationFeeRefunds'HasMore,
      applicationFeeRefunds'Url :: Text
applicationFeeRefunds'Url = Text
applicationFeeRefunds'Url
    }