Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Asana 1.1 and allow add use of body for new tasks #256

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mmynsted
Copy link

@mmynsted mmynsted commented Dec 29, 2021

The idea is to be able to read the values that changed, such as id to gid. Also I wanted the ability to easily provide any necessary detail for a new Asana task as defined here. To do this easily the body of the POST is populated.

One can merge a template of task details with other detail to form the data object of the POST body.

Example:

I have a template for inserting the new task into two Asana projects. It is stored in my configConsts.lua.

 asanaTaskParameters = {
       projects = {
          [1] = "1200536698010895",
          [2] = "1200674652387402"
       }
    }

Two things are necessary to make this work. The first is being able to join tables. I could not get the built-in or hs.fnutils table tools to work for me. I added a couple of functions that work. I have not tried to improve them. The second thing is simply designating the content type so the Asana service can decode the body of the POST.

reqHeader = tableMerge(reqHeader, {['Content-Type'] = "application/json; charset=UTF8"})

I did not do much with documentation. . .

Here is an example of how I registered this Asana spoon with Seal. (Almost the same as before.)

                        ,["New Asana task in " .. consts.asanaWorkWorkspaceName] = {
                            fn = function(y) spoon.Asana:createTask(y, consts.asanaWorkWorkspaceName, consts.asanaTaskParameters) end,
                              keyword = "astogo"
                           }

I am not sure if it is documented but I am storing the API key in the macOS keychain and retrieve it in the config like this.

 asanaApiKey = hs.execute("security find-generic-password -w -a ${USER} -s asana-api-key | tr -d '\n'")

The body of the POST can be used to provide all the necessary data for
an Asana task. In order for the server to read the body the content
ecooding must be declared and provided as a header. This allows for
unlimited Asana templates defined in Hammerspoon. I have not provided an
example.
@cmsj
Copy link
Member

cmsj commented Jan 5, 2022

pinging @malob as author of this Spoon

@mmynsted
Copy link
Author

mmynsted commented Jan 6, 2022

Is there something else I need to do for this?
I am actively using the code from this MR, and it works well for me.

@cmsj
Copy link
Member

cmsj commented Jan 14, 2022

Is there something else I need to do for this?

At this stage no - it's always tricky with the Spoons because one person submits them and then others want to make changes. I at least like to ping the original author to see if they have an opinion on the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants