go-mastodon/report.go

33 lines
721 B
Go
Raw Normal View History

2017-04-16 21:51:16 +02:00
package mastodon
2017-04-17 05:36:27 +02:00
import (
"context"
"net/http"
)
2017-04-16 21:51:16 +02:00
// Report hold information for mastodon report.
type Report struct {
ID int64 `json:"id"`
ActionTaken bool `json:"action_taken"`
}
// GetReport return report of the current user.
2017-04-17 05:36:27 +02:00
func (c *Client) GetReport(ctx context.Context) (*Report, error) {
2017-04-16 21:51:16 +02:00
var reports Report
2017-04-17 05:36:27 +02:00
err := c.doAPI(ctx, http.MethodGet, "/api/v1/reports", nil, &reports)
2017-04-16 21:51:16 +02:00
if err != nil {
return nil, err
}
2017-04-17 05:36:27 +02:00
return &reports, nil
2017-04-16 21:51:16 +02:00
}
// Report reports the report
2017-04-17 05:36:27 +02:00
func (c *Client) Report(ctx context.Context, id int64) (*Report, error) {
2017-04-16 21:51:16 +02:00
var report Report
2017-04-17 05:36:27 +02:00
err := c.doAPI(ctx, http.MethodPost, "/api/v1/reports", nil, &report)
2017-04-16 21:51:16 +02:00
if err != nil {
return nil, err
}
2017-04-17 05:36:27 +02:00
return &report, nil
2017-04-16 21:51:16 +02:00
}