diff --git a/api/shortcuts.go b/api/shortcuts.go index 8fdac25..67b4b94 100644 --- a/api/shortcuts.go +++ b/api/shortcuts.go @@ -164,7 +164,7 @@ func ReadPost(client Client, postID string, opts RequestOptions) (json.RawMessag postID = ResolvePostID(postID) opts.Method = "GET" - opts.Endpoint = fmt.Sprintf("/2/tweets/%s?tweet.fields=created_at,public_metrics,conversation_id,in_reply_to_user_id,referenced_tweets,entities,attachments&expansions=author_id,referenced_tweets.id&user.fields=username,name,verified", postID) + opts.Endpoint = fmt.Sprintf("/2/tweets/%s?tweet.fields=created_at,public_metrics,conversation_id,in_reply_to_user_id,referenced_tweets,entities,attachments,note_tweet,article&expansions=author_id,referenced_tweets.id&user.fields=username,name,verified", postID) opts.Data = "" return client.SendRequest(opts) diff --git a/api/shortcuts_test.go b/api/shortcuts_test.go index 5df9b8d..756d934 100644 --- a/api/shortcuts_test.go +++ b/api/shortcuts_test.go @@ -88,8 +88,14 @@ func setupShortcutServer() *httptest.Server { // GET /2/tweets/:id — read post case strings.HasPrefix(r.URL.Path, "/2/tweets/") && r.Method == "GET": + fields := r.URL.Query().Get("tweet.fields") + if !strings.Contains(fields, "note_tweet") || !strings.Contains(fields, "article") { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(`{"errors":[{"message":"missing long-form tweet fields"}]}`)) + return + } w.WriteHeader(http.StatusOK) - w.Write([]byte(`{"data":{"id":"123","text":"existing post","public_metrics":{"like_count":5}}}`)) + w.Write([]byte(`{"data":{"id":"123","text":"existing post","note_tweet":{"text":"full long-form post"},"public_metrics":{"like_count":5}}}`)) // GET /2/users/me case r.URL.Path == "/2/users/me" && r.Method == "GET": @@ -216,12 +222,16 @@ func TestReadPost(t *testing.T) { var result struct { Data struct { - ID string `json:"id"` - Text string `json:"text"` + ID string `json:"id"` + Text string `json:"text"` + NoteTweet struct { + Text string `json:"text"` + } `json:"note_tweet"` } `json:"data"` } require.NoError(t, json.Unmarshal(resp, &result)) assert.Equal(t, "123", result.Data.ID) + assert.Equal(t, "full long-form post", result.Data.NoteTweet.Text) } // ---- SearchPosts ----