diff --git a/activities.go b/activities.go index f23bdcd..59e2f95 100644 --- a/activities.go +++ b/activities.go @@ -166,6 +166,26 @@ func (c *ActivitiesGetCall) Do() (*ActivityDetailed, error) { /*********************************************************/ +type ActivitiesDeleteCall struct { + service *ActivitiesService + id int64 + ops map[string]interface{} +} + +func (s *ActivitiesService) Delete(activityId int64) *ActivitiesDeleteCall { + return &ActivitiesDeleteCall{ + service: s, + id: activityId, + } +} + +func (c *ActivitiesDeleteCall) Do() error { + _, err := c.service.client.run("DELETE", fmt.Sprintf("/activities/%d", c.id), nil) + return err +} + +/*********************************************************/ + type ActivitiesPostCall struct { service *ActivitiesService ops map[string]interface{} diff --git a/activities_test.go b/activities_test.go index e2cfb3f..be6835f 100644 --- a/activities_test.go +++ b/activities_test.go @@ -252,6 +252,23 @@ func TestActivitiesGet(t *testing.T) { } } +func TestActivitiesDelete(t *testing.T) { + // from here on out just check the request parameters + s := NewActivitiesService(newStoreRequestClient()) + + // path + s.Delete(123).Do() + + transport := s.client.httpClient.Transport.(*storeRequestTransport) + if transport.request.URL.Path != "/api/v3/activities/123" { + t.Errorf("request path incorrect, got %v", transport.request.URL.Path) + } + + if transport.request.Method != "DELETE" { + t.Errorf("request method incorrect, got %v", transport.request.Method) + } +} + func TestActivitiesCreate(t *testing.T) { client := newCassetteClient(testToken, "activity_post") activity, err := NewActivitiesService(client).Create("name", ActivityTypes.Ride, time.Now(), 100).Do()