From 91b8df43095fefcbdbf02ed05b939ffc76d9c3d7 Mon Sep 17 00:00:00 2001 From: Arundas666 Date: Tue, 1 Oct 2024 14:55:41 +0530 Subject: [PATCH] examples folder updated, folder-less-lists added --- example/folderless-lists/main.go | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 example/folderless-lists/main.go diff --git a/example/folderless-lists/main.go b/example/folderless-lists/main.go new file mode 100644 index 0000000..043f6c7 --- /dev/null +++ b/example/folderless-lists/main.go @@ -0,0 +1,37 @@ +// The simple command demonstrates the functionality that +// prompts the user for a Clickup list and lists which are not belonging to any folder inside a space. +// that are related to the specified space. +package main + +import ( + "context" + "fmt" + "os" + + "github.com/raksul/go-clickup/clickup" +) + +func fetchLists(spaceId string) ([]clickup.List, error) { + api_key := os.Getenv("CLICKUP_API_KEY") + client := clickup.NewClient(nil, api_key) + + lists, _, err := client.Lists.GetFolderlessLists(context.Background(), spaceId, false) + return lists, err +} + +func main() { + var spaceId string + fmt.Print("Enter clickup spaceId: ") + fmt.Scanf("%s", &spaceId) + + lists, err := fetchLists(spaceId) + + if err != nil { + fmt.Printf("Error: %v\n", err) + return + } + + for _, list := range lists { + fmt.Println(list.Name) + } +}