Module

MeowClient.Session

Package
purescript-meowclient
Repository
userfriendanonymous/purescript-meowclient

#Auth Source

type Auth = Value

#Value Source

data Value

#anonymous Source

#auth Source

auth :: Value -> Maybe Value

Extracts authentication information.

auth [session]

Example

do
   maybeInfo <- auth anonymous
   case maybeInfo of
       Just info -> -- ...
       Nothing -> -- ...

#logIn Source

logIn :: String -> String -> Aff (Either Error Value)

Logs in with username and password.

logIn [username] [password]

Example

do
   result <- logIn "username" "password"
   case result of
       Left err -> -- ...
       Right session -> -- ...

#logOut Source

logOut :: Value -> Aff (Either Error Unit)

Performs a log-out API call.

logOut [session]

Note

Session that's passed into this function, will not change. If it was logged in, it will stay logged in even after it's passed into this function.

Example

do
   result <- logOut session
   case result of
       Left error -> -- ...
       Right _ -> -- ...

#messages Source

messages :: Int -> Int -> Value -> Aff (Either Value (Array Value))

Gets logged in user's messages.

messages [offset] [limit] [session]

Example

do
   result <- messages 0 20 session
   case result of
       Left error -> -- ...
       Right messages -> -- ...

#searchProjects Source

searchProjects :: Value -> Int -> Int -> String -> Value -> Aff (Either JsonOrJsError (Array Item))

Searches projects.

searchProjects [mode] [offset] [limit] [query string] [session]

Example

import MeowClient.SearchMode as SearchMode
do
   result <- searchProjects SearchMode.Popular 0 20 "cat" session
   case result of
       Left error -> -- ...
       Right projects -> -- ...

#setSignature Source

setSignature :: String -> Value -> Aff (Either JsonOrJsError Unit)

Sets logged in user's forums signature.

setSignature [content] [session]

Example

do
   result <- setSignature "My new signature!" session
   case result of
       Left error -> -- ...
       Right _ -> -- ...

#uploadToAssets Source

uploadToAssets :: Buffer -> String -> Value -> Aff (Either Value String)

Uploads a file to https://assets.scratch.mit.edu/.

This can be used for adding images to be used in a forum post or signature.

uploadToAssets [buffer] [file extension] [session]

Example

do
   result <- uploadToAssets buffer "txt" session
   case result of
       Left error -> -- ...
       Right assetUrl -> -- ...