-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabuse.go
82 lines (67 loc) · 2.56 KB
/
abuse.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
package lwapi
import (
"encoding/json"
"fmt"
)
// List reports
func (a *AbuseApi) Reports(queryParams map[string]interface{}) (*Reports, error) {
query := MakeQuery(queryParams)
bodyResp, err := a.NewRequest(NilPayload, "/reports"+query, "GET")
var r *Reports
json.Unmarshal(bodyResp, &r)
return r, err
}
// Inspect a report
func (a *AbuseApi) Report(reportID string) (*Report, error) {
uri := fmt.Sprintf("/reports/%s", reportID)
bodyResp, err := a.NewRequest(NilPayload, uri, "GET")
var r *Report
json.Unmarshal(bodyResp, &r)
return r, err
}
// Inspect a report messages
func (a *AbuseApi) Messages(reportID string, queryParams map[string]interface{}) (*Messages, error) {
query := MakeQuery(queryParams)
uri := fmt.Sprintf("/reports/%s/messages", reportID)
payload, _ := json.Marshal(query)
bodyResp, err := a.NewRequest(payload, uri, "GET")
var r *Messages
json.Unmarshal(bodyResp, &r)
return r, err
}
// Create new message
func (a *AbuseApi) NewMessage(reportID string, params *Message) ([]string, error) {
payload, _ := json.Marshal(params)
uri := fmt.Sprintf("/reports/%s/messages", reportID)
bodyResp, err := a.NewRequest(payload, uri, "POST")
var r []string
json.Unmarshal(bodyResp, &r)
return r, err
}
// Inspect a report attachments
// The compliance team sometimes add an attachment to a message.
// You can use this endpoint to get the attachment. The content-type of the response depends on the content of the attachment.
// https://api.leaseweb.com/abuse/v1/reports/{reportId}/messageAttachments/{fileId}
func (a *AbuseApi) MessageAttachments(reportID string, fileID string) ([]byte, error) {
uri := fmt.Sprintf("/reports/%s/messageAttachments/%s", reportID, fileID)
bodyResp, err := a.NewRequest(NilPayload, uri, "GET")
return bodyResp, err
}
// Inspect a report attachment
// Use this endpoint to get an attachment which was created with the abuse report.
// The content-type of the response depends on the content of the attachment.
// https://api.leaseweb.com/abuse/v1/reports/{reportId}/reportAttachments/{fileId}
func (a *AbuseApi) ReportAttachments(reportID string, fileID string) ([]byte, error) {
uri := fmt.Sprintf("/reports/%s/reportAttachments/%s", reportID, fileID)
bodyResp, err := a.NewRequest(NilPayload, uri, "GET")
return bodyResp, err
}
// Resolve report
func (a *AbuseApi) Resolve(reportID string, params *Resolutions) (*Error, error) {
payload, _ := json.Marshal(params)
uri := fmt.Sprintf("/reports/%s/resolve", reportID)
bodyResp, err := a.NewRequest(payload, uri, "POST")
var r *Error
json.Unmarshal(bodyResp, &r)
return r, err
}