Repository: google/go-github
Pull request #3501 (2025-03-05 15:58:01)

Add created_at field to Reaction
This pull request exposes the `created_at` field for [reactions](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28). 

google-cla[bot]: Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this [failed invocation](https://github.com/google/go-github/pull/3501/checks?check_run_id=38250037275) of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3501?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.21%. Comparing base [(`0877faf`)](https://app.codecov.io/gh/google/go-github/commit/0877faf39ff4da78beac849a234b30d9a1a58a3c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`040af46`)](https://app.codecov.io/gh/google/go-github/commit/040af4645b71d720fd56a963dd5b3f0c98958a60?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master    #3501   +/-   ##
=======================================
  Coverage   91.21%   91.21%           
=======================================
  Files         182      182           
  Lines       15930    15930           
=======================================
  Hits        14531    14531           
  Misses       1225     1225           
  Partials      174      174           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3501?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).


Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 519f6cbb..e2a16527 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -20318,6 +20318,14 @@ func (r *Reaction) GetContent() string {
 	return *r.Content
 }
 
+// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
+func (r *Reaction) GetCreatedAt() Timestamp {
+	if r == nil || r.CreatedAt == nil {
+		return Timestamp{}
+	}
+	return *r.CreatedAt
+}
+
 // GetID returns the ID field if it's non-nil, zero value otherwise.
 func (r *Reaction) GetID() int64 {
 	if r == nil || r.ID == nil {
diff --git a/github/reactions.go b/github/reactions.go
index 9f9f72fa..e9823220 100644
--- a/github/reactions.go
+++ b/github/reactions.go
@@ -26,7 +26,8 @@ type Reaction struct {
 	// Content is the type of reaction.
 	// Possible values are:
 	//     "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes".
-	Content *string `json:"content,omitempty"`
+	Content   *string    `json:"content,omitempty"`
+	CreatedAt *Timestamp `json:"created_at,omitempty"`
 }
 
 // Reactions represents a summary of GitHub reactions.


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 7da18057..66132f57 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -26151,6 +26151,17 @@ func TestReaction_GetContent(tt *testing.T) {
 	r.GetContent()
 }
 
+func TestReaction_GetCreatedAt(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue Timestamp
+	r := &Reaction{CreatedAt: &zeroValue}
+	r.GetCreatedAt()
+	r = &Reaction{}
+	r.GetCreatedAt()
+	r = nil
+	r.GetCreatedAt()
+}
+
 func TestReaction_GetID(tt *testing.T) {
 	tt.Parallel()
 	var zeroValue int64
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index 948a9547..e0944471 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -1513,12 +1513,13 @@ func TestRate_String(t *testing.T) {
 func TestReaction_String(t *testing.T) {
 	t.Parallel()
 	v := Reaction{
-		ID:      Ptr(int64(0)),
-		User:    &User{},
-		NodeID:  Ptr(""),
-		Content: Ptr(""),
+		ID:        Ptr(int64(0)),
+		User:      &User{},
+		NodeID:    Ptr(""),
+		Content:   Ptr(""),
+		CreatedAt: &Timestamp{},
 	}
-	want := `github.Reaction{ID:0, User:github.User{}, NodeID:"", Content:""}`
+	want := `github.Reaction{ID:0, User:github.User{}, NodeID:"", Content:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}`
 	if got := v.String(); got != want {
 		t.Errorf("Reaction.String = %v, want %v", got, want)
 	}