ccollins / rebay

Ruby client for the RESTful JSON ebay finding and shopping api
MIT License
53 stars 56 forks source link

Pagination on find #6

Open thelal opened 12 years ago

thelal commented 12 years ago

I can see results info coming back from find_items_in_ebay_stores call but it doesn't handle pagination of the results. I can pass the pagination (page#) parameter but I get the same set (top 100 records) of data each time.

I need to be able to retrieve that other data (by pagenumber) and see the count info (totalPages and totalEntries)

in rebay / lib / rebay / finding.rb lines 57-58 you pull back only the 'items' array It appears extra meta data is as follows (I see this after the 1st item record and before the next one (searchResult) )
Note: I changed data below where store to <>

\"@count\"=>\"10 0\"}, @response={\"itemSearchURL\"=>\"http://stores.ebay.com/<>/_i.html?_fss=1&_saslop=1&LH_SpecificSeller=1&_ddo=1&_exm aitems=1&_ipg=100&_pgn=1&_sid=1032732382&_ssn=<>\", \"ack\"=>\"Success\", \"paginationOutput\"=>{\"entriesPerPage\"=>\"10 0\", \"totalPages\"=>\"39\", \"totalEntries\"=>\"3826\", \"pageNumber\"=>\"1\"}, \"version\"=>\"1.12.0\", \"timestamp\"=>\"2012-10-0 9T05:16:31.558Z\", \"searchResult\"=>{\"item\"

Code I'm using to call as follows: response = finder.find_items_in_ebay_stores( {:storeName => '<>', :pagination => {:entries_per_page => 100, :page_number => page_num} } )

thelal commented 12 years ago

created temp workaround. api.rb (line 30) needs its parms changed as passing wrong parms to ebay -- it needs to be in format &paginationInput.entriesPerPage=##&paginationInput.pageNumber=##

in finding.rb (before line 57) also return extra parm of pg = response.results['paginationOutput'] so can then pullout 'totalPages, 'totalEntries', 'pageNumber', 'entriesPerPage'

peppyheppy commented 11 years ago

@thelal, I am sure you have gotten past this already, but I just wanted to show you (and others) an example of how I get pagination information.

Here is a simple example:

finding_response = Rebay::Finding.new.find_items_by_keywords(
  :keywords => 'stuff',
  :'paginationInput.entriesPerPage' => '100',
  :'paginationInput.pageNumber' => '1',
)

# the results/items
finding_response.results

# the pagination information
finding_response.response["paginationOutput"] # => { 'entriesPerPage' => 100, 'pageNumber' => 1, 'totalEntries' => '1234', 'totalPages' => '13' }

Documentation for specifying Page and Per Page information to API: http://developer.ebay.com/DevZone/finding/CallRef/findItemsByKeywords.html#page

Documentation for paginationOutput: http://developer.ebay.com/DevZone/finding/CallRef/types/PaginationOutput.html