| 1 |
package putio |
| 2 |
|
| 3 |
import "context" |
| 4 |
|
| 5 |
|
| 6 |
type EventsService struct { |
| 7 |
client *Client |
| 8 |
} |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
func (e *EventsService) List(ctx context.Context) ([]Event, error) { |
| 14 |
req, err := e.client.NewRequest(ctx, "GET", "/v2/events/list", nil) |
| 15 |
if err != nil { |
| 16 |
return nil, err |
| 17 |
} |
| 18 |
|
| 19 |
var r struct { |
| 20 |
Events []Event |
| 21 |
} |
| 22 |
_, err = e.client.Do(req, &r) |
| 23 |
if err != nil { |
| 24 |
return nil, err |
| 25 |
} |
| 26 |
return r.Events, nil |
| 27 |
|
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
func (e *EventsService) Delete(ctx context.Context) error { |
| 32 |
req, err := e.client.NewRequest(ctx, "POST", "/v2/events/delete", nil) |
| 33 |
if err != nil { |
| 34 |
return err |
| 35 |
} |
| 36 |
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| 37 |
|
| 38 |
_, err = e.client.Do(req, &struct{}{}) |
| 39 |
if err != nil { |
| 40 |
return err |
| 41 |
} |
| 42 |
|
| 43 |
return nil |
| 44 |
} |