-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy pathrate_limit_status.go
More file actions
30 lines (25 loc) · 853 Bytes
/
Copy pathrate_limit_status.go
File metadata and controls
30 lines (25 loc) · 853 Bytes
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
package anaconda
import (
"net/url"
"strings"
)
type RateLimitStatusResponse struct {
RateLimitContext RateLimitContext `json:"rate_limit_context"`
Resources map[string]map[string]BaseResource `json:"resources"`
}
type RateLimitContext struct {
AccessToken string `json:"access_token"`
}
type BaseResource struct {
Limit int `json:"limit"`
Remaining int `json:"remaining"`
Reset int `json:"reset"`
}
func (a TwitterApi) GetRateLimits(r []string) (rateLimitStatusResponse RateLimitStatusResponse, err error) {
resources := strings.Join(r, ",")
v := url.Values{}
v.Set("resources", resources)
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/application/rate_limit_status.json", v, &rateLimitStatusResponse, _GET, response_ch}
return rateLimitStatusResponse, (<-response_ch).err
}