birarda / logan

ruby gem to communicate with new Basecamp API
MIT License
16 stars 19 forks source link

Todolist initializes with empty remaining and completed lists #5

Closed tybenz closed 10 years ago

tybenz commented 10 years ago

I noticed that remaining_todos and completed_todos initialize to an empty array.

You have a todos= method, but does logan provide a way to call the API to populate the params of todos=?

birarda commented 10 years ago

Hey @tybenz, sorry for the delay on this. I don't currently have that supported directly from the TodoList - I guess you'd have to go via the project first with the way things are currently setup.

Can you give me a snippet of what you'd like to do so I can accurately capture it and add it to logan?

sarafen commented 10 years ago

I have to say I second this. I just started using it and noticed that those were empty as well. I was trying to display the todo items in a specific todolist, but kept winding up empty.

birarda commented 10 years ago

Gotcha. Will add a way to call the API and get active and completed to-dos for the todolist.

sarafen commented 10 years ago

Thanks for that. Looking forward to the fix :)

Are you gonna add the ability to add items/delete items as well in the todolists? (Maybe needs to be another issue?)

On Feb 10, 2014, at 4:02 PM, Stephen Birarda notifications@github.com wrote:

Gotcha. Will add a way to call the API and get active and completed to-dos for the todolist.

— Reply to this email directly or view it on GitHub.

birarda commented 10 years ago

@StephenLovell you should have that one already via create_todo and delete_todo.

Both take todo objects. Does that sound like what you'd be looking for?

birarda commented 10 years ago

So I can understand how this should work, can you give me an example of how you're getting the Todolist object?

Is it one of the objects in todolists/completed_todolists from a project?

If so, there is a way to get the populated Todolist given the list ID, but I agree that it should be a little cleaner.

Here's how that would work now: downloaded_list = project.todolist(3)

What I propose is that, when remaining_todos or completed_todos is called, if the array is empty and there are remaining_todos or completed_todos (since the API is already returning us a completed/remaining count) I'll call the API.

tybenz commented 10 years ago

Yeah. I image it would something like this:

todo_list = project.todolists.select do |list|
    list.id == search_id
end

todo_list.todos.each do |todo|
  # do something
end
birarda commented 10 years ago

So this is what I'm envisioning:

todo_list = project.todolists.each do |list|
  list.remaining_todos.each do |todo|
    # do something with todo
  end
end
birarda commented 10 years ago

If you call todo on a list and it hasn't downloaded the todos, it'll do that now.

Logan 0.0.6 is up on rubygems now. Let me know if you were thinking of something different.