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.
Instance Attribute Summary collapse
- #campaign_id ⇒ String readonly
- #country ⇒ String? readonly
- #reference_id ⇒ String? readonly
- #zip ⇒ String? readonly
Attributes included from Requestable
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 Requestable
Constructor Details
#initialize(campaign_id:, reference_id: nil, country: nil, zip: nil, access_token: nil) ⇒ Browse
Returns a Browse API request instance
42 43 44 45 46 47 48 49 |
# File 'lib/ebay/browse.rb', line 42 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)
21 22 23 |
# File 'lib/ebay/browse.rb', line 21 def campaign_id @campaign_id end |
#country ⇒ String? (readonly)
27 28 29 |
# File 'lib/ebay/browse.rb', line 27 def country @country end |
#reference_id ⇒ String? (readonly)
24 25 26 |
# File 'lib/ebay/browse.rb', line 24 def reference_id @reference_id end |
#zip ⇒ String? (readonly)
30 31 32 |
# File 'lib/ebay/browse.rb', line 30 def zip @zip end |
Instance Method Details
#access_token ⇒ String
Returns the application access token.
33 34 35 |
# File 'lib/ebay/browse.rb', line 33 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 = params.merge(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 = params.merge(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
56 57 58 59 |
# File 'lib/ebay/browse.rb', line 56 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
66 67 68 69 70 71 72 73 |
# File 'lib/ebay/browse.rb', line 66 def search_by_image(image, params = {}) url = build_url('item_summary', 'search_by_image') headers = build_headers.update('CONTENT-TYPE' => 'application/json') encoded_string = Base64.encode64(image.read) body = JSON.dump(image: encoded_string) 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 |