Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Add delete activities endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmach committed Jan 22, 2015
1 parent 676d976 commit 3c7fb7c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
20 changes: 20 additions & 0 deletions activities.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
17 changes: 17 additions & 0 deletions activities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 3c7fb7c

Please sign in to comment.