ebayr 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4c809790d016f7a4df67b0268dfdeb45dff52846
4
+ data.tar.gz: 1aa1c7a2830a9e9cb6d074a80fd592bc48a1549e
5
+ SHA512:
6
+ metadata.gz: 92df7032f929f320713946267ea7efa0267bc0bba6f742d1846b2c477f82b536cf60f604bf749ff66d8eeb29fb1fc44e286423d311a12580e27198e190b59111
7
+ data.tar.gz: d1593399ee7398d3f275f9c370ba1048a1ea1d3b9f05e22beb2cd977ed5682071346a4215479c4a044a7b34c6340a3f8c8dd642d485d4fa5766c50a8c1291c07
data/README.md CHANGED
@@ -58,6 +58,12 @@ To use an authorized user's key, pass in an `auth_token` parameter
58
58
  Ebayr.call(:GetOrders, :auth_token => "another-ebay-auth-token")
59
59
  ```
60
60
 
61
+ Use the input array to add to the body of the call
62
+ ```ruby
63
+ # Adds: "<a>1</a><a><b>1</b><b>2</b></a>" to the ebay request.
64
+ args = [{ :a => 1 }, { :a => [{:b => 1 }, { :b => 2 }] }]
65
+ Ebayr::Request.new(:Blah, :input => args)
66
+ ```
61
67
 
62
68
  ### Configuration
63
69
 
data/ebayr.gemspec CHANGED
@@ -19,9 +19,14 @@ command-line client which aids integration into other projects.
19
19
  gem.test_files = gem.files.grep(%r{^test/})
20
20
  gem.name = "ebayr"
21
21
  gem.require_paths = ["lib"]
22
- gem.version = "0.0.7"
23
- gem.add_dependency 'activesupport'
22
+ gem.version = "0.0.8"
23
+ if RUBY_VERSION < "1.9"
24
+ gem.add_dependency 'i18n', '~> 0.6.11'
25
+ gem.add_dependency 'activesupport', '~> 3.2'
26
+ gem.add_development_dependency 'minitest'
27
+ else
28
+ gem.add_dependency 'activesupport', '~> 4.0'
29
+ end
24
30
  gem.add_development_dependency 'rake'
25
31
  gem.add_development_dependency 'fakeweb'
26
- gem.add_development_dependency 'minitest'
27
32
  end
data/lib/ebayr.rb CHANGED
@@ -76,6 +76,9 @@ module Ebayr
76
76
  self.logger = Logger.new(STDOUT)
77
77
  self.logger.level = Logger::INFO
78
78
 
79
+ mattr_accessor :debug
80
+ self.debug = false
81
+
79
82
  # Gets either ebay.com/ws or sandbox.ebay.com/ws, as appropriate, with
80
83
  # "service" prepended. E.g.
81
84
  #
data/lib/ebayr/request.rb CHANGED
@@ -17,7 +17,11 @@ module Ebayr #:nodoc:
17
17
  @compatability_level = (options.delete(:compatability_level) || self.compatability_level).to_s
18
18
  @http_timeout = (options.delete(:http_timeout) || 60).to_i
19
19
  # Remaining options are converted and used as input to the call
20
- @input = self.class.serialize_input(options)
20
+ @input = options.delete(:input) || options
21
+ end
22
+
23
+ def input_xml
24
+ self.class.xml(@input)
21
25
  end
22
26
 
23
27
  # Gets the path to which this request will be posted
@@ -46,7 +50,7 @@ module Ebayr #:nodoc:
46
50
  <RequesterCredentials>
47
51
  <eBayAuthToken>#{@auth_token}</eBayAuthToken>
48
52
  </RequesterCredentials>
49
- #{self.class.xml(@input)}
53
+ #{input_xml}
50
54
  </#{@command}Request>
51
55
  XML
52
56
  end
@@ -57,6 +61,9 @@ module Ebayr #:nodoc:
57
61
  http = Net::HTTP.new(@uri.host, @uri.port)
58
62
  http.read_timeout = @http_timeout
59
63
 
64
+ # Output request XML if debug flag is set
65
+ puts body if debug == true
66
+
60
67
  if @uri.port == 443
61
68
  http.use_ssl = true
62
69
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -84,22 +91,18 @@ module Ebayr #:nodoc:
84
91
  case structure
85
92
  when Hash then structure.map { |k, v| "<#{k.to_s}>#{xml(v)}</#{k.to_s}>" }.join
86
93
  when Array then structure.map { |v| xml(v) }.join
87
- else structure.to_s
94
+ else self.serialize_input(structure).to_s
88
95
  end
89
96
  end.join
90
97
  end
91
98
 
92
- # Prepares a hash of arguments for input to an eBay Trading API XML call.
99
+ # Prepares an argument for input to an eBay Trading API XML call.
93
100
  # * Times are converted to ISO 8601 format
94
- def self.serialize_input(args)
95
- result = {}
96
- args.each do |k, v|
97
- result[k] = case v
98
- when Time then v.to_time.utc.iso8601
99
- else v
100
- end
101
+ def self.serialize_input(input)
102
+ case input
103
+ when Time then input.to_time.utc.iso8601
104
+ else input
101
105
  end
102
- result
103
106
  end
104
107
 
105
108
  # Converts a command like get_ebay_offical_time to GeteBayOfficialTime
@@ -3,10 +3,11 @@ require 'test_helper'
3
3
  require 'ebayr/request'
4
4
 
5
5
  describe Ebayr::Request do
6
+
6
7
  describe "serializing input" do
7
8
  it "converts times" do
8
- result = Ebayr::Request.serialize_input("Time" => Time.utc(2010, 'oct', 31, 03, 15))
9
- result['Time'].must_equal "2010-10-31T03:15:00Z"
9
+ result = Ebayr::Request.serialize_input(Time.utc(2010, 'oct', 31, 03, 15))
10
+ result.must_equal "2010-10-31T03:15:00Z"
10
11
  end
11
12
  end
12
13
 
@@ -16,6 +17,19 @@ describe Ebayr::Request do
16
17
  end
17
18
  end
18
19
 
20
+ describe "arrays" do
21
+ it "converts multiple arguments in new function" do
22
+ args = [{ :a => 1 }, { :a => [{:b => 1 }, { :b => 2 }] }]
23
+ Ebayr::Request.new(:Blah, :input => args).input_xml.must_equal '<a>1</a><a><b>1</b><b>2</b></a>'
24
+ end
25
+
26
+ it "converts times" do
27
+ args = [{ :Time => Time.utc(2010, 'oct', 31, 03, 15)}]
28
+ result = Ebayr::Request.new(:Blah, args).input_xml
29
+ result.must_equal "<Time>2010-10-31T03:15:00Z</Time>"
30
+ end
31
+ end
32
+
19
33
  describe "xml" do
20
34
  def request(*args)
21
35
  Ebayr::Request.xml(*args)
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebayr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 0.0.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - JJ Buckley
@@ -10,88 +9,62 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-11-27 00:00:00.000000000 Z
12
+ date: 2015-05-07 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - "~>"
21
19
  - !ruby/object:Gem::Version
22
- version: '0'
20
+ version: '4.0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - "~>"
29
26
  - !ruby/object:Gem::Version
30
- version: '0'
27
+ version: '4.0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: fakeweb
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- - !ruby/object:Gem::Dependency
64
- name: minitest
65
- requirement: !ruby/object:Gem::Requirement
66
- none: false
67
45
  requirements:
68
- - - ! '>='
46
+ - - ">="
69
47
  - !ruby/object:Gem::Version
70
48
  version: '0'
71
49
  type: :development
72
50
  prerelease: false
73
51
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
52
  requirements:
76
- - - ! '>='
53
+ - - ">="
77
54
  - !ruby/object:Gem::Version
78
55
  version: '0'
79
- description: ! 'eBayR is a gem that makes it (relatively) easy to use the eBay Trading
80
- API from
81
-
56
+ description: |
57
+ eBayR is a gem that makes it (relatively) easy to use the eBay Trading API from
82
58
  Ruby. Includes a self-contained XML parser, a flexible callback system, and a
83
-
84
59
  command-line client which aids integration into other projects.
85
-
86
- '
87
60
  email:
88
61
  - jj@bjjb.org
89
62
  executables: []
90
63
  extensions: []
91
64
  extra_rdoc_files: []
92
65
  files:
93
- - .gitignore
94
- - .travis.yml
66
+ - ".gitignore"
67
+ - ".travis.yml"
95
68
  - Gemfile
96
69
  - Guardfile
97
70
  - LICENSE
@@ -112,27 +85,26 @@ files:
112
85
  homepage: http://github.com/bjjb/ebayr
113
86
  licenses:
114
87
  - MIT
88
+ metadata: {}
115
89
  post_install_message:
116
90
  rdoc_options: []
117
91
  require_paths:
118
92
  - lib
119
93
  required_ruby_version: !ruby/object:Gem::Requirement
120
- none: false
121
94
  requirements:
122
- - - ! '>='
95
+ - - ">="
123
96
  - !ruby/object:Gem::Version
124
97
  version: '0'
125
98
  required_rubygems_version: !ruby/object:Gem::Requirement
126
- none: false
127
99
  requirements:
128
- - - ! '>='
100
+ - - ">="
129
101
  - !ruby/object:Gem::Version
130
102
  version: '0'
131
103
  requirements: []
132
104
  rubyforge_project:
133
- rubygems_version: 1.8.23
105
+ rubygems_version: 2.2.2
134
106
  signing_key:
135
- specification_version: 3
107
+ specification_version: 4
136
108
  summary: A tidy library for using the eBay Trading API with Ruby
137
109
  test_files:
138
110
  - test/ebayr/record_test.rb