{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
module Web.Stripe.Card
(
CreateCustomerCardByToken
, createCustomerCardByToken
, CreateRecipientCardByToken
, createRecipientCardByToken
, CreateCustomerCard
, createCustomerCard
, CreateRecipientCard
, createRecipientCard
, GetCustomerCard
, getCustomerCard
, GetRecipientCard
, getRecipientCard
, GetCustomerCards
, getCustomerCards
, GetRecipientCards
, getRecipientCards
, UpdateCustomerCard
, updateCustomerCard
, UpdateRecipientCard
, updateRecipientCard
, DeleteCustomerCard
, deleteCustomerCard
, DeleteRecipientCard
, deleteRecipientCard
, AddressLine1 (..)
, AddressLine2 (..)
, AddressCity (..)
, AddressCountry (..)
, AddressState (..)
, AddressZip (..)
, Brand (..)
, Card (..)
, CardId (..)
, CardNumber (..)
, CVC (..)
, EndingBefore (..)
, ExpandParams (..)
, ExpMonth (..)
, ExpYear (..)
, Limit (..)
, Name (..)
, RecipientCard (..)
, RecipientCardId (..)
, RecipientId (..)
, StartingAfter (..)
) where
import Data.Text (Text)
import Web.Stripe.StripeRequest (Method (GET, POST, DELETE),
StripeHasParam, StripeRequest (..),
StripeReturn, ToStripeParam(..),
mkStripeRequest)
import Web.Stripe.Util ((</>))
import Web.Stripe.Types (AddressLine1(..), AddressLine2(..)
, AddressCity(..), AddressCountry(..)
, AddressState(..), AddressZip(..)
, Brand(..), Card(..), CardId(..)
, CardNumber(..), CustomerId(..)
, CVC(..), EndingBefore(..)
, ExpandParams(..)
, ExpMonth(..), ExpYear(..), ID
, Limit(..), Name(..), NewCard(..)
, RecipientCard(..)
, RecipientId(..), RecipientCardId(..)
, StartingAfter(..)
, StripeDeleteResult(..)
, StripeList(..), TokenId(..), URL)
import Web.Stripe.Types.Util (getCustomerId, getRecipientId)
createCardByToken
:: URL
-> ID
-> TokenId
-> StripeRequest a
createCardByToken
prefix
id_
tokenid = request
where request = mkStripeRequest POST url params
url = prefix </> id_ </> "cards"
params = toStripeParam tokenid []
createCustomerCardByToken
:: CustomerId
-> TokenId
-> StripeRequest CreateCustomerCardByToken
createCustomerCardByToken
customerid
tokenid =
createCardByToken "customers" (getCustomerId customerid) tokenid
data CreateCustomerCardByToken
type instance StripeReturn CreateCustomerCardByToken = Card
createRecipientCardByToken
:: RecipientId
-> TokenId
-> StripeRequest CreateRecipientCardByToken
createRecipientCardByToken
recipientid
tokenid =
createCardByToken "recipients" (getRecipientId recipientid) tokenid
data CreateRecipientCardByToken
type instance StripeReturn CreateRecipientCardByToken = RecipientCard
createCard
:: URL
-> ID
-> NewCard
-> StripeRequest a
createCard
prefix
id_
newCard = request
where request = mkStripeRequest POST url params
url = prefix </> id_ </> "cards"
params = toStripeParam newCard []
createCustomerCard
:: CustomerId
-> NewCard
-> StripeRequest CreateCustomerCard
createCustomerCard
customerid
newCard = createCard "customers" (getCustomerId customerid) newCard
data CreateCustomerCard
type instance StripeReturn CreateCustomerCard = Card
createRecipientCard
:: RecipientId
-> NewCard
-> StripeRequest CreateRecipientCard
createRecipientCard
recipientid
newCard = createCard "recipients" (getRecipientId recipientid) newCard
data CreateRecipientCard
type instance StripeReturn CreateRecipientCard = RecipientCard
getCard
:: URL
-> ID
-> Text
-> StripeRequest a
getCard
prefix
id_
cardid_ = request
where request = mkStripeRequest GET url params
url = prefix </> id_ </>
"cards" </> cardid_
params = []
getCustomerCard
:: CustomerId
-> CardId
-> StripeRequest GetCustomerCard
getCustomerCard
customerid
(CardId cardid) = getCard "customers" (getCustomerId customerid) cardid
data GetCustomerCard
type instance StripeReturn GetCustomerCard = Card
instance StripeHasParam GetCustomerCard ExpandParams
getRecipientCard
:: RecipientId
-> RecipientCardId
-> StripeRequest GetRecipientCard
getRecipientCard
recipientid
(RecipientCardId cardid)
= getCard "recipients" (getRecipientId recipientid) cardid
data GetRecipientCard
type instance StripeReturn GetRecipientCard = RecipientCard
instance StripeHasParam GetRecipientCard ExpandParams
updateCard
:: URL
-> ID
-> Text
-> StripeRequest a
updateCard
prefix
id_
cardid_ = request
where request = mkStripeRequest POST url params
url = prefix </> id_ </>
"cards" </> cardid_
params = []
updateCustomerCard
:: CustomerId
-> CardId
-> StripeRequest UpdateCustomerCard
updateCustomerCard
customerid
(CardId cardid)
= updateCard "customers" (getCustomerId customerid) cardid
data UpdateCustomerCard
type instance StripeReturn UpdateCustomerCard = Card
instance StripeHasParam UpdateCustomerCard AddressLine1
instance StripeHasParam UpdateCustomerCard AddressLine2
instance StripeHasParam UpdateCustomerCard AddressCity
instance StripeHasParam UpdateCustomerCard AddressZip
instance StripeHasParam UpdateCustomerCard AddressState
instance StripeHasParam UpdateCustomerCard AddressCountry
instance StripeHasParam UpdateCustomerCard ExpMonth
instance StripeHasParam UpdateCustomerCard ExpYear
instance StripeHasParam UpdateCustomerCard Name
updateRecipientCard
:: RecipientId
-> RecipientCardId
-> StripeRequest UpdateRecipientCard
updateRecipientCard
recipientid
(RecipientCardId cardid)
= updateCard "recipients" (getRecipientId recipientid) cardid
data UpdateRecipientCard
type instance StripeReturn UpdateRecipientCard = RecipientCard
instance StripeHasParam UpdateRecipientCard AddressLine1
instance StripeHasParam UpdateRecipientCard AddressLine2
instance StripeHasParam UpdateRecipientCard AddressCity
instance StripeHasParam UpdateRecipientCard AddressZip
instance StripeHasParam UpdateRecipientCard AddressState
instance StripeHasParam UpdateRecipientCard AddressCountry
instance StripeHasParam UpdateRecipientCard ExpMonth
instance StripeHasParam UpdateRecipientCard ExpYear
instance StripeHasParam UpdateRecipientCard Name
deleteCard
:: URL
-> ID
-> Text
-> StripeRequest a
deleteCard
prefix
id_
cardid_ = request
where request = mkStripeRequest DELETE url params
url = prefix </> id_ </> "cards" </> cardid_
params = []
deleteCustomerCard
:: CustomerId
-> CardId
-> StripeRequest DeleteCustomerCard
deleteCustomerCard
customerid
(CardId cardid) = deleteCard "customers" (getCustomerId customerid) cardid
data DeleteCustomerCard
type instance StripeReturn DeleteCustomerCard = StripeDeleteResult
deleteRecipientCard
:: RecipientId
-> RecipientCardId
-> StripeRequest DeleteRecipientCard
deleteRecipientCard
recipientid
(RecipientCardId cardid)
= deleteCard "recipients" (getRecipientId recipientid) cardid
data DeleteRecipientCard
type instance StripeReturn DeleteRecipientCard = StripeDeleteResult
getCards
:: URL
-> ID
-> StripeRequest a
getCards
prefix
id_
= request
where request = mkStripeRequest GET url params
url = prefix </> id_ </> "cards"
params = []
getCustomerCards
:: CustomerId
-> StripeRequest GetCustomerCards
getCustomerCards
customerid
= getCards "customers" (getCustomerId customerid)
data GetCustomerCards
type instance StripeReturn GetCustomerCards = (StripeList Card)
instance StripeHasParam GetCustomerCards ExpandParams
instance StripeHasParam GetCustomerCards (EndingBefore CardId)
instance StripeHasParam GetCustomerCards Limit
instance StripeHasParam GetCustomerCards (StartingAfter CardId)
getRecipientCards
:: RecipientId
-> StripeRequest GetRecipientCards
getRecipientCards
recipientid
= getCards "recipients" (getRecipientId recipientid)
data GetRecipientCards
type instance StripeReturn GetRecipientCards = (StripeList RecipientCard)
instance StripeHasParam GetRecipientCards ExpandParams
instance StripeHasParam GetRecipientCards (EndingBefore CardId)
instance StripeHasParam GetRecipientCards Limit
instance StripeHasParam GetRecipientCards (StartingAfter CardId)