{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
module Web.Stripe.Subscription
(
CreateSubscription
, createSubscription
, GetSubscription
, getSubscription
, UpdateSubscription
, updateSubscription
, CancelSubscription
, cancelSubscription
, GetSubscriptions
, getSubscriptions
, GetSubscriptionsByCustomerId
, getSubscriptionsByCustomerId
, ApplicationFeePercent (..)
, AtPeriodEnd (..)
, CustomerId (..)
, CouponId (..)
, Coupon (..)
, EndingBefore (..)
, ExpandParams (..)
, Limit (..)
, MetaData (..)
, PlanId (..)
, Prorate (..)
, Quantity (..)
, StartingAfter (..)
, StripeList (..)
, Subscription (..)
, SubscriptionId (..)
, SubscriptionStatus (..)
, TaxPercent (..)
, TrialEnd (..)
) where
import Web.Stripe.StripeRequest (Method (GET, POST, DELETE),
StripeHasParam, StripeReturn,
StripeRequest (..),
ToStripeParam(..), mkStripeRequest)
import Web.Stripe.Util ((</>))
import Web.Stripe.Types (ApplicationFeePercent(..),
AtPeriodEnd(..), CardId(..),
CustomerId (..), Coupon(..),
CouponId(..), EndingBefore(..),
ExpandParams(..), Limit(..), MetaData(..),
PlanId (..), Prorate(..), Quantity(..),
StartingAfter(..),
Subscription (..), StripeList(..),
SubscriptionId (..),
SubscriptionStatus (..), TaxPercent(..),
TrialEnd(..))
import Web.Stripe.Types.Util (getCustomerId)
createSubscription
:: CustomerId
-> PlanId
-> StripeRequest CreateSubscription
createSubscription
customerid
planId = request
where request = mkStripeRequest POST url params
url = "customers" </> getCustomerId customerid </> "subscriptions"
params = toStripeParam planId []
data CreateSubscription
type instance StripeReturn CreateSubscription = Subscription
instance StripeHasParam CreateSubscription CouponId
instance StripeHasParam CreateSubscription Prorate
instance StripeHasParam CreateSubscription TrialEnd
instance StripeHasParam CreateSubscription CardId
instance StripeHasParam CreateSubscription Quantity
instance StripeHasParam CreateSubscription ApplicationFeePercent
instance StripeHasParam CreateSubscription MetaData
instance StripeHasParam CreateSubscription TaxPercent
getSubscription
:: CustomerId
-> SubscriptionId
-> StripeRequest GetSubscription
getSubscription
customerid
(SubscriptionId subscriptionid)
= request
where request = mkStripeRequest GET url params
url = "customers" </> getCustomerId customerid </>
"subscriptions" </> subscriptionid
params = []
data GetSubscription
type instance StripeReturn GetSubscription = Subscription
instance StripeHasParam GetSubscription ExpandParams
updateSubscription
:: CustomerId
-> SubscriptionId
-> StripeRequest UpdateSubscription
updateSubscription
customerid
(SubscriptionId subscriptionid)
= request
where request = mkStripeRequest POST url params
url = "customers" </> getCustomerId customerid </> "subscriptions" </> subscriptionid
params = []
data UpdateSubscription
type instance StripeReturn UpdateSubscription = Subscription
instance StripeHasParam UpdateSubscription PlanId
instance StripeHasParam UpdateSubscription CouponId
instance StripeHasParam UpdateSubscription Prorate
instance StripeHasParam UpdateSubscription TrialEnd
instance StripeHasParam UpdateSubscription CardId
instance StripeHasParam UpdateSubscription Quantity
instance StripeHasParam UpdateSubscription ApplicationFeePercent
instance StripeHasParam UpdateSubscription MetaData
instance StripeHasParam UpdateSubscription TaxPercent
cancelSubscription
:: CustomerId
-> SubscriptionId
-> StripeRequest CancelSubscription
cancelSubscription
customerid
(SubscriptionId subscriptionid)
= request
where request = mkStripeRequest DELETE url params
url = "customers" </> getCustomerId customerid </> "subscriptions" </> subscriptionid
params = []
data CancelSubscription
instance StripeHasParam CancelSubscription AtPeriodEnd
type instance StripeReturn CancelSubscription = Subscription
getSubscriptions
:: StripeRequest GetSubscriptions
getSubscriptions
= request
where request = mkStripeRequest GET url params
url = "subscriptions"
params = []
data GetSubscriptions
type instance StripeReturn GetSubscriptions = StripeList Subscription
instance StripeHasParam GetSubscriptions ExpandParams
instance StripeHasParam GetSubscriptions (EndingBefore SubscriptionId)
instance StripeHasParam GetSubscriptions Limit
instance StripeHasParam GetSubscriptions (StartingAfter SubscriptionId)
getSubscriptionsByCustomerId
:: CustomerId
-> StripeRequest GetSubscriptionsByCustomerId
getSubscriptionsByCustomerId
customerid = request
where request = mkStripeRequest GET url params
url = "customers" </> getCustomerId customerid </> "subscriptions"
params = []
data GetSubscriptionsByCustomerId
type instance StripeReturn GetSubscriptionsByCustomerId = StripeList Subscription
instance StripeHasParam GetSubscriptionsByCustomerId ExpandParams
instance StripeHasParam GetSubscriptionsByCustomerId (EndingBefore SubscriptionId)
instance StripeHasParam GetSubscriptionsByCustomerId Limit
instance StripeHasParam GetSubscriptionsByCustomerId (StartingAfter SubscriptionId)