Reputation: 171
first of all, thanks to @gregdennis. I use Manatee Trello namespace to query and get Actions from Trello board. there is a limitation to getting entities on each request (50 by default). In Online API documentation I read there are several parameters like 'limit' and 'before'. How I passing these parameters to methods in my code, my sample fetch code is here:
Board board = new Board(boardId);
var actions = board.Actions.ToList();
Upvotes: 2
Views: 345
Reputation: 8428
There are a few extension methods on various collection types that will modify the API queries to add these parameters.
The first you're looking for is Limit(this ReadOnlyActionCollection, int)
. Just pass in the number of actions you want. Valid values (per the API) are 0-1000.
The second is Filter(this ReadOnlyActionCollection, DateTime?, DateTime?)
which will allow you to filter on since
(start) and before
(end). (The API docs say that lastView
is a valid option for the since
parameter. This is not supported at the moment.)
Edit
Note that these extension methods work just like LINQ: they return a new instance of the query. The query doesn't execute until the collection is enumerated.
Edit 2
To get any collection you have to have a Trello entity (board, list, card, etc.) first. A collection is meaningless without the object which defines it. For example, boards have lists, lists have cards, cards have checklists, and all of these have actions.
So to get a collection that consists of the 500 most recent actions for a card,
var card = new Card("<ID>");
var actions500 = card.Actions.Limit(500);
foreach(var action in actions500)
{
Console.WriteLine(action);
}
Edit 3
Okay. I see the problem. I didn't use the this
keyword in the Limit()
extensions. I'll fix that and publish an updated.
Until then, please use the method statically:
Collections.Limit(card.Actions, 100);
Edit 4
As of Manatee.Trello version 3.0.0, Limit
is a property on all collections. The default is 50 for most types.
Upvotes: 0