{-# LANGUAGE FlexibleContexts #-}
module Network.WebexTeams.Conduit
(
streamListWithFilter
, streamTeamList
, streamOrganizationList
, streamRoleList
) where
import Conduit (ConduitT, MonadIO, liftIO, yieldMany)
import Control.Monad (unless)
import Network.WebexTeams hiding (streamOrganizationList,
streamRoleList, streamTeamList)
readerToSource :: (MonadIO m) => ListReader i -> ConduitT () i m ()
readerToSource reader = go
where
go = do
xs <- liftIO reader
unless (null xs) $ yieldMany xs *> go
streamListWithFilter
:: (MonadIO m, WebexTeamsFilter filter, WebexTeamsListItem (ToResponse filter))
=> Authorization
-> WebexTeamsRequest
-> filter
-> ConduitT () (ToResponse filter) m ()
streamListWithFilter auth base param = getListWithFilter auth base param >>= readerToSource
streamTeamList :: MonadIO m => Authorization -> WebexTeamsRequest -> ConduitT () Team m ()
streamTeamList auth base = getTeamList auth base >>= readerToSource
streamOrganizationList :: MonadIO m => Authorization -> WebexTeamsRequest -> ConduitT () Organization m ()
streamOrganizationList auth base = getOrganizationList auth base >>= readerToSource
streamRoleList :: MonadIO m => Authorization -> WebexTeamsRequest -> ConduitT () Role m ()
streamRoleList auth base = getRoleList auth base >>= readerToSource