Skip to content

pagespeed-io/asana-tiny-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Asana Tiny Go

This is a very (!) tiny API wrapper for Asana, specifically to create tasks. It doesn’t do anything else but create tasks. I might add more functionality in the future, but there are no promises.

It is also severely limited in its functionality when creating tasks. The only parameters it supports are:

type TaskRequest struct {
  Workspace   int64             // ID of the workspace the tasks should go in
  Name        string            // task name (title)
  Notes       string            // task description (plain text)
  Followers   []*TaskFollower
  Memberships []*TaskMembership // assign task to project and section in that project
}

Why is it not just called asana-create-task, you ask? Because I can see myself needing and therefore adding more features to it in the future, but it will never be a feature-complete client.

Why is this thing so limited?

I needed a simple way to create tasks programmatically. I looked at orijtech/asana, but due to the request payload for task creation being different than the response payload, that library (unfortunately) doesn’t support setting a project for a task, which was a hard required for my use case.

I googled around a lot and found an answer deep in the Asana developer forums that even confirms that this is a common area of confusion:

[…] you’re getting caught by a very common area of confusion with our API that I’ve got a task to clarify in our documentation “someday hopefully soon”.

So here goes.

Installation

At this point I honestly don’t think anybody should "just install it" and start using it. You can, of course, but I’d prefer it if you read the code, understand it, and then copy the parts you need instead (see LICENSE). It’s really not much.

If not:

go get github.com/pagespeed-io/asana-tiny-go

Import as usual and refer to as asana.

Usage

You’ll need a personal access token from Asana. Then, create a client:

client, err := asana.New("your-token-here")

Then create a TaskRequest and use that to create the task:

tr := TaskRequest{
  Workspace: 98765,
  Name:      "Task created with Asana Tiny Go",
  Notes:     "Put some plain text here",
  Followers: []*TaskFollower{}, // no followers. If not set, the owner of the access token will be the follower
  Memberships: []*TaskMembership{
    &TaskMembership{
      Project: 54321,
      Section: 12345,
    },
  },
}

task, err := c.CreateTask(&tr)

Followers and Memberships are optional.

License

This code is given into the Public Domain using the Unlicense. See the LICENSE.md for details.

About

A very small API wrapper for the Asana API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages