jchrom/trelloR

New API Custom Fields handling

Closed this issue · 7 comments

It appears that Trello has updated their Custom Fields Power Up to fully integrate with the API. Therefore, pluginData is now depreciated. While this new capability allows for increased functionality, it means that some of the current trelloR functions, such as get_card_fields, no longer perform correctly.

The website for the new API Custom Fields info is https://developers.trello.com/docs/getting-started-custom-fields

I am trying to obtain all of the customs fields data for all cards on a board. While this was previously not possible, that appears to no longer be the case. The cURL code that the Trello API info suggests for doing this is:
curl https://api.trello.com/1/boards/5a00adcebe1991022b4a4bb4/cards/?fields=name&customFieldItems=true&key={APIKey}&token={APIToken}

Since I am new to R, I am still trying to figure out how to implement this with trelloR's get models. I will update once I have figure this out.

Custom fields have been on my radar for a while, and I was pleased when they released an actual API for it. I had a time where I wasn't really maintaining trelloR at all, as Trello is no longer my main tool for organizing work (I have a different tool imposed on me now basically :P )

I will implement calls for custom fields API eventually, but I'm a bit hesitant to commit to a time frame. I am happy to discuss ideas though!

On that note, trelloR is really just a wrapper for Hadley's httr. You can see what it's doing if you inspect the insides of the get_url function. We just need to figure out the request URL, and format the response into something sensible (like a data.frame).

I am happy to work on it, but I am very new to R and programing in general. However, this would be a great challenge.

I am trying to update the get_model function to add an argument for customFieldItems, however, I am encountering difficulties with the linked functions defined elsewhere in the trelloR package, paricularly those in get_internal.R. I keep getting errors saying a particular function cannot be found.

Here is the get_cards_fields function that works for individual cards:

get_card_custfields <- function (id, ...) 
{ 
  dat = get_model(parent = "card", id = id, child = "customFieldItems", ...)
}

I am still working on one for all cards from a list or board.

If interested, here is some r code I wrote for retrieving the custom field data for several cards at once, and adding them to a single dataframe. It includes an example for a Trello board containing cards of contacts.

Hi @deneara !

I have some good news: Implementing custom fields seems to be really easy. In order to get all open cards on the board along with their custom fields, all you have to do is:

get_board_cards(board_id, token = my_token, query = list(customFieldItems = "true"))

A minor inconvenience is that customFieldItems = "true" breaks R convention a little. You can't really go customFieldItems = TRUE because httr::build_query calls paste on that, so it will get coerced into a character vector "TRUE". But the request requires lowercase "true" and fails otherwise.

So I might implement some convenience function in get_model so that you can write logical customFieldItems = TRUE and it will get converted to character "true".

The function from your previous post is exactly what we need to replace the current get_card_fields with. And then the same deal for parent="board" in order to get field definitions from the board.

Ok, so I added some custom fields wrappers. If you want to test them, I have pushed the code to the master-rc branch. To install trelloR from that branch, do

 devtools::install_github("jchrom/trelloR", ref = "master-rc")

And see ?get_board_fields, ?get_card_fields, ?add_field, ?update_field, ?delete_field and ?update_card_field for some info on how these work. At some point, I'll write a proper vignette.

Taken care of in 0.6.0