-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathalert_contact.go
104 lines (80 loc) · 3 KB
/
alert_contact.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package uptimerobotapi
import (
"net/http"
)
type AlertContactService struct {
apiClient *Client
}
type AlertContactSingleResp struct {
Stat string `json:"stat"`
AlertContact AlertContactSingle `json:"alertcontact"`
}
type AlertContactEditResp struct {
Stat string `json:"stat"`
AlertContact AlertContactSingle `json:"alertcontact"`
}
type AlertContactSingle struct {
Id int `json:"id"`
}
type AlertContactResp struct {
Stat string `json:"stat"`
Limit int `json:"limit"`
Offset int `json:"offset"`
Total int `json:"total"`
AlertContacts []AlertContact `json:"alert_contacts"`
}
type AlertContact struct {
Id string `json:"id"`
FriendlyName string `json:"friendly_name"`
Type int `json:"type"`
Status int `json:"status"`
Value string `json:"value"`
}
// GetAlertContactsParams are parameters for GetAlertContacts.
type GetAlertContactsParams struct {
Offset *int `url:"offset,omitempty"`
Limit *int `url:"limit,omitempty"`
AlertContacts *string `url:"alert_contacts,omitempty"`
}
// NewAlertContactParams are parameters for NewAlertContact.
type NewAlertContactParams struct {
TypeContact string `url:"type"`
Value string `url:"value"`
FriendlyName string `url:"friendly_name"`
}
// EditAlertContactParams are parameters for EditAlertContact.
type EditAlertContactParams struct {
Id int `url:"id"`
Value *string `url:"value,omitempty"`
FriendlyName *string `url:"friendly_name,omitempty"`
}
// DeleteAlertContactWrapper are wrapper for DeleteAlertContact.
type DeleteAlertContactWrapper struct {
Id int `url:"id"`
}
// GetAlertContacts Get https://uptimerobot.com/#getAccountDetailsWrap
// The list of alert contacts
func (ac *AlertContactService) GetAlertContacts(params GetAlertContactsParams) (*AlertContactResp, error) {
obj := &AlertContactResp{}
err := ac.apiClient.request(http.MethodPost, "getAlertContacts", params, &obj)
return obj, err
}
// NewAlertContact Get https://uptimerobot.com/#newAlertContactWrap
func (ac *AlertContactService) NewAlertContact(params NewAlertContactParams) (*AlertContactSingleResp, error) {
obj := &AlertContactSingleResp{}
err := ac.apiClient.request(http.MethodPost, "newAlertContact", params, &obj)
return obj, err
}
// EditAlertContact Get https://uptimerobot.com/#editAlertContactWrap
func (ac *AlertContactService) EditAlertContact(params EditAlertContactParams) (*AlertContactEditResp, error) {
obj := &AlertContactEditResp{}
err := ac.apiClient.request(http.MethodPost, "editAlertContact", params, &obj)
return obj, err
}
// DeleteAlertContact Get https://uptimerobot.com/#deleteAlertContactWrap
func (ac *AlertContactService) DeleteAlertContact(id int) (*AlertContactEditResp, error) {
obj := &AlertContactEditResp{}
params := DeleteAlertContactWrapper{Id: id}
err := ac.apiClient.request(http.MethodPost, "deleteAlertContact", params, &obj)
return obj, err
}