Skip to content

Commit

Permalink
Add Since and Filter to SearchTweetParams (dghubble#141)
Browse files Browse the repository at this point in the history
* Add `Since` and `Filter` to SearchTweetParams
  • Loading branch information
HugoJBello authored and dghubble committed May 12, 2019
1 parent 0022a70 commit 53f972d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions twitter/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type SearchTweetParams struct {
SinceID int64 `url:"since_id,omitempty"`
MaxID int64 `url:"max_id,omitempty"`
Until string `url:"until,omitempty"`
Since string `url:"since,omitempty"`
Filter string `url:"filter,omitempty"`
IncludeEntities *bool `url:"include_entities,omitempty"`
TweetMode string `url:"tweet_mode,omitempty"`
}
Expand Down
7 changes: 4 additions & 3 deletions twitter/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ func TestSearchService_Tweets(t *testing.T) {

mux.HandleFunc("/1.1/search/tweets.json", func(w http.ResponseWriter, r *http.Request) {
assertMethod(t, "GET", r)
assertQuery(t, map[string]string{"q": "happy birthday", "result_type": "popular", "count": "1"}, r)
assertQuery(t, map[string]string{"q": "happy birthday", "result_type": "popular", "count": "1", "since": "2012-01-01", "filter": "safe"}, r)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `{"statuses":[{"id":781760642139250689}],"search_metadata":{"completed_in":0.043,"max_id":781760642139250689,"max_id_str":"781760642139250689","next_results":"?max_id=781760640104828927&q=happy+birthday&count=1&include_entities=1","query":"happy birthday","refresh_url":"?since_id=781760642139250689&q=happy+birthday&include_entities=1","count":1,"since_id":0,"since_id_str":"0"}}`)
fmt.Fprintf(w, `{"statuses":[{"id":781760642139250689}],"search_metadata":{"completed_in":0.043,"max_id":781760642139250689,"max_id_str":"781760642139250689","next_results":"?max_id=781760640104828927&q=happy+birthday&count=1&include_entities=1","query":"happy birthday","refresh_url":"?since_id=781760642139250689&q=happy+birthday&include_entities=1","count":1,"since_id":0,"since_id_str":"0", "since":"2012-01-01", "filter":"safe"}}`)
})

client := NewClient(httpClient)
search, _, err := client.Search.Tweets(&SearchTweetParams{
Query: "happy birthday",
Count: 1,
ResultType: "popular",
})
Since: "2012-01-01",
Filter: "safe"})
expected := &Search{
Statuses: []Tweet{
Tweet{ID: 781760642139250689},
Expand Down

0 comments on commit 53f972d

Please sign in to comment.