module SuiteTalk.XML where
import qualified Data.Text as T
import Text.XML ( Name(..) )
import Text.XML.Writer ( ToXML
, XML
, element
, elementA
, toXML
)
import SuiteTalk.Auth ( TokenPassport(..) )
import SuiteTalk.Auth.Types ( Signature(..) )
newtype Header =
Header TokenPassport
buildBody :: (ToXML a) => a -> String -> XML
buildBody attributes soapAction = element soapAction' $ toXML attributes
where soapAction' = Name (T.pack soapAction) Nothing Nothing
buildHeader :: Header -> XML
buildHeader header = case header of
Header (TokenPassport account consumerKey tokenId nonce timestamp (Signature algorithm value))
-> element "tokenPassport" $ do
element "account" (T.pack account)
element "consumerKey" (T.pack consumerKey)
element "token" (T.pack tokenId)
element "nonce" (T.pack nonce)
element "timestamp" (T.pack $ show timestamp)
elementA "signature"
[("algorithm", T.pack $ show algorithm)]
(T.pack value)