ebay-ruby 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbadae6120cf8748d6f33d847c9746199717facc4734db1d81719a37393886bc
4
- data.tar.gz: d457466d75675c9fb698d9fa8feac2bb773d4a89be43f698ab22598bada96839
3
+ metadata.gz: d6e9d59b1d0ba42b7c825f8a29aac4e7f88765c6095c686739e03688d3e5e831
4
+ data.tar.gz: 2b7d7471e20d57190db24d2e3c192c61ee2acc0918a75e594575050008380608
5
5
  SHA512:
6
- metadata.gz: 98aea0105ee22960dece81289809e60048afbc5a68bd17bbf3ef2d54c6f0c139b5551b0f0e04293d49d471a2bd7d244d285f8fcc76a8f8b35eb5eaef05b6900c
7
- data.tar.gz: 769e216aa765b9850aa3192e82668bc9a79bc69e47b34e54799ecb897b4bbbb38a3750d237a841ce3f3abc2556b9b0f77017801ea97229bb3521053f52354d7e
6
+ metadata.gz: ab9807c80c509e6d276f881c026d9d0a4430e6f57a57ff259250cc5bf30d4fe2e33b08a48c8da356fc37db90d7bc1c3109a6c42d72b584f0a2af8a9be827cb35
7
+ data.tar.gz: 5829d5b8fd4c8aa189d0979be0c030c2109976217e88434afce15b26e123b557bcbb21764a7fbdb2e170984420e0bfeef69c7ff2fe8638ccf5a398243a64db02
data/README.md CHANGED
@@ -47,7 +47,7 @@ You can override the default format of an API when instantiating the request.
47
47
  ```ruby
48
48
  require 'json'
49
49
 
50
- # the Finding API returns XML by default
50
+ ### the Finding API returns XML by default
51
51
  request = Ebay.finding(response_data_format: 'JSON')
52
52
  response = request.find_items_by_keywords('iphone')
53
53
 
@@ -55,10 +55,11 @@ JSON.parse(response)
55
55
  ```
56
56
 
57
57
  ## Usage
58
-
59
58
  ### [Browse API]
60
59
 
