packages feed

leankit-api 0.1 → 0.2

raw patch · 17 files changed

+34/−55 lines, 17 filesdep +aesondep +bytestringdep +colour

Dependencies added: aeson, bytestring, colour

Files

Leankit/Api.hs view
@@ -20,13 +20,13 @@ import Leankit.Types.CardComment (CardComment)  -- TODO what can we do with this?-(<=<) :: Monad m => (b->m c) -> (a -> m b) -> (a -> m c)+(<=<) :: Monad m => (b->m c) -> (a -> m b) -> a -> m c (<=<) fbc fab a = fbc =<< fab a -(<==<) :: Monad m => (b->m c) -> (a1 -> a2 -> m b) -> (a1 -> a2 -> m c)+(<==<) :: Monad m => (b->m c) -> (a1 -> a2 -> m b) -> a1 -> a2 -> m c (<==<) fbc fab a1 a2 = fbc =<< fab a1 a2 -(<===<) :: Monad m => (b->m c) -> (a1 -> a2 -> a3 -> m b) -> (a1 -> a2 -> a3 -> m c)+(<===<) :: Monad m => (b->m c) -> (a1 -> a2 -> a3 -> m b) -> a1 -> a2 -> a3 -> m c (<===<) fbc fab a1 a2 a3 = fbc =<< fab a1 a2 a3  ---------@@ -45,7 +45,7 @@   -- getBoard-getBoard :: Credentials -> BoardID -> IO (Board)+getBoard :: Credentials -> BoardID -> IO Board getBoard = _either2fail <==< getBoardEither  getBoardMaybe :: Credentials -> BoardID -> IO (Maybe Board)@@ -56,7 +56,7 @@   -- getCard-getCard :: Credentials -> BoardID -> CardID -> IO (Card)+getCard :: Credentials -> BoardID -> CardID -> IO Card getCard = _either2fail <===< getCardEither  getCardMaybe :: Credentials -> BoardID -> CardID -> IO (Maybe Card)@@ -67,14 +67,14 @@   -- getBoardIdentifiers-getBoardIdentifiers :: Credentials -> BoardID -> IO (BoardIdentifierSet)+getBoardIdentifiers :: Credentials -> BoardID -> IO BoardIdentifierSet getBoardIdentifiers = _either2fail <==< getBoardIdentifiersEither  getBoardIdentifiersMaybe :: Credentials -> BoardID -> IO (Maybe BoardIdentifierSet) getBoardIdentifiersMaybe = _either2maybe <==< getBoardIdentifiersEither  getBoardIdentifiersEither :: Credentials -> BoardID -> IO (Either String BoardIdentifierSet)-getBoardIdentifiersEither cred boardID = _boardApiCallEither cred boardID ("/GetBoardIdentifiers/")+getBoardIdentifiersEither cred boardID = _boardApiCallEither cred boardID "/GetBoardIdentifiers/"   -- getNewerIfExists@@ -93,7 +93,7 @@   -- getBoardHistorySince-getBoardHistorySince :: Credentials -> BoardID -> Int -> IO ([BoardHistoryItem])+getBoardHistorySince :: Credentials -> BoardID -> Int -> IO [BoardHistoryItem] getBoardHistorySince = _either2fail <===< getBoardHistorySinceEither  getBoardHistorySinceMaybe :: Credentials -> BoardID -> Int -> IO (Maybe [BoardHistoryItem])@@ -105,7 +105,7 @@   -- getCardByExternalId-getCardByExternalId :: Credentials -> BoardID -> String -> IO (Card)+getCardByExternalId :: Credentials -> BoardID -> String -> IO Card getCardByExternalId = _either2fail <===< getCardByExternalIdEither  getCardByExternalIdMaybe :: Credentials -> BoardID -> String -> IO (Maybe Card)@@ -116,7 +116,7 @@   -- getBackLog-getBackLog :: Credentials -> BoardID -> IO ([Lane])+getBackLog :: Credentials -> BoardID -> IO [Lane] getBackLog = _either2fail <==< getBackLogEither  getBackLogMaybe :: Credentials -> BoardID -> IO (Maybe [Lane])@@ -127,7 +127,7 @@   -- getArchive-getArchive :: Credentials -> BoardID -> IO ([LaneLayout])+getArchive :: Credentials -> BoardID -> IO [LaneLayout] getArchive = _either2fail <==< getArchiveEither  getArchiveMaybe :: Credentials -> BoardID -> IO (Maybe [LaneLayout])@@ -138,7 +138,7 @@   -- getCardHistory-getCardHistory :: Credentials -> BoardID -> CardID -> IO ([CardHistoryItem])+getCardHistory :: Credentials -> BoardID -> CardID -> IO [CardHistoryItem] getCardHistory = _either2fail <===< getCardHistoryEither  getCardHistoryMaybe :: Credentials -> BoardID -> CardID -> IO (Maybe [CardHistoryItem])@@ -150,7 +150,7 @@   -- getCardComments-getCardComments :: Credentials -> BoardID -> CardID -> IO ([CardComment])+getCardComments :: Credentials -> BoardID -> CardID -> IO [CardComment] getCardComments = _either2fail <===< getCardCommentsEither  getCardCommentsMaybe :: Credentials -> BoardID -> CardID -> IO (Maybe [CardComment])@@ -170,12 +170,12 @@ _either2fail (Right res) = return res  _either2maybe :: FromJSON a => Either String a -> IO (Maybe a)-_either2maybe (Left err) = return Nothing+_either2maybe (Left _) = return Nothing _either2maybe (Right res) = return $ Just res  _boardApiCallEither :: FromJSON a => Credentials -> BoardID -> String -> IO (Either String a) _boardApiCallEither cred (BoardID boardID) urlfrag = -	_apiCallEither ((cred)) ("/Board/" ++ show boardID ++ urlfrag) +	_apiCallEither cred ("/Board/" ++ show boardID ++ urlfrag)  	 _apiCallEither :: FromJSON a => Credentials -> String -> IO (Either String a) _apiCallEither creds url = parseReplyData <$> _loadPath url creds@@ -185,6 +185,6 @@         (_, body) <- curlGetString_ url opts         return body     where-        url = "http://" ++ (_company cred) ++ ".leankitkanban.com/Kanban/Api" ++ lpath+        url = "http://" ++ _company cred ++ ".leankitkanban.com/Kanban/Api" ++ lpath         opts = [CurlUserPwd authstr]         authstr = _username cred ++ ":" ++ _password cred
Leankit/Types.hs view
@@ -25,14 +25,14 @@ parseReply = eitherDecode  parseReplyData :: FromJSON a => ByteString -> Either String a-parseReplyData json = +parseReplyData json_ =  	case reply of 		Left s     -> Left s 		Right repl -> case _replyData repl of 						[]              -> Left  $ errorMsg repl 						(Nothing:[])    -> Left  $ errorMsg repl-						(Just rdata:[]) -> Right $ rdata-						(xs)            -> Left  $ errorMsg repl ++ " (multiple items in result data)"+						(Just rdata:[]) -> Right   rdata+						_               -> Left  $ errorMsg repl ++ " (multiple items in result data)" 	where -		reply = parseReply json+		reply = parseReply json_ 		errorMsg repl = show (_replyCode repl) ++ ": " ++ _replyText repl
Leankit/Types/AssignedUser.hs view
@@ -2,9 +2,6 @@  module Leankit.Types.AssignedUser where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero)-import Data.Aeson import Data.Aeson.TH  import Leankit.Types.Common
Leankit/Types/Board.hs view
@@ -2,8 +2,6 @@  module Leankit.Types.Board where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero) import Data.Aeson.TH  import Leankit.Types.Common
Leankit/Types/BoardHistoryItem.hs view
@@ -2,8 +2,6 @@  module Leankit.Types.BoardHistoryItem where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero) import Data.Aeson.TH  import Leankit.Types.TH
Leankit/Types/BoardIdentifierSet.hs view
@@ -2,8 +2,6 @@  module Leankit.Types.BoardIdentifierSet where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero) import Data.Aeson.TH  import Leankit.Types.TH
Leankit/Types/Card.hs view
@@ -2,13 +2,10 @@  module Leankit.Types.Card where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero)+import Control.Applicative ((<$>))+ import Data.Aeson import Data.Aeson.TH-import Data.Aeson.Types-import Data.Colour-import Data.Colour.SRGB import Data.List.Split  import Leankit.Types.TH@@ -22,7 +19,7 @@ instance FromJSON Tags where         parseJSON Null = return $ Tags []         parseJSON v = toTags <$> parseJSON v where-                        toTags = Tags . (splitOn ",")+                        toTags = Tags . splitOn ","   data Card = Card {
Leankit/Types/CardComment.hs view
@@ -2,8 +2,6 @@  module Leankit.Types.CardComment where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero) import Data.Aeson.TH  import Leankit.Types.TH
Leankit/Types/CardContext.hs view
@@ -2,8 +2,6 @@  module Leankit.Types.CardContext where -import Control.Applicative ((<$>), (<*>))-import Data.Aeson import Data.Aeson.TH  import Leankit.Types.Common
Leankit/Types/CardHistoryItem.hs view
@@ -60,12 +60,13 @@ } deriving (Eq, Show)  instance FromJSON CardFieldChange where-        parseJSON (Object v) = do CardFieldChange+        parseJSON (Object v) = CardFieldChange                                         <$> v .:  "FieldName"                                         <*> v .:  "NewValue"                                         <*> v .:? "OldValue"                                         <*> v .:? "NewDueDate"                                         <*> v .:? "OldDueDate"+        parseJSON _          = mzero   -- ==================@@ -103,3 +104,4 @@                         "CardFieldsChangedEventDTO" -> CardFieldChangedEventDetails                                                         <$> v .:  "Changes"                         _                           -> return UnknownEventDetails -- fallback+        parseJSON _          = mzero
Leankit/Types/Common.hs view
@@ -1,9 +1,8 @@ {-# LANGUAGE OverloadedStrings #-} module Leankit.Types.Common where -import Control.Applicative ((<$>), pure)+import Control.Applicative ((<$>)) import Data.Aeson.Types-import Data.Attoparsec.Number import Data.Colour import Data.Colour.SRGB 
Leankit/Types/Lane.hs view
@@ -2,8 +2,6 @@  module Leankit.Types.Lane where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero) import Data.Aeson.TH  import Leankit.Types.TH
Leankit/Types/LaneLayout.hs view
@@ -2,12 +2,9 @@  module Leankit.Types.LaneLayout where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero) import Data.Aeson.TH  import Leankit.Types.TH-import Leankit.Types.Common import Leankit.Types.Lane (Lane)  
Leankit/Types/LaneShort.hs view
@@ -2,13 +2,10 @@  module Leankit.Types.LaneShort where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero) import Data.Aeson.TH  import Leankit.Types.TH import Leankit.Types.Common-import Leankit.Types.Card (Card)   data LaneShort = LaneShort {
Leankit/Types/TH.hs view
@@ -7,7 +7,8 @@ key2field :: String -> String key2field [] = [] key2field "_wip" = "WIP"-key2field ('_':x:xs) = ((toUpper x) : xs)-key2field fn = undefined -- fail $ "Invalid fieldname" ++ fn+key2field ('_':x:xs) = toUpper x : xs+key2field _ = undefined +parseOptions :: Options parseOptions = defaultOptions{fieldLabelModifier=key2field}
Leankit/Types/User.hs view
@@ -2,8 +2,6 @@  module Leankit.Types.User where -import Control.Applicative ((<$>), (<*>))-import Control.Monad (mzero) import Data.Aeson.TH  import Leankit.Types.TH
leankit-api.cabal view
@@ -1,5 +1,5 @@ Name:              leankit-api-Version:           0.1+Version:           0.2 Synopsis:          LeanKit API Description:       A lightweight API for LeanKit (http:\/\/leankit.com) License:           MIT@@ -16,6 +16,9 @@  Library   Build-Depends:   base >= 4 && < 5,+                   aeson >= 0.6.2.1,+                   bytestring,+                   colour,                    curl,                    split   Exposed-modules: Leankit.Api