ebay-ruby 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +22 -0
- data/README.md +75 -9
- data/lib/ebay-ruby.rb +2 -0
- data/lib/ebay.rb +3 -9
- data/lib/ebay/browse.rb +167 -0
- data/lib/ebay/config.rb +33 -8
- data/lib/ebay/finding.rb +144 -5
- data/lib/ebay/merchandising.rb +90 -5
- data/lib/ebay/oauth/client_credentials_grant.rb +59 -0
- data/lib/ebay/sandboxable.rb +24 -0
- data/lib/ebay/shopping.rb +163 -6
- data/lib/ebay/version.rb +1 -1
- metadata +73 -59
- data/.gitignore +0 -5
- data/.travis.yml +0 -15
- data/Gemfile +0 -2
- data/Rakefile +0 -9
- data/ebay-ruby.gemspec +0 -22
- data/lib/ebay/parser.rb +0 -15
- data/lib/ebay/product.rb +0 -9
- data/lib/ebay/product_metadata.rb +0 -9
- data/lib/ebay/request.rb +0 -35
- data/test/cassettes/finding.yml +0 -135
- data/test/cassettes/merchandising.yml +0 -93
- data/test/cassettes/product.yml +0 -101
- data/test/cassettes/product_metadata.yml +0 -96
- data/test/cassettes/shopping.yml +0 -125
- data/test/helper.rb +0 -10
- data/test/test_finding.rb +0 -36
- data/test/test_merchandising.rb +0 -34
- data/test/test_parser.rb +0 -25
- data/test/test_product.rb +0 -38
- data/test/test_product_metadata.rb +0 -36
- data/test/test_shopping.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18523b3ec4ff1f6d4bac8c6dbeb4d2570ece325e963ed4540aded51bcbef8be9
|
4
|
+
data.tar.gz: 4db3fedd2023ff5c49d0a6e1369188325d1e61b798dc77b63c1cd51ee9b3baa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e6cf632c7006f51393878a5af01057e9cec95678ddc7e7565e528f4c015ec2a19a70e55b1ddd8f67e4a5f5e40e00e8e2c858811178faf214084f65f934bdcf3
|
7
|
+
data.tar.gz: 138a8d6fa3f982ed664cc4340ea9d47802fb4a4c8b3cc9dd5fcbfee050198c4916bda43521947831e78422bee8fd06f7db979e8934b998e7bfd153fb16151995
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) Hakan Ensari
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,16 +1,82 @@
|
|
1
1
|
# ebay-ruby
|
2
2
|
|
3
|
-
|
3
|
+
[![Build](https://github.com/hakanensari/ebay-ruby/workflows/build/badge.svg)](https://github.com/hakanensari/ebay-ruby/actions)
|
4
|
+
|
5
|
+
A Ruby wrapper to the [eBay APIs]
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Buy APIs
|
10
|
+
|
11
|
+
Retrieve purchasable items, check out, then track orders without visiting the eBay site.
|
12
|
+
|
13
|
+
#### [Browse API]
|
14
|
+
|
15
|
+
Using the Browse API, you can create a rich selection of items for your buyers to browse with keyword and category searches. You can 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.
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'ebay/browse'
|
19
|
+
require 'ebay/oauth/client_credentials_grant'
|
20
|
+
|
21
|
+
access_token = Oauth::ClientCredentialsGrant.new.mint_access_token
|
22
|
+
request = Ebay::Browse.new(campaign_id: '123',
|
23
|
+
country: 'US',
|
24
|
+
zip: '19406',
|
25
|
+
access_token: access_token)
|
26
|
+
response = @request.search(q: 'iphone')
|
27
|
+
|
28
|
+
JSON.parse(response)
|
29
|
+
```
|
30
|
+
|
31
|
+
### Traditional Searching APIs
|
32
|
+
|
33
|
+
Search eBay; build search and browse experiences.
|
34
|
+
|
35
|
+
#### [Finding API]
|
36
|
+
|
37
|
+
The Finding API provides programmatic access to the next generation search capabilities on the eBay platform. It lets you search and browse for items listed on eBay and provides useful metadata to refine searches and enhance the search experience.
|
4
38
|
|
5
39
|
```ruby
|
6
40
|
require 'ebay/finding'
|
7
41
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
'keywords' => 'minimalism'
|
13
|
-
}
|
14
|
-
parser = finding.get(query: params)
|
15
|
-
parser.parse
|
42
|
+
request = Ebay::Finding.new
|
43
|
+
response = request.find_items_by_keywords('iphone')
|
44
|
+
|
45
|
+
JSON.parse(response)
|
16
46
|
```
|
47
|
+
|
48
|
+
### Traditional Shopping/Buying APIs
|
49
|
+
|
50
|
+
Retrieve public items and user data to create shopping and marketing applications.
|
51
|
+
|
52
|
+
#### [Shopping API]
|
53
|
+
|
54
|
+
The eBay Shopping API makes it easy to search for things on eBay.
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
require 'ebay/shopping'
|
58
|
+
|
59
|
+
request = Ebay::Finding.new
|
60
|
+
response = request.find_products('QueryKeywords' => 'tolkien')
|
61
|
+
|
62
|
+
JSON.parse(response)
|
63
|
+
```
|
64
|
+
|
65
|
+
#### [Merchandising API]
|
66
|
+
|
67
|
+
The Merchandising API provides item and product recommendations that can be used to cross-sell and up-sell eBay items to buyers.
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require 'ebay/merchandising'
|
71
|
+
|
72
|
+
request = Ebay::Finding.new
|
73
|
+
response = request.get_most_watched_items
|
74
|
+
|
75
|
+
JSON.parse(response)
|
76
|
+
```
|
77
|
+
|
78
|
+
[eBay APIs]: https://developer.ebay.com/docs
|
79
|
+
[Browse API]: https://developer.ebay.com/api-docs/buy/browse/static/overview.html
|
80
|
+
[Finding API]: https://developer.ebay.com/Devzone/finding/Concepts/FindingAPIGuide.html
|
81
|
+
[Shopping API]: https://developer.ebay.com/Devzone/shopping/docs/Concepts/ShoppingAPIGuide.html
|
82
|
+
[Merchandising API]: https://developer.ebay.com/Devzone/merchandising/docs/Concepts/merchandisingAPIGuide.html
|
data/lib/ebay-ruby.rb
CHANGED
data/lib/ebay.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ebay/browse'
|
2
4
|
require 'ebay/finding'
|
3
5
|
require 'ebay/merchandising'
|
4
|
-
require 'ebay/product'
|
5
|
-
require 'ebay/product_metadata'
|
6
6
|
require 'ebay/shopping'
|
7
|
-
|
8
|
-
module Ebay
|
9
|
-
def self.configure
|
10
|
-
yield Config
|
11
|
-
end
|
12
|
-
end
|
data/lib/ebay/browse.rb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'http'
|
4
|
+
|
5
|
+
require 'ebay/config'
|
6
|
+
require 'ebay/sandboxable'
|
7
|
+
|
8
|
+
module Ebay
|
9
|
+
# Using the Browse API, you can create a rich selection of items for your
|
10
|
+
# buyers to browse with keyword and category searches. It also provides the
|
11
|
+
# ability to eBay members to add items and change the quantity of an item in
|
12
|
+
# their eBay shopping cart as well as view the contents of their eBay cart.
|
13
|
+
#
|
14
|
+
# @see https://developer.ebay.com/api-docs/buy/browse/overview.html
|
15
|
+
class Browse
|
16
|
+
include Sandboxable
|
17
|
+
|
18
|
+
SANDBOX_ENDPOINT = 'https://api.sandbox.ebay.com/buy/browse/v1'
|
19
|
+
PRODUCTION_ENDPOINT = 'https://api.ebay.com/buy/browse/v1'
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
attr_reader :campaign_id
|
23
|
+
|
24
|
+
# @return [String,nil]
|
25
|
+
attr_reader :reference_id
|
26
|
+
|
27
|
+
# @return [String,nil]
|
28
|
+
attr_reader :country
|
29
|
+
|
30
|
+
# @return [String,nil]
|
31
|
+
attr_reader :zip
|
32
|
+
|
33
|
+
# @return [String] the application access token
|
34
|
+
def access_token
|
35
|
+
@access_token ||= mint_access_token
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns a Browse API request instance
|
39
|
+
#
|
40
|
+
# @param [String] campaign_id
|
41
|
+
# @param [String] reference_id
|
42
|
+
# @param [String] access_token
|
43
|
+
def initialize(campaign_id:, reference_id: nil, country: nil, zip: nil,
|
44
|
+
access_token: nil)
|
45
|
+
@campaign_id = campaign_id
|
46
|
+
@reference_id = reference_id
|
47
|
+
@country = country
|
48
|
+
@zip = zip
|
49
|
+
@access_token = access_token
|
50
|
+
end
|
51
|
+
|
52
|
+
# Searches for eBay items by various query parameters and retrieves
|
53
|
+
# summaries of the item
|
54
|
+
#
|
55
|
+
# @param [Hash] params
|
56
|
+
# @return [HTTP::Response]
|
57
|
+
def search(**params)
|
58
|
+
url = build_url('item_summary', 'search')
|
59
|
+
HTTP.headers(build_headers).get(url, params: params)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Searches for eBay items based on a image and retrieves their summaries
|
63
|
+
#
|
64
|
+
# @param [String] image the Base64 string of the image
|
65
|
+
# @param [Hash] params
|
66
|
+
# @return [HTTP::Response]
|
67
|
+
def search_by_image(image, **params)
|
68
|
+
url = build_url('item_summary', 'search_by_image')
|
69
|
+
headers = build_headers.update('CONTENT-TYPE' => 'application/json')
|
70
|
+
body = JSON.dump(image: image)
|
71
|
+
|
72
|
+
HTTP.headers(headers).post(url, params: params, body: body)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Retrieves the details of a specific item
|
76
|
+
#
|
77
|
+
# @param [String] item_id
|
78
|
+
# @param [Hash] params
|
79
|
+
# @return [HTTP::Response]
|
80
|
+
def get_item(item_id, **params)
|
81
|
+
url = build_url('item', item_id)
|
82
|
+
params.update(item_id: item_id)
|
83
|
+
|
84
|
+
HTTP.headers(build_headers).get(url, params: params)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Retrieves the details of a specific item using its legacy item ID
|
88
|
+
#
|
89
|
+
# @param [String] legacy_item_id
|
90
|
+
# @param [Hash] params
|
91
|
+
# @return [HTTP::Response]
|
92
|
+
def get_item_by_legacy_id(legacy_item_id, **params)
|
93
|
+
url = build_url('item', 'get_item_by_legacy_id')
|
94
|
+
params.update(legacy_item_id: legacy_item_id)
|
95
|
+
|
96
|
+
HTTP.headers(build_headers).get(url, params: params)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Retrieves the details of the individual items in an item group
|
100
|
+
#
|
101
|
+
# @param [String] item_group_id
|
102
|
+
# @return [HTTP::Response]
|
103
|
+
def get_items_by_item_group(item_group_id)
|
104
|
+
url = build_url('item', 'get_items_by_item_group')
|
105
|
+
params = { item_group_id: item_group_id }
|
106
|
+
|
107
|
+
HTTP.headers(build_headers).get(url, params: params)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Retrieves the details of the individual items in an item group
|
111
|
+
#
|
112
|
+
# @param [String] item_id
|
113
|
+
# @param [String] marketplace_id
|
114
|
+
# @return [HTTP::Response]
|
115
|
+
def check_compatibility(item_id, marketplace_id, compatibility_properties)
|
116
|
+
url = build_url('item', item_id, 'check_compatibility')
|
117
|
+
headers = build_headers
|
118
|
+
headers.update('X-EBAY-C-MARKETPLACE-ID' => marketplace_id,
|
119
|
+
'CONTENT-TYPE' => 'application/json')
|
120
|
+
body = JSON.dump('compatibilityProperties' => compatibility_properties)
|
121
|
+
|
122
|
+
HTTP.headers(headers).post(url, body: body)
|
123
|
+
end
|
124
|
+
|
125
|
+
def add_item
|
126
|
+
raise 'not implemented'
|
127
|
+
end
|
128
|
+
|
129
|
+
def get_shopping_cart
|
130
|
+
raise 'not implemented'
|
131
|
+
end
|
132
|
+
|
133
|
+
def remove_item
|
134
|
+
raise 'not implemented'
|
135
|
+
end
|
136
|
+
|
137
|
+
def update_quantity
|
138
|
+
raise 'not implemented'
|
139
|
+
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
def build_url(*resources, operation)
|
144
|
+
endpoint = sandbox? ? SANDBOX_ENDPOINT : PRODUCTION_ENDPOINT
|
145
|
+
[endpoint, *resources, operation].join('/')
|
146
|
+
end
|
147
|
+
|
148
|
+
def build_headers
|
149
|
+
{ 'AUTHORIZATION' => "Bearer #{access_token}",
|
150
|
+
'X-EBAY-C-ENDUSERCTX' => build_ebay_enduser_context }
|
151
|
+
end
|
152
|
+
|
153
|
+
def build_ebay_enduser_context
|
154
|
+
{ 'affiliateCampaignId' => campaign_id,
|
155
|
+
'affiliateReferenceId' => reference_id,
|
156
|
+
'contextualLocation' => build_contextual_location }
|
157
|
+
.compact.map { |kv| kv.join('=') }.join(',')
|
158
|
+
end
|
159
|
+
|
160
|
+
def build_contextual_location
|
161
|
+
string = { 'country' => country, 'zip' => zip }
|
162
|
+
.compact.map { |kv| kv.join('=') }.join(',')
|
163
|
+
|
164
|
+
CGI.escape(string) if string
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
data/lib/ebay/config.rb
CHANGED
@@ -1,15 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Ruby wrapper to the eBay APIs
|
1
4
|
module Ebay
|
5
|
+
# Configures credentials for accessing the eBay APIs
|
6
|
+
# @yield {Config}
|
7
|
+
def self.configure
|
8
|
+
yield Config
|
9
|
+
end
|
10
|
+
|
11
|
+
# Stores credentials for accessing the eBay APIs
|
2
12
|
module Config
|
3
13
|
class << self
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
14
|
+
# @!attribute [rw] app_id
|
15
|
+
# @return [String] unique identifier for the application
|
16
|
+
# @note This attribute defaults to the `EBAY_APP_ID` environment variable.
|
17
|
+
def app_id
|
18
|
+
@app_id ||= ENV['EBAY_APP_ID']
|
19
|
+
end
|
20
|
+
|
21
|
+
# @!attribute [rw] dev_id
|
22
|
+
# @return [String] unique identifier for the developer's account
|
23
|
+
# @note This attribute defaults to the `EBAY_DEV_ID` environment variable.
|
24
|
+
def dev_id
|
25
|
+
@dev_id ||= ENV['EBAY_DEV_ID']
|
26
|
+
end
|
27
|
+
|
28
|
+
# @!attribute [rw] cert_id
|
29
|
+
# @return [String] certificate that authenticates the application when
|
30
|
+
# making API calls
|
31
|
+
# @note This attribute defaults to the `EBAY_CERT_ID` environment
|
32
|
+
# variable.
|
33
|
+
def cert_id
|
34
|
+
@cert_id ||= ENV['EBAY_CERT_ID']
|
12
35
|
end
|
36
|
+
|
37
|
+
attr_writer :app_id, :dev_id, :cert_id
|
13
38
|
end
|
14
39
|
end
|
15
40
|
end
|
data/lib/ebay/finding.rb
CHANGED
@@ -1,9 +1,148 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'http'
|
4
|
+
|
5
|
+
require 'ebay/config'
|
6
|
+
require 'ebay/sandboxable'
|
2
7
|
|
3
8
|
module Ebay
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
9
|
+
# The Finding API lets you search for and browse items listed on eBay and
|
10
|
+
# provides useful metadata to refine searches.
|
11
|
+
#
|
12
|
+
# @see https://developer.ebay.com/Devzone/finding/Concepts/MakingACall.html
|
13
|
+
# @see https://developer.ebay.com/Devzone/finding/CallRef/index.html
|
14
|
+
class Finding
|
15
|
+
include Sandboxable
|
16
|
+
|
17
|
+
SANDBOX_ENDPOINT = 'https://svcs.sandbox.ebay.com/services/search/FindingService/v1'
|
18
|
+
PRODUCTION_ENDPOINT = 'https://svcs.ebay.com/services/search/FindingService/v1'
|
19
|
+
|
20
|
+
# @return [String, nil]
|
21
|
+
attr_reader :global_id
|
22
|
+
|
23
|
+
# @return [String, nil]
|
24
|
+
attr_reader :message_encoding
|
25
|
+
|
26
|
+
# @return [String, nil]
|
27
|
+
attr_reader :response_data_format
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
attr_reader :security_appname
|
31
|
+
|
32
|
+
# @return [String, nil]
|
33
|
+
attr_reader :service_version
|
34
|
+
|
35
|
+
# Returns a Finding API request instance
|
36
|
+
#
|
37
|
+
# @see https://developer.ebay.com/Devzone/finding/Concepts/SiteIDToGlobalID.html
|
38
|
+
# @param [String] global_id
|
39
|
+
# @param [String] message_encoding
|
40
|
+
# @param [String] response_data_format
|
41
|
+
# @param [String] security_appname
|
42
|
+
# @param [String] service_version
|
43
|
+
def initialize(global_id: nil, message_encoding: nil,
|
44
|
+
response_data_format: 'JSON',
|
45
|
+
security_appname: Config.app_id, service_version: nil)
|
46
|
+
@global_id = global_id
|
47
|
+
@message_encoding = message_encoding
|
48
|
+
@response_data_format = response_data_format
|
49
|
+
@security_appname = security_appname
|
50
|
+
@service_version = service_version
|
51
|
+
end
|
52
|
+
|
53
|
+
# Searches for items whose listings are completed
|
54
|
+
#
|
55
|
+
# @param [Hash] payload
|
56
|
+
# @return [HTTP::Response]
|
57
|
+
def find_completed_items(payload = {})
|
58
|
+
request('findCompletedItems', payload)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Searches for items by category or keyword or both
|
62
|
+
#
|
63
|
+
# @param [Hash] payload
|
64
|
+
# @return [HTTP::Response]
|
65
|
+
def find_items_advanced(payload = {})
|
66
|
+
request('findItemsAdvanced', payload)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Searches for items using specific eBay category ID numbers
|
70
|
+
#
|
71
|
+
# @param [Hash] payload
|
72
|
+
# @return [HTTP::Response]
|
73
|
+
def find_items_by_category(payload = {})
|
74
|
+
request('findItemsByCategory', payload)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Searches for items by a keyword query
|
78
|
+
#
|
79
|
+
# @param [String] keywords
|
80
|
+
# @param [Hash] payload
|
81
|
+
# @return [HTTP::Response]
|
82
|
+
def find_items_by_keywords(keywords, payload = {})
|
83
|
+
payload.update('keywords' => keywords)
|
84
|
+
request('findItemsByKeywords', payload)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Searches for items using specific eBay product values\
|
88
|
+
#
|
89
|
+
# @param [String] product_id
|
90
|
+
# @param [String] product_id_type
|
91
|
+
# @param [Hash] payload
|
92
|
+
# @return [HTTP::Response]
|
93
|
+
def find_items_by_product(product_id, product_id_type, payload = {})
|
94
|
+
payload.update('productId' => product_id,
|
95
|
+
'productId.@type' => product_id_type)
|
96
|
+
|
97
|
+
request('findItemsByProduct', payload)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Searches for items in the eBay store inventories
|
101
|
+
#
|
102
|
+
# @param [Hash] payload
|
103
|
+
# @return [HTTP::Response]
|
104
|
+
def find_items_in_ebay_stores(payload = {})
|
105
|
+
request('findItemsIneBayStores', payload)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Retrieves category and/or aspect histogram information for an eBay
|
109
|
+
# category
|
110
|
+
#
|
111
|
+
# @param [String] category_id
|
112
|
+
# @return [HTTP::Response]
|
113
|
+
def get_histograms(category_id)
|
114
|
+
request('getHistograms', 'categoryId' => category_id)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Retrieves commonly used words found in eBay titles, based on the words you
|
118
|
+
# supply
|
119
|
+
#
|
120
|
+
# @param [String] keywords
|
121
|
+
# @return [HTTP::Response]
|
122
|
+
def get_search_keywords_recommendation(keywords)
|
123
|
+
request('getSearchKeywordsRecommendation', 'keywords' => keywords)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Returns the current version of the service
|
127
|
+
#
|
128
|
+
# @return [HTTP::Response]
|
129
|
+
def get_version
|
130
|
+
request('getVersion')
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def request(operation, payload = {})
|
136
|
+
url = sandbox? ? SANDBOX_ENDPOINT : PRODUCTION_ENDPOINT
|
137
|
+
params = { 'GLOBAL-ID' => global_id,
|
138
|
+
'MESSAGE-ENCODING' => message_encoding,
|
139
|
+
'OPERATION-NAME' => operation,
|
140
|
+
'REQUEST-DATA-FORMAT' => 'JSON',
|
141
|
+
'RESPONSE-DATA-FORMAT' => response_data_format,
|
142
|
+
'SECURITY-APPNAME' => security_appname,
|
143
|
+
'SERVICE-VERSION' => service_version }.compact
|
144
|
+
|
145
|
+
HTTP.post(url, params: params, body: JSON.dump(payload))
|
146
|
+
end
|
8
147
|
end
|
9
148
|
end
|