-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A matrix client library -- -- Matrix client is a library to interface with -- https://matrix.org. -- -- Use this library to interact with matrix server. -- -- Read the Network.Matrix.Tutorial for a detailed tutorial. @package matrix-client @version 0.1.1.0 -- | This module contains the Identity service API -- https://matrix.org/docs/spec/identity_service/r0.3.0.html module Network.Matrix.Identity -- | The session record, use createSession to create it. data IdentitySession newtype MatrixToken MatrixToken :: Text -> MatrixToken getTokenFromEnv :: Text -> IO MatrixToken -- | createSession creates the session record. createIdentitySession :: Text -> MatrixToken -> IO IdentitySession -- | MatrixIO is a convenient type alias for server response type MatrixIO a = IO (Either MatrixError a) data MatrixError MatrixError :: Text -> Text -> Maybe Int -> MatrixError [meErrcode] :: MatrixError -> Text [meError] :: MatrixError -> Text [meRetryAfterMS] :: MatrixError -> Maybe Int retry :: MatrixIO a -> MatrixIO a newtype UserID UserID :: Text -> UserID -- | getIdentityTokenOwner gets information about the owner of a -- given access token. getIdentityTokenOwner :: IdentitySession -> MatrixIO UserID data HashDetails HashDetails :: NonEmpty Text -> Text -> HashDetails [hdAlgorithms] :: HashDetails -> NonEmpty Text [hdPepper] :: HashDetails -> Text hashDetails :: IdentitySession -> MatrixIO HashDetails data Identity Email :: Text -> Identity Msisdn :: Text -> Identity -- | Use identityLookup to lookup a single identity, otherwise uses -- the full identitiesLookup. identityLookup :: IdentitySession -> HashDetails -> Identity -> MatrixIO (Maybe UserID) data HashedAddress data IdentityLookupRequest -- | A newtype wrapper to decoded nested list -- --
-- >>> decode "{\"mappings\": {\"hash\": \"user\"}}" :: Maybe IdentityLookupResponse
-- Just (IdentityLookupResponse [(HashedAddress "hash",UserID "user")])
--
data IdentityLookupResponse
identitiesLookup :: IdentitySession -> IdentityLookupRequest -> MatrixIO IdentityLookupResponse
mkIdentityLookupRequest :: HashDetails -> [HashedAddress] -> IdentityLookupRequest
toHashedAddress :: HashDetails -> Identity -> HashedAddress
lookupIdentity :: HashedAddress -> IdentityLookupResponse -> Maybe UserID
instance GHC.Classes.Eq Network.Matrix.Identity.HashDetails
instance GHC.Show.Show Network.Matrix.Identity.HashDetails
instance GHC.Classes.Eq Network.Matrix.Identity.HashedAddress
instance GHC.Show.Show Network.Matrix.Identity.HashedAddress
instance GHC.Classes.Eq Network.Matrix.Identity.IdentityLookupRequest
instance GHC.Show.Show Network.Matrix.Identity.IdentityLookupRequest
instance GHC.Show.Show Network.Matrix.Identity.IdentityLookupResponse
instance GHC.Classes.Eq Network.Matrix.Identity.Identity
instance GHC.Show.Show Network.Matrix.Identity.Identity
instance Data.Aeson.Types.FromJSON.FromJSON Network.Matrix.Identity.IdentityLookupResponse
instance Data.Aeson.Types.FromJSON.FromJSON Network.Matrix.Identity.HashDetails
-- | This module contains the client-server API
-- https://matrix.org/docs/spec/client_server/r0.6.1
module Network.Matrix.Client
-- | The session record, use createSession to create it.
data ClientSession
newtype MatrixToken
MatrixToken :: Text -> MatrixToken
getTokenFromEnv :: Text -> IO MatrixToken
-- | createSession creates the session record.
createSession :: Text -> MatrixToken -> IO ClientSession
-- | MatrixIO is a convenient type alias for server response
type MatrixIO a = IO (Either MatrixError a)
data MatrixError
MatrixError :: Text -> Text -> Maybe Int -> MatrixError
[meErrcode] :: MatrixError -> Text
[meError] :: MatrixError -> Text
[meRetryAfterMS] :: MatrixError -> Maybe Int
retry :: MatrixIO a -> MatrixIO a
newtype UserID
UserID :: Text -> UserID
-- | getTokenOwner gets information about the owner of a given
-- access token.
getTokenOwner :: ClientSession -> MatrixIO UserID
newtype TxnID
TxnID :: Text -> TxnID
sendMessage :: ClientSession -> RoomID -> Event -> TxnID -> MatrixIO EventID
data MessageText
MessageText :: Text -> Maybe Text -> Maybe Text -> MessageText
[mtBody] :: MessageText -> Text
[mtFormat] :: MessageText -> Maybe Text
[mtFormattedBody] :: MessageText -> Maybe Text
data RoomMessage
RoomMessageText :: MessageText -> RoomMessage
RoomMessageEmote :: MessageText -> RoomMessage
RoomMessageNotice :: MessageText -> RoomMessage
newtype Event
EventRoomMessage :: RoomMessage -> Event
newtype EventID
EventID :: Text -> EventID
eventType :: Event -> Text
newtype RoomID
RoomID :: Text -> RoomID
getJoinedRooms :: ClientSession -> MatrixIO [RoomID]
-- | Note that this API takes either a room ID or alias, unlike
-- joinRoomById
joinRoom :: ClientSession -> Text -> MatrixIO RoomID
joinRoomById :: ClientSession -> RoomID -> MatrixIO RoomID
leaveRoomById :: ClientSession -> RoomID -> MatrixIO ()
instance GHC.Classes.Eq Network.Matrix.Client.TxnID
instance GHC.Show.Show Network.Matrix.Client.TxnID
instance Data.Hashable.Class.Hashable Network.Matrix.Client.RoomID
instance GHC.Classes.Eq Network.Matrix.Client.RoomID
instance GHC.Show.Show Network.Matrix.Client.RoomID
instance GHC.Show.Show Network.Matrix.Client.JoinedRooms
instance Data.Aeson.Types.FromJSON.FromJSON Network.Matrix.Client.JoinedRooms
instance Data.Aeson.Types.FromJSON.FromJSON Network.Matrix.Client.RoomID
-- | The matrix-client library provides a simple interface for
-- interacting with Matrix servers.
--
-- This tutorial introduces how to use the matrix-client
-- library.
--
-- You will need a token to create a session, if you already have an
-- account, you can get it with the element client by visiting
-- the account Settings page, Help & About panel,
-- then click Access Token.
--
-- Alternatively, you can setup a test service by running these commands
-- in a terminal:
--
--
-- git clone https://github.com/matrix-org/dendrite
-- cd dendrite; ./build.sh; ./bin/generate-keys --private-key matrix_key.pem; cp dendrite-config.yaml dendrite.yaml
-- ./bin/dendrite-monolith-server --config dendrite.yaml
-- curl -XPOST http://localhost:8008/_matrix/client/r0/register -d'{"username": "tristanC", "password": "supersecret", "auth": {"type": "mlogin.dummy"}}
--
--
-- To avoid manipulating the token directly, put it in your environment:
--
-- -- export MATRIX_TOKEN="THE_ACCESS_TOKEN" --module Network.Matrix.Tutorial