From 6ec7491932b58825a0d42e5c7f31517de16339a4 Mon Sep 17 00:00:00 2001 From: Brandon Hansen Date: Wed, 12 Aug 2026 12:13:07 -0700 Subject: [PATCH 1/2] Support adding colors to tags in the Teamwork API SDK. This includes updating the Tag struct to include a Color field, modifying the TagCreateRequest struct to accept an optional Color parameter, and updating the NewTagCreateRequest function to handle the new Color parameter. Additionally, test cases and examples have been updated to reflect these changes. --- projects/tag.go | 17 +++++++++++++++-- projects/tag_example_test.go | 2 +- projects/tag_test.go | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/projects/tag.go b/projects/tag.go index e650578..a9806da 100644 --- a/projects/tag.go +++ b/projects/tag.go @@ -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"` } @@ -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, } } @@ -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"` diff --git a/projects/tag_example_test.go b/projects/tag_example_test.go index 09184f1..ad475af 100644 --- a/projects/tag_example_test.go +++ b/projects/tag_example_test.go @@ -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 { diff --git a/projects/tag_test.go b/projects/tag_test.go index f941f01..997f605 100644 --- a/projects/tag_test.go +++ b/projects/tag_test.go @@ -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{ From 5e7bc0d00e67cc7c0f7df896eb68109b4a3281c3 Mon Sep 17 00:00:00 2001 From: Brandon Hansen Date: Wed, 12 Aug 2026 12:17:17 -0700 Subject: [PATCH 2/2] fix gen --- projects/sparse_fields_gen.go | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/sparse_fields_gen.go b/projects/sparse_fields_gen.go index 97e7a3b..90640dc 100644 --- a/projects/sparse_fields_gen.go +++ b/projects/sparse_fields_gen.go @@ -389,6 +389,7 @@ type TagField string const ( TagFieldID TagField = "id" TagFieldName TagField = "name" + TagFieldColor TagField = "color" TagFieldProject TagField = "project" )