{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
module Web.Stripe.Invoice
(
CreateInvoice
, createInvoice
, GetInvoice
, getInvoice
, GetInvoiceLineItems
, getInvoiceLineItems
, GetUpcomingInvoice
, getUpcomingInvoice
, UpdateInvoice
, updateInvoice
, PayInvoice
, payInvoice
, GetInvoices
, getInvoices
, ApplicationFeeId (..)
, Closed (..)
, CustomerId (..)
, Description (..)
, Discount (..)
, EndingBefore (..)
, ExpandParams (..)
, Forgiven (..)
, Invoice (..)
, InvoiceId (..)
, InvoiceLineItem (..)
, InvoiceLineItemId (..)
, InvoiceLineItemType (..)
, Limit (..)
, MetaData (..)
, Period (..)
, StatementDescription(..)
, StartingAfter (..)
, StripeList (..)
, SubscriptionId (..)
) where
import Web.Stripe.StripeRequest (Method(GET, POST), StripeRequest(..),
StripeReturn, StripeHasParam,
toStripeParam, mkStripeRequest)
import Web.Stripe.Util ((</>))
import Web.Stripe.Types (ApplicationFeeId(..), Closed(..),
CustomerId(..), Description(..),
Discount(..), EndingBefore(..),
ExpandParams(..), Forgiven(..),
Invoice(..),InvoiceId(..),
InvoiceLineItem(..),
InvoiceLineItemId(..),
InvoiceLineItemType(..),
Limit(..), MetaData(..), Period(..),
SubscriptionId(..), StartingAfter(..),
StatementDescription(..),
StripeList(..))
import Web.Stripe.Types.Util (getInvoiceId)
createInvoice
:: CustomerId
-> StripeRequest CreateInvoice
createInvoice
customerid
= request
where request = mkStripeRequest POST url params
url = "invoices"
params = toStripeParam customerid $
[]
data CreateInvoice
type instance StripeReturn CreateInvoice = Invoice
instance StripeHasParam CreateInvoice ApplicationFeeId
instance StripeHasParam CreateInvoice Description
instance StripeHasParam CreateInvoice MetaData
instance StripeHasParam CreateInvoice StatementDescription
instance StripeHasParam CreateInvoice SubscriptionId
getInvoice
:: InvoiceId
-> StripeRequest GetInvoice
getInvoice
invoiceid = request
where request = mkStripeRequest GET url params
url = "invoices" </> getInvoiceId invoiceid
params = []
data GetInvoice
type instance StripeReturn GetInvoice = Invoice
instance StripeHasParam GetInvoice ExpandParams
getInvoices
:: StripeRequest GetInvoices
getInvoices = request
where request = mkStripeRequest GET url params
url = "invoices"
params = []
data GetInvoices
type instance StripeReturn GetInvoices = StripeList Invoice
instance StripeHasParam GetInvoices ExpandParams
instance StripeHasParam GetInvoices (EndingBefore InvoiceId)
instance StripeHasParam GetInvoices Limit
instance StripeHasParam GetInvoices CustomerId
instance StripeHasParam GetInvoices (StartingAfter InvoiceId)
getInvoiceLineItems
:: InvoiceId
-> StripeRequest GetInvoiceLineItems
getInvoiceLineItems
invoiceid = request
where request = mkStripeRequest GET url params
url = "invoices" </> getInvoiceId invoiceid </> "lines"
params = []
data GetInvoiceLineItems
type instance StripeReturn GetInvoiceLineItems = StripeList InvoiceLineItem
instance StripeHasParam GetInvoiceLineItems CustomerId
instance StripeHasParam GetInvoiceLineItems (EndingBefore InvoiceLineItemId)
instance StripeHasParam GetInvoiceLineItems Limit
instance StripeHasParam GetInvoiceLineItems (StartingAfter InvoiceLineItemId)
instance StripeHasParam GetInvoiceLineItems SubscriptionId
getUpcomingInvoice
:: CustomerId
-> StripeRequest GetUpcomingInvoice
getUpcomingInvoice
customerid = request
where request = mkStripeRequest GET url params
url = "invoices" </> "upcoming"
params = toStripeParam customerid []
data GetUpcomingInvoice
type instance StripeReturn GetUpcomingInvoice = Invoice
instance StripeHasParam GetUpcomingInvoice SubscriptionId
updateInvoice
:: InvoiceId
-> StripeRequest UpdateInvoice
updateInvoice
invoiceid = request
where request = mkStripeRequest POST url params
url = "invoices" </> getInvoiceId invoiceid
params = []
data UpdateInvoice
type instance StripeReturn UpdateInvoice = Invoice
instance StripeHasParam UpdateInvoice ApplicationFeeId
instance StripeHasParam UpdateInvoice Closed
instance StripeHasParam UpdateInvoice Description
instance StripeHasParam UpdateInvoice Forgiven
instance StripeHasParam UpdateInvoice MetaData
instance StripeHasParam UpdateInvoice StatementDescription
payInvoice
:: InvoiceId
-> StripeRequest PayInvoice
payInvoice
invoiceid = request
where request = mkStripeRequest POST url params
url = "invoices" </> getInvoiceId invoiceid </> "pay"
params = []
data PayInvoice
type instance StripeReturn PayInvoice = Invoice