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

-- | Defines the object schema located at @components.schemas.transfer@ in the specification.
--
-- A \`Transfer\` object is created when you move funds between Stripe accounts as
-- part of Connect.
--
-- Before April 6, 2017, transfers also represented movement of funds from a
-- Stripe account to a card or bank account. This behavior has since been split
-- out into a [Payout](https:\/\/stripe.com\/docs\/api\#payout_object) object, with corresponding payout endpoints. For more
-- information, read about the
-- [transfer\/payout split](https:\/\/stripe.com\/docs\/transfer-payout-split).
--
-- Related guide: [Creating Separate Charges and Transfers](https:\/\/stripe.com\/docs\/connect\/charges-transfers).
data Transfer = Transfer
  { -- | amount: Amount in %s to be transferred.
    Transfer -> Int
transferAmount :: GHC.Types.Int,
    -- | amount_reversed: Amount in %s reversed (can be less than the amount attribute on the transfer if a partial reversal was issued).
    Transfer -> Int
transferAmountReversed :: GHC.Types.Int,
    -- | balance_transaction: Balance transaction that describes the impact of this transfer on your account balance.
    Transfer -> Maybe TransferBalanceTransaction'Variants
transferBalanceTransaction :: (GHC.Maybe.Maybe TransferBalanceTransaction'Variants),
    -- | created: Time that this record of the transfer was first created.
    Transfer -> Int
transferCreated :: 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).
    Transfer -> Text
transferCurrency :: Data.Text.Internal.Text,
    -- | description: An arbitrary string attached to the object. Often useful for displaying to users.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Transfer -> Maybe Text
transferDescription :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | destination: ID of the Stripe account the transfer was sent to.
    Transfer -> Maybe TransferDestination'Variants
transferDestination :: (GHC.Maybe.Maybe TransferDestination'Variants),
    -- | destination_payment: If the destination is a Stripe account, this will be the ID of the payment that the destination account received for the transfer.
    Transfer -> Maybe TransferDestinationPayment'Variants
transferDestinationPayment :: (GHC.Maybe.Maybe TransferDestinationPayment'Variants),
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Transfer -> Text
transferId :: 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.
    Transfer -> Bool
transferLivemode :: GHC.Types.Bool,
    -- | 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.
    Transfer -> Object
transferMetadata :: Data.Aeson.Types.Internal.Object,
    -- | reversals: A list of reversals that have been applied to the transfer.
    Transfer -> TransferReversals'
transferReversals :: TransferReversals',
    -- | reversed: Whether the transfer has been fully reversed. If the transfer is only partially reversed, this attribute will still be false.
    Transfer -> Bool
transferReversed :: GHC.Types.Bool,
    -- | source_transaction: ID of the charge or payment that was used to fund the transfer. If null, the transfer was funded from the available balance.
    Transfer -> Maybe TransferSourceTransaction'Variants
transferSourceTransaction :: (GHC.Maybe.Maybe TransferSourceTransaction'Variants),
    -- | source_type: The source balance this transfer came from. One of \`card\`, \`fpx\`, or \`bank_account\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Transfer -> Maybe Text
transferSourceType :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | transfer_group: A string that identifies this transaction as part of a group. See the [Connect documentation](https:\/\/stripe.com\/docs\/connect\/charges-transfers\#transfer-options) for details.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Transfer -> Maybe Text
transferTransferGroup :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> Transfer -> ShowS
[Transfer] -> ShowS
Transfer -> String
(Int -> Transfer -> ShowS)
-> (Transfer -> String) -> ([Transfer] -> ShowS) -> Show Transfer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Transfer] -> ShowS
$cshowList :: [Transfer] -> ShowS
show :: Transfer -> String
$cshow :: Transfer -> String
showsPrec :: Int -> Transfer -> ShowS
$cshowsPrec :: Int -> Transfer -> ShowS
GHC.Show.Show,
      Transfer -> Transfer -> Bool
(Transfer -> Transfer -> Bool)
-> (Transfer -> Transfer -> Bool) -> Eq Transfer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Transfer -> Transfer -> Bool
$c/= :: Transfer -> Transfer -> Bool
== :: Transfer -> Transfer -> Bool
$c== :: Transfer -> Transfer -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON Transfer where
  toJSON :: Transfer -> Value
toJSON Transfer
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..= Transfer -> Int
transferAmount Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"amount_reversed" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Int
transferAmountReversed Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"balance_transaction" Text -> Maybe TransferBalanceTransaction'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe TransferBalanceTransaction'Variants
transferBalanceTransaction Transfer
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..= Transfer -> Int
transferCreated Transfer
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..= Transfer -> Text
transferCurrency Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"description" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe Text
transferDescription Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"destination" Text -> Maybe TransferDestination'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe TransferDestination'Variants
transferDestination Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"destination_payment" Text -> Maybe TransferDestinationPayment'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe TransferDestinationPayment'Variants
transferDestinationPayment Transfer
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..= Transfer -> Text
transferId Transfer
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..= Transfer -> Bool
transferLivemode Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Object
transferMetadata Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"reversals" Text -> TransferReversals' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> TransferReversals'
transferReversals Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"reversed" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Bool
transferReversed Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"source_transaction" Text -> Maybe TransferSourceTransaction'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe TransferSourceTransaction'Variants
transferSourceTransaction Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"source_type" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe Text
transferSourceType Transfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"transfer_group" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe Text
transferTransferGroup Transfer
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" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: Transfer -> Encoding
toEncoding Transfer
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..= Transfer -> Int
transferAmount Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"amount_reversed" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Int
transferAmountReversed Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"balance_transaction" Text -> Maybe TransferBalanceTransaction'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe TransferBalanceTransaction'Variants
transferBalanceTransaction Transfer
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..= Transfer -> Int
transferCreated Transfer
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..= Transfer -> Text
transferCurrency Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"description" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe Text
transferDescription Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"destination" Text -> Maybe TransferDestination'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe TransferDestination'Variants
transferDestination Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"destination_payment" Text -> Maybe TransferDestinationPayment'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe TransferDestinationPayment'Variants
transferDestinationPayment Transfer
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..= Transfer -> Text
transferId Transfer
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..= Transfer -> Bool
transferLivemode Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Object
transferMetadata Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"reversals" Text -> TransferReversals' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> TransferReversals'
transferReversals Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"reversed" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Bool
transferReversed Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"source_transaction" Text -> Maybe TransferSourceTransaction'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe TransferSourceTransaction'Variants
transferSourceTransaction Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"source_type" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe Text
transferSourceType Transfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"transfer_group" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Transfer -> Maybe Text
transferTransferGroup Transfer
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")))))))))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON Transfer where
  parseJSON :: Value -> Parser Transfer
parseJSON = String -> (Object -> Parser Transfer) -> Value -> Parser Transfer
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Transfer" (\Object
obj -> ((((((((((((((((Int
 -> Int
 -> Maybe TransferBalanceTransaction'Variants
 -> Int
 -> Text
 -> Maybe Text
 -> Maybe TransferDestination'Variants
 -> Maybe TransferDestinationPayment'Variants
 -> Text
 -> Bool
 -> Object
 -> TransferReversals'
 -> Bool
 -> Maybe TransferSourceTransaction'Variants
 -> Maybe Text
 -> Maybe Text
 -> Transfer)
-> Parser
     (Int
      -> Int
      -> Maybe TransferBalanceTransaction'Variants
      -> Int
      -> Text
      -> Maybe Text
      -> Maybe TransferDestination'Variants
      -> Maybe TransferDestinationPayment'Variants
      -> Text
      -> Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int
-> Int
-> Maybe TransferBalanceTransaction'Variants
-> Int
-> Text
-> Maybe Text
-> Maybe TransferDestination'Variants
-> Maybe TransferDestinationPayment'Variants
-> Text
-> Bool
-> Object
-> TransferReversals'
-> Bool
-> Maybe TransferSourceTransaction'Variants
-> Maybe Text
-> Maybe Text
-> Transfer
Transfer Parser
  (Int
   -> Int
   -> Maybe TransferBalanceTransaction'Variants
   -> Int
   -> Text
   -> Maybe Text
   -> Maybe TransferDestination'Variants
   -> Maybe TransferDestinationPayment'Variants
   -> Text
   -> Bool
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser Int
-> Parser
     (Int
      -> Maybe TransferBalanceTransaction'Variants
      -> Int
      -> Text
      -> Maybe Text
      -> Maybe TransferDestination'Variants
      -> Maybe TransferDestinationPayment'Variants
      -> Text
      -> Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
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
   -> Maybe TransferBalanceTransaction'Variants
   -> Int
   -> Text
   -> Maybe Text
   -> Maybe TransferDestination'Variants
   -> Maybe TransferDestinationPayment'Variants
   -> Text
   -> Bool
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser Int
-> Parser
     (Maybe TransferBalanceTransaction'Variants
      -> Int
      -> Text
      -> Maybe Text
      -> Maybe TransferDestination'Variants
      -> Maybe TransferDestinationPayment'Variants
      -> Text
      -> Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
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_reversed")) Parser
  (Maybe TransferBalanceTransaction'Variants
   -> Int
   -> Text
   -> Maybe Text
   -> Maybe TransferDestination'Variants
   -> Maybe TransferDestinationPayment'Variants
   -> Text
   -> Bool
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser (Maybe TransferBalanceTransaction'Variants)
-> Parser
     (Int
      -> Text
      -> Maybe Text
      -> Maybe TransferDestination'Variants
      -> Maybe TransferDestinationPayment'Variants
      -> Text
      -> Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe TransferBalanceTransaction'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"balance_transaction")) Parser
  (Int
   -> Text
   -> Maybe Text
   -> Maybe TransferDestination'Variants
   -> Maybe TransferDestinationPayment'Variants
   -> Text
   -> Bool
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser Int
-> Parser
     (Text
      -> Maybe Text
      -> Maybe TransferDestination'Variants
      -> Maybe TransferDestinationPayment'Variants
      -> Text
      -> Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
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 Text
   -> Maybe TransferDestination'Variants
   -> Maybe TransferDestinationPayment'Variants
   -> Text
   -> Bool
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser Text
-> Parser
     (Maybe Text
      -> Maybe TransferDestination'Variants
      -> Maybe TransferDestinationPayment'Variants
      -> Text
      -> Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
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 Text
   -> Maybe TransferDestination'Variants
   -> Maybe TransferDestinationPayment'Variants
   -> Text
   -> Bool
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser (Maybe Text)
-> Parser
     (Maybe TransferDestination'Variants
      -> Maybe TransferDestinationPayment'Variants
      -> Text
      -> Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"description")) Parser
  (Maybe TransferDestination'Variants
   -> Maybe TransferDestinationPayment'Variants
   -> Text
   -> Bool
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser (Maybe TransferDestination'Variants)
-> Parser
     (Maybe TransferDestinationPayment'Variants
      -> Text
      -> Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe TransferDestination'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"destination")) Parser
  (Maybe TransferDestinationPayment'Variants
   -> Text
   -> Bool
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser (Maybe TransferDestinationPayment'Variants)
-> Parser
     (Text
      -> Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe TransferDestinationPayment'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"destination_payment")) Parser
  (Text
   -> Bool
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser Text
-> Parser
     (Bool
      -> Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
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
   -> Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser Bool
-> Parser
     (Object
      -> TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
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
  (Object
   -> TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser Object
-> Parser
     (TransferReversals'
      -> Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Object
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"metadata")) Parser
  (TransferReversals'
   -> Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser TransferReversals'
-> Parser
     (Bool
      -> Maybe TransferSourceTransaction'Variants
      -> Maybe Text
      -> Maybe Text
      -> Transfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser TransferReversals'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"reversals")) Parser
  (Bool
   -> Maybe TransferSourceTransaction'Variants
   -> Maybe Text
   -> Maybe Text
   -> Transfer)
-> Parser Bool
-> Parser
     (Maybe TransferSourceTransaction'Variants
      -> Maybe Text -> Maybe Text -> Transfer)
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
"reversed")) Parser
  (Maybe TransferSourceTransaction'Variants
   -> Maybe Text -> Maybe Text -> Transfer)
-> Parser (Maybe TransferSourceTransaction'Variants)
-> Parser (Maybe Text -> Maybe Text -> Transfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe TransferSourceTransaction'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"source_transaction")) Parser (Maybe Text -> Maybe Text -> Transfer)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Transfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"source_type")) Parser (Maybe Text -> Transfer)
-> Parser (Maybe Text) -> Parser Transfer
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"transfer_group"))

-- | Create a new 'Transfer' with all required fields.
mkTransfer ::
  -- | 'transferAmount'
  GHC.Types.Int ->
  -- | 'transferAmountReversed'
  GHC.Types.Int ->
  -- | 'transferCreated'
  GHC.Types.Int ->
  -- | 'transferCurrency'
  Data.Text.Internal.Text ->
  -- | 'transferId'
  Data.Text.Internal.Text ->
  -- | 'transferLivemode'
  GHC.Types.Bool ->
  -- | 'transferMetadata'
  Data.Aeson.Types.Internal.Object ->
  -- | 'transferReversals'
  TransferReversals' ->
  -- | 'transferReversed'
  GHC.Types.Bool ->
  Transfer
mkTransfer :: Int
-> Int
-> Int
-> Text
-> Text
-> Bool
-> Object
-> TransferReversals'
-> Bool
-> Transfer
mkTransfer Int
transferAmount Int
transferAmountReversed Int
transferCreated Text
transferCurrency Text
transferId Bool
transferLivemode Object
transferMetadata TransferReversals'
transferReversals Bool
transferReversed =
  Transfer :: Int
-> Int
-> Maybe TransferBalanceTransaction'Variants
-> Int
-> Text
-> Maybe Text
-> Maybe TransferDestination'Variants
-> Maybe TransferDestinationPayment'Variants
-> Text
-> Bool
-> Object
-> TransferReversals'
-> Bool
-> Maybe TransferSourceTransaction'Variants
-> Maybe Text
-> Maybe Text
-> Transfer
Transfer
    { transferAmount :: Int
transferAmount = Int
transferAmount,
      transferAmountReversed :: Int
transferAmountReversed = Int
transferAmountReversed,
      transferBalanceTransaction :: Maybe TransferBalanceTransaction'Variants
transferBalanceTransaction = Maybe TransferBalanceTransaction'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      transferCreated :: Int
transferCreated = Int
transferCreated,
      transferCurrency :: Text
transferCurrency = Text
transferCurrency,
      transferDescription :: Maybe Text
transferDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      transferDestination :: Maybe TransferDestination'Variants
transferDestination = Maybe TransferDestination'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      transferDestinationPayment :: Maybe TransferDestinationPayment'Variants
transferDestinationPayment = Maybe TransferDestinationPayment'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      transferId :: Text
transferId = Text
transferId,
      transferLivemode :: Bool
transferLivemode = Bool
transferLivemode,
      transferMetadata :: Object
transferMetadata = Object
transferMetadata,
      transferReversals :: TransferReversals'
transferReversals = TransferReversals'
transferReversals,
      transferReversed :: Bool
transferReversed = Bool
transferReversed,
      transferSourceTransaction :: Maybe TransferSourceTransaction'Variants
transferSourceTransaction = Maybe TransferSourceTransaction'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      transferSourceType :: Maybe Text
transferSourceType = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      transferTransferGroup :: Maybe Text
transferTransferGroup = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

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

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

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

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

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

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

-- | Defines the oneOf schema located at @components.schemas.transfer.properties.destination_payment.anyOf@ in the specification.
--
-- If the destination is a Stripe account, this will be the ID of the payment that the destination account received for the transfer.
data TransferDestinationPayment'Variants
  = TransferDestinationPayment'Text Data.Text.Internal.Text
  | TransferDestinationPayment'Charge Charge
  deriving (Int -> TransferDestinationPayment'Variants -> ShowS
[TransferDestinationPayment'Variants] -> ShowS
TransferDestinationPayment'Variants -> String
(Int -> TransferDestinationPayment'Variants -> ShowS)
-> (TransferDestinationPayment'Variants -> String)
-> ([TransferDestinationPayment'Variants] -> ShowS)
-> Show TransferDestinationPayment'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransferDestinationPayment'Variants] -> ShowS
$cshowList :: [TransferDestinationPayment'Variants] -> ShowS
show :: TransferDestinationPayment'Variants -> String
$cshow :: TransferDestinationPayment'Variants -> String
showsPrec :: Int -> TransferDestinationPayment'Variants -> ShowS
$cshowsPrec :: Int -> TransferDestinationPayment'Variants -> ShowS
GHC.Show.Show, TransferDestinationPayment'Variants
-> TransferDestinationPayment'Variants -> Bool
(TransferDestinationPayment'Variants
 -> TransferDestinationPayment'Variants -> Bool)
-> (TransferDestinationPayment'Variants
    -> TransferDestinationPayment'Variants -> Bool)
-> Eq TransferDestinationPayment'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransferDestinationPayment'Variants
-> TransferDestinationPayment'Variants -> Bool
$c/= :: TransferDestinationPayment'Variants
-> TransferDestinationPayment'Variants -> Bool
== :: TransferDestinationPayment'Variants
-> TransferDestinationPayment'Variants -> Bool
$c== :: TransferDestinationPayment'Variants
-> TransferDestinationPayment'Variants -> Bool
GHC.Classes.Eq)

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

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

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

instance Data.Aeson.Types.ToJSON.ToJSON TransferReversals' where
  toJSON :: TransferReversals' -> Value
toJSON TransferReversals'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"data" Text -> [TransferReversal] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversals' -> [TransferReversal]
transferReversals'Data TransferReversals'
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..= TransferReversals' -> Bool
transferReversals'HasMore TransferReversals'
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..= TransferReversals' -> Text
transferReversals'Url TransferReversals'
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 :: TransferReversals' -> Encoding
toEncoding TransferReversals'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"data" Text -> [TransferReversal] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TransferReversals' -> [TransferReversal]
transferReversals'Data TransferReversals'
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..= TransferReversals' -> Bool
transferReversals'HasMore TransferReversals'
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..= TransferReversals' -> Text
transferReversals'Url TransferReversals'
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 TransferReversals' where
  parseJSON :: Value -> Parser TransferReversals'
parseJSON = String
-> (Object -> Parser TransferReversals')
-> Value
-> Parser TransferReversals'
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"TransferReversals'" (\Object
obj -> ((([TransferReversal] -> Bool -> Text -> TransferReversals')
-> Parser
     ([TransferReversal] -> Bool -> Text -> TransferReversals')
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure [TransferReversal] -> Bool -> Text -> TransferReversals'
TransferReversals' Parser ([TransferReversal] -> Bool -> Text -> TransferReversals')
-> Parser [TransferReversal]
-> Parser (Bool -> Text -> TransferReversals')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser [TransferReversal]
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"data")) Parser (Bool -> Text -> TransferReversals')
-> Parser Bool -> Parser (Text -> TransferReversals')
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 -> TransferReversals')
-> Parser Text -> Parser TransferReversals'
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 'TransferReversals'' with all required fields.
mkTransferReversals' ::
  -- | 'transferReversals'Data'
  [TransferReversal] ->
  -- | 'transferReversals'HasMore'
  GHC.Types.Bool ->
  -- | 'transferReversals'Url'
  Data.Text.Internal.Text ->
  TransferReversals'
mkTransferReversals' :: [TransferReversal] -> Bool -> Text -> TransferReversals'
mkTransferReversals' [TransferReversal]
transferReversals'Data Bool
transferReversals'HasMore Text
transferReversals'Url =
  TransferReversals' :: [TransferReversal] -> Bool -> Text -> TransferReversals'
TransferReversals'
    { transferReversals'Data :: [TransferReversal]
transferReversals'Data = [TransferReversal]
transferReversals'Data,
      transferReversals'HasMore :: Bool
transferReversals'HasMore = Bool
transferReversals'HasMore,
      transferReversals'Url :: Text
transferReversals'Url = Text
transferReversals'Url
    }

-- | Defines the oneOf schema located at @components.schemas.transfer.properties.source_transaction.anyOf@ in the specification.
--
-- ID of the charge or payment that was used to fund the transfer. If null, the transfer was funded from the available balance.
data TransferSourceTransaction'Variants
  = TransferSourceTransaction'Text Data.Text.Internal.Text
  | TransferSourceTransaction'Charge Charge
  deriving (Int -> TransferSourceTransaction'Variants -> ShowS
[TransferSourceTransaction'Variants] -> ShowS
TransferSourceTransaction'Variants -> String
(Int -> TransferSourceTransaction'Variants -> ShowS)
-> (TransferSourceTransaction'Variants -> String)
-> ([TransferSourceTransaction'Variants] -> ShowS)
-> Show TransferSourceTransaction'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransferSourceTransaction'Variants] -> ShowS
$cshowList :: [TransferSourceTransaction'Variants] -> ShowS
show :: TransferSourceTransaction'Variants -> String
$cshow :: TransferSourceTransaction'Variants -> String
showsPrec :: Int -> TransferSourceTransaction'Variants -> ShowS
$cshowsPrec :: Int -> TransferSourceTransaction'Variants -> ShowS
GHC.Show.Show, TransferSourceTransaction'Variants
-> TransferSourceTransaction'Variants -> Bool
(TransferSourceTransaction'Variants
 -> TransferSourceTransaction'Variants -> Bool)
-> (TransferSourceTransaction'Variants
    -> TransferSourceTransaction'Variants -> Bool)
-> Eq TransferSourceTransaction'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransferSourceTransaction'Variants
-> TransferSourceTransaction'Variants -> Bool
$c/= :: TransferSourceTransaction'Variants
-> TransferSourceTransaction'Variants -> Bool
== :: TransferSourceTransaction'Variants
-> TransferSourceTransaction'Variants -> Bool
$c== :: TransferSourceTransaction'Variants
-> TransferSourceTransaction'Variants -> Bool
GHC.Classes.Eq)

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

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