ebay 0.8.0 → 1.1
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 +142 -95
- data/contrib/ebay_platform_notifications.txt +4 -0
- data/contrib/get_and_store_ebay_categories.rb +1 -1
- data/examples/add_item.rb +4 -4
- data/examples/get_account.rb +1 -1
- data/examples/get_account2.rb +2 -2
- data/examples/get_account3.rb +1 -1
- data/examples/get_categories.rb +4 -4
- data/examples/get_categories2.rb +4 -4
- data/examples/get_category_features.rb +2 -2
- data/examples/get_ebay_details.rb +1 -1
- data/examples/get_feedback.rb +5 -5
- data/examples/get_item.rb +3 -3
- data/examples/get_notification_preferences.rb +27 -20
- data/examples/get_notifications_usage.rb +8 -12
- data/examples/get_suggested_categories.rb +3 -4
- data/examples/revise_item.rb +2 -2
- data/examples/set_notification_preferences.rb +10 -10
- data/examples/verify_add_item.rb +4 -4
- data/lib/RequesterCredentialsHandler.rb +4 -4
- data/lib/eBay.rb +15056 -13585
- data/lib/eBayAPI.rb +18 -1
- data/lib/eBayDriver.rb +584 -375
- data/lib/eBayMappingRegistry.rb +31223 -0
- data/test/myCredentials.rb +6 -0
- data/test/tc_items.rb +1 -1
- data/test/tc_routing.rb +1 -1
- metadata +50 -43
data/README
CHANGED
@@ -1,95 +1,129 @@
|
|
1
|
+
=================
|
2
|
+
Welcome to eBay4R
|
3
|
+
=================
|
1
4
|
|
2
|
-
|
5
|
+
:Author: Garry Dolley
|
6
|
+
:Date: 03-28-2008
|
7
|
+
:Version: v1.1
|
8
|
+
:eBay API: 555
|
3
9
|
|
4
|
-
eBay4R is a Ruby wrapper for eBay's Web Services SOAP API (
|
10
|
+
eBay4R is a Ruby wrapper for eBay's Web Services SOAP API (v555). Emphasis is
|
5
11
|
on ease of use and small footprint.
|
6
12
|
|
7
13
|
Please report bugs and other problems, see "Author" section at the bottom.
|
8
14
|
|
9
|
-
Current
|
15
|
+
Current release can be downloaded from:
|
10
16
|
|
11
17
|
http://rubyforge.org/projects/ebay4r
|
12
18
|
|
19
|
+
The latest code is in the following Git repository:
|
13
20
|
|
14
|
-
|
21
|
+
git://github.com/up_the_irons/ebay4r.git
|
15
22
|
|
16
|
-
* SOAP4R library newer than v1.5.5. At the time of this writing, the latest
|
17
|
-
version was v1.5.5, which will not work. You have to get a snapshot that is
|
18
|
-
dated 11-06-2005 or newer. You can find development snapshots here:
|
19
23
|
|
20
|
-
|
24
|
+
Requirements
|
25
|
+
------------
|
21
26
|
|
22
|
-
|
23
|
-
|
27
|
+
* SOAP4R library v1.5.7 or newer. The specific version I'm using for testing
|
28
|
+
is soap4r-1.5.7.90.20070921.
|
24
29
|
|
25
|
-
http://dev.ctor.org/download/archive/soap4r-20051106.tar.gz
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
box, however, I had to install the newer snapshot. Go figure, I don't
|
30
|
-
know what the diff is...
|
31
|
-
|
32
|
-
|
33
|
-
== Optionals
|
31
|
+
Optionals
|
32
|
+
---------
|
34
33
|
|
35
34
|
* RubyGems
|
36
35
|
|
37
36
|
|
38
|
-
|
37
|
+
Installation
|
38
|
+
------------
|
39
39
|
|
40
|
-
|
40
|
+
tar/gzip
|
41
|
+
~~~~~~~~
|
41
42
|
|
42
43
|
Just unzip the archive anywhere you like, and see "Getting Started" below
|
43
44
|
(you will need to add the ebay4r/lib path to your $RUBYLIB environment
|
44
45
|
variable)
|
45
46
|
|
46
|
-
|
47
|
+
RubyGems
|
48
|
+
~~~~~~~~
|
47
49
|
|
48
|
-
* To install a gem you already downloaded
|
50
|
+
* To install a gem you already downloaded::
|
49
51
|
|
50
52
|
gem install ebay-<version>.gem
|
51
53
|
|
52
|
-
* For the latest release with no fuss (previous download not required)
|
54
|
+
* For the latest release with no fuss (previous download not required)::
|
53
55
|
|
54
56
|
gem install -r ebay
|
55
57
|
|
56
|
-
|
58
|
+
Git
|
59
|
+
~~~
|
60
|
+
|
61
|
+
You can download the latest and greatest code using Git, just type::
|
62
|
+
|
63
|
+
git clone git://github.com/up_the_irons/ebay4r.git
|
64
|
+
|
65
|
+
|
66
|
+
Important Note about Using eBay4R and Ruby on Rails
|
67
|
+
---------------------------------------------------
|
68
|
+
|
69
|
+
If you installed SOAP4R as a gem you must put the following two lines at the
|
70
|
+
very top of your config/environment.rb::
|
71
|
+
|
72
|
+
require 'rubygems'
|
73
|
+
gem 'soap4r'
|
74
|
+
|
75
|
+
This must be done before Rails starts auto-loading things.
|
76
|
+
|
77
|
+
Additionally, you have to put those two lines in *every* Rails app you have
|
78
|
+
on your machine, even if it doesn't use SOAP4R! This is, allegedly, because
|
79
|
+
ActiveSupport (in dependency.rb) wrongly loads the SOAP4R included with Ruby
|
80
|
+
instead of your Gem. More details can be found here:
|
81
|
+
|
82
|
+
http://dev.ctor.org/soap4r/ticket/433
|
57
83
|
|
58
|
-
|
84
|
+
If you get this error, or similar, in every Rails app::
|
59
85
|
|
60
|
-
|
61
|
-
cvs -d :pserver:anonymous@rubyforge.org:/var/cvs/ebay4r checkout ebay4r
|
86
|
+
[...]/activesupport-1.4.2/lib/active_support/dependencies.rb:477:in `const_missing': uninitialized constant XSD::NS::KNOWN_TAG (NameError?)
|
62
87
|
|
88
|
+
you've hit this problem.
|
63
89
|
|
64
|
-
== Getting Started
|
65
90
|
|
66
|
-
|
91
|
+
Getting Started
|
92
|
+
---------------
|
93
|
+
|
94
|
+
If you installed eBay4R from a tarball or git repo, you will want to add the
|
67
95
|
ebay4r/lib directory to your Ruby include path ($RUBYLIB). Then put
|
68
96
|
|
69
|
-
|
97
|
+
::
|
70
98
|
|
99
|
+
require 'eBayAPI'
|
100
|
+
|
71
101
|
at the top of your programs.
|
72
102
|
|
73
103
|
If you installed eBay4R with RubyGems, you don't have to add anything to
|
74
104
|
Ruby's include path, just put
|
75
105
|
|
106
|
+
::
|
107
|
+
|
76
108
|
require 'rubygems'
|
77
|
-
|
109
|
+
gem 'ebay'
|
78
110
|
|
79
111
|
at the top of your programs.
|
80
112
|
|
81
|
-
|
113
|
+
Examples
|
114
|
+
--------
|
82
115
|
|
83
116
|
Look at the examples/ directory. Edit the file myCredentials.rb and insert
|
84
117
|
the appropriate values. Then you can run any of the example programs.
|
85
118
|
|
86
|
-
|
119
|
+
Hello, World!
|
120
|
+
~~~~~~~~~~~~~
|
87
121
|
|
88
122
|
The simplest eBay API call is "GeteBayOfficialTime". Here's how to call it
|
89
|
-
with eBay4R
|
123
|
+
with eBay4R::
|
90
124
|
|
91
125
|
require 'rubygems'
|
92
|
-
|
126
|
+
gem 'ebay'
|
93
127
|
|
94
128
|
# Put your credentials in this file
|
95
129
|
load('myCredentials.rb')
|
@@ -104,72 +138,60 @@ with eBay4R:
|
|
104
138
|
|
105
139
|
# Wasn't that easy?!
|
106
140
|
|
107
|
-
|
141
|
+
Adding an Item
|
142
|
+
~~~~~~~~~~~~~~
|
108
143
|
|
109
|
-
This is a more complex example that performs a real (useful) function
|
144
|
+
This is a more complex example that performs a real (useful) function::
|
110
145
|
|
111
146
|
require 'rubygems'
|
112
|
-
|
147
|
+
gem 'ebay'
|
113
148
|
|
114
149
|
load('myCredentials.rb')
|
115
150
|
|
116
151
|
eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
|
117
152
|
|
118
153
|
# Notice how we nest hashes to mimic the XML structure of an AddItem request
|
119
|
-
resp = eBay.AddItem(:Item => { :PrimaryCategory => { :CategoryID => 57882 },
|
120
|
-
:Title => 'Mouse Pad',
|
121
|
-
:Description => 'A really cool mouse pad, you know you want it...',
|
122
|
-
:Location => 'On Earth',
|
123
|
-
:StartPrice => 12.0,
|
124
|
-
:Quantity => 1,
|
125
|
-
:ListingDuration => "Days_7",
|
126
|
-
:Country => "US",
|
127
|
-
:Currency => "USD",
|
128
|
-
:PaymentMethods => ["VisaMC", "PersonalCheck"] })
|
129
|
-
|
130
|
-
puts "New Item #" + resp.itemID + " added."
|
131
|
-
|
132
|
-
The way we nest hashes in the above AddItem() call may be confusing at first.
|
133
|
-
It is just a short-hand way of creating the complex types we need for the
|
134
|
-
call.
|
135
|
-
|
136
|
-
You may instead explicitly create the complex types (see "Creating Complex
|
137
|
-
Data Types" below) needed for the call (it makes the code longer, but a bit
|
138
|
-
more readable):
|
139
|
-
|
140
154
|
resp = eBay.AddItem(:Item => EBay.Item(:PrimaryCategory => EBay.Category(:CategoryID => 57882),
|
141
155
|
:Title => 'Mouse Pad',
|
142
156
|
:Description => 'A really cool mouse pad, you know you want it...',
|
143
157
|
:Location => 'On Earth',
|
144
|
-
:StartPrice => 12.0,
|
158
|
+
:StartPrice => '12.0',
|
145
159
|
:Quantity => 1,
|
146
160
|
:ListingDuration => "Days_7",
|
147
161
|
:Country => "US",
|
148
162
|
:Currency => "USD",
|
149
163
|
:PaymentMethods => ["VisaMC", "PersonalCheck"]))
|
150
164
|
|
165
|
+
puts "New Item #" + resp.itemID + " added."
|
166
|
+
|
167
|
+
|
168
|
+
Don't worry too much about EBay.Item and EBay.Category calls for now, they are
|
169
|
+
explained in the "Creating Complex Data Types" section below.
|
151
170
|
|
152
|
-
=== Format of Requests
|
153
171
|
|
154
|
-
|
155
|
-
|
172
|
+
Format of Requests
|
173
|
+
~~~~~~~~~~~~~~~~~~
|
174
|
+
|
175
|
+
If ``eBay`` is your caller object, then you can issue any eBay API call
|
176
|
+
by doing::
|
156
177
|
|
157
178
|
eBay.<call_name>( ... hash of named-arguments ... )
|
158
179
|
|
159
|
-
For example, to issue the GetItem call for Item
|
160
|
-
information, you do
|
180
|
+
For example, to issue the GetItem call for Item #4503432058 and return all
|
181
|
+
information, you do::
|
161
182
|
|
162
183
|
eBay.GetItem(:DetailLevel => 'ReturnAll', :ItemID => '4503432058')
|
163
184
|
|
164
|
-
or to see your last invoice using the GetAccount call, you do
|
185
|
+
or to see your last invoice using the GetAccount call, you do::
|
165
186
|
|
166
187
|
eBay.GetAccount(:AccountHistorySelection => 'LastInvoice')
|
167
188
|
|
168
189
|
See the "eBay Web Services SOAP API Guide" for acceptable parameters and values
|
169
190
|
for each API call. This guide can be downloaded at eBay's
|
170
|
-
|
191
|
+
`SOAP Development Center <http://developer.ebay.com/soap/>`_.
|
171
192
|
|
172
|
-
|
193
|
+
Creating Complex Data Types
|
194
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
173
195
|
|
174
196
|
A number of elements in eBay's schema are XML Schema simple types. For
|
175
197
|
example, CategoryID, Title, and Description are all strings. But many
|
@@ -177,18 +199,20 @@ elements, like Item and Seller, are of types "ItemType" and "SellerType",
|
|
177
199
|
respectively. These are complex data types, meaning they are structures
|
178
200
|
composed of collections of simple types.
|
179
201
|
|
180
|
-
"How do I make a complex type object?", you ask. Simple
|
202
|
+
"How do I make a complex type object?", you ask. Simple::
|
181
203
|
|
182
204
|
EBay.<element_name>( ... hash of named-arguments ... )
|
183
205
|
|
184
|
-
creates a new
|
206
|
+
creates a new `<element_name>` element of type ``<element_name>Type``. For
|
185
207
|
example,
|
186
208
|
|
209
|
+
::
|
210
|
+
|
187
211
|
EBay.Item(:Title => 'Mouse Pad', :Description => '...')
|
188
212
|
|
189
|
-
creates a new ItemType object. Please note, these factory methods are class
|
213
|
+
creates a new ``ItemType`` object. Please note, these factory methods are class
|
190
214
|
methods of module EBay, so the upper-case "E" in "EBay" is not a typo. A
|
191
|
-
more common way to see this is
|
215
|
+
more common way to see this is::
|
192
216
|
|
193
217
|
EBay::Item( ... )
|
194
218
|
|
@@ -196,27 +220,29 @@ The only difference is if you do not pass any arguments to the factory method
|
|
196
220
|
and do not explicitly put empty parentheses (), Ruby will assume it is a
|
197
221
|
constant, not a method.
|
198
222
|
|
199
|
-
|
223
|
+
Setting XML Attributes
|
224
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
200
225
|
|
201
|
-
The symbol you use to set an XML attribute on an element is
|
226
|
+
The symbol you use to set an XML attribute on an element is::
|
202
227
|
|
203
228
|
:xmlattr_<attribute_name>
|
204
229
|
|
205
230
|
For example, to create a <Label> element (corresponding to eBay's LabelType)
|
206
|
-
with an attribute of "visible" equal to "true", you would do
|
231
|
+
with an attribute of "visible" equal to "true", you would do::
|
207
232
|
|
208
233
|
EBay.Label(:Name => "some string", :xmlattr_visible => true)
|
209
234
|
|
210
235
|
|
211
|
-
|
236
|
+
Format of Responses
|
237
|
+
~~~~~~~~~~~~~~~~~~~
|
212
238
|
|
213
239
|
There is a one-to-one correspondence between the XML returned by eBay and the
|
214
240
|
way you access the values contained therein using the response object returned
|
215
|
-
by the call. For example, let's say you issued a "GetItem" call
|
241
|
+
by the call. For example, let's say you issued a "GetItem" call::
|
216
242
|
|
217
243
|
resp = eBay.GetItem(:DetailLevel => 'ReturnAll', :ItemID => '4503432058')
|
218
244
|
|
219
|
-
and eBay returned the following XML (abbreviated where appropriate)
|
245
|
+
and eBay returned the following XML (abbreviated where appropriate)::
|
220
246
|
|
221
247
|
<?xml version="1.0" encoding="UTF-8"?>
|
222
248
|
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
@@ -253,22 +279,22 @@ The "resp" object is of type
|
|
253
279
|
|
254
280
|
SOAP::Mapping::Object
|
255
281
|
|
256
|
-
and contains all the XML elements between
|
282
|
+
and contains all the XML elements between ``<GetItemResponse> ... </GetItemResponse>``.
|
257
283
|
|
258
|
-
So, if you want to print the item description, just do
|
284
|
+
So, if you want to print the item description, just do::
|
259
285
|
|
260
286
|
puts resp.item.description
|
261
287
|
|
262
|
-
and you will see
|
288
|
+
and you will see::
|
263
289
|
|
264
290
|
"Fund. of Physics, 5th, by Halliday, Resnick, Walker"
|
265
291
|
|
266
292
|
Repeated XML elements automatically become arrays of the same name, so to see
|
267
|
-
all the locations this item can ship to, just do
|
293
|
+
all the locations this item can ship to, just do::
|
268
294
|
|
269
295
|
resp.item.shipToLocations.each { |loc| puts loc }
|
270
296
|
|
271
|
-
and you will see
|
297
|
+
and you will see::
|
272
298
|
|
273
299
|
US
|
274
300
|
CA
|
@@ -276,7 +302,8 @@ and you will see:
|
|
276
302
|
It's that easy! (Are any Java or C# developers reading this? Don't be
|
277
303
|
jealous... ;)
|
278
304
|
|
279
|
-
|
305
|
+
A Note about Case
|
306
|
+
~~~~~~~~~~~~~~~~~
|
280
307
|
|
281
308
|
Astute readers (all of you, right?) will notice that the first letter of every
|
282
309
|
element contained within the response object is lower-case, even though in the
|
@@ -295,22 +322,23 @@ bottom).
|
|
295
322
|
|
296
323
|
Please note, the opposite does _not_ apply. That is, you can *submit* a call
|
297
324
|
using either case of the first character, and your arguments can also have
|
298
|
-
either case letter first. For example, this
|
325
|
+
either case letter first. For example, this::
|
299
326
|
|
300
327
|
resp = eBay.GetItem(:DetailLevel => 'ReturnAll', :ItemID => '4503432058')
|
301
328
|
|
302
|
-
is the same as
|
329
|
+
is the same as::
|
303
330
|
|
304
331
|
resp = eBay.getItem(:detailLevel => 'ReturnAll', :itemID => '4503432058')
|
305
332
|
|
306
333
|
|
307
|
-
|
334
|
+
Debugging
|
335
|
+
---------
|
308
336
|
|
309
|
-
If "eBay" is your eBay caller object, as in
|
337
|
+
If "eBay" is your eBay caller object, as in::
|
310
338
|
|
311
339
|
eBay = EBay::API.new( ... )
|
312
340
|
|
313
|
-
You can see XML wiredumps by doing
|
341
|
+
You can see XML wiredumps by doing::
|
314
342
|
|
315
343
|
eBay.debug = true
|
316
344
|
|
@@ -318,7 +346,8 @@ before you issue any eBay API calls. This is useful to see the raw XML of
|
|
318
346
|
what eBay is sending back to you.
|
319
347
|
|
320
348
|
|
321
|
-
|
349
|
+
Files
|
350
|
+
-----
|
322
351
|
|
323
352
|
contrib/
|
324
353
|
Extras contributed by the community (myself included)
|
@@ -343,13 +372,15 @@ test/
|
|
343
372
|
Unit and functional tests
|
344
373
|
|
345
374
|
|
346
|
-
|
375
|
+
To Do
|
376
|
+
-----
|
347
377
|
|
348
378
|
* Add many more examples
|
349
379
|
* Add more unit and functional tests
|
350
380
|
|
351
381
|
|
352
|
-
|
382
|
+
Author
|
383
|
+
------
|
353
384
|
|
354
385
|
Garry C. Dolley
|
355
386
|
|
@@ -357,10 +388,27 @@ gdolley [at] NOSPAM- ucla.edu
|
|
357
388
|
|
358
389
|
AIM: garry97531
|
359
390
|
|
391
|
+
IRC: up_the_irons in #ram, #git, #caboose on Freenode (and usually many other
|
392
|
+
channels)
|
393
|
+
|
394
|
+
|
395
|
+
Formatting
|
396
|
+
----------
|
397
|
+
|
398
|
+
I've dropped RDoc formatting for this README. Headings never looked like
|
399
|
+
headings to me, which was annoying.
|
400
|
+
|
401
|
+
This README is formatted in reStructredText [RST]_. It has the best
|
402
|
+
correlation between what a document looks like as plain text vs. its
|
403
|
+
formatted output (HTML, LaTeX, etc...). What I like best is, markup doesn't
|
404
|
+
look like markup, even though it is.
|
405
|
+
|
406
|
+
.. [RST] http://docutils.sourceforge.net/rst.html
|
360
407
|
|
361
|
-
|
408
|
+
Copyright
|
409
|
+
---------
|
362
410
|
|
363
|
-
Copyright (c) 2005,2006 Garry C. Dolley
|
411
|
+
Copyright (c) 2005,2006,2007,2008 Garry C. Dolley
|
364
412
|
|
365
413
|
eBay4R is free software; you can redistribute it and/or modify it under the
|
366
414
|
terms of the GNU General Public License as published by the Free Software
|
@@ -376,4 +424,3 @@ You should have received a copy of the GNU General Public License along with
|
|
376
424
|
eBay4R; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
377
425
|
Street, Fifth Floor, Boston, MA 02110-1301, USA
|
378
426
|
|
379
|
-
$Id: README,v 1.19 2006/10/10 08:39:11 garrydolley Exp $
|
@@ -1,3 +1,7 @@
|
|
1
|
+
[Author's note: the example code for SetNotificationPreferences below is old
|
2
|
+
and won't work with eBay4R v1.0 or above. See
|
3
|
+
examples/set_notification_preferences.rb for a more up-to-date code sample]
|
4
|
+
|
1
5
|
Below is a bit of documentation contributed by David Balatero regarding eBay
|
2
6
|
Platform Notifications:
|
3
7
|
|