22 } |
21 } |
23 return reports, nil |
22 return reports, nil |
24 } |
23 } |
25 |
24 |
26 // ReportUser reports the user account |
25 // ReportUser reports the user account |
27 func (mc *Client) ReportUser(accountID int64, statusIDs []int64, comment string) (*Report, error) { |
26 func (mc *Client) ReportUser(accountID ActivityID, statusIDs []ActivityID, comment string) (*Report, error) { |
28 if accountID < 1 || comment == "" || len(statusIDs) < 1 { |
27 if accountID == "" || comment == "" || len(statusIDs) < 1 { |
29 return nil, ErrInvalidParameter |
28 return nil, ErrInvalidParameter |
30 } |
29 } |
31 |
30 |
32 params := make(apiCallParams) |
31 params := make(apiCallParams) |
33 params["account_id"] = strconv.FormatInt(accountID, 10) |
32 params["account_id"] = accountID |
34 params["comment"] = comment |
33 params["comment"] = comment |
35 for i, id := range statusIDs { |
34 for i, id := range statusIDs { |
36 if id < 1 { |
35 if id == "" { |
37 return nil, ErrInvalidID |
36 return nil, ErrInvalidID |
38 } |
37 } |
39 qID := fmt.Sprintf("[%d]status_ids", i) |
38 qID := fmt.Sprintf("[%d]status_ids", i) |
40 params[qID] = strconv.FormatInt(id, 10) |
39 params[qID] = id |
41 } |
40 } |
42 |
41 |
43 var report Report |
42 var report Report |
44 if err := mc.apiCall("v1/reports", rest.Post, params, nil, nil, &report); err != nil { |
43 if err := mc.apiCall("v1/reports", rest.Post, params, nil, nil, &report); err != nil { |
45 return nil, err |
44 return nil, err |