From 54c5c2c258fd9628a883a573d1aae9efc7e94659 Mon Sep 17 00:00:00 2001 From: Jesse Haka Date: Tue, 19 Dec 2023 17:21:12 +0200 Subject: [PATCH 1/3] fix copilot api payload --- github/copilot.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 3f3d73b25bc..42483049c75 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -241,7 +241,7 @@ func (s *CopilotService) AddCopilotUsers(ctx context.Context, org string, users u := fmt.Sprintf("orgs/%v/copilot/billing/selected_users", org) body := struct { - SelectedUsers []string `json:"selected_users"` + SelectedUsers []string `json:"selected_usernames"` }{ SelectedUsers: users, } @@ -269,7 +269,7 @@ func (s *CopilotService) RemoveCopilotUsers(ctx context.Context, org string, use u := fmt.Sprintf("orgs/%v/copilot/billing/selected_users", org) body := struct { - SelectedUsers []string `json:"selected_users"` + SelectedUsers []string `json:"selected_usernames"` }{ SelectedUsers: users, } From 7f15f06b79a1e7d10cc6887019988b5fdc964722 Mon Sep 17 00:00:00 2001 From: Jesse Haka Date: Tue, 19 Dec 2023 18:19:38 +0200 Subject: [PATCH 2/3] fix copilot test --- github/copilot_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/copilot_test.go b/github/copilot_test.go index 9df2c9a497d..c65fda0f217 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -680,7 +680,7 @@ func TestCopilotService_AddCopilotUsers(t *testing.T) { mux.HandleFunc("/orgs/o/copilot/billing/selected_users", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - testBody(t, r, `{"selected_users":["user1","user2"]}`+"\n") + testBody(t, r, `{"selected_usernames":["user1","user2"]}`+"\n") fmt.Fprint(w, `{"seats_created": 2}`) }) @@ -718,7 +718,7 @@ func TestCopilotService_RemoveCopilotUsers(t *testing.T) { mux.HandleFunc("/orgs/o/copilot/billing/selected_users", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") - testBody(t, r, `{"selected_users":["user1","user2"]}`+"\n") + testBody(t, r, `{"selected_usernames":["user1","user2"]}`+"\n") fmt.Fprint(w, `{"seats_cancelled": 2}`) }) From af72ec5d43379cc8ee1d154554f77d0c767557e9 Mon Sep 17 00:00:00 2001 From: Jesse Haka Date: Tue, 19 Dec 2023 22:27:09 +0200 Subject: [PATCH 3/3] update field names --- github/copilot.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 42483049c75..51c938c9748 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -241,9 +241,9 @@ func (s *CopilotService) AddCopilotUsers(ctx context.Context, org string, users u := fmt.Sprintf("orgs/%v/copilot/billing/selected_users", org) body := struct { - SelectedUsers []string `json:"selected_usernames"` + SelectedUsernames []string `json:"selected_usernames"` }{ - SelectedUsers: users, + SelectedUsernames: users, } req, err := s.client.NewRequest("POST", u, body) @@ -269,9 +269,9 @@ func (s *CopilotService) RemoveCopilotUsers(ctx context.Context, org string, use u := fmt.Sprintf("orgs/%v/copilot/billing/selected_users", org) body := struct { - SelectedUsers []string `json:"selected_usernames"` + SelectedUsernames []string `json:"selected_usernames"` }{ - SelectedUsers: users, + SelectedUsernames: users, } req, err := s.client.NewRequest("DELETE", u, body)