-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage.go
35 lines (25 loc) · 785 Bytes
/
usage.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
package locationiq
import (
"context"
)
// BalanceURL represents balance general usage url
const BalanceURL = "/v1/search.php"
// BalanceRequest represents balance and general usage request
type BalanceRequest struct{}
// BalanceResponse represents balance and general usage response
type BalanceResponse struct {
Status string `json:"status"`
Balance Balance `json:"balance"`
}
type Balance struct {
Day int `json:"day"`
Bonus int `json:"bonus"`
}
// Balance general usage
func (c *client) Balance(ctx context.Context, req BalanceRequest) (BalanceResponse, error) {
url := c.baseURLs[BackendService] + BalanceURL + "?key=" + c.Key
var res BalanceResponse
header := map[string]string{}
_, err := c.request(ctx, "GET", url, header, &req, &res)
return res, err
}