Auto-generate the Java, Python, Ruby, and PHP 5 Wesabe API client code
This is a very quick tutorial on how to auto-generate sample code for the Wesabe API yourself. Wesabe is a community site that makes managing your money easy by means of a REST API.
Copy the following generic sample requests into the clip board:
Point your browser to http://tomayac.com/rest-describe/latest/RestDescribe.html. You should now see an application called "REST Describe & Compile". In the upper panel with the heading "Request Sample" find the button "URI Batch Analysis". Click it.
Paste the sample requests copied above in the appearing pop-up dialog . Hit the "OK" button and confirm the "This may take some time…" alert box.
After a short while you should see a tree-like XML document, actually this is a WADL file (you don't need to care about what it is, we want the code…). Now find the "Generate Code" button on the lower right panel. Click it.
Finally you should see five buttons, "Java", "PHP 5", etc. Click the button of your preferred programming language. There you go, this is your code.
If you feel like, you can fine-tune the generated classes. Therefore change the "Naming Depth Level" from 1 to 2, or in addition to that, click the "Settings" link in the upper right corner, then go to the "Code Generation" tab. Hit "Re-Compile" after you have made your changes. Once you are happy with the class names, hit the "Select All" button and paste the code into some text editor.
In the newly generated file find the credentials at the very beginning, enter your Wesabe user and password. Now you can start the "Hello World" of Wesabe, simply retrieve your accounts by calling the method AccountsXml, for example in Ruby this can be done via:
>\ Accounts = AccountsXml.new()If this sounds like too complicated, I have thrown together a short screencast and uploaded it to YouTube: https://www.youtube.com/watch?v=QoM7tCcIq9o.
>\ puts Accounts.submit()
Image from wesabe.com