agent_cooper 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ Agent Cooper
2
+ ======
3
+
4
+ Agent Cooper is a minimalistic, Nokogiri-based Ruby wrapper to the [eBay Web Services API](http://developer.ebay.com/).
5
+
6
+ Currently the following eBay APIs are supported:
7
+ - [Finding API](http://developer.ebay.com/products/finding/)
8
+ - [Shopping API](http://developer.ebay.com/products/shopping/)
9
+ - [Merchandising API](http://developer.ebay.com/products/merchandising/)
10
+
11
+ Usage
12
+ -----
13
+ Set up.
14
+
15
+ AgentCooper::Request::APP_ID = YOUR_APP_ID
16
+
17
+ Initialize a request
18
+
19
+ request = AgentCooper::Finder.new
20
+ request = AgentCooper::Shopper.new
21
+ request = AgentCooper::Merchandiser.new
22
+
23
+ Build request params.
24
+
25
+ request << {
26
+ 'OPERATION-NAME' => 'findItemsByKeywords',
27
+ 'keywords' => 'harry potter'
28
+ }
29
+
30
+ Get a response.
31
+
32
+ response = request.get
33
+
34
+ Response API allows one to utilize the pure goodness of Nokogiri:
35
+
36
+ response.xml.css("Item > Title").each do |title|
37
+ some business value
38
+ end
39
+
40
+ response.xml.xpath("//Item")
41
+
42
+ Specify a particular eBay locale (defaults to US):
43
+
44
+ AgentCooper::Shopper.new(:locale => :fr)
45
+
46
+ ----
47
+
48
+ Based on papercavalier's [sucker](http://github.com/papercavalier/sucker).
@@ -4,6 +4,8 @@ module AgentCooper
4
4
  HOST = 'http://svcs.ebay.com/services/search/FindingService/v1'
5
5
  VERSION = '1.9.0'
6
6
 
7
+ protected
8
+
7
9
  def options
8
10
  {
9
11
  'SECURITY-APPNAME' => APP_ID,
@@ -36,6 +36,10 @@ class Request
36
36
  @locale ||= :us
37
37
  end
38
38
 
39
+ def locale_code
40
+ LOCALE_CODES[locale]
41
+ end
42
+
39
43
  def get
40
44
  response = HTTParty.get(uri)
41
45
  Response.new(response)
@@ -14,6 +14,10 @@ class Response
14
14
  response.code
15
15
  end
16
16
 
17
+ def valid?
18
+ code == 200
19
+ end
20
+
17
21
  def xml
18
22
  @xml ||= Nokogiri::XML(body)
19
23
  end
@@ -6,16 +6,12 @@ module AgentCooper
6
6
 
7
7
  protected
8
8
 
9
- def site_id
10
- LOCALE_CODES[locale]
11
- end
12
-
13
9
  def options
14
10
  {
15
11
  'APPID' => APP_ID,
16
12
  'RESPONSEENCODING' => ENCODING,
17
13
  'VERSION' => VERSION,
18
- 'SITEID' => site_id
14
+ 'SITEID' => locale_code
19
15
  }.merge(parameters)
20
16
  end
21
17
 
@@ -1,3 +1,3 @@
1
1
  module AgentCooper
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agent_cooper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Closner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-22 00:00:00 -07:00
18
+ date: 2011-05-24 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -191,8 +191,8 @@ extra_rdoc_files: []
191
191
  files:
192
192
  - .gitignore
193
193
  - Gemfile
194
+ - README.md
194
195
  - Rakefile
195
- - VERSION
196
196
  - agent_cooper.gemspec
197
197
  - features/finder.feature
198
198
  - features/merchandiser.feature
data/VERSION DELETED
@@ -1,3 +0,0 @@
1
- module AgentCooper
2
- VERSION = "0.0.1"
3
- end