Skip to content

Commit

Permalink
projects: Add missing fields to struct (#969)
Browse files Browse the repository at this point in the history
Helps #884.
  • Loading branch information
radeksimko authored and gmlewis committed Aug 13, 2018
1 parent dae5b87 commit d8bee75
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 15 deletions.
80 changes: 80 additions & 0 deletions github/github-accessors.go

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

2 changes: 1 addition & 1 deletion github/orgs_projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestOrganizationsService_CreateProject(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

input := &ProjectOptions{Name: "Project Name", Body: "Project body."}
input := &ProjectOptions{Name: String("Project Name"), Body: String("Project body.")}

mux.HandleFunc("/orgs/o/projects", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
Expand Down
38 changes: 26 additions & 12 deletions github/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ type ProjectsService service

// Project represents a GitHub Project.
type Project struct {
ID *int64 `json:"id,omitempty"`
URL *string `json:"url,omitempty"`
OwnerURL *string `json:"owner_url,omitempty"`
Name *string `json:"name,omitempty"`
Body *string `json:"body,omitempty"`
Number *int `json:"number,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
NodeID *string `json:"node_id,omitempty"`
ID *int64 `json:"id,omitempty"`
URL *string `json:"url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
ColumnsURL *string `json:"columns_url,omitempty"`
OwnerURL *string `json:"owner_url,omitempty"`
Name *string `json:"name,omitempty"`
Body *string `json:"body,omitempty"`
Number *int `json:"number,omitempty"`
State *string `json:"state,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
NodeID *string `json:"node_id,omitempty"`

// The User object that generated the project.
Creator *User `json:"creator,omitempty"`
Expand Down Expand Up @@ -63,15 +66,24 @@ func (s *ProjectsService) GetProject(ctx context.Context, id int64) (*Project, *
// ProjectsService.UpdateProject methods.
type ProjectOptions struct {
// The name of the project. (Required for creation; optional for update.)
Name string `json:"name,omitempty"`
Name *string `json:"name,omitempty"`
// The body of the project. (Optional.)
Body string `json:"body,omitempty"`
Body *string `json:"body,omitempty"`

// The following field(s) are only applicable for update.
// They should be left with zero values for creation.

// State of the project. Either "open" or "closed". (Optional.)
State string `json:"state,omitempty"`
State *string `json:"state,omitempty"`
// The permission level that all members of the project's organization
// will have on this project.
// Setting the organization permission is only available
// for organization projects. (Optional.)
OrganizationPermission *string `json:"organization_permission,omitempty"`
// Sets visibility of the project within the organization.
// Setting visibility is only available
// for organization projects.(Optional.)
Public *bool `json:"public,omitempty"`
}

// UpdateProject updates a repository project.
Expand Down Expand Up @@ -118,7 +130,9 @@ func (s *ProjectsService) DeleteProject(ctx context.Context, id int64) (*Respons
type ProjectColumn struct {
ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
URL *string `json:"url,omitempty"`
ProjectURL *string `json:"project_url,omitempty"`
CardsURL *string `json:"cards_url,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Expand Down
8 changes: 7 additions & 1 deletion github/projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ func TestProjectsService_UpdateProject(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

input := &ProjectOptions{Name: "Project Name", Body: "Project body.", State: "open"}
input := &ProjectOptions{
Name: String("Project Name"),
Body: String("Project body."),
State: String("open"),
OrganizationPermission: String("read"),
Public: Bool(true),
}

mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PATCH")
Expand Down
2 changes: 1 addition & 1 deletion github/repos_projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestRepositoriesService_CreateProject(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

input := &ProjectOptions{Name: "Project Name", Body: "Project body."}
input := &ProjectOptions{Name: String("Project Name"), Body: String("Project body.")}

mux.HandleFunc("/repos/o/r/projects", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
Expand Down

0 comments on commit d8bee75

Please sign in to comment.