61
- 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.
60
+ 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. The Browse API defaults to the eBay US marketplace but may be set during initialisation. The list of available marketplaces is [here](https://developer.ebay.com/api-docs/static/rest-request-components.html#marketpl).
61
+
62
+ **Note** The marketplace value needs to use an underscore between EBAY and the country code. The Finding and Merchandising APIs use a hyphen.
62
63
 
63
64
  ```ruby
64
65
  require 'ebay/browse'
@@ -66,7 +67,7 @@ require 'ebay/oauth/client_credentials_grant'
66
67
 
67
68
  access_token = Oauth::ClientCredentialsGrant.new.mint_access_token
68
69
  request = Ebay.browse(campaign_id: '123', country: 'US', zip: '19406',
69
- access_token: access_token)
70
+ access_token: access_token, market_id: 'EBAY_US')
70
71
  response = request.search(q: 'iphone')
71
72
  ```
72
73
 
@@ -103,6 +104,11 @@ request = Ebay::Shopping.new
103
104
  response = request.find_products('QueryKeywords' => 'tolkien')
104
105
  ```
105
106
 
107
+ ### Market Place
108
+ eBay has country bsaed marketplaces ( listed [here](https://developer.ebay.com/api-docs/static/rest-request-components.html#marketpl) ). By default, the eBay gem queries the US Marketplace. To change the marketplace, set the marketplace on the request object.
109
+
110
+ **Note** For the Browse API, the marketplace value needs to use an underscore between EBAY and the country code (EBAY_AU). The Finding and Merchandising APIs require a hyphen between EBAY and the country code ( EBAY-AU )
111
+
106
112
  ## Development
107
113
 
108
114
  To write requests and responses to a logger, use the logging feature:
data/lib/ebay/browse.rb CHANGED
@@ -33,6 +33,9 @@ module Ebay
33
33
  # @return [String,nil]
34
34
  attr_reader :zip
35
35
 
36
+ # @return [String,nil]
37
+ attr_reader :market_id
38
+
36
39
  # @return [String] the application access token
37
40
  def access_token
38
41
  @access_token ||= mint_access_token
@@ -43,12 +46,13 @@ module Ebay
43
46
  # @param [String] campaign_id
44
47
  # @param [String] reference_id
45
48
  # @param [String] access_token
46
- def initialize(campaign_id:, reference_id: nil, country: nil, zip: nil, access_token: nil)
49
+ def initialize(campaign_id:, reference_id: nil, country: nil, zip: nil, access_token: nil, market_id: 'EBAY_US')
47
50
  @campaign_id = campaign_id
48
51
  @reference_id = reference_id
49
52
  @country = country
50
53
  @zip = zip
51
54
  @access_token = access_token
55
+ @market_id = market_id
52
56
  end
53
57
 
54
58
  # Searches for eBay items by various query parameters and retrieves summaries of the item
@@ -147,6 +151,7 @@ module Ebay
147
151
 
148
152
  def build_headers
149
153
  { 'AUTHORIZATION' => "Bearer #{access_token}",
154
+ 'X-EBAY-C-MARKETPLACE-ID' => market_id,
150
155
  'X-EBAY-C-ENDUSERCTX' => build_ebay_enduser_context }
151
156
  end
152
157
 
data/lib/ebay/finding.rb CHANGED
@@ -143,7 +143,7 @@ module Ebay
143
143
  'SECURITY-APPNAME' => security_appname,
144
144
  'SERVICE-VERSION' => service_version }.update(payload).compact
145
145
 
146
- http.get(endpoint, params: params)
146
+ http.headers(headers).get(endpoint, params: params)
147
147
  end
148
148
  end
149
149
  end
@@ -90,7 +90,7 @@ module Ebay
90
90
  'RESPONSE-DATA-FORMAT' => response_data_format,
91
91
  'SERVICE-VERSION' => service_version }.compact
92
92
 
93
- http.post(endpoint, params: params, body: JSON.dump(payload))
93
+ http.headers(headers).post(endpoint, params: params, body: JSON.dump(payload))
94
94
  end
95
95
  end
96
96
  end
@@ -18,6 +18,18 @@ module Ebay
18
18
  # @return [HTTP::Client]
19
19
  attr_writer :http
20
20
 
21
+ # @!attribute [r] headers
22
+ # @return [Hash]
23
+ attr_accessor :headers
24
+
25
+ # Sets the eBay Market
26
+ #
27
+ # @param [String]
28
+ def market_id=(market_id)
29
+ @headers ||= {}
30
+ @headers['X-EBAY-SOA-GLOBAL-ID'] = market_id
31
+ end
32
+
21
33
  # @!attribute [r] http
22
34
  # @return [HTTP::Client]
23
35
  def http
@@ -59,7 +71,7 @@ module Ebay
59
71
  # @param [Array] proxy
60
72
  # @raise [HTTP::Request::Error] if HTTP proxy is invalid
61
73
  # @return [self]
62
- %i[timeout via through headers use].each do |method_name|
74
+ %i[timeout via through use].each do |method_name|
63
75
  define_method(method_name) do |*args, &block|
64
76
  self.http = http.send(method_name, *args, &block)
65
77
  self
data/lib/ebay/shopping.rb CHANGED
@@ -163,7 +163,7 @@ module Ebay
163
163
  'trackingid' => tracking_id,
164
164
  'trackingpartnercode' => tracking_partner_code }.compact
165
165
 
166
- http.post(endpoint, params: params, body: JSON.dump(payload))
166
+ http.headers(headers).post(endpoint, params: params, body: JSON.dump(payload))
167
167
  end
168
168
  end
169
169
  end
data/lib/ebay/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ebay
4
- VERSION = '0.3.4'
4
+ VERSION = '0.3.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebay-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-22 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http