balanced / balanced-ruby

Balanced API library in ruby.
MIT License
111 stars 47 forks source link

Improve offset functionality #160

Closed sgrshah closed 10 years ago

sgrshah commented 10 years ago

Every month we pull all of our balanced debits and refunds, which I'm sure many companies do. To cycle through all of our transactions we provide a limit of 25 and increase the offset by 25 each time. However, if we sell more products while pulling the transactions, the offset seems to change. So, instead of pulling the 1000-1025 it pulls 999-1024 creating duplicates in our data set. Would be great to set the offset point when first starting to pull.

mjallday commented 10 years ago

You're right that some sort of frozen pagination would be a good solution.

In the meantime you can specify a sort order for the Balanced ruby client and that will work just as well for your use-case:

Balanced::Credit.all(:sort => 'created_at,asc')

will return all credits sorted by created_at ascending.