Class: Ebay::Shopping

Inherits:
Object
  • Object
show all
Includes:
Requestable
Defined in:
lib/ebay/shopping.rb

Overview

The eBay Shopping API makes it easy to search for things on eBay.

Instance Attribute Summary collapse

Attributes included from Requestable

#endpoint, #headers, #http

Instance Method Summary collapse

Methods included from Requestable

#market_id=, #persistent, #sandbox, #use, #via

Constructor Details

#initialize(app_id: Config.app_id, response_encoding: nil, site_id: nil, version: '1119', version_handling: nil, tracking_id: nil, tracking_partner_code: nil, affiliate_user_id: nil) ⇒ Shopping

Returns a Finding API request instance

Parameters:

  • app_id (String) (defaults to: Config.app_id)
  • response_encoding (String) (defaults to: nil)
  • site_id (String) (defaults to: nil)
  • version (String) (defaults to: '1119')
  • version_handling (String) (defaults to: nil)
  • tracking_id (String) (defaults to: nil)
  • tracking_partner_code (String) (defaults to: nil)
  • affiliate_user_id (String) (defaults to: nil)


56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ebay/shopping.rb', line 56

def initialize(app_id: Config.app_id, response_encoding: nil,
               site_id: nil, version: '1119',
               version_handling: nil, tracking_id: nil,
               tracking_partner_code: nil, affiliate_user_id: nil)
  @app_id = app_id
  @response_encoding = response_encoding
  @site_id = site_id
  @version = version
  @version_handling = version_handling
  @tracking_id = tracking_id
  @tracking_partner_code = tracking_partner_code
  @affiliate_user_id = affiliate_user_id
end

Instance Attribute Details

#affiliate_user_idString (readonly)

Returns:

  • (String)


44
45
46
# File 'lib/ebay/shopping.rb', line 44

def affiliate_user_id
  @affiliate_user_id
end

#app_idString (readonly)

Returns:

  • (String)


23
24
25
# File 'lib/ebay/shopping.rb', line 23

def app_id
  @app_id
end

#response_encodingString (readonly)

Returns:

  • (String)


26
27
28
# File 'lib/ebay/shopping.rb', line 26

def response_encoding
  @response_encoding
end

#site_idString (readonly)

Returns:

  • (String)


29
30
31
# File 'lib/ebay/shopping.rb', line 29

def site_id
  @site_id
end

#tracking_idString (readonly)

Returns:

  • (String)


38
39
40
# File 'lib/ebay/shopping.rb', line 38

def tracking_id
  @tracking_id
end

#tracking_partner_codeString (readonly)

Returns:

  • (String)


41
42
43
# File 'lib/ebay/shopping.rb', line 41

def tracking_partner_code
  @tracking_partner_code
end

#versionString (readonly)

Returns:

  • (String)


32
33
34
# File 'lib/ebay/shopping.rb', line 32

def version
  @version
end

#version_handlingString (readonly)

Returns:

  • (String)


35
36
37
# File 'lib/ebay/shopping.rb', line 35

def version_handling
  @version_handling
end

Instance Method Details

#find_products(payload = {}) ⇒ HTTP::Response

Returns one or more eBay catalog products based on a query string or product ID value

Parameters:

  • payload (Hash) (defaults to: {})

Returns:

  • (HTTP::Response)


75
76
77
# File 'lib/ebay/shopping.rb', line 75

def find_products(payload = {})
  request('FindProducts', payload)
end

#get_category_info(category_id, payload = {}) ⇒ HTTP::Response

Retrieves high-level data for a specified eBay category

Parameters:

  • category_id (String)
  • payload (Hash) (defaults to: {})

Returns:

  • (HTTP::Response)


84
85
86
87
# File 'lib/ebay/shopping.rb', line 84

def get_category_info(category_id, payload = {})
  payload = payload.merge('CategoryID' => category_id)
  request('GetCategoryInfo', payload)
end

#get_ebay_time(payload = {}) ⇒ HTTP::Response

Gets the official eBay system time in GMT

Parameters:

  • payload (Hash) (defaults to: {})

Returns:

  • (HTTP::Response)


93
94
95
# File 'lib/ebay/shopping.rb', line 93

def get_ebay_time(payload = {})
  request('GeteBayTime', payload)
end

#get_item_status(*item_ids, payload = {}) ⇒ HTTP::Response

Retrieves the current status of up to 20 eBay listings

Parameters:

  • item_ids (String)
  • payload (Hash) (defaults to: {})

Returns:

  • (HTTP::Response)


103
104
105
106
107
# File 'lib/ebay/shopping.rb', line 103

def get_item_status(*item_ids)
  payload = item_ids.last.is_a?(Hash) ? item_ids.pop : {}
  payload = payload.merge('ItemID' => item_ids.map(&:to_s))
  request('GetItemStatus', payload)
end

#get_multiple_items(*item_ids, payload = {}) ⇒ HTTP::Response

Retrieves publicly available data for one or more listings

Parameters:

  • item_ids (String)
  • payload (Hash) (defaults to: {})

Returns:

  • (HTTP::Response)


115
116
117
118
119
120
# File 'lib/ebay/shopping.rb', line 115

def get_multiple_items(*item_ids)
  payload = item_ids.last.is_a?(Hash) ? item_ids.pop : {}
  payload = payload.merge('ItemID' => item_ids.map(&:to_s))

  request('GetMultipleItems', payload)
end

#get_shipping_costs(item_id, payload = {}) ⇒ HTTP::Response

Gets shipping costs for a listing

Parameters:

  • item_id (String)
  • payload (Hash) (defaults to: {})

Returns:

  • (HTTP::Response)


127
128
129
130
# File 'lib/ebay/shopping.rb', line 127

def get_shipping_costs(item_id, payload = {})
  payload = payload.merge('ItemID' => item_id)
  request('GetShippingCosts', payload)
end

#get_single_item(item_id, payload = {}) ⇒ HTTP::Response

Gets publicly visible details about one listing

Parameters:

  • item_id (String)
  • payload (Hash) (defaults to: {})

Returns:

  • (HTTP::Response)


137
138
139
140
# File 'lib/ebay/shopping.rb', line 137

def get_single_item(item_id, payload = {})
  payload = payload.merge('ItemID' => item_id)
  request('GetSingleItem', payload)
end

#get_user_profile(user_id, payload = {}) ⇒ HTTP::Response

Retrieves user information

Parameters:

  • user_id (String)
  • payload (Hash) (defaults to: {})

Returns:

  • (HTTP::Response)


147
148
149
150
# File 'lib/ebay/shopping.rb', line 147

def (user_id, payload = {})
  payload = payload.merge('UserID' => user_id)
  request('GetUserProfile', payload)
end