Prev | Current Page 165 | Next

David Berube

"Practical Reporting with Ruby and Rails"


Listing 6-2. Average Price Reporter, Part 2 (average_price_report.rb)
class EBaySearch
@@ebay_config = {
:ebay_address=> 'rest.api.ebay.com',
:request_token => 'my_request_token',
:user_id => 'my_ebay_user_id' }.freeze # Insert your request token
# and eBay user ID here.
def self.get_average_price(keyword, seller_id=nil)
params = {
# Authorization information . . .
'RequestToken' => @@ebay_config[:request_token],
'RequestUserId' => @@ebay_config[:user_id],
# Function name
'CallName' => 'GetSearchResults',
# Search parameters
'Query'=>URI.escape(keyword), # Note that only
# some parameters are escaped.
# This is because the RequestToken
# is already escaped for URLs, so
# re-URL encoding would cause
CHAPTER 6 n TRACKING AUCTIONS WITH EBAY 116
# problems; otherwise, we could just
# run all of these values through a URI.escaping
# loop.
'ItemTypeFilter' => 3, # Search all items,
# including fixed price items.
# If you change this to 2,
# you'll get fewer results,
# but it won't include in-progress
# auctions, which may make your
# results more accurate.


Pages:
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
Julie London Maxïmo Park Sophie Milman Marie Ricky Martin