{-# LANGUAGE ExplicitForAll #-}
{-# 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 different functions to run the operation postTransfersIdReversals
module StripeAPI.Operations.PostTransfersIdReversals where

import qualified Control.Monad.Fail
import qualified Control.Monad.Trans.Reader
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.Either
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 Data.Vector
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified Network.HTTP.Client
import qualified Network.HTTP.Client as Network.HTTP.Client.Request
import qualified Network.HTTP.Client as Network.HTTP.Client.Types
import qualified Network.HTTP.Simple
import qualified Network.HTTP.Types
import qualified Network.HTTP.Types as Network.HTTP.Types.Status
import qualified Network.HTTP.Types as Network.HTTP.Types.URI
import qualified StripeAPI.Common
import StripeAPI.Types
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | > POST /v1/transfers/{id}/reversals
--
-- \<p>When you create a new reversal, you must specify a transfer to create it on.\<\/p>
--
-- \<p>When reversing transfers, you can optionally reverse part of the transfer. You can do so as many times as you wish until the entire transfer has been reversed.\<\/p>
--
-- \<p>Once entirely reversed, a transfer can’t be reversed again. This method will return an error when called on an already-reversed transfer, or when trying to reverse more money than is left on a transfer.\<\/p>
postTransfersIdReversals ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | id | Constraints: Maximum length of 5000
  Data.Text.Internal.Text ->
  -- | The request body to send
  GHC.Maybe.Maybe PostTransfersIdReversalsRequestBody ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response PostTransfersIdReversalsResponse)
postTransfersIdReversals :: Text
-> Maybe PostTransfersIdReversalsRequestBody
-> ClientT m (Response PostTransfersIdReversalsResponse)
postTransfersIdReversals
  Text
id
  Maybe PostTransfersIdReversalsRequestBody
body =
    (Response ByteString -> Response PostTransfersIdReversalsResponse)
-> ClientT m (Response ByteString)
-> ClientT m (Response PostTransfersIdReversalsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
      ( \Response ByteString
response_0 ->
          (ByteString -> PostTransfersIdReversalsResponse)
-> Response ByteString -> Response PostTransfersIdReversalsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
            ( (String -> PostTransfersIdReversalsResponse)
-> (PostTransfersIdReversalsResponse
    -> PostTransfersIdReversalsResponse)
-> Either String PostTransfersIdReversalsResponse
-> PostTransfersIdReversalsResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostTransfersIdReversalsResponse
PostTransfersIdReversalsResponseError PostTransfersIdReversalsResponse
-> PostTransfersIdReversalsResponse
forall a. a -> a
GHC.Base.id
                (Either String PostTransfersIdReversalsResponse
 -> PostTransfersIdReversalsResponse)
-> (ByteString -> Either String PostTransfersIdReversalsResponse)
-> ByteString
-> PostTransfersIdReversalsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. ( \Response ByteString
response ByteString
body ->
                               if
                                   | (\Status
status_1 -> Status -> Int
Network.HTTP.Types.Status.statusCode Status
status_1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Int
200) (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
                                     TransferReversal -> PostTransfersIdReversalsResponse
PostTransfersIdReversalsResponse200
                                       (TransferReversal -> PostTransfersIdReversalsResponse)
-> Either String TransferReversal
-> Either String PostTransfersIdReversalsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String TransferReversal
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                            Data.Either.Either
                                                              GHC.Base.String
                                                              TransferReversal
                                                        )
                                   | Bool -> Status -> Bool
forall a b. a -> b -> a
GHC.Base.const Bool
GHC.Types.True (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
                                     Error -> PostTransfersIdReversalsResponse
PostTransfersIdReversalsResponseDefault
                                       (Error -> PostTransfersIdReversalsResponse)
-> Either String Error
-> Either String PostTransfersIdReversalsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Error
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                            Data.Either.Either
                                                              GHC.Base.String
                                                              Error
                                                        )
                                   | Bool
GHC.Base.otherwise -> String -> Either String PostTransfersIdReversalsResponse
forall a b. a -> Either a b
Data.Either.Left String
"Missing default response type"
                           )
                  Response ByteString
response_0
            )
            Response ByteString
response_0
      )
      (Text
-> Text
-> [QueryParameter]
-> Maybe PostTransfersIdReversalsRequestBody
-> RequestBodyEncoding
-> ClientT m (Response ByteString)
forall (m :: * -> *) body.
(MonadHTTP m, ToJSON body) =>
Text
-> Text
-> [QueryParameter]
-> Maybe body
-> RequestBodyEncoding
-> ClientT m (Response ByteString)
StripeAPI.Common.doBodyCallWithConfigurationM (Text -> Text
Data.Text.toUpper (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
GHC.Base.$ String -> Text
Data.Text.pack String
"POST") (String -> Text
Data.Text.pack (String
"/v1/transfers/" String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ (ByteString -> String
Data.ByteString.Char8.unpack (Bool -> ByteString -> ByteString
Network.HTTP.Types.URI.urlEncode Bool
GHC.Types.True (ByteString -> ByteString) -> ByteString -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ (String -> ByteString
Data.ByteString.Char8.pack (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ Text -> String
forall a. StringifyModel a => a -> String
StripeAPI.Common.stringifyModel Text
id)) String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ String
"/reversals"))) [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty Maybe PostTransfersIdReversalsRequestBody
body RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)

-- | Defines the object schema located at @paths.\/v1\/transfers\/{id}\/reversals.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification.
data PostTransfersIdReversalsRequestBody = PostTransfersIdReversalsRequestBody
  { -- | amount: A positive integer in %s representing how much of this transfer to reverse. Can only reverse up to the unreversed amount remaining of the transfer. Partial transfer reversals are only allowed for transfers to Stripe Accounts. Defaults to the entire transfer amount.
    PostTransfersIdReversalsRequestBody -> Maybe Int
postTransfersIdReversalsRequestBodyAmount :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | description: An arbitrary string which you can attach to a reversal object. It is displayed alongside the reversal in the Dashboard. This will be unset if you POST an empty value.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PostTransfersIdReversalsRequestBody -> Maybe Text
postTransfersIdReversalsRequestBodyDescription :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | expand: Specifies which fields in the response should be expanded.
    PostTransfersIdReversalsRequestBody -> Maybe [Text]
postTransfersIdReversalsRequestBodyExpand :: (GHC.Maybe.Maybe ([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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to \`metadata\`.
    PostTransfersIdReversalsRequestBody
-> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
postTransfersIdReversalsRequestBodyMetadata :: (GHC.Maybe.Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants),
    -- | refund_application_fee: Boolean indicating whether the application fee should be refunded when reversing this transfer. If a full transfer reversal is given, the full application fee will be refunded. Otherwise, the application fee will be refunded with an amount proportional to the amount of the transfer reversed.
    PostTransfersIdReversalsRequestBody -> Maybe Bool
postTransfersIdReversalsRequestBodyRefundApplicationFee :: (GHC.Maybe.Maybe GHC.Types.Bool)
  }
  deriving
    ( Int -> PostTransfersIdReversalsRequestBody -> String -> String
[PostTransfersIdReversalsRequestBody] -> String -> String
PostTransfersIdReversalsRequestBody -> String
(Int -> PostTransfersIdReversalsRequestBody -> String -> String)
-> (PostTransfersIdReversalsRequestBody -> String)
-> ([PostTransfersIdReversalsRequestBody] -> String -> String)
-> Show PostTransfersIdReversalsRequestBody
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostTransfersIdReversalsRequestBody] -> String -> String
$cshowList :: [PostTransfersIdReversalsRequestBody] -> String -> String
show :: PostTransfersIdReversalsRequestBody -> String
$cshow :: PostTransfersIdReversalsRequestBody -> String
showsPrec :: Int -> PostTransfersIdReversalsRequestBody -> String -> String
$cshowsPrec :: Int -> PostTransfersIdReversalsRequestBody -> String -> String
GHC.Show.Show,
      PostTransfersIdReversalsRequestBody
-> PostTransfersIdReversalsRequestBody -> Bool
(PostTransfersIdReversalsRequestBody
 -> PostTransfersIdReversalsRequestBody -> Bool)
-> (PostTransfersIdReversalsRequestBody
    -> PostTransfersIdReversalsRequestBody -> Bool)
-> Eq PostTransfersIdReversalsRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTransfersIdReversalsRequestBody
-> PostTransfersIdReversalsRequestBody -> Bool
$c/= :: PostTransfersIdReversalsRequestBody
-> PostTransfersIdReversalsRequestBody -> Bool
== :: PostTransfersIdReversalsRequestBody
-> PostTransfersIdReversalsRequestBody -> Bool
$c== :: PostTransfersIdReversalsRequestBody
-> PostTransfersIdReversalsRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostTransfersIdReversalsRequestBody where
  toJSON :: PostTransfersIdReversalsRequestBody -> Value
toJSON PostTransfersIdReversalsRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTransfersIdReversalsRequestBody -> Maybe Int
postTransfersIdReversalsRequestBodyAmount PostTransfersIdReversalsRequestBody
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..= PostTransfersIdReversalsRequestBody -> Maybe Text
postTransfersIdReversalsRequestBodyDescription PostTransfersIdReversalsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"expand" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTransfersIdReversalsRequestBody -> Maybe [Text]
postTransfersIdReversalsRequestBodyExpand PostTransfersIdReversalsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text
-> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
-> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTransfersIdReversalsRequestBody
-> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
postTransfersIdReversalsRequestBodyMetadata PostTransfersIdReversalsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refund_application_fee" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTransfersIdReversalsRequestBody -> Maybe Bool
postTransfersIdReversalsRequestBodyRefundApplicationFee PostTransfersIdReversalsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostTransfersIdReversalsRequestBody -> Encoding
toEncoding PostTransfersIdReversalsRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTransfersIdReversalsRequestBody -> Maybe Int
postTransfersIdReversalsRequestBodyAmount PostTransfersIdReversalsRequestBody
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..= PostTransfersIdReversalsRequestBody -> Maybe Text
postTransfersIdReversalsRequestBodyDescription PostTransfersIdReversalsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"expand" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTransfersIdReversalsRequestBody -> Maybe [Text]
postTransfersIdReversalsRequestBodyExpand PostTransfersIdReversalsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text
-> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
-> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTransfersIdReversalsRequestBody
-> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
postTransfersIdReversalsRequestBodyMetadata PostTransfersIdReversalsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"refund_application_fee" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTransfersIdReversalsRequestBody -> Maybe Bool
postTransfersIdReversalsRequestBodyRefundApplicationFee PostTransfersIdReversalsRequestBody
obj)))))

instance Data.Aeson.Types.FromJSON.FromJSON PostTransfersIdReversalsRequestBody where
  parseJSON :: Value -> Parser PostTransfersIdReversalsRequestBody
parseJSON = String
-> (Object -> Parser PostTransfersIdReversalsRequestBody)
-> Value
-> Parser PostTransfersIdReversalsRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostTransfersIdReversalsRequestBody" (\Object
obj -> (((((Maybe Int
 -> Maybe Text
 -> Maybe [Text]
 -> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
 -> Maybe Bool
 -> PostTransfersIdReversalsRequestBody)
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe [Text]
      -> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
      -> Maybe Bool
      -> PostTransfersIdReversalsRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int
-> Maybe Text
-> Maybe [Text]
-> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
-> Maybe Bool
-> PostTransfersIdReversalsRequestBody
PostTransfersIdReversalsRequestBody Parser
  (Maybe Int
   -> Maybe Text
   -> Maybe [Text]
   -> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
   -> Maybe Bool
   -> PostTransfersIdReversalsRequestBody)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe [Text]
      -> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
      -> Maybe Bool
      -> PostTransfersIdReversalsRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"amount")) Parser
  (Maybe Text
   -> Maybe [Text]
   -> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
   -> Maybe Bool
   -> PostTransfersIdReversalsRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Text]
      -> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
      -> Maybe Bool
      -> PostTransfersIdReversalsRequestBody)
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 [Text]
   -> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
   -> Maybe Bool
   -> PostTransfersIdReversalsRequestBody)
-> Parser (Maybe [Text])
-> Parser
     (Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
      -> Maybe Bool -> PostTransfersIdReversalsRequestBody)
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
"expand")) Parser
  (Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
   -> Maybe Bool -> PostTransfersIdReversalsRequestBody)
-> Parser
     (Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants)
-> Parser (Maybe Bool -> PostTransfersIdReversalsRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser
     (Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata")) Parser (Maybe Bool -> PostTransfersIdReversalsRequestBody)
-> Parser (Maybe Bool)
-> Parser PostTransfersIdReversalsRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"refund_application_fee"))

-- | Create a new 'PostTransfersIdReversalsRequestBody' with all required fields.
mkPostTransfersIdReversalsRequestBody :: PostTransfersIdReversalsRequestBody
mkPostTransfersIdReversalsRequestBody :: PostTransfersIdReversalsRequestBody
mkPostTransfersIdReversalsRequestBody =
  PostTransfersIdReversalsRequestBody :: Maybe Int
-> Maybe Text
-> Maybe [Text]
-> Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
-> Maybe Bool
-> PostTransfersIdReversalsRequestBody
PostTransfersIdReversalsRequestBody
    { postTransfersIdReversalsRequestBodyAmount :: Maybe Int
postTransfersIdReversalsRequestBodyAmount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      postTransfersIdReversalsRequestBodyDescription :: Maybe Text
postTransfersIdReversalsRequestBodyDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTransfersIdReversalsRequestBodyExpand :: Maybe [Text]
postTransfersIdReversalsRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postTransfersIdReversalsRequestBodyMetadata :: Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
postTransfersIdReversalsRequestBodyMetadata = Maybe PostTransfersIdReversalsRequestBodyMetadata'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      postTransfersIdReversalsRequestBodyRefundApplicationFee :: Maybe Bool
postTransfersIdReversalsRequestBodyRefundApplicationFee = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the oneOf schema located at @paths.\/v1\/transfers\/{id}\/reversals.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.metadata.anyOf@ in the specification.
--
-- 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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to \`metadata\`.
data PostTransfersIdReversalsRequestBodyMetadata'Variants
  = -- | Represents the JSON value @""@
    PostTransfersIdReversalsRequestBodyMetadata'EmptyString
  | PostTransfersIdReversalsRequestBodyMetadata'Object Data.Aeson.Types.Internal.Object
  deriving (Int
-> PostTransfersIdReversalsRequestBodyMetadata'Variants
-> String
-> String
[PostTransfersIdReversalsRequestBodyMetadata'Variants]
-> String -> String
PostTransfersIdReversalsRequestBodyMetadata'Variants -> String
(Int
 -> PostTransfersIdReversalsRequestBodyMetadata'Variants
 -> String
 -> String)
-> (PostTransfersIdReversalsRequestBodyMetadata'Variants -> String)
-> ([PostTransfersIdReversalsRequestBodyMetadata'Variants]
    -> String -> String)
-> Show PostTransfersIdReversalsRequestBodyMetadata'Variants
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostTransfersIdReversalsRequestBodyMetadata'Variants]
-> String -> String
$cshowList :: [PostTransfersIdReversalsRequestBodyMetadata'Variants]
-> String -> String
show :: PostTransfersIdReversalsRequestBodyMetadata'Variants -> String
$cshow :: PostTransfersIdReversalsRequestBodyMetadata'Variants -> String
showsPrec :: Int
-> PostTransfersIdReversalsRequestBodyMetadata'Variants
-> String
-> String
$cshowsPrec :: Int
-> PostTransfersIdReversalsRequestBodyMetadata'Variants
-> String
-> String
GHC.Show.Show, PostTransfersIdReversalsRequestBodyMetadata'Variants
-> PostTransfersIdReversalsRequestBodyMetadata'Variants -> Bool
(PostTransfersIdReversalsRequestBodyMetadata'Variants
 -> PostTransfersIdReversalsRequestBodyMetadata'Variants -> Bool)
-> (PostTransfersIdReversalsRequestBodyMetadata'Variants
    -> PostTransfersIdReversalsRequestBodyMetadata'Variants -> Bool)
-> Eq PostTransfersIdReversalsRequestBodyMetadata'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTransfersIdReversalsRequestBodyMetadata'Variants
-> PostTransfersIdReversalsRequestBodyMetadata'Variants -> Bool
$c/= :: PostTransfersIdReversalsRequestBodyMetadata'Variants
-> PostTransfersIdReversalsRequestBodyMetadata'Variants -> Bool
== :: PostTransfersIdReversalsRequestBodyMetadata'Variants
-> PostTransfersIdReversalsRequestBodyMetadata'Variants -> Bool
$c== :: PostTransfersIdReversalsRequestBodyMetadata'Variants
-> PostTransfersIdReversalsRequestBodyMetadata'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostTransfersIdReversalsRequestBodyMetadata'Variants where
  toJSON :: PostTransfersIdReversalsRequestBodyMetadata'Variants -> Value
toJSON (PostTransfersIdReversalsRequestBodyMetadata'Object Object
a) = Object -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Object
a
  toJSON (PostTransfersIdReversalsRequestBodyMetadata'Variants
PostTransfersIdReversalsRequestBodyMetadata'EmptyString) = Value
""

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

-- | Represents a response of the operation 'postTransfersIdReversals'.
--
-- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'PostTransfersIdReversalsResponseError' is used.
data PostTransfersIdReversalsResponse
  = -- | Means either no matching case available or a parse error
    PostTransfersIdReversalsResponseError GHC.Base.String
  | -- | Successful response.
    PostTransfersIdReversalsResponse200 TransferReversal
  | -- | Error response.
    PostTransfersIdReversalsResponseDefault Error
  deriving (Int -> PostTransfersIdReversalsResponse -> String -> String
[PostTransfersIdReversalsResponse] -> String -> String
PostTransfersIdReversalsResponse -> String
(Int -> PostTransfersIdReversalsResponse -> String -> String)
-> (PostTransfersIdReversalsResponse -> String)
-> ([PostTransfersIdReversalsResponse] -> String -> String)
-> Show PostTransfersIdReversalsResponse
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostTransfersIdReversalsResponse] -> String -> String
$cshowList :: [PostTransfersIdReversalsResponse] -> String -> String
show :: PostTransfersIdReversalsResponse -> String
$cshow :: PostTransfersIdReversalsResponse -> String
showsPrec :: Int -> PostTransfersIdReversalsResponse -> String -> String
$cshowsPrec :: Int -> PostTransfersIdReversalsResponse -> String -> String
GHC.Show.Show, PostTransfersIdReversalsResponse
-> PostTransfersIdReversalsResponse -> Bool
(PostTransfersIdReversalsResponse
 -> PostTransfersIdReversalsResponse -> Bool)
-> (PostTransfersIdReversalsResponse
    -> PostTransfersIdReversalsResponse -> Bool)
-> Eq PostTransfersIdReversalsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTransfersIdReversalsResponse
-> PostTransfersIdReversalsResponse -> Bool
$c/= :: PostTransfersIdReversalsResponse
-> PostTransfersIdReversalsResponse -> Bool
== :: PostTransfersIdReversalsResponse
-> PostTransfersIdReversalsResponse -> Bool
$c== :: PostTransfersIdReversalsResponse
-> PostTransfersIdReversalsResponse -> Bool
GHC.Classes.Eq)