Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions go/pkg/basecamp/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@
//
// List todos in a todolist:
//
// todos, err := account.Todos().List(ctx, projectID, todolistID, nil)
// todos, err := account.Todos().List(ctx, todolistID, nil)
//
// Create a todo:
//
// todo, err := account.Todos().Create(ctx, projectID, todolistID, &basecamp.CreateTodoRequest{
// todo, err := account.Todos().Create(ctx, todolistID, &basecamp.CreateTodoRequest{
// Content: "Ship the feature",
// DueOn: "2024-12-31",
// })
//
// Complete a todo:
//
// err := account.Todos().Complete(ctx, projectID, todoID)
// err := account.Todos().Complete(ctx, todoID)
//
// # Searching
//
Expand Down Expand Up @@ -176,6 +176,6 @@
// acme := client.ForAccount("12345")
// initech := client.ForAccount("67890")
//
// go func() { acme.Todos().List(ctx, projectID, todolistID, nil) }()
// go func() { acme.Todos().List(ctx, todolistID, nil) }()
// go func() { initech.Projects().List(ctx, nil) }()
package basecamp
22 changes: 22 additions & 0 deletions go/pkg/basecamp/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@ func ExampleTodosService_List() {
}
}

func ExampleTodosService_List_completed() {
cfg := basecamp.DefaultConfig()
token := &basecamp.StaticTokenProvider{Token: os.Getenv("BASECAMP_TOKEN")}
client := basecamp.NewClient(cfg, token)

ctx := context.Background()

todolistID := int64(789012)

// List only completed todos in a todolist.
todosResult, err := client.ForAccount("12345").Todos().List(ctx, todolistID, &basecamp.TodoListOptions{
Completed: true,
})
if err != nil {
log.Fatal(err)
}

for _, t := range todosResult.Todos {
fmt.Printf("[x] %s\n", t.Content)
}
}

func ExampleTodosService_Create() {
cfg := basecamp.DefaultConfig()
token := &basecamp.StaticTokenProvider{Token: os.Getenv("BASECAMP_TOKEN")}
Expand Down
Loading