{-# LANGUAGE OverloadedStrings #-}
module Mollie.API.Methods
    ( methodsPath
    , getMethod
    , getMethods
    
    , PaymentMethod (..)
    , MethodAmount (..)
    , MethodImage (..)
    , Method (..)
    , ListLinks (..)
    , List (..)
    , ResponseError (..)
    ) where
import           Data.Monoid
import qualified Data.Text           as Text
import           Mollie.API.Internal
import           Mollie.API.Types
methodsPath :: Text.Text
methodsPath = "methods"
getMethod :: PaymentMethod
          -> Text.Text 
          -> Mollie (Either ResponseError Method)
getMethod methodId locale = get path
    where
        path = (Text.intercalate "/" [methodsPath, toText methodId]) <> query
        query = "?locale=" <> locale
getMethods :: Text.Text 
           -> Int 
           -> Int 
           -> Mollie (Either ResponseError (List Method))
getMethods locale offset count = get path
    where
        path = methodsPath <> query
        query = "?locale=" <> locale <> "&offset=" <> showT offset <> "&count=" <> showT count