I’ve done a fair amount of integration work between Sage Line 50 and various websites, e-commerce and others, and I’m writing a plugin for Rails to make this process a bit easier.
Integration is achieved with a great product from Internetware called connect which lets us talk with Sage via Connects own XML format. This makes integration pretty easy in any language with good XML support providing you know the schema. My plugin will hopefully remove the need to understand the inner details of the schema.
I’ve already written the part for handling uploading data from Sage, thats nice and simple – you handover the xml, and the call either Products, Categories/Tax Codes or Customers methods with nice rubyesque code blocks to do something with that Product/Category/Tax Code/Customer.
I’m now trying to decide on a clean API for downloading data back to Sage Line 50. This needs quite a lot of data to generate either a Sales Order or Invoice, the question is how make doing this easy without knowledge of the schema. Options I’ve thought of so far
- Some way to extend the users models to generate SalesOrders or Invoices – will need to spec how to map fields, then we have an equivalent to the current to_json, to_xml methods – this ties the knowledge of sage quite tightly to the users models though.
- a generator which creates a nicely commented builder template – the user can then play fill in the blanks, this does expose the schema directly but makes it quite easy for the user – doesn’t feel very clean though
- a intermediate object, much like the upload – this will either need to be handed a way to map fields though, and I’m not sure how to hand the nesting of data within the schema, or will just need a stack load of methods – which is extremely messy
- some kind of DSL, AtomBuilder is a bit like this but ends up still requiring the user to know the Atom schema – this wont fly for us since our schema is a lot more complicated. In principle this feels the right way but I don’t want the user to need to know the ins and outs of the schema
Will have to see where this leads – the intention is a plugin with the logic well hidden, and a generator to create a sample controller which the Connect package can talk to and the user can butcher/tweak/learn from.
As an aside I’ve been using Git for this – seems to have come on a long way but is still not as pleasant to use as bzr. Easygit makes it bearable though and its certainly a lot faster.