building out wrapper for client
authorOwen Smith <owen@omsmith.ca>
Mon, 19 Nov 2012 03:47:54 +0000 (22:47 -0500)
committerOwen Smith <owen@omsmith.ca>
Mon, 19 Nov 2012 03:47:54 +0000 (22:47 -0500)
www/assets/js/client.js
www/assets/js/ui.js

index 09e280c..c0cd448 100644 (file)
@@ -1,5 +1,18 @@
-var transport = new Thrift.Transport('');
-var protocol  = new Thrift.Protocol(transport);
-var client    = new PosClient(protocol);
+var client = new PosClientWrapper('', '');
 
+PosClientWrapper = function (authKey, serverLocation) {
+       this._authKey = authKey;
 
+       this._transport = new Thrift.Transport(serverLocation);
+       this._protocol = new Thrift.Protocol(this._transport);
+       this._client = new PosClient(this._protocol);
+};
+
+PosClientWrapper.prototype = {};
+PosClientWrapper.prototype.getPrice = function (upc, callback) {
+       if (callback === undefined) {
+               return this._client.getUPCPrice(upc);
+       }
+
+       this._client.getUPCPrice(upc, callback);
+}
index 009210b..8be73f0 100644 (file)
@@ -81,6 +81,9 @@ $('input[name=upc]').keypress(function (e) {
                        request_upc_data(upc, function (data) {
                                update_entry(upc, data);
                        });
+                       client.getPrice(upc, function (val) {
+                               update_entry(upc, { price:val });
+                       });
                }
 
                update_entry(upc, { 'quantity':1 });