Skip to content

Commit 1c2938d

Browse files
author
Artem Stoianov
committed
POD-155: Allow remaining credits to be string as well
1 parent ebdf735 commit 1c2938d

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

perfops/dns.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package perfops
1616
import (
1717
"context"
1818
"net/http"
19+
"reflect"
1920
)
2021

2122
type (
@@ -24,15 +25,21 @@ type (
2425
)
2526

2627
// RemainingCredits retrieves the ramining credits from the server.
27-
func (s *DNSService) RemainingCredits(ctx context.Context) (int, error) {
28+
func (s *DNSService) RemainingCredits(ctx context.Context) (interface{}, error) {
2829
u := s.client.BasePath + "/remaining-credits"
2930
req, _ := http.NewRequest("GET", u, nil)
3031
var v *struct {
31-
Val int `json:"remaining_credits"`
32+
Val interface{} `json:"remaining_credits"`
3233
}
3334
err := s.client.do(req, &v)
3435
if err != nil {
3536
return 0, err
3637
}
37-
return v.Val, nil
38+
39+
credits := v.Val
40+
if "float64" == reflect.TypeOf(v.Val).String() {
41+
credits = int(v.Val.(float64))
42+
}
43+
44+
return credits, nil
3845
}

0 commit comments

Comments
 (0)