8
|
1 |
package gondole |
116
|
2 |
|
|
3 |
import ( |
|
4 |
"strconv" |
|
5 |
|
|
6 |
"github.com/sendgrid/rest" |
|
7 |
) |
|
8 |
|
|
9 |
// GetReports returns the current user's reports |
|
10 |
func (g *Client) GetReports() ([]Report, error) { |
|
11 |
var reports []Report |
120
|
12 |
if err := g.apiCall("reports", rest.Get, nil, &reports); err != nil { |
|
13 |
return nil, err |
116
|
14 |
} |
|
15 |
return reports, nil |
|
16 |
} |
|
17 |
|
|
18 |
// ReportUser reports the user account |
|
19 |
// NOTE: Currently only the first statusID is sent. |
|
20 |
func (g *Client) ReportUser(accountID int, statusIDs []int, comment string) (*Report, error) { |
|
21 |
if accountID < 1 || comment == "" || len(statusIDs) < 1 { |
|
22 |
return nil, ErrInvalidParameter |
|
23 |
} |
|
24 |
|
120
|
25 |
params := make(apiCallParams) |
|
26 |
params["account_id"] = strconv.Itoa(accountID) |
116
|
27 |
// XXX Sending only the first one since I'm not sure arrays work |
120
|
28 |
params["status_ids"] = strconv.Itoa(statusIDs[0]) |
|
29 |
params["comment"] = comment |
116
|
30 |
|
|
31 |
var report Report |
120
|
32 |
if err := g.apiCall("reports", rest.Post, params, &report); err != nil { |
|
33 |
return nil, err |
116
|
34 |
} |
|
35 |
return &report, nil |
|
36 |
} |