module Web.Stripe.ApplicationFeeRefund
(
createApplicationFeeRefund
, getApplicationFeeRefund
, getApplicationFeeRefundExpandable
, getApplicationFeeRefunds
, getApplicationFeeRefundsExpandable
, updateApplicationFeeRefund
, FeeId (..)
, RefundId (..)
, ApplicationFee (..)
, ApplicationFeeRefund (..)
, StripeList (..)
, EndingBefore
, StartingAfter
, Limit
, ExpandParams
, MetaData
, Amount
) where
import Web.Stripe.Client.Internal (Method (POST, GET), Stripe,
StripeRequest (..), callAPI,
getParams, toExpandable,
toMetaData, toText, (</>))
import Web.Stripe.Types (Amount, ApplicationFee (..),
ApplicationFeeRefund (..),
EndingBefore, ExpandParams,
FeeId (..), Limit, MetaData,
RefundId (..), StartingAfter,
StripeList (..))
createApplicationFeeRefund
:: FeeId
-> Maybe Amount
-> MetaData
-> Stripe ApplicationFeeRefund
createApplicationFeeRefund
(FeeId feeid)
amount
metadata = callAPI request
where request = StripeRequest POST url params
url = "application_fees" </> feeid </> "refunds"
params = toMetaData metadata ++ getParams [
("amount", fmap toText amount)
]
getApplicationFeeRefund
:: FeeId
-> RefundId
-> Stripe ApplicationFeeRefund
getApplicationFeeRefund feeid refundid =
getApplicationFeeRefundExpandable feeid refundid []
getApplicationFeeRefundExpandable
:: FeeId
-> RefundId
-> ExpandParams
-> Stripe ApplicationFeeRefund
getApplicationFeeRefundExpandable (FeeId feeid) (RefundId refundid) expansion
= callAPI request
where request = StripeRequest GET url params
url = "application_fees" </> feeid </> "refunds" </> refundid
params = toExpandable expansion
getApplicationFeeRefunds
:: FeeId
-> Limit
-> StartingAfter FeeId
-> EndingBefore FeeId
-> Stripe (StripeList ApplicationFeeRefund)
getApplicationFeeRefunds
feeid
limit
startingAfter
endingBefore =
getApplicationFeeRefundsExpandable
feeid limit startingAfter endingBefore []
getApplicationFeeRefundsExpandable
:: FeeId
-> Limit
-> StartingAfter FeeId
-> EndingBefore FeeId
-> ExpandParams
-> Stripe (StripeList ApplicationFeeRefund)
getApplicationFeeRefundsExpandable
(FeeId feeid)
limit
startingAfter
endingBefore
expandParams = callAPI request
where
request = StripeRequest GET url params
url = "application_fees" </> feeid </> "refunds"
params = getParams [
("limit", toText `fmap` limit )
, ("starting_after", (\(FeeId x) -> x) `fmap` startingAfter)
, ("ending_before", (\(FeeId x) -> x) `fmap` endingBefore)
] ++ toExpandable expandParams
updateApplicationFeeRefund
:: FeeId
-> RefundId
-> MetaData
-> Stripe (StripeList ApplicationFeeRefund)
updateApplicationFeeRefund
(FeeId feeid)
(RefundId refundid)
metadata = callAPI request
where
request = StripeRequest GET url params
url = "application_fees" </> feeid </> "refunds" </> refundid
params = toMetaData metadata