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

Add Missing Changes Field to Member Event Type. #3153

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 24 additions & 4 deletions github/event_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,14 +689,34 @@ type MarketplacePurchaseEvent struct {
Org *Organization `json:"organization,omitempty"`
}

// MemberEvent is triggered when a user is added as a collaborator to a repository.
// MemberChangesPermission represents changes to a repository collaborator's permissions.
type MemberChangesPermission struct {
From *string `json:"from,omitempty"`
To *string `json:"to,omitempty"`
}

// MemberChangesRoleName represents changes to a repository collaborator's role.
type MemberChangesRoleName struct {
From *string `json:"from,omitempty"`
To *string `json:"to,omitempty"`
}

// MemberChanges represents changes to a repository collaborator's role or permission.
type MemberChanges struct {
Permission *MemberChangesPermission `json:"permission,omitempty"`
RoleName *MemberChangesRoleName `json:"role_name,omitempty"`
}

// MemberEvent is triggered when a user's membership as a collaborator to a repository changes.
// The Webhook event name is "member".
//
// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhook-events-and-payloads#member
type MemberEvent struct {
// Action is the action that was performed. Possible value is: "added".
Action *string `json:"action,omitempty"`
Member *User `json:"member,omitempty"`
// Action is the action that was performed. Possible values are:
//"added", "edited", "removed".
Action *string `json:"action,omitempty"`
Member *User `json:"member,omitempty"`
Changes *MemberChanges `json:"changes,omitempty"`

// The following fields are only populated by Webhook events.
Repo *Repository `json:"repository,omitempty"`
Expand Down
20 changes: 20 additions & 0 deletions github/event_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9106,6 +9106,16 @@ func TestMemberEvent_Marshal(t *testing.T) {
EventsURL: String("e"),
AvatarURL: String("a"),
},
Changes: &MemberChanges{
Permission: &MemberChangesPermission{
From: String("f"),
To: String("t"),
},
RoleName: &MemberChangesRoleName{
From: String("f"),
To: String("t"),
},
},
Repo: &Repository{
ID: Int64(1),
URL: String("s"),
Expand Down Expand Up @@ -9226,6 +9236,16 @@ func TestMemberEvent_Marshal(t *testing.T) {
"events_url": "e",
"repos_url": "r"
},
"changes": {
"permission": {
"from": "f",
"to": "t"
},
"role_name": {
"from": "f",
"to": "t"
}
},
"repository": {
"id": 1,
"name": "n",
Expand Down
56 changes: 56 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading