ebay-finding-api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ebay/finding/api.rb +1 -0
- data/lib/ebay/finding/api/client.rb +17 -3
- data/lib/ebay/finding/api/error.rb +7 -0
- data/lib/ebay/finding/api/response.rb +5 -1
- data/lib/ebay/finding/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 138cd0fdefa75ca5ed2505554c22090351a6564a97ace1174011438d85b1b8d9
|
4
|
+
data.tar.gz: 51ac371b1fcc262f8b1b8ad66ac8dbcb26c2d45e635dd1e091f4badf81a81e80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae88581f2067bb13e4d2e7ded6fcfec7902ebc1a26eb0010a4996ab1ab7a9fe4b53155727ad04a98017d25974976354c8d2b8e51656f28430081aec58faccc62
|
7
|
+
data.tar.gz: 12fb3cbe62c5272951104a588c1756b3bf06256abb9f688f33877fa7651262ec9f8008cf8952b30d4465ac5f7767d2b47d7507d1e96daacb1076076210d73f20
|
data/lib/ebay/finding/api.rb
CHANGED
@@ -2,19 +2,33 @@ module Ebay::Finding::Api
|
|
2
2
|
PRODUCTION_ENDPOINT = "https://svcs.ebay.com"
|
3
3
|
SANDBOX_ENDPOINT = "https://svcs.sandbox.ebay.com"
|
4
4
|
SERVICE_VERSION = "1.13.0"
|
5
|
+
PRODUCT_TYPES = %w(ISBN UPC EAN ReferenceID)
|
5
6
|
|
6
7
|
class Client
|
7
8
|
def initialize(app_id, sandbox = true)
|
8
9
|
@app_id = app_id
|
9
10
|
@sandbox = sandbox
|
11
|
+
@base_options = { "SECURITY-APPNAME" => @app_id, "SERVICE-VERSION" => SERVICE_VERSION, "REST-PAYLOAD" => "TRUE",
|
12
|
+
"RESPONSE-DATA-FORMAT" => "JSON" }
|
10
13
|
end
|
11
14
|
|
12
15
|
def find_items_by_keywords(keyword)
|
13
16
|
operation_name = "findItemsByKeywords"
|
14
|
-
options =
|
15
|
-
"SECURITY-APPNAME" => @app_id, "RESPONSE-DATA-FORMAT" => "JSON", "keywords" => keyword }
|
17
|
+
options = @base_options.merge("OPERATION-NAME" => operation_name, "keywords" => keyword)
|
16
18
|
|
17
|
-
Response.new(operation_name, connection.get("/
|
19
|
+
Response.new(operation_name, connection.get("/services/search/FindingService/v1", options))
|
20
|
+
end
|
21
|
+
|
22
|
+
def find_items_by_product(type, product_id)
|
23
|
+
operation_name = "findItemsByProduct"
|
24
|
+
|
25
|
+
unless PRODUCT_TYPES.include? type
|
26
|
+
raise ArgumentError.new("You need to pass string 'ISBN', 'UPC', 'EAN' or 'ReferenceID' to first argument")
|
27
|
+
end
|
28
|
+
options = @base_options.merge("OPERATION-NAME" => operation_name, "productId.@type" => type,
|
29
|
+
"productId" => product_id)
|
30
|
+
|
31
|
+
Response.new(operation_name, connection.get("/services/search/FindingService/v1", options))
|
18
32
|
end
|
19
33
|
|
20
34
|
private
|
@@ -10,7 +10,11 @@ module Ebay::Finding::Api
|
|
10
10
|
def items
|
11
11
|
return [] unless success?
|
12
12
|
|
13
|
-
|
13
|
+
result = JSON.parse(@response.body)["#{@key_name}Response"].first["searchResult"].first
|
14
|
+
|
15
|
+
return [] if result["@count"] === "0"
|
16
|
+
|
17
|
+
@items ||= result["item"]
|
14
18
|
end
|
15
19
|
|
16
20
|
def success?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ebay-finding-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- camelmasa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- ebay-finding-api.gemspec
|
86
86
|
- lib/ebay/finding/api.rb
|
87
87
|
- lib/ebay/finding/api/client.rb
|
88
|
+
- lib/ebay/finding/api/error.rb
|
88
89
|
- lib/ebay/finding/api/response.rb
|
89
90
|
- lib/ebay/finding/api/version.rb
|
90
91
|
homepage: https://github.com/camelmasa/ebay-finding-api
|