birarda / logan

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

Access and add comments to Todos #6

Open sarafen opened 10 years ago

sarafen commented 10 years ago

Perhaps this is more a feature request, but it'd be nice to grab comments on todos and add comments to todos (unless I missed this somewhere).

birarda commented 10 years ago

It's not in there yet - something I can definitely add in the next week or so.

birarda commented 10 years ago

@StephenLovell - 96ed8c4203af7bdc48b80c0d29a66da7c8a8d172 handles part of this.

Now, if you have a todo you can call comments to have it grab the comments on the todo for you (if they exist).

I'll keep this to-do open because you can't add comments yet.

The other thing is that the comment content is not stripped of any html or weird unicode characters. I think it makes to keep it this way so if you're sticking it in a webpage it will be formatted as it is on basecamp, but am open to suggestions on this one.

kannannadarajan commented 10 years ago

I am trying to write a small ruby library, which is trying to add a comment to a todo, but it is not working, is there any way that can I achieve it ?

NOTE: All other things are working like adding a todo, todolist etc.., ===================MY CODE================= params={ :content => "Test comment", :subscribers => [] }

Logan::Client.post "/projects//todos//comments.json",params

Response seems:

<HTTParty::Response:0x..fb6daf758 parsed_response="403 Forbidden", @response=#<Net::HTTPForbidden 403 Forbidden readbody=true>, @headers={"connection"=>["close"], "x-content-type-options"=>["nosniff"], "x-runtime"=>["0.018705"], "server"=>["nginx"], "content-type"=>["text/html; charset=utf-8"], "transfer-encoding"=>["chunked"], "x-xss-protection"=>["1; mode=block"], "date"=>["Thu, 25 Sep 2014 10:42:09 GMT"], "x-frame-options"=>["SAMEORIGIN"], "set-cookie"=>["X-Runtime=0.018705; path=/; expires=Thu, 25-Sep-2014 10:42:19 GMT; secure", "X-Request-Id=ceac140a-81d2-4782-8d17-047b1531ecc3; path=/; expires=Thu, 25-Sep-2014 10:42:19 GMT; secure"], "status"=>["403 Forbidden"], "x-request-id"=>["ceac140a-81d2-4782-8d17-047b1531ecc3"], "x-queue-time"=>["0.0014562606811523438"], "cache-control"=>["no-cache"], "vary"=>["Accept-Encoding"]}>

Thanks, Kannan

birarda commented 10 years ago

Hey @kannannadarajan - it looks like you're not authenticated to make that request.

Have you given logan a set of credentials to use?

kannannadarajan commented 10 years ago

Hi Birarda,

I have the access, but I forgot to send the header! to me it is fixed.

So, I modified my code as

body = Hash.new body[:content]= "Another test with subscriber" body[:subscribers] = [8240532]

params = Hash.new params[:headers] = Logan::Client.headers.merge({'Content-Type' => 'application/json'}) params[:body] = body.to_json

logan.class.post "/projects//todos//comments.json", params

Note: I am using your older version gem(0.0.7), it is 100% fit to me, since i am working with the lower version of ruby/rails (1.8.7/1.2.1).

Thanks for your valuable contribution, Kannan

kannannadarajan commented 10 years ago

Hi, Is there any way to access all my todos across all projects and todo lists ?

Thanks, Kannan

birarda commented 10 years ago

@kannannadarajan I think as far as I have it setup now you'd have to enumerate via projects and then todolists

Feel free to open up another issue if you'd like to make a feature request!

kannannadarajan commented 10 years ago

Sure and I will share if I found anything! Thanks.