Safe Haskell | None |
---|
Access to the API of Marmalade
- data Marmalade a
- runMarmalade :: String -> Auth -> Marmalade a -> IO a
- runMarmaladeWithManager :: String -> Auth -> Manager -> Marmalade a -> IO a
- data MarmaladeError
- newtype Username = Username String
- newtype Token = Token String
- data Auth
- login :: Marmalade (Username, Token)
- newtype Message = Message {}
- newtype Upload = Upload {}
- uploadPackage :: FilePath -> Marmalade Upload
The Marmalade Monad
The Marmalade monad.
This monad provides access to the Marmalade API.
:: String | The user agent sent to Marmalade |
-> Auth | The authentication information |
-> Marmalade a | The actions to run |
-> IO a | The result of the actions, or any error thrown in the course of running the actions. |
runs runMarmalade
userAgent auth actionsactions
.
userAgent
is sent as User-Agent
header to Marmalade, and auth
is the
authentication information.
Marmalade requires a token to access most of its API, however clients can login with a username and a password to obtain their token.
:: String | The user agent sent to Marmalade |
-> Auth | The authentication information |
-> Manager | The connection manager |
-> Marmalade a | The actions to run |
-> IO a | The result of the actions, or any error thrown in the course of running the actions. |
'runMarmaladeWithManager userAgent auth manager actions'
runs actions
with the given connection manager
.
Like
, except that it lets you use your own connection
manager.
runMarmalade
Error handling
data MarmaladeError Source
Errors thrown by Marmalade.
MarmaladeInvalidResponseStatus Status String | An invalid response from Marmalade, with a status and probably an error message from Marmalade. |
MarmaladeInvalidResponseBody ByteString | Invalid response body |
MarmaladeBadRequest String | A bad request error from Marmalade. Marmalade raises this error for failed logins and for uploads of invalid packages (e.g. files without a version header) |
MarmaladeInvalidPackage FilePath String | An invalid package file, with a corresponding error message. |
Authentication
Authentication information for Marmalade.
login :: Marmalade (Username, Token)Source
logs in to Marmalade to obtain the client's access token.
login
If the monad already uses token authentication this function is a no-op and merely returns the stored token. Otherwise it sends a login request to Marmalade to obtain the token and stores the token in the monad.
Generic types
Package uploads
The result of an upload.
Upload | |
|
uploadPackage :: FilePath -> Marmalade UploadSource
uploads a uploadPackage
packagepackage
file to Marmalade.
Return the result of the upload, or throw an error if Marmalade refused to accept the upload.