hzulip 0.4.0.1 → 0.4.1.0
raw patch · 2 files changed
+23/−6 lines, 2 filesdep +lens-aesonPVP ok
version bump matches the API change (PVP)
Dependencies added: lens-aeson
API changes (from Hackage documentation)
+ HZulip: getSubscriptions :: ZulipClient -> IO [String]
Files
- hzulip.cabal +4/−2
- src/HZulip.hs +19/−4
hzulip.cabal view
@@ -1,5 +1,5 @@ name: hzulip-version: 0.4.0.1+version: 0.4.1.0 synopsis: A haskell wrapper for the Zulip API. description: This a Zulip API wrapper for Haskell. homepage: https://github.com/yamadapc/hzulip@@ -19,9 +19,9 @@ , wreq >=0.2 && <1 , lens >=4.4 && <5 , aeson >=0.7 && <1+ , lens-aeson >=1 && <2 , bytestring >=0.10 && <1 , text >=1.1 &&<1.2- , hspec >=1.11 && <2 hs-source-dirs: src default-language: Haskell2010 @@ -34,7 +34,9 @@ , wreq >=0.2 && <1 , lens >=4.4 && <5 , aeson >=0.7 && <1+ , lens-aeson >=1 && <2 , bytestring >=0.10 && <1 , hspec >=1.11 && <2 , raw-strings-qq >=1.0.2 && <2+ , text >=1.1 &&<1.2 default-language: Haskell2010
src/HZulip.hs view
@@ -9,6 +9,7 @@ , defaultBaseUrl , eventTypes , getEvents+ , getSubscriptions , newZulip , onNewEvent , onNewMessage@@ -19,11 +20,12 @@ ) where -import Control.Concurrent-import Control.Exception-import Control.Lens ((.~), (&), (^.))+import Control.Concurrent (threadDelay)+import Control.Exception (SomeException, handle)+import Control.Lens ((.~), (&), (^.), (^..))+import Data.Aeson.Lens (key, values, _String) import qualified Data.ByteString.Char8 as BS (pack)-import qualified Data.Text as T (pack)+import qualified Data.Text as T (pack, unpack) import Network.Wreq import qualified Network.Wreq.Types as WT (params) @@ -105,6 +107,14 @@ else fail $ responseMsg body -- |+-- Get a list of the streams the client is currently subscribed to.+getSubscriptions :: ZulipClient -> IO [String]+getSubscriptions z = do+ r <- getWith (reqOptions z) (subscriptionsUrl z)+ return $ map T.unpack $ r ^.. responseBody . key "subscriptions"+ . values . key "name" . _String++-- | -- Fetches new set of events from a `Queue`. getEvents :: ZulipClient -> Queue -> Bool -> IO (Queue, [Event]) getEvents z q b = do@@ -171,6 +181,11 @@ -- Gets the endpoint for fetching events for a given `ZulipClient` eventsUrl :: ZulipClient -> String eventsUrl = (++ "/events") . clientBaseUrl++-- |+-- Gets the endpoint for fetching subscriptions for a given `ZulipClient`+subscriptionsUrl :: ZulipClient -> String+subscriptionsUrl = (++ "/users/me/subscriptions") . clientBaseUrl -- | -- Constructs the `Wreq` HTTP request `Options` object for a `ZulipClient`