Class: Ebay::Browse
Overview
Using the Browse API, you can create a rich selection of items for your buyers to browse with keyword and category searches. It also provides the ability to eBay members to add items and change the quantity of an item in their eBay shopping cart as well as view the contents of their eBay cart.
Constant Summary collapse
- SANDBOX_ENDPOINT =
'https://api.sandbox.ebay.com/buy/browse/v1'- PRODUCTION_ENDPOINT =
'https://api.ebay.com/buy/browse/v1'
Instance Attribute Summary collapse
- #campaign_id ⇒ String readonly
- #country ⇒ String? readonly
- #reference_id ⇒ String? readonly
- #zip ⇒ String? readonly
Attributes included from Sandboxable
Instance Method Summary collapse
-
#access_token ⇒ String
The application access token.
- #add_item ⇒ Object
-
#check_compatibility(item_id, marketplace_id, compatibility_properties) ⇒ HTTP::Response
Retrieves the details of the individual items in an item group.
-
#get_item(item_id, **params) ⇒ HTTP::Response
Retrieves the details of a specific item.
-
#get_item_by_legacy_id(legacy_item_id, **params) ⇒ HTTP::Response
Retrieves the details of a specific item using its legacy item ID.
-
#get_items_by_item_group(item_group_id) ⇒ HTTP::Response
Retrieves the details of the individual items in an item group.
- #get_shopping_cart ⇒ Object
-
#initialize(campaign_id:, reference_id: nil, country: nil, zip: nil, access_token: nil) ⇒ Browse
constructor
Returns a Browse API request instance.
- #remove_item ⇒ Object
-
#search(**params) ⇒ HTTP::Response
Searches for eBay items by various query parameters and retrieves summaries of the item.
-
#search_by_image(image, **params) ⇒ HTTP::Response
Searches for eBay items based on a image and retrieves their summaries.
- #update_quantity ⇒ Object
Methods included from Sandboxable
Constructor Details
#initialize(campaign_id:, reference_id: nil, country: nil, zip: nil, access_token: nil) ⇒ Browse
Returns a Browse API request instance
43 44 45 46 47 48 49 50 |
# File 'lib/ebay/browse.rb', line 43 def initialize(campaign_id:, reference_id: nil, country: nil, zip: nil, access_token: nil) @campaign_id = campaign_id @reference_id = reference_id @country = country @zip = zip @access_token = access_token end |
Instance Attribute Details
#campaign_id ⇒ String (readonly)
22 23 24 |
# File 'lib/ebay/browse.rb', line 22 def campaign_id @campaign_id end |
#country ⇒ String? (readonly)
28 29 30 |
# File 'lib/ebay/browse.rb', line 28 def country @country end |
#reference_id ⇒ String? (readonly)
25 26 27 |
# File 'lib/ebay/browse.rb', line 25 def reference_id @reference_id end |
#zip ⇒ String? (readonly)
31 32 33 |
# File 'lib/ebay/browse.rb', line 31 def zip @zip end |
Instance Method Details
#access_token ⇒ String
Returns the application access token.
34 35 36 |
# File 'lib/ebay/browse.rb', line 34 def access_token @access_token ||= mint_access_token end |
#add_item ⇒ Object
125 126 127 |
# File 'lib/ebay/browse.rb', line 125 def add_item raise 'not implemented' end |
#check_compatibility(item_id, marketplace_id, compatibility_properties) ⇒ HTTP::Response
Retrieves the details of the individual items in an item group
115 116 117 118 119 120 121 122 123 |
# File 'lib/ebay/browse.rb', line 115 def check_compatibility(item_id, marketplace_id, compatibility_properties) url = build_url('item', item_id, 'check_compatibility') headers = build_headers headers.update('X-EBAY-C-MARKETPLACE-ID' => marketplace_id, 'CONTENT-TYPE' => 'application/json') body = JSON.dump('compatibilityProperties' => compatibility_properties) HTTP.headers(headers).post(url, body: body) end |
#get_item(item_id, **params) ⇒ HTTP::Response
Retrieves the details of a specific item
80 81 82 83 84 85 |
# File 'lib/ebay/browse.rb', line 80 def get_item(item_id, **params) url = build_url('item', item_id) params.update(item_id: item_id) HTTP.headers(build_headers).get(url, params: params) end |
#get_item_by_legacy_id(legacy_item_id, **params) ⇒ HTTP::Response
Retrieves the details of a specific item using its legacy item ID
92 93 94 95 96 97 |
# File 'lib/ebay/browse.rb', line 92 def get_item_by_legacy_id(legacy_item_id, **params) url = build_url('item', 'get_item_by_legacy_id') params.update(legacy_item_id: legacy_item_id) HTTP.headers(build_headers).get(url, params: params) end |
#get_items_by_item_group(item_group_id) ⇒ HTTP::Response
Retrieves the details of the individual items in an item group
103 104 105 106 107 108 |
# File 'lib/ebay/browse.rb', line 103 def get_items_by_item_group(item_group_id) url = build_url('item', 'get_items_by_item_group') params = { item_group_id: item_group_id } HTTP.headers(build_headers).get(url, params: params) end |
#get_shopping_cart ⇒ Object
129 130 131 |
# File 'lib/ebay/browse.rb', line 129 def get_shopping_cart raise 'not implemented' end |
#remove_item ⇒ Object
133 134 135 |
# File 'lib/ebay/browse.rb', line 133 def remove_item raise 'not implemented' end |
#search(**params) ⇒ HTTP::Response
Searches for eBay items by various query parameters and retrieves summaries of the item
57 58 59 60 |
# File 'lib/ebay/browse.rb', line 57 def search(**params) url = build_url('item_summary', 'search') HTTP.headers(build_headers).get(url, params: params) end |
#search_by_image(image, **params) ⇒ HTTP::Response
Searches for eBay items based on a image and retrieves their summaries
67 68 69 70 71 72 73 |
# File 'lib/ebay/browse.rb', line 67 def search_by_image(image, **params) url = build_url('item_summary', 'search_by_image') headers = build_headers.update('CONTENT-TYPE' => 'application/json') body = JSON.dump(image: image) HTTP.headers(headers).post(url, params: params, body: body) end |
#update_quantity ⇒ Object
137 138 139 |
# File 'lib/ebay/browse.rb', line 137 def update_quantity raise 'not implemented' end |