-
Notifications
You must be signed in to change notification settings - Fork 6
/
notification.go
41 lines (27 loc) · 946 Bytes
/
notification.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
package vscale_api_go
import (
"encoding/json"
"net/http"
)
type NotificationService struct {
client Client
}
type Notification struct {
NotifyBalance int64 `json:"notify_balance,omitempty"`
Status string `json:"status,omitempty"`
}
func (n *NotificationService) BillingSettings() (*Notification, *http.Response, error) {
notification := new(Notification)
res, err := n.client.ExecuteRequest("GET", "billing/notify", []byte{}, notification)
return notification, res, err
}
func (n *NotificationService) BillingSettingsUpdate(notifyBalance int64) (*Notification, *http.Response, error) {
// TODO Doesn't work because API don't use JSON in this case
notification := new(Notification)
body := struct {
NotifyBalance int64 `json:"notify_balance,omitempty"`
}{notifyBalance}
b, _ := json.Marshal(body)
res, err := n.client.ExecuteRequest("PUT", "billing/notify", b, notification)
return notification, res, err
}