POSLavu

The POSLavu API is, franky, disgusting. It feels like something someone
might have come up with their first week using MySQL and PHP. There's
POST parameters and XML fragments and JSON scattered about. Error handling
and input sanitization are afterthoughts. There's no direction or
cohesiveness. Tell me: would you expose an “order” table with 91
different columns? POSLavu did.

This gem wraps that API into something that's more reasonable than
using their API directly. A gem can't fix the data model, but it can
add some sanity to the access methods.

Naturally, you'll need a POSLavu account to do anything useful.

Installation

Add this line to your application's Gemfile:

gem'poslavu'

And then execute:

$ bundle

Or install it yourself as:

$ gem install poslavu

Usage

All usage starts by instantiating a client object.

client=POSLavu::Client.new('dataname','token','key')

From here, you can invoke API methods directly:

client.invoke('command','parameter'=>'value')

This is the low-level interface. Hopefully you'll never need it.

The POSLavu gem provides a higher-level query interface. Say you want to
iterate over all your orders:

client.table('orders').each{|order|# ...
}

Done. This will issue multiple API calls as needed, traversing the list of
orders one page at a time. Naturally, the resulting object is
Enumerable, so you can call .map or .inject or
whatever other normal things you might want to do.

Client#table returns a POSLavu::QueryScope, which lets you chain various
conditions and lazily retrieve the results. Records are encapsulated by
POSLavu::Row, which is just a Hash that came from the POSLavu API.

Development

POSLavu uses rspec and WebMock to validate functionality.

There is a component of the test suite that runs read-only queries against
the live POSLavu API. This is intended as a smoke test, principally
exercising the RPC mechanism, although it can also identify changes in the
server-side data model.

Running the live component of the test suite requires POSLavu API
credentials. This is safe to run against a live site; it does not modify
any data. You can pass in your credentials using environment variables or
by creating a .env file with the following: