{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module Mollie.API.Mandates
( MandateAPI
, newMandate
, createCustomerMandate
, getCustomerMandate
, getCustomerMandates
, getCustomerMandatesPaginated
, revokeCustomerMandate
) where
import Control.Lens ((&), (.~))
import Data.Default (def)
import qualified Data.Text as Text
import GHC.Generics (Generic)
import Mollie.API.Helpers
import Mollie.API.Internal (HalJSON)
import Mollie.API.Types
import Servant.API
import Servant.API.Generic
newMandate :: PaymentMethod
-> Text.Text
-> Text.Text
-> NewMandate
newMandate _method _consumerName _consumerAccount =
def
& method .~ _method
& consumerName .~ _consumerName
& consumerAccount .~ _consumerAccount
data MandateAPI route = MandateAPI
{ getCustomerMandatesPaginated :: route :- "customers"
:> Capture "customerId" CustomerId
:> "mandates"
:> QueryParam "limit" Int
:> QueryParam "from" MandateId
:> Get '[HalJSON] (List Mandate)
, getCustomerMandates :: route :- "customers"
:> Capture "customerId" CustomerId
:> "mandates"
:> Get '[HalJSON] (List Mandate)
, createCustomerMandate :: route :- "customers"
:> Capture "customerId" CustomerId
:> "mandates"
:> ReqBody '[JSON] NewMandate
:> Post '[HalJSON] Mandate
, getCustomerMandate :: route :- "customers"
:> Capture "customerId" CustomerId
:> "mandates"
:> Capture "id" MandateId
:> Get '[HalJSON] Mandate
, revokeCustomerMandate :: route :- "customers"
:> Capture "customerId" CustomerId
:> "mandates"
:> Capture "mandateId" MandateId
:> DeleteNoContent '[HalJSON] NoContent
} deriving Generic