goshippo / shippo-node-client

Shipping API Node.js library (USPS, FedEx, UPS and more)
https://goshippo.com/docs
MIT License
136 stars 54 forks source link

Pagination support #48

Closed zrisher closed 4 years ago

zrisher commented 5 years ago

Many of the Shippo resources are paginated and respond to the page and results params to view data past the initial 10. However, only the Batch resource allows us to specify a page.

For example, carrieraccount.list returns

{ 
  next: 'https://api.goshippo.com/carrier_accounts/?page=2',
  previous: null,
  results: [ [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object]] 
} 

Does this repo provide any way to access data past the first 10 results for any resource besides Batch?

epistemancer commented 4 years ago

@zrisher : just in case you or someone else is still wondering about this, you can pass results and page parameters into the resource methods, e.g.

shippo.carrieraccount.list({ results: 2, page: 2})

(In fact, all the attributes of the argument object get included as URI parameters, even for create methods. Most of the URL parameters are ignored -- the POST data is what's used for creates -- but as a kind of side effect, results and page parameters are included too and have their intended effect. We should probably clean this up and filter out the unnecessary parameters but keep allowing useful ones like the pagination parameters.)

mhirsch commented 3 years ago

This should be in the docs somewhere (apologies if I missed it but I don't see it)