As a Limio user, you should take advantage of all the functionality we provide to make bulk updates. In order to do this, you might want to view all of the offers available in your Limio implementation. The best way of retrieving this information is using the Limio API: https://apidocs.dev.limio.com/#getoffers.
This endpoint paginates its results and therefore in order to retrieve all of the offers you'll need to make more than one network request. An example of how to do this in Postman is provided below:
const token = pm.variables.get("token")
function fetchItems() {
const queryMoreFrom = pm.variables.get("queryMoreFrom")
pm.sendRequest({
url: `https://gedi.prod.limio.com/l-api/offers?opt.all=true&opt.modifiedAfter=2022-08-08T01:00:05&opt.queryMoreFrom=${queryMoreFrom}`,
method: "GET",
header: `Authorization: Bearer ${token}`
}, function (err, response) {
if (err) {
console.error(err);
}
const res = response.json()
if (!pm.variables.get('items')) return
const currentItems = Object.values(JSON.parse(pm.variables.get('items')))
pm.variables.set('items', JSON.stringify([...currentItems, ...Object.values(res.items)]))
pm.variables.set('queryMoreFrom', res.queryMore.from)
if (res?.queryMore?.from) {
fetchItems()
}
});
}
pm.test("Fetches multiple pages of results", function () {
const res = pm.response.json();
pm.variables.set("queryMoreFrom", res.queryMore.from)
pm.variables.set('items', JSON.stringify([...Object.values(res.items)]))
fetchItems()
});
Comments
0 comments
Please sign in to leave a comment.