-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell implementation of the Campfire API -- -- Implements the Campfire REST API. Campfire is a business group chat -- system tailored specifically for work groups. Find out more at -- http://www.campfirenow.com. Currently supports the entire API -- except for streaming and file uploads. Stability is listed as -- provisional because there are currently no formal tests in place. @package campfire @version 0.1.1 module Web.Campfire.Monad -- | Authentication environment used in Campfire API calls data CampfireEnv CampfireEnv :: Text -> Text -> CampfireEnv -- | Authentication token. Obtained from the user info page in Campfire cfKey :: CampfireEnv -> Text -- | The subdomain on the Campfire website to authenticate against cfSubDomain :: CampfireEnv -> Text -- | IO wrapper used to chain and compose Campfire API actions newtype CampfireM a CampfireM :: ReaderT CampfireEnv IO a -> CampfireM a unCampfireM :: CampfireM a -> ReaderT CampfireEnv IO a instance Monad CampfireM instance MonadIO CampfireM instance MonadReader CampfireEnv CampfireM module Web.Campfire.Types -- | A chat room on a Campfire site data Room Room :: Id -> Text -> Maybe Text -> Integer -> Maybe Bool -> Maybe Bool -> Maybe Text -> CampfireTime -> CampfireTime -> Maybe [User] -> Room roomId :: Room -> Id roomName :: Room -> Text -- | Room topic if available roomTopic :: Room -> Maybe Text -- | Maximum number of users that may be in this room roomMembershipLimit :: Room -> Integer -- | May not be present depending on the API call used roomFull :: Room -> Maybe Bool -- | May not be present depending on the API call used roomOpenToGuests :: Room -> Maybe Bool -- | Campfire API doesn't really specify what this means roomActiveTokenValue :: Room -> Maybe Text roomUpdatedAt :: Room -> CampfireTime roomCreatedAt :: Room -> CampfireTime roomUsers :: Room -> Maybe [User] -- | Utility type used for extracting a Room from the root JSON object the -- Campfire API returns newtype RoomWithRoot RoomWithRoot :: Room -> RoomWithRoot unRootRoom :: RoomWithRoot -> Room -- | Utility type used for extracting a Room from the list returned by the -- Campfire API newtype Rooms Rooms :: [Room] -> Rooms unRooms :: Rooms -> [Room] -- | Modification to be made to a room. data RoomUpdate RoomUpdate :: Maybe Text -> Maybe Text -> RoomUpdate updateRoomName :: RoomUpdate -> Maybe Text updateRoomTopic :: RoomUpdate -> Maybe Text -- | A single line of dialog in a particular chat data Message Message :: Id -> Maybe Text -> Id -> Maybe Id -> CampfireTime -> MessageType -> Message messageId :: Message -> Id messageBody :: Message -> Maybe Text messageRoomId :: Message -> Id messageUserId :: Message -> Maybe Id messageCreatedAt :: Message -> CampfireTime messageType :: Message -> MessageType -- | Utility type used for extracting a Message from the list returned by -- the Campfire API newtype Messages Messages :: [Message] -> Messages unMessages :: Messages -> [Message] -- | Distinct types of messages which can be found in Campfire data MessageType TextMessage :: MessageType -- | Monospaced text displayed in block form PasteMessage :: MessageType -- | Audio sound effect message SoundMessage :: MessageType AdvertisementMessage :: MessageType AllowGuestsMessage :: MessageType DisallowGuestsMessage :: MessageType IdleMessage :: MessageType -- | Message indicating that a user was kicked out KickMessage :: MessageType LeaveMessage :: MessageType SystemMessage :: MessageType TimestampMessage :: MessageType TopicChangeMessage :: MessageType UnidleMessage :: MessageType UnlockMessage :: MessageType UploadMessage :: MessageType EnterMessage :: MessageType -- | Statements are messages that you can send to CampFire. data Statement TextStatement :: Text -> Statement statementBody :: Statement -> Text PasteStatement :: Text -> Statement statementBody :: Statement -> Text -- | Play an audio message in the room SoundStatement :: Sound -> Statement soundType :: Statement -> Sound -- | Display a tweet from a url on Twitter TweetStatement :: Text -> Statement statementUrl :: Statement -> Text -- | Different pre-set sounds that can be played in a room. data Sound Rimshot :: Sound Crickets :: Sound Trombone :: Sound -- | User which can be found in any number of rooms. data User User :: Id -> Text -> Text -> Bool -> CampfireTime -> UserType -> User userId :: User -> Id userName :: User -> Text userEmailAddress :: User -> Text -- | User has administrative privileges userAdmin :: User -> Bool userCreatedAt :: User -> CampfireTime userType :: User -> UserType -- | Utility type used for extracting a User from the root JSON object the -- Campfire API returns newtype UserWithRoot UserWithRoot :: User -> UserWithRoot unRootUser :: UserWithRoot -> User -- | Different classes of users that can be found in chat. data UserType Member :: UserType Guest :: UserType -- | File upload in a room. data Upload Upload :: Id -> Text -> Id -> Id -> Integer -> Text -> Text -> CampfireTime -> Upload uploadId :: Upload -> Id uploadName :: Upload -> Text uploadRoomId :: Upload -> Id uploadUserId :: Upload -> Id uploadByteSize :: Upload -> Integer uploadContentType :: Upload -> Text uploadFullUrl :: Upload -> Text uploadCreatedAt :: Upload -> CampfireTime -- | Utility type used for extracting a Upload from the list returned by -- the Campfire API newtype Uploads Uploads :: [Upload] -> Uploads unUploads :: Uploads -> [Upload] -- | Utility type used for extracting an Upload from the root JSON object -- the Campfire API returns newtype UploadWithRoot UploadWithRoot :: Upload -> UploadWithRoot unRootUpload :: UploadWithRoot -> Upload type Id = Integer -- | Utility type to normalize the non-standard date format that the -- Campfire API returns newtype CampfireTime CampfireTime :: UTCTime -> CampfireTime fromCampfireTime :: CampfireTime -> UTCTime instance Typeable RoomUpdate instance Typeable MessageType instance Typeable Sound instance Typeable Statement instance Typeable UserType instance Typeable CampfireTime instance Typeable Upload instance Typeable UploadWithRoot instance Typeable Uploads instance Typeable User instance Typeable UserWithRoot instance Typeable Message instance Typeable Messages instance Typeable Room instance Typeable Rooms instance Typeable RoomWithRoot instance Eq RoomUpdate instance Ord RoomUpdate instance Read RoomUpdate instance Show RoomUpdate instance Eq MessageType instance Ord MessageType instance Read MessageType instance Show MessageType instance Eq Sound instance Ord Sound instance Read Sound instance Show Sound instance Eq Statement instance Ord Statement instance Read Statement instance Show Statement instance Eq UserType instance Ord UserType instance Read UserType instance Show UserType instance Eq CampfireTime instance Ord CampfireTime instance Read CampfireTime instance Show CampfireTime instance FormatTime CampfireTime instance Eq Upload instance Ord Upload instance Read Upload instance Show Upload instance Eq UploadWithRoot instance Ord UploadWithRoot instance Read UploadWithRoot instance Show UploadWithRoot instance Eq Uploads instance Ord Uploads instance Read Uploads instance Show Uploads instance Eq User instance Ord User instance Read User instance Show User instance Eq UserWithRoot instance Ord UserWithRoot instance Read UserWithRoot instance Show UserWithRoot instance Eq Message instance Ord Message instance Read Message instance Show Message instance Eq Messages instance Ord Messages instance Read Messages instance Show Messages instance Eq Room instance Ord Room instance Read Room instance Show Room instance Eq Rooms instance Ord Rooms instance Read Rooms instance Show Rooms instance Eq RoomWithRoot instance Ord RoomWithRoot instance Read RoomWithRoot instance Show RoomWithRoot instance FromJSON CampfireTime instance FromJSON UploadWithRoot instance FromJSON Uploads instance FromJSON Upload instance FromJSON UserType instance FromJSON UserWithRoot instance FromJSON User instance ToJSON Sound instance ToJSON Statement instance FromJSON MessageType instance FromJSON Messages instance FromJSON Message instance ToJSON RoomUpdate instance FromJSON Rooms instance FromJSON RoomWithRoot instance FromJSON Room -- | Toplevel module for the Campfire API operating in the CamfireM monad. -- Covers the entire campfire API excluding the streaming and file upload -- APIs. Might include support for these features in the future. -- --
-- {-# LANGUAGE OverloadedStrings #-}
-- import Web.Campfire
-- import Web.Campfire.Monad
-- import Web.Campfire.Types
-- import Control.Monad.Reader
-- import Data.Text (unpack)
--
-- doStuff :: CampfireM ()
-- doStuff = do
-- (room:_) <- getRooms
-- let rid = roomId room
-- joinRoom rid
-- speak rid stmt
-- leaveRoom rid
-- return ()
-- where stmt = TextStatement { statementBody = "ATTENTION: I have nothing important to say" }
--
-- main :: IO ()
-- main = do
-- runReaderT (unCampfireM doStuff) env
-- me <- runReaderT (unCampfireM getMe) env
-- putStrLn "Hello, my name is:"
-- putStrLn . unpack $ userName me
-- where env = CampfireEnv { cfKey = "MYKEY", cfSubDomain = "mysubdomain"}
--
module Web.Campfire
-- | Get a list of rooms visible to the authenticated user.
getRooms :: CampfireM [Room]
-- | Get a specific room by Room ID.
getRoom :: Id -> CampfireM Room
-- | Get a list of rooms in which the authenticated user is present.
getPresence :: CampfireM [Room]
-- | Change the topic of a particular room.
setRoomTopic :: Id -> Text -> CampfireM (Int, ByteString)
-- | Change the name of a particular room.
setRoomName :: Id -> Text -> CampfireM (Int, ByteString)
-- | Causes the authenticated user to join a particular room.
joinRoom :: Id -> CampfireM (Int, ByteString)
-- | Causes the authenticated user to leave a particular room.
leaveRoom :: Id -> CampfireM (Int, ByteString)
-- | Locks a particular room.
lockRoom :: Id -> CampfireM (Int, ByteString)
-- | Unlocks a particular room.
unlockRoom :: Id -> CampfireM (Int, ByteString)
-- | Get information about the currently authenticated user.
getMe :: CampfireM User
-- | Get information about the requested user.
getUser :: Id -> CampfireM User
-- | Say something in a room as the currently authenticated user.
speak :: Id -> Statement -> CampfireM (Int, ByteString)
-- | Put a star next to a message. That message will then show up in that
-- day's highlights.
highlightMessage :: Id -> CampfireM (Int, ByteString)
-- | Remove the star next to a message.
unhighlightMessage :: Id -> CampfireM (Int, ByteString)
-- | Receive a list of recent messages in a particular room.
getRecentMessages :: Id -> Maybe Integer -> Maybe Integer -> CampfireM [Message]
-- | Get a list of up to 5 recent uploads to a given room
getUploads :: Id -> CampfireM [Upload]
-- | Retrieve a particular upload from a room.
getUpload :: Id -> Id -> CampfireM Upload
-- | Search for messages matching a given term.
search :: Text -> CampfireM [Message]
-- | Get a transcript of all messages in a room for the day.
getTodayTranscript :: Id -> CampfireM [Message]
-- | Get a transcript of all messages in a room for a particular day
getTranscript :: Id -> Day -> CampfireM [Message]