Skip to content

Commit

Permalink
Fix copilot API payload (#3034)
Browse files Browse the repository at this point in the history
  • Loading branch information
zetaab committed Dec 19, 2023
1 parent 9d6658a commit a6f50f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions github/copilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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_users"`
SelectedUsernames []string `json:"selected_usernames"`
}{
SelectedUsers: users,
SelectedUsernames: users,
}

req, err := s.client.NewRequest("POST", u, body)
Expand All @@ -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_users"`
SelectedUsernames []string `json:"selected_usernames"`
}{
SelectedUsers: users,
SelectedUsernames: users,
}

req, err := s.client.NewRequest("DELETE", u, body)
Expand Down
4 changes: 2 additions & 2 deletions github/copilot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
})

Expand Down Expand Up @@ -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}`)
})

Expand Down

0 comments on commit a6f50f1

Please sign in to comment.