--------------------------------------------------------------------
-- |
-- Module      : FriendFeed.Search
-- Description : Search FriendFeed entries
-- Copyright   : (c) Sigbjorn Finne, 2008
-- License     : BSD3
--
-- Maintainer: Sigbjorn Finne <sof@forkIO.com>
-- Stability : provisional
-- Portability: portable
--
-- Actions for publishing entries, comments, likes etc. to FriendFeed.
-- 
--------------------------------------------------------------------
module FriendFeed.Search where

import FriendFeed.Types
import FriendFeed.Types.Import ()
import FriendFeed.Monad

-- | Executes a search over the entries in FriendFeed.
searchEntries :: String
              -> Maybe UserName
	      -> Maybe ServiceName
	      -> FFm [Entry]
searchEntries query mbUser mbService = 
  ffeedTranslateLs "entries" $
   ffeedCall ["feed","search"]
             [("q"
	      , mbPrep "who" mbUser $
	          mbPrep "service" mbService 
	            query)]
 where
  mbPrep _ Nothing xs = xs
  mbPrep a (Just b) xs = (a++':':b++ ' ':xs)