Skip to content

Commit cbc8d26

Browse files
committed
Add support for organisation teams
1 parent 0b794b5 commit cbc8d26

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

Github/Data.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,14 @@ instance FromJSON Hook where
560560
<*> o .: "updated_at"
561561
parseJSON _ = fail "Could not build a Hook"
562562

563+
instance FromJSON Team where
564+
parseJSON (Object o) =
565+
Team
566+
<$> (TeamName <$> o .: "name")
567+
<*> o .: "id"
568+
parseJSON _ =
569+
fail "Could not build a Team"
570+
563571
-- | A slightly more generic version of Aeson's @(.:?)@, using `mzero' instead
564572
-- of `Nothing'.
565573
(.:<) :: (FromJSON a) => Object -> T.Text -> Parser [a]

Github/Data/Definitions.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ newtype User =
520520
user :: String
521521
} deriving (Show, Data, Typeable, Eq, Ord)
522522

523+
data Team =
524+
Team {
525+
teamName :: TeamName
526+
, teamId :: Integer
527+
} deriving (Show, Data, Typeable, Eq, Ord)
528+
523529
newtype TeamName =
524530
TeamName {
525531
team :: String

Github/Organizations/Teams.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- | The organization members API as described on
2+
-- <http://developer.github.com/v3/orgs/teams/>.
3+
module Github.Organizations.Teams (
4+
listTeams'
5+
,listTeamMembers'
6+
,module Github.Data
7+
) where
8+
9+
import Github.Data
10+
import Github.Private
11+
12+
listTeams' :: Maybe GithubAuth -> String -> IO (Either Error [Team])
13+
listTeams' auth organization =
14+
githubGet' auth ["orgs", organization, "teams"]
15+
16+
listTeamMembers' :: Maybe GithubAuth -> Integer -> IO (Either Error [GithubOwner])
17+
listTeamMembers' auth teamId =
18+
githubGet' auth ["teams", show teamId, "members"]

github.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ Library
131131
Github.Issues.Milestones,
132132
Github.Organizations,
133133
Github.Organizations.Members,
134+
Github.Organizations.Teams,
134135
Github.PullRequests,
135136
Github.Repos,
136137
Github.Repos.Branches,

0 commit comments

Comments
 (0)