Saturday, 28 January 2012

Crunch, the RESTful Accountants (And Introducing the Crunch API Explorer)

One of the things that scared me a little when I thought about starting my own business was the thought of the bookkeeping. I know, I know – I have a Maths degree, so I ought to be able to cope with adding up a few numbers then working out the 20% I owe to the tax man. And the 20% I owe to the VAT lady. And how to take just the right amount of salary to avoid giving anything to the PAYE person. But my arithmetic has always been terrible, and the mathematicians who lectured me, strange to say, rarely used actual numbers. It was all xs and ys and βs and πs. So that didn’t help.

CrunchA big factor in persuading me to make the leap into running a company was finding an excellent online accounting service to handle all those troublesome numbers for me. Crunch are a smart bunch of accountants based down in Brighton who have teamed up with an equally smart bunch of developers to create bookkeeping software that is actually quite fun to use (I know – I couldn’t quite believe that when I read it on another freelancer’s blog, but it’s true!). You enter all the numbers in the website as you rake in the profits, or fork out to your suppliers, and at the end of the year, Crunch will put together your accounts and send them off to H.M.R.C. They’ll even submit your VAT returns for you. And your payroll, if you should happen to have any minions employees. All for £59.50 a month. It’s great. Sign up here and we’ll both get a £25 Amazon voucher!

And as if all that wasn’t awesome enough, earlier this month they launched an API. It its RESTful, speaking XML, with OAuth authentication. That’s right – a REST API from an accountancy company! I should caution that the first release is limited to dealing with expenses and suppliers, but the dev team plan to add areas according to the priorities indicated by us users.

The Crunch API Explorer

Well, you know me. I couldn’t leave a shiny new toy like that lying on the shelf. So I had a play, and knocked together something that I think you’ll like.

Allow me to introduce the Crunch API Explorer:

image

It’s a little tool to help you poke and prod the Crunch API. You enter a URL, set the appropriate Http Method, hit Go!, and it will show you the XML that Crunch returns.

You can download it here (it installs using ClickOnce, so it will auto-update when I add new features. If you don’t already have .Net 4.0 on your machine, you should be prompted to install it). To connect to Crunch using the Crunch API Explorer, you’ll need your own API key which you can get by contacting the nice folks at api-dev@crunch.co.uk. Then you can make REST calls to your hearts delight. All the documentation you need about the resource URLs and the structure of the XML for submitting updates can be found here on the Crunch website.

Here are a few of my favourite features:

  • XML Syntax colouring when you’re editing requests (this courtesy of AvalonEdit, the open source WPF text editor component that is part of SharpDevelop)
  • Makes you confirm any update/delete requests made to the live server (but not to the test server)
  • All the source is available on GitHub, so if ever you wanted an example of how to connect to an OAuth API with DotNetOAuth, well – now you have one (see CrunchFacade.cs). It’s all in C#, with some WPF, and of course a topping of MVVM.

There are a couple of things I wanted to add, but didn’t get time for – maybe next week:

  • Remembering frequently used resource URIs, and maybe saving template Xml request documents
  • Ability to choose a file and insert it into the XML request documents in Base64 format for the APIs that support file upload
  • Saving Base64 encoded data in the responses to files

Anything else?

I’d love to hear from anyone who finds this useful. Feature requests are welcome (pull requests even more so). And if you fancy forking this and adapting it to explore other APIs, be my guest.

Monday, 26 December 2011

Happy Christmas to all

I hope you have all enjoyed a Happy Christmas. Nothing technical today. I just wanted to share with you something my six-year old daughter made for me:

EPSON007

Tuesday, 29 November 2011

Mini Review: NHibernate 3 Beginner’s Guide

I’ve recently re-discovered the pleasure of reading in bed, thanks to my new iPad, which, with its backlit screen, allows me to snuggle under the covers with a good book without disturbing my wife. Packt Publishing kindly provided my bedtime reading for the last few nights - NHibernate 3 Beginner's Guide by Dr. Gabriel Nicolas Schenker and Aaron Cure.

nhibernateThis is a book I wish I’d had three years ago. Back then I was sketching designs for a database-heavy application, and I evaluated Nhibernate, but was put off by its steep learning curve, and skimpy documentation. The documentation has improved immensely in the years since, and NHibernate itself has got easier to use, but it can still appear daunting for someone just getting started.

This book makes Nhibernate approachable for the absolute beginner, even one who is relatively new to database technologies. The author explains key concepts carefully, and drives lessons home with plenty of comprehensive step-by-step tutorials.

What I particularly liked was the inclusion of the Nhibernate ecosystem: FluentNhibernate (in my opinion the best mechanism for configuring NHibernate) is given good treatment, as is NHProf, a commercial Nhibernate profiling tool. It was also nice to see an introduction to unit testing NHibernate data access layers.

One area that I did feel was a little weak was the section on setting up mappings. The author gives examples of three different ways in which mappings can be configured, but doesn't cover important aspects like cascading updates in much detail at all – something I’ve been caught out by several times, and an area on which I would have appreciated some friendly guidance when I was starting out. Have a look at NHibernate in Action if you want to dig in more deeply here.

This book definitely goes on my list to recommend to anybody starting out with NHibernate development.

Monday, 24 October 2011

XAML Magic: Turning an Ugly Silverlight Duckling into a Beautiful Photoshopped Swan

Over the last few weeks I’ve had the privilege of working with Ayende and the Hibernating Rhinos team on the new management UI for RavenDB. Never one to follow the herd (unless perhaps it consisted of Rhinos), Ayende’s bucking the trend and building it in Silverlight.

My part was to beautify the application by mimicking Photoshop designs that a designer had created for a new version of the RavenDB website. I was quite pleased with the way it turned out, and the screenshots Ayende posted on his blog got some favourable feedback.

Ayende asked me to write a blog post on the transmogrification process, and he has just published it on the company blog. Go read it, to find out how I turned this

image_thumb30

into this

image