-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for fetching requested reviewers (users and teams) for a …
…Pull Request.
- Loading branch information
Showing
4 changed files
with
242 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// Team.swift | ||
// OctoKit | ||
// | ||
// Created by Jeroen Wesbeek on 04/12/2024. | ||
// | ||
|
||
import Foundation | ||
import RequestKit | ||
#if canImport(FoundationNetworking) | ||
import FoundationNetworking | ||
#endif | ||
|
||
// MARK: model | ||
|
||
open class Team: Codable { | ||
open internal(set) var id: Int | ||
open var nodeID: String | ||
open var name: String | ||
open var slug: String | ||
open var description: String? | ||
open var privacy: Privacy? | ||
open var notificationSetting: NotificationSetting? | ||
open var url: String? | ||
open var htmlURL: String? | ||
open var membersURL: String? | ||
open var repositoriesURL: String? | ||
|
||
public init(id: Int = -1, | ||
nodeID: String, | ||
name: String, | ||
slug: String, | ||
description: String, | ||
privacy: Privacy? = nil, | ||
notificationSetting: NotificationSetting? = nil, | ||
url: String? = nil, | ||
htmlURL: String? = nil, | ||
membersURL: String? = nil, | ||
repositoriesURL: String? = nil) { | ||
self.id = id | ||
self.nodeID = nodeID | ||
self.name = name | ||
self.slug = slug | ||
self.description = description | ||
self.privacy = privacy | ||
self.notificationSetting = notificationSetting | ||
self.url = url | ||
self.htmlURL = htmlURL | ||
self.membersURL = membersURL | ||
self.repositoriesURL = repositoriesURL | ||
} | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case id, name, slug, description, privacy, url | ||
case nodeID = "node_id" | ||
case htmlURL = "html_url" | ||
case membersURL = "members_url" | ||
case repositoriesURL = "repositories_url" | ||
} | ||
} | ||
|
||
public extension Team { | ||
/// The level of privacy of a team. | ||
enum Privacy: String, Codable { | ||
/// Only visible to organization owners and members of this team. | ||
case secret | ||
/// Visible to all members of this organization. | ||
case closed | ||
} | ||
} | ||
|
||
public extension Team { | ||
enum Permission: String, Codable { | ||
case pull, push, triage, maintain, admin | ||
} | ||
} | ||
|
||
public extension Team { | ||
enum NotificationSetting: String, Codable { | ||
case enabled = "notifications_enabled" | ||
case disabled = "notifications_disabled" | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Tests/OctoKitTests/Fixtures/pull_request_requested_reviewers.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"users": [ | ||
{ | ||
"login": "octocat", | ||
"id": 1, | ||
"node_id": "MDQ6VXNlcjE=", | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
} | ||
], | ||
"teams": [ | ||
{ | ||
"id": 1, | ||
"node_id": "MDQ6VGVhbTE=", | ||
"url": "https://api.github.com/teams/1", | ||
"html_url": "https://github.com/orgs/github/teams/justice-league", | ||
"name": "Justice League", | ||
"slug": "justice-league", | ||
"description": "A great team.", | ||
"privacy": "closed", | ||
"notification_setting": "notifications_enabled", | ||
"permission": "admin", | ||
"members_url": "https://api.github.com/teams/1/members{/member}", | ||
"repositories_url": "https://api.github.com/teams/1/repos", | ||
"parent": null | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters