Code Monkey home page Code Monkey logo

clickup-client-go's Introduction

clickup-client-go

Go Reference

Get Started

Create a Clickup Client by providing a ClientOpts. The default Doer is an http.Client with a 20 second timeout.

Use the APITokenAuthenticator for a simple authentication mechanism and provide your Clickup user's API Key. If you want to implement Authenticator in different ways (eg. OAuth flow) then provide your implementation to the client.

	client := clickup.NewClient(&clickup.ClientOpts{
		Doer: nil,
		Authenticator: &clickup.APITokenAuthenticator{
			APIToken: os.Args[1],
		},
	})

Tasks

	queryOpts := &clickup.TaskQueryOptions{
		IncludeArchived: false,
	}

	for {
		tasks, _ := client.TasksForList("list-id", queryOpts)

		for _, task := range tasks.Tasks {
			fmt.Println("Task: ", task.CustomID, task.Name)
		}
		if len(tasks.Tasks) < clickup.MaxPageSize {
			return
		} else {
			queryOpts.Page++
		}
	}
}

Create and get webhooks

Create a webhook and listen for Task Updated Events for a particular list.

	newWebhook, _ := client.CreateWebhook(workspaceID, &clickup.CreateWebhookRequest{
		Endpoint: "https://your-webhook.site/myhook",
		Events: []clickup.WebhookEvent{
			clickup.EventTaskUpdated,
		},
		ListID: "list-id",
	})

	fmt.Println("New Webhook ID: ", newWebhook.ID)
	fmt.Println("Health: ", newWebhook.Webhook.Health.FailCount, newWebhook.Webhook.Health.Status)

Get webhooks for a workspace.

	webhooks, _ := client.WebhooksFor(workspaceID)

	fmt.Println("Existing webhooks:")
	for _, v := range webhooks.Webhooks {
		fmt.Println("ID:", v.ID)
		fmt.Println("Status:", v.Health.Status, v.Health.FailCount)

		fmt.Println("deleting webhook for:", v.ID)
		client.DeleteWebhook(v.ID)
	}

Other webhook events...

	EventAll                     
	EventTaskCreated             
	EventTaskUpdated             
	EventTaskDeleted             
	EventTaskPriorityUpdated     
	EventTaskStatusUpdated       
	EventTaskAssigneeUpdated     
	EventTaskDueDateUpdated      
	EventTaskTagUpdated          
	EventTaskMoved               
	EventTaskCommentPosted       
	EventTaskCommentUpdated      
	EventTaskTimeEstimateUpdated 
	EventTaskTimeTrackedUpdated  
	EventListCreated             
	EventListUpdated             
	EventListDeleted             
	EventFolderCreated           
	EventFolderUpdated           
	EventFolderDeleted           
	EventSpaceCreated            
	EventSpaceUpdated            
	EventSpaceDeleted            
	EventGoalCreated             
	EventGoalUpdated             
	EventGoalDeleted             
	EventKeyResultCreated        
	EventKeyResultUpdated        
	EventKeyResultDeleted        

Comments

Comments are not very intuitive via Clickup's API (IMO). This library provides some helpers to construct a comment request (builder). The comment request mode is completely exported, so feel free to construct it yourself if desired.

	comment := clickup.NewCreateTaskCommentRequest(
		os.Getenv("CLICKUP_TASK_ID"),
		true,
		os.Getenv("CLICKUP_WORKSPACE_ID"),
	)
	comment.BulletedListItem("Bullet Item 4asdf", nil)
	comment.BulletedListItem("Bullet Item 5", nil)
	comment.BulletedListItem("Bullet Item 6", &clickup.Attributes{Italic: true})
	comment.NumberedListItem("Numbered Item 1", nil)
	comment.ChecklistItem("Checklist item 1", false, nil)
	comment.ChecklistItem("Checklist item 2", true, nil)

	res, err := client.CreateTaskComment(context.Background(), *comment)
	if err != nil {
		panic(err)
	}

Pagination

The clickup API is a little inconsistent with pagination. This client library will aim to document behavior as well as it can. For example, use the Page attribute in TaskQueryOptions and call TasksForList() again.

Unfortunately, the GET Tasks operation returns up to 100 tasks and the caller must know that the last page was reached only if there are less than 100.

Client Library Progress

โœ…๏ธ Implemented or partially implemented

๐Ÿ™…๏ธ Not implemented


โœ…๏ธ Attachments

โœ…๏ธ Authorization (API Key supported "out of box." See Authenticator interface to implement OAuth, etc.)

โœ…๏ธ Checklists

โœ…๏ธ Comments

โœ…๏ธ Dependencies

โœ…๏ธ Folders

โœ…๏ธ Goals

๐Ÿ™…๏ธ Guests

โœ…๏ธ Lists

๐Ÿ™…๏ธ Members

โœ…๏ธ Shared Hierarchy

โœ…๏ธ Spaces

โœ…๏ธ Tags

โœ…๏ธ Tasks

โœ…๏ธ Task Templates

โœ…๏ธ Teams

๐Ÿ™…๏ธ Time Tracking

๐Ÿ™…๏ธ Users

โœ…๏ธ Views

โœ…๏ธ Webhooks

Contributions

Open a PR with your fork or open an issue. Open to help!

clickup-client-go's People

Contributors

guitarbum722 avatar dabbertorres avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.