Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teams improvements #417

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/Organizations/Teams/CreateTeamFor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ main = do
Github.createTeamFor'
(Github.OAuth token)
org
(Github.CreateTeam team (Just desc) (read repos :: [String]) Github.PermissionPull)
(Github.CreateTeam team (Just desc) (read repos :: [String]) Nothing Github.PermissionPull)
_ ->
error "usage: CreateTeamFor <token> <org> <team_name> <description> <[\"repos\"]>"
case result of
Expand Down
2 changes: 1 addition & 1 deletion samples/Teams/EditTeam.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ main = do
(GitHub.OAuth $ fromString token)
GitHub.editTeamR
(GitHub.mkTeamId $ read team_id)
(GitHub.EditTeam (GitHub.mkTeamName $ fromString team_name) (Just $ fromString desc) GitHub.PermissionPull)
(GitHub.EditTeam (GitHub.mkTeamName $ fromString team_name) (Just $ fromString desc) Nothing GitHub.PermissionPull)
_ ->
error "usage: EditTeam <token> <team_id> <team_name> <description>"
case result of
Expand Down
28 changes: 15 additions & 13 deletions src/GitHub/Data/Teams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ data SimpleTeam = SimpleTeam
, simpleTeamName :: !Text -- TODO (0.15.0): unify this and 'simpleTeamSlug' as in 'Team'.
, simpleTeamSlug :: !(Name Team)
, simpleTeamDescription :: !(Maybe Text)
, simpleTeamPrivacy :: !(Maybe Privacy)
, simpleTeamPrivacy :: !Privacy
, simpleTeamPermission :: !Permission
, simpleTeamMembersUrl :: !URL
, simpleTeamRepositoriesUrl :: !URL
Expand All @@ -66,7 +66,7 @@ data Team = Team
, teamName :: !Text
, teamSlug :: !(Name Team)
, teamDescription :: !(Maybe Text)
, teamPrivacy :: !(Maybe Privacy)
, teamPrivacy :: !Privacy
, teamPermission :: !Permission
, teamMembersUrl :: !URL
, teamRepositoriesUrl :: !URL
Expand All @@ -83,8 +83,8 @@ data CreateTeam = CreateTeam
{ createTeamName :: !(Name Team)
, createTeamDescription :: !(Maybe Text)
, createTeamRepoNames :: !(Vector (Name Repo))
-- , createTeamPrivacy :: Privacy
, createTeamPermission :: Permission
, createTeamPrivacy :: !(Maybe Privacy)
robbiemcmichael marked this conversation as resolved.
Show resolved Hide resolved
, createTeamPermission :: !Permission
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)

Expand All @@ -94,7 +94,7 @@ instance Binary CreateTeam
data EditTeam = EditTeam
{ editTeamName :: !(Name Team)
, editTeamDescription :: !(Maybe Text)
-- , editTeamPrivacy :: Privacy
, editTeamPrivacy :: !(Maybe Privacy)
, editTeamPermission :: !Permission
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)
Expand Down Expand Up @@ -144,7 +144,7 @@ instance FromJSON SimpleTeam where
<*> o .: "name"
<*> o .: "slug"
<*> o .:?"description" .!= Nothing
<*> o .:?"privacy" .!= Nothing
<*> o .: "privacy"
<*> o .: "permission"
<*> o .: "members_url"
<*> o .: "repositories_url"
Expand All @@ -156,7 +156,7 @@ instance FromJSON Team where
<*> o .: "name"
<*> o .: "slug"
<*> o .:?"description" .!= Nothing
<*> o .:?"privacy" .!= Nothing
<*> o .: "privacy"
<*> o .: "permission"
<*> o .: "members_url"
<*> o .: "repositories_url"
Expand All @@ -165,19 +165,21 @@ instance FromJSON Team where
<*> o .: "organization"

instance ToJSON CreateTeam where
toJSON (CreateTeam name desc repo_names {-privacy-} permissions) =
toJSON (CreateTeam name desc repo_names privacy permission) =
object [ "name" .= name
, "description" .= desc
, "repo_names" .= repo_names
{-, "privacy" .= privacy-}
, "permissions" .= permissions ]
, "privacy" .= privacy
, "permission" .= permission
]

instance ToJSON EditTeam where
toJSON (EditTeam name desc {-privacy-} permissions) =
toJSON (EditTeam name desc privacy permission) =
object [ "name" .= name
, "description" .= desc
{-, "privacy" .= privacy-}
, "permissions" .= permissions ]
, "privacy" .= privacy
robbiemcmichael marked this conversation as resolved.
Show resolved Hide resolved
, "permission" .= permission
]

instance FromJSON TeamMembership where
parseJSON = withObject "TeamMembership" $ \o -> TeamMembership
Expand Down