Class: Ebay::Browse
Overview
The Browse API allows your buyers to search eBay items by keyword and category. It also allows them to view and add items to their eBay shopping cart.
Instance Attribute Summary collapse
- #campaign_id ⇒ String readonly
- #country ⇒ String? readonly
- #market_id ⇒ 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, market_id: 'EBAY_US') ⇒ 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
#market_id=, #persistent, #sandbox, #use, #via
Constructor Details
#initialize(campaign_id:, reference_id: nil, country: nil, zip: nil, access_token: nil, market_id: 'EBAY_US') ⇒ Browse
Returns a Browse API request instance
49 50 51 52 53 54 55 56 |
# File 'lib/ebay/browse.rb', line 49 def initialize(campaign_id:, reference_id: nil, country: nil, zip: nil, access_token: nil, market_id: 'EBAY_US') @campaign_id = campaign_id @reference_id = reference_id @country = country @zip = zip @access_token = access_token @market_id = market_id end |
Instance Attribute Details
#campaign_id ⇒ String (readonly)
25 26 27 |
# File 'lib/ebay/browse.rb', line 25 def campaign_id @campaign_id end |
#country ⇒ String? (readonly)
31 32 33 |
# File 'lib/ebay/browse.rb', line 31 def country @country end |
#market_id ⇒ String? (readonly)
37 38 39 |
# File 'lib/ebay/browse.rb', line 37 def market_id @market_id end |
#reference_id ⇒ String? (readonly)
28 29 30 |
# File 'lib/ebay/browse.rb', line 28 def reference_id @reference_id end |
#zip ⇒ String? (readonly)
34 35 36 |
# File 'lib/ebay/browse.rb', line 34 def zip @zip end |
Instance Method Details
#access_token ⇒ String
Returns the application access token.
40 41 42 |
# File 'lib/ebay/browse.rb', line 40 def access_token @access_token ||= mint_access_token end |
#add_item ⇒ Object
130 131 132 |
# File 'lib/ebay/browse.rb', line 130 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
121 122 123 124 125 126 127 128 |
# File 'lib/ebay/browse.rb', line 121 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
86 87 88 89 90 91 |
# File 'lib/ebay/browse.rb', line 86 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
98 99 100 101 102 103 |
# File 'lib/ebay/browse.rb', line 98 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
109 110 111 112 113 114 |
# File 'lib/ebay/browse.rb', line 109 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
134 135 136 |
# File 'lib/ebay/browse.rb', line 134 def get_shopping_cart raise 'not implemented' end |
#remove_item ⇒ Object
138 139 140 |
# File 'lib/ebay/browse.rb', line 138 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
62 63 64 65 |
# File 'lib/ebay/browse.rb', line 62 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
72 73 74 75 76 77 78 79 |
# File 'lib/ebay/browse.rb', line 72 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
142 143 144 |
# File 'lib/ebay/browse.rb', line 142 def update_quantity raise 'not implemented' end |