Skip to content
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
1 change: 1 addition & 0 deletions projects/sparse_fields_gen.go

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

17 changes: 15 additions & 2 deletions projects/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ type Tag struct {
// Name is the name of the tag.
Name string `json:"name"`

// Color is the color of the tag, represented as a hexadecimal color code.
Color string `json:"color"`

// Project is the project the tag belongs to.
Project *twapi.Relationship `json:"project"`
}
Expand All @@ -75,15 +78,21 @@ type TagCreateRequest struct {
// 50 characters.
Name string `json:"name"`

// Color is the color of the tag, represented as a hexadecimal color code. This
// field is optional. If not provided, a default color will be assigned.
Color *string `json:"color,omitempty"`

// ProjectID is the unique identifier of the project the tag belongs to. This
// is for project-scoped tags.
ProjectID *int64 `json:"projectId,omitempty"`
}

// NewTagCreateRequest creates a new TagCreateRequest with the provided name.
func NewTagCreateRequest(name string) TagCreateRequest {
func NewTagCreateRequest(name string, color *string, projectID *int64) TagCreateRequest {
return TagCreateRequest{
Name: name,
Name: name,
Color: color,
ProjectID: projectID,
}
}

Expand Down Expand Up @@ -162,6 +171,10 @@ type TagUpdateRequest struct {
// provided.
Name *string `json:"name,omitempty"`

// Color is the color of the tag, represented as a hexadecimal color code. When
// provided, it must be a valid hexadecimal color code.
Color *string `json:"color,omitempty"`

// ProjectID is the unique identifier of the project the tag belongs to. This
// is for project-scoped tags.
ProjectID *int64 `json:"projectId,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion projects/tag_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func ExampleTagCreate() {
ctx := context.Background()
engine := twapi.NewEngine(session.NewBearerToken("your_token", fmt.Sprintf("http://%s", address)))

tagResponse, err := projects.TagCreate(ctx, engine, projects.NewTagCreateRequest("Test Tag"))
tagResponse, err := projects.TagCreate(ctx, engine, projects.NewTagCreateRequest("Test Tag", new("#e8e8e8"), nil))
if err != nil {
fmt.Printf("failed to create tag: %s", err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion projects/tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestTagCreate(t *testing.T) {
input projects.TagCreateRequest
}{{
name: "only required fields",
input: projects.NewTagCreateRequest(fmt.Sprintf("test%d%d", time.Now().UnixNano(), rand.Intn(100))),
input: projects.NewTagCreateRequest(fmt.Sprintf("test%d%d", time.Now().UnixNano(), rand.Intn(100)), nil, nil),
}, {
name: "all fields",
input: projects.TagCreateRequest{
Expand Down