Closed kyeshmz closed 1 month ago
hi @kyeshmz - can you provide a little more detail about your request and response?
I don't think order responses are going to be guaranteed on any of these batch API calls, but I just want to make sure I'm understanding your question.
@zenmasterjobo I am utilizing the
await squareClient.catalogApi.retrieveCatalogObject(
id,
true
)
API call. It returns a category and images that are related to the certain object. The order of the images differs from the one that you can setup at square.online, where you can configure the order of images that would appear, for example in a carousel.
Ah yes, I see. Unfortunately Square Online operates on different APIs that that of the APIs exposed on our public platform. And again in this case, order isn't guaranteed. I Will forward this feedback to the relevant team as I did with your previous post.
Also, for issues like this that concern the API and not the SDK, please use our developer forums - Thank you!
It would be great to put it in the documentation somewhere!
Is there a possiblity of making this the same as the Square Online? Currently, I get rate limited because related object images returns the wrong order, but querying by image Ids returns in order @zenmasterjobo
Hi @kyeshmz
I don't think we can make the related objects list have the same sort order because the related objects can contain way more than just the images. However, because the image_ids array is respecting the correct order, we can use this array to sort the related object images so that way we don't need to query the API again.
After you have queried the object you want with retrieveCatalogObject(id, true)
you can do something like this in javascript
let sorted = related_objects.sort((a, b) => image_ids.indexOf(a.id) - image_ids.indexOf(b.id));
By using javascript's sort method, we can write our own compare function that will sort the related objects to match the order of the image_ids
array. This does assume that your related objects for a given catalog item only has image objects in it. If it does not, you would first need to go through the related objects and make a new array of only the objects that have type: 'IMAGE'
Let me know if you have any questions about this!
@zenmasterjobo This worked for my usecase, thanks!
Describe the bug retrieveCatalogObject returns results out of order for related object images
Expected behavior Return the same order as in the GUI.
To Reproduce Steps to reproduce the bug:
Square SDK version square": "^37.1.1",