ebayr 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ebayr.gemspec +1 -0
- data/lib/ebayr.rb +10 -1
- data/lib/ebayr/test_helper.rb +37 -0
- data/lib/ebayr/version.rb +1 -1
- data/test/test_ebayr.rb +19 -2
- metadata +20 -8
data/ebayr.gemspec
CHANGED
data/lib/ebayr.rb
CHANGED
@@ -36,9 +36,18 @@ module Ebayr
|
|
36
36
|
!!sandbox
|
37
37
|
end
|
38
38
|
|
39
|
+
def self.uri_prefix
|
40
|
+
"https://api#{sandbox ? ".sandbox" : ""}.ebay.com/ws"
|
41
|
+
end
|
42
|
+
|
39
43
|
# Gets the URI used for calls
|
40
44
|
def self.uri
|
41
|
-
URI::parse("
|
45
|
+
URI::parse("#{uri_prefix}/api.dll")
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.authorization_uri(session_id, ru_params = {})
|
49
|
+
ruparams = CGI::escape(ru_params.map { |k, v| "#{k}=#{v}" }.join("&"))
|
50
|
+
URI::parse("#{uri_prefix}/eBayISAPI.dll?SignIn&RuName=%s&SessId=#{session_id}&ruparams=#{ruparams}")
|
42
51
|
end
|
43
52
|
|
44
53
|
def self.xml(structure)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Ebayr
|
2
|
+
module TestHelper
|
3
|
+
@@success = Ebayr.xml(:Ack => "Success")
|
4
|
+
|
5
|
+
def self.included(mod)
|
6
|
+
begin
|
7
|
+
require 'fakeweb' unless const_defined?(:FakeWeb)
|
8
|
+
rescue LoadError
|
9
|
+
throw "Couldn't load fakeweb! Is it in your Gemfile?"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Allows you to stub out the calls within the given block. For example:
|
14
|
+
#
|
15
|
+
# def test_something
|
16
|
+
# stub_ebay_call!(:GeteBayOffficialTime, :Timestamp => "Yo") do
|
17
|
+
# assert Ebayr.call(:GeteBayOfficialTime) # => stubbed call
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
def stub_ebay_call!(call, content, &block)
|
21
|
+
content = Ebayr.xml(content) unless content.is_a?(String)
|
22
|
+
_allow_net_connect_ = FakeWeb.allow_net_connect?
|
23
|
+
FakeWeb.allow_net_connect = false
|
24
|
+
body = <<-XML
|
25
|
+
<#{call}Response>
|
26
|
+
#{Ebayr.xml(:Ack => "Success")}
|
27
|
+
#{content}
|
28
|
+
</#{call}Response>
|
29
|
+
XML
|
30
|
+
FakeWeb.register_uri( :any, Ebayr.uri, :body => body)
|
31
|
+
yield
|
32
|
+
FakeWeb.clean_registry
|
33
|
+
FakeWeb.allow_net_connect = _allow_net_connect_
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/ebayr/version.rb
CHANGED
data/test/test_ebayr.rb
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'ebayr'
|
3
|
+
require 'ebayr/test_helper'
|
3
4
|
|
4
5
|
class TestEbayr < Test::Unit::TestCase
|
6
|
+
include Ebayr::TestHelper
|
7
|
+
|
5
8
|
# If this passes without an exception, then we're ok.
|
6
9
|
def test_sanity
|
7
|
-
|
8
|
-
|
10
|
+
t = Time.now.to_s
|
11
|
+
stub_ebay_call!(:GeteBayOfficialTime, :Timestamp => t) do
|
12
|
+
result = Ebayr.call(:GeteBayOfficialTime)
|
13
|
+
assert_equal t, result['Timestamp']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_sandbox_reports_accurately
|
18
|
+
Ebayr.sandbox = false
|
19
|
+
assert !Ebayr.sandbox?
|
20
|
+
Ebayr.sandbox = true
|
21
|
+
assert Ebayr.sandbox?
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_ebayr_uri
|
25
|
+
assert_equal "https://api.sandbox.ebay.com/ws/api.dll", Ebayr.uri.to_s
|
9
26
|
end
|
10
27
|
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.2
|
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-03-
|
12
|
+
date: 2012-03-29 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &81104660 !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: *81104660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &81104440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,18 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *81104440
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: fakeweb
|
38
|
+
requirement: &81104210 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *81104210
|
36
47
|
description: A tidy library for using the eBay Trading API with Ruby
|
37
48
|
email:
|
38
49
|
- jj@bjjb.org
|
@@ -47,6 +58,7 @@ files:
|
|
47
58
|
- Rakefile
|
48
59
|
- ebayr.gemspec
|
49
60
|
- lib/ebayr.rb
|
61
|
+
- lib/ebayr/test_helper.rb
|
50
62
|
- lib/ebayr/version.rb
|
51
63
|
- test/test_ebayr.rb
|
52
64
|
homepage: http://jjbuckley.github.com/ebayr
|
@@ -63,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
75
|
version: '0'
|
64
76
|
segments:
|
65
77
|
- 0
|
66
|
-
hash:
|
78
|
+
hash: 758613683
|
67
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
80
|
none: false
|
69
81
|
requirements:
|
@@ -72,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
84
|
version: '0'
|
73
85
|
segments:
|
74
86
|
- 0
|
75
|
-
hash:
|
87
|
+
hash: 758613683
|
76
88
|
requirements: []
|
77
89
|
rubyforge_project:
|
78
90
|
rubygems_version: 1.8.10
|