forked from g8rswimmer/go-twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tweet_quote.go
63 lines (58 loc) · 1.69 KB
/
tweet_quote.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package twitter
import (
"net/http"
"strconv"
"strings"
)
// QuoteTweetsLookupOpts are the options for the quote tweets
type QuoteTweetsLookupOpts struct {
MaxResults int
PaginationToken string
Expansions []Expansion
MediaFields []MediaField
PlaceFields []PlaceField
PollFields []PollField
TweetFields []TweetField
UserFields []UserField
}
func (qt QuoteTweetsLookupOpts) addQuery(req *http.Request) {
q := req.URL.Query()
if len(qt.Expansions) > 0 {
q.Add("expansions", strings.Join(expansionStringArray(qt.Expansions), ","))
}
if len(qt.MediaFields) > 0 {
q.Add("media.fields", strings.Join(mediaFieldStringArray(qt.MediaFields), ","))
}
if len(qt.PlaceFields) > 0 {
q.Add("place.fields", strings.Join(placeFieldStringArray(qt.PlaceFields), ","))
}
if len(qt.PollFields) > 0 {
q.Add("poll.fields", strings.Join(pollFieldStringArray(qt.PollFields), ","))
}
if len(qt.TweetFields) > 0 {
q.Add("tweet.fields", strings.Join(tweetFieldStringArray(qt.TweetFields), ","))
}
if len(qt.UserFields) > 0 {
q.Add("user.fields", strings.Join(userFieldStringArray(qt.UserFields), ","))
}
if qt.MaxResults > 0 {
q.Add("max_results", strconv.Itoa(qt.MaxResults))
}
if len(qt.PaginationToken) > 0 {
q.Add("pagination_token", qt.PaginationToken)
}
if len(q) > 0 {
req.URL.RawQuery = q.Encode()
}
}
// QuoteTweetsLookupResponse is the response from the quote tweet
type QuoteTweetsLookupResponse struct {
Raw *TweetRaw
Meta *QuoteTweetsLookupMeta
RateLimit *RateLimit
}
// QuoteTweetsLookupMeta is the meta data from the response
type QuoteTweetsLookupMeta struct {
ResultCount int `json:"result_count"`
NextToken string `json:"next_token"`
}