Skip to content

Commit

Permalink
Fix --rateLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
hashworks committed Jan 17, 2016
1 parent 282a0e0 commit 0c7555f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
9 changes: 5 additions & 4 deletions api/types/user.go
Expand Up @@ -2,7 +2,6 @@ package types

import (
"time"
"strconv"
)

type User struct {
Expand All @@ -16,9 +15,11 @@ type User struct {

type RateLimitStatus struct {
RemainingCalls int `json:"remaining_calls"`
ResetTimeU int `json:"reset_time_u"`
ResetTimeU int64 `json:"reset_time_u"`
}

func (rateLimitStatus *RateLimitStatus) GetResetTime() (time.Time, error) {
return time.Parse(time.RFC1123Z, strconv.Itoa(rateLimitStatus.ResetTimeU))
func (rateLimitStatus *RateLimitStatus) GetResetTime() (time.Time) {
var resetTime time.Time
resetTime = time.Unix(rateLimitStatus.ResetTimeU, 0)
return resetTime
}
1 change: 0 additions & 1 deletion api/user.go
Expand Up @@ -55,7 +55,6 @@ func User_RateLimitStatus() (types.RateLimitStatus, error) {
var bytes []byte
bytes, err = ioutil.ReadAll(response.Body)
if err == nil {
var rateLimitStatus types.RateLimitStatus
bytes = stripeJSON(bytes)
err = json.Unmarshal(bytes, &rateLimitStatus)
}
Expand Down
5 changes: 2 additions & 3 deletions client/user.go
Expand Up @@ -34,8 +34,7 @@ func Authenticate() {

func CheckRateLimit() {
data, err := api.User_RateLimitStatus()
OK(err, "Failed to check rate limit: \n")
resetTime, _ := data.GetResetTime()
OK(err, "Failed to check rate limit:\n")
fmt.Printf("You have %d calls remaining, they will reset in %d seconds.",
data.RemainingCalls, resetTime.Unix() - time.Now().Unix())
data.RemainingCalls, data.GetResetTime().Unix() - time.Now().Unix())
}
2 changes: 1 addition & 1 deletion xREL.go
Expand Up @@ -108,7 +108,7 @@ func main() {
config, _ := configHandler.GetConfig(configFilePath)

if versionFlag {
fmt.Println("xREL Terminal Client v1.0.0")
fmt.Println("xREL Terminal Client v1.0.1")
fmt.Println("https://github.com/hashworks/xRELTerminalClient")
fmt.Println()
fmt.Println("Published under the GNU General Public License v3.0.")
Expand Down

0 comments on commit 0c7555f

Please sign in to comment.