There's an interface with some "handy" methods, they should be enough for any basic usage of toodledo:
org.loststone.toodledo.ToodledoApi
and it has its implementation file in the same package: org.loststone.toodledo.ToodledoApiImpl
it's also a good example of how to use the other methods in the library. Also, there's the javadoc in the doc/javadoc directory (ant javadoc)
If anyone needs anything that's not in the interface feel free to code it and add it to the library. Basically what all the methods do is create a Request, which inherits from the org.loststone.toodledo.request.Request
class and then return a class than inherits from org.loststone.toodledo.response.Response
, like this we encapsulate all the HTTP stuff, and the Response
inherited class contains a getResponseContent
that gives back the info from the call. If the response is easy you can parse the output there, but if the response is something bigger, like one of those xmls then you can use one class at the package org.loststone.toodledo.xml
to parse it. Up to you.
Then, more advanced stuff:
initialize
method in the interface you'll get a AuthToken
, this is an object which contains a key that will be valid for 4 hours, so, for every user you must cache or serialize or whatever that object. If you try to authenticate several times the same user (use the initialize
method for the same user) that user will be banned temporarily from using the API, and that's not good. So, use that call or get an AuthToken
manually and save that key for future use.
The initialize
method needs the userid, not the username, you can get the userid from the toodledo webpage, it's always a 15 or 16 hexadecimal string. If for any reason you cannot log into the webpage and get the userid for a user you can user the getUserId
method in the API. This method only requires the user e-mail and password. Take care using this method as it's sending the password in plain text format over the net as an http parameter. So, use it only if necessary.
All the requests use the commons-http package to do HTTP GET's to the REST API.