Repository: google/go-github
File: github/dependabot_secrets.go (Go)

Code before:
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-an-organization-secret
func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *DependabotEncryptedSecret) (*Response, error) {
	repoIDs := make([]string, len(eSecret.SelectedRepositoryIDs))
	for i, secret := range eSecret.SelectedRepositoryIDs {
		repoIDs[i] = strconv.Itoa(int(secret))
	}
	params := struct {
		*DependabotEncryptedSecret
		SelectedRepositoryIDs []string `json:"selected_repository_ids,omitempty"`
	}{
		DependabotEncryptedSecret: eSecret,
		SelectedRepositoryIDs:     repoIDs,
	}

	putSecret := func(ctx context.Context, url string, eSecret interface{}) (*Response, error) {
		req, err := s.client.NewRequest("PUT", url, eSecret)
		if err != nil {
			return nil, err
		}

		return s.client.Do(ctx, req, nil)
	}

	url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, eSecret.Name)
	return putSecret(ctx, url, params)
}

func (s *DependabotService) deleteSecret(ctx context.Context, url string) (*Response, error) {
	req, err := s.client.NewRequest("DELETE", url, nil)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
}

// DeleteRepoSecret deletes a Dependabot secret in a repository using the secret name.
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-a-repository-secret
func (s *DependabotService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) {
	url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name)
	return s.deleteSecret(ctx, url)
}

// DeleteOrgSecret deletes a Dependabot secret in an organization using the secret name.
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-an-organization-secret
func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
	url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name)
	return s.deleteSecret(ctx, url)

Review comment (suggestion):
```suggestion
	req, err := s.client.NewRequest("PUT", url, params)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
```

Code after:
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-an-organization-secret
func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *DependabotEncryptedSecret) (*Response, error) {
	repoIDs := make([]string, len(eSecret.SelectedRepositoryIDs))
	for i, secret := range eSecret.SelectedRepositoryIDs {
		repoIDs[i] = fmt.Sprintf("%v", secret)
	}
	params := struct {
		*DependabotEncryptedSecret
		SelectedRepositoryIDs []string `json:"selected_repository_ids,omitempty"`
	}{
		DependabotEncryptedSecret: eSecret,
		SelectedRepositoryIDs:     repoIDs,
	}

	url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, eSecret.Name)
	req, err := s.client.NewRequest("PUT", url, params)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
}

func (s *DependabotService) deleteSecret(ctx context.Context, url string) (*Response, error) {
	req, err := s.client.NewRequest("DELETE", url, nil)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
}

// DeleteRepoSecret deletes a Dependabot secret in a repository using the secret name.
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-a-repository-secret
func (s *DependabotService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) {
	url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name)
	return s.deleteSecret(ctx, url)
}

// DeleteOrgSecret deletes a Dependabot secret in an organization using the secret name.
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-an-organization-secret
func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
	url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name)
	return s.deleteSecret(ctx, url)
}

// ListSelectedReposForOrgSecret lists all repositories that have access to a Dependabot secret.
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-selected-repositories-for-an-organization-secret