ebay4r 2.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0264e5eb2508258a39e4f73c80bfb5d939b71c55
4
+ data.tar.gz: 24f30247dfdc6c3154d44dbf39ccfe02047ec653
5
+ SHA512:
6
+ metadata.gz: ca9cbc22993458d63d83b4f8bcc06e29df187137b515035c7248655b60df34fbdeb4cca0fc8d1e0b31f0deecf9dd8fdfb3f0b1d27e428efccf58ed8b9b8805ce
7
+ data.tar.gz: 15ddbc27f9a043647e4b100eccc8110e9c18972e0a5a13ca464944b73cd6b9a3c09cc3e3d7e6ba4cd8e08e5c6e0315c5230134fac482891e8bff31895ab44a6e
data/README ADDED
@@ -0,0 +1,426 @@
1
+ =================
2
+ Welcome to eBay4R
3
+ =================
4
+
5
+ :Author: Garry Dolley
6
+ :Date: 03-28-2008
7
+ :Version: v1.1
8
+ :eBay API: 555
9
+
10
+ eBay4R is a Ruby wrapper for eBay's Web Services SOAP API (v555). Emphasis is
11
+ on ease of use and small footprint.
12
+
13
+ Please report bugs and other problems, see "Author" section at the bottom.
14
+
15
+ Current release can be downloaded from:
16
+
17
+ http://rubyforge.org/projects/ebay4r
18
+
19
+ The latest code is in the following Git repository:
20
+
21
+ git://github.com/up_the_irons/ebay4r.git
22
+
23
+
24
+ Requirements
25
+ ------------
26
+
27
+ * SOAP4R library v1.5.7 or newer. The specific version I'm using for testing
28
+ is soap4r-1.5.7.90.20070921.
29
+
30
+
31
+ Optionals
32
+ ---------
33
+
34
+ * RubyGems
35
+
36
+
37
+ Installation
38
+ ------------
39
+
40
+ tar/gzip
41
+ ~~~~~~~~
42
+
43
+ Just unzip the archive anywhere you like, and see "Getting Started" below
44
+ (you will need to add the ebay4r/lib path to your $RUBYLIB environment
45
+ variable)
46
+
47
+ RubyGems
48
+ ~~~~~~~~
49
+
50
+ * To install a gem you already downloaded::
51
+
52
+ gem install ebay-<version>.gem
53
+
54
+ * For the latest release with no fuss (previous download not required)::
55
+
56
+ gem install -r ebay
57
+
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
83
+
84
+ If you get this error, or similar, in every Rails app::
85
+
86
+ [...]/activesupport-1.4.2/lib/active_support/dependencies.rb:477:in `const_missing': uninitialized constant XSD::NS::KNOWN_TAG (NameError?)
87
+
88
+ you've hit this problem.
89
+
90
+
91
+ Getting Started
92
+ ---------------
93
+
94
+ If you installed eBay4R from a tarball or git repo, you will want to add the
95
+ ebay4r/lib directory to your Ruby include path ($RUBYLIB). Then put
96
+
97
+ ::
98
+
99
+ require 'eBayAPI'
100
+
101
+ at the top of your programs.
102
+
103
+ If you installed eBay4R with RubyGems, you don't have to add anything to
104
+ Ruby's include path, just put
105
+
106
+ ::
107
+
108
+ require 'rubygems'
109
+ gem 'ebay'
110
+
111
+ at the top of your programs.
112
+
113
+ Examples
114
+ --------
115
+
116
+ Look at the examples/ directory. Edit the file myCredentials.rb and insert
117
+ the appropriate values. Then you can run any of the example programs.
118
+
119
+ Hello, World!
120
+ ~~~~~~~~~~~~~
121
+
122
+ The simplest eBay API call is "GeteBayOfficialTime". Here's how to call it
123
+ with eBay4R::
124
+
125
+ require 'rubygems'
126
+ gem 'ebay'
127
+
128
+ # Put your credentials in this file
129
+ load('myCredentials.rb')
130
+
131
+ # Create new eBay caller object. Omit last argument to use live platform.
132
+ eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
133
+
134
+ resp = eBay.GeteBayOfficialTime
135
+
136
+ puts "Hello, World!"
137
+ puts "The eBay time is now: #{resp.timestamp}"
138
+
139
+ # Wasn't that easy?!
140
+
141
+ Adding an Item
142
+ ~~~~~~~~~~~~~~
143
+
144
+ This is a more complex example that performs a real (useful) function::
145
+
146
+ require 'rubygems'
147
+ gem 'ebay'
148
+
149
+ load('myCredentials.rb')
150
+
151
+ eBay = EBay::API.new($authToken, $devId, $appId, $certId, :sandbox => true)
152
+
153
+ # Notice how we nest hashes to mimic the XML structure of an AddItem request
154
+ resp = eBay.AddItem(:Item => EBay.Item(:PrimaryCategory => EBay.Category(:CategoryID => 57882),
155
+ :Title => 'Mouse Pad',
156
+ :Description => 'A really cool mouse pad, you know you want it...',
157
+ :Location => 'On Earth',
158
+ :StartPrice => '12.0',
159
+ :Quantity => 1,
160
+ :ListingDuration => "Days_7",
161
+ :Country => "US",
162
+ :Currency => "USD",
163
+ :PaymentMethods => ["VisaMC", "PersonalCheck"]))
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.
170
+
171
+
172
+ Format of Requests
173
+ ~~~~~~~~~~~~~~~~~~
174
+
175
+ If ``eBay`` is your caller object, then you can issue any eBay API call
176
+ by doing::
177
+
178
+ eBay.<call_name>( ... hash of named-arguments ... )
179
+
180
+ For example, to issue the GetItem call for Item #4503432058 and return all
181
+ information, you do::
182
+
183
+ eBay.GetItem(:DetailLevel => 'ReturnAll', :ItemID => '4503432058')
184
+
185
+ or to see your last invoice using the GetAccount call, you do::
186
+
187
+ eBay.GetAccount(:AccountHistorySelection => 'LastInvoice')
188
+
189
+ See the "eBay Web Services SOAP API Guide" for acceptable parameters and values
190
+ for each API call. This guide can be downloaded at eBay's
191
+ `SOAP Development Center <http://developer.ebay.com/soap/>`_.
192
+
193
+ Creating Complex Data Types
194
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
195
+
196
+ A number of elements in eBay's schema are XML Schema simple types. For
197
+ example, CategoryID, Title, and Description are all strings. But many
198
+ elements, like Item and Seller, are of types "ItemType" and "SellerType",
199
+ respectively. These are complex data types, meaning they are structures
200
+ composed of collections of simple types.
201
+
202
+ "How do I make a complex type object?", you ask. Simple::
203
+
204
+ EBay.<element_name>( ... hash of named-arguments ... )
205
+
206
+ creates a new `<element_name>` element of type ``<element_name>Type``. For
207
+ example,
208
+
209
+ ::
210
+
211
+ EBay.Item(:Title => 'Mouse Pad', :Description => '...')
212
+
213
+ creates a new ``ItemType`` object. Please note, these factory methods are class
214
+ methods of module EBay, so the upper-case "E" in "EBay" is not a typo. A
215
+ more common way to see this is::
216
+
217
+ EBay::Item( ... )
218
+
219
+ The only difference is if you do not pass any arguments to the factory method
220
+ and do not explicitly put empty parentheses (), Ruby will assume it is a
221
+ constant, not a method.
222
+
223
+ Setting XML Attributes
224
+ ~~~~~~~~~~~~~~~~~~~~~~
225
+
226
+ The symbol you use to set an XML attribute on an element is::
227
+
228
+ :xmlattr_<attribute_name>
229
+
230
+ For example, to create a <Label> element (corresponding to eBay's LabelType)
231
+ with an attribute of "visible" equal to "true", you would do::
232
+
233
+ EBay.Label(:Name => "some string", :xmlattr_visible => true)
234
+
235
+
236
+ Format of Responses
237
+ ~~~~~~~~~~~~~~~~~~~
238
+
239
+ There is a one-to-one correspondence between the XML returned by eBay and the
240
+ way you access the values contained therein using the response object returned
241
+ by the call. For example, let's say you issued a "GetItem" call::
242
+
243
+ resp = eBay.GetItem(:DetailLevel => 'ReturnAll', :ItemID => '4503432058')
244
+
245
+ and eBay returned the following XML (abbreviated where appropriate)::
246
+
247
+ <?xml version="1.0" encoding="UTF-8"?>
248
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
249
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
250
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
251
+ <soapenv:Body>
252
+ <GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
253
+ <Timestamp>2005-12-09T09:40:41.602Z</Timestamp>
254
+ <Ack>Success</Ack>
255
+ <Version>437</Version>
256
+ <Build>e437_core_Bundled_2119808_R1</Build>
257
+ <Item>
258
+ ...
259
+
260
+ <AutoPay>false</AutoPay>
261
+ <BuyerProtection>ItemIneligible</BuyerProtection>
262
+ <BuyItNowPrice currencyID="USD">0.0</BuyItNowPrice>
263
+ <Country>US</Country>
264
+ <Currency>USD</Currency>
265
+ <Description>Fund. of Physics, 5th, by Halliday, Resnick, Walker</Description>
266
+ <Escrow>None</Escrow>
267
+ <GiftIcon>0</GiftIcon>
268
+ ...
269
+
270
+ <ShipToLocations>US</ShipToLocations>
271
+ <ShipToLocations>CA</ShipToLocations>
272
+ </Item>
273
+ </GetItemResponse>
274
+ </soapenv:Body>
275
+ </soapenv:Envelope>
276
+
277
+
278
+ The "resp" object is of type
279
+
280
+ SOAP::Mapping::Object
281
+
282
+ and contains all the XML elements between ``<GetItemResponse> ... </GetItemResponse>``.
283
+
284
+ So, if you want to print the item description, just do::
285
+
286
+ puts resp.item.description
287
+
288
+ and you will see::
289
+
290
+ "Fund. of Physics, 5th, by Halliday, Resnick, Walker"
291
+
292
+ Repeated XML elements automatically become arrays of the same name, so to see
293
+ all the locations this item can ship to, just do::
294
+
295
+ resp.item.shipToLocations.each { |loc| puts loc }
296
+
297
+ and you will see::
298
+
299
+ US
300
+ CA
301
+
302
+ It's that easy! (Are any Java or C# developers reading this? Don't be
303
+ jealous... ;)
304
+
305
+ A Note about Case
306
+ ~~~~~~~~~~~~~~~~~
307
+
308
+ Astute readers (all of you, right?) will notice that the first letter of every
309
+ element contained within the response object is lower-case, even though in the
310
+ XML it is upper-case. This is currently the way things are and you will have
311
+ to remember to lower the first character in your code.
312
+
313
+ Ruby's convention is that only classes, modules, and constants begin with
314
+ upper-case letters. The author of the SOAP4R library (which contains
315
+ wsdl2ruby.rb) respected this convention, and as a result, the eBay.rb
316
+ file I use (generated from eBay's WSDL) has this mapping.
317
+
318
+ I haven't come up with any Ruby magic to dynamically allow upper-case first
319
+ characters to work also, so if you happen to want to take a crack at it and
320
+ get it working, please send me your patches (see "Author" section at the
321
+ bottom).
322
+
323
+ Please note, the opposite does _not_ apply. That is, you can *submit* a call
324
+ using either case of the first character, and your arguments can also have
325
+ either case letter first. For example, this::
326
+
327
+ resp = eBay.GetItem(:DetailLevel => 'ReturnAll', :ItemID => '4503432058')
328
+
329
+ is the same as::
330
+
331
+ resp = eBay.getItem(:detailLevel => 'ReturnAll', :itemID => '4503432058')
332
+
333
+
334
+ Debugging
335
+ ---------
336
+
337
+ If "eBay" is your eBay caller object, as in::
338
+
339
+ eBay = EBay::API.new( ... )
340
+
341
+ You can see XML wiredumps by doing::
342
+
343
+ eBay.debug = true
344
+
345
+ before you issue any eBay API calls. This is useful to see the raw XML of
346
+ what eBay is sending back to you.
347
+
348
+
349
+ Files
350
+ -----
351
+
352
+ contrib/
353
+ Extras contributed by the community (myself included)
354
+
355
+ examples/
356
+ Examples of eBay API calls using this library. You will want to check out
357
+ these examples before making your own calls.
358
+
359
+ lib/eBayAPI.rb
360
+ The heart of this library
361
+
362
+ lib/eBayDriver.rb
363
+ Autogenerated by wsdl2ruby.rb
364
+
365
+ lib/eBay.rb
366
+ Autogenerated by wsdl2ruby.rb
367
+
368
+ lib/RequesterCredentialsHandler.rb
369
+ Helper for generating the eBay Authentication header for each call
370
+
371
+ test/
372
+ Unit and functional tests
373
+
374
+
375
+ To Do
376
+ -----
377
+
378
+ * Add many more examples
379
+ * Add more unit and functional tests
380
+
381
+
382
+ Author
383
+ ------
384
+
385
+ Garry C. Dolley
386
+
387
+ gdolley [at] NOSPAM- ucla.edu
388
+
389
+ AIM: garry97531
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
407
+
408
+ Copyright
409
+ ---------
410
+
411
+ Copyright (c) 2005,2006,2007,2008 Garry C. Dolley
412
+
413
+ eBay4R is free software; you can redistribute it and/or modify it under the
414
+ terms of the GNU General Public License as published by the Free Software
415
+ Foundation; either version 2 of the License, or (at your option) any later
416
+ version.
417
+
418
+ eBay4R is distributed in the hope that it will be useful, but WITHOUT ANY
419
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
420
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
421
+ details.
422
+
423
+ You should have received a copy of the GNU General Public License along with
424
+ eBay4R; if not, write to the Free Software Foundation, Inc., 51 Franklin
425
+ Street, Fifth Floor, Boston, MA 02110-1301, USA
426
+
@@ -0,0 +1,68 @@
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
+
5
+ Below is a bit of documentation contributed by David Balatero regarding eBay
6
+ Platform Notifications:
7
+
8
+ Tips on how to handle eBay Platform Notifications within a Rails app
9
+ ====================================================================
10
+
11
+ One quick way to handle incoming notifications from eBay is to setup a Rails
12
+ controller to receive them. There are a few tricks you need to do in order to
13
+ receive them, however.
14
+
15
+ 1. First, you need to create a controller.
16
+
17
+ script/generate controller Ebay
18
+
19
+ 2. Next, you need to tell eBay to send all notifications to this new controller.
20
+ You can do this from script/console, if you want (just make sure that in the
21
+ console, you load the appropriate eBay4r classes)
22
+
23
+ {{{
24
+ @ebay = EBay::API.new('auth_token', 'dev_id', 'app_id', 'cert_id', :sandbox => true)
25
+ resp = @ebay.SetNotificationPreferences(:ApplicationDeliveryPreferences => {
26
+ :ApplicationEnable => 'Enable',
27
+ :ApplicationURL => 'http://' + request.env["SERVER_NAME"] + '/ebay/notification',
28
+ :NotificationPayloadType => 'eBLSchemaSOAP' },
29
+ :UserDeliveryPreferenceArray => {
30
+ :NotificationEnable => [
31
+ { :EventEnable => 'Enable',
32
+ :EventType => 'EndOfAuction' },
33
+ { :EventEnable => 'Enable',
34
+ :EventType => 'Feedback' },
35
+ { :EventEnable => 'Enable',
36
+ :EventType => 'AskSellerQuestion' }
37
+ ]
38
+ })
39
+ }}}
40
+
41
+ 3. Finally, you need to write some controller methods to handle the incoming notifications.
42
+
43
+ {{{
44
+ def notification
45
+ # Grab the raw SOAP XML into a string
46
+ post_data = request.raw_post
47
+
48
+ # Unmarshal the XML into a SOAP object
49
+ resp = SOAP::Marshal.unmarshal(post_data)
50
+
51
+ # Now it's business as usual -- use the resp object like you would
52
+ # use any outgoing eBay call object.
53
+
54
+ case resp.notificationEventName
55
+ when 'AskSellerQuestion'
56
+ # code here
57
+ when 'EndOfAuction'
58
+ # end of auction code
59
+ when 'Feedback'
60
+ # feedback received code
61
+ end
62
+ end
63
+ }}}
64
+
65
+
66
+ Hope this helps!
67
+
68
+ - David Balatero ezwelty [at] NOSPAM- u.washington.edu