producteca-sdk
Advanced tools
Comparing version 6.0.0 to 6.0.1
@@ -12,4 +12,6 @@ (function() { | ||
} | ||
this._getPageByPage = bind(this._getPageByPage, this); | ||
this._buildAuthMethod = bind(this._buildAuthMethod, this); | ||
this._makeUrlAsync = bind(this._makeUrlAsync, this); | ||
this.getBatch = bind(this.getBatch, this); | ||
this.respondMany = bind(this.respondMany, this); | ||
@@ -34,2 +36,15 @@ this.initializeClients = bind(this.initializeClients, this); | ||
ProductecaApi.prototype.getBatch = function(skip, top, moreQueryString) { | ||
if (skip == null) { | ||
skip = 0; | ||
} | ||
if (top == null) { | ||
top = 20; | ||
} | ||
if (moreQueryString == null) { | ||
moreQueryString = ""; | ||
} | ||
return this.respondMany(this.client.getAsync("/" + this.resource + "?$top=" + top + "&$skip=" + skip + "&" + moreQueryString)); | ||
}; | ||
ProductecaApi.prototype._makeUrlAsync = function(url) { | ||
@@ -57,2 +72,23 @@ var parts; | ||
ProductecaApi.prototype._getPageByPage = function(skip, moreQueryString) { | ||
var TOP; | ||
if (skip == null) { | ||
skip = 0; | ||
} | ||
if (moreQueryString == null) { | ||
moreQueryString = ""; | ||
} | ||
TOP = 500; | ||
return this.getBatch(skip, TOP, moreQueryString).then((function(_this) { | ||
return function(items) { | ||
if (items.length < TOP) { | ||
return items; | ||
} | ||
return _this._getPageByPage(skip + TOP, moreQueryString).then(function(moreItems) { | ||
return items.concat(moreItems); | ||
}); | ||
}; | ||
})(this)); | ||
}; | ||
return ProductecaApi; | ||
@@ -59,0 +95,0 @@ |
@@ -16,9 +16,7 @@ (function() { | ||
function ProductsApi() { | ||
function ProductsApi(endpoint) { | ||
this._convertJsonToProduct = bind(this._convertJsonToProduct, this); | ||
this._convertJsonToProducts = bind(this._convertJsonToProducts, this); | ||
this._findMany = bind(this._findMany, this); | ||
this._getProductsPageByPage = bind(this._getProductsPageByPage, this); | ||
this.getSkus = bind(this.getSkus, this); | ||
this.getBatch = bind(this.getBatch, this); | ||
this.getWarehouses = bind(this.getWarehouses, this); | ||
@@ -40,3 +38,4 @@ this.getPricelists = bind(this.getPricelists, this); | ||
this.get = bind(this.get, this); | ||
return ProductsApi.__super__.constructor.apply(this, arguments); | ||
this.resource = "products"; | ||
ProductsApi.__super__.constructor.call(this, endpoint); | ||
} | ||
@@ -49,3 +48,3 @@ | ||
ProductsApi.prototype.getAll = function() { | ||
return this._getProductsPageByPage().then(this._convertJsonToProducts); | ||
return this._getPageByPage().then(this._convertJsonToProducts); | ||
}; | ||
@@ -121,15 +120,2 @@ | ||
ProductsApi.prototype.getBatch = function(skip, top, moreQueryString) { | ||
if (skip == null) { | ||
skip = 0; | ||
} | ||
if (top == null) { | ||
top = 20; | ||
} | ||
if (moreQueryString == null) { | ||
moreQueryString = ""; | ||
} | ||
return this.respondMany(this.client.getAsync("/products?$top=" + top + "&$skip=" + skip + "&" + moreQueryString)); | ||
}; | ||
ProductsApi.prototype.getSkus = function(skip, top, moreQueryString) { | ||
@@ -148,20 +134,2 @@ if (skip == null) { | ||
ProductsApi.prototype._getProductsPageByPage = function(skip) { | ||
var TOP; | ||
if (skip == null) { | ||
skip = 0; | ||
} | ||
TOP = 500; | ||
return this.getBatch(skip, TOP).then((function(_this) { | ||
return function(products) { | ||
if (products.length < TOP) { | ||
return products; | ||
} | ||
return _this._getProductsPageByPage(skip + TOP).then(function(moreProducts) { | ||
return products.concat(moreProducts); | ||
}); | ||
}; | ||
})(this)); | ||
}; | ||
ProductsApi.prototype._findMany = function($filter, $select) { | ||
@@ -168,0 +136,0 @@ var query; |
@@ -33,2 +33,3 @@ (function() { | ||
this.getAll = bind(this.getAll, this); | ||
this.resource = "salesorders"; | ||
this.productsApi = new ProductsApi(endpoint); | ||
@@ -44,3 +45,3 @@ SalesOrdersApi.__super__.constructor.call(this, endpoint); | ||
querystring = this._buildSalesOrdersFilters(filters); | ||
return this.respondMany(this.client.getAsync("/salesorders/?$filter=" + querystring)); | ||
return this._getPageByPage(0, "$filter=" + querystring); | ||
}; | ||
@@ -47,0 +48,0 @@ |
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"main": "build/sdk.js", | ||
@@ -11,0 +11,0 @@ "dependencies": { |
31435
763