{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Operations.PostRefundsRefund 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
postRefundsRefund ::
forall m.
StripeAPI.Common.MonadHTTP m =>
Data.Text.Internal.Text ->
GHC.Maybe.Maybe PostRefundsRefundRequestBody ->
StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response PostRefundsRefundResponse)
postRefundsRefund :: Text
-> Maybe PostRefundsRefundRequestBody
-> StripeT m (Response PostRefundsRefundResponse)
postRefundsRefund
Text
refund
Maybe PostRefundsRefundRequestBody
body =
(Response ByteString -> Response PostRefundsRefundResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response PostRefundsRefundResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( \Response ByteString
response_0 ->
(ByteString -> PostRefundsRefundResponse)
-> Response ByteString -> Response PostRefundsRefundResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( (String -> PostRefundsRefundResponse)
-> (PostRefundsRefundResponse -> PostRefundsRefundResponse)
-> Either String PostRefundsRefundResponse
-> PostRefundsRefundResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostRefundsRefundResponse
PostRefundsRefundResponseError PostRefundsRefundResponse -> PostRefundsRefundResponse
forall a. a -> a
GHC.Base.id
(Either String PostRefundsRefundResponse
-> PostRefundsRefundResponse)
-> (ByteString -> Either String PostRefundsRefundResponse)
-> ByteString
-> PostRefundsRefundResponse
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) ->
Refund -> PostRefundsRefundResponse
PostRefundsRefundResponse200
(Refund -> PostRefundsRefundResponse)
-> Either String Refund -> Either String PostRefundsRefundResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Refund
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
Data.Either.Either
GHC.Base.String
Refund
)
| 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 -> PostRefundsRefundResponse
PostRefundsRefundResponseDefault
(Error -> PostRefundsRefundResponse)
-> Either String Error -> Either String PostRefundsRefundResponse
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 PostRefundsRefundResponse
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 PostRefundsRefundRequestBody
-> RequestBodyEncoding
-> StripeT m (Response ByteString)
forall (m :: * -> *) body.
(MonadHTTP m, ToJSON body) =>
Text
-> Text
-> [QueryParameter]
-> Maybe body
-> RequestBodyEncoding
-> StripeT 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/refunds/" 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
refund)) String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ String
""))) [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty Maybe PostRefundsRefundRequestBody
body RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)
data PostRefundsRefundRequestBody = PostRefundsRefundRequestBody
{
PostRefundsRefundRequestBody -> Maybe [Text]
postRefundsRefundRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
PostRefundsRefundRequestBody
-> Maybe PostRefundsRefundRequestBodyMetadata'Variants
postRefundsRefundRequestBodyMetadata :: (GHC.Maybe.Maybe PostRefundsRefundRequestBodyMetadata'Variants)
}
deriving
( Int -> PostRefundsRefundRequestBody -> String -> String
[PostRefundsRefundRequestBody] -> String -> String
PostRefundsRefundRequestBody -> String
(Int -> PostRefundsRefundRequestBody -> String -> String)
-> (PostRefundsRefundRequestBody -> String)
-> ([PostRefundsRefundRequestBody] -> String -> String)
-> Show PostRefundsRefundRequestBody
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostRefundsRefundRequestBody] -> String -> String
$cshowList :: [PostRefundsRefundRequestBody] -> String -> String
show :: PostRefundsRefundRequestBody -> String
$cshow :: PostRefundsRefundRequestBody -> String
showsPrec :: Int -> PostRefundsRefundRequestBody -> String -> String
$cshowsPrec :: Int -> PostRefundsRefundRequestBody -> String -> String
GHC.Show.Show,
PostRefundsRefundRequestBody
-> PostRefundsRefundRequestBody -> Bool
(PostRefundsRefundRequestBody
-> PostRefundsRefundRequestBody -> Bool)
-> (PostRefundsRefundRequestBody
-> PostRefundsRefundRequestBody -> Bool)
-> Eq PostRefundsRefundRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostRefundsRefundRequestBody
-> PostRefundsRefundRequestBody -> Bool
$c/= :: PostRefundsRefundRequestBody
-> PostRefundsRefundRequestBody -> Bool
== :: PostRefundsRefundRequestBody
-> PostRefundsRefundRequestBody -> Bool
$c== :: PostRefundsRefundRequestBody
-> PostRefundsRefundRequestBody -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON PostRefundsRefundRequestBody where
toJSON :: PostRefundsRefundRequestBody -> Value
toJSON PostRefundsRefundRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"expand" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRefundsRefundRequestBody -> Maybe [Text]
postRefundsRefundRequestBodyExpand PostRefundsRefundRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Maybe PostRefundsRefundRequestBodyMetadata'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRefundsRefundRequestBody
-> Maybe PostRefundsRefundRequestBodyMetadata'Variants
postRefundsRefundRequestBodyMetadata PostRefundsRefundRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: PostRefundsRefundRequestBody -> Encoding
toEncoding PostRefundsRefundRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"expand" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRefundsRefundRequestBody -> Maybe [Text]
postRefundsRefundRequestBodyExpand PostRefundsRefundRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"metadata" Text
-> Maybe PostRefundsRefundRequestBodyMetadata'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostRefundsRefundRequestBody
-> Maybe PostRefundsRefundRequestBodyMetadata'Variants
postRefundsRefundRequestBodyMetadata PostRefundsRefundRequestBody
obj))
instance Data.Aeson.Types.FromJSON.FromJSON PostRefundsRefundRequestBody where
parseJSON :: Value -> Parser PostRefundsRefundRequestBody
parseJSON = String
-> (Object -> Parser PostRefundsRefundRequestBody)
-> Value
-> Parser PostRefundsRefundRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostRefundsRefundRequestBody" (\Object
obj -> ((Maybe [Text]
-> Maybe PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBody)
-> Parser
(Maybe [Text]
-> Maybe PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe [Text]
-> Maybe PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBody
PostRefundsRefundRequestBody Parser
(Maybe [Text]
-> Maybe PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBody)
-> Parser (Maybe [Text])
-> Parser
(Maybe PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBody)
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 PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBody)
-> Parser (Maybe PostRefundsRefundRequestBodyMetadata'Variants)
-> Parser PostRefundsRefundRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PostRefundsRefundRequestBodyMetadata'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata"))
mkPostRefundsRefundRequestBody :: PostRefundsRefundRequestBody
mkPostRefundsRefundRequestBody :: PostRefundsRefundRequestBody
mkPostRefundsRefundRequestBody =
PostRefundsRefundRequestBody :: Maybe [Text]
-> Maybe PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBody
PostRefundsRefundRequestBody
{ postRefundsRefundRequestBodyExpand :: Maybe [Text]
postRefundsRefundRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
postRefundsRefundRequestBodyMetadata :: Maybe PostRefundsRefundRequestBodyMetadata'Variants
postRefundsRefundRequestBodyMetadata = Maybe PostRefundsRefundRequestBodyMetadata'Variants
forall a. Maybe a
GHC.Maybe.Nothing
}
data PostRefundsRefundRequestBodyMetadata'Variants
=
PostRefundsRefundRequestBodyMetadata'EmptyString
| PostRefundsRefundRequestBodyMetadata'Object Data.Aeson.Types.Internal.Object
deriving (Int
-> PostRefundsRefundRequestBodyMetadata'Variants
-> String
-> String
[PostRefundsRefundRequestBodyMetadata'Variants] -> String -> String
PostRefundsRefundRequestBodyMetadata'Variants -> String
(Int
-> PostRefundsRefundRequestBodyMetadata'Variants
-> String
-> String)
-> (PostRefundsRefundRequestBodyMetadata'Variants -> String)
-> ([PostRefundsRefundRequestBodyMetadata'Variants]
-> String -> String)
-> Show PostRefundsRefundRequestBodyMetadata'Variants
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostRefundsRefundRequestBodyMetadata'Variants] -> String -> String
$cshowList :: [PostRefundsRefundRequestBodyMetadata'Variants] -> String -> String
show :: PostRefundsRefundRequestBodyMetadata'Variants -> String
$cshow :: PostRefundsRefundRequestBodyMetadata'Variants -> String
showsPrec :: Int
-> PostRefundsRefundRequestBodyMetadata'Variants
-> String
-> String
$cshowsPrec :: Int
-> PostRefundsRefundRequestBodyMetadata'Variants
-> String
-> String
GHC.Show.Show, PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBodyMetadata'Variants -> Bool
(PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBodyMetadata'Variants -> Bool)
-> (PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBodyMetadata'Variants -> Bool)
-> Eq PostRefundsRefundRequestBodyMetadata'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBodyMetadata'Variants -> Bool
$c/= :: PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBodyMetadata'Variants -> Bool
== :: PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBodyMetadata'Variants -> Bool
$c== :: PostRefundsRefundRequestBodyMetadata'Variants
-> PostRefundsRefundRequestBodyMetadata'Variants -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON PostRefundsRefundRequestBodyMetadata'Variants where
toJSON :: PostRefundsRefundRequestBodyMetadata'Variants -> Value
toJSON (PostRefundsRefundRequestBodyMetadata'Object Object
a) = Object -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Object
a
toJSON (PostRefundsRefundRequestBodyMetadata'Variants
PostRefundsRefundRequestBodyMetadata'EmptyString) = Value
""
instance Data.Aeson.Types.FromJSON.FromJSON PostRefundsRefundRequestBodyMetadata'Variants where
parseJSON :: Value -> Parser PostRefundsRefundRequestBodyMetadata'Variants
parseJSON Value
val =
if
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"" -> PostRefundsRefundRequestBodyMetadata'Variants
-> Parser PostRefundsRefundRequestBodyMetadata'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PostRefundsRefundRequestBodyMetadata'Variants
PostRefundsRefundRequestBodyMetadata'EmptyString
| Bool
GHC.Base.otherwise -> case (Object -> PostRefundsRefundRequestBodyMetadata'Variants
PostRefundsRefundRequestBodyMetadata'Object (Object -> PostRefundsRefundRequestBodyMetadata'Variants)
-> Result Object
-> Result PostRefundsRefundRequestBodyMetadata'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 PostRefundsRefundRequestBodyMetadata'Variants
-> Result PostRefundsRefundRequestBodyMetadata'Variants
-> Result PostRefundsRefundRequestBodyMetadata'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result PostRefundsRefundRequestBodyMetadata'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched" of
Data.Aeson.Types.Internal.Success PostRefundsRefundRequestBodyMetadata'Variants
a -> PostRefundsRefundRequestBodyMetadata'Variants
-> Parser PostRefundsRefundRequestBodyMetadata'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PostRefundsRefundRequestBodyMetadata'Variants
a
Data.Aeson.Types.Internal.Error String
a -> String -> Parser PostRefundsRefundRequestBodyMetadata'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a
data PostRefundsRefundResponse
=
PostRefundsRefundResponseError GHC.Base.String
|
PostRefundsRefundResponse200 Refund
|
PostRefundsRefundResponseDefault Error
deriving (Int -> PostRefundsRefundResponse -> String -> String
[PostRefundsRefundResponse] -> String -> String
PostRefundsRefundResponse -> String
(Int -> PostRefundsRefundResponse -> String -> String)
-> (PostRefundsRefundResponse -> String)
-> ([PostRefundsRefundResponse] -> String -> String)
-> Show PostRefundsRefundResponse
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostRefundsRefundResponse] -> String -> String
$cshowList :: [PostRefundsRefundResponse] -> String -> String
show :: PostRefundsRefundResponse -> String
$cshow :: PostRefundsRefundResponse -> String
showsPrec :: Int -> PostRefundsRefundResponse -> String -> String
$cshowsPrec :: Int -> PostRefundsRefundResponse -> String -> String
GHC.Show.Show, PostRefundsRefundResponse -> PostRefundsRefundResponse -> Bool
(PostRefundsRefundResponse -> PostRefundsRefundResponse -> Bool)
-> (PostRefundsRefundResponse -> PostRefundsRefundResponse -> Bool)
-> Eq PostRefundsRefundResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostRefundsRefundResponse -> PostRefundsRefundResponse -> Bool
$c/= :: PostRefundsRefundResponse -> PostRefundsRefundResponse -> Bool
== :: PostRefundsRefundResponse -> PostRefundsRefundResponse -> Bool
$c== :: PostRefundsRefundResponse -> PostRefundsRefundResponse -> Bool
GHC.Classes.Eq)