{-# 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 TransferReversal
module StripeAPI.Types.TransferReversal 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.BalanceTransaction
import {-# SOURCE #-} StripeAPI.Types.Refund
import {-# SOURCE #-} StripeAPI.Types.Transfer
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.transfer_reversal@ in the specification.
--
-- [Stripe Connect](https:\/\/stripe.com\/docs\/connect) platforms can reverse transfers made to a
-- connected account, either entirely or partially, and can also specify whether
-- to refund any related application fees. Transfer reversals add to the
-- platform\'s balance and subtract from the destination account\'s balance.
--
-- Reversing a transfer that was made for a [destination
-- charge](\/docs\/connect\/destination-charges) is allowed only up to the amount of
-- the charge. It is possible to reverse a
-- [transfer_group](https:\/\/stripe.com\/docs\/connect\/charges-transfers\#transfer-options)
-- transfer only if the destination account has enough balance to cover the
-- reversal.
--
-- Related guide: [Reversing Transfers](https:\/\/stripe.com\/docs\/connect\/charges-transfers\#reversing-transfers).
data TransferReversal = TransferReversal
  { -- | amount: Amount, in %s.
    TransferReversal -> Int
transferReversalAmount :: GHC.Types.Int,
    -- | balance_transaction: Balance transaction that describes the impact on your account balance.
    TransferReversal
-> Maybe TransferReversalBalanceTransaction'Variants
transferReversalBalanceTransaction :: (GHC.Maybe.Maybe TransferReversalBalanceTransaction'Variants),
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    TransferReversal -> Int
transferReversalCreated :: 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).
    TransferReversal -> Text
transferReversalCurrency :: Data.Text.Internal.Text,
    -- | destination_payment_refund: Linked payment refund for the transfer reversal.
    TransferReversal
-> Maybe TransferReversalDestinationPaymentRefund'Variants
transferReversalDestinationPaymentRefund :: (GHC.Maybe.Maybe TransferReversalDestinationPaymentRefund'Variants),
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    TransferReversal -> Text
transferReversalId :: Data.Text.Internal.Text,
    -- | metadata: Set of [key-value pairs](https:\/\/stripe.com\/docs\/api\/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    TransferReversal -> Maybe Object
transferReversalMetadata :: (GHC.Maybe.Maybe Data.Aeson.Types.Internal.Object),
    -- | source_refund: ID of the refund responsible for the transfer reversal.
    TransferReversal -> Maybe TransferReversalSourceRefund'Variants
transferReversalSourceRefund :: (GHC.Maybe.Maybe TransferReversalSourceRefund'Variants),
    -- | transfer: ID of the transfer that was reversed.
    TransferReversal -> TransferReversalTransfer'Variants
transferReversalTransfer :: TransferReversalTransfer'Variants
  }
  deriving
    ( Int -> TransferReversal -> ShowS
[TransferReversal] -> ShowS
TransferReversal -> String
(Int -> TransferReversal -> ShowS)
-> (TransferReversal -> String)
-> ([TransferReversal] -> ShowS)
-> Show TransferReversal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransferReversal] -> ShowS
$cshowList :: [TransferReversal] -> ShowS
show :: TransferReversal -> String
$cshow :: TransferReversal -> String
showsPrec :: Int -> TransferReversal -> ShowS
$cshowsPrec :: Int -> TransferReversal -> ShowS
GHC.Show.Show,
      TransferReversal -> TransferReversal -> Bool
(TransferReversal -> TransferReversal -> Bool)
-> (TransferReversal -> TransferReversal -> Bool)
-> Eq TransferReversal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransferReversal -> TransferReversal -> Bool
$c/= :: TransferReversal -> TransferReversal -> Bool
== :: TransferReversal -> TransferReversal -> Bool
$c== :: TransferReversal -> TransferReversal -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON TransferReversal where
  toJSON :: TransferReversal -> Value
toJSON TransferReversal
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal -> Int
transferReversalAmount TransferReversal
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"balance_transaction" Text -> Maybe TransferReversalBalanceTransaction'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal
-> Maybe TransferReversalBalanceTransaction'Variants
transferReversalBalanceTransaction TransferReversal
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..= TransferReversal -> Int
transferReversalCreated TransferReversal
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..= TransferReversal -> Text
transferReversalCurrency TransferReversal
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"destination_payment_refund" Text
-> Maybe TransferReversalDestinationPaymentRefund'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal
-> Maybe TransferReversalDestinationPaymentRefund'Variants
transferReversalDestinationPaymentRefund TransferReversal
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..= TransferReversal -> Text
transferReversalId TransferReversal
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Maybe Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal -> Maybe Object
transferReversalMetadata TransferReversal
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"source_refund" Text -> Maybe TransferReversalSourceRefund'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal -> Maybe TransferReversalSourceRefund'Variants
transferReversalSourceRefund TransferReversal
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"transfer" Text -> TransferReversalTransfer'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal -> TransferReversalTransfer'Variants
transferReversalTransfer TransferReversal
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
"transfer_reversal" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: TransferReversal -> Encoding
toEncoding TransferReversal
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal -> Int
transferReversalAmount TransferReversal
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"balance_transaction" Text -> Maybe TransferReversalBalanceTransaction'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal
-> Maybe TransferReversalBalanceTransaction'Variants
transferReversalBalanceTransaction TransferReversal
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..= TransferReversal -> Int
transferReversalCreated TransferReversal
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..= TransferReversal -> Text
transferReversalCurrency TransferReversal
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"destination_payment_refund" Text
-> Maybe TransferReversalDestinationPaymentRefund'Variants
-> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal
-> Maybe TransferReversalDestinationPaymentRefund'Variants
transferReversalDestinationPaymentRefund TransferReversal
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..= TransferReversal -> Text
transferReversalId TransferReversal
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Maybe Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal -> Maybe Object
transferReversalMetadata TransferReversal
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"source_refund" Text -> Maybe TransferReversalSourceRefund'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal -> Maybe TransferReversalSourceRefund'Variants
transferReversalSourceRefund TransferReversal
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"transfer" Text -> TransferReversalTransfer'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversal -> TransferReversalTransfer'Variants
transferReversalTransfer TransferReversal
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
"transfer_reversal"))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON TransferReversal where
  parseJSON :: Value -> Parser TransferReversal
parseJSON = String
-> (Object -> Parser TransferReversal)
-> Value
-> Parser TransferReversal
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"TransferReversal" (\Object
obj -> (((((((((Int
 -> Maybe TransferReversalBalanceTransaction'Variants
 -> Int
 -> Text
 -> Maybe TransferReversalDestinationPaymentRefund'Variants
 -> Text
 -> Maybe Object
 -> Maybe TransferReversalSourceRefund'Variants
 -> TransferReversalTransfer'Variants
 -> TransferReversal)
-> Parser
     (Int
      -> Maybe TransferReversalBalanceTransaction'Variants
      -> Int
      -> Text
      -> Maybe TransferReversalDestinationPaymentRefund'Variants
      -> Text
      -> Maybe Object
      -> Maybe TransferReversalSourceRefund'Variants
      -> TransferReversalTransfer'Variants
      -> TransferReversal)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int
-> Maybe TransferReversalBalanceTransaction'Variants
-> Int
-> Text
-> Maybe TransferReversalDestinationPaymentRefund'Variants
-> Text
-> Maybe Object
-> Maybe TransferReversalSourceRefund'Variants
-> TransferReversalTransfer'Variants
-> TransferReversal
TransferReversal Parser
  (Int
   -> Maybe TransferReversalBalanceTransaction'Variants
   -> Int
   -> Text
   -> Maybe TransferReversalDestinationPaymentRefund'Variants
   -> Text
   -> Maybe Object
   -> Maybe TransferReversalSourceRefund'Variants
   -> TransferReversalTransfer'Variants
   -> TransferReversal)
-> Parser Int
-> Parser
     (Maybe TransferReversalBalanceTransaction'Variants
      -> Int
      -> Text
      -> Maybe TransferReversalDestinationPaymentRefund'Variants
      -> Text
      -> Maybe Object
      -> Maybe TransferReversalSourceRefund'Variants
      -> TransferReversalTransfer'Variants
      -> TransferReversal)
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
  (Maybe TransferReversalBalanceTransaction'Variants
   -> Int
   -> Text
   -> Maybe TransferReversalDestinationPaymentRefund'Variants
   -> Text
   -> Maybe Object
   -> Maybe TransferReversalSourceRefund'Variants
   -> TransferReversalTransfer'Variants
   -> TransferReversal)
-> Parser (Maybe TransferReversalBalanceTransaction'Variants)
-> Parser
     (Int
      -> Text
      -> Maybe TransferReversalDestinationPaymentRefund'Variants
      -> Text
      -> Maybe Object
      -> Maybe TransferReversalSourceRefund'Variants
      -> TransferReversalTransfer'Variants
      -> TransferReversal)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe TransferReversalBalanceTransaction'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"balance_transaction")) Parser
  (Int
   -> Text
   -> Maybe TransferReversalDestinationPaymentRefund'Variants
   -> Text
   -> Maybe Object
   -> Maybe TransferReversalSourceRefund'Variants
   -> TransferReversalTransfer'Variants
   -> TransferReversal)
-> Parser Int
-> Parser
     (Text
      -> Maybe TransferReversalDestinationPaymentRefund'Variants
      -> Text
      -> Maybe Object
      -> Maybe TransferReversalSourceRefund'Variants
      -> TransferReversalTransfer'Variants
      -> TransferReversal)
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
   -> Maybe TransferReversalDestinationPaymentRefund'Variants
   -> Text
   -> Maybe Object
   -> Maybe TransferReversalSourceRefund'Variants
   -> TransferReversalTransfer'Variants
   -> TransferReversal)
-> Parser Text
-> Parser
     (Maybe TransferReversalDestinationPaymentRefund'Variants
      -> Text
      -> Maybe Object
      -> Maybe TransferReversalSourceRefund'Variants
      -> TransferReversalTransfer'Variants
      -> TransferReversal)
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
  (Maybe TransferReversalDestinationPaymentRefund'Variants
   -> Text
   -> Maybe Object
   -> Maybe TransferReversalSourceRefund'Variants
   -> TransferReversalTransfer'Variants
   -> TransferReversal)
-> Parser (Maybe TransferReversalDestinationPaymentRefund'Variants)
-> Parser
     (Text
      -> Maybe Object
      -> Maybe TransferReversalSourceRefund'Variants
      -> TransferReversalTransfer'Variants
      -> TransferReversal)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe TransferReversalDestinationPaymentRefund'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"destination_payment_refund")) Parser
  (Text
   -> Maybe Object
   -> Maybe TransferReversalSourceRefund'Variants
   -> TransferReversalTransfer'Variants
   -> TransferReversal)
-> Parser Text
-> Parser
     (Maybe Object
      -> Maybe TransferReversalSourceRefund'Variants
      -> TransferReversalTransfer'Variants
      -> TransferReversal)
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
  (Maybe Object
   -> Maybe TransferReversalSourceRefund'Variants
   -> TransferReversalTransfer'Variants
   -> TransferReversal)
-> Parser (Maybe Object)
-> Parser
     (Maybe TransferReversalSourceRefund'Variants
      -> TransferReversalTransfer'Variants -> TransferReversal)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Object)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata")) Parser
  (Maybe TransferReversalSourceRefund'Variants
   -> TransferReversalTransfer'Variants -> TransferReversal)
-> Parser (Maybe TransferReversalSourceRefund'Variants)
-> Parser (TransferReversalTransfer'Variants -> TransferReversal)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe TransferReversalSourceRefund'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"source_refund")) Parser (TransferReversalTransfer'Variants -> TransferReversal)
-> Parser TransferReversalTransfer'Variants
-> Parser TransferReversal
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser TransferReversalTransfer'Variants
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"transfer"))

-- | Create a new 'TransferReversal' with all required fields.
mkTransferReversal ::
  -- | 'transferReversalAmount'
  GHC.Types.Int ->
  -- | 'transferReversalCreated'
  GHC.Types.Int ->
  -- | 'transferReversalCurrency'
  Data.Text.Internal.Text ->
  -- | 'transferReversalId'
  Data.Text.Internal.Text ->
  -- | 'transferReversalTransfer'
  TransferReversalTransfer'Variants ->
  TransferReversal
mkTransferReversal :: Int
-> Int
-> Text
-> Text
-> TransferReversalTransfer'Variants
-> TransferReversal
mkTransferReversal Int
transferReversalAmount Int
transferReversalCreated Text
transferReversalCurrency Text
transferReversalId TransferReversalTransfer'Variants
transferReversalTransfer =
  TransferReversal :: Int
-> Maybe TransferReversalBalanceTransaction'Variants
-> Int
-> Text
-> Maybe TransferReversalDestinationPaymentRefund'Variants
-> Text
-> Maybe Object
-> Maybe TransferReversalSourceRefund'Variants
-> TransferReversalTransfer'Variants
-> TransferReversal
TransferReversal
    { transferReversalAmount :: Int
transferReversalAmount = Int
transferReversalAmount,
      transferReversalBalanceTransaction :: Maybe TransferReversalBalanceTransaction'Variants
transferReversalBalanceTransaction = Maybe TransferReversalBalanceTransaction'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      transferReversalCreated :: Int
transferReversalCreated = Int
transferReversalCreated,
      transferReversalCurrency :: Text
transferReversalCurrency = Text
transferReversalCurrency,
      transferReversalDestinationPaymentRefund :: Maybe TransferReversalDestinationPaymentRefund'Variants
transferReversalDestinationPaymentRefund = Maybe TransferReversalDestinationPaymentRefund'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      transferReversalId :: Text
transferReversalId = Text
transferReversalId,
      transferReversalMetadata :: Maybe Object
transferReversalMetadata = Maybe Object
forall a. Maybe a
GHC.Maybe.Nothing,
      transferReversalSourceRefund :: Maybe TransferReversalSourceRefund'Variants
transferReversalSourceRefund = Maybe TransferReversalSourceRefund'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      transferReversalTransfer :: TransferReversalTransfer'Variants
transferReversalTransfer = TransferReversalTransfer'Variants
transferReversalTransfer
    }

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

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

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

-- | Defines the oneOf schema located at @components.schemas.transfer_reversal.properties.destination_payment_refund.anyOf@ in the specification.
--
-- Linked payment refund for the transfer reversal.
data TransferReversalDestinationPaymentRefund'Variants
  = TransferReversalDestinationPaymentRefund'Text Data.Text.Internal.Text
  | TransferReversalDestinationPaymentRefund'Refund Refund
  deriving (Int -> TransferReversalDestinationPaymentRefund'Variants -> ShowS
[TransferReversalDestinationPaymentRefund'Variants] -> ShowS
TransferReversalDestinationPaymentRefund'Variants -> String
(Int -> TransferReversalDestinationPaymentRefund'Variants -> ShowS)
-> (TransferReversalDestinationPaymentRefund'Variants -> String)
-> ([TransferReversalDestinationPaymentRefund'Variants] -> ShowS)
-> Show TransferReversalDestinationPaymentRefund'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransferReversalDestinationPaymentRefund'Variants] -> ShowS
$cshowList :: [TransferReversalDestinationPaymentRefund'Variants] -> ShowS
show :: TransferReversalDestinationPaymentRefund'Variants -> String
$cshow :: TransferReversalDestinationPaymentRefund'Variants -> String
showsPrec :: Int -> TransferReversalDestinationPaymentRefund'Variants -> ShowS
$cshowsPrec :: Int -> TransferReversalDestinationPaymentRefund'Variants -> ShowS
GHC.Show.Show, TransferReversalDestinationPaymentRefund'Variants
-> TransferReversalDestinationPaymentRefund'Variants -> Bool
(TransferReversalDestinationPaymentRefund'Variants
 -> TransferReversalDestinationPaymentRefund'Variants -> Bool)
-> (TransferReversalDestinationPaymentRefund'Variants
    -> TransferReversalDestinationPaymentRefund'Variants -> Bool)
-> Eq TransferReversalDestinationPaymentRefund'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransferReversalDestinationPaymentRefund'Variants
-> TransferReversalDestinationPaymentRefund'Variants -> Bool
$c/= :: TransferReversalDestinationPaymentRefund'Variants
-> TransferReversalDestinationPaymentRefund'Variants -> Bool
== :: TransferReversalDestinationPaymentRefund'Variants
-> TransferReversalDestinationPaymentRefund'Variants -> Bool
$c== :: TransferReversalDestinationPaymentRefund'Variants
-> TransferReversalDestinationPaymentRefund'Variants -> Bool
GHC.Classes.Eq)

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

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

-- | Defines the oneOf schema located at @components.schemas.transfer_reversal.properties.source_refund.anyOf@ in the specification.
--
-- ID of the refund responsible for the transfer reversal.
data TransferReversalSourceRefund'Variants
  = TransferReversalSourceRefund'Text Data.Text.Internal.Text
  | TransferReversalSourceRefund'Refund Refund
  deriving (Int -> TransferReversalSourceRefund'Variants -> ShowS
[TransferReversalSourceRefund'Variants] -> ShowS
TransferReversalSourceRefund'Variants -> String
(Int -> TransferReversalSourceRefund'Variants -> ShowS)
-> (TransferReversalSourceRefund'Variants -> String)
-> ([TransferReversalSourceRefund'Variants] -> ShowS)
-> Show TransferReversalSourceRefund'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransferReversalSourceRefund'Variants] -> ShowS
$cshowList :: [TransferReversalSourceRefund'Variants] -> ShowS
show :: TransferReversalSourceRefund'Variants -> String
$cshow :: TransferReversalSourceRefund'Variants -> String
showsPrec :: Int -> TransferReversalSourceRefund'Variants -> ShowS
$cshowsPrec :: Int -> TransferReversalSourceRefund'Variants -> ShowS
GHC.Show.Show, TransferReversalSourceRefund'Variants
-> TransferReversalSourceRefund'Variants -> Bool
(TransferReversalSourceRefund'Variants
 -> TransferReversalSourceRefund'Variants -> Bool)
-> (TransferReversalSourceRefund'Variants
    -> TransferReversalSourceRefund'Variants -> Bool)
-> Eq TransferReversalSourceRefund'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransferReversalSourceRefund'Variants
-> TransferReversalSourceRefund'Variants -> Bool
$c/= :: TransferReversalSourceRefund'Variants
-> TransferReversalSourceRefund'Variants -> Bool
== :: TransferReversalSourceRefund'Variants
-> TransferReversalSourceRefund'Variants -> Bool
$c== :: TransferReversalSourceRefund'Variants
-> TransferReversalSourceRefund'Variants -> Bool
GHC.Classes.Eq)

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

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

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

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

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