| Safe Haskell | None |
|---|
Web.Marmalade
Description
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 {}
- verifyPackage :: String -> Marmalade ()
- uploadPackage :: FilePath -> Marmalade Upload
- newtype Upload = Upload {}
The Marmalade Monad
The Marmalade monad.
This monad provides access to the Marmalade API.
Arguments
| :: 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.
Arguments
| :: 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.
Constructors
| MarmaladeInvalidResponseStatus Status (Maybe String) | An invalid response from Marmalade, with a status and probably an error message from Marmalade. |
| MarmaladeInvalidResponseBody ByteString | Invalid response body |
| MarmaladeBadRequest (Maybe 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
The name of a user
An authentication token.
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
verifyPackage :: String -> Marmalade ()Source
checks whether verifyPackage packagepackage is a valid package
object.
Throw an error if package does not exist, or is not a valid package.
uploadPackage :: FilePath -> Marmalade UploadSource
uploads a uploadPackage packagepackage file to Marmalade.
Return the result of the upload, or throw an error if package is not a
valid package, or if Marmalade refused to accept the upload.