ebayr 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +28 -2
- data/lib/ebayr.rb +19 -6
- data/lib/ebayr/version.rb +1 -1
- data/test/test_ebayr.rb +3 -1
- metadata +10 -10
data/README.md
CHANGED
@@ -24,7 +24,7 @@ http://developer.ebay.com if you haven't already done so.
|
|
24
24
|
|
25
25
|
Next, you'll need to require Ebayr, and tell it to use your keys. You will also
|
26
26
|
need to generate an RUName, and get the key for that. (This is all standard
|
27
|
-
stuff - look at the eBay developer docs for details).
|
27
|
+
stuff - look at the [eBay developer docs][1] for details).
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
require 'ebayr'
|
@@ -76,11 +76,37 @@ config/initializers/ebayr.rb (or something), and put the configuration there. Of
|
|
76
76
|
course, you should probably not check in these files, if you're using a public
|
77
77
|
repository.
|
78
78
|
|
79
|
+
## Testing
|
80
|
+
|
81
|
+
When running test, you generally won't want to use up your API call-limit too
|
82
|
+
quickly, so it makes sense to stub out calls to the eBay API.
|
83
|
+
|
84
|
+
Ebayr has a small test helper library to help with this. It uses [Fakeweb][2]
|
85
|
+
for this, and just requires that you wrap your test code in a block, like this:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
require 'ebayr/test_helper'
|
89
|
+
class MyTest < Test::Unit::TestCase
|
90
|
+
include Ebayr::TestHelper
|
91
|
+
|
92
|
+
# A very contrived example...
|
93
|
+
def test_fetching_user_id
|
94
|
+
stub_ebay_call!(:GetUser, :UserID => "joebloggs") do
|
95
|
+
assert_equal("joebloggs", Ebayr.call(:GetUser)['UserID'])
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
101
|
+
You need to remember to include Fakeweb in your Gemfile, or Ebayr will complain.
|
102
|
+
|
79
103
|
## Contributing
|
80
104
|
|
81
105
|
1. Fork it
|
82
106
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
83
107
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
84
108
|
4. Push to the branch (`git push origin my-new-feature`)
|
85
|
-
|
86
109
|
5. Create new Pull Request
|
110
|
+
|
111
|
+
[1]: http://developer.ebay.com
|
112
|
+
[2]: http://fakeweb.rubyforge.org
|
data/lib/ebayr.rb
CHANGED
@@ -36,20 +36,33 @@ module Ebayr
|
|
36
36
|
!!sandbox
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
# Gets either ebay.com/ws or sandbox.ebay.com/ws, as appropriate, with
|
40
|
+
# "service" prepended. E.g.
|
41
|
+
#
|
42
|
+
# Ebayr.uri_prefix("blah") # => https://blah.ebay.com/ws
|
43
|
+
# Ebayr.uri_prefix # => https://api.ebay.com/ws
|
44
|
+
def self.uri_prefix(service = "api")
|
45
|
+
"https://#{service}#{sandbox ? ".sandbox" : ""}.ebay.com/ws"
|
41
46
|
end
|
42
47
|
|
43
|
-
# Gets the URI used for calls
|
44
|
-
def self.uri
|
45
|
-
URI::parse("#{uri_prefix}/api.dll")
|
48
|
+
# Gets the URI used for API calls (as a URI object)
|
49
|
+
def self.uri(*args)
|
50
|
+
URI::parse("#{uri_prefix(*args)}/api.dll")
|
46
51
|
end
|
47
52
|
|
53
|
+
# Gets the URI for eBay authorization/login. The session_id should be obtained
|
54
|
+
# via an API call to GetSessionID (be sure to use the right ru_name), and the
|
55
|
+
# ru_params can contain anything (they will be passed back to your app in the
|
56
|
+
# redirect from eBay upon successful login and authorization).
|
48
57
|
def self.authorization_uri(session_id, ru_params = {})
|
49
58
|
ruparams = CGI::escape(ru_params.map { |k, v| "#{k}=#{v}" }.join("&"))
|
50
|
-
URI::parse("#{uri_prefix}/eBayISAPI.dll?SignIn&RuName
|
59
|
+
URI::parse("#{uri_prefix("signin")}/eBayISAPI.dll?SignIn&RuName=#{ru_name}&SessId=#{session_id}&ruparams=#{ruparams}")
|
51
60
|
end
|
52
61
|
|
62
|
+
# A very, very simple XML serializer.
|
63
|
+
#
|
64
|
+
# Ebayr.xml("Hello!") # => "Hello!"
|
65
|
+
# Ebayr.xml({:foo=>"Bar"}) # => <foo>Bar</foo>
|
53
66
|
def self.xml(structure)
|
54
67
|
case structure
|
55
68
|
when Hash then structure.map { |k, v| "<#{k.to_s}>#{xml(v)}</#{k.to_s}>" }.join
|
data/lib/ebayr/version.rb
CHANGED
data/test/test_ebayr.rb
CHANGED
@@ -21,7 +21,9 @@ class TestEbayr < Test::Unit::TestCase
|
|
21
21
|
assert Ebayr.sandbox?
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def test_ebayr_uris
|
25
|
+
assert_equal "https://api.sandbox.ebay.com/ws", Ebayr.uri_prefix
|
26
|
+
assert_equal "https://blah.sandbox.ebay.com/ws", Ebayr.uri_prefix("blah")
|
25
27
|
assert_equal "https://api.sandbox.ebay.com/ws/api.dll", Ebayr.uri.to_s
|
26
28
|
end
|
27
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ebayr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-18 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &81893100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *81893100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &81892860 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *81892860
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fakeweb
|
38
|
-
requirement: &
|
38
|
+
requirement: &81892620 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *81892620
|
47
47
|
description: A tidy library for using the eBay Trading API with Ruby
|
48
48
|
email:
|
49
49
|
- jj@bjjb.org
|
@@ -75,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
segments:
|
77
77
|
- 0
|
78
|
-
hash:
|
78
|
+
hash: -317667633
|
79
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
80
|
none: false
|
81
81
|
requirements:
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
segments:
|
86
86
|
- 0
|
87
|
-
hash:
|
87
|
+
hash: -317667633
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
90
|
rubygems_version: 1.8.10
|