From c5dbf3905390ced5ebbca9e70ecd9bf1965d072f Mon Sep 17 00:00:00 2001 From: chansuke Date: Mon, 17 Apr 2017 04:51:16 +0900 Subject: [PATCH] Add reports API --- README.md | 4 ++-- report.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 report.go diff --git a/README.md b/README.md index b959ce3..dbbed08 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,8 @@ if err != nil { * [x] GET /api/v1/notifications * [x] GET /api/v1/notifications/:id * [x] POST /api/v1/notifications/clear -* [ ] GET /api/v1/reports -* [ ] POST /api/v1/reports +* [x] GET /api/v1/reports +* [x] POST /api/v1/reports * [ ] GET /api/v1/search * [x] GET /api/v1/statuses/:id * [x] GET /api/v1/statuses/:id/context diff --git a/report.go b/report.go new file mode 100644 index 0000000..a86ea95 --- /dev/null +++ b/report.go @@ -0,0 +1,29 @@ +package mastodon + +import "net/http" + +// 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. +func (c *Client) GetReport() (*Report, error) { + var reports Report + err := c.doAPI(http.MethodGet, "/api/v1/reports", nil, &reports) + if err != nil { + return nil, err + } + return reports, nil +} + +// Report reports the report +func (c *Client) Report(id int64) (*Report, error) { + var report Report + err := c.doAPI(http.MethodPost, "/api/v1/reports", nil, &report) + if err != nil { + return nil, err + } + return &relationship, nil +}